linting the code

This commit is contained in:
9seconds
2019-10-11 09:41:18 +03:00
parent 432e2970a0
commit 5009859a1e
50 changed files with 172 additions and 55 deletions
+3
View File
@@ -27,6 +27,7 @@ func (w *wrapperBlockCipher) Write(p []byte) (int, error) {
if err != nil {
return 0, err
}
return w.parent.Write(encrypted)
}
@@ -35,6 +36,7 @@ func (w *wrapperBlockCipher) WriteTimeout(p []byte, timeout time.Duration) (int,
if err != nil {
return 0, err
}
return w.parent.WriteTimeout(encrypted, timeout)
}
@@ -49,6 +51,7 @@ func (w *wrapperBlockCipher) Read(p []byte) (int, error) {
if err != nil {
return 0, fmt.Errorf("cannot read data: %w", err)
}
currentBuffer = append(currentBuffer, rv...)
}
+2
View File
@@ -38,6 +38,7 @@ func (w *wrapperConn) WriteTimeout(p []byte, timeout time.Duration) (int, error)
func (w *wrapperConn) Write(p []byte) (int, error) {
n, err := w.parent.Write(p)
w.logger.Debugw("write to stream", "bytes", n, "error", err)
if err != nil {
w.Close() // nolint: gosec
}
@@ -57,6 +58,7 @@ func (w *wrapperConn) ReadTimeout(p []byte, timeout time.Duration) (int, error)
func (w *wrapperConn) Read(p []byte) (int, error) {
n, err := w.parent.Read(p)
w.logger.Debugw("Read from stream", "bytes", n, "error", err)
if err != nil {
w.Close()
}
+6 -2
View File
@@ -4,8 +4,8 @@ import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/md5"
"crypto/sha1"
"crypto/md5" // nolint: gosec
"crypto/sha1" // nolint: gosec
"encoding/binary"
"net"
@@ -61,13 +61,16 @@ func mtprotoDeriveKeys(purpose mtprotoCipherPurpose,
clientIPv4 := mtprotoEmptyIP[:]
serverIPv4 := mtprotoEmptyIP[:]
if client.IP.To4() != nil {
clientIPv4 = utils.ReverseBytes(client.IP.To4())
serverIPv4 = utils.ReverseBytes(remote.IP.To4())
}
message.Write(serverIPv4) // nolint: gosec
var port [2]byte
binary.LittleEndian.PutUint16(port[:], uint16(client.Port))
message.Write(port[:]) // nolint: gosec
@@ -90,6 +93,7 @@ func mtprotoDeriveKeys(purpose mtprotoCipherPurpose,
message.Write(client.IP.To16()) // nolint: gosec
message.Write(remote.IP.To16()) // nolint: gosec
}
message.Write(req.Nonce) // nolint: gosec
data := message.Bytes()
+2
View File
@@ -22,6 +22,7 @@ func (w *wrapperObfuscated2) ReadTimeout(p []byte, timeout time.Duration) (int,
if err != nil {
return 0, fmt.Errorf("cannot read stream ciphered data: %w", err)
}
w.decryptor.XORKeyStream(p, p[:n])
return n, nil
@@ -32,6 +33,7 @@ func (w *wrapperObfuscated2) Read(p []byte) (int, error) {
if err != nil {
return n, err
}
w.decryptor.XORKeyStream(p, p[:n])
return n, nil
+1
View File
@@ -65,6 +65,7 @@ func NewTelegramStats(dc conntypes.DC, parent conntypes.StreamReadWriteCloser) c
parent: parent,
dc: dc,
}
stats.Stats.TelegramConnected(dc, parent.RemoteAddr())
return conn