diff --git a/app/dispatcher/fakednssniffer.go b/app/dispatcher/fakednssniffer.go index 495c95ff2..be3ddda19 100644 --- a/app/dispatcher/fakednssniffer.go +++ b/app/dispatcher/fakednssniffer.go @@ -74,10 +74,7 @@ type DNSThenOthersSniffResult struct { } func (f DNSThenOthersSniffResult) IsProtoSubsetOf(protocolName string) bool { - if strings.HasPrefix(protocolName, f.protocolOriginalName) { - return true - } - return false + return strings.HasPrefix(protocolName, f.protocolOriginalName) } func (DNSThenOthersSniffResult) Protocol() string { @@ -88,7 +85,10 @@ func (f DNSThenOthersSniffResult) Domain() string { return f.domainName } -func newFakeDNSThenOthers(ctx context.Context, fakeDNSSniffer protocolSnifferWithMetadata, others []protocolSnifferWithMetadata) (protocolSnifferWithMetadata, error) { +func newFakeDNSThenOthers(ctx context.Context, fakeDNSSniffer protocolSnifferWithMetadata, others []protocolSnifferWithMetadata) ( + protocolSnifferWithMetadata, error) { // nolint: unparam + // ctx may be used in the future + _ = ctx return protocolSnifferWithMetadata{ protocolSniffer: func(ctx context.Context, bytes []byte) (SniffResult, error) { ipAddressInRangeValue := &ipAddressInRangeOpt{} @@ -98,7 +98,7 @@ func newFakeDNSThenOthers(ctx context.Context, fakeDNSSniffer protocolSnifferWit return result, nil } if ipAddressInRangeValue.addressInRange != nil { - if *ipAddressInRangeValue.addressInRange == true { + if *ipAddressInRangeValue.addressInRange { for _, v := range others { if v.metadataSniffer || bytes != nil { if result, err := v.protocolSniffer(ctx, bytes); err == nil { diff --git a/app/dns/fakedns/fakedns_test.go b/app/dns/fakedns/fakedns_test.go index 44229acc5..c19f55dde 100644 --- a/app/dns/fakedns/fakedns_test.go +++ b/app/dns/fakedns/fakedns_test.go @@ -127,6 +127,7 @@ func TestFakeDNSMulti(t *testing.T) { }}, }, ) + common.Must(err) err = fakeMulti.Start() diff --git a/app/observatory/observer.go b/app/observatory/observer.go index 18e934da7..7da459b00 100644 --- a/app/observatory/observer.go +++ b/app/observatory/observer.go @@ -73,14 +73,14 @@ func (o *Observer) background() { } time.Sleep(time.Second * 10) } - } } func (o *Observer) updateStatus(outbounds []string) { o.statusLock.Lock() defer o.statusLock.Unlock() - //TODO should remove old inbound that is removed + // TODO should remove old inbound that is removed + _ = outbounds } func (o *Observer) probe(outbound string) ProbeResult { @@ -93,7 +93,7 @@ func (o *Observer) probe(outbound string) ProbeResult { DialContext: func(ctx context.Context, network string, addr string) (net.Conn, error) { var connection net.Conn taskErr := task.Run(ctx, func() error { - //MUST use V2Fly's built in context system + // MUST use V2Fly's built in context system dest, err := v2net.ParseDestination(network + ":" + addr) if err != nil { return newError("cannot understand address").Base(err) @@ -111,7 +111,7 @@ func (o *Observer) probe(outbound string) ProbeResult { } return connection, nil }, - TLSHandshakeTimeout: time.Duration(time.Second * 5), + TLSHandshakeTimeout: time.Second * 5, } httpClient := &http.Client{ Transport: &httpTransport, @@ -119,7 +119,7 @@ func (o *Observer) probe(outbound string) ProbeResult { return http.ErrUseLastResponse }, Jar: nil, - Timeout: time.Duration(time.Second * 5), + Timeout: time.Second * 5, } var GETTime time.Duration err := task.Run(o.ctx, func() error { diff --git a/app/router/config.go b/app/router/config.go index e4fa2e7ce..e69745380 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -175,6 +175,5 @@ func (br *BalancingRule) Build(ohm outbound.Manager) (*Balancer, error) { strategy: &RandomStrategy{}, ohm: ohm, }, nil - } } diff --git a/app/router/router.go b/app/router/router.go index 351f52333..6e51d1945 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -6,6 +6,7 @@ package router import ( "context" + core "github.com/v2fly/v2ray-core/v4" "github.com/v2fly/v2ray-core/v4/common" "github.com/v2fly/v2ray-core/v4/features/dns" diff --git a/app/router/strategy_leastping.go b/app/router/strategy_leastping.go index 1c00f024f..d5a62039e 100644 --- a/app/router/strategy_leastping.go +++ b/app/router/strategy_leastping.go @@ -47,7 +47,7 @@ func (l *LeastPingStrategy) PickOutbound(strings []string) string { return selectedOutboundName } - //No way to understand observeReport + // No way to understand observeReport return "" } diff --git a/infra/conf/v2ray.go b/infra/conf/v2ray.go index 482c42296..3257bad5e 100644 --- a/infra/conf/v2ray.go +++ b/infra/conf/v2ray.go @@ -580,7 +580,7 @@ func (c *Config) Build() (*core.Config, error) { config.App = append(config.App, serial.ToTypedMessage(r)) } - //Load Additional Services that do not have a json translator + // Load Additional Services that do not have a json translator if msg, err := c.BuildServices(c.Services); err != nil { developererr := newError("Loading a V2Ray Features as a service is intended for developers only. " +