diff --git a/internal/config/config.go b/internal/config/config.go index 7653479..83c86fb 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -7,9 +7,10 @@ import ( "os" "path/filepath" "slices" - "strings" "time" + words "go.datum.net/network-services-operator/internal/words" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -538,7 +539,9 @@ func (c *GatewayConfig) ShouldDeleteErroredChallenges() bool { } func (c *GatewayConfig) GatewayDNSAddress(gateway *gatewayv1.Gateway) string { - return fmt.Sprintf("%s.%s", strings.ReplaceAll(string(gateway.UID), "-", ""), c.TargetDomain) + seed := string(gateway.UID) + suffix := fmt.Sprintf(".%s", c.TargetDomain) + return words.WordsAndEntropy(suffix, seed) } func (c *GatewayConfig) ConnectorTunnelListenerName() string { diff --git a/internal/words/words.go b/internal/words/words.go new file mode 100644 index 0000000..83c0db2 --- /dev/null +++ b/internal/words/words.go @@ -0,0 +1,315 @@ +package words + +import ( + "fmt" + "math/rand" +) + +// Generate a number out of a string +func stringInt64(s string) int64 { + var n int64 + for _, b := range []byte(s) { + n = n*31 + int64(b) + } + return n +} + +// Create a random string using a mixture of two english words and 5 +// bytes of entropy (no vowels, no ambiguous chars). +// +// This provides 340 trillion possible strings: +// - 5 char hash: 45M +// - ~2800 words, picking 2 at a time (ordered, permutation): 7.5M +// - 45M * 7.5M ~= 340T +func WordsAndEntropy(suffix, seedString string) string { + r := rand.New(rand.NewSource(stringInt64(seedString))) + + hashChars := make([]byte, 5) + charset := "bcdfghjkmnpqrstvwxyz23456789" + for i := range hashChars { + hashChars[i] = charset[r.Intn(len(charset))] + } + + word1 := DictionaryWords[r.Intn(len(DictionaryWords))] + word2 := DictionaryWords[r.Intn(len(DictionaryWords))] + + return fmt.Sprintf("%s-%s-%s%s", word1, word2, string(hashChars), suffix) +} + +var DictionaryWords = []string{ + "stark", "threat", "weave", "clear", "donut", "ham", "sat", "tracks", "lost", "crown", + "dizzy", "gummy", "raven", "transit", "camp", "flow", "flake", "realm", "strain", "milk", + "most", "lunch", "noble", "shrink", "toy", "module", "stop", "mouth", "object", "shall", + "van", "decade", "text", "facet", "fatty", "spite", "woman", "bath", "twirl", "worry", + "finger", "done", "swim", "unit", "person", "pride", "village", "door", "drug", "scrap", + "strife", "during", "drive", "jade", "pan", "pledge", "trap", "variable", "critic", "tackle", + "hairy", "rotate", "shine", "prop", "show", "grave", "input", "switch", "tweed", "dodge", + "flung", "timber", "weigh", "located", "hold", "iron", "jeans", "seize", "unreal", "varied", + "gold", "crater", "infra", "petite", "sonic", "fancy", "health", "poker", "unable", "yellow", + "earn", "them", "normal", "satin", "tool", "user", "husky", "lean", "tonic", "turtle", + "unmarried", "besides", "fetch", "reckon", "either", "flock", "gadget", "govern", "great", "omen", + "stall", "wolf", "honest", "fail", "term", "stiff", "struck", "yet", "baby", "pink", + "crank", "strip", "stuff", "throw", "world", "hush", "student", "wagon", "jean", "brute", + "lover", "oath", "shell", "under", "worse", "parent", "stay", "verb", "flick", "knit", + "perch", "waste", "longer", "firm", "horse", "lynx", "sum", "usage", "choice", "ford", + "late", "link", "pack", "warm", "hyena", "leak", "marry", "embed", "myself", "rat", + "reed", "resort", "carbon", "casual", "flight", "last", "dread", "pint", "steak", "margin", + "diary", "gleam", "pencil", "suds", "tomb", "sexual", "typing", "bomb", "lovely", "low", + "toe", "veto", "ward", "fully", "pop", "their", "account", "farmer", "harm", "groove", + "loop", "monk", "natal", "lawyer", "bone", "blink", "clash", "crisp", "dirty", "log", + "string", "wade", "tariff", "optic", "singer", "regard", "blend", "every", "graph", "guilt", + "sewer", "clown", "result", "stain", "king", "shop", "pendulum", "scalp", "total", "trance", + "coffee", "except", "lake", "juicy", "out", "trial", "budget", "rarely", "easy", "look", + "brush", "diver", "obtain", "circle", "claim", "silicon", "hundred", "motto", "sauna", "soccer", + "spoke", "thrill", "rich", "creep", "dairy", "phone", "shout", "ski", "custom", "devote", + "luck", "rule", "spent", "wheat", "rating", "writer", "empty", "inept", "plaid", "rust", + "strict", "joke", "mint", "stride", "ever", "socket", "star", "ignore", "our", "deal", + "left", "various", "weasel", "advanced", "cold", "giant", "flat", "list", "range", "reap", + "super", "middle", "chart", "glee", "nest", "unwise", "alcohol", "cabinet", "luxury", "mean", + "glen", "gull", "helium", "muster", "ministry", "mile", "beef", "brain", "erase", "found", + "hover", "reel", "toward", "very", "fungi", "grill", "patch", "sun", "temper", "unhealthy", + "subtle", "skin", "work", "siege", "slack", "speed", "walker", "knew", "week", "plow", + "set", "sting", "minute", "ace", "rice", "chord", "comma", "best", "join", "limp", + "spend", "nature", "away", "fine", "hill", "mold", "ray", "servant", "slit", "commit", + "heat", "myth", "over", "wife", "picnic", "preach", "salmon", "sphere", "nose", "decay", + "overt", "period", "pest", "prophet", "steep", "touch", "pose", "sick", "gloom", "prince", + "sharp", "spill", "tease", "rug", "sunny", "balance", "policy", "cost", "ours", "spider", + "client", "pursuit", "trusts", "math", "chair", "murder", "ought", "stance", "tutor", "gender", + "goes", "loan", "oval", "jumpy", "spark", "teach", "smooth", "vampire", "buffer", "museum", + "power", "unlawful", "make", "haunt", "setting", "spike", "zombie", "circuit", "food", "siren", + "slept", "spouse", "symptom", "academy", "lesson", "lights", "cross", "key", "twig", "portal", + "waiting", "jump", "lucid", "reward", "mightily", "back", "cope", "nail", "such", "gorge", + "bottle", "plot", "herpes", "token", "alleged", "port", "polar", "sour", "whip", "feed", + "fishy", "inbox", "lace", "train", "weird", "seat", "review", "palace", "within", "race", + "tale", "dogma", "extra", "label", "prove", "similar", "anybody", "than", "eerie", "inter", + "remit", "shuffle", "skip", "solve", "trigger", "entry", "reach", "raising", "rising", "penalty", + "prefer", "trek", "long", "shore", "whose", "zoom", "airport", "guilty", "measure", "each", + "clock", "dryer", "slang", "closely", "hardly", "hug", "merger", "mild", "relax", "right", + "spear", "value", "wound", "brink", "knight", "nurse", "red", "twice", "dancer", "handy", + "lever", "pedal", "strand", "relate", "speaks", "jelly", "noisy", "one", "diet", "self", + "plunge", "repel", "void", "denied", "home", "sink", "breed", "theme", "tumor", "moving", + "stem", "wing", "float", "grove", "howl", "leaf", "pave", "rotten", "scan", "see", + "squad", "hung", "blast", "heist", "lurk", "muzzle", "calcium", "career", "length", "form", + "board", "hoping", "greed", "moral", "stage", "violin", "just", "gaze", "ignite", "shawl", + "assured", "call", "wall", "heal", "mammal", "nasal", "off", "recruit", "unaware", "band", + "want", "wish", "beech", "gecko", "gross", "wealth", "soul", "clang", "phase", "worst", + "born", "cheek", "grin", "point", "quick", "rhythm", "safety", "tame", "receive", "scale", + "tycoon", "universe", "violet", "vital", "itself", "letter", "main", "plug", "stupid", "unlike", + "versus", "this", "guppy", "often", "vehicle", "african", "chip", "give", "thus", "crowd", + "vendor", "must", "sake", "route", "snake", "mimic", "theory", "think", "broker", "clasp", + "folly", "reign", "resume", "serve", "severe", "enough", "estate", "impose", "lame", "lime", + "bond", "exit", "near", "poll", "fugue", "guild", "hurdle", "hybrid", "minus", "punch", + "rigid", "trade", "mental", "fort", "ring", "straight", "track", "vale", "win", "castle", + "fabric", "ship", "ghost", "launch", "mummy", "pepper", "proud", "mirror", "outcome", "equip", + "ice", "laugh", "rub", "tray", "apparent", "timing", "younger", "major", "situated", "study", + "unhappy", "driver", "spoken", "nice", "draft", "eagle", "quart", "she", "static", "totem", + "paying", "comic", "sense", "dish", "five", "same", "cycle", "record", "visual", "father", + "holy", "weak", "remedy", "skill", "valve", "worth", "stove", "bottom", "path", "donor", + "large", "maple", "march", "tooth", "half", "roof", "went", "color", "micro", "offer", + "shake", "shock", "soon", "incur", "strap", "headed", "kelp", "loose", "settle", "warn", + "keep", "camel", "essay", "force", "scary", "silver", "deep", "film", "issue", "solar", + "even", "grape", "humor", "nanny", "there", "try", "variety", "fence", "trend", "grey", + "neat", "virtue", "find", "frost", "growl", "public", "rhino", "married", "simply", "less", + "grown", "photo", "session", "state", "sweet", "fish", "drink", "foggy", "kiss", "pill", + "stone", "odds", "exist", "plant", "slim", "thaw", "uneven", "ticket", "tank", "candy", + "decoy", "erupt", "fruit", "outer", "prior", "scare", "days", "told", "event", "mural", + "sob", "squid", "stale", "submit", "magic", "stole", "venom", "ember", "gourd", "neither", + "pail", "solely", "ivory", "feel", "kept", "saddle", "shelf", "citizen", "lotus", "recall", + "profit", "update", "trip", "crude", "eater", "rescue", "suck", "flare", "import", "penguin", + "shrug", "tide", "humble", "thrust", "some", "petal", "sweep", "gift", "walk", "chick", + "error", "lung", "orchard", "routine", "tap", "unfair", "backing", "salvage", "server", "transfer", + "seed", "wine", "fatal", "mad", "score", "slab", "tea", "will", "hello", "imp", + "series", "snug", "tag", "heel", "since", "former", "lord", "wash", "hard", "hurt", + "wave", "image", "sword", "victim", "finish", "zone", "flank", "heath", "behalf", "global", + "cave", "view", "nomad", "sad", "slight", "speech", "mice", "happen", "secure", "giddy", + "nothing", "oak", "rebel", "recover", "sheet", "squat", "risk", "glass", "index", "light", + "noodle", "shrine", "sofa", "worm", "chat", "care", "bunch", "owl", "sea", "syrup", + "anyone", "girl", "finer", "ranch", "today", "canal", "pot", "unusual", "lot", "rapid", + "trouble", "write", "golem", "say", "cancer", "wholly", "civil", "flash", "hydro", "hyphen", + "neon", "though", "thrive", "truth", "built", "fifth", "melee", "sport", "tribal", "turkey", + "twin", "crack", "gloss", "kernel", "print", "reply", "scene", "reject", "plus", "clerk", + "heart", "heron", "husband", "german", "replay", "tenant", "repair", "shade", "snarl", "dense", + "flush", "labor", "potter", "rage", "sung", "wreak", "rail", "comet", "drawn", "hare", + "niche", "nudge", "parody", "slash", "case", "operate", "sneak", "space", "vivid", "witch", + "behind", "camera", "talk", "wind", "clout", "dress", "humus", "numb", "proof", "violent", + "shot", "limb", "strike", "tough", "via", "wool", "behave", "belief", "bush", "dying", + "kneel", "prefix", "common", "others", "mate", "top", "online", "acid", "wet", "island", + "heap", "rave", "river", "system", "whale", "trader", "boss", "oblique", "raft", "together", + "poor", "sand", "lumpy", "monthly", "gone", "primary", "swift", "option", "phrase", "then", + "scope", "tear", "tortoise", "utter", "number", "human", "neglect", "target", "master", "book", + "sage", "fewer", "house", "nobly", "query", "salad", "spring", "activity", "courtesy", "game", + "upon", "pony", "satisfy", "unripe", "roll", "type", "novel", "danger", "dwarf", "inane", + "lap", "pig", "killed", "fear", "lead", "outlaw", "hour", "brake", "imbue", "order", + "retail", "stamp", "deputy", "fallen", "glad", "tent", "powder", "quiet", "retain", "seller", + "shaped", "bowl", "duke", "hope", "rate", "dance", "puma", "live", "cause", "dwell", + "moat", "ruby", "volume", "cloak", "fried", "known", "parrot", "dust", "science", "weld", + "change", "corps", "enable", "yeah", "frank", "jewel", "soak", "terrain", "indeed", "boast", + "gland", "stun", "swept", "patio", "sound", "picked", "pie", "calm", "crop", "hall", + "broth", "return", "tall", "basin", "blown", "fuzzy", "icing", "stood", "hair", "jeep", + "basil", "muffin", "rifle", "trim", "offset", "song", "sure", "blond", "output", "ready", + "trash", "soot", "solving", "sudden", "apron", "elite", "shiver", "wedge", "mull", "saint", + "between", "worker", "ferry", "piece", "these", "liberal", "bike", "many", "ridge", "neck", + "pit", "swarm", "unwanted", "buried", "soil", "berry", "emcee", "oil", "pelican", "pigeon", + "quilt", "sixty", "fused", "hail", "jacket", "radio", "raise", "ritual", "spread", "waist", + "sent", "frown", "groin", "heir", "unknown", "fourth", "fast", "mace", "orange", "pilot", + "rein", "trail", "mask", "used", "drawl", "hymn", "kiosk", "script", "success", "logo", + "nephew", "north", "pawn", "survey", "intend", "vinyl", "tiny", "graze", "guise", "loft", + "onset", "other", "use", "warp", "debt", "peak", "blame", "defer", "enter", "silent", + "anxiety", "meat", "focus", "match", "snare", "ulcer", "sell", "china", "orca", "ramp", + "torch", "bright", "green", "mix", "pub", "sister", "wisdom", "lately", "opening", "paid", + "post", "blaze", "net", "rash", "tin", "mother", "talent", "knock", "snail", "vague", + "caught", "host", "pole", "block", "chief", "debut", "final", "mumbo", "music", "money", + "pen", "place", "planet", "popcorn", "quack", "sector", "shallow", "burn", "pork", "lion", + "pasta", "sustain", "sway", "worn", "becoming", "rank", "clamp", "shame", "suffer", "unborn", + "war", "costly", "entire", "level", "muse", "nap", "sash", "setup", "sonar", "stake", + "weapon", "cafe", "prod", "count", "riot", "shun", "son", "buttons", "formal", "bliss", + "hurl", "meter", "seldom", "amazing", "chain", "flesh", "stair", "yes", "trucks", "weekly", + "aged", "ribbon", "velvet", "region", "soup", "drill", "groom", "seven", "origin", "lady", + "rose", "fling", "glory", "smell", "soar", "stream", "struggle", "fault", "ideal", "ladle", + "potato", "school", "sheer", "swell", "anymore", "need", "lawn", "store", "support", "tomato", + "suit", "cheat", "prairie", "water", "which", "appeal", "stable", "belt", "vast", "carry", + "matrix", "ninja", "party", "plenty", "wrath", "burst", "pray", "time", "tree", "when", + "quote", "hate", "fight", "gout", "urban", "step", "broad", "cream", "tower", "buying", + "cover", "flood", "flute", "sight", "tight", "ultra", "wise", "beach", "brick", "metal", + "staff", "nearby", "famed", "scissors", "jack", "ride", "town", "brook", "guide", "serious", + "spur", "way", "kick", "hunch", "quirk", "sheep", "surprise", "treat", "zipper", "device", + "gouge", "layer", "rouge", "seeing", "zip", "warmth", "enjoy", "grate", "guard", "visor", + "wonder", "losing", "signed", "sold", "streak", "tried", "groan", "kid", "street", "root", + "basket", "nasty", "probe", "twenty", "victory", "what", "chase", "rubber", "thanks", "goal", + "joint", "ozone", "puff", "sketch", "nearly", "coat", "flask", "gnash", "notice", "remote", + "your", "delta", "gem", "leach", "tax", "exalt", "gutter", "plate", "effort", "ending", + "purge", "rectify", "trump", "visa", "inn", "knife", "lard", "leap", "male", "grief", + "pouch", "third", "thumb", "dawn", "spit", "union", "habit", "manage", "obey", "coach", + "motor", "shed", "pin", "plutonium", "sunset", "autumn", "chunk", "foray", "lasso", "leather", + "upset", "french", "blunt", "moist", "rubble", "shaft", "smoke", "strong", "freak", "octopus", + "sniff", "vigil", "else", "lava", "shape", "engage", "pity", "thin", "cabin", "dozen", + "hazel", "herd", "narrow", "vain", "past", "coral", "fairy", "logic", "surge", "twist", + "valor", "reform", "quota", "too", "station", "trades", "farm", "curve", "hump", "plod", + "press", "rotor", "select", "wild", "gauge", "recycle", "birth", "opt", "quantity", "dose", + "foot", "vary", "hound", "remove", "satire", "strive", "share", "silly", "spec", "fact", + "soft", "grass", "editor", "gauze", "lizard", "mead", "model", "smile", "topic", "copy", + "gave", "blade", "fraud", "grab", "man", "month", "needle", "silk", "brand", "pants", + "rope", "rough", "scroll", "sadness", "signal", "plan", "room", "cigar", "story", "style", + "come", "deny", "geek", "hull", "ledge", "rural", "surface", "wit", "toast", "volcano", + "leg", "mustard", "nut", "poach", "facing", "female", "nobody", "hire", "plane", "romance", + "sit", "slave", "slice", "army", "site", "leave", "straw", "warned", "junior", "saving", + "huge", "none", "moment", "stand", "kill", "slow", "cargo", "drunk", "furry", "guest", + "plump", "tip", "civic", "stereo", "vase", "virtual", "factor", "income", "runner", "news", + "cheer", "inlet", "niece", "peach", "ton", "trunk", "why", "name", "craze", "eight", + "excel", "given", "gown", "owner", "predict", "shut", "disco", "group", "havoc", "magnet", + "muscle", "scout", "throat", "area", "note", "cliff", "hack", "truck", "you", "pattern", + "scheme", "sort", "crook", "doing", "mercy", "ninth", "peace", "priest", "render", "busy", + "cash", "gene", "fauna", "grasp", "hazard", "relay", "run", "move", "bleed", "mob", + "ruin", "spiral", "vegan", "winner", "studio", "tone", "dough", "puppy", "saga", "sleep", + "suggest", "would", "arrival", "haven", "kidnap", "moan", "pirate", "winter", "adequate", "largely", + "hell", "rode", "fresh", "maid", "notch", "slam", "spicy", "tablet", "ease", "earth", + "proper", "razor", "resent", "legacy", "notion", "arrow", "joust", "pizza", "reader", "smart", + "pain", "eager", "short", "slain", "slot", "spoon", "latter", "happy", "heave", "sized", + "pull", "year", "break", "chest", "drank", "fever", "grain", "inject", "lonely", "queue", + "stare", "chosen", "here", "brave", "cough", "moor", "penny", "modify", "bless", "forum", + "lorry", "mud", "widow", "youth", "memory", "tennis", "glare", "pay", "secret", "sequence", + "armed", "grim", "harsh", "thief", "tunnel", "bite", "dark", "fell", "injury", "stump", + "oral", "hotel", "merry", "pocket", "rot", "shack", "vent", "verse", "pond", "sigh", + "brisk", "broil", "creek", "glide", "rake", "whole", "road", "roar", "salute", "snap", + "trace", "read", "napkin", "shift", "swing", "native", "lush", "office", "precis", "slipper", + "tack", "halo", "vile", "dirt", "much", "parcel", "posting", "core", "crane", "south", + "divide", "jazz", "bound", "cloud", "season", "valley", "medical", "dial", "full", "rest", + "catch", "child", "detox", "limit", "pillow", "meal", "rude", "carve", "react", "round", + "scorn", "sin", "sixth", "pile", "grocery", "sample", "temple", "those", "tunic", "battery", + "forest", "dual", "evade", "feast", "harp", "stub", "swap", "tulip", "uncle", "guess", + "naval", "semester", "small", "watch", "burning", "tempo", "achieved", "does", "okay", "bread", + "delay", "source", "spare", "vow", "chance", "coal", "wait", "elect", "inner", "lamp", + "lease", "ounce", "rocket", "sentence", "stunt", "umbrella", "web", "million", "palm", "quit", + "ethos", "ocean", "sorrow", "address", "future", "status", "taxi", "excess", "sacred", "tender", + "broom", "fetal", "judge", "remain", "rival", "storm", "unpleasant", "border", "life", "quite", + "driven", "soviet", "till", "fudge", "neutral", "separate", "six", "merely", "east", "media", + "pale", "rally", "starve", "identity", "vessel", "high", "tell", "merge", "organ", "segment", + "wrong", "navy", "hang", "loss", "bluff", "kite", "olive", "pipe", "spade", "nation", + "ruling", "enemy", "mayor", "mucus", "onto", "felt", "rear", "cling", "could", "relief", + "sibling", "exceed", "drop", "shoot", "flame", "absence", "motion", "fuel", "ways", "shooting", + "bill", "grow", "title", "fall", "know", "play", "hunger", "spin", "crest", "hurry", + "omit", "sleek", "split", "tissue", "virus", "titles", "came", "toll", "forge", "knead", + "laser", "witness", "boom", "kind", "mars", "circus", "purse", "quake", "turned", "chaos", + "grit", "welcome", "covers", "method", "fair", "mine", "boost", "brass", "harbor", "helmet", + "ill", "mining", "idea", "mail", "next", "beers", "latch", "speck", "thing", "wed", + "scarf", "weather", "window", "young", "belong", "bell", "fleet", "helm", "might", "swallow", + "closet", "mortgage", "stadium", "hero", "stout", "prison", "beat", "code", "fund", "opinion", + "resist", "trait", "ability", "banking", "unite", "decide", "yields", "pound", "zinc", "bear", + "jerk", "cease", "charm", "height", "trust", "vanish", "veal", "mutual", "thank", "whistle", + "invest", "literal", "proven", "shorts", "worried", "raid", "disk", "attic", "mug", "myriad", + "soap", "inch", "sole", "bride", "lure", "perish", "pistol", "pour", "tend", "elder", + "kitten", "lemon", "thunder", "trick", "unity", "info", "infer", "ladder", "funding", "member", + "seem", "spot", "depth", "orbit", "attend", "occupy", "patient", "free", "retire", "borrow", + "maxwell", "jury", "bench", "dingo", "focal", "liver", "noise", "oxide", "vodka", "article", + "well", "floor", "glyph", "prize", "format", "ground", "towers", "noun", "real", "peer", + "senate", "shadow", "tie", "cast", "tech", "blood", "paint", "viable", "flying", "fossil", + "booth", "drown", "also", "fill", "lots", "zero", "hub", "minor", "sack", "useful", + "data", "made", "intro", "escape", "monitor", "really", "crash", "froze", "single", "ballot", + "tragic", "club", "oven", "glint", "lodge", "vibrant", "barrier", "boat", "edit", "ditch", + "hemp", "avenue", "famous", "once", "depot", "knob", "said", "usual", "pick", "snow", + "test", "sling", "moon", "tape", "pant", "travel", "pretty", "wear", "decry", "sky", + "statue", "stray", "suppose", "sail", "nadir", "reveal", "poetry", "wrist", "shield", "pool", + "learn", "pearl", "tattoo", "rumor", "stomach", "send", "drift", "now", "old", "stack", + "wreck", "bedroom", "ball", "beet", "roast", "stead", "taste", "golden", "louse", "shiny", + "modern", "ether", "spell", "keen", "prose", "zebra", "exile", "soldier", "take", "task", + "mutt", "rigor", "speaker", "surround", "teeth", "slip", "erect", "wrap", "player", "blue", + "save", "hammer", "muck", "summer", "chamber", "literary", "sign", "derby", "killer", "sever", + "sip", "visit", "energy", "null", "shy", "thigh", "hawk", "mirth", "service", "square", + "fairly", "held", "blurt", "dater", "jolly", "taught", "mode", "machine", "duty", "devon", + "robot", "shove", "sprinkle", "arise", "defence", "face", "gear", "have", "ruth", "crush", + "farce", "valid", "dream", "herb", "labour", "cinema", "remark", "tonight", "unveil", "both", + "page", "choir", "ratio", "thread", "edge", "fire", "land", "lane", "prey", "spine", + "sticky", "steam", "stroke", "dead", "good", "poet", "seek", "gossip", "subject", "swear", + "useless", "gray", "sept", "midst", "pitch", "thick", "damage", "shares", "pulp", "spree", + "tour", "local", "plain", "reef", "slate", "yarn", "sale", "lance", "stock", "verify", + "bird", "jobs", "lapse", "queen", "stress", "wary", "weep", "gathering", "pace", "cruel", + "pact", "putt", "card", "open", "decor", "rudder", "steal", "cage", "cook", "fiend", + "hungry", "odd", "expand", "cloth", "lobe", "panel", "hefty", "breach", "shoe", "urge", + "expel", "graft", "haste", "humid", "thorn", "empire", "hidden", "crew", "grew", "chess", + "fiber", "juice", "purple", "load", "lock", "broke", "fifty", "heavy", "poise", "table", + "the", "flora", "idiot", "revive", "whisper", "corner", "eleven", "exam", "wood", "remind", + "current", "patent", "like", "click", "mobile", "new", "people", "psalm", "radar", "recipe", + "climb", "hatch", "prowl", "simple", "solid", "sponsor", "took", "maker", "scent", "spray", + "suspect", "ugly", "bishop", "side", "coast", "twelve", "cool", "desk", "crazy", "drama", + "grade", "centre", "failed", "craft", "filth", "flour", "harry", "loyal", "plum", "random", + "social", "evil", "grace", "prompt", "video", "illness", "cell", "genre", "greet", "uniform", + "plea", "champ", "daisy", "sales", "spoil", "hole", "knee", "lose", "onion", "parade", + "peel", "while", "arrange", "dinner", "extend", "hand", "meet", "paper", "serial", "shark", + "snack", "stool", "wedding", "hydra", "slide", "faith", "who", "treaty", "first", "frame", + "unfold", "steady", "lack", "jiffy", "revise", "sing", "brought", "clean", "pause", "special", + "debate", "loud", "steer", "park", "gospel", "juror", "arbor", "chose", "stored", "lift", + "equal", "fluid", "sir", "skirt", "slime", "gain", "team", "drape", "idiom", "runway", + "author", "base", "burden", "wage", "wake", "wire", "buggy", "robust", "unique", "screen", + "rinse", "sauce", "sugar", "supply", "loneliness", "sweat", "crawl", "quality", "rhyme", "speak", + "mere", "mood", "tail", "grip", "thought", "build", "mole", "repeat", "vigor", "wanting", + "porch", "search", "summit", "oxford", "mass", "dried", "gravy", "lawsuit", "mush", "permit", + "where", "hunt", "were", "faint", "glove", "double", "blank", "paste", "pine", "slant", + "eating", "thrown", "file", "apple", "beast", "tribe", "vocal", "suburb", "front", "marsh", + "skull", "vote", "court", "tiger", "century", "tune", "vine", "viola", "nine", "seen", + "gnome", "puppet", "soda", "stick", "vowel", "wink", "head", "pope", "rare", "quest", + "ripe", "yield", "desire", "gulf", "blues", "piano", "renew", "slope", "more", "role", + "mule", "petrol", "wander", "true", "zoo", "close", "rabbit", "tile", "toilet", "bureau", + "impair", "poem", "push", "demon", "mouse", "anywhere", "blush", "gavel", "receipt", "spice", + "dear", "feet", "merit", "milky", "senior", "bloom", "diner", "shower", "combat", "whom", + "drain", "false", "nerve", "white", "flint", "kiwi", "strange", "down", "rent", "carol", + "denim", "primal", "reason", "forced", "cheap", "robe", "comply", "blow", "city", "stir", + "fable", "melon", "pulse", "start", "subway", "four", "laid", "love", "bring", "chill", + "meant", "prism", "second", "price", "prone", "marked", "mark", "pump", "chalk", "check", + "grind", "icon", "lemur", "outside", "cake", "rely", "word", "blimp", "lamb", "lust", + "rib", "quartz", "flair", "report", "attempt", "figure", "nights", "poultry", "recent", "salt", + "that", "class", "exact", "poppy", "recite", "shave", "throne", "grand", "seminar", "league", + "remember", "fiery", "knot", "panic", "shrimp", "tongue", "trophy", "voice", "addition", "date", + "item", "brief", "release", "tactic", "domain", "equity", "fellow", "line", "tire", "west", + "clone", "indoor", "mount", "smash", "tube", "irony", "navel", "royal", "sorry", "weed", + "part", "rise", "yard", "medal", "reduce", "riding", "field", "hardy", "rip", "slump", + "spirit", "stink", "marine", "still", "menu", "pair", "eaten", "legal", "symbol", "mind", + "rock", "doubt", "theft", "tornado", "size", "hedge", "steel", "blurb", "halt", "credit", + "bank", "body", "khaki", "pike", "row", "tram", "vest", "accused", "jail", "modem", + "night", "fiscal", "email", "girth", "prune", "certain", "growth", "haze", "mystery", "toad", + "width", "church", "safe", "with", "cable", "thirst", "stolen", "buddy", "degree", "toss", + "hear", "pure", "they", "vice", "quail", "twine", "wheel", "affected", "wide", "beard", + "buyer", "early", "nab", "sore", "help", "only", "lump", "miss", "scoop", "screw", + "scrub", "vein", "seal", "draw", "peril", "pupil", "thirty", "beer", "gate", "mesh", + "rain", "couch", "hat", "ancient", "trends", "mill", "pass", "rush", "turn", "span", + "tick", "means", "picture", "shred", "snore", "from", "golf", "gust", "lucky", +} diff --git a/internal/words/words_test.go b/internal/words/words_test.go new file mode 100644 index 0000000..fbe4a50 --- /dev/null +++ b/internal/words/words_test.go @@ -0,0 +1,57 @@ +package words + +import ( + "fmt" + "os" + "testing" + "time" +) + +func TestWordsAndEntropy(t *testing.T) { + suffix := ".datum.local" + + fmt.Println("Example hostnames:") + + for i := 0; i < 5; i++ { + randomString := WordsAndEntropy(suffix, fmt.Sprintf("%d", time.Now().UnixNano())) + fmt.Printf("%s\n", randomString) + } +} + +// This is not an exhaustive collision test, but a quick check that +// runs in a couple of seconds to make sure we haven't introduced an +// obvious entropy bug. +// +// In actuality this starts generating collisions around 8.8M +// iterations, simply because an incrementing integer isn't random +// enough. +// +// In production use with randomized namespace and project names +// created at different times across different machines, this should +// be more than sufficient. +func TestNoCollisions(t *testing.T) { + const n = 1_000_000 + + set := make(map[string]bool) + + for i := 0; i < n; i++ { + suffix := "--test" + seedStr := fmt.Sprintf("%d", i) + hostname := WordsAndEntropy(suffix, seedStr) + + if set[hostname] { + t.Errorf("collision detected at index %d: %s", i, hostname) + } + set[hostname] = true + + if i%100_000 == 0 { + _, _ = os.Stdout.WriteString(".") + } + } + + fmt.Println() + + if len(set) != n { + t.Errorf("expected set length %d, got %d", n, len(set)) + } +}