"go.uber.org/zap"
"io"
"io/ioutil"
- "log"
"math/big"
"math/rand"
"net"
"sync"
"time"
- "golang.org/x/crypto/bcrypt"
"gopkg.in/yaml.v2"
)
APIListener net.Listener
FileListener net.Listener
- newsReader io.Reader
- newsWriter io.WriteCloser
+ // newsReader io.Reader
+ // newsWriter io.WriteCloser
outbox chan Transaction
Connection: conn,
Server: s,
Version: &[]byte{},
- AutoReply: &[]byte{},
+ AutoReply: []byte{},
Transfers: make(map[int][]*FileTransfer),
Agreed: false,
}
var connectedUsers []Field
for _, c := range sortedClients(s.Clients) {
- if c.Agreed == false {
+ if !c.Agreed {
continue
}
user := User{
}
}
-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
}
// 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
}
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