Browse Source

Chore: Run gofmt (#3990)

pull/3995/head
zonescape 2 weeks ago committed by GitHub
parent
commit
83bab5dd90
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      app/dispatcher/fakednssniffer.go
  2. 2
      app/proxyman/outbound/handler.go
  3. 8
      app/router/strategy_leastload_test.go
  4. 2
      app/router/strategy_random.go
  5. 2
      common/ctx/context.go
  6. 2
      common/singbridge/dialer.go
  7. 2
      features/routing/session/context.go
  8. 2
      infra/conf/router_strategy.go
  9. 2
      main/commands/all/api/shared.go
  10. 2
      proxy/blackhole/blackhole.go
  11. 2
      proxy/shadowsocks/protocol.go
  12. 10
      proxy/trojan/server.go
  13. 1
      proxy/trojan/validator.go
  14. 2
      proxy/wireguard/client.go
  15. 4
      transport/internet/grpc/dial.go
  16. 2
      transport/internet/grpc/hub.go
  17. 6
      transport/internet/tls/config.go

2
app/dispatcher/fakednssniffer.go

@ -28,7 +28,7 @@ func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error)
}
return protocolSnifferWithMetadata{protocolSniffer: func(ctx context.Context, bytes []byte) (SniffResult, error) {
outbounds := session.OutboundsFromContext(ctx)
ob := outbounds[len(outbounds) - 1]
ob := outbounds[len(outbounds)-1]
if ob.Target.Network == net.Network_TCP || ob.Target.Network == net.Network_UDP {
domainFromFakeDNS := fakeDNSEngine.GetDomainFromFakeDNS(ob.Target.Address)
if domainFromFakeDNS != "" {

2
app/proxyman/outbound/handler.go

@ -11,8 +11,8 @@ import (
"github.com/xtls/xray-core/app/proxyman"
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/mux"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/net/cnc"

8
app/router/strategy_leastload_test.go

@ -7,7 +7,7 @@ import (
/*
Split into multiple package, need to be tested separately
func TestSelectLeastLoad(t *testing.T) {
func TestSelectLeastLoad(t *testing.T) {
settings := &StrategyLeastLoadConfig{
HealthCheck: &HealthPingConfig{
SamplingCount: 10,
@ -36,9 +36,9 @@ func TestSelectLeastLoad(t *testing.T) {
if actual != expected {
t.Errorf("expected: %v, actual: %v", expected, actual)
}
}
}
func TestSelectLeastLoadWithCost(t *testing.T) {
func TestSelectLeastLoadWithCost(t *testing.T) {
settings := &StrategyLeastLoadConfig{
HealthCheck: &HealthPingConfig{
SamplingCount: 10,
@ -64,7 +64,7 @@ func TestSelectLeastLoadWithCost(t *testing.T) {
if actual != expected {
t.Errorf("expected: %v, actual: %v", expected, actual)
}
}
}
*/
func TestSelectLeastExpected(t *testing.T) {
strategy := &LeastLoadStrategy{

2
app/router/strategy_random.go

@ -11,7 +11,7 @@ import (
)
// RandomStrategy represents a random balancing strategy
type RandomStrategy struct{
type RandomStrategy struct {
FallbackTag string
ctx context.Context

2
common/ctx/context.go

@ -7,7 +7,7 @@ type SessionKey int
// ID of a session.
type ID uint32
const(
const (
idSessionKey SessionKey = 0
)

2
common/singbridge/dialer.go

@ -48,7 +48,7 @@ func (d *XrayOutboundDialer) DialContext(ctx context.Context, network string, de
outbounds = []*session.Outbound{{}}
ctx = session.ContextWithOutbounds(ctx, outbounds)
}
ob := outbounds[len(outbounds) - 1]
ob := outbounds[len(outbounds)-1]
ob.Target = ToDestination(destination, ToNetwork(network))
opts := []pipe.Option{pipe.WithSizeLimit(64 * 1024)}

2
features/routing/session/context.go

@ -125,7 +125,7 @@ func (ctx *Context) GetSkipDNSResolve() bool {
// AsRoutingContext creates a context from context.context with session info.
func AsRoutingContext(ctx context.Context) routing.Context {
outbounds := session.OutboundsFromContext(ctx)
ob := outbounds[len(outbounds) - 1]
ob := outbounds[len(outbounds)-1]
return &Context{
Inbound: session.InboundFromContext(ctx),
Outbound: ob,

2
infra/conf/router_strategy.go

@ -3,8 +3,8 @@ package conf
import (
"google.golang.org/protobuf/proto"
"github.com/xtls/xray-core/app/router"
"github.com/xtls/xray-core/app/observatory/burst"
"github.com/xtls/xray-core/app/router"
"github.com/xtls/xray-core/infra/conf/cfgcommon/duration"
)

2
main/commands/all/api/shared.go

@ -15,8 +15,8 @@ import (
"google.golang.org/grpc/credentials/insecure"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/main/commands/base"
creflect "github.com/xtls/xray-core/common/reflect"
"github.com/xtls/xray-core/main/commands/base"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
)

2
proxy/blackhole/blackhole.go

@ -30,7 +30,7 @@ func New(ctx context.Context, config *Config) (*Handler, error) {
// Process implements OutboundHandler.Dispatch().
func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error {
outbounds := session.OutboundsFromContext(ctx)
ob := outbounds[len(outbounds) - 1]
ob := outbounds[len(outbounds)-1]
ob.Name = "blackhole"
nBytes := h.response.WriteTo(link.Writer)

2
proxy/shadowsocks/protocol.go

@ -10,9 +10,9 @@ import (
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/crypto"
"github.com/xtls/xray-core/common/drain"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/protocol"
)

10
proxy/trojan/server.go

@ -361,14 +361,14 @@ func (s *Server) fallback(ctx context.Context, err error, sessionPolicy policy.S
cs := tlsConn.ConnectionState()
name = cs.ServerName
alpn = cs.NegotiatedProtocol
errors.LogInfo(ctx, "realName = " + name)
errors.LogInfo(ctx, "realAlpn = " + alpn)
errors.LogInfo(ctx, "realName = "+name)
errors.LogInfo(ctx, "realAlpn = "+alpn)
} else if realityConn, ok := iConn.(*reality.Conn); ok {
cs := realityConn.ConnectionState()
name = cs.ServerName
alpn = cs.NegotiatedProtocol
errors.LogInfo(ctx, "realName = " + name)
errors.LogInfo(ctx, "realAlpn = " + alpn)
errors.LogInfo(ctx, "realName = "+name)
errors.LogInfo(ctx, "realAlpn = "+alpn)
}
name = strings.ToLower(name)
alpn = strings.ToLower(alpn)
@ -418,7 +418,7 @@ func (s *Server) fallback(ctx context.Context, err error, sessionPolicy policy.S
}
if k == '?' || k == ' ' {
path = string(firstBytes[i:j])
errors.LogInfo(ctx, "realPath = " + path)
errors.LogInfo(ctx, "realPath = "+path)
if pfb[path] == nil {
path = ""
}

1
proxy/trojan/validator.go

@ -51,7 +51,6 @@ func (v *Validator) Get(hash string) *protocol.MemoryUser {
return nil
}
// Get a trojan user with hashed key, nil if user doesn't exist.
func (v *Validator) GetByEmail(email string) *protocol.MemoryUser {
u, _ := v.email.Load(email)

2
proxy/wireguard/client.go

@ -29,8 +29,8 @@ import (
"github.com/xtls/xray-core/common"
"github.com/xtls/xray-core/common/buf"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/dice"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/log"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/protocol"

4
transport/internet/grpc/dial.go

@ -56,7 +56,7 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne
}
client := encoding.NewGRPCServiceClient(conn)
if grpcSettings.MultiMode {
errors.LogDebug(ctx, "using gRPC multi mode service name: `" + grpcSettings.getServiceName() + "` stream name: `" + grpcSettings.getTunMultiStreamName() + "`")
errors.LogDebug(ctx, "using gRPC multi mode service name: `"+grpcSettings.getServiceName()+"` stream name: `"+grpcSettings.getTunMultiStreamName()+"`")
grpcService, err := client.(encoding.GRPCServiceClientX).TunMultiCustomName(ctx, grpcSettings.getServiceName(), grpcSettings.getTunMultiStreamName())
if err != nil {
return nil, errors.New("Cannot dial gRPC").Base(err)
@ -64,7 +64,7 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne
return encoding.NewMultiHunkConn(grpcService, nil), nil
}
errors.LogDebug(ctx, "using gRPC tun mode service name: `" + grpcSettings.getServiceName() + "` stream name: `" + grpcSettings.getTunStreamName() + "`")
errors.LogDebug(ctx, "using gRPC tun mode service name: `"+grpcSettings.getServiceName()+"` stream name: `"+grpcSettings.getTunStreamName()+"`")
grpcService, err := client.(encoding.GRPCServiceClientX).TunCustomName(ctx, grpcSettings.getServiceName(), grpcSettings.getTunStreamName())
if err != nil {
return nil, errors.New("Cannot dial gRPC").Base(err)

2
transport/internet/grpc/hub.go

@ -120,7 +120,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, settings *i
}
}
errors.LogDebug(ctx, "gRPC listen for service name `" + grpcSettings.getServiceName() + "` tun `" + grpcSettings.getTunStreamName() + "` multi tun `" + grpcSettings.getTunMultiStreamName() + "`")
errors.LogDebug(ctx, "gRPC listen for service name `"+grpcSettings.getServiceName()+"` tun `"+grpcSettings.getTunStreamName()+"` multi tun `"+grpcSettings.getTunMultiStreamName()+"`")
encoding.RegisterGRPCServiceServerX(s, listener, grpcSettings.getServiceName(), grpcSettings.getTunStreamName(), grpcSettings.getTunMultiStreamName())
if config := reality.ConfigFromStreamSettings(settings); config != nil {

6
transport/internet/tls/config.go

@ -1,6 +1,7 @@
package tls
import (
"bytes"
"context"
"crypto/hmac"
"crypto/tls"
@ -10,7 +11,6 @@ import (
"strings"
"sync"
"time"
"bytes"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/net"
@ -70,7 +70,7 @@ func (c *Config) BuildCertificates() []*tls.Certificate {
continue
}
index := len(certs) - 1
setupOcspTicker(entry, func(isReloaded, isOcspstapling bool){
setupOcspTicker(entry, func(isReloaded, isOcspstapling bool) {
cert := certs[index]
if isReloaded {
if newKeyPair := getX509KeyPair(); newKeyPair != nil {
@ -162,7 +162,7 @@ func (c *Config) getCustomCA() []*Certificate {
for _, certificate := range c.Certificate {
if certificate.Usage == Certificate_AUTHORITY_ISSUE {
certs = append(certs, certificate)
setupOcspTicker(certificate, func(isReloaded, isOcspstapling bool){ })
setupOcspTicker(certificate, func(isReloaded, isOcspstapling bool) {})
}
}
return certs

Loading…
Cancel
Save