X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/95159e5585762c06c654945070ba54262b7dcec9..f8e4cd540b87de3e308ec18a2b040b284a741522:/hotline/server.go?ds=inline diff --git a/hotline/server.go b/hotline/server.go index b4841a7..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" @@ -92,12 +92,6 @@ type PrivateChat struct { } func (s *Server) ListenAndServe(ctx context.Context, cancelRoot context.CancelFunc) error { - s.Logger.Info("Hotline server started", - "version", VERSION, - "API port", fmt.Sprintf("%s:%v", s.NetInterface, s.Port), - "Transfer port", fmt.Sprintf("%s:%v", s.NetInterface, s.Port+1), - ) - var wg sync.WaitGroup wg.Add(1) @@ -252,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 { @@ -766,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{