X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/d005ef04cfaa26943e6dd33807d741577ffb232a..bdd21a62b39f18b1c78ede4e0dc2bd569d33173d:/hotline/server.go diff --git a/hotline/server.go b/hotline/server.go index f4a2ad4..bfc1c11 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -11,7 +11,6 @@ import ( "gopkg.in/yaml.v3" "io" "io/fs" - "io/ioutil" "math/big" "math/rand" "net" @@ -28,8 +27,6 @@ var contextKeyReq = contextKey("req") type requestCtx struct { remoteAddr string - login string - name string } type Server struct { @@ -106,7 +103,6 @@ func (s *Server) ListenAndServe(ctx context.Context, cancelRoot context.CancelFu ln, err := net.Listen("tcp", fmt.Sprintf("%s:%v", "", s.Port+1)) if err != nil { s.Logger.Fatal(err) - } s.Logger.Fatal(s.ServeFileTransfers(ctx, ln)) @@ -210,7 +206,7 @@ const ( ) // NewServer constructs a new Server from a config dir -func NewServer(configDir string, netPort int, logger *zap.SugaredLogger, FS FileStore) (*Server, error) { +func NewServer(configDir string, netPort int, logger *zap.SugaredLogger, fs FileStore) (*Server, error) { server := Server{ Port: netPort, Accounts: make(map[string]*Account), @@ -224,7 +220,7 @@ func NewServer(configDir string, netPort int, logger *zap.SugaredLogger, FS File outbox: make(chan Transaction), Stats: &Stats{Since: time.Now()}, ThreadedNews: &ThreadedNews{}, - FS: FS, + FS: fs, banList: make(map[string]*time.Time), } @@ -315,7 +311,7 @@ func (s *Server) keepaliveHandler() { c.Idle = true flagBitmap := big.NewInt(int64(binary.BigEndian.Uint16(c.Flags))) - flagBitmap.SetBit(flagBitmap, userFlagAway, 1) + flagBitmap.SetBit(flagBitmap, UserFlagAway, 1) binary.BigEndian.PutUint16(c.Flags, uint16(flagBitmap.Int64())) c.sendAll( @@ -339,7 +335,7 @@ func (s *Server) writeBanList() error { if err != nil { return err } - err = ioutil.WriteFile( + err = os.WriteFile( filepath.Join(s.ConfigDir, "Banlist.yaml"), out, 0666, @@ -741,7 +737,7 @@ func (s *Server) NewPrivateChat(cc *ClientConn) []byte { randID := make([]byte, 4) rand.Read(randID) - data := binary.BigEndian.Uint32(randID[:]) + data := binary.BigEndian.Uint32(randID) s.PrivateChats[data] = &PrivateChat{ ClientConn: make(map[uint16]*ClientConn), @@ -1210,7 +1206,7 @@ func (s *Server) handleFileTransfer(ctx context.Context, rwc io.ReadWriter) erro return err } - if err := receiveFile(rwc, file, ioutil.Discard, ioutil.Discard, fileTransfer.bytesSentCounter); err != nil { + if err := receiveFile(rwc, file, io.Discard, io.Discard, fileTransfer.bytesSentCounter); err != nil { s.Logger.Error(err) }