aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/icrowley/fake/internet.go
blob: 8fd1c2736e66f7e61d4a100842271e8f6b02d927 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package fake

import (
	"net"
	"strings"

	"github.com/corpix/uarand"
)

// UserName generates user name in one of the following forms
// first name + last name, letter + last names or concatenation of from 1 to 3 lowercased words
func UserName() string {
	gender := randGender()
	switch r.Intn(3) {
	case 0:
		return lookup("en", gender+"_first_names", false) + lookup(lang, gender+"_last_names", false)
	case 1:
		return Character() + lookup(lang, gender+"_last_names", false)
	default:
		return strings.Replace(WordsN(r.Intn(3)+1), " ", "_", -1)
	}
}

// TopLevelDomain generates random top level domain
func TopLevelDomain() string {
	return lookup(lang, "top_level_domains", true)
}

// DomainName generates random domain name
func DomainName() string {
	return Company() + "." + TopLevelDomain()
}

// EmailAddress generates email address
func EmailAddress() string {
	return UserName() + "@" + DomainName()
}

// EmailSubject generates random email subject
func EmailSubject() string {
	return Sentence()
}

// EmailBody generates random email body
func EmailBody() string {
	return Paragraphs()
}

// DomainZone generates random domain zone
func DomainZone() string {
	return lookup(lang, "domain_zones", true)
}

// IPv4 generates IPv4 address
func IPv4() string {
	size := 4
	ip := make([]byte, size)
	for i := 0; i < size; i++ {
		ip[i] = byte(r.Intn(256))
	}
	return net.IP(ip).To4().String()
}

// IPv6 generates IPv6 address
func IPv6() string {
	size := 16
	ip := make([]byte, size)
	for i := 0; i < size; i++ {
		ip[i] = byte(r.Intn(256))
	}
	return net.IP(ip).To16().String()
}

// UserAgent generates a random user agent.
func UserAgent() string {
	return uarand.GetRandom()
}