1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-07-05 16:38:17 -04:00

fix lint issues in tls mirror

This commit is contained in:
Shelikhoo 2025-07-04 17:14:00 +01:00 committed by Xiaokang Wang (Shelikhoo)
parent 19025d330e
commit 800e6f03c9
9 changed files with 11 additions and 12 deletions

View File

@ -50,7 +50,7 @@ linters:
- builtin$
- examples$
issues:
new: true
new: false
formatters:
enable:
- gofmt

View File

@ -294,7 +294,7 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
}
}
if c.Ciphersuites != nil && len(c.Ciphersuites) > 0 {
if len(c.Ciphersuites) > 0 {
config.CipherSuites = make([]uint16, 0, len(c.Ciphersuites))
for _, cs := range c.Ciphersuites {
config.CipherSuites = append(config.CipherSuites, uint16(cs))

View File

@ -16,7 +16,6 @@ import (
// NewMirroredTLSConn creates a new mirrored TLS connection.
// No stable interface
func NewMirroredTLSConn(ctx context.Context, clientConn net.Conn, serverConn net.Conn, onC2SMessage, onS2CMessage tlsmirror.MessageHook, closable common.Closable, explicitNonceDetection tlsmirror.ExplicitNonceDetection) tlsmirror.InsertableTLSConn {
explicitNonceDetectionReady, explicitNonceDetectionOver := context.WithCancel(ctx)
c := &conn{
ctx: ctx,
@ -462,7 +461,7 @@ func (c *conn) GetApplicationDataExplicitNonceReservedOverheadHeaderLength() (in
if c.tls12ExplicitNonce == nil {
return 0, newError("explicit nonce info is not ready")
}
if *c.tls12ExplicitNonce == true {
if *c.tls12ExplicitNonce {
return 8, nil
}
return 0, nil

View File

@ -1,9 +1,10 @@
package mirrorbase
import (
"github.com/google/go-cmp/cmp"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/v2fly/v2ray-core/v5/common/crypto"
)

View File

@ -187,7 +187,7 @@ func (s *clientConnState) WriteMessage(message []byte) error {
return newError("failed to get explicit nonce reserved overhead header length").Base(err)
}
buffer := make([]byte, explicitNonceReservedOverheadHeaderLength, explicitNonceReservedOverheadHeaderLength+len(message)+s.encryptor.NonceSize())
buffer, err = s.encryptor.Seal(buffer[:], message)
buffer, err = s.encryptor.Seal(buffer, message)
if err != nil {
return newError("failed to encrypt message").Base(err)
}

View File

@ -173,7 +173,7 @@ func (s *connState) WriteMessage(message []byte) error {
}
buffer := make([]byte, explicitNonceReservedOverheadHeaderLength, explicitNonceReservedOverheadHeaderLength+len(message)+s.decryptor.NonceSize())
buffer, err = s.encryptor.Seal(buffer[:], message)
buffer, err = s.encryptor.Seal(buffer, message)
if err != nil {
return newError("failed to encrypt message").Base(err)
}

View File

@ -22,7 +22,7 @@ import "encoding/binary"
// @param data_OWNERSHIP_RELINQUISHED - The payload, this reference is consumed and should not be used after this call.
// @param padding - The number of padding bytes to add to the data.
func Pack(data_OWNERSHIP_RELINQUISHED []byte, paddingLength int) []byte {
data := append(data_OWNERSHIP_RELINQUISHED, make([]byte, paddingLength)...)
data := append(data_OWNERSHIP_RELINQUISHED, make([]byte, paddingLength)...) //nolint:gocritic
dataLength := len(data_OWNERSHIP_RELINQUISHED)
data = binary.BigEndian.AppendUint32(data, uint32(dataLength))
return data
@ -47,9 +47,8 @@ func Pad(paddingLength int) []byte {
case 4:
return []byte{0, 0, 0, 0}
default:
return append(make([]byte, paddingLength))
return append(make([]byte, paddingLength)) //nolint:gocritic, govet, staticcheck
}
}
// Unpack extracts the data and padding from the given padded data. It

View File

@ -158,7 +158,7 @@ func (generator *TrafficGenerator) GenerateNextTraffic(ctx context.Context) erro
startTime := time.Now()
resp, err := httpRoundTripper.RoundTrip(httpReq)
resp, err := httpRoundTripper.RoundTrip(httpReq) //nolint:bodyclose
if err != nil {
return newError("failed to send HTTP request").Base(err).AtWarning()
}

View File

@ -235,7 +235,7 @@ func (c *unclaimedConnection) tick() {
defer c.access.Unlock()
if !c.claimed {
c.claimed = true
c.Conn.Close()
c.Conn.Close() //nolint: staticcheck
c.Conn = nil
}
}