mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
apply coding style
This commit is contained in:
parent
8323add330
commit
d7c9a98d76
@ -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 {
|
||||
|
@ -127,6 +127,7 @@ func TestFakeDNSMulti(t *testing.T) {
|
||||
}},
|
||||
},
|
||||
)
|
||||
common.Must(err)
|
||||
|
||||
err = fakeMulti.Start()
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -175,6 +175,5 @@ func (br *BalancingRule) Build(ohm outbound.Manager) (*Balancer, error) {
|
||||
strategy: &RandomStrategy{},
|
||||
ohm: ohm,
|
||||
}, nil
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -47,7 +47,7 @@ func (l *LeastPingStrategy) PickOutbound(strings []string) string {
|
||||
return selectedOutboundName
|
||||
}
|
||||
|
||||
//No way to understand observeReport
|
||||
// No way to understand observeReport
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -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. " +
|
||||
|
Loading…
Reference in New Issue
Block a user