1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

apply coding style

This commit is contained in:
Shelikhoo 2021-04-13 16:06:48 +01:00
parent 8323add330
commit d7c9a98d76
No known key found for this signature in database
GPG Key ID: C4D5E79D22B25316
7 changed files with 15 additions and 14 deletions

View File

@ -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 {

View File

@ -127,6 +127,7 @@ func TestFakeDNSMulti(t *testing.T) {
}},
},
)
common.Must(err)
err = fakeMulti.Start()

View File

@ -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 {

View File

@ -175,6 +175,5 @@ func (br *BalancingRule) Build(ohm outbound.Manager) (*Balancer, error) {
strategy: &RandomStrategy{},
ohm: ohm,
}, nil
}
}

View File

@ -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"

View File

@ -47,7 +47,7 @@ func (l *LeastPingStrategy) PickOutbound(strings []string) string {
return selectedOutboundName
}
//No way to understand observeReport
// No way to understand observeReport
return ""
}

View File

@ -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. " +