From f046feb9caca6271591cc4fe55a081fa449ddcc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 18 May 2022 15:29:01 +0800 Subject: [PATCH] Reformat code --- app/commander/commander.go | 3 +-- app/commander/service.go | 3 +-- app/dispatcher/default.go | 4 ++-- app/dispatcher/fakednssniffer.go | 3 ++- app/dns/dns_test.go | 1 - app/dns/dnscommon.go | 3 +-- app/dns/dnscommon_test.go | 3 +-- app/dns/fakedns/fakedns_test.go | 4 +--- app/dns/hosts_test.go | 1 - app/dns/nameserver_doh.go | 3 +-- app/dns/nameserver_doh_test.go | 1 - app/dns/nameserver_quic.go | 5 ++--- app/dns/nameserver_quic_test.go | 1 - app/dns/nameserver_tcp.go | 3 +-- app/dns/nameserver_tcp_test.go | 1 - app/dns/nameserver_udp.go | 3 +-- app/log/command/command.go | 3 +-- app/log/log_test.go | 1 - app/metrics/metrics.go | 4 ++-- app/observatory/command/command.go | 3 +-- app/observatory/observer.go | 1 - app/proxyman/command/command.go | 3 +-- app/proxyman/inbound/always.go | 1 - app/proxyman/inbound/dynamic.go | 1 - app/reverse/bridge.go | 1 - app/reverse/portal.go | 1 - app/router/balancing.go | 1 + app/router/command/command.go | 3 +-- app/router/command/command_test.go | 5 ++--- app/router/condition.go | 5 ++--- app/router/condition_geoip_test.go | 1 - app/router/condition_test.go | 1 - app/router/router_test.go | 1 - app/router/strategy_leastping.go | 2 +- app/stats/command/command.go | 3 +-- app/stats/command/command_test.go | 1 - common/buf/buffer_test.go | 1 - common/buf/copy_test.go | 1 - common/buf/multi_buffer_test.go | 1 - common/buf/readv_test.go | 3 +-- common/buf/writer_test.go | 1 - common/crypto/auth_test.go | 1 - common/crypto/chacha20_test.go | 1 - common/errors/errors_test.go | 1 - common/log/log_test.go | 1 - common/mux/client_test.go | 1 - common/mux/mux_test.go | 1 - common/net/address_test.go | 1 - common/net/destination_test.go | 1 - common/ocsp/ocsp.go | 3 +-- common/protocol/address_test.go | 1 - common/protocol/dns/io.go | 3 +-- common/protocol/http/headers_test.go | 1 - common/serial/serial_test.go | 1 - common/serial/string_test.go | 1 - common/task/task_test.go | 1 - common/uuid/uuid_test.go | 1 - core/config.go | 1 - core/context_test.go | 2 +- core/functions_test.go | 1 - core/xray_test.go | 1 - features/dns/fakedns.go | 6 ++++-- features/extension/observatory.go | 1 - infra/conf/blackhole.go | 1 - infra/conf/common_test.go | 1 - infra/conf/dns_proxy.go | 1 - infra/conf/dns_test.go | 1 - infra/conf/dokodemo.go | 1 - infra/conf/freedom.go | 1 - infra/conf/general_test.go | 1 - infra/conf/grpc.go | 1 - infra/conf/http.go | 1 - infra/conf/json/reader_test.go | 1 - infra/conf/loopback.go | 1 - infra/conf/mtproto.go | 1 - infra/conf/observatory.go | 1 - infra/conf/reverse.go | 1 - infra/conf/router.go | 1 - infra/conf/router_test.go | 1 - infra/conf/serial/loader.go | 1 - infra/conf/shadowsocks.go | 1 - infra/conf/socks.go | 1 - infra/conf/transport_authenticators.go | 1 - infra/conf/transport_internet.go | 1 - infra/conf/transport_test.go | 1 - infra/conf/trojan.go | 1 - infra/conf/vless.go | 1 - infra/conf/vmess.go | 1 - infra/conf/xray_test.go | 1 - main/commands/all/api/shared.go | 5 ++--- main/commands/all/convert.go | 3 +-- proxy/dns/dns.go | 3 +-- proxy/dns/dns_test.go | 1 - proxy/http/client.go | 3 +-- proxy/mtproto/auth_test.go | 1 - proxy/shadowsocks/config.go | 9 +++------ proxy/shadowsocks/config_test.go | 1 - proxy/shadowsocks/protocol.go | 1 - proxy/shadowsocks/protocol_test.go | 1 - proxy/shadowsocks/validator.go | 4 +--- proxy/socks/protocol_test.go | 1 - proxy/trojan/protocol_test.go | 1 - proxy/trojan/server.go | 3 ++- proxy/vless/encoding/addons.go | 1 - proxy/vless/encoding/encoding_test.go | 1 - proxy/vmess/encoding/auth.go | 3 +-- proxy/vmess/encoding/auth_test.go | 1 - proxy/vmess/encoding/client.go | 3 +-- proxy/vmess/encoding/commands_test.go | 1 - proxy/vmess/encoding/encoding_test.go | 1 - proxy/vmess/encoding/server.go | 4 +--- testing/scenarios/command_test.go | 3 +-- testing/scenarios/common.go | 1 - testing/scenarios/dns_test.go | 3 +-- testing/scenarios/dokodemo_test.go | 3 +-- testing/scenarios/feature_test.go | 3 +-- testing/scenarios/http_test.go | 1 - testing/scenarios/policy_test.go | 3 +-- testing/scenarios/reverse_test.go | 3 +-- testing/scenarios/shadowsocks_test.go | 3 +-- testing/scenarios/socks_test.go | 5 ++--- testing/scenarios/tls_test.go | 3 +-- testing/scenarios/transport_test.go | 3 +-- testing/scenarios/vmess_test.go | 3 +-- transport/internet/dialer_test.go | 1 - transport/internet/domainsocket/listener.go | 3 +-- transport/internet/grpc/dial.go | 11 +++++------ transport/internet/grpc/encoding/hunkconn.go | 5 ++--- transport/internet/grpc/encoding/multiconn.go | 5 ++--- transport/internet/grpc/hub.go | 7 +++---- transport/internet/headers/http/linkedreadRequest.go | 1 - transport/internet/http/dialer.go | 3 +-- transport/internet/http/http_test.go | 1 - transport/internet/http/hub.go | 5 ++--- transport/internet/kcp/crypt_test.go | 1 - transport/internet/kcp/kcp_test.go | 3 +-- transport/internet/kcp/listener.go | 1 - transport/internet/kcp/segment_test.go | 1 - transport/internet/quic/config.go | 3 +-- transport/internet/quic/conn.go | 1 - transport/internet/quic/dialer.go | 1 - transport/internet/quic/hub.go | 1 - transport/internet/quic/quic_test.go | 1 - transport/internet/sockopt_test.go | 1 - transport/internet/system_listener.go | 1 - transport/internet/tcp/hub.go | 4 +--- transport/internet/tls/tls.go | 1 - transport/internet/udp/hub_linux.go | 3 +-- transport/internet/websocket/connection.go | 1 - transport/internet/websocket/dialer.go | 1 - transport/internet/websocket/hub.go | 4 +--- transport/internet/xtls/config.go | 1 - transport/internet/xtls/config_test.go | 1 - 153 files changed, 82 insertions(+), 229 deletions(-) diff --git a/app/commander/commander.go b/app/commander/commander.go index 666a247c..c03da83f 100644 --- a/app/commander/commander.go +++ b/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. diff --git a/app/commander/service.go b/app/commander/service.go index d9bc1760..510f321f 100644 --- a/app/commander/service.go +++ b/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. diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 7143ccfc..93dd348f 100644 --- a/app/dispatcher/default.go +++ b/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)) } diff --git a/app/dispatcher/fakednssniffer.go b/app/dispatcher/fakednssniffer.go index 366b6ff5..ad879daf 100644 --- a/app/dispatcher/fakednssniffer.go +++ b/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{ diff --git a/app/dns/dns_test.go b/app/dns/dns_test.go index 50f2062b..b3a8def8 100644 --- a/app/dns/dns_test.go +++ b/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" diff --git a/app/dns/dnscommon.go b/app/dns/dnscommon.go index 9f5e3795..de0d794c 100644 --- a/app/dns/dnscommon.go +++ b/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 '.' diff --git a/app/dns/dnscommon_test.go b/app/dns/dnscommon_test.go index 76e89688..6530d1a0 100644 --- a/app/dns/dnscommon_test.go +++ b/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) { diff --git a/app/dns/fakedns/fakedns_test.go b/app/dns/fakedns/fakedns_test.go index 2a42b65f..76ccbca6 100644 --- a/app/dns/fakedns/fakedns_test.go +++ b/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" diff --git a/app/dns/hosts_test.go b/app/dns/hosts_test.go index dd8c8813..40533b11 100644 --- a/app/dns/hosts_test.go +++ b/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" diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index 6286c3e5..86161a85 100644 --- a/app/dns/nameserver_doh.go +++ b/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, diff --git a/app/dns/nameserver_doh_test.go b/app/dns/nameserver_doh_test.go index d439a93b..f5cae5a6 100644 --- a/app/dns/nameserver_doh_test.go +++ b/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" diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 83cc3225..63be44ba 100644 --- a/app/dns/nameserver_quic.go +++ b/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 diff --git a/app/dns/nameserver_quic_test.go b/app/dns/nameserver_quic_test.go index 9e87d8e1..cf445b43 100644 --- a/app/dns/nameserver_quic_test.go +++ b/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" diff --git a/app/dns/nameserver_tcp.go b/app/dns/nameserver_tcp.go index 50dc62f0..99206bfc 100644 --- a/app/dns/nameserver_tcp.go +++ b/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). diff --git a/app/dns/nameserver_tcp_test.go b/app/dns/nameserver_tcp_test.go index 4e4ea746..da362355 100644 --- a/app/dns/nameserver_tcp_test.go +++ b/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" diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index 36747016..fc8e5d68 100644 --- a/app/dns/nameserver_udp.go +++ b/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. diff --git a/app/log/command/command.go b/app/log/command/command.go index ef7223f3..74a02d77 100644 --- a/app/log/command/command.go +++ b/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 { diff --git a/app/log/log_test.go b/app/log/log_test.go index ddc765c4..cda55f62 100644 --- a/app/log/log_test.go +++ b/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" diff --git a/app/metrics/metrics.go b/app/metrics/metrics.go index d4c59590..9b0ba071 100644 --- a/app/metrics/metrics.go +++ b/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 { diff --git a/app/observatory/command/command.go b/app/observatory/command/command.go index 9f79207a..0c1fac51 100644 --- a/app/observatory/command/command.go +++ b/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 { diff --git a/app/observatory/observer.go b/app/observatory/observer.go index a86fec10..576818c4 100644 --- a/app/observatory/observer.go +++ b/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" diff --git a/app/proxyman/command/command.go b/app/proxyman/command/command.go index 5f2ec2ae..9782d6c1 100644 --- a/app/proxyman/command/command.go +++ b/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. diff --git a/app/proxyman/inbound/always.go b/app/proxyman/inbound/always.go index 101990b2..f422e626 100644 --- a/app/proxyman/inbound/always.go +++ b/app/proxyman/inbound/always.go @@ -144,7 +144,6 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig * } } } - } return h, nil diff --git a/app/proxyman/inbound/dynamic.go b/app/proxyman/inbound/dynamic.go index 998d3a18..0f81c26e 100644 --- a/app/proxyman/inbound/dynamic.go +++ b/app/proxyman/inbound/dynamic.go @@ -87,7 +87,6 @@ func (h *DynamicInboundHandler) allocatePort() net.Port { return port } } - } func (h *DynamicInboundHandler) closeWorkers(workers []worker) { diff --git a/app/reverse/bridge.go b/app/reverse/bridge.go index cc8b4226..4b86c3a2 100644 --- a/app/reverse/bridge.go +++ b/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" diff --git a/app/reverse/portal.go b/app/reverse/portal.go index 3ad2f949..b0860a6e 100644 --- a/app/reverse/portal.go +++ b/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" diff --git a/app/router/balancing.go b/app/router/balancing.go index b7c43f32..50b84388 100644 --- a/app/router/balancing.go +++ b/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) diff --git a/app/router/command/command.go b/app/router/command/command.go index fff78cb7..58981056 100644 --- a/app/router/command/command.go +++ b/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. diff --git a/app/router/command/command_test.go b/app/router/command/command_test.go index 2322b8a3..b9d252a6 100644 --- a/app/router/command/command_test.go +++ b/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) { diff --git a/app/router/condition.go b/app/router/condition.go index fd421560..cdcb6747 100644 --- a/app/router/condition.go +++ b/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 { diff --git a/app/router/condition_geoip_test.go b/app/router/condition_geoip_test.go index c92a3b78..b5a5ef90 100644 --- a/app/router/condition_geoip_test.go +++ b/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" diff --git a/app/router/condition_test.go b/app/router/condition_test.go index ef473a24..5d98eb43 100644 --- a/app/router/condition_test.go +++ b/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" diff --git a/app/router/router_test.go b/app/router/router_test.go index f77bca8e..1b71e99b 100644 --- a/app/router/router_test.go +++ b/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" diff --git a/app/router/strategy_leastping.go b/app/router/strategy_leastping.go index 0b241576..e8c40aea 100644 --- a/app/router/strategy_leastping.go +++ b/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 "" } diff --git a/app/stats/command/command.go b/app/stats/command/command.go index 3c9f5424..24dc3db6 100644 --- a/app/stats/command/command.go +++ b/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. diff --git a/app/stats/command/command_test.go b/app/stats/command/command_test.go index a58ba982..3f56c7a3 100644 --- a/app/stats/command/command_test.go +++ b/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" diff --git a/common/buf/buffer_test.go b/common/buf/buffer_test.go index 3a49d55f..596ae4e1 100644 --- a/common/buf/buffer_test.go +++ b/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" ) diff --git a/common/buf/copy_test.go b/common/buf/copy_test.go index e5cd5ece..cb2f831b 100644 --- a/common/buf/copy_test.go +++ b/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" diff --git a/common/buf/multi_buffer_test.go b/common/buf/multi_buffer_test.go index 762c3ee3..4f9499af 100644 --- a/common/buf/multi_buffer_test.go +++ b/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" ) diff --git a/common/buf/readv_test.go b/common/buf/readv_test.go index e9f46171..dbab9c76 100644 --- a/common/buf/readv_test.go +++ b/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) { diff --git a/common/buf/writer_test.go b/common/buf/writer_test.go index 686527f5..20c3579a 100644 --- a/common/buf/writer_test.go +++ b/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" diff --git a/common/crypto/auth_test.go b/common/crypto/auth_test.go index 0f293b9a..6af8e0ad 100644 --- a/common/crypto/auth_test.go +++ b/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" diff --git a/common/crypto/chacha20_test.go b/common/crypto/chacha20_test.go index 4a51ea75..a552cdac 100644 --- a/common/crypto/chacha20_test.go +++ b/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" ) diff --git a/common/errors/errors_test.go b/common/errors/errors_test.go index 87537696..a38e8733 100644 --- a/common/errors/errors_test.go +++ b/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" ) diff --git a/common/log/log_test.go b/common/log/log_test.go index 28c47325..fd166cc6 100644 --- a/common/log/log_test.go +++ b/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" ) diff --git a/common/mux/client_test.go b/common/mux/client_test.go index 0063c061..7837a86e 100644 --- a/common/mux/client_test.go +++ b/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" diff --git a/common/mux/mux_test.go b/common/mux/mux_test.go index 282ff210..39def2ab 100644 --- a/common/mux/mux_test.go +++ b/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" diff --git a/common/net/address_test.go b/common/net/address_test.go index 1fec3671..906a7b85 100644 --- a/common/net/address_test.go +++ b/common/net/address_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - . "github.com/xtls/xray-core/common/net" ) diff --git a/common/net/destination_test.go b/common/net/destination_test.go index f6b19a4c..0c2b1854 100644 --- a/common/net/destination_test.go +++ b/common/net/destination_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - . "github.com/xtls/xray-core/common/net" ) diff --git a/common/ocsp/ocsp.go b/common/ocsp/ocsp.go index 7aadf3ef..02140c0d 100644 --- a/common/ocsp/ocsp.go +++ b/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) { diff --git a/common/protocol/address_test.go b/common/protocol/address_test.go index b18adf82..ceecded2 100644 --- a/common/protocol/address_test.go +++ b/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" diff --git a/common/protocol/dns/io.go b/common/protocol/dns/io.go index 1bb22f74..0c215a70 100644 --- a/common/protocol/dns/io.go +++ b/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) { diff --git a/common/protocol/http/headers_test.go b/common/protocol/http/headers_test.go index 80a0402b..80e243ae 100644 --- a/common/protocol/http/headers_test.go +++ b/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" diff --git a/common/serial/serial_test.go b/common/serial/serial_test.go index d6fb86ce..f3cb511a 100644 --- a/common/serial/serial_test.go +++ b/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" diff --git a/common/serial/string_test.go b/common/serial/string_test.go index f0967158..369d1b10 100644 --- a/common/serial/string_test.go +++ b/common/serial/string_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - . "github.com/xtls/xray-core/common/serial" ) diff --git a/common/task/task_test.go b/common/task/task_test.go index d871e03e..87ebe0aa 100644 --- a/common/task/task_test.go +++ b/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" ) diff --git a/common/uuid/uuid_test.go b/common/uuid/uuid_test.go index 7e9b24d8..6f26ca5b 100644 --- a/common/uuid/uuid_test.go +++ b/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" ) diff --git a/core/config.go b/core/config.go index c5318558..5892226b 100644 --- a/core/config.go +++ b/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" diff --git a/core/context_test.go b/core/context_test.go index 423585e1..ec640dfd 100644 --- a/core/context_test.go +++ b/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) { diff --git a/core/functions_test.go b/core/functions_test.go index 2439579e..2355cc03 100644 --- a/core/functions_test.go +++ b/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" diff --git a/core/xray_test.go b/core/xray_test.go index 6a5bc3a9..59de0f46 100644 --- a/core/xray_test.go +++ b/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" diff --git a/features/dns/fakedns.go b/features/dns/fakedns.go index 462bcccf..7aff1fcb 100644 --- a/features/dns/fakedns.go +++ b/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 diff --git a/features/extension/observatory.go b/features/extension/observatory.go index 27252782..eb51a61b 100644 --- a/features/extension/observatory.go +++ b/features/extension/observatory.go @@ -4,7 +4,6 @@ import ( "context" "github.com/golang/protobuf/proto" - "github.com/xtls/xray-core/features" ) diff --git a/infra/conf/blackhole.go b/infra/conf/blackhole.go index e2fdeedc..c1551de1 100644 --- a/infra/conf/blackhole.go +++ b/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" ) diff --git a/infra/conf/common_test.go b/infra/conf/common_test.go index f7c9985b..a5484034 100644 --- a/infra/conf/common_test.go +++ b/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" diff --git a/infra/conf/dns_proxy.go b/infra/conf/dns_proxy.go index c96846e3..90a5d65e 100644 --- a/infra/conf/dns_proxy.go +++ b/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" ) diff --git a/infra/conf/dns_test.go b/infra/conf/dns_test.go index cbd5d672..c97c5bea 100644 --- a/infra/conf/dns_test.go +++ b/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" diff --git a/infra/conf/dokodemo.go b/infra/conf/dokodemo.go index 8c744d01..03a21d71 100644 --- a/infra/conf/dokodemo.go +++ b/infra/conf/dokodemo.go @@ -2,7 +2,6 @@ package conf import ( "github.com/golang/protobuf/proto" - "github.com/xtls/xray-core/proxy/dokodemo" ) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 3ba8e321..60dfd5b8 100644 --- a/infra/conf/freedom.go +++ b/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" diff --git a/infra/conf/general_test.go b/infra/conf/general_test.go index d4fdcc48..1de1109c 100644 --- a/infra/conf/general_test.go +++ b/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" ) diff --git a/infra/conf/grpc.go b/infra/conf/grpc.go index f4d97af5..3813e40d 100644 --- a/infra/conf/grpc.go +++ b/infra/conf/grpc.go @@ -2,7 +2,6 @@ package conf import ( "github.com/golang/protobuf/proto" - "github.com/xtls/xray-core/transport/internet/grpc" ) diff --git a/infra/conf/http.go b/infra/conf/http.go index 54cf178b..c917197c 100644 --- a/infra/conf/http.go +++ b/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" diff --git a/infra/conf/json/reader_test.go b/infra/conf/json/reader_test.go index 145157a0..d30ab072 100644 --- a/infra/conf/json/reader_test.go +++ b/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" ) diff --git a/infra/conf/loopback.go b/infra/conf/loopback.go index 93b1537c..b6d83178 100644 --- a/infra/conf/loopback.go +++ b/infra/conf/loopback.go @@ -2,7 +2,6 @@ package conf import ( "github.com/golang/protobuf/proto" - "github.com/xtls/xray-core/proxy/loopback" ) diff --git a/infra/conf/mtproto.go b/infra/conf/mtproto.go index 4cd5972e..88b02af5 100644 --- a/infra/conf/mtproto.go +++ b/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" diff --git a/infra/conf/observatory.go b/infra/conf/observatory.go index 6dce81ca..25a4d52c 100644 --- a/infra/conf/observatory.go +++ b/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" ) diff --git a/infra/conf/reverse.go b/infra/conf/reverse.go index cfaa2c83..1b42a63a 100644 --- a/infra/conf/reverse.go +++ b/infra/conf/reverse.go @@ -2,7 +2,6 @@ package conf import ( "github.com/golang/protobuf/proto" - "github.com/xtls/xray-core/app/reverse" ) diff --git a/infra/conf/router.go b/infra/conf/router.go index 013a8882..e10317bd 100644 --- a/infra/conf/router.go +++ b/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" diff --git a/infra/conf/router_test.go b/infra/conf/router_test.go index 4a26c3e0..98e31b3a 100644 --- a/infra/conf/router_test.go +++ b/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" diff --git a/infra/conf/serial/loader.go b/infra/conf/serial/loader.go index 9195c6f7..e3235675 100644 --- a/infra/conf/serial/loader.go +++ b/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" diff --git a/infra/conf/shadowsocks.go b/infra/conf/shadowsocks.go index 422b1903..19dd035f 100644 --- a/infra/conf/shadowsocks.go +++ b/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" diff --git a/infra/conf/socks.go b/infra/conf/socks.go index fe9205da..490c24bd 100644 --- a/infra/conf/socks.go +++ b/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" diff --git a/infra/conf/transport_authenticators.go b/infra/conf/transport_authenticators.go index c9e42605..703a1366 100644 --- a/infra/conf/transport_authenticators.go +++ b/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" diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index d2cb35cd..9642b792 100644 --- a/infra/conf/transport_internet.go +++ b/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" diff --git a/infra/conf/transport_test.go b/infra/conf/transport_test.go index 229fd829..3afe9729 100644 --- a/infra/conf/transport_test.go +++ b/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" diff --git a/infra/conf/trojan.go b/infra/conf/trojan.go index 4fe96c07..80ae7bb6 100644 --- a/infra/conf/trojan.go +++ b/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" diff --git a/infra/conf/vless.go b/infra/conf/vless.go index f5ded7a0..a3598d8b 100644 --- a/infra/conf/vless.go +++ b/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" diff --git a/infra/conf/vmess.go b/infra/conf/vmess.go index 9759890d..c646bebb 100644 --- a/infra/conf/vmess.go +++ b/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" diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index 3331518e..8c8151de 100644 --- a/infra/conf/xray_test.go +++ b/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" diff --git a/main/commands/all/api/shared.go b/main/commands/all/api/shared.go index 8fdd5f0a..b0990368 100644 --- a/main/commands/all/api/shared.go +++ b/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 diff --git a/main/commands/all/convert.go b/main/commands/all/convert.go index 4c454861..2ed25a13 100644 --- a/main/commands/all/convert.go +++ b/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{ diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index ae6e3953..ae123c28 100644 --- a/proxy/dns/dns.go +++ b/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() { diff --git a/proxy/dns/dns_test.go b/proxy/dns/dns_test.go index 6a67e2a0..ba6ee00e 100644 --- a/proxy/dns/dns_test.go +++ b/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" diff --git a/proxy/http/client.go b/proxy/http/client.go index 713842f5..ae80e354 100644 --- a/proxy/http/client.go +++ b/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 { diff --git a/proxy/mtproto/auth_test.go b/proxy/mtproto/auth_test.go index 9fc6a9a0..a05bc743 100644 --- a/proxy/mtproto/auth_test.go +++ b/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" ) diff --git a/proxy/shadowsocks/config.go b/proxy/shadowsocks/config.go index a2c56be1..1b977ded 100644 --- a/proxy/shadowsocks/config.go +++ b/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 { diff --git a/proxy/shadowsocks/config_test.go b/proxy/shadowsocks/config_test.go index cfc7a43b..3db6dc2d 100644 --- a/proxy/shadowsocks/config_test.go +++ b/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" diff --git a/proxy/shadowsocks/protocol.go b/proxy/shadowsocks/protocol.go index d310b009..3176d118 100644 --- a/proxy/shadowsocks/protocol.go +++ b/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) } diff --git a/proxy/shadowsocks/protocol_test.go b/proxy/shadowsocks/protocol_test.go index 9453fa74..e1b6495e 100644 --- a/proxy/shadowsocks/protocol_test.go +++ b/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" diff --git a/proxy/shadowsocks/validator.go b/proxy/shadowsocks/validator.go index 5be81447..2aa62e06 100644 --- a/proxy/shadowsocks/validator.go +++ b/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 { diff --git a/proxy/socks/protocol_test.go b/proxy/socks/protocol_test.go index c201ef7d..99e07389 100644 --- a/proxy/socks/protocol_test.go +++ b/proxy/socks/protocol_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" diff --git a/proxy/trojan/protocol_test.go b/proxy/trojan/protocol_test.go index d7c96cca..038f45fd 100644 --- a/proxy/trojan/protocol_test.go +++ b/proxy/trojan/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" diff --git a/proxy/trojan/server.go b/proxy/trojan/server.go index a9ce3da4..27afcfc9 100644 --- a/proxy/trojan/server.go +++ b/proxy/trojan/server.go @@ -343,7 +343,8 @@ func (s *Server) handleUDPPayload(ctx context.Context, clientReader *PacketReade func (s *Server) handleConnection(ctx context.Context, sessionPolicy policy.Session, destination net.Destination, clientReader buf.Reader, - clientWriter buf.Writer, dispatcher routing.Dispatcher, iConn stat.Connection, rawConn syscall.RawConn, statConn *stat.CounterConnection) error { + clientWriter buf.Writer, dispatcher routing.Dispatcher, iConn stat.Connection, rawConn syscall.RawConn, statConn *stat.CounterConnection, +) error { ctx, cancel := context.WithCancel(ctx) timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle) ctx = policy.ContextWithBufferPolicy(ctx, sessionPolicy.Buffer) diff --git a/proxy/vless/encoding/addons.go b/proxy/vless/encoding/addons.go index 8d253b8d..2249e916 100644 --- a/proxy/vless/encoding/addons.go +++ b/proxy/vless/encoding/addons.go @@ -4,7 +4,6 @@ import ( "io" "github.com/golang/protobuf/proto" - "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/proxy/vless" diff --git a/proxy/vless/encoding/encoding_test.go b/proxy/vless/encoding/encoding_test.go index 15b0468e..ee7c6df0 100644 --- a/proxy/vless/encoding/encoding_test.go +++ b/proxy/vless/encoding/encoding_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" diff --git a/proxy/vmess/encoding/auth.go b/proxy/vmess/encoding/auth.go index 09557161..09689cea 100644 --- a/proxy/vmess/encoding/auth.go +++ b/proxy/vmess/encoding/auth.go @@ -5,10 +5,9 @@ import ( "encoding/binary" "hash/fnv" - "golang.org/x/crypto/sha3" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/crypto" + "golang.org/x/crypto/sha3" ) // Authenticate authenticates a byte array using Fnv hash. diff --git a/proxy/vmess/encoding/auth_test.go b/proxy/vmess/encoding/auth_test.go index 87e414c1..ae83076f 100644 --- a/proxy/vmess/encoding/auth_test.go +++ b/proxy/vmess/encoding/auth_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/proxy/vmess/encoding" ) diff --git a/proxy/vmess/encoding/client.go b/proxy/vmess/encoding/client.go index 3d573210..0b535d2a 100644 --- a/proxy/vmess/encoding/client.go +++ b/proxy/vmess/encoding/client.go @@ -13,8 +13,6 @@ import ( "hash/fnv" "io" - "golang.org/x/crypto/chacha20poly1305" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/bitmask" "github.com/xtls/xray-core/common/buf" @@ -25,6 +23,7 @@ import ( "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/proxy/vmess" vmessaead "github.com/xtls/xray-core/proxy/vmess/aead" + "golang.org/x/crypto/chacha20poly1305" ) func hashTimestamp(h hash.Hash, t protocol.Timestamp) []byte { diff --git a/proxy/vmess/encoding/commands_test.go b/proxy/vmess/encoding/commands_test.go index 5b337b46..17892bb6 100644 --- a/proxy/vmess/encoding/commands_test.go +++ b/proxy/vmess/encoding/commands_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/stretchr/testify/assert" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/protocol" diff --git a/proxy/vmess/encoding/encoding_test.go b/proxy/vmess/encoding/encoding_test.go index a7ae364d..a8fd8f3a 100644 --- a/proxy/vmess/encoding/encoding_test.go +++ b/proxy/vmess/encoding/encoding_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" diff --git a/proxy/vmess/encoding/server.go b/proxy/vmess/encoding/server.go index fb2620d6..be83bb31 100644 --- a/proxy/vmess/encoding/server.go +++ b/proxy/vmess/encoding/server.go @@ -12,8 +12,6 @@ import ( "sync" "time" - "golang.org/x/crypto/chacha20poly1305" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/bitmask" "github.com/xtls/xray-core/common/buf" @@ -24,6 +22,7 @@ import ( "github.com/xtls/xray-core/common/task" "github.com/xtls/xray-core/proxy/vmess" vmessaead "github.com/xtls/xray-core/proxy/vmess/aead" + "golang.org/x/crypto/chacha20poly1305" ) type sessionID struct { @@ -140,7 +139,6 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader, isDrain bool) (*pr buffer := buf.New() drainer, err := drain.NewBehaviorSeedLimitedDrainer(int64(s.userValidator.GetBehaviorSeed()), 16+38, 3266, 64) - if err != nil { return nil, newError("failed to initialize drainer").Base(err) } diff --git a/testing/scenarios/command_test.go b/testing/scenarios/command_test.go index 2d1dc5ad..d82e6a37 100644 --- a/testing/scenarios/command_test.go +++ b/testing/scenarios/command_test.go @@ -10,8 +10,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - "google.golang.org/grpc" - "github.com/xtls/xray-core/app/commander" "github.com/xtls/xray-core/app/policy" "github.com/xtls/xray-core/app/proxyman" @@ -31,6 +29,7 @@ import ( "github.com/xtls/xray-core/proxy/vmess/inbound" "github.com/xtls/xray-core/proxy/vmess/outbound" "github.com/xtls/xray-core/testing/servers/tcp" + "google.golang.org/grpc" ) func TestCommanderRemoveHandler(t *testing.T) { diff --git a/testing/scenarios/common.go b/testing/scenarios/common.go index 88477ed6..f011a64f 100644 --- a/testing/scenarios/common.go +++ b/testing/scenarios/common.go @@ -15,7 +15,6 @@ import ( "time" "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" diff --git a/testing/scenarios/dns_test.go b/testing/scenarios/dns_test.go index 81c20a66..3280cbec 100644 --- a/testing/scenarios/dns_test.go +++ b/testing/scenarios/dns_test.go @@ -5,8 +5,6 @@ import ( "testing" "time" - xproxy "golang.org/x/net/proxy" - "github.com/xtls/xray-core/app/dns" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/app/router" @@ -18,6 +16,7 @@ import ( "github.com/xtls/xray-core/proxy/freedom" "github.com/xtls/xray-core/proxy/socks" "github.com/xtls/xray-core/testing/servers/tcp" + xproxy "golang.org/x/net/proxy" ) func TestResolveIP(t *testing.T) { diff --git a/testing/scenarios/dokodemo_test.go b/testing/scenarios/dokodemo_test.go index b13bae27..69032b6e 100644 --- a/testing/scenarios/dokodemo_test.go +++ b/testing/scenarios/dokodemo_test.go @@ -4,8 +4,6 @@ import ( "testing" "time" - "golang.org/x/sync/errgroup" - "github.com/xtls/xray-core/app/log" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" @@ -22,6 +20,7 @@ import ( "github.com/xtls/xray-core/proxy/vmess/outbound" "github.com/xtls/xray-core/testing/servers/tcp" "github.com/xtls/xray-core/testing/servers/udp" + "golang.org/x/sync/errgroup" ) func TestDokodemoTCP(t *testing.T) { diff --git a/testing/scenarios/feature_test.go b/testing/scenarios/feature_test.go index 6a69e2bb..bee4598f 100644 --- a/testing/scenarios/feature_test.go +++ b/testing/scenarios/feature_test.go @@ -8,8 +8,6 @@ import ( "testing" "time" - xproxy "golang.org/x/net/proxy" - "github.com/xtls/xray-core/app/dispatcher" "github.com/xtls/xray-core/app/log" "github.com/xtls/xray-core/app/proxyman" @@ -34,6 +32,7 @@ import ( "github.com/xtls/xray-core/testing/servers/tcp" "github.com/xtls/xray-core/testing/servers/udp" "github.com/xtls/xray-core/transport/internet" + xproxy "golang.org/x/net/proxy" ) func TestPassiveConnection(t *testing.T) { diff --git a/testing/scenarios/http_test.go b/testing/scenarios/http_test.go index c81f089b..d6a765bb 100644 --- a/testing/scenarios/http_test.go +++ b/testing/scenarios/http_test.go @@ -11,7 +11,6 @@ import ( "time" "github.com/google/go-cmp/cmp" - "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" diff --git a/testing/scenarios/policy_test.go b/testing/scenarios/policy_test.go index 463ad020..e45748d5 100644 --- a/testing/scenarios/policy_test.go +++ b/testing/scenarios/policy_test.go @@ -5,8 +5,6 @@ import ( "testing" "time" - "golang.org/x/sync/errgroup" - "github.com/xtls/xray-core/app/log" "github.com/xtls/xray-core/app/policy" "github.com/xtls/xray-core/app/proxyman" @@ -23,6 +21,7 @@ import ( "github.com/xtls/xray-core/proxy/vmess/inbound" "github.com/xtls/xray-core/proxy/vmess/outbound" "github.com/xtls/xray-core/testing/servers/tcp" + "golang.org/x/sync/errgroup" ) func startQuickClosingTCPServer() (net.Listener, error) { diff --git a/testing/scenarios/reverse_test.go b/testing/scenarios/reverse_test.go index 0629a3b2..a87020b6 100644 --- a/testing/scenarios/reverse_test.go +++ b/testing/scenarios/reverse_test.go @@ -4,8 +4,6 @@ import ( "testing" "time" - "golang.org/x/sync/errgroup" - "github.com/xtls/xray-core/app/log" "github.com/xtls/xray-core/app/policy" "github.com/xtls/xray-core/app/proxyman" @@ -25,6 +23,7 @@ import ( "github.com/xtls/xray-core/proxy/vmess/inbound" "github.com/xtls/xray-core/proxy/vmess/outbound" "github.com/xtls/xray-core/testing/servers/tcp" + "golang.org/x/sync/errgroup" ) func TestReverseProxy(t *testing.T) { diff --git a/testing/scenarios/shadowsocks_test.go b/testing/scenarios/shadowsocks_test.go index e1403ab9..d6b8ee82 100644 --- a/testing/scenarios/shadowsocks_test.go +++ b/testing/scenarios/shadowsocks_test.go @@ -4,8 +4,6 @@ import ( "testing" "time" - "golang.org/x/sync/errgroup" - "github.com/xtls/xray-core/app/log" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" @@ -19,6 +17,7 @@ import ( "github.com/xtls/xray-core/proxy/shadowsocks" "github.com/xtls/xray-core/testing/servers/tcp" "github.com/xtls/xray-core/testing/servers/udp" + "golang.org/x/sync/errgroup" ) func TestShadowsocksChaCha20Poly1305TCP(t *testing.T) { diff --git a/testing/scenarios/socks_test.go b/testing/scenarios/socks_test.go index 829646fe..cb158c58 100644 --- a/testing/scenarios/socks_test.go +++ b/testing/scenarios/socks_test.go @@ -4,9 +4,6 @@ import ( "testing" "time" - xproxy "golang.org/x/net/proxy" - socks4 "h12.io/socks" - "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/app/router" "github.com/xtls/xray-core/common" @@ -20,6 +17,8 @@ import ( "github.com/xtls/xray-core/proxy/socks" "github.com/xtls/xray-core/testing/servers/tcp" "github.com/xtls/xray-core/testing/servers/udp" + xproxy "golang.org/x/net/proxy" + socks4 "h12.io/socks" ) func TestSocksBridgeTCP(t *testing.T) { diff --git a/testing/scenarios/tls_test.go b/testing/scenarios/tls_test.go index c7ffc834..cac1d499 100644 --- a/testing/scenarios/tls_test.go +++ b/testing/scenarios/tls_test.go @@ -6,8 +6,6 @@ import ( "testing" "time" - "golang.org/x/sync/errgroup" - "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" @@ -28,6 +26,7 @@ import ( "github.com/xtls/xray-core/transport/internet/http" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/internet/websocket" + "golang.org/x/sync/errgroup" ) func TestSimpleTLSConnection(t *testing.T) { diff --git a/testing/scenarios/transport_test.go b/testing/scenarios/transport_test.go index d8b606de..e1db105e 100644 --- a/testing/scenarios/transport_test.go +++ b/testing/scenarios/transport_test.go @@ -6,8 +6,6 @@ import ( "testing" "time" - "golang.org/x/sync/errgroup" - "github.com/xtls/xray-core/app/log" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" @@ -30,6 +28,7 @@ import ( "github.com/xtls/xray-core/transport/internet/headers/wechat" "github.com/xtls/xray-core/transport/internet/quic" tcptransport "github.com/xtls/xray-core/transport/internet/tcp" + "golang.org/x/sync/errgroup" ) func TestHTTPConnectionHeader(t *testing.T) { diff --git a/testing/scenarios/vmess_test.go b/testing/scenarios/vmess_test.go index c5319521..9f2b0abc 100644 --- a/testing/scenarios/vmess_test.go +++ b/testing/scenarios/vmess_test.go @@ -5,8 +5,6 @@ import ( "testing" "time" - "golang.org/x/sync/errgroup" - "github.com/xtls/xray-core/app/log" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" @@ -25,6 +23,7 @@ import ( "github.com/xtls/xray-core/testing/servers/udp" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/kcp" + "golang.org/x/sync/errgroup" ) func TestVMessDynamicPort(t *testing.T) { diff --git a/transport/internet/dialer_test.go b/transport/internet/dialer_test.go index 232ee709..c20f7a6e 100644 --- a/transport/internet/dialer_test.go +++ b/transport/internet/dialer_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/net" "github.com/xtls/xray-core/testing/servers/tcp" diff --git a/transport/internet/domainsocket/listener.go b/transport/internet/domainsocket/listener.go index c59e515d..a8185d6b 100644 --- a/transport/internet/domainsocket/listener.go +++ b/transport/internet/domainsocket/listener.go @@ -10,14 +10,13 @@ import ( "strings" goxtls "github.com/xtls/go" - "golang.org/x/sys/unix" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/internet/xtls" + "golang.org/x/sys/unix" ) type Listener struct { diff --git a/transport/internet/grpc/dial.go b/transport/internet/grpc/dial.go index 50b09734..07fe40e8 100644 --- a/transport/internet/grpc/dial.go +++ b/transport/internet/grpc/dial.go @@ -6,12 +6,6 @@ import ( "sync" "time" - "google.golang.org/grpc" - "google.golang.org/grpc/backoff" - "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/keepalive" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/session" @@ -19,6 +13,11 @@ import ( "github.com/xtls/xray-core/transport/internet/grpc/encoding" "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" + "google.golang.org/grpc" + "google.golang.org/grpc/backoff" + "google.golang.org/grpc/connectivity" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/keepalive" ) func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) { diff --git a/transport/internet/grpc/encoding/hunkconn.go b/transport/internet/grpc/encoding/hunkconn.go index 44c06322..cfa0d527 100644 --- a/transport/internet/grpc/encoding/hunkconn.go +++ b/transport/internet/grpc/encoding/hunkconn.go @@ -5,13 +5,12 @@ import ( "io" "net" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/peer" - "github.com/xtls/xray-core/common/buf" xnet "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net/cnc" "github.com/xtls/xray-core/common/signal/done" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/peer" ) type HunkConn interface { diff --git a/transport/internet/grpc/encoding/multiconn.go b/transport/internet/grpc/encoding/multiconn.go index 750268ef..ec503947 100644 --- a/transport/internet/grpc/encoding/multiconn.go +++ b/transport/internet/grpc/encoding/multiconn.go @@ -5,13 +5,12 @@ import ( "io" "net" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/peer" - "github.com/xtls/xray-core/common/buf" xnet "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net/cnc" "github.com/xtls/xray-core/common/signal/done" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/peer" ) type MultiHunkConn interface { diff --git a/transport/internet/grpc/hub.go b/transport/internet/grpc/hub.go index 40bb0b51..4f553070 100644 --- a/transport/internet/grpc/hub.go +++ b/transport/internet/grpc/hub.go @@ -4,16 +4,15 @@ import ( "context" "time" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials" - "google.golang.org/grpc/keepalive" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/grpc/encoding" "github.com/xtls/xray-core/transport/internet/tls" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/keepalive" ) type Listener struct { diff --git a/transport/internet/headers/http/linkedreadRequest.go b/transport/internet/headers/http/linkedreadRequest.go index 45773312..a485403e 100644 --- a/transport/internet/headers/http/linkedreadRequest.go +++ b/transport/internet/headers/http/linkedreadRequest.go @@ -3,7 +3,6 @@ package http import ( "bufio" "net/http" - // required to use go:linkname _ "unsafe" ) diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index f9649156..30947103 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -8,8 +8,6 @@ import ( "sync" "time" - "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" @@ -19,6 +17,7 @@ import ( "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/pipe" + "golang.org/x/net/http2" ) type dialerConf struct { diff --git a/transport/internet/http/http_test.go b/transport/internet/http/http_test.go index caf2a509..3639eb84 100644 --- a/transport/internet/http/http_test.go +++ b/transport/internet/http/http_test.go @@ -7,7 +7,6 @@ import ( "time" "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" diff --git a/transport/internet/http/hub.go b/transport/internet/http/hub.go index 4a9b8989..13149267 100644 --- a/transport/internet/http/hub.go +++ b/transport/internet/http/hub.go @@ -7,9 +7,6 @@ import ( "strings" "time" - "golang.org/x/net/http2" - "golang.org/x/net/http2/h2c" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net/cnc" @@ -19,6 +16,8 @@ import ( "github.com/xtls/xray-core/common/signal/done" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/tls" + "golang.org/x/net/http2" + "golang.org/x/net/http2/h2c" ) type Listener struct { diff --git a/transport/internet/kcp/crypt_test.go b/transport/internet/kcp/crypt_test.go index 42b177d7..9b7d6ce6 100644 --- a/transport/internet/kcp/crypt_test.go +++ b/transport/internet/kcp/crypt_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/transport/internet/kcp" ) diff --git a/transport/internet/kcp/kcp_test.go b/transport/internet/kcp/kcp_test.go index 641dd6e3..985d33d2 100644 --- a/transport/internet/kcp/kcp_test.go +++ b/transport/internet/kcp/kcp_test.go @@ -8,14 +8,13 @@ import ( "time" "github.com/google/go-cmp/cmp" - "golang.org/x/sync/errgroup" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/transport/internet" . "github.com/xtls/xray-core/transport/internet/kcp" "github.com/xtls/xray-core/transport/internet/stat" + "golang.org/x/sync/errgroup" ) func TestDialAndListen(t *testing.T) { diff --git a/transport/internet/kcp/listener.go b/transport/internet/kcp/listener.go index aa0443ac..6cf2a539 100644 --- a/transport/internet/kcp/listener.go +++ b/transport/internet/kcp/listener.go @@ -7,7 +7,6 @@ import ( "sync" goxtls "github.com/xtls/go" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" diff --git a/transport/internet/kcp/segment_test.go b/transport/internet/kcp/segment_test.go index 57102342..daa9098a 100644 --- a/transport/internet/kcp/segment_test.go +++ b/transport/internet/kcp/segment_test.go @@ -5,7 +5,6 @@ import ( "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - . "github.com/xtls/xray-core/transport/internet/kcp" ) diff --git a/transport/internet/quic/config.go b/transport/internet/quic/config.go index 6f91ff72..fe13eec6 100644 --- a/transport/internet/quic/config.go +++ b/transport/internet/quic/config.go @@ -5,11 +5,10 @@ import ( "crypto/cipher" "crypto/sha256" - "golang.org/x/crypto/chacha20poly1305" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/transport/internet" + "golang.org/x/crypto/chacha20poly1305" ) func getAuth(config *Config) (cipher.AEAD, error) { diff --git a/transport/internet/quic/conn.go b/transport/internet/quic/conn.go index 648b5fcc..a349eb42 100644 --- a/transport/internet/quic/conn.go +++ b/transport/internet/quic/conn.go @@ -8,7 +8,6 @@ import ( "time" "github.com/lucas-clemente/quic-go" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" diff --git a/transport/internet/quic/dialer.go b/transport/internet/quic/dialer.go index 386952f7..cc0a3a4c 100644 --- a/transport/internet/quic/dialer.go +++ b/transport/internet/quic/dialer.go @@ -9,7 +9,6 @@ import ( "github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go/logging" "github.com/lucas-clemente/quic-go/qlog" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/task" diff --git a/transport/internet/quic/hub.go b/transport/internet/quic/hub.go index 8858bfbf..b879c4bd 100644 --- a/transport/internet/quic/hub.go +++ b/transport/internet/quic/hub.go @@ -8,7 +8,6 @@ import ( "github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go/logging" "github.com/lucas-clemente/quic-go/qlog" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol/tls/cert" diff --git a/transport/internet/quic/quic_test.go b/transport/internet/quic/quic_test.go index c3c82822..ab071058 100644 --- a/transport/internet/quic/quic_test.go +++ b/transport/internet/quic/quic_test.go @@ -7,7 +7,6 @@ import ( "time" "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" diff --git a/transport/internet/sockopt_test.go b/transport/internet/sockopt_test.go index be3f4d90..cc82bc21 100644 --- a/transport/internet/sockopt_test.go +++ b/transport/internet/sockopt_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/testing/servers/tcp" diff --git a/transport/internet/system_listener.go b/transport/internet/system_listener.go index 31fb71ec..730339f5 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -9,7 +9,6 @@ import ( "syscall" "github.com/pires/go-proxyproto" - "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/session" ) diff --git a/transport/internet/tcp/hub.go b/transport/internet/tcp/hub.go index 5ea3a613..828bf972 100644 --- a/transport/internet/tcp/hub.go +++ b/transport/internet/tcp/hub.go @@ -7,7 +7,6 @@ import ( "time" goxtls "github.com/xtls/go" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/session" @@ -39,8 +38,7 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, streamSe if streamSettings.SocketSettings == nil { streamSettings.SocketSettings = &internet.SocketConfig{} } - streamSettings.SocketSettings.AcceptProxyProtocol = - l.config.AcceptProxyProtocol || streamSettings.SocketSettings.AcceptProxyProtocol + streamSettings.SocketSettings.AcceptProxyProtocol = l.config.AcceptProxyProtocol || streamSettings.SocketSettings.AcceptProxyProtocol } var listener net.Listener var err error diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index 8ea2ce0f..48ae8d72 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -4,7 +4,6 @@ import ( "crypto/tls" utls "github.com/refraction-networking/utls" - "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" ) diff --git a/transport/internet/udp/hub_linux.go b/transport/internet/udp/hub_linux.go index 97619c19..07dc472e 100644 --- a/transport/internet/udp/hub_linux.go +++ b/transport/internet/udp/hub_linux.go @@ -6,9 +6,8 @@ package udp import ( "syscall" - "golang.org/x/sys/unix" - "github.com/xtls/xray-core/common/net" + "golang.org/x/sys/unix" ) func RetrieveOriginalDest(oob []byte) net.Destination { diff --git a/transport/internet/websocket/connection.go b/transport/internet/websocket/connection.go index d5dd7419..ca53b619 100644 --- a/transport/internet/websocket/connection.go +++ b/transport/internet/websocket/connection.go @@ -6,7 +6,6 @@ import ( "time" "github.com/gorilla/websocket" - "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/serial" diff --git a/transport/internet/websocket/dialer.go b/transport/internet/websocket/dialer.go index 97177938..284d8dee 100644 --- a/transport/internet/websocket/dialer.go +++ b/transport/internet/websocket/dialer.go @@ -11,7 +11,6 @@ import ( "time" "github.com/gorilla/websocket" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/session" diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index 4f377ebe..c0cf3446 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -12,7 +12,6 @@ import ( "time" "github.com/gorilla/websocket" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" http_proto "github.com/xtls/xray-core/common/protocol/http" @@ -89,8 +88,7 @@ func ListenWS(ctx context.Context, address net.Address, port net.Port, streamSet if streamSettings.SocketSettings == nil { streamSettings.SocketSettings = &internet.SocketConfig{} } - streamSettings.SocketSettings.AcceptProxyProtocol = - l.config.AcceptProxyProtocol || streamSettings.SocketSettings.AcceptProxyProtocol + streamSettings.SocketSettings.AcceptProxyProtocol = l.config.AcceptProxyProtocol || streamSettings.SocketSettings.AcceptProxyProtocol } var listener net.Listener var err error diff --git a/transport/internet/xtls/config.go b/transport/internet/xtls/config.go index bf5283ce..c1d93f4c 100644 --- a/transport/internet/xtls/config.go +++ b/transport/internet/xtls/config.go @@ -9,7 +9,6 @@ import ( "time" xtls "github.com/xtls/go" - "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/ocsp" "github.com/xtls/xray-core/common/platform/filesystem" diff --git a/transport/internet/xtls/config_test.go b/transport/internet/xtls/config_test.go index 6342ba07..bd7fbf1d 100644 --- a/transport/internet/xtls/config_test.go +++ b/transport/internet/xtls/config_test.go @@ -6,7 +6,6 @@ import ( "time" xtls "github.com/xtls/go" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/protocol/tls/cert" . "github.com/xtls/xray-core/transport/internet/xtls"