From ffc2f7c4e2f759d1040a620b2ba019476e6456d4 Mon Sep 17 00:00:00 2001 From: Arthur Morgan <4637240+badO1a5A90@users.noreply.github.com> Date: Mon, 20 Sep 2021 21:00:55 +0800 Subject: [PATCH] Style: format code --- app/commander/service.go | 3 ++- app/dns/dnscommon.go | 3 ++- app/dns/dnscommon_test.go | 3 ++- app/dns/dohdns.go | 3 ++- app/dns/udpns.go | 3 ++- app/log/log_test.go | 1 + app/reverse/bridge.go | 1 + app/reverse/portal.go | 1 + app/router/command/command_test.go | 5 +++-- app/router/condition_geoip_test.go | 1 + app/router/router_test.go | 1 + common/buf/buffer_test.go | 1 + common/buf/multi_buffer_test.go | 1 + common/buf/readv_posix.go | 5 ++--- common/buf/readv_reader.go | 1 + common/buf/readv_reader_wasm.go | 1 + common/buf/readv_test.go | 4 +++- common/buf/readv_unix.go | 1 + common/crypto/internal/chacha_core_gen.go | 1 + common/mux/client_test.go | 1 + common/platform/ctlcmd/attr_other.go | 1 + common/platform/ctlcmd/attr_windows.go | 1 + common/platform/others.go | 1 + common/platform/windows.go | 1 + common/protocol/dns/io.go | 3 ++- infra/conf/dns_proxy.go | 1 + infra/conf/dns_test.go | 1 + infra/conf/dokodemo.go | 1 + infra/conf/fakedns.go | 1 + infra/conf/freedom.go | 1 + infra/conf/general_test.go | 1 + infra/conf/http.go | 1 + infra/conf/reverse.go | 1 + infra/conf/serial/builder.go | 3 ++- infra/conf/socks.go | 1 + infra/conf/transport_internet.go | 1 + infra/conf/transport_test.go | 1 + infra/conf/xray.go | 3 ++- infra/conf/xray_test.go | 1 + main/commands/all/convert.go | 3 ++- main/main_test.go | 1 + proxy/dokodemo/fakeudp_linux.go | 1 + proxy/dokodemo/fakeudp_other.go | 1 + proxy/trojan/protocol_test.go | 1 + proxy/vmess/encoding/server.go | 3 ++- proxy/vmess/inbound/inbound.go | 2 +- testing/scenarios/common.go | 1 + testing/scenarios/common_coverage.go | 1 + testing/scenarios/common_regular.go | 1 + testing/scenarios/dns_test.go | 3 ++- testing/scenarios/feature_test.go | 3 ++- testing/scenarios/shadowsocks_test.go | 20 +++++++++---------- testing/scenarios/vmess_test.go | 3 ++- transport/internet/domainsocket/dial.go | 4 ++-- transport/internet/domainsocket/listener.go | 4 ++-- .../internet/domainsocket/listener_test.go | 4 ++-- transport/internet/filelocker_other.go | 1 + transport/internet/http/dialer.go | 3 ++- transport/internet/kcp/xor.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/sockopt_other.go | 1 + transport/internet/sockopt_test.go | 1 + transport/internet/system_listener.go | 1 + transport/internet/tcp/sockopt_freebsd.go | 1 + transport/internet/tcp/sockopt_linux.go | 1 + transport/internet/tcp/sockopt_linux_test.go | 1 + transport/internet/tcp/sockopt_other.go | 1 + transport/internet/tls/config_other.go | 1 + transport/internet/tls/config_windows.go | 1 + transport/internet/udp/hub_freebsd.go | 1 + transport/internet/udp/hub_linux.go | 4 +++- transport/internet/udp/hub_other.go | 1 + transport/internet/websocket/connection.go | 1 + transport/internet/xtls/config_other.go | 1 + transport/internet/xtls/config_windows.go | 1 + 78 files changed, 112 insertions(+), 39 deletions(-) diff --git a/app/commander/service.go b/app/commander/service.go index 510f321f..d9bc1760 100644 --- a/app/commander/service.go +++ b/app/commander/service.go @@ -3,9 +3,10 @@ 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/dns/dnscommon.go b/app/dns/dnscommon.go index 6f1fada2..0d465713 100644 --- a/app/dns/dnscommon.go +++ b/app/dns/dnscommon.go @@ -5,11 +5,12 @@ 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 normalize domain make sure it ends with '.' diff --git a/app/dns/dnscommon_test.go b/app/dns/dnscommon_test.go index 58462655..f089f306 100644 --- a/app/dns/dnscommon_test.go +++ b/app/dns/dnscommon_test.go @@ -7,10 +7,11 @@ 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/dohdns.go b/app/dns/dohdns.go index c863a5d0..b204e769 100644 --- a/app/dns/dohdns.go +++ b/app/dns/dohdns.go @@ -12,6 +12,8 @@ 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" @@ -23,7 +25,6 @@ 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/udpns.go b/app/dns/udpns.go index 4f26a773..cb4cffe5 100644 --- a/app/dns/udpns.go +++ b/app/dns/udpns.go @@ -7,6 +7,8 @@ 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" @@ -18,7 +20,6 @@ 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" ) type ClassicNameServer struct { diff --git a/app/log/log_test.go b/app/log/log_test.go index cda55f62..ddc765c4 100644 --- a/app/log/log_test.go +++ b/app/log/log_test.go @@ -5,6 +5,7 @@ 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/reverse/bridge.go b/app/reverse/bridge.go index 32226447..bef40a3a 100644 --- a/app/reverse/bridge.go +++ b/app/reverse/bridge.go @@ -5,6 +5,7 @@ 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 b0860a6e..3ad2f949 100644 --- a/app/reverse/portal.go +++ b/app/reverse/portal.go @@ -6,6 +6,7 @@ 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/command/command_test.go b/app/router/command/command_test.go index e8e50cc6..2dce1838 100644 --- a/app/router/command/command_test.go +++ b/app/router/command/command_test.go @@ -8,6 +8,9 @@ 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" @@ -15,8 +18,6 @@ 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_geoip_test.go b/app/router/condition_geoip_test.go index 596478c6..3332be3c 100644 --- a/app/router/condition_geoip_test.go +++ b/app/router/condition_geoip_test.go @@ -6,6 +6,7 @@ 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/router_test.go b/app/router/router_test.go index 14ce8a3d..cc8e2b3a 100644 --- a/app/router/router_test.go +++ b/app/router/router_test.go @@ -5,6 +5,7 @@ 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/common/buf/buffer_test.go b/common/buf/buffer_test.go index 811ef0c7..7b0a7924 100644 --- a/common/buf/buffer_test.go +++ b/common/buf/buffer_test.go @@ -6,6 +6,7 @@ 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/multi_buffer_test.go b/common/buf/multi_buffer_test.go index bdcd6e34..5e1b1cb9 100644 --- a/common/buf/multi_buffer_test.go +++ b/common/buf/multi_buffer_test.go @@ -9,6 +9,7 @@ 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_posix.go b/common/buf/readv_posix.go index 9fbee794..eb63e3cc 100644 --- a/common/buf/readv_posix.go +++ b/common/buf/readv_posix.go @@ -1,6 +1,5 @@ -// +build !windows -// +build !wasm -// +build !illumos +//go:build !windows && !wasm && !illumos +// +build !windows,!wasm,!illumos package buf diff --git a/common/buf/readv_reader.go b/common/buf/readv_reader.go index 14e93571..9a93baca 100644 --- a/common/buf/readv_reader.go +++ b/common/buf/readv_reader.go @@ -1,3 +1,4 @@ +//go:build !wasm // +build !wasm package buf diff --git a/common/buf/readv_reader_wasm.go b/common/buf/readv_reader_wasm.go index a4d9fa67..30b52e74 100644 --- a/common/buf/readv_reader_wasm.go +++ b/common/buf/readv_reader_wasm.go @@ -1,3 +1,4 @@ +//go:build wasm // +build wasm package buf diff --git a/common/buf/readv_test.go b/common/buf/readv_test.go index 6bca9491..98ae8894 100644 --- a/common/buf/readv_test.go +++ b/common/buf/readv_test.go @@ -1,3 +1,4 @@ +//go:build !wasm // +build !wasm package buf_test @@ -9,10 +10,11 @@ import ( "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/readv_unix.go b/common/buf/readv_unix.go index 8c8bb970..f5ac6ad1 100644 --- a/common/buf/readv_unix.go +++ b/common/buf/readv_unix.go @@ -1,3 +1,4 @@ +//go:build illumos // +build illumos package buf diff --git a/common/crypto/internal/chacha_core_gen.go b/common/crypto/internal/chacha_core_gen.go index 0058bd43..a77a9250 100644 --- a/common/crypto/internal/chacha_core_gen.go +++ b/common/crypto/internal/chacha_core_gen.go @@ -1,3 +1,4 @@ +//go:build generate // +build generate package main diff --git a/common/mux/client_test.go b/common/mux/client_test.go index 7837a86e..0063c061 100644 --- a/common/mux/client_test.go +++ b/common/mux/client_test.go @@ -6,6 +6,7 @@ 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/platform/ctlcmd/attr_other.go b/common/platform/ctlcmd/attr_other.go index 8dfe963d..3e1bc265 100644 --- a/common/platform/ctlcmd/attr_other.go +++ b/common/platform/ctlcmd/attr_other.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package ctlcmd diff --git a/common/platform/ctlcmd/attr_windows.go b/common/platform/ctlcmd/attr_windows.go index b4c1c5f8..ab8ac064 100644 --- a/common/platform/ctlcmd/attr_windows.go +++ b/common/platform/ctlcmd/attr_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package ctlcmd diff --git a/common/platform/others.go b/common/platform/others.go index 1ad58848..a4465794 100644 --- a/common/platform/others.go +++ b/common/platform/others.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package platform diff --git a/common/platform/windows.go b/common/platform/windows.go index 17ee35e7..aa912cf6 100644 --- a/common/platform/windows.go +++ b/common/platform/windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package platform diff --git a/common/protocol/dns/io.go b/common/protocol/dns/io.go index 0c215a70..1bb22f74 100644 --- a/common/protocol/dns/io.go +++ b/common/protocol/dns/io.go @@ -4,10 +4,11 @@ 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/infra/conf/dns_proxy.go b/infra/conf/dns_proxy.go index 922d32ba..3e8cd81f 100644 --- a/infra/conf/dns_proxy.go +++ b/infra/conf/dns_proxy.go @@ -2,6 +2,7 @@ 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 421fb877..59d0dc41 100644 --- a/infra/conf/dns_test.go +++ b/infra/conf/dns_test.go @@ -7,6 +7,7 @@ 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 03a21d71..8c744d01 100644 --- a/infra/conf/dokodemo.go +++ b/infra/conf/dokodemo.go @@ -2,6 +2,7 @@ package conf import ( "github.com/golang/protobuf/proto" + "github.com/xtls/xray-core/proxy/dokodemo" ) diff --git a/infra/conf/fakedns.go b/infra/conf/fakedns.go index a047ee9f..10f63e89 100644 --- a/infra/conf/fakedns.go +++ b/infra/conf/fakedns.go @@ -2,6 +2,7 @@ package conf import ( "github.com/golang/protobuf/proto" + "github.com/xtls/xray-core/app/dns/fakedns" "github.com/xtls/xray-core/features/dns" ) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 29e778d2..7ef1cff1 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -5,6 +5,7 @@ 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 1de1109c..d4fdcc48 100644 --- a/infra/conf/general_test.go +++ b/infra/conf/general_test.go @@ -5,6 +5,7 @@ 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/http.go b/infra/conf/http.go index e6969582..d3d944f6 100644 --- a/infra/conf/http.go +++ b/infra/conf/http.go @@ -4,6 +4,7 @@ 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/reverse.go b/infra/conf/reverse.go index 1b42a63a..cfaa2c83 100644 --- a/infra/conf/reverse.go +++ b/infra/conf/reverse.go @@ -2,6 +2,7 @@ package conf import ( "github.com/golang/protobuf/proto" + "github.com/xtls/xray-core/app/reverse" ) diff --git a/infra/conf/serial/builder.go b/infra/conf/serial/builder.go index 651f24c9..a1de8b84 100644 --- a/infra/conf/serial/builder.go +++ b/infra/conf/serial/builder.go @@ -1,10 +1,11 @@ package serial import ( + "io" + "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/infra/conf" "github.com/xtls/xray-core/main/confloader" - "io" ) func BuildConfig(files []string, formats []string) (*core.Config, error) { diff --git a/infra/conf/socks.go b/infra/conf/socks.go index 05dad7bc..794b60d4 100644 --- a/infra/conf/socks.go +++ b/infra/conf/socks.go @@ -4,6 +4,7 @@ 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/socks" diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index f584f80b..37c1749a 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -8,6 +8,7 @@ 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 3afe9729..229fd829 100644 --- a/infra/conf/transport_test.go +++ b/infra/conf/transport_test.go @@ -5,6 +5,7 @@ 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/xray.go b/infra/conf/xray.go index 0b139792..9ea77828 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -2,11 +2,12 @@ package conf import ( "encoding/json" - "github.com/xtls/xray-core/transport/internet" "log" "os" "strings" + "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/app/dispatcher" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/app/stats" diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index d4f0ba6b..db930dd6 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -7,6 +7,7 @@ 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/convert.go b/main/commands/all/convert.go index c580fc50..e4775e84 100644 --- a/main/commands/all/convert.go +++ b/main/commands/all/convert.go @@ -11,12 +11,13 @@ 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/main/main_test.go b/main/main_test.go index 63c18234..e873c7b3 100644 --- a/main/main_test.go +++ b/main/main_test.go @@ -1,3 +1,4 @@ +//go:build coveragemain // +build coveragemain package main diff --git a/proxy/dokodemo/fakeudp_linux.go b/proxy/dokodemo/fakeudp_linux.go index 455efb48..6915349f 100644 --- a/proxy/dokodemo/fakeudp_linux.go +++ b/proxy/dokodemo/fakeudp_linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package dokodemo diff --git a/proxy/dokodemo/fakeudp_other.go b/proxy/dokodemo/fakeudp_other.go index abad344e..490f0912 100644 --- a/proxy/dokodemo/fakeudp_other.go +++ b/proxy/dokodemo/fakeudp_other.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux package dokodemo diff --git a/proxy/trojan/protocol_test.go b/proxy/trojan/protocol_test.go index 038f45fd..d7c96cca 100644 --- a/proxy/trojan/protocol_test.go +++ b/proxy/trojan/protocol_test.go @@ -4,6 +4,7 @@ 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 d1136371..1cf28aac 100644 --- a/proxy/vmess/encoding/server.go +++ b/proxy/vmess/encoding/server.go @@ -13,6 +13,8 @@ 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" @@ -23,7 +25,6 @@ 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 { diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index 056f32e6..7c1a2e50 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -31,7 +31,7 @@ import ( ) var ( - aeadForced = false + aeadForced = false aeadForced2022 = false ) diff --git a/testing/scenarios/common.go b/testing/scenarios/common.go index d562e9ba..34a8af14 100644 --- a/testing/scenarios/common.go +++ b/testing/scenarios/common.go @@ -14,6 +14,7 @@ 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/common_coverage.go b/testing/scenarios/common_coverage.go index aa4b7968..160df47c 100644 --- a/testing/scenarios/common_coverage.go +++ b/testing/scenarios/common_coverage.go @@ -1,3 +1,4 @@ +//go:build coverage // +build coverage package scenarios diff --git a/testing/scenarios/common_regular.go b/testing/scenarios/common_regular.go index 514daafb..19efc713 100644 --- a/testing/scenarios/common_regular.go +++ b/testing/scenarios/common_regular.go @@ -1,3 +1,4 @@ +//go:build !coverage // +build !coverage package scenarios diff --git a/testing/scenarios/dns_test.go b/testing/scenarios/dns_test.go index 886068d7..9e3ef135 100644 --- a/testing/scenarios/dns_test.go +++ b/testing/scenarios/dns_test.go @@ -5,6 +5,8 @@ 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" @@ -16,7 +18,6 @@ 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/feature_test.go b/testing/scenarios/feature_test.go index 3977606d..2392baa3 100644 --- a/testing/scenarios/feature_test.go +++ b/testing/scenarios/feature_test.go @@ -8,6 +8,8 @@ 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" @@ -32,7 +34,6 @@ 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/shadowsocks_test.go b/testing/scenarios/shadowsocks_test.go index ca93524d..06273e61 100644 --- a/testing/scenarios/shadowsocks_test.go +++ b/testing/scenarios/shadowsocks_test.go @@ -67,8 +67,8 @@ func TestShadowsocksChaCha20Poly1305TCP(t *testing.T) { Listen: net.NewIPOrDomain(net.LocalHostIP), }), ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(dest.Address), - Port: uint32(dest.Port), + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), Networks: []net.Network{net.Network_TCP}, }), }, @@ -163,8 +163,8 @@ func TestShadowsocksAES256GCMTCP(t *testing.T) { Listen: net.NewIPOrDomain(net.LocalHostIP), }), ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(dest.Address), - Port: uint32(dest.Port), + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), Networks: []net.Network{net.Network_TCP}, }), }, @@ -260,8 +260,8 @@ func TestShadowsocksAES128GCMUDP(t *testing.T) { Listen: net.NewIPOrDomain(net.LocalHostIP), }), ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(dest.Address), - Port: uint32(dest.Port), + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), Networks: []net.Network{net.Network_UDP}, }), }, @@ -356,8 +356,8 @@ func TestShadowsocksAES128GCMUDPMux(t *testing.T) { Listen: net.NewIPOrDomain(net.LocalHostIP), }), ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(dest.Address), - Port: uint32(dest.Port), + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), Networks: []net.Network{net.Network_UDP}, }), }, @@ -447,8 +447,8 @@ func TestShadowsocksNone(t *testing.T) { Listen: net.NewIPOrDomain(net.LocalHostIP), }), ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(dest.Address), - Port: uint32(dest.Port), + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), Networks: []net.Network{net.Network_TCP}, }), }, diff --git a/testing/scenarios/vmess_test.go b/testing/scenarios/vmess_test.go index dbb05015..7a8958fb 100644 --- a/testing/scenarios/vmess_test.go +++ b/testing/scenarios/vmess_test.go @@ -5,6 +5,8 @@ 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" @@ -23,7 +25,6 @@ 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/domainsocket/dial.go b/transport/internet/domainsocket/dial.go index a539b769..97715a39 100644 --- a/transport/internet/domainsocket/dial.go +++ b/transport/internet/domainsocket/dial.go @@ -1,5 +1,5 @@ -// +build !windows -// +build !wasm +//go:build !windows && !wasm +// +build !windows,!wasm package domainsocket diff --git a/transport/internet/domainsocket/listener.go b/transport/internet/domainsocket/listener.go index 492a8cb4..91150ac9 100644 --- a/transport/internet/domainsocket/listener.go +++ b/transport/internet/domainsocket/listener.go @@ -1,5 +1,5 @@ -// +build !windows -// +build !wasm +//go:build !windows && !wasm +// +build !windows,!wasm package domainsocket diff --git a/transport/internet/domainsocket/listener_test.go b/transport/internet/domainsocket/listener_test.go index 0f04e240..d59cd249 100644 --- a/transport/internet/domainsocket/listener_test.go +++ b/transport/internet/domainsocket/listener_test.go @@ -1,5 +1,5 @@ -// +build !windows -// +build !android +//go:build !windows && !android +// +build !windows,!android package domainsocket_test diff --git a/transport/internet/filelocker_other.go b/transport/internet/filelocker_other.go index 347cd66c..28fc0f58 100644 --- a/transport/internet/filelocker_other.go +++ b/transport/internet/filelocker_other.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package internet diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index 60034b7b..9c8221e2 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -10,6 +10,8 @@ import ( "github.com/xtls/xray-core/transport/internet/stat" + "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" @@ -18,7 +20,6 @@ import ( "github.com/xtls/xray-core/transport/internet" "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/kcp/xor.go b/transport/internet/kcp/xor.go index 6de9d295..233a2729 100644 --- a/transport/internet/kcp/xor.go +++ b/transport/internet/kcp/xor.go @@ -1,3 +1,4 @@ +//go:build !amd64 // +build !amd64 package kcp diff --git a/transport/internet/quic/config.go b/transport/internet/quic/config.go index fe13eec6..6f91ff72 100644 --- a/transport/internet/quic/config.go +++ b/transport/internet/quic/config.go @@ -5,10 +5,11 @@ 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 81033713..067e6951 100644 --- a/transport/internet/quic/conn.go +++ b/transport/internet/quic/conn.go @@ -7,6 +7,7 @@ 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 3c5dd0ec..131cec74 100644 --- a/transport/internet/quic/dialer.go +++ b/transport/internet/quic/dialer.go @@ -8,6 +8,7 @@ import ( "github.com/xtls/xray-core/transport/internet/stat" "github.com/lucas-clemente/quic-go" + "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 605b52dc..49ca1f7e 100644 --- a/transport/internet/quic/hub.go +++ b/transport/internet/quic/hub.go @@ -5,6 +5,7 @@ import ( "time" "github.com/lucas-clemente/quic-go" + "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/sockopt_other.go b/transport/internet/sockopt_other.go index ac61296b..ebcf4e26 100644 --- a/transport/internet/sockopt_other.go +++ b/transport/internet/sockopt_other.go @@ -1,3 +1,4 @@ +//go:build js || dragonfly || netbsd || openbsd || solaris // +build js dragonfly netbsd openbsd solaris package internet diff --git a/transport/internet/sockopt_test.go b/transport/internet/sockopt_test.go index cc82bc21..be3f4d90 100644 --- a/transport/internet/sockopt_test.go +++ b/transport/internet/sockopt_test.go @@ -5,6 +5,7 @@ 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 eb753d60..ef758e0b 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -6,6 +6,7 @@ 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/sockopt_freebsd.go b/transport/internet/tcp/sockopt_freebsd.go index 277c3ae2..906e06ea 100644 --- a/transport/internet/tcp/sockopt_freebsd.go +++ b/transport/internet/tcp/sockopt_freebsd.go @@ -1,3 +1,4 @@ +//go:build freebsd // +build freebsd package tcp diff --git a/transport/internet/tcp/sockopt_linux.go b/transport/internet/tcp/sockopt_linux.go index 783cd5fe..748a6cfc 100644 --- a/transport/internet/tcp/sockopt_linux.go +++ b/transport/internet/tcp/sockopt_linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package tcp diff --git a/transport/internet/tcp/sockopt_linux_test.go b/transport/internet/tcp/sockopt_linux_test.go index c879b2bf..8210cb4b 100644 --- a/transport/internet/tcp/sockopt_linux_test.go +++ b/transport/internet/tcp/sockopt_linux_test.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package tcp_test diff --git a/transport/internet/tcp/sockopt_other.go b/transport/internet/tcp/sockopt_other.go index f1ad3f8b..7c722e1b 100644 --- a/transport/internet/tcp/sockopt_other.go +++ b/transport/internet/tcp/sockopt_other.go @@ -1,3 +1,4 @@ +//go:build !linux && !freebsd // +build !linux,!freebsd package tcp diff --git a/transport/internet/tls/config_other.go b/transport/internet/tls/config_other.go index 3a46792b..59e0c153 100644 --- a/transport/internet/tls/config_other.go +++ b/transport/internet/tls/config_other.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package tls diff --git a/transport/internet/tls/config_windows.go b/transport/internet/tls/config_windows.go index 94b24762..8818befe 100644 --- a/transport/internet/tls/config_windows.go +++ b/transport/internet/tls/config_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package tls diff --git a/transport/internet/udp/hub_freebsd.go b/transport/internet/udp/hub_freebsd.go index 0438eeb2..f9f2bf89 100644 --- a/transport/internet/udp/hub_freebsd.go +++ b/transport/internet/udp/hub_freebsd.go @@ -1,3 +1,4 @@ +//go:build freebsd // +build freebsd package udp diff --git a/transport/internet/udp/hub_linux.go b/transport/internet/udp/hub_linux.go index b01dbd0b..97619c19 100644 --- a/transport/internet/udp/hub_linux.go +++ b/transport/internet/udp/hub_linux.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package udp @@ -5,8 +6,9 @@ package udp import ( "syscall" - "github.com/xtls/xray-core/common/net" "golang.org/x/sys/unix" + + "github.com/xtls/xray-core/common/net" ) func RetrieveOriginalDest(oob []byte) net.Destination { diff --git a/transport/internet/udp/hub_other.go b/transport/internet/udp/hub_other.go index 1a3c6773..3765ba31 100644 --- a/transport/internet/udp/hub_other.go +++ b/transport/internet/udp/hub_other.go @@ -1,3 +1,4 @@ +//go:build !linux && !freebsd // +build !linux,!freebsd package udp diff --git a/transport/internet/websocket/connection.go b/transport/internet/websocket/connection.go index 7cc2ad9b..563ed242 100644 --- a/transport/internet/websocket/connection.go +++ b/transport/internet/websocket/connection.go @@ -6,6 +6,7 @@ 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/xtls/config_other.go b/transport/internet/xtls/config_other.go index d0940a87..a429cf37 100644 --- a/transport/internet/xtls/config_other.go +++ b/transport/internet/xtls/config_other.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package xtls diff --git a/transport/internet/xtls/config_windows.go b/transport/internet/xtls/config_windows.go index 0e74379c..68f82b40 100644 --- a/transport/internet/xtls/config_windows.go +++ b/transport/internet/xtls/config_windows.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package xtls