Browse Source

Reformat code

世界 3 years ago
parent
commit
f046feb9ca
100 changed files with 44 additions and 137 deletions
  1. 1 2
      app/commander/commander.go
  2. 1 2
      app/commander/service.go
  3. 2 2
      app/dispatcher/default.go
  4. 2 1
      app/dispatcher/fakednssniffer.go
  5. 0 1
      app/dns/dns_test.go
  6. 1 2
      app/dns/dnscommon.go
  7. 1 2
      app/dns/dnscommon_test.go
  8. 1 3
      app/dns/fakedns/fakedns_test.go
  9. 0 1
      app/dns/hosts_test.go
  10. 1 2
      app/dns/nameserver_doh.go
  11. 0 1
      app/dns/nameserver_doh_test.go
  12. 2 3
      app/dns/nameserver_quic.go
  13. 0 1
      app/dns/nameserver_quic_test.go
  14. 1 2
      app/dns/nameserver_tcp.go
  15. 0 1
      app/dns/nameserver_tcp_test.go
  16. 1 2
      app/dns/nameserver_udp.go
  17. 1 2
      app/log/command/command.go
  18. 0 1
      app/log/log_test.go
  19. 2 2
      app/metrics/metrics.go
  20. 1 2
      app/observatory/command/command.go
  21. 0 1
      app/observatory/observer.go
  22. 1 2
      app/proxyman/command/command.go
  23. 0 1
      app/proxyman/inbound/always.go
  24. 0 1
      app/proxyman/inbound/dynamic.go
  25. 0 1
      app/reverse/bridge.go
  26. 0 1
      app/reverse/portal.go
  27. 1 0
      app/router/balancing.go
  28. 1 2
      app/router/command/command.go
  29. 2 3
      app/router/command/command_test.go
  30. 2 3
      app/router/condition.go
  31. 0 1
      app/router/condition_geoip_test.go
  32. 0 1
      app/router/condition_test.go
  33. 0 1
      app/router/router_test.go
  34. 1 1
      app/router/strategy_leastping.go
  35. 1 2
      app/stats/command/command.go
  36. 0 1
      app/stats/command/command_test.go
  37. 0 1
      common/buf/buffer_test.go
  38. 0 1
      common/buf/copy_test.go
  39. 0 1
      common/buf/multi_buffer_test.go
  40. 1 2
      common/buf/readv_test.go
  41. 0 1
      common/buf/writer_test.go
  42. 0 1
      common/crypto/auth_test.go
  43. 0 1
      common/crypto/chacha20_test.go
  44. 0 1
      common/errors/errors_test.go
  45. 0 1
      common/log/log_test.go
  46. 0 1
      common/mux/client_test.go
  47. 0 1
      common/mux/mux_test.go
  48. 0 1
      common/net/address_test.go
  49. 0 1
      common/net/destination_test.go
  50. 1 2
      common/ocsp/ocsp.go
  51. 0 1
      common/protocol/address_test.go
  52. 1 2
      common/protocol/dns/io.go
  53. 0 1
      common/protocol/http/headers_test.go
  54. 0 1
      common/serial/serial_test.go
  55. 0 1
      common/serial/string_test.go
  56. 0 1
      common/task/task_test.go
  57. 0 1
      common/uuid/uuid_test.go
  58. 0 1
      core/config.go
  59. 1 1
      core/context_test.go
  60. 0 1
      core/functions_test.go
  61. 0 1
      core/xray_test.go
  62. 4 2
      features/dns/fakedns.go
  63. 0 1
      features/extension/observatory.go
  64. 0 1
      infra/conf/blackhole.go
  65. 0 1
      infra/conf/common_test.go
  66. 0 1
      infra/conf/dns_proxy.go
  67. 0 1
      infra/conf/dns_test.go
  68. 0 1
      infra/conf/dokodemo.go
  69. 0 1
      infra/conf/freedom.go
  70. 0 1
      infra/conf/general_test.go
  71. 0 1
      infra/conf/grpc.go
  72. 0 1
      infra/conf/http.go
  73. 0 1
      infra/conf/json/reader_test.go
  74. 0 1
      infra/conf/loopback.go
  75. 0 1
      infra/conf/mtproto.go
  76. 0 1
      infra/conf/observatory.go
  77. 0 1
      infra/conf/reverse.go
  78. 0 1
      infra/conf/router.go
  79. 0 1
      infra/conf/router_test.go
  80. 0 1
      infra/conf/serial/loader.go
  81. 0 1
      infra/conf/shadowsocks.go
  82. 0 1
      infra/conf/socks.go
  83. 0 1
      infra/conf/transport_authenticators.go
  84. 0 1
      infra/conf/transport_internet.go
  85. 0 1
      infra/conf/transport_test.go
  86. 0 1
      infra/conf/trojan.go
  87. 0 1
      infra/conf/vless.go
  88. 0 1
      infra/conf/vmess.go
  89. 0 1
      infra/conf/xray_test.go
  90. 2 3
      main/commands/all/api/shared.go
  91. 1 2
      main/commands/all/convert.go
  92. 1 2
      proxy/dns/dns.go
  93. 0 1
      proxy/dns/dns_test.go
  94. 1 2
      proxy/http/client.go
  95. 0 1
      proxy/mtproto/auth_test.go
  96. 3 6
      proxy/shadowsocks/config.go
  97. 0 1
      proxy/shadowsocks/config_test.go
  98. 0 1
      proxy/shadowsocks/protocol.go
  99. 0 1
      proxy/shadowsocks/protocol_test.go
  100. 1 3
      proxy/shadowsocks/validator.go

