X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/f6f1d88969e12eadb7013397cdad3c4c5625988c..a55350daaf83498b7a237c027ad0dd2377f06fee:/hotline/server.go?ds=inline diff --git a/hotline/server.go b/hotline/server.go index ff8daf3..5245c7b 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -4,6 +4,7 @@ import ( "bufio" "bytes" "context" + "crypto/rand" "encoding/binary" "errors" "fmt" @@ -15,7 +16,6 @@ import ( "log" "log/slog" "math/big" - "math/rand" "net" "os" "path" @@ -246,7 +246,7 @@ func NewServer(configDir, netInterface string, netPort int, logger *slog.Logger, _ = server.loadBanList(filepath.Join(configDir, "Banlist.yaml")) if err := server.loadThreadedNews(filepath.Join(configDir, "ThreadedNews.yaml")); err != nil { - return nil, err + return nil, fmt.Errorf("error loading threaded news: %w", err) } if err := server.loadConfig(filepath.Join(configDir, "config.yaml")); err != nil { @@ -760,7 +760,8 @@ func (s *Server) NewPrivateChat(cc *ClientConn) []byte { defer s.PrivateChatsMu.Unlock() randID := make([]byte, 4) - rand.Read(randID) + _, _ = rand.Read(randID) + data := binary.BigEndian.Uint32(randID) s.PrivateChats[data] = &PrivateChat{