From e93da4bd02f2420df87d7b0b44412fbfbad7c295 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Tue, 14 Dec 2021 19:28:47 -0500 Subject: [PATCH] Fix some tests and format code (#830) * Increase some tls test timeout * Fix TestUserValidator * Change all tests to VMessAEAD Old VMess MD5 tests will be rejected and fail in 2022 * Chore: auto format code --- app/dispatcher/default.go | 2 +- app/dns/dns_test.go | 1 + app/dns/fakedns/fakedns_test.go | 3 +- app/dns/hosts_test.go | 1 + app/dns/nameserver_local.go | 3 +- app/dns/nameserver_local_test.go | 3 +- app/dns/nameserver_quic.go | 5 +- app/dns/nameserver_quic_test.go | 3 +- app/log/log_creator.go | 2 +- app/observatory/command/command.go | 3 +- app/observatory/observer.go | 2 +- app/proxyman/inbound/worker.go | 3 +- app/proxyman/outbound/handler.go | 3 +- app/proxyman/outbound/handler_test.go | 3 +- app/router/router_test.go | 3 +- app/router/strategy_leastping.go | 2 +- common/buf/readv_reader.go | 3 +- common/buf/readv_test.go | 1 - common/buf/writer.go | 3 +- infra/conf/blackhole.go | 1 + infra/conf/common_test.go | 3 +- infra/conf/fakedns.go | 8 +-- infra/conf/vmess_test.go | 13 ++-- infra/conf/xray.go | 3 +- infra/conf/xray_test.go | 8 +-- proxy/dns/dns.go | 3 +- proxy/dokodemo/dokodemo.go | 3 +- proxy/freedom/freedom.go | 3 +- proxy/http/client.go | 3 +- proxy/http/server.go | 3 +- proxy/loopback/loopback.go | 2 +- proxy/mtproto/server.go | 3 +- proxy/proxy.go | 3 +- proxy/shadowsocks/client.go | 3 +- proxy/shadowsocks/server.go | 3 +- proxy/socks/client.go | 3 +- proxy/socks/server.go | 3 +- proxy/trojan/client.go | 3 +- proxy/trojan/protocol.go | 3 +- proxy/trojan/server.go | 3 +- proxy/vless/encoding/encoding.go | 3 +- proxy/vless/inbound/inbound.go | 3 +- proxy/vless/outbound/outbound.go | 3 +- proxy/vmess/encoding/auth.go | 7 +- proxy/vmess/encoding/encoding_test.go | 9 +-- proxy/vmess/inbound/inbound.go | 3 +- proxy/vmess/outbound/outbound.go | 3 +- proxy/vmess/validator.go | 5 ++ proxy/vmess/validator_test.go | 17 ++--- testing/scenarios/command_test.go | 15 ++--- testing/scenarios/feature_test.go | 6 +- testing/scenarios/policy_test.go | 12 ++-- testing/scenarios/reverse_test.go | 12 ++-- testing/scenarios/tls_test.go | 8 +-- testing/scenarios/transport_test.go | 6 +- testing/scenarios/vmess_test.go | 66 +++++++------------ transport/internet/dialer.go | 3 +- transport/internet/domainsocket/dial.go | 3 +- transport/internet/domainsocket/listener.go | 3 +- .../internet/domainsocket/listener_test.go | 3 +- transport/internet/http/dialer.go | 3 +- transport/internet/http/http_test.go | 3 +- transport/internet/kcp/dialer.go | 3 +- transport/internet/kcp/kcp_test.go | 3 +- transport/internet/kcp/listener.go | 3 +- transport/internet/kcp/output.go | 3 +- transport/internet/quic/dialer.go | 3 +- transport/internet/quic/quic_test.go | 3 +- transport/internet/tagged/taggedimpl/impl.go | 4 +- transport/internet/tcp/dialer.go | 3 +- transport/internet/tcp/hub.go | 3 +- transport/internet/tcp/sockopt_linux.go | 3 +- transport/internet/tcp_hub.go | 3 +- transport/internet/udp/dialer.go | 3 +- transport/internet/udp/dispatcher.go | 3 +- transport/internet/websocket/dialer.go | 3 +- transport/internet/websocket/ws_test.go | 3 +- 77 files changed, 137 insertions(+), 234 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 3c23cd67..7879662a 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -4,7 +4,6 @@ package dispatcher import ( "context" - "github.com/xtls/xray-core/features/dns" "strings" "sync" "time" @@ -16,6 +15,7 @@ import ( "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/core" + "github.com/xtls/xray-core/features/dns" "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/features/routing" diff --git a/app/dns/dns_test.go b/app/dns/dns_test.go index b3a8def8..50f2062b 100644 --- a/app/dns/dns_test.go +++ b/app/dns/dns_test.go @@ -6,6 +6,7 @@ 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/fakedns/fakedns_test.go b/app/dns/fakedns/fakedns_test.go index a5553170..139a8407 100644 --- a/app/dns/fakedns/fakedns_test.go +++ b/app/dns/fakedns/fakedns_test.go @@ -1,9 +1,8 @@ package fakedns import ( - "testing" - gonet "net" + "testing" "github.com/stretchr/testify/assert" diff --git a/app/dns/hosts_test.go b/app/dns/hosts_test.go index 40533b11..dd8c8813 100644 --- a/app/dns/hosts_test.go +++ b/app/dns/hosts_test.go @@ -4,6 +4,7 @@ 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_local.go b/app/dns/nameserver_local.go index 6b0f1319..0748732d 100644 --- a/app/dns/nameserver_local.go +++ b/app/dns/nameserver_local.go @@ -4,9 +4,8 @@ import ( "context" "strings" - "github.com/xtls/xray-core/features/dns" - "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/features/dns" "github.com/xtls/xray-core/features/dns/localdns" ) diff --git a/app/dns/nameserver_local_test.go b/app/dns/nameserver_local_test.go index c27692e5..3331a333 100644 --- a/app/dns/nameserver_local_test.go +++ b/app/dns/nameserver_local_test.go @@ -5,10 +5,9 @@ import ( "testing" "time" - "github.com/xtls/xray-core/common/net" - . "github.com/xtls/xray-core/app/dns" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/features/dns" ) diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 9c712f17..6279aadb 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -8,6 +8,9 @@ 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" @@ -17,8 +20,6 @@ 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 2c4710a9..9e87d8e1 100644 --- a/app/dns/nameserver_quic_test.go +++ b/app/dns/nameserver_quic_test.go @@ -6,13 +6,12 @@ import ( "testing" "time" - "github.com/xtls/xray-core/features/dns" - "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" + "github.com/xtls/xray-core/features/dns" ) func TestQUICNameServer(t *testing.T) { diff --git a/app/log/log_creator.go b/app/log/log_creator.go index ba53f2fc..9db8e1c7 100644 --- a/app/log/log_creator.go +++ b/app/log/log_creator.go @@ -2,7 +2,7 @@ package log import ( "sync" - + "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/log" ) diff --git a/app/observatory/command/command.go b/app/observatory/command/command.go index f929233f..9f79207a 100644 --- a/app/observatory/command/command.go +++ b/app/observatory/command/command.go @@ -1,3 +1,4 @@ +//go:build !confonly // +build !confonly package command @@ -7,9 +8,9 @@ import ( "google.golang.org/grpc" - core "github.com/xtls/xray-core/core" "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" ) diff --git a/app/observatory/observer.go b/app/observatory/observer.go index b752dcfa..a86fec10 100644 --- a/app/observatory/observer.go +++ b/app/observatory/observer.go @@ -2,7 +2,6 @@ package observatory import ( "context" - "github.com/xtls/xray-core/core" "net" "net/http" "net/url" @@ -17,6 +16,7 @@ import ( "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/common/signal/done" "github.com/xtls/xray-core/common/task" + "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/extension" "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/transport/internet/tagged" diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 4efdcbe9..9c033534 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -6,8 +6,6 @@ import ( "sync/atomic" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" @@ -20,6 +18,7 @@ import ( "github.com/xtls/xray-core/features/stats" "github.com/xtls/xray-core/proxy" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tcp" "github.com/xtls/xray-core/transport/internet/udp" "github.com/xtls/xray-core/transport/pipe" diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 5f98bb22..37f0eccc 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -3,8 +3,6 @@ package outbound import ( "context" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/mux" @@ -18,6 +16,7 @@ import ( "github.com/xtls/xray-core/proxy" "github.com/xtls/xray-core/transport" "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/pipe" ) diff --git a/app/proxyman/outbound/handler_test.go b/app/proxyman/outbound/handler_test.go index 9a9bf45c..c5afea70 100644 --- a/app/proxyman/outbound/handler_test.go +++ b/app/proxyman/outbound/handler_test.go @@ -4,8 +4,6 @@ import ( "context" "testing" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/app/policy" . "github.com/xtls/xray-core/app/proxyman/outbound" "github.com/xtls/xray-core/app/stats" @@ -14,6 +12,7 @@ import ( core "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/proxy/freedom" + "github.com/xtls/xray-core/transport/internet/stat" ) func TestInterfaces(t *testing.T) { diff --git a/app/router/router_test.go b/app/router/router_test.go index a4f973e5..f77bca8e 100644 --- a/app/router/router_test.go +++ b/app/router/router_test.go @@ -4,14 +4,13 @@ import ( "context" "testing" - "github.com/xtls/xray-core/features/dns" - "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" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/features/dns" "github.com/xtls/xray-core/features/outbound" routing_session "github.com/xtls/xray-core/features/routing/session" "github.com/xtls/xray-core/testing/mocks" diff --git a/app/router/strategy_leastping.go b/app/router/strategy_leastping.go index 2b9e2789..0b241576 100644 --- a/app/router/strategy_leastping.go +++ b/app/router/strategy_leastping.go @@ -2,10 +2,10 @@ package router import ( "context" - "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/app/observatory" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/extension" ) diff --git a/common/buf/readv_reader.go b/common/buf/readv_reader.go index 9a93baca..f897ccca 100644 --- a/common/buf/readv_reader.go +++ b/common/buf/readv_reader.go @@ -7,9 +7,8 @@ import ( "io" "syscall" - "github.com/xtls/xray-core/features/stats" - "github.com/xtls/xray-core/common/platform" + "github.com/xtls/xray-core/features/stats" ) type allocStrategy struct { diff --git a/common/buf/readv_test.go b/common/buf/readv_test.go index 98ae8894..e9f46171 100644 --- a/common/buf/readv_test.go +++ b/common/buf/readv_test.go @@ -9,7 +9,6 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "golang.org/x/sync/errgroup" "github.com/xtls/xray-core/common" diff --git a/common/buf/writer.go b/common/buf/writer.go index 6faa1959..8c348a46 100644 --- a/common/buf/writer.go +++ b/common/buf/writer.go @@ -5,10 +5,9 @@ import ( "net" "sync" - "github.com/xtls/xray-core/features/stats" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/features/stats" ) // BufferToBytesWriter is a Writer that writes alloc.Buffer into underlying writer. diff --git a/infra/conf/blackhole.go b/infra/conf/blackhole.go index a8d4e632..e2fdeedc 100644 --- a/infra/conf/blackhole.go +++ b/infra/conf/blackhole.go @@ -2,6 +2,7 @@ package conf import ( "encoding/json" + "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/common/serial" diff --git a/infra/conf/common_test.go b/infra/conf/common_test.go index 39e4cbea..f7c9985b 100644 --- a/infra/conf/common_test.go +++ b/infra/conf/common_test.go @@ -209,8 +209,7 @@ func TestUserParsing(t *testing.T) { common.Must(json.Unmarshal([]byte(`{ "id": "96edb838-6d68-42ef-a933-25f7ac3a9d09", "email": "love@example.com", - "level": 1, - "alterId": 100 + "level": 1 }`), user)) nUser := user.Build() diff --git a/infra/conf/fakedns.go b/infra/conf/fakedns.go index e730acdf..ca425457 100644 --- a/infra/conf/fakedns.go +++ b/infra/conf/fakedns.go @@ -68,10 +68,10 @@ func (FakeDNSPostProcessingStage) Process(config *Config) error { } switch strings.ToLower(config.DNSConfig.QueryStrategy) { - case "useip4", "useipv4", "use_ip4", "use_ipv4", "use_ip_v4", "use-ip4", "use-ipv4", "use-ip-v4": - isIPv4Enable, isIPv6Enable = true, false - case "useip6", "useipv6", "use_ip6", "use_ipv6", "use_ip_v6", "use-ip6", "use-ipv6", "use-ip-v6": - isIPv4Enable, isIPv6Enable = false, true + case "useip4", "useipv4", "use_ip4", "use_ipv4", "use_ip_v4", "use-ip4", "use-ipv4", "use-ip-v4": + isIPv4Enable, isIPv6Enable = true, false + case "useip6", "useipv6", "use_ip6", "use_ipv6", "use_ip_v6", "use-ip6", "use-ipv6", "use-ip-v6": + isIPv4Enable, isIPv6Enable = false, true } } diff --git a/infra/conf/vmess_test.go b/infra/conf/vmess_test.go index e6b9d58b..17cda04d 100644 --- a/infra/conf/vmess_test.go +++ b/infra/conf/vmess_test.go @@ -47,8 +47,7 @@ func TestVMessOutbound(t *testing.T) { Email: "love@example.com", Level: 255, Account: serial.ToTypedMessage(&vmess.Account{ - Id: "e641f5ad-9397-41e3-bf1a-e8740dfed019", - AlterId: 0, + Id: "e641f5ad-9397-41e3-bf1a-e8740dfed019", SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AUTO, }, @@ -74,14 +73,12 @@ func TestVMessInbound(t *testing.T) { { "id": "27848739-7e62-4138-9fd3-098a63964b6b", "level": 0, - "alterId": 16, "email": "love@example.com", "security": "aes-128-gcm" } ], "default": { - "level": 0, - "alterId": 32 + "level": 0 }, "detour": { "to": "tag_to_detour" @@ -95,8 +92,7 @@ func TestVMessInbound(t *testing.T) { Level: 0, Email: "love@example.com", Account: serial.ToTypedMessage(&vmess.Account{ - Id: "27848739-7e62-4138-9fd3-098a63964b6b", - AlterId: 16, + Id: "27848739-7e62-4138-9fd3-098a63964b6b", SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -104,8 +100,7 @@ func TestVMessInbound(t *testing.T) { }, }, Default: &inbound.DefaultConfig{ - Level: 0, - AlterId: 32, + Level: 0, }, Detour: &inbound.DetourConfig{ To: "tag_to_detour", diff --git a/infra/conf/xray.go b/infra/conf/xray.go index e0c0a120..6a007074 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -11,9 +11,8 @@ import ( "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/app/stats" "github.com/xtls/xray-core/common/serial" - "github.com/xtls/xray-core/transport/internet" - core "github.com/xtls/xray-core/core" + "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/xtls" ) diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index 1ea8dadd..3331518e 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -72,7 +72,6 @@ func TestXrayConfig(t *testing.T) { "settings": { "clients": [ { - "alterId": 100, "security": "aes-128-gcm", "id": "0cdf8a45-303d-4fed-9780-29aa7f54175e" } @@ -102,7 +101,6 @@ func TestXrayConfig(t *testing.T) { "settings": { "clients": [ { - "alterId": 100, "security": "aes-128-gcm", "id": "0cdf8a45-303d-4fed-9780-29aa7f54175e" } @@ -266,8 +264,7 @@ func TestXrayConfig(t *testing.T) { { Level: 0, Account: serial.ToTypedMessage(&vmess.Account{ - Id: "0cdf8a45-303d-4fed-9780-29aa7f54175e", - AlterId: 100, + Id: "0cdf8a45-303d-4fed-9780-29aa7f54175e", SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -322,8 +319,7 @@ func TestXrayConfig(t *testing.T) { { Level: 0, Account: serial.ToTypedMessage(&vmess.Account{ - Id: "0cdf8a45-303d-4fed-9780-29aa7f54175e", - AlterId: 100, + Id: "0cdf8a45-303d-4fed-9780-29aa7f54175e", SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index 0fcd502d..ae6e3953 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -6,8 +6,6 @@ import ( "sync" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "golang.org/x/net/dns/dnsmessage" "github.com/xtls/xray-core/common" @@ -22,6 +20,7 @@ import ( "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" ) func init() { diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 999c546f..d0fb69f9 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -7,8 +7,6 @@ import ( "sync/atomic" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/log" @@ -20,6 +18,7 @@ import ( "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/features/routing" + "github.com/xtls/xray-core/transport/internet/stat" ) func init() { diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 21d00414..15ebc22b 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -6,8 +6,6 @@ import ( "context" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/dice" @@ -22,6 +20,7 @@ import ( "github.com/xtls/xray-core/features/stats" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" ) func init() { diff --git a/proxy/http/client.go b/proxy/http/client.go index ab0b420c..713842f5 100644 --- a/proxy/http/client.go +++ b/proxy/http/client.go @@ -9,8 +9,6 @@ import ( "net/url" "sync" - "github.com/xtls/xray-core/transport/internet/stat" - "golang.org/x/net/http2" "github.com/xtls/xray-core/common" @@ -26,6 +24,7 @@ import ( "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" ) diff --git a/proxy/http/server.go b/proxy/http/server.go index 67f82976..cdcf2e3a 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -9,8 +9,6 @@ import ( "strings" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" @@ -24,6 +22,7 @@ import ( "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/features/routing" + "github.com/xtls/xray-core/transport/internet/stat" ) // Server is an HTTP proxy server. diff --git a/proxy/loopback/loopback.go b/proxy/loopback/loopback.go index ab19fc20..946847f3 100644 --- a/proxy/loopback/loopback.go +++ b/proxy/loopback/loopback.go @@ -2,11 +2,11 @@ package loopback import ( "context" - "github.com/xtls/xray-core/common/net/cnc" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/net/cnc" "github.com/xtls/xray-core/common/retry" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/common/task" diff --git a/proxy/mtproto/server.go b/proxy/mtproto/server.go index 45096d33..2079df1f 100644 --- a/proxy/mtproto/server.go +++ b/proxy/mtproto/server.go @@ -5,8 +5,6 @@ import ( "context" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/crypto" @@ -18,6 +16,7 @@ import ( "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/features/routing" + "github.com/xtls/xray-core/transport/internet/stat" ) var dcList = []net.Address{ diff --git a/proxy/proxy.go b/proxy/proxy.go index 01960cdf..fb52605c 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -8,13 +8,12 @@ package proxy import ( "context" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" ) // An Inbound processes inbound connections. diff --git a/proxy/shadowsocks/client.go b/proxy/shadowsocks/client.go index 5e45852a..10f4d33f 100644 --- a/proxy/shadowsocks/client.go +++ b/proxy/shadowsocks/client.go @@ -4,8 +4,6 @@ import ( "context" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" @@ -18,6 +16,7 @@ import ( "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" ) // Client is a inbound handler for Shadowsocks protocol diff --git a/proxy/shadowsocks/server.go b/proxy/shadowsocks/server.go index c15bd175..140c6704 100644 --- a/proxy/shadowsocks/server.go +++ b/proxy/shadowsocks/server.go @@ -4,8 +4,6 @@ import ( "context" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/log" @@ -18,6 +16,7 @@ import ( "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/features/routing" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/udp" ) diff --git a/proxy/socks/client.go b/proxy/socks/client.go index e1274079..f1690bec 100644 --- a/proxy/socks/client.go +++ b/proxy/socks/client.go @@ -4,8 +4,6 @@ import ( "context" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "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/features/policy" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" ) // Client is a Socks5 client. diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 966c3ac2..ce15163c 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -5,8 +5,6 @@ import ( "io" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/log" @@ -20,6 +18,7 @@ import ( "github.com/xtls/xray-core/features" "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/features/routing" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/udp" ) diff --git a/proxy/trojan/client.go b/proxy/trojan/client.go index bc5b96bf..7094554f 100644 --- a/proxy/trojan/client.go +++ b/proxy/trojan/client.go @@ -5,8 +5,6 @@ import ( "syscall" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" @@ -22,6 +20,7 @@ import ( "github.com/xtls/xray-core/features/stats" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/xtls" ) diff --git a/proxy/trojan/protocol.go b/proxy/trojan/protocol.go index 34b6b267..b49314e6 100644 --- a/proxy/trojan/protocol.go +++ b/proxy/trojan/protocol.go @@ -8,8 +8,6 @@ import ( "runtime" "syscall" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" @@ -17,6 +15,7 @@ import ( "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/features/stats" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/xtls" ) diff --git a/proxy/trojan/server.go b/proxy/trojan/server.go index 2ba4823c..a9ce3da4 100644 --- a/proxy/trojan/server.go +++ b/proxy/trojan/server.go @@ -8,8 +8,6 @@ import ( "syscall" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" @@ -26,6 +24,7 @@ import ( "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/features/stats" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/internet/udp" "github.com/xtls/xray-core/transport/internet/xtls" diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index a5ee0690..436846f0 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -9,8 +9,6 @@ import ( "runtime" "syscall" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" @@ -19,6 +17,7 @@ import ( "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/features/stats" "github.com/xtls/xray-core/proxy/vless" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/xtls" ) diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index d78782c0..62c215e9 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -10,8 +10,6 @@ import ( "syscall" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" @@ -31,6 +29,7 @@ import ( "github.com/xtls/xray-core/features/stats" "github.com/xtls/xray-core/proxy/vless" "github.com/xtls/xray-core/proxy/vless/encoding" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/internet/xtls" ) diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index 87dd9caf..68995cd6 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -7,8 +7,6 @@ import ( "syscall" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" @@ -26,6 +24,7 @@ import ( "github.com/xtls/xray-core/proxy/vless/encoding" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/xtls" ) diff --git a/proxy/vmess/encoding/auth.go b/proxy/vmess/encoding/auth.go index 23536de6..09557161 100644 --- a/proxy/vmess/encoding/auth.go +++ b/proxy/vmess/encoding/auth.go @@ -5,11 +5,10 @@ import ( "encoding/binary" "hash/fnv" - "github.com/xtls/xray-core/common" - - "github.com/xtls/xray-core/common/crypto" - "golang.org/x/crypto/sha3" + + "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/crypto" ) // Authenticate authenticates a byte array using Fnv hash. diff --git a/proxy/vmess/encoding/encoding_test.go b/proxy/vmess/encoding/encoding_test.go index 9619a606..a7ae364d 100644 --- a/proxy/vmess/encoding/encoding_test.go +++ b/proxy/vmess/encoding/encoding_test.go @@ -28,8 +28,7 @@ func TestRequestSerialization(t *testing.T) { } id := uuid.New() account := &vmess.Account{ - Id: id.String(), - AlterId: 0, + Id: id.String(), } user.Account = toAccount(account) @@ -78,8 +77,7 @@ func TestInvalidRequest(t *testing.T) { } id := uuid.New() account := &vmess.Account{ - Id: id.String(), - AlterId: 0, + Id: id.String(), } user.Account = toAccount(account) @@ -120,8 +118,7 @@ func TestMuxRequest(t *testing.T) { } id := uuid.New() account := &vmess.Account{ - Id: id.String(), - AlterId: 0, + Id: id.String(), } user.Account = toAccount(account) diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index 64cdc934..6150edf2 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -9,8 +9,6 @@ import ( "sync" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" @@ -28,6 +26,7 @@ import ( "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/proxy/vmess" "github.com/xtls/xray-core/proxy/vmess/encoding" + "github.com/xtls/xray-core/transport/internet/stat" ) var ( diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index 8bde21bb..ce6e12a1 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -9,8 +9,6 @@ import ( "hash/crc64" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" @@ -27,6 +25,7 @@ import ( "github.com/xtls/xray-core/proxy/vmess/encoding" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" ) // Handler is an outbound connection handler for VMess protocol. diff --git a/proxy/vmess/validator.go b/proxy/vmess/validator.go index 692a9cf6..30c44af7 100644 --- a/proxy/vmess/validator.go +++ b/proxy/vmess/validator.go @@ -71,6 +71,11 @@ func NewTimedUserValidator(hasher protocol.IDHash) *TimedUserValidator { return tuv } +// visible for testing +func (v *TimedUserValidator) GetBaseTime() protocol.Timestamp { + return v.baseTime +} + func (v *TimedUserValidator) generateNewHashes(nowSec protocol.Timestamp, user *user) { var hashValue [16]byte genEndSec := nowSec + cacheDurationSec diff --git a/proxy/vmess/validator_test.go b/proxy/vmess/validator_test.go index 634b4e23..ee170655 100644 --- a/proxy/vmess/validator_test.go +++ b/proxy/vmess/validator_test.go @@ -2,7 +2,6 @@ package vmess_test import ( "testing" - "time" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/protocol" @@ -26,15 +25,14 @@ func TestUserValidator(t *testing.T) { user := &protocol.MemoryUser{ Email: "test", Account: toAccount(&Account{ - Id: id.String(), - AlterId: 8, + Id: id.String(), }), } common.Must(v.Add(user)) { - testSmallLag := func(lag time.Duration) { - ts := protocol.Timestamp(time.Now().Add(time.Second * lag).Unix()) + testSmallLag := func(lag int64) { + ts := int64(v.GetBaseTime()) + lag + 240 idHash := hasher(id.Bytes()) common.Must2(serial.WriteUint64(idHash, uint64(ts))) userHash := idHash.Sum(nil) @@ -46,7 +44,7 @@ func TestUserValidator(t *testing.T) { if euser.Email != user.Email { t.Error("unexpected user email: ", euser.Email, " want ", user.Email) } - if ets != ts { + if int64(ets) != ts { t.Error("unexpected timestamp: ", ets, " want ", ts) } } @@ -61,8 +59,8 @@ func TestUserValidator(t *testing.T) { } { - testBigLag := func(lag time.Duration) { - ts := protocol.Timestamp(time.Now().Add(time.Second * lag).Unix()) + testBigLag := func(lag int64) { + ts := int64(v.GetBaseTime()) + lag + 240 idHash := hasher(id.Bytes()) common.Must2(serial.WriteUint64(idHash, uint64(ts))) userHash := idHash.Sum(nil) @@ -99,8 +97,7 @@ func BenchmarkUserValidator(b *testing.B) { v.Add(&protocol.MemoryUser{ Email: "test", Account: toAccount(&Account{ - Id: id.String(), - AlterId: 16, + Id: id.String(), }), }) } diff --git a/testing/scenarios/command_test.go b/testing/scenarios/command_test.go index 9b83907a..2d1dc5ad 100644 --- a/testing/scenarios/command_test.go +++ b/testing/scenarios/command_test.go @@ -181,8 +181,7 @@ func TestCommanderAddRemoveUser(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: u1.String(), - AlterId: 64, + Id: u1.String(), }), }, }, @@ -248,8 +247,7 @@ func TestCommanderAddRemoveUser(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: u2.String(), - AlterId: 64, + Id: u2.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -285,8 +283,7 @@ func TestCommanderAddRemoveUser(t *testing.T) { User: &protocol.User{ Email: "test@example.com", Account: serial.ToTypedMessage(&vmess.Account{ - Id: u2.String(), - AlterId: 64, + Id: u2.String(), }), }, }), @@ -376,8 +373,7 @@ func TestCommanderStats(t *testing.T) { Level: 1, Email: "test", Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -432,8 +428,7 @@ func TestCommanderStats(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, diff --git a/testing/scenarios/feature_test.go b/testing/scenarios/feature_test.go index 2cf09777..ba819b20 100644 --- a/testing/scenarios/feature_test.go +++ b/testing/scenarios/feature_test.go @@ -673,8 +673,7 @@ func TestDialXray(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -705,8 +704,7 @@ func TestDialXray(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, diff --git a/testing/scenarios/policy_test.go b/testing/scenarios/policy_test.go index d9e2857b..463ad020 100644 --- a/testing/scenarios/policy_test.go +++ b/testing/scenarios/policy_test.go @@ -76,8 +76,7 @@ func TestVMessClosing(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -130,8 +129,7 @@ func TestVMessClosing(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -190,8 +188,7 @@ func TestZeroBuffer(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -238,8 +235,7 @@ func TestZeroBuffer(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, diff --git a/testing/scenarios/reverse_test.go b/testing/scenarios/reverse_test.go index f9a1d979..0629a3b2 100644 --- a/testing/scenarios/reverse_test.go +++ b/testing/scenarios/reverse_test.go @@ -93,8 +93,7 @@ func TestReverseProxy(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -168,8 +167,7 @@ func TestReverseProxy(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -278,8 +276,7 @@ func TestReverseProxyLongRunning(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -367,8 +364,7 @@ func TestReverseProxyLongRunning(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, diff --git a/testing/scenarios/tls_test.go b/testing/scenarios/tls_test.go index 1c37a53a..c7ffc834 100644 --- a/testing/scenarios/tls_test.go +++ b/testing/scenarios/tls_test.go @@ -125,7 +125,7 @@ func TestSimpleTLSConnection(t *testing.T) { common.Must(err) defer CloseAllServers(servers) - if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil { + if err := testTCPConn(clientPort, 1024, time.Second*20)(); err != nil { t.Fatal(err) } } @@ -247,7 +247,7 @@ func TestAutoIssuingCertificate(t *testing.T) { defer CloseAllServers(servers) for i := 0; i < 10; i++ { - if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil { + if err := testTCPConn(clientPort, 1024, time.Second*20)(); err != nil { t.Error(err) } } @@ -350,7 +350,7 @@ func TestTLSOverKCP(t *testing.T) { common.Must(err) defer CloseAllServers(servers) - if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil { + if err := testTCPConn(clientPort, 1024, time.Second*20)(); err != nil { t.Error(err) } } @@ -925,7 +925,7 @@ func TestSimpleTLSConnectionPinned(t *testing.T) { common.Must(err) defer CloseAllServers(servers) - if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil { + if err := testTCPConn(clientPort, 1024, time.Second*20)(); err != nil { t.Fatal(err) } } diff --git a/testing/scenarios/transport_test.go b/testing/scenarios/transport_test.go index bc148616..d8b606de 100644 --- a/testing/scenarios/transport_test.go +++ b/testing/scenarios/transport_test.go @@ -290,8 +290,7 @@ func TestVMessQuic(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -354,8 +353,7 @@ func TestVMessQuic(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, diff --git a/testing/scenarios/vmess_test.go b/testing/scenarios/vmess_test.go index 3e846c53..5da53a7a 100644 --- a/testing/scenarios/vmess_test.go +++ b/testing/scenarios/vmess_test.go @@ -216,8 +216,7 @@ func TestVMessGCM(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -264,8 +263,7 @@ func TestVMessGCM(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -322,8 +320,7 @@ func TestVMessGCMReadv(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -370,8 +367,7 @@ func TestVMessGCMReadv(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -431,8 +427,7 @@ func TestVMessGCMUDP(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -479,8 +474,7 @@ func TestVMessGCMUDP(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -534,8 +528,7 @@ func TestVMessChacha20(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -582,8 +575,7 @@ func TestVMessChacha20(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_CHACHA20_POLY1305, }, @@ -638,8 +630,7 @@ func TestVMessNone(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -686,8 +677,7 @@ func TestVMessNone(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_NONE, }, @@ -744,8 +734,7 @@ func TestVMessKCP(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -792,8 +781,7 @@ func TestVMessKCP(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -874,8 +862,7 @@ func TestVMessKCPLarge(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -922,8 +909,7 @@ func TestVMessKCPLarge(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -1005,8 +991,7 @@ func TestVMessGCMMux(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -1059,8 +1044,7 @@ func TestVMessGCMMux(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -1124,8 +1108,7 @@ func TestVMessGCMMuxUDP(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -1192,8 +1175,7 @@ func TestVMessGCMMuxUDP(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, @@ -1255,8 +1237,7 @@ func TestVMessZero(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -1303,8 +1284,7 @@ func TestVMessZero(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_ZERO, }, @@ -1358,8 +1338,7 @@ func TestVMessGCMLengthAuth(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), }), }, }, @@ -1406,8 +1385,7 @@ func TestVMessGCMLengthAuth(t *testing.T) { User: []*protocol.User{ { Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - AlterId: 64, + Id: userID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AES128_GCM, }, diff --git a/transport/internet/dialer.go b/transport/internet/dialer.go index fe676b3b..d178bdcd 100644 --- a/transport/internet/dialer.go +++ b/transport/internet/dialer.go @@ -5,14 +5,13 @@ import ( "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/dice" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net/cnc" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/features/dns" "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/transport" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/pipe" ) diff --git a/transport/internet/domainsocket/dial.go b/transport/internet/domainsocket/dial.go index 97715a39..556c48e3 100644 --- a/transport/internet/domainsocket/dial.go +++ b/transport/internet/domainsocket/dial.go @@ -6,11 +6,10 @@ package domainsocket import ( "context" - "github.com/xtls/xray-core/transport/internet/stat" - "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" ) diff --git a/transport/internet/domainsocket/listener.go b/transport/internet/domainsocket/listener.go index 91150ac9..c59e515d 100644 --- a/transport/internet/domainsocket/listener.go +++ b/transport/internet/domainsocket/listener.go @@ -9,14 +9,13 @@ import ( "os" "strings" - "github.com/xtls/xray-core/transport/internet/stat" - 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" ) diff --git a/transport/internet/domainsocket/listener_test.go b/transport/internet/domainsocket/listener_test.go index d59cd249..308fa07b 100644 --- a/transport/internet/domainsocket/listener_test.go +++ b/transport/internet/domainsocket/listener_test.go @@ -8,13 +8,12 @@ import ( "runtime" "testing" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/transport/internet" . "github.com/xtls/xray-core/transport/internet/domainsocket" + "github.com/xtls/xray-core/transport/internet/stat" ) func TestListen(t *testing.T) { diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index 93a248e3..f9649156 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -8,8 +8,6 @@ import ( "sync" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "golang.org/x/net/http2" "github.com/xtls/xray-core/common" @@ -18,6 +16,7 @@ import ( "github.com/xtls/xray-core/common/net/cnc" "github.com/xtls/xray-core/common/session" "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/pipe" ) diff --git a/transport/internet/http/http_test.go b/transport/internet/http/http_test.go index 91aab580..caf2a509 100644 --- a/transport/internet/http/http_test.go +++ b/transport/internet/http/http_test.go @@ -6,8 +6,6 @@ import ( "testing" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/google/go-cmp/cmp" "github.com/xtls/xray-core/common" @@ -17,6 +15,7 @@ import ( "github.com/xtls/xray-core/testing/servers/tcp" "github.com/xtls/xray-core/transport/internet" . "github.com/xtls/xray-core/transport/internet/http" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" ) diff --git a/transport/internet/kcp/dialer.go b/transport/internet/kcp/dialer.go index 9df28c99..dd6393bc 100644 --- a/transport/internet/kcp/dialer.go +++ b/transport/internet/kcp/dialer.go @@ -5,13 +5,12 @@ import ( "io" "sync/atomic" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/dice" "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" ) diff --git a/transport/internet/kcp/kcp_test.go b/transport/internet/kcp/kcp_test.go index 5346c0ae..641dd6e3 100644 --- a/transport/internet/kcp/kcp_test.go +++ b/transport/internet/kcp/kcp_test.go @@ -7,8 +7,6 @@ import ( "testing" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/google/go-cmp/cmp" "golang.org/x/sync/errgroup" @@ -17,6 +15,7 @@ import ( "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" ) func TestDialAndListen(t *testing.T) { diff --git a/transport/internet/kcp/listener.go b/transport/internet/kcp/listener.go index e6f67315..aa0443ac 100644 --- a/transport/internet/kcp/listener.go +++ b/transport/internet/kcp/listener.go @@ -6,14 +6,13 @@ import ( gotls "crypto/tls" "sync" - "github.com/xtls/xray-core/transport/internet/stat" - 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" "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/udp" "github.com/xtls/xray-core/transport/internet/xtls" diff --git a/transport/internet/kcp/output.go b/transport/internet/kcp/output.go index 30d3e2c5..3aed95f4 100644 --- a/transport/internet/kcp/output.go +++ b/transport/internet/kcp/output.go @@ -4,9 +4,8 @@ import ( "io" "sync" - "github.com/xtls/xray-core/common/retry" - "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/retry" ) type SegmentWriter interface { diff --git a/transport/internet/quic/dialer.go b/transport/internet/quic/dialer.go index 3d057dc9..42b4ac00 100644 --- a/transport/internet/quic/dialer.go +++ b/transport/internet/quic/dialer.go @@ -5,14 +5,13 @@ import ( "sync" "time" - "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" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" ) diff --git a/transport/internet/quic/quic_test.go b/transport/internet/quic/quic_test.go index 3354f9cc..c3c82822 100644 --- a/transport/internet/quic/quic_test.go +++ b/transport/internet/quic/quic_test.go @@ -6,8 +6,6 @@ import ( "testing" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/google/go-cmp/cmp" "github.com/xtls/xray-core/common" @@ -20,6 +18,7 @@ import ( "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/headers/wireguard" "github.com/xtls/xray-core/transport/internet/quic" + "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" ) diff --git a/transport/internet/tagged/taggedimpl/impl.go b/transport/internet/tagged/taggedimpl/impl.go index f54116b0..6b66e11f 100644 --- a/transport/internet/tagged/taggedimpl/impl.go +++ b/transport/internet/tagged/taggedimpl/impl.go @@ -2,11 +2,11 @@ package taggedimpl import ( "context" - "github.com/xtls/xray-core/common/net/cnc" - "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/net/cnc" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport/internet/tagged" ) diff --git a/transport/internet/tcp/dialer.go b/transport/internet/tcp/dialer.go index 3d75a438..296c7d8d 100644 --- a/transport/internet/tcp/dialer.go +++ b/transport/internet/tcp/dialer.go @@ -3,12 +3,11 @@ package tcp import ( "context" - "github.com/xtls/xray-core/transport/internet/stat" - "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/stat" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/internet/xtls" ) diff --git a/transport/internet/tcp/hub.go b/transport/internet/tcp/hub.go index 3aee41a2..5ea3a613 100644 --- a/transport/internet/tcp/hub.go +++ b/transport/internet/tcp/hub.go @@ -6,14 +6,13 @@ import ( "strings" "time" - "github.com/xtls/xray-core/transport/internet/stat" - 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" "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" ) diff --git a/transport/internet/tcp/sockopt_linux.go b/transport/internet/tcp/sockopt_linux.go index 748a6cfc..86044a80 100644 --- a/transport/internet/tcp/sockopt_linux.go +++ b/transport/internet/tcp/sockopt_linux.go @@ -7,9 +7,8 @@ import ( "syscall" "unsafe" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/transport/internet/stat" ) const SO_ORIGINAL_DST = 80 diff --git a/transport/internet/tcp_hub.go b/transport/internet/tcp_hub.go index cbb1ca99..2ebff9a7 100644 --- a/transport/internet/tcp_hub.go +++ b/transport/internet/tcp_hub.go @@ -3,9 +3,8 @@ package internet import ( "context" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/transport/internet/stat" ) var transportListenerCache = make(map[string]ListenFunc) diff --git a/transport/internet/udp/dialer.go b/transport/internet/udp/dialer.go index 6babe3af..27f1505a 100644 --- a/transport/internet/udp/dialer.go +++ b/transport/internet/udp/dialer.go @@ -3,11 +3,10 @@ package udp import ( "context" - "github.com/xtls/xray-core/transport/internet/stat" - "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" ) func init() { diff --git a/transport/internet/udp/dispatcher.go b/transport/internet/udp/dispatcher.go index ba0759b4..6243cb57 100644 --- a/transport/internet/udp/dispatcher.go +++ b/transport/internet/udp/dispatcher.go @@ -6,14 +6,13 @@ import ( "sync" "time" - "github.com/xtls/xray-core/common/signal/done" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol/udp" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/common/signal" + "github.com/xtls/xray-core/common/signal/done" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport" ) diff --git a/transport/internet/websocket/dialer.go b/transport/internet/websocket/dialer.go index 6a06a67e..97177938 100644 --- a/transport/internet/websocket/dialer.go +++ b/transport/internet/websocket/dialer.go @@ -10,14 +10,13 @@ import ( "os" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/gorilla/websocket" "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/stat" "github.com/xtls/xray-core/transport/internet/tls" ) diff --git a/transport/internet/websocket/ws_test.go b/transport/internet/websocket/ws_test.go index 6e82109d..f3ae38fb 100644 --- a/transport/internet/websocket/ws_test.go +++ b/transport/internet/websocket/ws_test.go @@ -6,12 +6,11 @@ import ( "testing" "time" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol/tls/cert" "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/websocket" )