mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
use GenerateSecretToken for msgids
This commit is contained in:
parent
c95ed46949
commit
f35a1c7212
@ -9,7 +9,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
@ -371,13 +370,7 @@ func (server *Server) createListener(addr string, tlsConfig *tls.Config, bindMod
|
|||||||
|
|
||||||
// generateMessageID returns a network-unique message ID.
|
// generateMessageID returns a network-unique message ID.
|
||||||
func (server *Server) generateMessageID() string {
|
func (server *Server) generateMessageID() string {
|
||||||
// we don't need the full like 30 chars since the unixnano below handles
|
return utils.GenerateSecretToken()
|
||||||
// most of our uniqueness requirements, so just truncate at 5
|
|
||||||
lastbit := strconv.FormatInt(rand.Int63(), 36)
|
|
||||||
if 5 < len(lastbit) {
|
|
||||||
lastbit = lastbit[:4]
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%s%s", strconv.FormatInt(time.Now().UTC().UnixNano(), 36), lastbit)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -8,10 +8,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/docopt/docopt-go"
|
"github.com/docopt/docopt-go"
|
||||||
"github.com/oragono/oragono/irc"
|
"github.com/oragono/oragono/irc"
|
||||||
@ -114,7 +112,6 @@ Options:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if arguments["run"].(bool) {
|
} else if arguments["run"].(bool) {
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
|
||||||
if !arguments["--quiet"].(bool) {
|
if !arguments["--quiet"].(bool) {
|
||||||
logman.Info("startup", fmt.Sprintf("Oragono v%s starting", irc.SemVer))
|
logman.Info("startup", fmt.Sprintf("Oragono v%s starting", irc.SemVer))
|
||||||
if commit == "" {
|
if commit == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user