Update to the latest golangci-lint

This commit is contained in:
9seconds
2026-02-11 10:20:04 +01:00
parent 37de052feb
commit ecba88d2e3
38 changed files with 82 additions and 78 deletions
+2 -2
View File
@@ -56,7 +56,7 @@ func ParseClientHello(secret, handshake []byte) (ClientHello, error) {
if len(handshake)-4 != int(handshakeLength) {
return hello,
fmt.Errorf("incorrect handshake size. manifested=%d, real=%d",
handshakeLength, len(handshake)-4) //nolint: gomnd
handshakeLength, len(handshake)-4)
}
copy(hello.Random[:], handshake[ClientHelloRandomOffset:])
@@ -100,7 +100,7 @@ func parseSessionID(hello *ClientHello, handshake []byte) {
}
func parseCipherSuite(hello *ClientHello, handshake []byte) {
cipherSuiteOffset := ClientHelloSessionIDOffset + len(hello.SessionID) + 3 //nolint: gomnd
cipherSuiteOffset := ClientHelloSessionIDOffset + len(hello.SessionID) + 3
hello.CipherSuite = binary.BigEndian.Uint16(handshake[cipherSuiteOffset : cipherSuiteOffset+2])
}
+1 -1
View File
@@ -36,7 +36,7 @@ func SendWelcomePacket(writer io.Writer, secret []byte, clientHello ClientHello)
rec.Type = record.TypeApplicationData
rec.Version = record.Version12
if _, err := io.CopyN(&rec.Payload, rand.Reader, int64(1024+mrand.Intn(3092))); err != nil { //nolint: gomnd
if _, err := io.CopyN(&rec.Payload, rand.Reader, int64(1024+mrand.Intn(3092))); err != nil {
panic(err)
}
@@ -36,7 +36,7 @@ type handshakeFrame struct {
}
func (h *handshakeFrame) dc() int {
idx := int16(h.data[handshakeFrameOffsetDC]) | int16(h.data[handshakeFrameOffsetDC+1])<<8 //nolint: gomnd, lll // little endian for int16 is here
idx := int16(h.data[handshakeFrameOffsetDC]) | int16(h.data[handshakeFrameOffsetDC+1])<<8 //nolint: lll // little endian for int16 is here
switch {
case idx > 0:
@@ -47,12 +47,12 @@ func generateServerHanshakeFrame() serverHandshakeFrame {
panic(err)
}
if frame.data[0] == 0xef { //nolint: gomnd // taken from tg sources
if frame.data[0] == 0xef { // taken from tg sources
continue
}
switch binary.LittleEndian.Uint32(frame.data[:4]) {
case 0x44414548, 0x54534f50, 0x20544547, 0x4954504f, 0xeeeeeeee: //nolint: gomnd // taken from tg sources
case 0x44414548, 0x54534f50, 0x20544547, 0x4954504f, 0xeeeeeeee: // taken from tg sources
continue
}
+4 -4
View File
@@ -9,16 +9,16 @@ import (
)
func Relay(ctx context.Context, log Logger, telegramConn, clientConn essentials.Conn) {
defer telegramConn.Close()
defer clientConn.Close()
defer telegramConn.Close() //nolint: errcheck
defer clientConn.Close() //nolint: errcheck
ctx, cancel := context.WithCancel(ctx)
defer cancel()
go func() {
<-ctx.Done()
telegramConn.Close()
clientConn.Close()
telegramConn.Close() //nolint: errcheck
clientConn.Close() //nolint: errcheck
}()
closeChan := make(chan struct{})
+3 -3
View File
@@ -110,7 +110,7 @@ func (p *Proxy) Serve(listener net.Listener) error {
logger := p.logger.BindStr("ip", ipAddr.String())
if !p.allowlist.Contains(ipAddr) {
conn.Close()
conn.Close() //nolint: errcheck
logger.Info("ip was rejected by allowlist")
p.eventStream.Send(p.ctx, NewEventIPAllowlisted(ipAddr))
@@ -118,7 +118,7 @@ func (p *Proxy) Serve(listener net.Listener) error {
}
if p.blocklist.Contains(ipAddr) {
conn.Close()
conn.Close() //nolint: errcheck
logger.Info("ip was blacklisted")
p.eventStream.Send(p.ctx, NewEventIPBlocklisted(ipAddr))
@@ -235,7 +235,7 @@ func (p *Proxy) doTelegramCall(ctx *streamContext) error {
encryptor, decryptor, err := obfuscated2.ServerHandshake(conn)
if err != nil {
conn.Close()
conn.Close() //nolint: errcheck
return fmt.Errorf("cannot perform obfuscated2 handshake: %w", err)
}
+2 -2
View File
@@ -86,7 +86,7 @@ func (suite *ProxyTestSuite) SetupSuite() {
func (suite *ProxyTestSuite) TearDownSuite() {
if suite.listener != nil {
suite.listener.Close()
suite.listener.Close() //nolint: errcheck
}
if suite.p != nil {
@@ -177,7 +177,7 @@ func (suite *ProxyTestSuite) TestHTTPSRequest() {
resp, err := client.Get(addr) //nolint: noctx
suite.NoError(err)
defer resp.Body.Close()
defer resp.Body.Close() //nolint: errcheck
suite.Equal(http.StatusOK, resp.StatusCode)
+1 -1
View File
@@ -74,7 +74,7 @@ func (s *Secret) Set(text string) error {
return fmt.Errorf("incorrect secret format: %w", err)
}
if len(decoded) < 2 { //nolint: gomnd // we need at least 1 byte here
if len(decoded) < 2 { // we need at least 1 byte here
return fmt.Errorf("secret is truncated, length=%d", len(decoded))
}
+2 -2
View File
@@ -40,11 +40,11 @@ func (s *streamContext) Close() {
s.ctxCancel()
if s.clientConn != nil {
s.clientConn.Close()
s.clientConn.Close() //nolint: errcheck
}
if s.telegramConn != nil {
s.telegramConn.Close()
s.telegramConn.Close() //nolint: errcheck
}
}
+1 -1
View File
@@ -24,7 +24,7 @@ func (suite *StreamContextTestSuite) SetupSuite() {
func (suite *StreamContextTestSuite) SetupTest() {
ctx, cancel := context.WithCancel(context.Background())
ctx = context.WithValue(ctx, "key", "value") //nolint: golint, staticcheck
ctx = context.WithValue(ctx, "key", "value") //nolint: staticcheck
suite.ctxCancel = cancel
suite.connMock = &testlib.EssentialsConnMock{}