+ 1 - 2
app/commander/commander.go

@@ -7,12 +7,11 @@ import (
 	"net"
 	"sync"
 
-	"google.golang.org/grpc"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/signal/done"
 	core "github.com/xtls/xray-core/core"
 	"github.com/xtls/xray-core/features/outbound"
+	"google.golang.org/grpc"
 )
 
 // Commander is a Xray feature that provides gRPC methods to external clients.

+ 1 - 2
app/commander/service.go

@@ -3,10 +3,9 @@ package commander
 import (
 	"context"
 
+	"github.com/xtls/xray-core/common"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/reflection"
-
-	"github.com/xtls/xray-core/common"
 )
 
 // Service is a Commander service.

+ 2 - 2
app/dispatcher/default.go

@@ -161,7 +161,7 @@ func (d *DefaultDispatcher) getLink(ctx context.Context, network net.Network, sn
 						}
 					}
 				} else {
-					if (ip2domain == nil) {
+					if ip2domain == nil {
 						ip2domain = new(sync.Map)
 						newError("[fakedns client] create a new map").WriteToLog(session.ExportIDToError(ctx))
 					}
@@ -171,7 +171,7 @@ func (d *DefaultDispatcher) getLink(ctx context.Context, network net.Network, sn
 						for _, ip := range ips {
 							ip2domain.Store(ip.String(), domain)
 						}
-						newError("[fakedns client] candidate ip: " + fmt.Sprintf("%v", ips), " for xUDP buffer at ", i).WriteToLog(session.ExportIDToError(ctx))
+						newError("[fakedns client] candidate ip: "+fmt.Sprintf("%v", ips), " for xUDP buffer at ", i).WriteToLog(session.ExportIDToError(ctx))
 					} else {
 						newError("[fakedns client] failed to look up IP for ", domain, " for xUDP buffer at ", i).Base(err).WriteToLog(session.ExportIDToError(ctx))
 					}

+ 2 - 1
app/dispatcher/fakednssniffer.go

@@ -85,7 +85,8 @@ func (f DNSThenOthersSniffResult) Domain() string {
 }
 
 func newFakeDNSThenOthers(ctx context.Context, fakeDNSSniffer protocolSnifferWithMetadata, others []protocolSnifferWithMetadata) (
-	protocolSnifferWithMetadata, error) { // nolint: unparam
+	protocolSnifferWithMetadata, error,
+) { // nolint: unparam
 	// ctx may be used in the future
 	_ = ctx
 	return protocolSnifferWithMetadata{

+ 0 - 1
app/dns/dns_test.go

@@ -6,7 +6,6 @@ import (
 
 	"github.com/google/go-cmp/cmp"
 	"github.com/miekg/dns"
-
 	"github.com/xtls/xray-core/app/dispatcher"
 	. "github.com/xtls/xray-core/app/dns"
 	"github.com/xtls/xray-core/app/policy"

+ 1 - 2
app/dns/dnscommon.go

@@ -5,12 +5,11 @@ import (
 	"strings"
 	"time"
 
-	"golang.org/x/net/dns/dnsmessage"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/errors"
 	"github.com/xtls/xray-core/common/net"
 	dns_feature "github.com/xtls/xray-core/features/dns"
+	"golang.org/x/net/dns/dnsmessage"
 )
 
 // Fqdn normalizes domain make sure it ends with '.'

+ 1 - 2
app/dns/dnscommon_test.go

@@ -7,11 +7,10 @@ import (
 
 	"github.com/google/go-cmp/cmp"
 	"github.com/miekg/dns"
-	"golang.org/x/net/dns/dnsmessage"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"
 	dns_feature "github.com/xtls/xray-core/features/dns"
+	"golang.org/x/net/dns/dnsmessage"
 )
 
 func Test_parseResponse(t *testing.T) {

+ 1 - 3
app/dns/fakedns/fakedns_test.go

@@ -6,13 +6,11 @@ import (
 	"testing"
 
 	"github.com/stretchr/testify/assert"
-
-	"golang.org/x/sync/errgroup"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/uuid"
 	"github.com/xtls/xray-core/features/dns"
+	"golang.org/x/sync/errgroup"
 )
 
 var ipPrefix = "198.1"

+ 0 - 1
app/dns/hosts_test.go

@@ -4,7 +4,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	. "github.com/xtls/xray-core/app/dns"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"

+ 1 - 2
app/dns/nameserver_doh.go

@@ -11,8 +11,6 @@ import (
 	"sync/atomic"
 	"time"
 
-	"golang.org/x/net/dns/dnsmessage"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/log"
 	"github.com/xtls/xray-core/common/net"
@@ -24,6 +22,7 @@ import (
 	dns_feature "github.com/xtls/xray-core/features/dns"
 	"github.com/xtls/xray-core/features/routing"
 	"github.com/xtls/xray-core/transport/internet"
+	"golang.org/x/net/dns/dnsmessage"
 )
 
 // DoHNameServer implemented DNS over HTTPS (RFC8484) Wire Format,

+ 0 - 1
app/dns/nameserver_doh_test.go

@@ -7,7 +7,6 @@ import (
 	"time"
 
 	"github.com/google/go-cmp/cmp"
-
 	. "github.com/xtls/xray-core/app/dns"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"

+ 2 - 3
app/dns/nameserver_quic.go

@@ -8,9 +8,6 @@ import (
 	"time"
 
 	"github.com/lucas-clemente/quic-go"
-	"golang.org/x/net/dns/dnsmessage"
-	"golang.org/x/net/http2"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/net"
@@ -20,6 +17,8 @@ import (
 	"github.com/xtls/xray-core/common/task"
 	dns_feature "github.com/xtls/xray-core/features/dns"
 	"github.com/xtls/xray-core/transport/internet/tls"
+	"golang.org/x/net/dns/dnsmessage"
+	"golang.org/x/net/http2"
 )
 
 // NextProtoDQ - During connection establishment, DNS/QUIC support is indicated

+ 0 - 1
app/dns/nameserver_quic_test.go

@@ -7,7 +7,6 @@ import (
 	"time"
 
 	"github.com/google/go-cmp/cmp"
-
 	. "github.com/xtls/xray-core/app/dns"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"

+ 1 - 2
app/dns/nameserver_tcp.go

@@ -9,8 +9,6 @@ import (
 	"sync/atomic"
 	"time"
 
-	"golang.org/x/net/dns/dnsmessage"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/net"
@@ -22,6 +20,7 @@ import (
 	dns_feature "github.com/xtls/xray-core/features/dns"
 	"github.com/xtls/xray-core/features/routing"
 	"github.com/xtls/xray-core/transport/internet"
+	"golang.org/x/net/dns/dnsmessage"
 )
 
 // TCPNameServer implemented DNS over TCP (RFC7766).

+ 0 - 1
app/dns/nameserver_tcp_test.go

@@ -7,7 +7,6 @@ import (
 	"time"
 
 	"github.com/google/go-cmp/cmp"
-
 	. "github.com/xtls/xray-core/app/dns"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"

+ 1 - 2
app/dns/nameserver_udp.go

@@ -7,8 +7,6 @@ import (
 	"sync/atomic"
 	"time"
 
-	"golang.org/x/net/dns/dnsmessage"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/log"
 	"github.com/xtls/xray-core/common/net"
@@ -21,6 +19,7 @@ import (
 	dns_feature "github.com/xtls/xray-core/features/dns"
 	"github.com/xtls/xray-core/features/routing"
 	"github.com/xtls/xray-core/transport/internet/udp"
+	"golang.org/x/net/dns/dnsmessage"
 )
 
 // ClassicNameServer implemented traditional UDP DNS.

+ 1 - 2
app/log/command/command.go

@@ -5,11 +5,10 @@ package command
 import (
 	"context"
 
-	grpc "google.golang.org/grpc"
-
 	"github.com/xtls/xray-core/app/log"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/core"
+	grpc "google.golang.org/grpc"
 )
 
 type LoggerServer struct {

+ 0 - 1
app/log/log_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/golang/mock/gomock"
-
 	"github.com/xtls/xray-core/app/log"
 	"github.com/xtls/xray-core/common"
 	clog "github.com/xtls/xray-core/common/log"

+ 2 - 2
app/metrics/metrics.go

@@ -39,7 +39,7 @@ func NewMetricsHandler(ctx context.Context, config *Config) (*MetricsHandler, er
 		if !ok {
 			return nil
 		}
-		var resp = map[string]map[string]map[string]int64{
+		resp := map[string]map[string]map[string]int64{
 			"inbound":  {},
 			"outbound": {},
 			"user":     {},
@@ -68,7 +68,7 @@ func NewMetricsHandler(ctx context.Context, config *Config) (*MetricsHandler, er
 				return nil
 			}
 		}
-		var resp = map[string]*observatory.OutboundStatus{}
+		resp := map[string]*observatory.OutboundStatus{}
 		if o, err := c.observatory.GetObservation(context.Background()); err != nil {
 			return err
 		} else {

+ 1 - 2
app/observatory/command/command.go

@@ -6,12 +6,11 @@ package command
 import (
 	"context"
 
-	"google.golang.org/grpc"
-
 	"github.com/xtls/xray-core/app/observatory"
 	"github.com/xtls/xray-core/common"
 	core "github.com/xtls/xray-core/core"
 	"github.com/xtls/xray-core/features/extension"
+	"google.golang.org/grpc"
 )
 
 type service struct {

+ 0 - 1
app/observatory/observer.go

@@ -10,7 +10,6 @@ import (
 	"time"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common"
 	v2net "github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/session"

+ 1 - 2
app/proxyman/command/command.go

@@ -3,13 +3,12 @@ package command
 import (
 	"context"
 
-	grpc "google.golang.org/grpc"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/core"
 	"github.com/xtls/xray-core/features/inbound"
 	"github.com/xtls/xray-core/features/outbound"
 	"github.com/xtls/xray-core/proxy"
+	grpc "google.golang.org/grpc"
 )
 
 // InboundOperation is the interface for operations that applies to inbound handlers.

+ 0 - 1
app/proxyman/inbound/always.go

@@ -144,7 +144,6 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *
 				}
 			}
 		}
-
 	}
 
 	return h, nil

+ 0 - 1
app/proxyman/inbound/dynamic.go

@@ -87,7 +87,6 @@ func (h *DynamicInboundHandler) allocatePort() net.Port {
 			return port
 		}
 	}
-
 }
 
 func (h *DynamicInboundHandler) closeWorkers(workers []worker) {

+ 0 - 1
app/reverse/bridge.go

@@ -5,7 +5,6 @@ import (
 	"time"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/mux"
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/session"

+ 0 - 1
app/reverse/portal.go

@@ -6,7 +6,6 @@ import (
 	"time"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/mux"

+ 1 - 0
app/router/balancing.go

@@ -44,6 +44,7 @@ func (b *Balancer) PickOutbound() (string, error) {
 	}
 	return tag, nil
 }
+
 func (b *Balancer) InjectContext(ctx context.Context) {
 	if contextReceiver, ok := b.strategy.(extension.ContextReceiver); ok {
 		contextReceiver.InjectContext(ctx)

+ 1 - 2
app/router/command/command.go

@@ -6,12 +6,11 @@ import (
 	"context"
 	"time"
 
-	"google.golang.org/grpc"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/core"
 	"github.com/xtls/xray-core/features/routing"
 	"github.com/xtls/xray-core/features/stats"
+	"google.golang.org/grpc"
 )
 
 // routingServer is an implementation of RoutingService.

+ 2 - 3
app/router/command/command_test.go

@@ -8,9 +8,6 @@ import (
 	"github.com/golang/mock/gomock"
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
-	"google.golang.org/grpc"
-	"google.golang.org/grpc/test/bufconn"
-
 	"github.com/xtls/xray-core/app/router"
 	. "github.com/xtls/xray-core/app/router/command"
 	"github.com/xtls/xray-core/app/stats"
@@ -18,6 +15,8 @@ import (
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/features/routing"
 	"github.com/xtls/xray-core/testing/mocks"
+	"google.golang.org/grpc"
+	"google.golang.org/grpc/test/bufconn"
 )
 
 func TestServiceSubscribeRoutingStats(t *testing.T) {

+ 2 - 3
app/router/condition.go

@@ -3,12 +3,11 @@ package router
 import (
 	"strings"
 
-	"go.starlark.net/starlark"
-	"go.starlark.net/syntax"
-
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/strmatcher"
 	"github.com/xtls/xray-core/features/routing"
+	"go.starlark.net/starlark"
+	"go.starlark.net/syntax"
 )
 
 type Condition interface {

+ 0 - 1
app/router/condition_geoip_test.go

@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/app/router"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"

+ 0 - 1
app/router/condition_test.go

@@ -7,7 +7,6 @@ import (
 	"testing"
 
 	"github.com/golang/protobuf/proto"
-
 	. "github.com/xtls/xray-core/app/router"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/errors"

+ 0 - 1
app/router/router_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/golang/mock/gomock"
-
 	. "github.com/xtls/xray-core/app/router"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"

+ 1 - 1
app/router/strategy_leastping.go

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

+ 1 - 2
app/stats/command/command.go

@@ -7,13 +7,12 @@ import (
 	"runtime"
 	"time"
 
-	grpc "google.golang.org/grpc"
-
 	"github.com/xtls/xray-core/app/stats"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/strmatcher"
 	"github.com/xtls/xray-core/core"
 	feature_stats "github.com/xtls/xray-core/features/stats"
+	grpc "google.golang.org/grpc"
 )
 
 // statsServer is an implementation of StatsService.

+ 0 - 1
app/stats/command/command_test.go

@@ -6,7 +6,6 @@ import (
 
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
-
 	"github.com/xtls/xray-core/app/stats"
 	. "github.com/xtls/xray-core/app/stats/command"
 	"github.com/xtls/xray-core/common"

+ 0 - 1
common/buf/buffer_test.go

@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	. "github.com/xtls/xray-core/common/buf"
 )

+ 0 - 1
common/buf/copy_test.go

@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	"github.com/golang/mock/gomock"
-
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/errors"
 	"github.com/xtls/xray-core/testing/mocks"

+ 0 - 1
common/buf/multi_buffer_test.go

@@ -8,7 +8,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	. "github.com/xtls/xray-core/common/buf"
 )

+ 1 - 2
common/buf/readv_test.go

@@ -9,11 +9,10 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-	"golang.org/x/sync/errgroup"
-
 	"github.com/xtls/xray-core/common"
 	. "github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/testing/servers/tcp"
+	"golang.org/x/sync/errgroup"
 )
 
 func TestReadvReader(t *testing.T) {

+ 0 - 1
common/buf/writer_test.go

@@ -8,7 +8,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	. "github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/transport/pipe"

+ 0 - 1
common/crypto/auth_test.go

@@ -9,7 +9,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	. "github.com/xtls/xray-core/common/crypto"

+ 0 - 1
common/crypto/chacha20_test.go

@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	. "github.com/xtls/xray-core/common/crypto"
 )

+ 0 - 1
common/errors/errors_test.go

@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	. "github.com/xtls/xray-core/common/errors"
 	"github.com/xtls/xray-core/common/log"
 )

+ 0 - 1
common/log/log_test.go

@@ -4,7 +4,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common/log"
 	"github.com/xtls/xray-core/common/net"
 )

+ 0 - 1
common/mux/client_test.go

@@ -6,7 +6,6 @@ import (
 	"time"
 
 	"github.com/golang/mock/gomock"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/errors"
 	"github.com/xtls/xray-core/common/mux"

+ 0 - 1
common/mux/mux_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	. "github.com/xtls/xray-core/common/mux"

+ 0 - 1
common/net/address_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	. "github.com/xtls/xray-core/common/net"
 )
 

+ 0 - 1
common/net/destination_test.go

@@ -4,7 +4,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	. "github.com/xtls/xray-core/common/net"
 )
 

+ 1 - 2
common/ocsp/ocsp.go

@@ -8,9 +8,8 @@ import (
 	"net/http"
 	"os"
 
-	"golang.org/x/crypto/ocsp"
-
 	"github.com/xtls/xray-core/common/platform/filesystem"
+	"golang.org/x/crypto/ocsp"
 )
 
 func GetOCSPForFile(path string) ([]byte, error) {

+ 0 - 1
common/protocol/address_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/net"

+ 1 - 2
common/protocol/dns/io.go

@@ -4,11 +4,10 @@ import (
 	"encoding/binary"
 	"sync"
 
-	"golang.org/x/net/dns/dnsmessage"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/serial"
+	"golang.org/x/net/dns/dnsmessage"
 )
 
 func PackMessage(msg *dnsmessage.Message) (*buf.Buffer, error) {

+ 0 - 1
common/protocol/http/headers_test.go

@@ -7,7 +7,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"
 	. "github.com/xtls/xray-core/common/protocol/http"

+ 0 - 1
common/serial/serial_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/serial"

+ 0 - 1
common/serial/string_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	. "github.com/xtls/xray-core/common/serial"
 )
 

+ 0 - 1
common/task/task_test.go

@@ -8,7 +8,6 @@ import (
 	"time"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	. "github.com/xtls/xray-core/common/task"
 )

+ 0 - 1
common/uuid/uuid_test.go

@@ -4,7 +4,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	. "github.com/xtls/xray-core/common/uuid"
 )

+ 0 - 1
core/config.go

@@ -5,7 +5,6 @@ import (
 	"strings"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/cmdarg"

+ 1 - 1
core/context_test.go

@@ -3,9 +3,9 @@ package core_test
 import (
 	"context"
 	"testing"
+	_ "unsafe"
 
 	. "github.com/xtls/xray-core/core"
-	_ "unsafe"
 )
 
 func TestFromContextPanic(t *testing.T) {

+ 0 - 1
core/functions_test.go

@@ -9,7 +9,6 @@ import (
 
 	"github.com/golang/protobuf/proto"
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/app/dispatcher"
 	"github.com/xtls/xray-core/app/proxyman"
 	"github.com/xtls/xray-core/common"

+ 0 - 1
core/xray_test.go

@@ -4,7 +4,6 @@ import (
 	"testing"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/app/dispatcher"
 	"github.com/xtls/xray-core/app/proxyman"
 	"github.com/xtls/xray-core/common"

+ 4 - 2
features/dns/fakedns.go

@@ -11,8 +11,10 @@ type FakeDNSEngine interface {
 	GetDomainFromFakeDNS(ip net.Address) string
 }
 
-var FakeIPv4Pool = "198.18.0.0/15"
-var FakeIPv6Pool = "fc00::/18"
+var (
+	FakeIPv4Pool = "198.18.0.0/15"
+	FakeIPv6Pool = "fc00::/18"
+)
 
 type FakeDNSEngineRev0 interface {
 	FakeDNSEngine

+ 0 - 1
features/extension/observatory.go

@@ -4,7 +4,6 @@ import (
 	"context"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/features"
 )
 

+ 0 - 1
infra/conf/blackhole.go

@@ -4,7 +4,6 @@ import (
 	"encoding/json"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/serial"
 	"github.com/xtls/xray-core/proxy/blackhole"
 )

+ 0 - 1
infra/conf/common_test.go

@@ -7,7 +7,6 @@ import (
 
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp/cmpopts"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/protocol"

+ 0 - 1
infra/conf/dns_proxy.go

@@ -2,7 +2,6 @@ package conf
 
 import (
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/proxy/dns"
 )

+ 0 - 1
infra/conf/dns_test.go

@@ -7,7 +7,6 @@ import (
 	"testing"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/app/dns"
 	"github.com/xtls/xray-core/app/router"
 	"github.com/xtls/xray-core/common"

+ 0 - 1
infra/conf/dokodemo.go

@@ -2,7 +2,6 @@ package conf
 
 import (
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/proxy/dokodemo"
 )
 

+ 0 - 1
infra/conf/freedom.go

@@ -5,7 +5,6 @@ import (
 	"strings"
 
 	"github.com/golang/protobuf/proto"
-
 	v2net "github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/proxy/freedom"

+ 0 - 1
infra/conf/general_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common"
 	. "github.com/xtls/xray-core/infra/conf"
 )

+ 0 - 1
infra/conf/grpc.go

@@ -2,7 +2,6 @@ package conf
 
 import (
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/transport/internet/grpc"
 )
 

+ 0 - 1
infra/conf/http.go

@@ -4,7 +4,6 @@ import (
 	"encoding/json"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/common/serial"
 	"github.com/xtls/xray-core/proxy/http"

+ 0 - 1
infra/conf/json/reader_test.go

@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	. "github.com/xtls/xray-core/infra/conf/json"
 )

+ 0 - 1
infra/conf/loopback.go

@@ -2,7 +2,6 @@ package conf
 
 import (
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/proxy/loopback"
 )
 

+ 0 - 1
infra/conf/mtproto.go

@@ -5,7 +5,6 @@ import (
 	"encoding/json"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/common/serial"
 	"github.com/xtls/xray-core/proxy/mtproto"

+ 0 - 1
infra/conf/observatory.go

@@ -2,7 +2,6 @@ package conf
 
 import (
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/app/observatory"
 	"github.com/xtls/xray-core/infra/conf/cfgcommon/duration"
 )

+ 0 - 1
infra/conf/reverse.go

@@ -2,7 +2,6 @@ package conf
 
 import (
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/app/reverse"
 )
 

+ 0 - 1
infra/conf/router.go

@@ -7,7 +7,6 @@ import (
 	"strings"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/app/router"
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/platform/filesystem"

+ 0 - 1
infra/conf/router_test.go

@@ -8,7 +8,6 @@ import (
 	_ "unsafe"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/app/router"
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/net"

+ 0 - 1
infra/conf/serial/loader.go

@@ -7,7 +7,6 @@ import (
 
 	"github.com/ghodss/yaml"
 	"github.com/pelletier/go-toml"
-
 	"github.com/xtls/xray-core/common/errors"
 	"github.com/xtls/xray-core/core"
 	"github.com/xtls/xray-core/infra/conf"

+ 0 - 1
infra/conf/shadowsocks.go

@@ -4,7 +4,6 @@ import (
 	"strings"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/common/serial"
 	"github.com/xtls/xray-core/proxy/shadowsocks"

+ 0 - 1
infra/conf/socks.go

@@ -5,7 +5,6 @@ import (
 	"strings"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/common/serial"
 	"github.com/xtls/xray-core/proxy/socks"

+ 0 - 1
infra/conf/transport_authenticators.go

@@ -4,7 +4,6 @@ import (
 	"sort"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/transport/internet/headers/http"
 	"github.com/xtls/xray-core/transport/internet/headers/noop"
 	"github.com/xtls/xray-core/transport/internet/headers/srtp"

+ 0 - 1
infra/conf/transport_internet.go

@@ -9,7 +9,6 @@ import (
 	"strings"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/platform/filesystem"
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/common/serial"

+ 0 - 1
infra/conf/transport_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/common/serial"
 	. "github.com/xtls/xray-core/infra/conf"

+ 0 - 1
infra/conf/trojan.go

@@ -7,7 +7,6 @@ import (
 	"syscall"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/common/serial"

+ 0 - 1
infra/conf/vless.go

@@ -7,7 +7,6 @@ import (
 	"syscall"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/net"
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/common/serial"

+ 0 - 1
infra/conf/vmess.go

@@ -5,7 +5,6 @@ import (
 	"strings"
 
 	"github.com/golang/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/protocol"
 	"github.com/xtls/xray-core/common/serial"
 	"github.com/xtls/xray-core/common/uuid"

+ 0 - 1
infra/conf/xray_test.go

@@ -7,7 +7,6 @@ import (
 
 	"github.com/golang/protobuf/proto"
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/app/dispatcher"
 	"github.com/xtls/xray-core/app/log"
 	"github.com/xtls/xray-core/app/proxyman"

+ 2 - 3
main/commands/all/api/shared.go

@@ -13,11 +13,10 @@ import (
 	"strings"
 	"time"
 
-	"google.golang.org/grpc"
-	"google.golang.org/protobuf/proto"
-
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/main/commands/base"
+	"google.golang.org/grpc"
+	"google.golang.org/protobuf/proto"
 )
 
 type serviceHandler func(ctx context.Context, conn *grpc.ClientConn, cmd *base.Command, args []string) string

+ 1 - 2
main/commands/all/convert.go

@@ -10,13 +10,12 @@ import (
 	"strings"
 	"time"
 
-	"google.golang.org/protobuf/proto"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/infra/conf"
 	"github.com/xtls/xray-core/infra/conf/serial"
 	"github.com/xtls/xray-core/main/commands/base"
+	"google.golang.org/protobuf/proto"
 )
 
 var cmdConvert = &base.Command{

+ 1 - 2
proxy/dns/dns.go

@@ -6,8 +6,6 @@ import (
 	"sync"
 	"time"
 
-	"golang.org/x/net/dns/dnsmessage"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/net"
@@ -21,6 +19,7 @@ import (
 	"github.com/xtls/xray-core/transport"
 	"github.com/xtls/xray-core/transport/internet"
 	"github.com/xtls/xray-core/transport/internet/stat"
+	"golang.org/x/net/dns/dnsmessage"
 )
 
 func init() {

+ 0 - 1
proxy/dns/dns_test.go

@@ -7,7 +7,6 @@ import (
 
 	"github.com/google/go-cmp/cmp"
 	"github.com/miekg/dns"
-
 	"github.com/xtls/xray-core/app/dispatcher"
 	dnsapp "github.com/xtls/xray-core/app/dns"
 	"github.com/xtls/xray-core/app/policy"

+ 1 - 2
proxy/http/client.go

@@ -9,8 +9,6 @@ import (
 	"net/url"
 	"sync"
 
-	"golang.org/x/net/http2"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/bytespool"
@@ -26,6 +24,7 @@ import (
 	"github.com/xtls/xray-core/transport/internet"
 	"github.com/xtls/xray-core/transport/internet/stat"
 	"github.com/xtls/xray-core/transport/internet/tls"
+	"golang.org/x/net/http2"
 )
 
 type Client struct {

+ 0 - 1
proxy/mtproto/auth_test.go

@@ -6,7 +6,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	. "github.com/xtls/xray-core/proxy/mtproto"
 )

+ 3 - 6
proxy/shadowsocks/config.go

@@ -8,14 +8,13 @@ import (
 	"crypto/sha1"
 	"io"
 
-	"golang.org/x/crypto/chacha20poly1305"
-	"golang.org/x/crypto/hkdf"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/antireplay"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/crypto"
 	"github.com/xtls/xray-core/common/protocol"
+	"golang.org/x/crypto/chacha20poly1305"
+	"golang.org/x/crypto/hkdf"
 )
 
 // MemoryAccount is an account type converted from Account.
@@ -26,9 +25,7 @@ type MemoryAccount struct {
 	replayFilter antireplay.GeneralizedReplayFilter
 }
 
-var (
-	ErrIVNotUnique = newError("IV is not unique")
-)
+var ErrIVNotUnique = newError("IV is not unique")
 
 // Equals implements protocol.Account.Equals().
 func (a *MemoryAccount) Equals(another protocol.Account) bool {

+ 0 - 1
proxy/shadowsocks/config_test.go

@@ -5,7 +5,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/proxy/shadowsocks"

+ 0 - 1
proxy/shadowsocks/protocol.go

@@ -172,7 +172,6 @@ func ReadTCPResponse(user *protocol.MemoryUser, reader io.Reader) (buf.Reader, e
 	behaviorSeed := crc32.ChecksumIEEE(hashkdf.Sum(nil))
 
 	drainer, err := drain.NewBehaviorSeedLimitedDrainer(int64(behaviorSeed), 16+38, 3266, 64)
-
 	if err != nil {
 		return nil, newError("failed to initialize drainer").Base(err)
 	}

+ 0 - 1
proxy/shadowsocks/protocol_test.go

@@ -4,7 +4,6 @@ import (
 	"testing"
 
 	"github.com/google/go-cmp/cmp"
-
 	"github.com/xtls/xray-core/common"
 	"github.com/xtls/xray-core/common/buf"
 	"github.com/xtls/xray-core/common/net"

+ 1 - 3
proxy/shadowsocks/validator.go

@@ -21,9 +21,7 @@ type Validator struct {
 	behaviorFused bool
 }
 
-var (
-	ErrNotFound = newError("Not Found")
-)
+var ErrNotFound = newError("Not Found")
 
 // Add a Shadowsocks user.
 func (v *Validator) Add(u *protocol.MemoryUser) error {

Some files were not shown because too many files changed in this diff