diff options
Diffstat (limited to 'src/lib.go')
-rw-r--r-- | src/lib.go | 36 |
1 files changed, 26 insertions, 10 deletions
@@ -137,8 +137,6 @@ func (uuid UUID) ToString() string { return string(dst[:]) } - - type LogLevel int8 const ( @@ -369,7 +367,13 @@ pbkdf2.Key. // // Using a higher iteration count will increase the cost of an exhaustive // search but will also make derivation proportionally slower. -func PBKDF2Key(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte { +func PBKDF2Key( + password []byte, + salt []byte, + iter int, + keyLen int, + h func() hash.Hash, +) []byte { prf := hmac.New(h, password) hashLen := prf.Size() numBlocks := (keyLen + hashLen - 1) / hashLen @@ -588,7 +592,7 @@ func smix(b []byte, r, N int, v, xy []uint32) { // Key derives a key from the password, salt, and cost parameters, returning // a byte slice of length keyLen that can be used as cryptographic key. // -// N is a CPU/memory cost parameter, which must be a power of two greater than 1. +// N is a CPU/memory cost parameter, which must be a power of 2 greater than 1. // r and p must satisfy r * p < 2³⁰. If the parameters do not satisfy the // limits, the function returns a nil byte slice and an error. // @@ -605,7 +609,8 @@ func Scrypt(password, salt []byte, N, r, p, keyLen int) ([]byte, error) { if N <= 1 || N&(N-1) != 0 { return nil, errors.New("scrypt: N must be > 1 and a power of 2") } - if uint64(r)*uint64(p) >= 1<<30 || r > maxInt/128/p || r > maxInt/256 || N > maxInt/128/r { + if uint64(r)*uint64(p) >= 1<<30 || + r > maxInt/128/p || r > maxInt/256 || N > maxInt/128/r { return nil, errors.New("scrypt: parameters are too large") } @@ -768,7 +773,12 @@ func HandlePRIVMSG(ctx *Context, msg Message) { } defer stmt.Close() - ret, err := stmt.Exec(NewUUID().ToString(), "FIXME", "FIXME", time.Now()) + ret, err := stmt.Exec( + NewUUID().ToString(), + "FIXME", + "FIXME", + time.Now(), + ) if err != nil { // FIXME: reply error fmt.Println("xablau can't prepare: ", err) @@ -912,8 +922,8 @@ func PingLoop(ctx *Context, connection *Connection) { if (time.Since(connection.lastReadFrom) <= PingWindow) { continue } - - if ((connection.lastWrittenTo.Sub(connection.lastReadFrom)) <= PingWindow) { + window := connection.lastWrittenTo.Sub(connection.lastReadFrom) + if (window <= PingWindow) { connection.replyChan <- "PING" continue } @@ -954,14 +964,19 @@ func IRCdLoop(ctx *Context, publicSocketPath string) { // conn.Close() // FIXME: is conn nil? continue } - go HandleConnection(ctx, conn) // FIXME: where does it get closed + // FIXME: where does it get closed + go HandleConnection(ctx, conn) } } func CommandListenerLoop(ctx *Context, commandSocketPath string) { listener, err := net.Listen("unix", commandSocketPath) FatalIf(err) - Info("command listener started", "component-up", "component", "command-listener") + Info( + "command listener started", + "component-up", + "component", "command-listener", + ) for { conn, err := listener.Accept() @@ -1146,6 +1161,7 @@ var ( ) ) + func Main() { Init() flag.Parse() |