Преглед на файлове

Use base 36 when generating message IDs, gives us full 0-9a-z to use while preserving uniqueness nicely

tags/v0.11.0-alpha
Daniel Oaks преди 6 години
родител
ревизия
3ba8af714e
променени са 1 файла, в които са добавени 3 реда и са изтрити 3 реда
  1. 3
    3
      irc/server.go

+ 3
- 3
irc/server.go Целия файл

@@ -397,11 +397,11 @@ func (server *Server) createListener(addr string, tlsConfig *tls.Config) *Listen
397 397
 func (server *Server) generateMessageID() string {
398 398
 	// we don't need the full like 30 chars since the unixnano below handles
399 399
 	// most of our uniqueness requirements, so just truncate at 5
400
-	lastbit := strconv.FormatInt(rand.Int63(), 16)
400
+	lastbit := strconv.FormatInt(rand.Int63(), 36)
401 401
 	if 5 < len(lastbit) {
402
-		lastbit = lastbit[:5]
402
+		lastbit = lastbit[:4]
403 403
 	}
404
-	return fmt.Sprintf("%s%s", strconv.FormatInt(time.Now().UTC().UnixNano(), 16), lastbit)
404
+	return fmt.Sprintf("%s%s", strconv.FormatInt(time.Now().UTC().UnixNano(), 36), lastbit)
405 405
 }
406 406
 
407 407
 //

Loading…
Отказ
Запис