Compare commits

...

2 Commits

Author SHA1 Message Date
Charles Iliya Krempeaux 5b0908e842 InternetHostName() 2024-08-26 15:53:38 -07:00
Charles Iliya Krempeaux 1f5dcd5b8a pct-encoded 2024-08-26 15:15:24 -07:00
3 changed files with 206 additions and 1 deletions

View File

@ -21,6 +21,11 @@ func HTMLFile() fs.File {
return Default.HTMLFile()
}
// InternetHostName returns an arbitrary Internet hostname.
func InternetHostName() string {
return Default.InternetHostName()
}
// NetAddr returns an arbitrary net.Addr.
func NetAddr() net.Addr {
return Default.NetAddr()
@ -36,7 +41,7 @@ func Password() string {
return Default.Password()
}
// Password returns an arbitrary pct-encoded.
// PctEncoded returns an arbitrary pct-encoded.
func PctEncoded() string {
return Default.PctEncoded()
}

View File

@ -0,0 +1,44 @@
package arbitrary
import (
"fmt"
"strings"
)
// InternetHostName returns an arbitrary Internet hostname.
func (arb T) InternetHostName() string {
var partchars string = "0123456789abcdefghijklmnopqrstuvwxyz"
var tld string = tlds[arb.randomness.Intn(len(tlds))]
var parts []string
{
var numparts int = 1 + arb.randomness.Intn(3)
for i:=0; i<numparts; i++ {
var part string
if arb.Bool() {
var partlen int = 1 + arb.randomness.Intn(63)
part = arb.String(partlen, partchars)
} else {
part = wordsEnglish[arb.randomness.Intn(len(wordsEnglish))]
if 0 == (arb.randomness.Int() % 10) {
part += fmt.Sprintf("-%d", arb.randomness.Intn(1000))
}
}
parts = append(parts, part)
}
}
parts = append(parts, tld)
return strings.Join(parts, ".")
}

156
tlds.go 100644
View File

@ -0,0 +1,156 @@
package arbitrary
var tlds = []string{
"academy",
"accountant",
"accountants",
"active",
"actor",
"ads",
"adult",
"aero",
"africa",
"agency",
"amazon",
"analytics",
"apartments",
"app",
"apple",
"art",
"arpa",
"audible",
"author",
"auto",
"autos",
"baby",
"banana",
"band",
"bank",
"bbs",
"bio",
"black",
"blog",
"blue",
"boo",
"book",
"bot",
"call",
"camp",
"car",
"cars",
"chat",
"cherry",
"city",
"com",
"cool",
"click",
"computer",
"data",
"day",
"dev",
"directory",
"diy",
"dot",
"edu",
"fail",
"farm",
"fire",
"fish",
"free",
"fun",
"fyi",
"game",
"games",
"gov",
"green",
"group",
"int",
"help",
"here",
"host",
"info",
"kim",
"land",
"link",
"live",
"lol",
"meet",
"mil",
"monster",
"name",
"net",
"network",
"ninja",
"now",
"one",
"open",
"org",
"page",
"pay",
"phone",
"photo",
"photography",
"photos",
"pics",
"pictures",
"pizza",
"plus",
"post",
"pub",
"radio",
"read",
"red",
"report",
"rocks",
"room",
"run",
"save",
"science",
"select",
"show",
"site",
"social",
"software",
"solar",
"song",
"spot",
"store",
"stream",
"studio",
"style",
"sucks",
"support",
"talk",
"taxi",
"team",
"tech",
"technology",
"tel",
"tips",
"today",
"tools",
"top",
"town",
"toys",
"travel",
"trust",
"tube",
"video",
"vision",
"webcam",
"website",
"wedding",
"whoswho",
"wiki",
"win",
"work",
"works",
"world",
"wow",
"wtf",
"you",
"zero",
"zip",
"zone",
"xxx",
}