From 52458783f8cfa8d0b1ca37853438c8a5a416691a Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Tue, 21 Jan 2025 19:32:12 +0000 Subject: [PATCH] Fixing all the lint errors! --- app/commander/commander.go | 2 +- app/commander/webcommander/webcommander.go | 9 +++------ app/dns/dnscommon_test.go | 2 +- app/router/command/command_test.go | 1 - app/subscription/containers/urlline/parser.go | 5 +++-- .../subscriptionmanager/tracked_subscription.go | 2 +- common/net/packetaddr/packetaddr.go | 2 +- common/platform/platform_test.go | 2 +- infra/conf/v4/transport_internet.go | 7 ++++--- infra/vprotogen/main.go | 4 ++-- main/commands/all/jsonv4/convert.go | 10 +++++----- main/commands/run.go | 2 +- main/plugins/plugin_pprof/plugin_pprof.go | 4 ++-- proxy/hysteria2/client.go | 2 +- proxy/hysteria2/protocol.go | 4 ++-- proxy/hysteria2/server.go | 2 +- proxy/vlite/inbound/inbound.go | 2 +- testing/scenarios/common.go | 5 +++-- transport/internet/httpupgrade/connection.go | 5 +++-- transport/internet/httpupgrade/dialer.go | 3 +-- transport/internet/hysteria2/conn.go | 14 ++++++++------ transport/internet/hysteria2/dialer.go | 12 +++++++----- transport/internet/hysteria2/hub.go | 6 +++--- transport/internet/hysteria2/hy2_transport_test.go | 1 + .../request/assembler/packetconn/req2packet.go | 2 +- .../internet/request/assembler/simple/server.go | 2 +- .../internet/request/stereotype/mekya/mekya.go | 1 + transport/internet/system_listener.go | 2 +- transport/internet/tls/config.go | 4 ++-- transport/internet/tls/ech_go122.go | 2 +- 30 files changed, 63 insertions(+), 58 deletions(-) diff --git a/app/commander/commander.go b/app/commander/commander.go index 76163c292ec..05b6fb57d43 100644 --- a/app/commander/commander.go +++ b/app/commander/commander.go @@ -4,7 +4,6 @@ package commander import ( "context" - "github.com/v2fly/v2ray-core/v5/features" "net" "sync" @@ -14,6 +13,7 @@ import ( "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/serial" "github.com/v2fly/v2ray-core/v5/common/signal/done" + "github.com/v2fly/v2ray-core/v5/features" "github.com/v2fly/v2ray-core/v5/features/outbound" "github.com/v2fly/v2ray-core/v5/infra/conf/v5cfg" ) diff --git a/app/commander/webcommander/webcommander.go b/app/commander/webcommander/webcommander.go index 251b518d89a..7cf93fead11 100644 --- a/app/commander/webcommander/webcommander.go +++ b/app/commander/webcommander/webcommander.go @@ -38,7 +38,6 @@ func newWebCommander(ctx context.Context, config *Config) (*WebCommander, error) } return &WebCommander{ctx: ctx, config: config, webRootfs: webRootfs}, nil - } type WebCommander struct { @@ -56,9 +55,9 @@ type WebCommander struct { } func (w *WebCommander) ServeHTTP(writer http.ResponseWriter, request *http.Request) { - api_path := w.config.ApiMountpoint - if strings.HasPrefix(request.URL.Path, api_path) { - request.URL.Path = strings.TrimPrefix(request.URL.Path, api_path) + apiPath := w.config.ApiMountpoint + if strings.HasPrefix(request.URL.Path, apiPath) { + request.URL.Path = strings.TrimPrefix(request.URL.Path, apiPath) if w.wrappedGrpc.IsGrpcWebRequest(request) { w.wrappedGrpc.ServeHTTP(writer, request) return @@ -109,7 +108,6 @@ func (w *WebCommander) Type() interface{} { } func (w *WebCommander) Start() error { - if err := core.RequireFeatures(w.ctx, func(cm commander.CommanderIfce, om outbound.Manager) { w.Lock() defer w.Unlock() @@ -118,7 +116,6 @@ func (w *WebCommander) Start() error { w.ohm = om go w.asyncStart() - }); err != nil { return err } diff --git a/app/dns/dnscommon_test.go b/app/dns/dnscommon_test.go index 0fce61ddcbd..2ae44ae1862 100644 --- a/app/dns/dnscommon_test.go +++ b/app/dns/dnscommon_test.go @@ -89,7 +89,7 @@ func Test_parseResponse(t *testing.T) { got.Expire = time.Time{} } if cmp.Diff(got, tt.want) != "" { - t.Errorf(cmp.Diff(got, tt.want)) + t.Errorf("%v", cmp.Diff(got, tt.want)) // t.Errorf("handleResponse() = %#v, want %#v", got, tt.want) } }) diff --git a/app/router/command/command_test.go b/app/router/command/command_test.go index dac3b69b0ff..71f99d5f794 100644 --- a/app/router/command/command_test.go +++ b/app/router/command/command_test.go @@ -97,7 +97,6 @@ func TestServiceSubscribeRoutingStats(t *testing.T) { grpc.WithContextDialer(bufDialer), grpc.WithTransportCredentials(insecure.NewCredentials()), ) - if err != nil { errCh <- err return diff --git a/app/subscription/containers/urlline/parser.go b/app/subscription/containers/urlline/parser.go index 0750cf5b912..3528c077886 100644 --- a/app/subscription/containers/urlline/parser.go +++ b/app/subscription/containers/urlline/parser.go @@ -3,10 +3,11 @@ package urlline import ( "bufio" "bytes" - "github.com/v2fly/v2ray-core/v5/app/subscription/containers" - "github.com/v2fly/v2ray-core/v5/common" "net/url" "strings" + + "github.com/v2fly/v2ray-core/v5/app/subscription/containers" + "github.com/v2fly/v2ray-core/v5/common" ) func newURLLineParser() containers.SubscriptionContainerDocumentParser { diff --git a/app/subscription/subscriptionmanager/tracked_subscription.go b/app/subscription/subscriptionmanager/tracked_subscription.go index ee7809ae493..94a29f58ec3 100644 --- a/app/subscription/subscriptionmanager/tracked_subscription.go +++ b/app/subscription/subscriptionmanager/tracked_subscription.go @@ -77,7 +77,7 @@ type materializedServer struct { serverConfig *specs.SubscriptionServerConfig } -func (s *trackedSubscription) fillStatus(status *subscription.TrackedSubscriptionStatus) error { +func (s *trackedSubscription) fillStatus(status *subscription.TrackedSubscriptionStatus) error { //nolint: unparam status.ImportSource = s.importSource if s.currentDocument == nil { return nil diff --git a/common/net/packetaddr/packetaddr.go b/common/net/packetaddr/packetaddr.go index dbe83fc7718..42099a65db0 100644 --- a/common/net/packetaddr/packetaddr.go +++ b/common/net/packetaddr/packetaddr.go @@ -2,10 +2,10 @@ package packetaddr import ( "bytes" - "github.com/v2fly/v2ray-core/v5/common/errors" gonet "net" "github.com/v2fly/v2ray-core/v5/common/buf" + "github.com/v2fly/v2ray-core/v5/common/errors" "github.com/v2fly/v2ray-core/v5/common/net" "github.com/v2fly/v2ray-core/v5/common/protocol" ) diff --git a/common/platform/platform_test.go b/common/platform/platform_test.go index 028bda307cc..35a0862d919 100644 --- a/common/platform/platform_test.go +++ b/common/platform/platform_test.go @@ -57,7 +57,7 @@ func TestWrongErrorCheckOnOSStat(t *testing.T) { // be discovered by the Go runtime, which will lead to failure to // find & read geoip & geosite files. // The correct code is `errors.Is(err, fs.ErrNotExist)` - if _, err := os.Stat(p); err != nil && errors.Is(fs.ErrNotExist, err) { + if _, err := os.Stat(p); err != nil && errors.Is(fs.ErrNotExist, err) { //nolint: staticcheck continue } // asset found diff --git a/infra/conf/v4/transport_internet.go b/infra/conf/v4/transport_internet.go index 61412d95842..9a47f2ad3f8 100644 --- a/infra/conf/v4/transport_internet.go +++ b/infra/conf/v4/transport_internet.go @@ -147,19 +147,20 @@ type Hy2ConfigCongestion struct { type Hy2Config struct { Password string `json:"password"` Congestion Hy2ConfigCongestion `json:"congestion"` - UseUdpExtension bool `json:"use_udp_extension"` + UseUDPExtension bool `json:"use_udp_extension"` IgnoreClientBandwidth bool `json:"ignore_client_bandwidth"` } // Build implements Buildable. func (c *Hy2Config) Build() (proto.Message, error) { - return &hysteria2.Config{Password: c.Password, + return &hysteria2.Config{ + Password: c.Password, Congestion: &hysteria2.Congestion{ Type: c.Congestion.Type, DownMbps: c.Congestion.DownMbps, UpMbps: c.Congestion.UpMbps, }, - UseUdpExtension: c.UseUdpExtension, + UseUdpExtension: c.UseUDPExtension, IgnoreClientBandwidth: c.IgnoreClientBandwidth, }, nil } diff --git a/infra/vprotogen/main.go b/infra/vprotogen/main.go index 05ce25b7fa8..8f878ac5b36 100644 --- a/infra/vprotogen/main.go +++ b/infra/vprotogen/main.go @@ -93,7 +93,7 @@ Command "%s" not found. Make sure that %s is in your system path or current path. Download %s v%s or later from https://github.com/protocolbuffers/protobuf/releases `, protoc, protoc, protoc, targetedVersion) - return "", fmt.Errorf(errStr) + return "", fmt.Errorf("%v", errStr) } return path, nil } @@ -124,7 +124,7 @@ func getInstalledProtocVersion(protocPath string) (string, error) { matched := versionRegexp.FindStringSubmatch(string(output)) installedVersion := "" if len(matched) == 0 { - return "", errors.New("Can not parse protoc version.") + return "", errors.New("can not parse protoc version") } if len(matched) == 2 { diff --git a/main/commands/all/jsonv4/convert.go b/main/commands/all/jsonv4/convert.go index dbda70932f3..b7556ef5914 100644 --- a/main/commands/all/jsonv4/convert.go +++ b/main/commands/all/jsonv4/convert.go @@ -119,7 +119,7 @@ func executeConvert(cmd *base.Command, args []string) { r := bytes.NewReader(data) pbConfig, err := core.LoadConfig(inputFormat, r) if err != nil { - base.Fatalf(err.Error()) + base.Fatalf("%v", err.Error()) } out, err = proto.Marshal(pbConfig) if err != nil { @@ -133,12 +133,12 @@ func executeConvert(cmd *base.Command, args []string) { r := bytes.NewReader(data) pbConfig, err := core.LoadConfig(inputFormat, r) if err != nil { - base.Fatalf(err.Error()) + base.Fatalf("%v", err.Error()) } w := bytes.NewBuffer(nil) err = jsonpb.DumpJSONPb(pbConfig, w) if err != nil { - base.Fatalf(err.Error()) + base.Fatalf("%v", err.Error()) } out = w.Bytes() case v2jsonpb.FormatProtobufV2JSONPB: @@ -149,11 +149,11 @@ func executeConvert(cmd *base.Command, args []string) { r := bytes.NewReader(data) pbConfig, err := core.LoadConfig(inputFormat, r) if err != nil { - base.Fatalf(err.Error()) + base.Fatalf("%v", err.Error()) } out, err = v2jsonpb.DumpV2JsonPb(pbConfig) if err != nil { - base.Fatalf(err.Error()) + base.Fatalf("%v", err.Error()) } default: base.Errorf("invalid output format: %s", outputFormat) diff --git a/main/commands/run.go b/main/commands/run.go index 2fbb7a2bce0..7fce654565e 100644 --- a/main/commands/run.go +++ b/main/commands/run.go @@ -166,7 +166,7 @@ func readConfDirRecursively(dirPath string, extension []string) cmdarg.Arg { func getConfigFilePath() cmdarg.Arg { extension, err := core.GetLoaderExtensions(*configFormat) if err != nil { - base.Fatalf(err.Error()) + base.Fatalf("%v", err.Error()) } dirReader := readConfDir if *configDirRecursively { diff --git a/main/plugins/plugin_pprof/plugin_pprof.go b/main/plugins/plugin_pprof/plugin_pprof.go index 5da1a7b75c7..0bb5e5114c6 100644 --- a/main/plugins/plugin_pprof/plugin_pprof.go +++ b/main/plugins/plugin_pprof/plugin_pprof.go @@ -1,11 +1,11 @@ -package plugin_pprof +package plugin_pprof //nolint: stylecheck import ( - "github.com/v2fly/v2ray-core/v5/main/plugins" "net/http" "net/http/pprof" "github.com/v2fly/v2ray-core/v5/main/commands/base" + "github.com/v2fly/v2ray-core/v5/main/plugins" ) var pprofPlugin plugins.Plugin = func(cmd *base.Command) func() error { diff --git a/proxy/hysteria2/client.go b/proxy/hysteria2/client.go index 4caf6362ae9..c795adcf55b 100644 --- a/proxy/hysteria2/client.go +++ b/proxy/hysteria2/client.go @@ -88,7 +88,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter if !IsHy2Transport && network == net.Network_UDP { // hysteria2 need to use udp extension to proxy UDP. - return newError(hyTransport.CanNotUseUdpExtension) + return newError(hyTransport.CanNotUseUDPExtension) } user := server.PickUser() diff --git a/proxy/hysteria2/protocol.go b/proxy/hysteria2/protocol.go index 6ea7fd33561..823950f7178 100644 --- a/proxy/hysteria2/protocol.go +++ b/proxy/hysteria2/protocol.go @@ -4,8 +4,8 @@ import ( "io" "math/rand" - hyProtocol "github.com/v2fly/hysteria/core/v2/international/protocol" "github.com/apernet/quic-go/quicvarint" + hyProtocol "github.com/v2fly/hysteria/core/v2/international/protocol" "github.com/v2fly/v2ray-core/v5/common/buf" "github.com/v2fly/v2ray-core/v5/common/net" @@ -59,7 +59,7 @@ func (c *ConnWriter) WriteTCPHeader() error { } func QuicLen(s int) int { - return int(quicvarint.Len(uint64(s))) + return quicvarint.Len(uint64(s)) } func (c *ConnWriter) writeTCPHeader() error { diff --git a/proxy/hysteria2/server.go b/proxy/hysteria2/server.go index ec5ffddcbd5..bac9683ce21 100644 --- a/proxy/hysteria2/server.go +++ b/proxy/hysteria2/server.go @@ -67,7 +67,7 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn internet } if !IsHy2Transport && network == net.Network_UDP { - return newError(hyTransport.CanNotUseUdpExtension) + return newError(hyTransport.CanNotUseUDPExtension) } sessionPolicy := s.policyManager.ForLevel(0) diff --git a/proxy/vlite/inbound/inbound.go b/proxy/vlite/inbound/inbound.go index 0e0aa7065d1..98c065df62e 100644 --- a/proxy/vlite/inbound/inbound.go +++ b/proxy/vlite/inbound/inbound.go @@ -146,7 +146,7 @@ func createStatusFromConfig(config *UDPProtocolConfig) (*status, error) { //noli return s, nil } -func enableInterface(s *status) error { +func enableInterface(s *status) error { //nolint: unparam s.transport = s if s.config.EnableStabilization { s.transport = uniserver.NewUnifiedConnectionTransportHub(s, s.ctx) diff --git a/testing/scenarios/common.go b/testing/scenarios/common.go index f23291aac37..05fd4717473 100644 --- a/testing/scenarios/common.go +++ b/testing/scenarios/common.go @@ -4,7 +4,6 @@ import ( "bytes" "crypto/rand" "fmt" - "golang.org/x/net/proxy" "io" "os" "os/exec" @@ -14,6 +13,8 @@ import ( "syscall" "time" + "golang.org/x/net/proxy" + "google.golang.org/protobuf/proto" core "github.com/v2fly/v2ray-core/v5" @@ -169,7 +170,7 @@ func withDefaultApps(config *core.Config) *core.Config { return config } -func testTCPConnViaSocks(socksPort, testPort net.Port, payloadSize int, timeout time.Duration) func() error { +func testTCPConnViaSocks(socksPort, testPort net.Port, payloadSize int, timeout time.Duration) func() error { //nolint: unparam return func() error { socksDialer, err := proxy.SOCKS5("tcp", "127.0.0.1:"+socksPort.String(), nil, nil) if err != nil { diff --git a/transport/internet/httpupgrade/connection.go b/transport/internet/httpupgrade/connection.go index 6a43a4384e1..bd41eb81f09 100644 --- a/transport/internet/httpupgrade/connection.go +++ b/transport/internet/httpupgrade/connection.go @@ -2,11 +2,12 @@ package httpupgrade import ( "context" + "io" + "time" + "github.com/v2fly/v2ray-core/v5/common/buf" "github.com/v2fly/v2ray-core/v5/common/net" "github.com/v2fly/v2ray-core/v5/common/serial" - "io" - "time" ) type connection struct { diff --git a/transport/internet/httpupgrade/dialer.go b/transport/internet/httpupgrade/dialer.go index 14b3e93e972..15d061d2f3e 100644 --- a/transport/internet/httpupgrade/dialer.go +++ b/transport/internet/httpupgrade/dialer.go @@ -43,7 +43,7 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings * earlyDataSize = int(transportConfiguration.MaxEarlyData) } - if earlyData != nil && len(earlyData) > 0 { + if len(earlyData) > 0 { if transportConfiguration.EarlyDataHeaderName == "" { return nil, nil, newError("EarlyDataHeaderName is not set") } @@ -71,7 +71,6 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings * if resp.Status == "101 Switching Protocols" && strings.ToLower(resp.Header.Get("Upgrade")) == "websocket" && strings.ToLower(resp.Header.Get("Connection")) == "upgrade" { - earlyReplyReader := io.LimitReader(bufferedConn, int64(bufferedConn.Buffered())) return conn, earlyReplyReader, nil } diff --git a/transport/internet/hysteria2/conn.go b/transport/internet/hysteria2/conn.go index ac27de0c004..acd43701429 100644 --- a/transport/internet/hysteria2/conn.go +++ b/transport/internet/hysteria2/conn.go @@ -3,16 +3,18 @@ package hysteria2 import ( "time" + "github.com/apernet/quic-go" hyClient "github.com/v2fly/hysteria/core/v2/client" "github.com/v2fly/hysteria/core/v2/international/protocol" hyServer "github.com/v2fly/hysteria/core/v2/server" - "github.com/apernet/quic-go" "github.com/v2fly/v2ray-core/v5/common/net" ) -const CanNotUseUdpExtension = "Only hysteria2 proxy protocol can use udpExtension." -const Hy2MustNeedTLS = "Hysteria2 based on QUIC that requires TLS." +const ( + CanNotUseUDPExtension = "Only hysteria2 proxy protocol can use udpExtension." + Hy2MustNeedTLS = "Hysteria2 based on QUIC that requires TLS." +) type HyConn struct { IsUDPExtension bool @@ -44,7 +46,7 @@ func (c *HyConn) Write(b []byte) (int, error) { func (c *HyConn) WritePacket(b []byte, dest net.Destination) (int, error) { if !c.IsUDPExtension { - return 0, newError(CanNotUseUdpExtension) + return 0, newError(CanNotUseUDPExtension) } if c.IsServer { @@ -64,7 +66,7 @@ func (c *HyConn) WritePacket(b []byte, dest net.Destination) (int, error) { func (c *HyConn) ReadPacket() (int, []byte, *net.Destination, error) { if !c.IsUDPExtension { - return 0, nil, nil, newError(CanNotUseUdpExtension) + return 0, nil, nil, newError(CanNotUseUDPExtension) } if c.IsServer { @@ -89,7 +91,7 @@ func (c *HyConn) ReadPacket() (int, []byte, *net.Destination, error) { func (c *HyConn) Close() error { if c.IsUDPExtension { if !c.IsServer && c.ClientUDPSession == nil || (c.IsServer && c.ServerUDPSession == nil) { - return newError(CanNotUseUdpExtension) + return newError(CanNotUseUDPExtension) } if c.IsServer { c.ServerUDPSession.CloseWithErr(nil) diff --git a/transport/internet/hysteria2/dialer.go b/transport/internet/hysteria2/dialer.go index ca8a708eb9b..575986821f7 100644 --- a/transport/internet/hysteria2/dialer.go +++ b/transport/internet/hysteria2/dialer.go @@ -4,9 +4,9 @@ import ( "context" "sync" + "github.com/apernet/quic-go/quicvarint" hyClient "github.com/v2fly/hysteria/core/v2/client" hyProtocol "github.com/v2fly/hysteria/core/v2/international/protocol" - "github.com/apernet/quic-go/quicvarint" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/net" @@ -20,9 +20,11 @@ type dialerConf struct { *internet.MemoryStreamConfig } -var RunningClient map[dialerConf](hyClient.Client) -var ClientMutex sync.Mutex -var MBps uint64 = 1000000 / 8 // MByte +var ( + RunningClient map[dialerConf](hyClient.Client) + ClientMutex sync.Mutex + MBps uint64 = 1000000 / 8 // MByte +) func GetClientTLSConfig(dest net.Destination, streamSettings *internet.MemoryStreamConfig) (*hyClient.TLSConfig, error) { config := tls.ConfigFromStreamSettings(streamSettings) @@ -190,7 +192,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } // write TCP frame type - frameSize := int(quicvarint.Len(hyProtocol.FrameTypeTCPRequest)) + frameSize := quicvarint.Len(hyProtocol.FrameTypeTCPRequest) buf := make([]byte, frameSize) hyProtocol.VarintPut(buf, hyProtocol.FrameTypeTCPRequest) _, err = conn.stream.Write(buf) diff --git a/transport/internet/hysteria2/hub.go b/transport/internet/hysteria2/hub.go index 9ead1c6bae4..c5c8840deab 100644 --- a/transport/internet/hysteria2/hub.go +++ b/transport/internet/hysteria2/hub.go @@ -3,9 +3,9 @@ package hysteria2 import ( "context" - hyServer "github.com/v2fly/hysteria/core/v2/server" "github.com/apernet/quic-go" "github.com/apernet/quic-go/http3" + hyServer "github.com/v2fly/hysteria/core/v2/server" "github.com/v2fly/v2ray-core/v5/common" "github.com/v2fly/v2ray-core/v5/common/net" @@ -42,7 +42,7 @@ func (l *Listener) StreamHijacker(ft http3.FrameType, conn quic.Connection, stre return true, nil } -func (l *Listener) UdpHijacker(entry *hyServer.UdpSessionEntry, originalAddr string) { +func (l *Listener) UDPHijacker(entry *hyServer.UdpSessionEntry, originalAddr string) { addr, err := net.ResolveUDPAddr("udp", originalAddr) if err != nil { return @@ -90,7 +90,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti Authenticator: &Authenticator{Password: config.GetPassword()}, StreamHijacker: listener.StreamHijacker, // acceptStreams BandwidthConfig: hyServer.BandwidthConfig{MaxTx: config.Congestion.GetUpMbps() * MBps, MaxRx: config.GetCongestion().GetDownMbps() * MBps}, - UdpSessionHijacker: listener.UdpHijacker, // acceptUDPSession + UdpSessionHijacker: listener.UDPHijacker, // acceptUDPSession IgnoreClientBandwidth: config.GetIgnoreClientBandwidth(), }) if err != nil { diff --git a/transport/internet/hysteria2/hy2_transport_test.go b/transport/internet/hysteria2/hy2_transport_test.go index e4a5c1fde88..a816c52030c 100644 --- a/transport/internet/hysteria2/hy2_transport_test.go +++ b/transport/internet/hysteria2/hy2_transport_test.go @@ -127,6 +127,7 @@ func TestUDP(t *testing.T) { time.Sleep(time.Second) address, err := net.ParseDestination("udp:127.0.0.1:1180") + common.Must(err) dctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: address}) conn, err := hysteria2.Dial(dctx, net.TCPDestination(net.LocalHostIP, port), &internet.MemoryStreamConfig{ diff --git a/transport/internet/request/assembler/packetconn/req2packet.go b/transport/internet/request/assembler/packetconn/req2packet.go index c8e7e881ad9..6ad36c1533e 100644 --- a/transport/internet/request/assembler/packetconn/req2packet.go +++ b/transport/internet/request/assembler/packetconn/req2packet.go @@ -122,7 +122,7 @@ copyFromChan: return } } - if resp.Data != nil && len(resp.Data) != 0 { + if len(resp.Data) != 0 { respReader := bytes.NewReader(resp.Data) for respReader.Len() != 0 { packet, err := packetBundler.ReadFromBundle(respReader) diff --git a/transport/internet/request/assembler/simple/server.go b/transport/internet/request/assembler/simple/server.go index 696e732340b..7268afe8cae 100644 --- a/transport/internet/request/assembler/simple/server.go +++ b/transport/internet/request/assembler/simple/server.go @@ -104,7 +104,7 @@ func (s *simpleAssemblerServerSession) Close() error { func (s *simpleAssemblerServerSession) OnRoundTrip(ctx context.Context, req request.Request, opts ...request.RoundTripperOption, ) (resp request.Response, err error) { - if req.Data != nil && len(req.Data) > 0 { + if len(req.Data) > 0 { select { case <-s.ctx.Done(): return request.Response{}, s.ctx.Err() diff --git a/transport/internet/request/stereotype/mekya/mekya.go b/transport/internet/request/stereotype/mekya/mekya.go index 83196d8e787..b52054814ec 100644 --- a/transport/internet/request/stereotype/mekya/mekya.go +++ b/transport/internet/request/stereotype/mekya/mekya.go @@ -56,6 +56,7 @@ func mekyaDial(ctx context.Context, dest net.Destination, streamSettings *intern return internet.Dial(ctx, dest, constructedSetting) } + func mekyaListen(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, callback internet.ConnHandler) (internet.Listener, error) { mekyaSetting := streamSettings.ProtocolSettings.(*Config) packetConnAssembler := &packetconn.ServerConfig{} diff --git a/transport/internet/system_listener.go b/transport/internet/system_listener.go index e9ca184cefe..82897d1090a 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -91,7 +91,7 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S lc.Control = nil network = addr.Network() address = addr.Name - if (runtime.GOOS == "linux" || runtime.GOOS == "android") && address[0] == '@' { + if (runtime.GOOS == "linux" || runtime.GOOS == "android") && address[0] == '@' { //nolint: gocritic // linux abstract unix domain socket is lockfree if len(address) > 1 && address[1] == '@' { // but may need padding to work with haproxy diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index d73f81c3f7e..efa5f92b3f3 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -288,8 +288,8 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { } if len(c.EchConfig) > 0 || len(c.Ech_DOHserver) > 0 { - err := ApplyECH(c, config) - if err != nil { + err := ApplyECH(c, config) //nolint: staticcheck + if err != nil { //nolint: staticcheck newError("unable to set ECH").AtError().Base(err).WriteToLog() } } diff --git a/transport/internet/tls/ech_go122.go b/transport/internet/tls/ech_go122.go index 35ba0fa81f4..4fc205b6047 100644 --- a/transport/internet/tls/ech_go122.go +++ b/transport/internet/tls/ech_go122.go @@ -7,6 +7,6 @@ import ( "crypto/tls" ) -func ApplyECH(c *Config, config *tls.Config) error { +func ApplyECH(c *Config, config *tls.Config) error { //nolint: staticcheck return newError("using ECH require go 1.23 or higher") }