Browse Source

use GenerateSecretToken for msgids

tags/v1.0.0-rc1
Shivaram Lingamneni 5 years ago
parent
commit
f35a1c7212
2 changed files with 1 additions and 11 deletions
  1. 1
    8
      irc/server.go
  2. 0
    3
      oragono.go

+ 1
- 8
irc/server.go View File

@@ -9,7 +9,6 @@ import (
9 9
 	"bufio"
10 10
 	"crypto/tls"
11 11
 	"fmt"
12
-	"math/rand"
13 12
 	"net"
14 13
 	"net/http"
15 14
 	_ "net/http/pprof"
@@ -371,13 +370,7 @@ func (server *Server) createListener(addr string, tlsConfig *tls.Config, bindMod
371 370
 
372 371
 // generateMessageID returns a network-unique message ID.
373 372
 func (server *Server) generateMessageID() string {
374
-	// we don't need the full like 30 chars since the unixnano below handles
375
-	// most of our uniqueness requirements, so just truncate at 5
376
-	lastbit := strconv.FormatInt(rand.Int63(), 36)
377
-	if 5 < len(lastbit) {
378
-		lastbit = lastbit[:4]
379
-	}
380
-	return fmt.Sprintf("%s%s", strconv.FormatInt(time.Now().UTC().UnixNano(), 36), lastbit)
373
+	return utils.GenerateSecretToken()
381 374
 }
382 375
 
383 376
 //

+ 0
- 3
oragono.go View File

@@ -8,10 +8,8 @@ package main
8 8
 import (
9 9
 	"fmt"
10 10
 	"log"
11
-	"math/rand"
12 11
 	"strings"
13 12
 	"syscall"
14
-	"time"
15 13
 
16 14
 	"github.com/docopt/docopt-go"
17 15
 	"github.com/oragono/oragono/irc"
@@ -114,7 +112,6 @@ Options:
114 112
 			}
115 113
 		}
116 114
 	} else if arguments["run"].(bool) {
117
-		rand.Seed(time.Now().UTC().UnixNano())
118 115
 		if !arguments["--quiet"].(bool) {
119 116
 			logman.Info("startup", fmt.Sprintf("Oragono v%s starting", irc.SemVer))
120 117
 			if commit == "" {

Loading…
Cancel
Save