From 3ba8af714e20329195cb0e5ff2dee3013f3b2ad2 Mon Sep 17 00:00:00 2001 From: Daniel Oaks Date: Thu, 4 Jan 2018 00:21:35 +1000 Subject: [PATCH] Use base 36 when generating message IDs, gives us full 0-9a-z to use while preserving uniqueness nicely --- irc/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/irc/server.go b/irc/server.go index ccbf1ac2..ebb66102 100644 --- a/irc/server.go +++ b/irc/server.go @@ -397,11 +397,11 @@ func (server *Server) createListener(addr string, tlsConfig *tls.Config) *Listen func (server *Server) generateMessageID() string { // we don't need the full like 30 chars since the unixnano below handles // most of our uniqueness requirements, so just truncate at 5 - lastbit := strconv.FormatInt(rand.Int63(), 16) + lastbit := strconv.FormatInt(rand.Int63(), 36) if 5 < len(lastbit) { - lastbit = lastbit[:5] + lastbit = lastbit[:4] } - return fmt.Sprintf("%s%s", strconv.FormatInt(time.Now().UTC().UnixNano(), 16), lastbit) + return fmt.Sprintf("%s%s", strconv.FormatInt(time.Now().UTC().UnixNano(), 36), lastbit) } //