Calculate random hostname by taking random length of the SHA1 of current time.
()
| 203 | // Calculate random hostname by taking random length |
| 204 | // of the SHA1 of current time. |
| 205 | func randomHostname() string { |
| 206 | currentTime := time.Now().Format("2006-01-02 15:04:05") |
| 207 | h := sha1.New() |
| 208 | h.Write([]byte(currentTime)) |
| 209 | bs := h.Sum(nil) |
| 210 | randomSlice := bs[:(rand.Intn(len(bs)-3) + 3)] |
| 211 | randomName := fmt.Sprintf("%x\n", randomSlice) |
| 212 | return randomName |
| 213 | } |
| 214 | |
| 215 | // From all the IP addresses of this interface, |
| 216 | // extract the IPv4 address where we'll bind to |