X-Git-Url: https://git.r.bdr.sh/rbdr/mobius/blobdiff_plain/61c272e101b6f0444c7b2a666b0b5e828ba6db03..aebc4d3647b9823ae8cbb57b21b1af83bfd011fb:/hotline/server.go?ds=inline diff --git a/hotline/server.go b/hotline/server.go index c5a29ba..1da2859 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -8,7 +8,6 @@ import ( "go.uber.org/zap" "io" "io/ioutil" - "log" "math/big" "math/rand" "net" @@ -21,7 +20,6 @@ import ( "sync" "time" - "golang.org/x/crypto/bcrypt" "gopkg.in/yaml.v2" ) @@ -50,8 +48,8 @@ type Server struct { APIListener net.Listener FileListener net.Listener - newsReader io.Reader - newsWriter io.WriteCloser + // newsReader io.Reader + // newsWriter io.WriteCloser outbox chan Transaction @@ -327,7 +325,7 @@ func (s *Server) NewClientConn(conn net.Conn) *ClientConn { Connection: conn, Server: s, Version: &[]byte{}, - AutoReply: &[]byte{}, + AutoReply: []byte{}, Transfers: make(map[int][]*FileTransfer), Agreed: false, } @@ -376,7 +374,7 @@ func (s *Server) connectedUsers() []Field { var connectedUsers []Field for _, c := range sortedClients(s.Clients) { - if c.Agreed == false { + if !c.Agreed { continue } user := User{ @@ -577,21 +575,6 @@ func (s *Server) handleNewConnection(conn net.Conn) error { } } -func hashAndSalt(pwd []byte) string { - // Use GenerateFromPassword to hash & salt pwd. - // MinCost is just an integer constant provided by the bcrypt - // package along with DefaultCost & MaxCost. - // The cost can be any value you want provided it isn't lower - // than the MinCost (4) - hash, err := bcrypt.GenerateFromPassword(pwd, bcrypt.MinCost) - if err != nil { - log.Println(err) - } - // GenerateFromPassword returns a byte slice so we need to - // convert the bytes to a string and return it - return string(hash) -} - // NewTransactionRef generates a random ID for the file transfer. The Hotline client includes this ID // in the file transfer request payload, and the file transfer server will use it to map the request // to a transfer @@ -796,7 +779,7 @@ func (s *Server) TransferFile(conn net.Conn) error { } // Read the client's Next Action request - //TODO: Remove hardcoded behavior and switch behaviors based on the next action send + // TODO: Remove hardcoded behavior and switch behaviors based on the next action send if _, err := conn.Read(readBuffer); err != nil { return err } @@ -848,7 +831,7 @@ func (s *Server) TransferFile(conn net.Conn) error { bytesRead, err := file.Read(sendBuffer) if err == io.EOF { // Read the client's Next Action request - //TODO: Remove hardcoded behavior and switch behaviors based on the next action send + // TODO: Remove hardcoded behavior and switch behaviors based on the next action send if _, err := conn.Read(readBuffer); err != nil { s.Logger.Errorf("error reading next action: %v", err) return err