Skip to content

Commit 817696f

Browse files
committed
fix lint issues in tls mirror
1 parent 5cce254 commit 817696f

File tree

9 files changed

+11
-12
lines changed

9 files changed

+11
-12
lines changed

.github/linters/.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ linters:
5050
- builtin$
5151
- examples$
5252
issues:
53-
new: true
53+
new: false
5454
formatters:
5555
enable:
5656
- gofmt

transport/internet/tls/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
294294
}
295295
}
296296

297-
if c.Ciphersuites != nil && len(c.Ciphersuites) > 0 {
297+
if len(c.Ciphersuites) > 0 {
298298
config.CipherSuites = make([]uint16, 0, len(c.Ciphersuites))
299299
for _, cs := range c.Ciphersuites {
300300
config.CipherSuites = append(config.CipherSuites, uint16(cs))

transport/internet/tlsmirror/mirrorbase/conn.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
// NewMirroredTLSConn creates a new mirrored TLS connection.
1717
// No stable interface
1818
func NewMirroredTLSConn(ctx context.Context, clientConn net.Conn, serverConn net.Conn, onC2SMessage, onS2CMessage tlsmirror.MessageHook, closable common.Closable, explicitNonceDetection tlsmirror.ExplicitNonceDetection) tlsmirror.InsertableTLSConn {
19-
2019
explicitNonceDetectionReady, explicitNonceDetectionOver := context.WithCancel(ctx)
2120
c := &conn{
2221
ctx: ctx,
@@ -462,7 +461,7 @@ func (c *conn) GetApplicationDataExplicitNonceReservedOverheadHeaderLength() (in
462461
if c.tls12ExplicitNonce == nil {
463462
return 0, newError("explicit nonce info is not ready")
464463
}
465-
if *c.tls12ExplicitNonce == true {
464+
if *c.tls12ExplicitNonce {
466465
return 8, nil
467466
}
468467
return 0, nil

transport/internet/tlsmirror/mirrorbase/crypto_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package mirrorbase
22

33
import (
4-
"github.com/google/go-cmp/cmp"
54
"testing"
65

6+
"github.com/google/go-cmp/cmp"
7+
78
"github.com/v2fly/v2ray-core/v5/common/crypto"
89
)
910

transport/internet/tlsmirror/server/client_conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (s *clientConnState) WriteMessage(message []byte) error {
187187
return newError("failed to get explicit nonce reserved overhead header length").Base(err)
188188
}
189189
buffer := make([]byte, explicitNonceReservedOverheadHeaderLength, explicitNonceReservedOverheadHeaderLength+len(message)+s.encryptor.NonceSize())
190-
buffer, err = s.encryptor.Seal(buffer[:], message)
190+
buffer, err = s.encryptor.Seal(buffer, message)
191191
if err != nil {
192192
return newError("failed to encrypt message").Base(err)
193193
}

transport/internet/tlsmirror/server/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (s *connState) WriteMessage(message []byte) error {
173173
}
174174

175175
buffer := make([]byte, explicitNonceReservedOverheadHeaderLength, explicitNonceReservedOverheadHeaderLength+len(message)+s.decryptor.NonceSize())
176-
buffer, err = s.encryptor.Seal(buffer[:], message)
176+
buffer, err = s.encryptor.Seal(buffer, message)
177177
if err != nil {
178178
return newError("failed to encrypt message").Base(err)
179179
}

transport/internet/tlsmirror/server/padding.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import "encoding/binary"
2222
// @param data_OWNERSHIP_RELINQUISHED - The payload, this reference is consumed and should not be used after this call.
2323
// @param padding - The number of padding bytes to add to the data.
2424
func Pack(data_OWNERSHIP_RELINQUISHED []byte, paddingLength int) []byte {
25-
data := append(data_OWNERSHIP_RELINQUISHED, make([]byte, paddingLength)...)
25+
data := append(data_OWNERSHIP_RELINQUISHED, make([]byte, paddingLength)...) //nolint:gocritic
2626
dataLength := len(data_OWNERSHIP_RELINQUISHED)
2727
data = binary.BigEndian.AppendUint32(data, uint32(dataLength))
2828
return data
@@ -47,9 +47,8 @@ func Pad(paddingLength int) []byte {
4747
case 4:
4848
return []byte{0, 0, 0, 0}
4949
default:
50-
return append(make([]byte, paddingLength))
50+
return append(make([]byte, paddingLength)) //nolint:gocritic, govet, staticcheck
5151
}
52-
5352
}
5453

5554
// Unpack extracts the data and padding from the given padded data. It

transport/internet/tlsmirror/tlstrafficgen/trafficgen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (generator *TrafficGenerator) GenerateNextTraffic(ctx context.Context) erro
158158

159159
startTime := time.Now()
160160

161-
resp, err := httpRoundTripper.RoundTrip(httpReq)
161+
resp, err := httpRoundTripper.RoundTrip(httpReq) //nolint:bodyclose
162162
if err != nil {
163163
return newError("failed to send HTTP request").Base(err).AtWarning()
164164
}

transport/internet/transportcommon/httpDialer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (c *unclaimedConnection) tick() {
235235
defer c.access.Unlock()
236236
if !c.claimed {
237237
c.claimed = true
238-
c.Conn.Close()
238+
c.Conn.Close() //nolint: staticcheck
239239
c.Conn = nil
240240
}
241241
}

0 commit comments

Comments
 (0)