]> git.r.bdr.sh - rbdr/mobius/blobdiff - hotline/server.go
Adopt more fixed size array types for struct fields
[rbdr/mobius] / hotline / server.go
index ff8daf3fb3ccaff5f882c77bca28ae3f5399ee3c..5245c7bdda3a2c368bad00d9da7ecbbddcb120b8 100644 (file)
@@ -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{