mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 14:54:01 +03:00
Switch to golangci-lint
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/9seconds/mtg/stats"
|
||||
)
|
||||
|
||||
// ConnPurpose is intented to be identifier of connection purpose. We
|
||||
// ConnPurpose is intended to be identifier of connection purpose. We
|
||||
// sometimes want to treat client/telegram connection differently (for
|
||||
// logging for example).
|
||||
type ConnPurpose uint8
|
||||
|
||||
@@ -24,7 +24,8 @@ var emptyIP = [4]byte{0x00, 0x00, 0x00, 0x00}
|
||||
|
||||
// NewMiddleProxyCipher creates new block cipher to proxy<->telegram
|
||||
// connection.
|
||||
func NewMiddleProxyCipher(conn StreamReadWriteCloser, req *rpc.NonceRequest, resp *rpc.NonceResponse, secret []byte) StreamReadWriteCloser {
|
||||
func NewMiddleProxyCipher(conn StreamReadWriteCloser,
|
||||
req *rpc.NonceRequest, resp *rpc.NonceResponse, secret []byte) StreamReadWriteCloser {
|
||||
localAddr := conn.LocalAddr()
|
||||
remoteAddr := conn.RemoteAddr()
|
||||
|
||||
@@ -37,7 +38,8 @@ func NewMiddleProxyCipher(conn StreamReadWriteCloser, req *rpc.NonceRequest, res
|
||||
return NewBlockCipher(conn, enc, dec)
|
||||
}
|
||||
|
||||
func deriveKeys(purpose cipherPurpose, req *rpc.NonceRequest, resp *rpc.NonceResponse, client *net.TCPAddr, remote *net.TCPAddr, secret []byte) ([]byte, []byte) {
|
||||
func deriveKeys(purpose cipherPurpose, req *rpc.NonceRequest, resp *rpc.NonceResponse,
|
||||
client, remote *net.TCPAddr, secret []byte) ([]byte, []byte) {
|
||||
message := bytes.Buffer{}
|
||||
message.Write(resp.Nonce[:])
|
||||
message.Write(req.Nonce[:])
|
||||
|
||||
@@ -61,7 +61,8 @@ func (m *MTProtoFrame) Read() ([]byte, error) { // nolint: gocyclo
|
||||
"messageLength", messageLength,
|
||||
"sequence_number", m.readSeqNo,
|
||||
)
|
||||
if messageLength%4 != 0 || messageLength < mtprotoFrameMinMessageLength || messageLength > mtprotoFrameMaxMessageLength {
|
||||
if messageLength%4 != 0 || messageLength < mtprotoFrameMinMessageLength ||
|
||||
messageLength > mtprotoFrameMaxMessageLength {
|
||||
return nil, errors.Errorf("Incorrect frame message length %d", messageLength)
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ func (m *MTProtoProxy) Read() ([]byte, error) {
|
||||
case bytes.Equal(tag, rpc.TagSimpleAck):
|
||||
return m.readSimpleAck(packet)
|
||||
case bytes.Equal(tag, rpc.TagCloseExt):
|
||||
return m.readCloseExt(packet)
|
||||
return m.readCloseExt()
|
||||
}
|
||||
|
||||
return nil, errors.Errorf("Unknown RPC answer %v", tag)
|
||||
@@ -91,7 +91,7 @@ func (m *MTProtoProxy) readSimpleAck(data []byte) ([]byte, error) {
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (m *MTProtoProxy) readCloseExt(data []byte) ([]byte, error) {
|
||||
func (m *MTProtoProxy) readCloseExt() ([]byte, error) {
|
||||
m.logger.Debugw("Read RPC_CLOSE_EXT", "counter", m.readCounter)
|
||||
|
||||
return nil, errors.New("Connection has been closed remotely by RPC call")
|
||||
@@ -150,7 +150,8 @@ func (m *MTProtoProxy) Close() error {
|
||||
}
|
||||
|
||||
// NewMTProtoProxy creates new RPC wrapper.
|
||||
func NewMTProtoProxy(conn PacketReadWriteCloser, connOpts *mtproto.ConnectionOpts, adTag []byte) (PacketReadWriteCloser, error) {
|
||||
func NewMTProtoProxy(conn PacketReadWriteCloser, connOpts *mtproto.ConnectionOpts,
|
||||
adTag []byte) (PacketReadWriteCloser, error) {
|
||||
req, err := rpc.NewProxyRequest(connOpts.ClientAddr, conn.LocalAddr(), connOpts, adTag)
|
||||
if err != nil {
|
||||
return nil, errors.Annotate(err, "Cannot create new RPC proxy request")
|
||||
|
||||
Reference in New Issue
Block a user