From f1e35ad9d42ee0c0e95f6d2b49b858775881c7f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Mar 2023 01:00:21 +0000 Subject: [PATCH 001/867] Bump github.com/sagernet/sing from 0.1.7 to 0.1.8 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.1.7 to 0.1.8. - [Release notes](https://github.com/sagernet/sing/releases) - [Commits](https://github.com/sagernet/sing/compare/v0.1.7...v0.1.8) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 58f1cd65..be50bf9f 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pires/go-proxyproto v0.6.2 github.com/quic-go/quic-go v0.33.0 github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db - github.com/sagernet/sing v0.1.7 + github.com/sagernet/sing v0.1.8 github.com/sagernet/sing-shadowsocks v0.1.1 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index ab32e439..0b7e80ff 100644 --- a/go.sum +++ b/go.sum @@ -141,8 +141,8 @@ github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db/go.mo github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.1.7 h1:g4vjr3q8SUlBZSx97Emz5OBfSMBxxW5Q8C2PfdoSo08= -github.com/sagernet/sing v0.1.7/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk= +github.com/sagernet/sing v0.1.8 h1:6DKo2FkSHn0nUcjO7bAext/ai7y7pCusK/+fScBJ5Jk= +github.com/sagernet/sing v0.1.8/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk= github.com/sagernet/sing-shadowsocks v0.1.1 h1:uFK2rlVeD/b1xhDwSMbUI2goWc6fOKxp+ZeKHZq6C9Q= github.com/sagernet/sing-shadowsocks v0.1.1/go.mod h1:f3mHTy5shnVM9l8UocMlJgC/1G/zdj5FuEuVXhDinGU= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= From f57ec1388084df041a2289bacab14e446bf1b357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 15 Mar 2023 14:42:32 +0800 Subject: [PATCH 002/867] Update UoT protocol --- app/proxyman/outbound/uot.go | 12 +++++++-- go.mod | 2 +- go.sum | 6 +++-- infra/conf/shadowsocks.go | 18 +++++++------ proxy/shadowsocks_2022/config.pb.go | 41 ++++++++++++++++++----------- proxy/shadowsocks_2022/config.proto | 1 + proxy/shadowsocks_2022/outbound.go | 24 ++++++++++------- 7 files changed, 66 insertions(+), 38 deletions(-) diff --git a/app/proxyman/outbound/uot.go b/app/proxyman/outbound/uot.go index a4af220c..4610bd79 100644 --- a/app/proxyman/outbound/uot.go +++ b/app/proxyman/outbound/uot.go @@ -11,13 +11,21 @@ import ( ) func (h *Handler) getUoTConnection(ctx context.Context, dest net.Destination) (stat.Connection, error) { - if !dest.Address.Family().IsDomain() || dest.Address.Domain() != uot.UOTMagicAddress { + if !dest.Address.Family().IsDomain() { + return nil, os.ErrInvalid + } + var uotVersion int + if dest.Address.Domain() == uot.MagicAddress { + uotVersion = uot.Version + } else if dest.Address.Domain() == uot.LegacyMagicAddress { + uotVersion = uot.LegacyVersion + } else { return nil, os.ErrInvalid } packetConn, err := internet.ListenSystemPacket(ctx, &net.UDPAddr{IP: net.AnyIP.IP(), Port: 0}, h.streamSettings.SocketSettings) if err != nil { return nil, newError("unable to listen socket").Base(err) } - conn := uot.NewServerConn(packetConn) + conn := uot.NewServerConn(packetConn, uotVersion) return h.getStatCouterConnection(conn), nil } diff --git a/go.mod b/go.mod index be50bf9f..dfb7ca04 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pires/go-proxyproto v0.6.2 github.com/quic-go/quic-go v0.33.0 github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db - github.com/sagernet/sing v0.1.8 + github.com/sagernet/sing v0.2.0 github.com/sagernet/sing-shadowsocks v0.1.1 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index 0b7e80ff..155155a2 100644 --- a/go.sum +++ b/go.sum @@ -141,8 +141,10 @@ github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db/go.mo github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.1.8 h1:6DKo2FkSHn0nUcjO7bAext/ai7y7pCusK/+fScBJ5Jk= -github.com/sagernet/sing v0.1.8/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk= +github.com/sagernet/sing v0.1.9-0.20230315063014-2731df16725b h1:1iKGftQ59+shDSx2RaLaxXJcMK/B+IU9WqUPwyBW+E0= +github.com/sagernet/sing v0.1.9-0.20230315063014-2731df16725b/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= +github.com/sagernet/sing v0.2.0 h1:iyc4TaeXG5XYXixl48zSDDTw46C9NOEAVFq6ZE0dA2k= +github.com/sagernet/sing v0.2.0/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= github.com/sagernet/sing-shadowsocks v0.1.1 h1:uFK2rlVeD/b1xhDwSMbUI2goWc6fOKxp+ZeKHZq6C9Q= github.com/sagernet/sing-shadowsocks v0.1.1/go.mod h1:f3mHTy5shnVM9l8UocMlJgC/1G/zdj5FuEuVXhDinGU= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= diff --git a/infra/conf/shadowsocks.go b/infra/conf/shadowsocks.go index 4b94c8e8..240d4aaa 100644 --- a/infra/conf/shadowsocks.go +++ b/infra/conf/shadowsocks.go @@ -155,14 +155,15 @@ func buildShadowsocks2022(v *ShadowsocksServerConfig) (proto.Message, error) { } type ShadowsocksServerTarget struct { - Address *Address `json:"address"` - Port uint16 `json:"port"` - Cipher string `json:"method"` - Password string `json:"password"` - Email string `json:"email"` - Level byte `json:"level"` - IVCheck bool `json:"ivCheck"` - UoT bool `json:"uot"` + Address *Address `json:"address"` + Port uint16 `json:"port"` + Cipher string `json:"method"` + Password string `json:"password"` + Email string `json:"email"` + Level byte `json:"level"` + IVCheck bool `json:"ivCheck"` + UoT bool `json:"uot"` + UoTVersion int `json:"uotVersion"` } type ShadowsocksClientConfig struct { @@ -193,6 +194,7 @@ func (v *ShadowsocksClientConfig) Build() (proto.Message, error) { config.Method = server.Cipher config.Key = server.Password config.UdpOverTcp = server.UoT + config.UdpOverTcpVersion = uint32(server.UoTVersion) return config, nil } } diff --git a/proxy/shadowsocks_2022/config.pb.go b/proxy/shadowsocks_2022/config.pb.go index 50626f7a..fd51459e 100644 --- a/proxy/shadowsocks_2022/config.pb.go +++ b/proxy/shadowsocks_2022/config.pb.go @@ -389,11 +389,12 @@ type ClientConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address *net.IPOrDomain `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - Port uint32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` - Method string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"` - Key string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"` - UdpOverTcp bool `protobuf:"varint,5,opt,name=udp_over_tcp,json=udpOverTcp,proto3" json:"udp_over_tcp,omitempty"` + Address *net.IPOrDomain `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Port uint32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` + Method string `protobuf:"bytes,3,opt,name=method,proto3" json:"method,omitempty"` + Key string `protobuf:"bytes,4,opt,name=key,proto3" json:"key,omitempty"` + UdpOverTcp bool `protobuf:"varint,5,opt,name=udp_over_tcp,json=udpOverTcp,proto3" json:"udp_over_tcp,omitempty"` + UdpOverTcpVersion uint32 `protobuf:"varint,6,opt,name=udp_over_tcp_version,json=udpOverTcpVersion,proto3" json:"udp_over_tcp_version,omitempty"` } func (x *ClientConfig) Reset() { @@ -463,6 +464,13 @@ func (x *ClientConfig) GetUdpOverTcp() bool { return false } +func (x *ClientConfig) GetUdpOverTcpVersion() uint32 { + if x != nil { + return x.UdpOverTcpVersion + } + return 0 +} + var File_proxy_shadowsocks_2022_config_proto protoreflect.FileDescriptor var file_proxy_shadowsocks_2022_config_proto_rawDesc = []byte{ @@ -520,7 +528,7 @@ var file_proxy_shadowsocks_2022_config_proto_rawDesc = []byte{ 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x22, 0xa5, 0x01, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x22, 0xd6, 0x01, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, @@ -531,15 +539,18 @@ var file_proxy_shadowsocks_2022_config_proto_rawDesc = []byte{ 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x0c, 0x75, 0x64, 0x70, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x5f, 0x74, 0x63, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x75, 0x64, 0x70, 0x4f, 0x76, - 0x65, 0x72, 0x54, 0x63, 0x70, 0x42, 0x72, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, - 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, - 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x68, 0x61, 0x64, - 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0xaa, 0x02, 0x1a, 0x58, - 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, - 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x65, 0x72, 0x54, 0x63, 0x70, 0x12, 0x2f, 0x0a, 0x14, 0x75, 0x64, 0x70, 0x5f, 0x6f, 0x76, 0x65, + 0x72, 0x5f, 0x74, 0x63, 0x70, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x11, 0x75, 0x64, 0x70, 0x4f, 0x76, 0x65, 0x72, 0x54, 0x63, 0x70, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x72, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, + 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, + 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x68, 0x61, + 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0xaa, 0x02, 0x1a, + 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x68, 0x61, 0x64, 0x6f, + 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/proxy/shadowsocks_2022/config.proto b/proxy/shadowsocks_2022/config.proto index 2c4690e4..60540991 100644 --- a/proxy/shadowsocks_2022/config.proto +++ b/proxy/shadowsocks_2022/config.proto @@ -51,4 +51,5 @@ message ClientConfig { string method = 3; string key = 4; bool udp_over_tcp = 5; + uint32 udp_over_tcp_version = 6; } diff --git a/proxy/shadowsocks_2022/outbound.go b/proxy/shadowsocks_2022/outbound.go index cc23f737..5b1583cb 100644 --- a/proxy/shadowsocks_2022/outbound.go +++ b/proxy/shadowsocks_2022/outbound.go @@ -11,7 +11,6 @@ import ( C "github.com/sagernet/sing/common" B "github.com/sagernet/sing/common/buf" "github.com/sagernet/sing/common/bufio" - M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" "github.com/sagernet/sing/common/uot" "github.com/xtls/xray-core/common" @@ -29,10 +28,10 @@ func init() { } type Outbound struct { - ctx context.Context - server net.Destination - method shadowsocks.Method - uot bool + ctx context.Context + server net.Destination + method shadowsocks.Method + uotClient *uot.Client } func NewClient(ctx context.Context, config *ClientConfig) (*Outbound, error) { @@ -43,7 +42,6 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Outbound, error) { Port: net.Port(config.Port), Network: net.Network_TCP, }, - uot: config.UdpOverTcp, } if C.Contains(shadowaead_2022.List, config.Method) { if config.Key == "" { @@ -57,6 +55,9 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Outbound, error) { } else { return nil, newError("unknown method ", config.Method) } + if config.UdpOverTcp { + o.uotClient = &uot.Client{Version: uint8(config.UdpOverTcpVersion)} + } return o, nil } @@ -77,7 +78,7 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int newError("tunneling request to ", destination, " via ", o.server.NetAddr()).WriteToLog(session.ExportIDToError(ctx)) serverDestination := o.server - if o.uot { + if o.uotClient != nil { serverDestination.Network = net.Network_TCP } else { serverDestination.Network = network @@ -149,9 +150,12 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int } } - if o.uot { - serverConn := o.method.DialEarlyConn(connection, M.Socksaddr{Fqdn: uot.UOTMagicAddress}) - return returnError(bufio.CopyPacketConn(ctx, packetConn, uot.NewClientConn(serverConn))) + if o.uotClient != nil { + uConn, err := o.uotClient.DialEarlyConn(o.method.DialEarlyConn(connection, uot.RequestDestination(o.uotClient.Version)), false, toSocksaddr(destination)) + if err != nil { + return err + } + return returnError(bufio.CopyPacketConn(ctx, packetConn, uConn)) } else { serverConn := o.method.DialPacketConn(connection) return returnError(bufio.CopyPacketConn(ctx, packetConn, serverConn)) From 55efac7236ca63f7d16620190643a83c7d4ec4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Fri, 17 Mar 2023 13:17:01 +0800 Subject: [PATCH 003/867] Reformat code --- common/protocol/headers.go | 3 +-- infra/conf/transport_internet.go | 4 ++-- proxy/vless/encoding/encoding.go | 2 +- proxy/vless/outbound/outbound.go | 2 +- transport/internet/headers/dns/dns.go | 1 - transport/internet/kcp/listener.go | 16 ++++++++-------- transport/internet/reality/reality.go | 6 ++++-- transport/internet/sockopt_linux.go | 22 +++++++++++----------- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/common/protocol/headers.go b/common/protocol/headers.go index 8806ee80..0058d1c5 100644 --- a/common/protocol/headers.go +++ b/common/protocol/headers.go @@ -3,11 +3,10 @@ package protocol import ( "runtime" - "golang.org/x/sys/cpu" - "github.com/xtls/xray-core/common/bitmask" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/uuid" + "golang.org/x/sys/cpu" ) // RequestCommand is a custom command in a proxy request. diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 63c8fbed..7424c548 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -616,7 +616,7 @@ type SocketConfig struct { TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"` TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"` TCPCongestion string `json:"tcpCongestion"` - TCPWindowClamp int32 `json:"tcpWindowClamp"` + TCPWindowClamp int32 `json:"tcpWindowClamp"` V6only bool `json:"v6only"` Interface string `json:"interface"` } @@ -668,7 +668,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { TcpKeepAliveInterval: c.TCPKeepAliveInterval, TcpKeepAliveIdle: c.TCPKeepAliveIdle, TcpCongestion: c.TCPCongestion, - TcpWindowClamp: c.TCPWindowClamp, + TcpWindowClamp: c.TCPWindowClamp, V6Only: c.V6only, Interface: c.Interface, }, nil diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index b96acee9..27d1fb01 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -485,7 +485,7 @@ func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool } paddingLen = int32(l.Int64()) } - if paddingLen > buf.Size - 21 - contentLen { + if paddingLen > buf.Size-21-contentLen { paddingLen = buf.Size - 21 - contentLen } newbuffer := buf.New() diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index cde09bad..b7bc6964 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -287,7 +287,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte counter = statConn.ReadCounter } err = encoding.XtlsRead(serverReader, clientWriter, timer, netConn, rawConn, input, rawInput, counter, ctx, account.ID.Bytes(), - &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) + &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) } else { // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer)) diff --git a/transport/internet/headers/dns/dns.go b/transport/internet/headers/dns/dns.go index 5839bc81..a7366d1a 100644 --- a/transport/internet/headers/dns/dns.go +++ b/transport/internet/headers/dns/dns.go @@ -37,7 +37,6 @@ func NewDNS(ctx context.Context, config interface{}) (interface{}, error) { buf := make([]byte, 0x100) off1, err := dns.PackDomainName(dns.Fqdn(config.(*Config).Domain), buf, 0, nil, false) - if err != nil { return nil, err } diff --git a/transport/internet/kcp/listener.go b/transport/internet/kcp/listener.go index baf38e6d..82b5a3bc 100644 --- a/transport/internet/kcp/listener.go +++ b/transport/internet/kcp/listener.go @@ -24,14 +24,14 @@ type ConnectionID struct { // Listener defines a server listening for connections type Listener struct { sync.Mutex - sessions map[ConnectionID]*Connection - hub *udp.Hub - tlsConfig *gotls.Config - config *Config - reader PacketReader - header internet.PacketHeader - security cipher.AEAD - addConn internet.ConnHandler + sessions map[ConnectionID]*Connection + hub *udp.Hub + tlsConfig *gotls.Config + config *Config + reader PacketReader + header internet.PacketHeader + security cipher.AEAD + addConn internet.ConnHandler } func NewListener(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (*Listener, error) { diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 835c075a..3bdf1f43 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -240,8 +240,10 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati return uConn, nil } -var href = regexp.MustCompile(`href="([/h].*?)"`) -var dot = []byte(".") +var ( + href = regexp.MustCompile(`href="([/h].*?)"`) + dot = []byte(".") +) var maps struct { sync.Mutex diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index eda5de15..ea023f53 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -47,11 +47,11 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf } } - if config.Interface != "" { - if err := syscall.BindToDevice(int(fd), config.Interface); err != nil { - return newError("failed to set Interface").Base(err) - } - } + if config.Interface != "" { + if err := syscall.BindToDevice(int(fd), config.Interface); err != nil { + return newError("failed to set Interface").Base(err) + } + } if isTCPSocket(network) { tfo := config.ParseTFOValue() @@ -91,10 +91,10 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf } if config.TcpWindowClamp > 0 { - if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_WINDOW_CLAMP, int(config.TcpWindowClamp)); err != nil { - return newError("failed to set TCP_WINDOW_CLAMP", err) - } - } + if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_WINDOW_CLAMP, int(config.TcpWindowClamp)); err != nil { + return newError("failed to set TCP_WINDOW_CLAMP", err) + } + } } if config.Tproxy.IsEnabled() { @@ -148,8 +148,8 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) if config.TcpWindowClamp > 0 { if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_WINDOW_CLAMP, int(config.TcpWindowClamp)); err != nil { - return newError("failed to set TCP_WINDOW_CLAMP", err) - } + return newError("failed to set TCP_WINDOW_CLAMP", err) + } } } From 172f353bd7fa0783d61f28a64f94bbef1d43cd79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 20 Mar 2023 14:59:13 +0800 Subject: [PATCH 004/867] Update dependencies --- go.mod | 2 +- go.sum | 6 ++---- proxy/shadowsocks_2022/inbound.go | 2 +- proxy/shadowsocks_2022/inbound_multi.go | 2 +- proxy/shadowsocks_2022/outbound.go | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index dfb7ca04..d24f0def 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/quic-go/quic-go v0.33.0 github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db github.com/sagernet/sing v0.2.0 - github.com/sagernet/sing-shadowsocks v0.1.1 + github.com/sagernet/sing-shadowsocks v0.2.0 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.2 diff --git a/go.sum b/go.sum index 155155a2..32c5e31e 100644 --- a/go.sum +++ b/go.sum @@ -141,12 +141,10 @@ github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db/go.mo github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.1.9-0.20230315063014-2731df16725b h1:1iKGftQ59+shDSx2RaLaxXJcMK/B+IU9WqUPwyBW+E0= -github.com/sagernet/sing v0.1.9-0.20230315063014-2731df16725b/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= github.com/sagernet/sing v0.2.0 h1:iyc4TaeXG5XYXixl48zSDDTw46C9NOEAVFq6ZE0dA2k= github.com/sagernet/sing v0.2.0/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= -github.com/sagernet/sing-shadowsocks v0.1.1 h1:uFK2rlVeD/b1xhDwSMbUI2goWc6fOKxp+ZeKHZq6C9Q= -github.com/sagernet/sing-shadowsocks v0.1.1/go.mod h1:f3mHTy5shnVM9l8UocMlJgC/1G/zdj5FuEuVXhDinGU= +github.com/sagernet/sing-shadowsocks v0.2.0 h1:ILDWL7pwWfkPLEbviE/MyCgfjaBmJY/JVVY+5jhSb58= +github.com/sagernet/sing-shadowsocks v0.2.0/go.mod h1:ysYzszRLpNzJSorvlWRMuzU6Vchsp7sd52q+JNY4axw= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c/go.mod h1:euOmN6O5kk9dQmgSS8Df4psAl3TCjxOz0NW60EWkSaI= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= diff --git a/proxy/shadowsocks_2022/inbound.go b/proxy/shadowsocks_2022/inbound.go index 55bdda9f..550aadd1 100644 --- a/proxy/shadowsocks_2022/inbound.go +++ b/proxy/shadowsocks_2022/inbound.go @@ -50,7 +50,7 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Inbound, error) { if !C.Contains(shadowaead_2022.List, config.Method) { return nil, newError("unsupported method ", config.Method) } - service, err := shadowaead_2022.NewServiceWithPassword(config.Method, config.Key, 500, inbound) + service, err := shadowaead_2022.NewServiceWithPassword(config.Method, config.Key, 500, inbound, nil) if err != nil { return nil, newError("create service").Base(err) } diff --git a/proxy/shadowsocks_2022/inbound_multi.go b/proxy/shadowsocks_2022/inbound_multi.go index 662a171c..695de8e2 100644 --- a/proxy/shadowsocks_2022/inbound_multi.go +++ b/proxy/shadowsocks_2022/inbound_multi.go @@ -58,7 +58,7 @@ func NewMultiServer(ctx context.Context, config *MultiUserServerConfig) (*MultiU if err != nil { return nil, newError("parse config").Base(err) } - service, err := shadowaead_2022.NewMultiService[int](config.Method, psk, 500, inbound) + service, err := shadowaead_2022.NewMultiService[int](config.Method, psk, 500, inbound, nil) if err != nil { return nil, newError("create service").Base(err) } diff --git a/proxy/shadowsocks_2022/outbound.go b/proxy/shadowsocks_2022/outbound.go index 5b1583cb..eb38c017 100644 --- a/proxy/shadowsocks_2022/outbound.go +++ b/proxy/shadowsocks_2022/outbound.go @@ -47,7 +47,7 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Outbound, error) { if config.Key == "" { return nil, newError("missing psk") } - method, err := shadowaead_2022.NewWithPassword(config.Method, config.Key) + method, err := shadowaead_2022.NewWithPassword(config.Method, config.Key, nil) if err != nil { return nil, newError("create method").Base(err) } From 05737603463b5ad0064e386d97318f2559f17d2b Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 20 Mar 2023 23:39:56 +0800 Subject: [PATCH 005/867] Do not show ciphertext SessionID or full AuthKey --- go.mod | 2 +- go.sum | 4 ++-- transport/internet/reality/reality.go | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index d24f0def..2f4e1d2e 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.2 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e - github.com/xtls/reality v0.0.0-20230309125256-0d0713b108c8 + github.com/xtls/reality v0.0.0-20230320153727-442d33ede91e go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 golang.org/x/crypto v0.7.0 golang.org/x/net v0.8.0 diff --git a/go.sum b/go.sum index 32c5e31e..7bf28256 100644 --- a/go.sum +++ b/go.sum @@ -189,8 +189,8 @@ github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/xtls/reality v0.0.0-20230309125256-0d0713b108c8 h1:LLtLxEe3S0Ko+ckqt4t29RLskpNdOZfgjZCC2/Byr50= -github.com/xtls/reality v0.0.0-20230309125256-0d0713b108c8/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= +github.com/xtls/reality v0.0.0-20230320153727-442d33ede91e h1:mUMY3ndB1zZVic4+EjvTWzm9ghdpbdHZC9RwR0CoFxU= +github.com/xtls/reality v0.0.0-20230320153727-442d33ede91e/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 3bdf1f43..a0a66afa 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -127,7 +127,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati hello.SessionId[2] = core.Version_z copy(hello.SessionId[8:], config.ShortId) if config.Show { - fmt.Printf("REALITY localAddr: %v\thello.sessionId[:16]: %v\n", localAddr, hello.SessionId[:16]) + fmt.Printf("REALITY localAddr: %v\thello.SessionId[:16]: %v\n", localAddr, hello.SessionId[:16]) } uConn.AuthKey = uConn.HandshakeState.State13.EcdheParams.SharedKey(config.PublicKey) if uConn.AuthKey == nil { @@ -136,14 +136,13 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati if _, err := hkdf.New(sha256.New, uConn.AuthKey, hello.Random[:20], []byte("REALITY")).Read(uConn.AuthKey); err != nil { return nil, err } + if config.Show { + fmt.Printf("REALITY localAddr: %v\tuConn.AuthKey[:16]: %v\n", localAddr, uConn.AuthKey[:16]) + } block, _ := aes.NewCipher(uConn.AuthKey) aead, _ := cipher.NewGCM(block) aead.Seal(hello.SessionId[:0], hello.Random[20:], hello.SessionId[:16], hello.Raw) copy(hello.Raw[39:], hello.SessionId) - if config.Show { - fmt.Printf("REALITY localAddr: %v\thello.sessionId: %v\n", localAddr, hello.SessionId) - fmt.Printf("REALITY localAddr: %v\tuConn.AuthKey: %v\n", localAddr, uConn.AuthKey) - } } if err := uConn.Handshake(); err != nil { return nil, err From f89998fc779b96047affa5b6a73b3a883217d813 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Mar 2023 01:35:15 +0000 Subject: [PATCH 006/867] Update dependencies --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- go.mod | 10 +++++----- go.sum | 37 ++++++++++------------------------- 4 files changed, 17 insertions(+), 34 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index edbc01c1..98ee485a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -165,7 +165,7 @@ jobs: echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: '1.20' check-latest: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 49af621b..55891af0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: os: [windows-latest, ubuntu-latest, macos-latest] steps: - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: go-version: '1.20' check-latest: true diff --git a/go.mod b/go.mod index 2f4e1d2e..52aac9af 100644 --- a/go.mod +++ b/go.mod @@ -8,11 +8,11 @@ require ( github.com/golang/protobuf v1.5.3 github.com/google/go-cmp v0.5.9 github.com/gorilla/websocket v1.5.0 - github.com/miekg/dns v1.1.51 + github.com/miekg/dns v1.1.52 github.com/pelletier/go-toml v1.9.5 - github.com/pires/go-proxyproto v0.6.2 + github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.33.0 - github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db + github.com/refraction-networking/utls v1.3.1 github.com/sagernet/sing v0.2.0 github.com/sagernet/sing-shadowsocks v0.2.0 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c @@ -25,8 +25,8 @@ require ( golang.org/x/net v0.8.0 golang.org/x/sync v0.1.0 golang.org/x/sys v0.6.0 - google.golang.org/grpc v1.53.0 - google.golang.org/protobuf v1.29.0 + google.golang.org/grpc v1.54.0 + google.golang.org/protobuf v1.30.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h12.io/socks v1.0.3 ) diff --git a/go.sum b/go.sum index 7bf28256..d56f19e4 100644 --- a/go.sum +++ b/go.sum @@ -106,8 +106,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= -github.com/miekg/dns v1.1.51 h1:0+Xg7vObnhrz/4ZCZcZh7zPXlmU0aveS2HDBd0m0qSo= -github.com/miekg/dns v1.1.51/go.mod h1:2Z9d3CP1LQWihRZUf29mQ19yDThaI4DAYzte2CaQW5c= +github.com/miekg/dns v1.1.52 h1:Bmlc/qsNNULOe6bpXcUTsuOajd0DzRHwup6D9k1An0c= +github.com/miekg/dns v1.1.52/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= @@ -120,8 +120,8 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= -github.com/pires/go-proxyproto v0.6.2 h1:KAZ7UteSOt6urjme6ZldyFm4wDe/z0ZUP0Yv0Dos0d8= -github.com/pires/go-proxyproto v0.6.2/go.mod h1:Odh9VFOZJCf9G8cLW5o435Xf1J95Jw9Gw5rnCjcwzAY= +github.com/pires/go-proxyproto v0.7.0 h1:IukmRewDQFWC7kfnb66CSomk2q/seBuilHBYFwyq0Hs= +github.com/pires/go-proxyproto v0.7.0/go.mod h1:Vz/1JPY/OACxWGQNIRY2BeyDmpoaWmEP40O9LbuiFR4= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -136,8 +136,8 @@ github.com/quic-go/qtls-go1-20 v0.1.1 h1:KbChDlg82d3IHqaj2bn6GfKRj84Per2VGf5XV3w github.com/quic-go/qtls-go1-20 v0.1.1/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0= github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA= -github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db h1:ULRv/GPW5KYDafE0FACN2no+HTCyQLUtfyOIeyp3GNc= -github.com/refraction-networking/utls v1.2.3-0.20230308205431-4f1df6c200db/go.mod h1:kHXvVB66a4BzVRYC4Em7e1HAfp7uwOCCw0+2CZ3sMY8= +github.com/refraction-networking/utls v1.3.1 h1:3zVomUqx7nCmyGuU/6kYA/jp5NcqX8KQSGko8pY5Ch4= +github.com/refraction-networking/utls v1.3.1/go.mod h1:kHXvVB66a4BzVRYC4Em7e1HAfp7uwOCCw0+2CZ3sMY8= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= @@ -192,7 +192,6 @@ github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMI github.com/xtls/reality v0.0.0-20230320153727-442d33ede91e h1:mUMY3ndB1zZVic4+EjvTWzm9ghdpbdHZC9RwR0CoFxU= github.com/xtls/reality v0.0.0-20230320153727-442d33ede91e/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 h1:Ss6D3hLXTM0KobyBYEAygXzFfGcjnmfEJOBgSbemCtg= go.starlark.net v0.0.0-20230302034142-4b1e35fe2254/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds= @@ -204,7 +203,6 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -215,8 +213,6 @@ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTk golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -230,10 +226,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -247,7 +240,6 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -260,22 +252,15 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -291,8 +276,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -321,8 +304,8 @@ google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3 google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc= -google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw= +google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= +google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -333,8 +316,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.29.0 h1:44S3JjaKmLEE4YIkjzexaP+NzZsudE3Zin5Njn/pYX0= -google.golang.org/protobuf v1.29.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= From c6b78318cb5f3b596b9fbb06a48a8fdb83ba925d Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 24 Mar 2023 22:57:56 +0000 Subject: [PATCH 007/867] Update README.md Co-authored-by: chika0801 <88967758+chika0801@users.noreply.github.com> Co-authored-by: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> --- README.md | 89 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 62 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 7579cb91..77b6185e 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,99 @@ # Project X -[Project X](https://github.com/XTLS) originates from XTLS protocol, provides a set of network tools such as [Xray-core](https://github.com/XTLS/Xray-core). +[Project X](https://github.com/XTLS) originates from XTLS protocol, providing a set of network tools such as [Xray-core](https://github.com/XTLS/Xray-core) and [REALITY](https://github.com/XTLS/REALITY). + +[README](https://github.com/XTLS/Xray-core#readme) is open, so feel free to submit your project [here](https://github.com/XTLS/Xray-core/pulls). ## License [Mozilla Public License Version 2.0](https://github.com/XTLS/Xray-core/blob/main/LICENSE) +## Documentation + +[Project X Official Website](https://xtls.github.io) + +## Telegram + +[Project X](https://t.me/projectXray) + +[Project X Channel](https://t.me/projectXtls) + ## Installation - Linux Script - - [Xray-install](https://github.com/XTLS/Xray-install) - - [Xray-script](https://github.com/kirin10000/Xray-script) + - [XTLS/Xray-install](https://github.com/XTLS/Xray-install) - Docker - [teddysun/xray](https://hub.docker.com/r/teddysun/xray) +- Web Panel + - [X-UI](https://github.com/FranzKafkaYu/x-ui), [X-UI-English](https://github.com/NidukaAkalanka/x-ui-english), [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [X-UI](https://github.com/diditra/x-ui) + - [Hiddify](https://github.com/hiddify/hiddify-config) + - [Marzban](https://github.com/Gozargah/Marzban) - One Click - - [ProxySU](https://github.com/proxysu/ProxySU) - - [v2ray-agent](https://github.com/mack-a/v2ray-agent) - - [Xray-yes](https://github.com/jiuqi9997/Xray-yes) - - [Xray_onekey](https://github.com/wulabing/Xray_onekey) + - [Xray-script](https://github.com/kirin10000/Xray-script), [Xray-script](https://github.com/zxcvos/Xray-script), [xray_script](https://github.com/tdjnodj/xray_script) + - [XTool](https://github.com/LordPenguin666/XTool), [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [xray-reality](https://github.com/sajjaddg/xray-reality) + - [v2ray-agent](https://github.com/mack-a/v2ray-agent), [Xray_onekey](https://github.com/wulabing/Xray_onekey), [ProxySU](https://github.com/proxysu/ProxySU) - Magisk - [Xray4Magisk](https://github.com/CerteKim/Xray4Magisk) - [Xray_For_Magisk](https://github.com/E7KMbb/Xray_For_Magisk) - Homebrew - `brew install xray` - [(Tap) Repository 0](https://github.com/N4FA/homebrew-xray) - - [(Tap) Repository 1](https://github.com/xiruizhao/homebrew-xray) - -## Contributing -[Code Of Conduct](https://github.com/XTLS/Xray-core/blob/main/CODE_OF_CONDUCT.md) ## Usage -[Xray-examples](https://github.com/XTLS/Xray-examples) / [VLESS-TCP-XTLS-WHATEVER](https://github.com/XTLS/Xray-examples/tree/main/VLESS-TCP-XTLS-WHATEVER) +- Example + - [VLESS-XTLS-uTLS-REALITY](https://github.com/XTLS/REALITY#readme) + - [VLESS-TCP-XTLS-Vision](https://github.com/XTLS/Xray-examples/tree/main/VLESS-TCP-XTLS-Vision) + - [All-in-One-fallbacks-Nginx](https://github.com/XTLS/Xray-examples/tree/main/All-in-One-fallbacks-Nginx) +- Xray-examples + - [XTLS/Xray-examples](https://github.com/XTLS/Xray-examples) + - [chika0801/Xray-examples](https://github.com/chika0801/Xray-examples) + - [lxhao61/integrated-examples](https://github.com/lxhao61/integrated-examples) +- Tutorial + - [XTLS Vision](https://github.com/chika0801/Xray-install) + - [REALITY (English)](https://cscot.pages.dev/2023/03/02/Xray-REALITY-tutorial/) ## GUI Clients - OpenWrt - - [PassWall](https://github.com/xiaorouji/openwrt-passwall) - - [Hello World](https://github.com/jerrykuku/luci-app-vssr) + - [PassWall](https://github.com/xiaorouji/openwrt-passwall), [PassWall 2](https://github.com/xiaorouji/openwrt-passwall2) - [ShadowSocksR Plus+](https://github.com/fw876/helloworld) - [luci-app-xray](https://github.com/yichya/luci-app-xray) ([openwrt-xray](https://github.com/yichya/openwrt-xray)) - Windows - [v2rayN](https://github.com/2dust/v2rayN) - - [Qv2ray](https://github.com/Qv2ray/Qv2ray) (This project had been archived and currently inactive) - - [Netch (NetFilter & TUN/TAP)](https://github.com/NetchX/Netch) (This project had been archived and currently inactive) + - [Invisible Man - Xray](https://github.com/InvisibleManVPN/InvisibleMan-XRayClient) - Android - [v2rayNG](https://github.com/2dust/v2rayNG) - - [Kitsunebi](https://github.com/rurirei/Kitsunebi/tree/release_xtls) -- iOS & macOS (with M1 chip) + - [X-flutter](https://github.com/XTLS/X-flutter) +- iOS & macOS arm64 + - [Mango](https://github.com/daemooon/Mango) + - [Wings X](https://apps.apple.com/app/wings-x/id6446119727) +- macOS arm64 & x64 + - [V2RayXS](https://github.com/tzmax/V2RayXS) + - [Wings X](https://apps.apple.com/app/wings-x/id6446119727) + +## Others that support VLESS, XTLS, REALITY, XUDP, PLUX... + +- iOS & macOS arm64 - [Shadowrocket](https://apps.apple.com/app/shadowrocket/id932747118) - [Stash](https://apps.apple.com/app/stash/id1596063349) -- macOS (Intel chip & M1 chip) - - [Qv2ray](https://github.com/Qv2ray/Qv2ray) (This project had been archived and currently inactive) - - [V2RayXS](https://github.com/tzmax/V2RayXS) +- API Wrapper + - [xtlsapi](https://github.com/hiddify/xtlsapi) +- [XrayR](https://github.com/XrayR-project/XrayR) + - [XrayR-release](https://github.com/XrayR-project/XrayR-release) + - [XrayR-V2Board](https://github.com/missuo/XrayR-V2Board) +- [Clash.Meta](https://github.com/MetaCubeX/Clash.Meta) + - [Clash Verge](https://github.com/zzzgydi/clash-verge) + - [clashN](https://github.com/2dust/clashN) + - [Clash Meta for Android](https://github.com/MetaCubeX/ClashMetaForAndroid) + - [meta_for_ios](https://t.me/meta_for_ios) +- [sing-box](https://github.com/SagerNet/sing-box) + - [installReality](https://github.com/BoxXt/installReality) + - [sing-box-for-ios](https://github.com/SagerNet/sing-box-for-ios) + +## Contributing + +[Code of Conduct](https://github.com/XTLS/Xray-core/blob/main/CODE_OF_CONDUCT.md) ## Credits @@ -88,12 +129,6 @@ go build -o xray.exe -trimpath -ldflags "-s -w -buildid=" ./main go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main ``` -## Telegram - -[Project X](https://t.me/projectXray) - -[Project X Channel](https://t.me/projectXtls) - ## Stargazers over time [![Stargazers over time](https://starchart.cc/XTLS/Xray-core.svg)](https://starchart.cc/XTLS/Xray-core) From 6872be5cc34ca82db31b341cd40b990ad585ab4c Mon Sep 17 00:00:00 2001 From: Hirbod Behnam Date: Sun, 26 Mar 2023 09:23:42 +0330 Subject: [PATCH 008/867] Add user agent to gRPC (#1790) --- infra/conf/grpc.go | 2 ++ transport/internet/grpc/config.pb.go | 22 ++++++++++++++++------ transport/internet/grpc/config.proto | 1 + transport/internet/grpc/dial.go | 4 ++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/infra/conf/grpc.go b/infra/conf/grpc.go index 3813e40d..9085ab4d 100644 --- a/infra/conf/grpc.go +++ b/infra/conf/grpc.go @@ -12,6 +12,7 @@ type GRPCConfig struct { HealthCheckTimeout int32 `json:"health_check_timeout"` PermitWithoutStream bool `json:"permit_without_stream"` InitialWindowsSize int32 `json:"initial_windows_size"` + UserAgent string `json:"user_agent"` } func (g *GRPCConfig) Build() (proto.Message, error) { @@ -33,5 +34,6 @@ func (g *GRPCConfig) Build() (proto.Message, error) { HealthCheckTimeout: g.HealthCheckTimeout, PermitWithoutStream: g.PermitWithoutStream, InitialWindowsSize: g.InitialWindowsSize, + UserAgent: g.UserAgent, }, nil } diff --git a/transport/internet/grpc/config.pb.go b/transport/internet/grpc/config.pb.go index 9a94984d..52d03fd1 100644 --- a/transport/internet/grpc/config.pb.go +++ b/transport/internet/grpc/config.pb.go @@ -32,6 +32,7 @@ type Config struct { HealthCheckTimeout int32 `protobuf:"varint,5,opt,name=health_check_timeout,json=healthCheckTimeout,proto3" json:"health_check_timeout,omitempty"` PermitWithoutStream bool `protobuf:"varint,6,opt,name=permit_without_stream,json=permitWithoutStream,proto3" json:"permit_without_stream,omitempty"` InitialWindowsSize int32 `protobuf:"varint,7,opt,name=initial_windows_size,json=initialWindowsSize,proto3" json:"initial_windows_size,omitempty"` + UserAgent string `protobuf:"bytes,8,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"` } func (x *Config) Reset() { @@ -115,6 +116,13 @@ func (x *Config) GetInitialWindowsSize() int32 { return 0 } +func (x *Config) GetUserAgent() string { + if x != nil { + return x.UserAgent + } + return "" +} + var File_transport_internet_grpc_config_proto protoreflect.FileDescriptor var file_transport_internet_grpc_config_proto_rawDesc = []byte{ @@ -122,7 +130,7 @@ var file_transport_internet_grpc_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x25, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, - 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x22, 0x99, 0x02, + 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x22, 0xb8, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, @@ -140,11 +148,13 @@ var file_transport_internet_grpc_config_proto_rawDesc = []byte{ 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x30, 0x0a, 0x14, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x57, 0x69, - 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x53, 0x69, 0x7a, 0x65, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, + 0x73, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/grpc/config.proto b/transport/internet/grpc/config.proto index 7d256b2c..56c507ae 100644 --- a/transport/internet/grpc/config.proto +++ b/transport/internet/grpc/config.proto @@ -11,4 +11,5 @@ message Config { int32 health_check_timeout = 5; bool permit_without_stream = 6; int32 initial_windows_size = 7; + string user_agent = 8; } diff --git a/transport/internet/grpc/dial.go b/transport/internet/grpc/dial.go index 4ab4b615..8c58ff14 100644 --- a/transport/internet/grpc/dial.go +++ b/transport/internet/grpc/dial.go @@ -150,6 +150,10 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in dialOptions = append(dialOptions, grpc.WithInitialWindowSize(grpcSettings.InitialWindowsSize)) } + if grpcSettings.UserAgent != "" { + dialOptions = append(dialOptions, grpc.WithUserAgent(grpcSettings.UserAgent)) + } + var grpcDestHost string if dest.Address.Family().IsDomain() { grpcDestHost = dest.Address.Domain() From 526c6789ed5f56aaf8bad665f12692b8aae1565a Mon Sep 17 00:00:00 2001 From: Hirbod Behnam Date: Sun, 26 Mar 2023 09:28:19 +0330 Subject: [PATCH 009/867] Add custom path to gRPC (#1815) --- transport/internet/grpc/config.go | 40 ++++++- transport/internet/grpc/config_test.go | 111 ++++++++++++++++++ transport/internet/grpc/dial.go | 7 +- .../grpc/encoding/customSeviceName.go | 22 ++-- transport/internet/grpc/hub.go | 3 +- 5 files changed, 166 insertions(+), 17 deletions(-) create mode 100644 transport/internet/grpc/config_test.go diff --git a/transport/internet/grpc/config.go b/transport/internet/grpc/config.go index d87722a4..39eadf31 100644 --- a/transport/internet/grpc/config.go +++ b/transport/internet/grpc/config.go @@ -2,6 +2,7 @@ package grpc import ( "net/url" + "strings" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/transport/internet" @@ -15,6 +16,41 @@ func init() { })) } -func (c *Config) getNormalizedName() string { - return url.PathEscape(c.ServiceName) +func (c *Config) getServiceName() string { + // Normal old school config + if !strings.HasPrefix(c.ServiceName, "/") { + return url.PathEscape(c.ServiceName) + } + // Otherwise new custom paths + rawServiceName := c.ServiceName[1:strings.LastIndex(c.ServiceName, "/")] // trim from first to last '/' + serviceNameParts := strings.Split(rawServiceName, "/") + for i := range serviceNameParts { + serviceNameParts[i] = url.PathEscape(serviceNameParts[i]) + } + return strings.Join(serviceNameParts, "/") +} + +func (c *Config) getTunStreamName() string { + // Normal old school config + if !strings.HasPrefix(c.ServiceName, "/") { + return "Tun" + } + // Otherwise new custom paths + endingPath := c.ServiceName[strings.LastIndex(c.ServiceName, "/")+1:] // from the last '/' to end of string + return url.PathEscape(strings.Split(endingPath, "|")[0]) +} + +func (c *Config) getTunMultiStreamName() string { + // Normal old school config + if !strings.HasPrefix(c.ServiceName, "/") { + return "TunMulti" + } + // Otherwise new custom paths + endingPath := c.ServiceName[strings.LastIndex(c.ServiceName, "/")+1:] // from the last '/' to end of string + streamNames := strings.Split(endingPath, "|") + if len(streamNames) == 1 { // client side. Service name is the full path to multi tun + return url.PathEscape(streamNames[0]) + } else { // server side. The second part is the path to multi tun + return url.PathEscape(streamNames[1]) + } } diff --git a/transport/internet/grpc/config_test.go b/transport/internet/grpc/config_test.go new file mode 100644 index 00000000..fbc549b4 --- /dev/null +++ b/transport/internet/grpc/config_test.go @@ -0,0 +1,111 @@ +package grpc + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +func TestConfig_GetServiceName(t *testing.T) { + tests := []struct { + TestName string + ServiceName string + Expected string + }{ + { + TestName: "simple no absolute path", + ServiceName: "hello", + Expected: "hello", + }, + { + TestName: "escape no absolute path", + ServiceName: "hello/world!", + Expected: "hello%2Fworld%21", + }, + { + TestName: "absolute path", + ServiceName: "/my/sample/path/a|b", + Expected: "my/sample/path", + }, + { + TestName: "escape absolute path", + ServiceName: "/hello /world!/a|b", + Expected: "hello%20/world%21", + }, + } + for _, test := range tests { + t.Run(test.TestName, func(t *testing.T) { + config := Config{ServiceName: test.ServiceName} + assert.Equal(t, test.Expected, config.getServiceName()) + }) + } +} + +func TestConfig_GetTunStreamName(t *testing.T) { + tests := []struct { + TestName string + ServiceName string + Expected string + }{ + { + TestName: "no absolute path", + ServiceName: "hello", + Expected: "Tun", + }, + { + TestName: "absolute path server", + ServiceName: "/my/sample/path/tun_service|multi_service", + Expected: "tun_service", + }, + { + TestName: "absolute path client", + ServiceName: "/my/sample/path/tun_service", + Expected: "tun_service", + }, + { + TestName: "escape absolute path client", + ServiceName: "/m y/sa !mple/pa\\th/tun\\_serv!ice", + Expected: "tun%5C_serv%21ice", + }, + } + for _, test := range tests { + t.Run(test.TestName, func(t *testing.T) { + config := Config{ServiceName: test.ServiceName} + assert.Equal(t, test.Expected, config.getTunStreamName()) + }) + } +} + +func TestConfig_GetTunMultiStreamName(t *testing.T) { + tests := []struct { + TestName string + ServiceName string + Expected string + }{ + { + TestName: "no absolute path", + ServiceName: "hello", + Expected: "TunMulti", + }, + { + TestName: "absolute path server", + ServiceName: "/my/sample/path/tun_service|multi_service", + Expected: "multi_service", + }, + { + TestName: "absolute path client", + ServiceName: "/my/sample/path/multi_service", + Expected: "multi_service", + }, + { + TestName: "escape absolute path client", + ServiceName: "/m y/sa !mple/pa\\th/mu%lti\\_serv!ice", + Expected: "mu%25lti%5C_serv%21ice", + }, + } + for _, test := range tests { + t.Run(test.TestName, func(t *testing.T) { + config := Config{ServiceName: test.ServiceName} + assert.Equal(t, test.Expected, config.getTunMultiStreamName()) + }) + } +} diff --git a/transport/internet/grpc/dial.go b/transport/internet/grpc/dial.go index 8c58ff14..8fd544b5 100644 --- a/transport/internet/grpc/dial.go +++ b/transport/internet/grpc/dial.go @@ -54,15 +54,16 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne } client := encoding.NewGRPCServiceClient(conn) if grpcSettings.MultiMode { - newError("using gRPC multi mode").AtDebug().WriteToLog() - grpcService, err := client.(encoding.GRPCServiceClientX).TunMultiCustomName(ctx, grpcSettings.getNormalizedName()) + newError("using gRPC multi mode service name: `" + grpcSettings.getServiceName() + "` stream name: `" + grpcSettings.getTunMultiStreamName() + "`").AtDebug().WriteToLog() + grpcService, err := client.(encoding.GRPCServiceClientX).TunMultiCustomName(ctx, grpcSettings.getServiceName(), grpcSettings.getTunMultiStreamName()) if err != nil { return nil, newError("Cannot dial gRPC").Base(err) } return encoding.NewMultiHunkConn(grpcService, nil), nil } - grpcService, err := client.(encoding.GRPCServiceClientX).TunCustomName(ctx, grpcSettings.getNormalizedName()) + newError("using gRPC tun mode service name: `" + grpcSettings.getServiceName() + "` stream name: `" + grpcSettings.getTunStreamName() + "`").AtDebug().WriteToLog() + grpcService, err := client.(encoding.GRPCServiceClientX).TunCustomName(ctx, grpcSettings.getServiceName(), grpcSettings.getTunStreamName()) if err != nil { return nil, newError("Cannot dial gRPC").Base(err) } diff --git a/transport/internet/grpc/encoding/customSeviceName.go b/transport/internet/grpc/encoding/customSeviceName.go index aa098835..dd990755 100644 --- a/transport/internet/grpc/encoding/customSeviceName.go +++ b/transport/internet/grpc/encoding/customSeviceName.go @@ -6,20 +6,20 @@ import ( "google.golang.org/grpc" ) -func ServerDesc(name string) grpc.ServiceDesc { +func ServerDesc(name, tun, tunMulti string) grpc.ServiceDesc { return grpc.ServiceDesc{ ServiceName: name, HandlerType: (*GRPCServiceServer)(nil), Methods: []grpc.MethodDesc{}, Streams: []grpc.StreamDesc{ { - StreamName: "Tun", + StreamName: tun, Handler: _GRPCService_Tun_Handler, ServerStreams: true, ClientStreams: true, }, { - StreamName: "TunMulti", + StreamName: tunMulti, Handler: _GRPCService_TunMulti_Handler, ServerStreams: true, ClientStreams: true, @@ -29,8 +29,8 @@ func ServerDesc(name string) grpc.ServiceDesc { } } -func (c *gRPCServiceClient) TunCustomName(ctx context.Context, name string, opts ...grpc.CallOption) (GRPCService_TunClient, error) { - stream, err := c.cc.NewStream(ctx, &ServerDesc(name).Streams[0], "/"+name+"/Tun", opts...) +func (c *gRPCServiceClient) TunCustomName(ctx context.Context, name, tun string, opts ...grpc.CallOption) (GRPCService_TunClient, error) { + stream, err := c.cc.NewStream(ctx, &ServerDesc(name, tun, "").Streams[0], "/"+name+"/"+tun, opts...) if err != nil { return nil, err } @@ -38,8 +38,8 @@ func (c *gRPCServiceClient) TunCustomName(ctx context.Context, name string, opts return x, nil } -func (c *gRPCServiceClient) TunMultiCustomName(ctx context.Context, name string, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error) { - stream, err := c.cc.NewStream(ctx, &ServerDesc(name).Streams[1], "/"+name+"/TunMulti", opts...) +func (c *gRPCServiceClient) TunMultiCustomName(ctx context.Context, name, tunMulti string, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error) { + stream, err := c.cc.NewStream(ctx, &ServerDesc(name, "", tunMulti).Streams[1], "/"+name+"/"+tunMulti, opts...) if err != nil { return nil, err } @@ -48,13 +48,13 @@ func (c *gRPCServiceClient) TunMultiCustomName(ctx context.Context, name string, } type GRPCServiceClientX interface { - TunCustomName(ctx context.Context, name string, opts ...grpc.CallOption) (GRPCService_TunClient, error) - TunMultiCustomName(ctx context.Context, name string, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error) + TunCustomName(ctx context.Context, name, tun string, opts ...grpc.CallOption) (GRPCService_TunClient, error) + TunMultiCustomName(ctx context.Context, name, tunMulti string, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error) Tun(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunClient, error) TunMulti(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error) } -func RegisterGRPCServiceServerX(s *grpc.Server, srv GRPCServiceServer, name string) { - desc := ServerDesc(name) +func RegisterGRPCServiceServerX(s *grpc.Server, srv GRPCServiceServer, name, tun, tunMulti string) { + desc := ServerDesc(name, tun, tunMulti) s.RegisterService(&desc, srv) } diff --git a/transport/internet/grpc/hub.go b/transport/internet/grpc/hub.go index 9bce2274..d3dd6da5 100644 --- a/transport/internet/grpc/hub.go +++ b/transport/internet/grpc/hub.go @@ -125,7 +125,8 @@ func Listen(ctx context.Context, address net.Address, port net.Port, settings *i } } - encoding.RegisterGRPCServiceServerX(s, listener, grpcSettings.getNormalizedName()) + newError("gRPC listen for service name `" + grpcSettings.getServiceName() + "` tun `" + grpcSettings.getTunStreamName() + "` multi tun `" + grpcSettings.getTunMultiStreamName() + "`").AtDebug().WriteToLog() + encoding.RegisterGRPCServiceServerX(s, listener, grpcSettings.getServiceName(), grpcSettings.getTunStreamName(), grpcSettings.getTunMultiStreamName()) if config := reality.ConfigFromStreamSettings(settings); config != nil { streamListener = goreality.NewListener(streamListener, config.GetREALITYConfig()) From a0d06f3a97e09815aa9268d0ee17a22bb56bea49 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 26 Mar 2023 10:10:27 +0000 Subject: [PATCH 010/867] Add env support to "address", "listen", etc. Usage: `"address": "env:ADDR"`, `"listen": "env:AUDS"`... Just like existing `"port": "env:PORT"` --- infra/conf/common.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/infra/conf/common.go b/infra/conf/common.go index 486e7824..f8f56056 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -45,6 +45,9 @@ func (v *Address) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &rawStr); err != nil { return newError("invalid address: ", string(data)).Base(err) } + if strings.HasPrefix(rawStr, "env:") { + rawStr = os.Getenv(rawStr[4:]) + } v.Address = net.ParseAddress(rawStr) return nil @@ -115,8 +118,7 @@ func parseIntPort(data []byte) (net.Port, error) { func parseStringPort(s string) (net.Port, net.Port, error) { if strings.HasPrefix(s, "env:") { - s = s[4:] - s = os.Getenv(s) + s = os.Getenv(s[4:]) } pair := strings.SplitN(s, "-", 2) From beb603af06137df357550fc99b89b2c88f698271 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 26 Mar 2023 10:57:20 +0000 Subject: [PATCH 011/867] Allow IP address ServerName when "serverName" is not configured In this case, TLS Client Hello will not have SNI (RFC 6066, Section 3) --- transport/internet/reality/reality.go | 4 ++-- transport/internet/tls/config.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index a0a66afa..90580056 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -107,8 +107,8 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati InsecureSkipVerify: true, SessionTicketsDisabled: true, } - if utlsConfig.ServerName == "" && dest.Address.Family().IsDomain() { - utlsConfig.ServerName = dest.Address.Domain() + if utlsConfig.ServerName == "" { + utlsConfig.ServerName = dest.Address.String() } uConn.ServerName = utlsConfig.ServerName fingerprint := tls.GetFingerprint(config.Fingerprint) diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 9c1f8eee..2e2b784a 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -373,8 +373,8 @@ type Option func(*tls.Config) // WithDestination sets the server name in TLS config. func WithDestination(dest net.Destination) Option { return func(config *tls.Config) { - if dest.Address.Family().IsDomain() && config.ServerName == "" { - config.ServerName = dest.Address.Domain() + if config.ServerName == "" { + config.ServerName = dest.Address.String() } } } From f4ab8d7e8b5f433a4ae627679addaffecba79f02 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Mar 2023 03:38:12 +0000 Subject: [PATCH 012/867] Bump github.com/sagernet/sing from 0.2.0 to 0.2.1 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.2.0 to 0.2.1. - [Release notes](https://github.com/sagernet/sing/releases) - [Commits](https://github.com/sagernet/sing/compare/v0.2.0...v0.2.1) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 52aac9af..f4738d47 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.33.0 github.com/refraction-networking/utls v1.3.1 - github.com/sagernet/sing v0.2.0 + github.com/sagernet/sing v0.2.1 github.com/sagernet/sing-shadowsocks v0.2.0 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index d56f19e4..117378ff 100644 --- a/go.sum +++ b/go.sum @@ -141,8 +141,8 @@ github.com/refraction-networking/utls v1.3.1/go.mod h1:kHXvVB66a4BzVRYC4Em7e1HAf github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.0 h1:iyc4TaeXG5XYXixl48zSDDTw46C9NOEAVFq6ZE0dA2k= -github.com/sagernet/sing v0.2.0/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= +github.com/sagernet/sing v0.2.1 h1:r0STYeyfKBBtoAHsBtW1dQonxG+3Qidde7/1VAMhdn8= +github.com/sagernet/sing v0.2.1/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= github.com/sagernet/sing-shadowsocks v0.2.0 h1:ILDWL7pwWfkPLEbviE/MyCgfjaBmJY/JVVY+5jhSb58= github.com/sagernet/sing-shadowsocks v0.2.0/go.mod h1:ysYzszRLpNzJSorvlWRMuzU6Vchsp7sd52q+JNY4axw= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= From a4d1509c236d18c2e74f99b89613a3df20e45053 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 29 Mar 2023 00:59:47 +0000 Subject: [PATCH 013/867] Bump github.com/miekg/dns from 1.1.52 to 1.1.53 Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.52 to 1.1.53. - [Release notes](https://github.com/miekg/dns/releases) - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.52...v1.1.53) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f4738d47..e60d2629 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/golang/protobuf v1.5.3 github.com/google/go-cmp v0.5.9 github.com/gorilla/websocket v1.5.0 - github.com/miekg/dns v1.1.52 + github.com/miekg/dns v1.1.53 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.33.0 diff --git a/go.sum b/go.sum index 117378ff..1b7006a4 100644 --- a/go.sum +++ b/go.sum @@ -106,8 +106,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= -github.com/miekg/dns v1.1.52 h1:Bmlc/qsNNULOe6bpXcUTsuOajd0DzRHwup6D9k1An0c= -github.com/miekg/dns v1.1.52/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= +github.com/miekg/dns v1.1.53 h1:ZBkuHr5dxHtB1caEOlZTLPo7D3L3TWckgUUs/RHfDxw= +github.com/miekg/dns v1.1.53/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= From 2c0a89f7dc64bc34df28dd05686b2f4f84ca33d7 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 31 Mar 2023 22:39:57 +0000 Subject: [PATCH 014/867] REALITY protocol: Set the fourth byte as reserved --- go.mod | 2 +- go.sum | 4 ++-- transport/internet/reality/reality.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index e60d2629..32a245bc 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.2 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e - github.com/xtls/reality v0.0.0-20230320153727-442d33ede91e + github.com/xtls/reality v0.0.0-20230331223127-176a94313eda go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 golang.org/x/crypto v0.7.0 golang.org/x/net v0.8.0 diff --git a/go.sum b/go.sum index 1b7006a4..bf6a63d0 100644 --- a/go.sum +++ b/go.sum @@ -189,8 +189,8 @@ github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/xtls/reality v0.0.0-20230320153727-442d33ede91e h1:mUMY3ndB1zZVic4+EjvTWzm9ghdpbdHZC9RwR0CoFxU= -github.com/xtls/reality v0.0.0-20230320153727-442d33ede91e/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= +github.com/xtls/reality v0.0.0-20230331223127-176a94313eda h1:psRJD2RrZbnI0OWyHvXfgYCPqlRM5q5SPDcjDoDBWhE= +github.com/xtls/reality v0.0.0-20230331223127-176a94313eda/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 h1:Ss6D3hLXTM0KobyBYEAygXzFfGcjnmfEJOBgSbemCtg= diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 90580056..6355687b 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -121,10 +121,10 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati hello := uConn.HandshakeState.Hello hello.SessionId = make([]byte, 32) copy(hello.Raw[39:], hello.SessionId) // the location of session ID - binary.BigEndian.PutUint64(hello.SessionId, uint64(time.Now().Unix())) hello.SessionId[0] = core.Version_x hello.SessionId[1] = core.Version_y hello.SessionId[2] = core.Version_z + binary.BigEndian.PutUint32(hello.SessionId[4:], uint32(time.Now().Unix())) copy(hello.SessionId[8:], config.ShortId) if config.Show { fmt.Printf("REALITY localAddr: %v\thello.SessionId[:16]: %v\n", localAddr, hello.SessionId[:16]) From 67affe3753ffbc24c5c8e257ef1c6a89e74095d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Apr 2023 00:59:34 +0000 Subject: [PATCH 015/867] Bump golang.org/x/sys from 0.6.0 to 0.7.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.6.0 to 0.7.0. - [Release notes](https://github.com/golang/sys/releases) - [Commits](https://github.com/golang/sys/compare/v0.6.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 32a245bc..7d534bac 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( golang.org/x/crypto v0.7.0 golang.org/x/net v0.8.0 golang.org/x/sync v0.1.0 - golang.org/x/sys v0.6.0 + golang.org/x/sys v0.7.0 google.golang.org/grpc v1.54.0 google.golang.org/protobuf v1.30.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c diff --git a/go.sum b/go.sum index bf6a63d0..44f624c3 100644 --- a/go.sum +++ b/go.sum @@ -254,8 +254,8 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From be23d5d3b741268ef86f27dfcb06389e97447e87 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 6 Apr 2023 10:21:35 +0000 Subject: [PATCH 016/867] XUDP protocol: Add Global ID & UoT Migration The first UoT protocol that supports UoT Migration Thank @yuhan6665 for testing --- app/proxyman/config.pb.go | 32 ++++--- app/proxyman/config.proto | 2 + app/proxyman/outbound/handler.go | 7 +- common/mux/client.go | 26 ++---- common/mux/frame.go | 9 ++ common/mux/mux_test.go | 6 +- common/mux/server.go | 100 +++++++++++++++++---- common/mux/session.go | 112 +++++++++++++++++++++--- common/mux/session_test.go | 2 +- common/mux/writer.go | 5 +- common/session/context.go | 16 ++++ common/session/session.go | 2 + common/task/task.go | 12 +++ common/xudp/xudp.go | 67 ++++++++++++-- go.mod | 2 +- infra/conf/xray.go | 25 ++++-- proxy/dns/dns.go | 4 + proxy/dokodemo/dokodemo.go | 1 + proxy/freedom/freedom.go | 17 +++- proxy/http/client.go | 17 +++- proxy/http/server.go | 1 + proxy/shadowsocks/client.go | 17 +++- proxy/shadowsocks/server.go | 1 + proxy/shadowsocks_2022/inbound.go | 3 +- proxy/shadowsocks_2022/inbound_multi.go | 1 + proxy/shadowsocks_2022/inbound_relay.go | 1 + proxy/shadowsocks_2022/outbound.go | 6 +- proxy/socks/client.go | 17 +++- proxy/socks/server.go | 1 + proxy/trojan/client.go | 17 +++- proxy/trojan/server.go | 1 + proxy/vless/inbound/inbound.go | 1 + proxy/vless/outbound/outbound.go | 19 +++- proxy/vmess/inbound/inbound.go | 1 + proxy/vmess/outbound/outbound.go | 19 +++- proxy/wireguard/wireguard.go | 17 +++- transport/pipe/impl.go | 3 + transport/pipe/pipe.go | 1 + transport/pipe/reader.go | 14 +++ 39 files changed, 506 insertions(+), 99 deletions(-) diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index 2dfe2931..03613e88 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -595,6 +595,8 @@ type MultiplexingConfig struct { Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` // Max number of concurrent connections that one Mux connection can handle. Concurrency uint32 `protobuf:"varint,2,opt,name=concurrency,proto3" json:"concurrency,omitempty"` + // Both(0), TCP(1), UDP(2). + Only uint32 `protobuf:"varint,3,opt,name=only,proto3" json:"only,omitempty"` } func (x *MultiplexingConfig) Reset() { @@ -643,6 +645,13 @@ func (x *MultiplexingConfig) GetConcurrency() uint32 { return 0 } +func (x *MultiplexingConfig) GetOnly() uint32 { + if x != nil { + return x.Only + } + return 0 +} + type AllocationStrategy_AllocationStrategyConcurrency struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -856,21 +865,22 @@ var file_app_proxyman_config_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x6d, 0x75, 0x6c, 0x74, 0x69, - 0x70, 0x6c, 0x65, 0x78, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x50, 0x0a, 0x12, + 0x70, 0x6c, 0x65, 0x78, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x64, 0x0a, 0x12, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x2a, 0x23, - 0x0a, 0x0e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, - 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x4c, - 0x53, 0x10, 0x01, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x50, 0x01, 0x5a, 0x26, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, - 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, - 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x0d, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x12, + 0x0a, 0x04, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x6f, 0x6e, + 0x6c, 0x79, 0x2a, 0x23, 0x0a, 0x0e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x6f, 0x6c, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x00, 0x12, 0x07, + 0x0a, 0x03, 0x54, 0x4c, 0x53, 0x10, 0x01, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, + 0x50, 0x01, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, + 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, + 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61, + 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/app/proxyman/config.proto b/app/proxyman/config.proto index 24216d2c..54f63436 100644 --- a/app/proxyman/config.proto +++ b/app/proxyman/config.proto @@ -98,4 +98,6 @@ message MultiplexingConfig { bool enabled = 1; // Max number of concurrent connections that one Mux connection can handle. uint32 concurrency = 2; + // Both(0), TCP(1), UDP(2). + uint32 only = 3; } diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 42554b72..89e2862d 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -111,7 +111,7 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbou return nil, newError("invalid mux concurrency: ", config.Concurrency).AtWarning() } h.mux = &mux.ClientManager{ - Enabled: h.senderSettings.MultiplexSettings.Enabled, + Enabled: config.Enabled, Picker: &mux.IncrementalWorkerPicker{ Factory: &mux.DialingWorkerFactory{ Proxy: proxyHandler, @@ -122,6 +122,7 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbou }, }, }, + Only: config.Only, } } @@ -136,7 +137,9 @@ func (h *Handler) Tag() string { // Dispatch implements proxy.Outbound.Dispatch. func (h *Handler) Dispatch(ctx context.Context, link *transport.Link) { - if h.mux != nil && (h.mux.Enabled || session.MuxPreferedFromContext(ctx)) { + outbound := session.OutboundFromContext(ctx) + if h.mux != nil && (h.mux.Enabled || session.MuxPreferedFromContext(ctx)) && + (h.mux.Only == 0 || (outbound != nil && h.mux.Only == uint32(outbound.Target.Network))) { if err := h.mux.Dispatch(ctx, link); err != nil { err := newError("failed to process mux outbound traffic").Base(err) session.SubmitOutboundErrorToOriginator(ctx, err) diff --git a/common/mux/client.go b/common/mux/client.go index 2019738f..f933ef4c 100644 --- a/common/mux/client.go +++ b/common/mux/client.go @@ -14,6 +14,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/common/xudp" "github.com/xtls/xray-core/proxy" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" @@ -23,6 +24,7 @@ import ( type ClientManager struct { Enabled bool // wheather mux is enabled from user config Picker WorkerPicker + Only uint32 } func (m *ClientManager) Dispatch(ctx context.Context, link *transport.Link) error { @@ -247,22 +249,20 @@ func fetchInput(ctx context.Context, s *Session, output buf.Writer) { transferType = protocol.TransferTypePacket } s.transferType = transferType - writer := NewWriter(s.ID, dest, output, transferType) - defer s.Close() + writer := NewWriter(s.ID, dest, output, transferType, xudp.GetGlobalID(ctx)) + defer s.Close(false) defer writer.Close() newError("dispatching request to ", dest).WriteToLog(session.ExportIDToError(ctx)) if err := writeFirstPayload(s.input, writer); err != nil { newError("failed to write first payload").Base(err).WriteToLog(session.ExportIDToError(ctx)) writer.hasError = true - common.Interrupt(s.input) return } if err := buf.Copy(s.input, writer); err != nil { newError("failed to fetch all input").Base(err).WriteToLog(session.ExportIDToError(ctx)) writer.hasError = true - common.Interrupt(s.input) return } } @@ -335,15 +335,8 @@ func (m *ClientWorker) handleStatusKeep(meta *FrameMetadata, reader *buf.Buffere err := buf.Copy(rr, s.output) if err != nil && buf.IsWriteError(err) { newError("failed to write to downstream. closing session ", s.ID).Base(err).WriteToLog() - - // Notify remote peer to close this session. - closingWriter := NewResponseWriter(meta.SessionID, m.link.Writer, protocol.TransferTypeStream) - closingWriter.Close() - - drainErr := buf.Copy(rr, buf.Discard) - common.Interrupt(s.input) - s.Close() - return drainErr + s.Close(false) + return buf.Copy(rr, buf.Discard) } return err @@ -351,12 +344,7 @@ func (m *ClientWorker) handleStatusKeep(meta *FrameMetadata, reader *buf.Buffere func (m *ClientWorker) handleStatusEnd(meta *FrameMetadata, reader *buf.BufferedReader) error { if s, found := m.sessionManager.Get(meta.SessionID); found { - if meta.Option.Has(OptionError) { - common.Interrupt(s.input) - common.Interrupt(s.output) - } - common.Interrupt(s.input) - s.Close() + s.Close(false) } if meta.Option.Has(OptionData) { return buf.Copy(NewStreamReader(reader), buf.Discard) diff --git a/common/mux/frame.go b/common/mux/frame.go index 30f3c1db..ab57d771 100644 --- a/common/mux/frame.go +++ b/common/mux/frame.go @@ -58,6 +58,7 @@ type FrameMetadata struct { SessionID uint16 Option bitmask.Byte SessionStatus SessionStatus + GlobalID [8]byte } func (f FrameMetadata) WriteTo(b *buf.Buffer) error { @@ -81,6 +82,9 @@ func (f FrameMetadata) WriteTo(b *buf.Buffer) error { if err := addrParser.WriteAddressPort(b, f.Target.Address, f.Target.Port); err != nil { return err } + if b.UDP != nil { + b.Write(f.GlobalID[:]) + } } else if b.UDP != nil { b.WriteByte(byte(TargetNetworkUDP)) addrParser.WriteAddressPort(b, b.UDP.Address, b.UDP.Port) @@ -144,5 +148,10 @@ func (f *FrameMetadata) UnmarshalFromBuffer(b *buf.Buffer) error { } } + if f.SessionStatus == SessionStatusNew && f.Option.Has(OptionData) && + f.Target.Network == net.Network_UDP && b.Len() >= 8 { + copy(f.GlobalID[:], b.Bytes()) + } + return nil } diff --git a/common/mux/mux_test.go b/common/mux/mux_test.go index 39def2ab..f326ffd7 100644 --- a/common/mux/mux_test.go +++ b/common/mux/mux_test.go @@ -32,13 +32,13 @@ func TestReaderWriter(t *testing.T) { pReader, pWriter := pipe.New(pipe.WithSizeLimit(1024)) dest := net.TCPDestination(net.DomainAddress("example.com"), 80) - writer := NewWriter(1, dest, pWriter, protocol.TransferTypeStream) + writer := NewWriter(1, dest, pWriter, protocol.TransferTypeStream, [8]byte{}) dest2 := net.TCPDestination(net.LocalHostIP, 443) - writer2 := NewWriter(2, dest2, pWriter, protocol.TransferTypeStream) + writer2 := NewWriter(2, dest2, pWriter, protocol.TransferTypeStream, [8]byte{}) dest3 := net.TCPDestination(net.LocalHostIPv6, 18374) - writer3 := NewWriter(3, dest3, pWriter, protocol.TransferTypeStream) + writer3 := NewWriter(3, dest3, pWriter, protocol.TransferTypeStream, [8]byte{}) writePayload := func(writer *Writer, payload ...byte) error { b := buf.New() diff --git a/common/mux/server.go b/common/mux/server.go index df461be7..e64e038f 100644 --- a/common/mux/server.go +++ b/common/mux/server.go @@ -2,6 +2,7 @@ package mux import ( "context" + "fmt" "io" "github.com/xtls/xray-core/common" @@ -11,6 +12,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/xudp" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport" @@ -99,7 +101,7 @@ func handle(ctx context.Context, s *Session, output buf.Writer) { } writer.Close() - s.Close() + s.Close(false) } func (w *ServerWorker) ActiveConnections() uint32 { @@ -131,6 +133,81 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, } ctx = log.ContextWithAccessMessage(ctx, msg) } + + if meta.GlobalID != [8]byte{} { + mb, err := NewPacketReader(reader, &meta.Target).ReadMultiBuffer() + if err != nil { + return err + } + XUDPManager.Lock() + x := XUDPManager.Map[meta.GlobalID] + if x == nil { + x = &XUDP{GlobalID: meta.GlobalID} + XUDPManager.Map[meta.GlobalID] = x + XUDPManager.Unlock() + } else { + if x.Status == Initializing { // nearly impossible + XUDPManager.Unlock() + if xudp.Show { + fmt.Printf("XUDP hit: %v err: conflict\n", meta.GlobalID) + } + // It's not a good idea to return an err here, so just let client wait. + // Client will receive an End frame after sending a Keep frame. + return nil + } + x.Status = Initializing + XUDPManager.Unlock() + x.Mux.Close(false) // detach from previous Mux + b := buf.New() + b.Write(mb[0].Bytes()) + b.UDP = mb[0].UDP + if err = x.Mux.output.WriteMultiBuffer(mb); err != nil { + x.Interrupt() + mb = buf.MultiBuffer{b} + } else { + b.Release() + mb = nil + } + if xudp.Show { + fmt.Printf("XUDP hit: %v err: %v\n", meta.GlobalID, err) + } + } + if mb != nil { + ctx = session.ContextWithTimeoutOnly(ctx, true) + // Actually, it won't return an error in Xray-core's implementations. + link, err := w.dispatcher.Dispatch(ctx, meta.Target) + if err != nil { + err = newError("failed to dispatch request to ", meta.Target).Base(err) + if xudp.Show { + fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err) + } + return err // it will break the whole Mux connection + } + link.Writer.WriteMultiBuffer(mb) // it's meaningless to test a new pipe + x.Mux = &Session{ + input: link.Reader, + output: link.Writer, + } + if xudp.Show { + fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err) + } + } + x.Mux = &Session{ + input: x.Mux.input, + output: x.Mux.output, + parent: w.sessionManager, + ID: meta.SessionID, + transferType: protocol.TransferTypePacket, + XUDP: x, + } + go handle(ctx, x.Mux, w.link.Writer) + x.Status = Active + if !w.sessionManager.Add(x.Mux) { + x.Mux.Close(false) + } + return nil + } + link, err := w.dispatcher.Dispatch(ctx, meta.Target) if err != nil { if meta.Option.Has(OptionData) { @@ -157,8 +234,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, rr := s.NewReader(reader, &meta.Target) if err := buf.Copy(rr, s.output); err != nil { buf.Copy(rr, buf.Discard) - common.Interrupt(s.input) - return s.Close() + return s.Close(false) } return nil } @@ -182,15 +258,8 @@ func (w *ServerWorker) handleStatusKeep(meta *FrameMetadata, reader *buf.Buffere if err != nil && buf.IsWriteError(err) { newError("failed to write to downstream writer. closing session ", s.ID).Base(err).WriteToLog() - - // Notify remote peer to close this session. - closingWriter := NewResponseWriter(meta.SessionID, w.link.Writer, protocol.TransferTypeStream) - closingWriter.Close() - - drainErr := buf.Copy(rr, buf.Discard) - common.Interrupt(s.input) - s.Close() - return drainErr + s.Close(false) + return buf.Copy(rr, buf.Discard) } return err @@ -198,12 +267,7 @@ func (w *ServerWorker) handleStatusKeep(meta *FrameMetadata, reader *buf.Buffere func (w *ServerWorker) handleStatusEnd(meta *FrameMetadata, reader *buf.BufferedReader) error { if s, found := w.sessionManager.Get(meta.SessionID); found { - if meta.Option.Has(OptionError) { - common.Interrupt(s.input) - common.Interrupt(s.output) - } - common.Interrupt(s.input) - s.Close() + s.Close(false) } if meta.Option.Has(OptionData) { return buf.Copy(NewStreamReader(reader), buf.Discard) diff --git a/common/mux/session.go b/common/mux/session.go index 2f21b97a..650e3545 100644 --- a/common/mux/session.go +++ b/common/mux/session.go @@ -1,12 +1,18 @@ package mux import ( + "fmt" + "io" + "runtime" "sync" + "time" "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" + "github.com/xtls/xray-core/common/xudp" + "github.com/xtls/xray-core/transport/pipe" ) type SessionManager struct { @@ -61,21 +67,25 @@ func (m *SessionManager) Allocate() *Session { return s } -func (m *SessionManager) Add(s *Session) { +func (m *SessionManager) Add(s *Session) bool { m.Lock() defer m.Unlock() if m.closed { - return + return false } m.count++ m.sessions[s.ID] = s + return true } -func (m *SessionManager) Remove(id uint16) { - m.Lock() - defer m.Unlock() +func (m *SessionManager) Remove(locked bool, id uint16) { + if !locked { + m.Lock() + defer m.Unlock() + } + locked = true if m.closed { return @@ -83,9 +93,11 @@ func (m *SessionManager) Remove(id uint16) { delete(m.sessions, id) - if len(m.sessions) == 0 { - m.sessions = make(map[uint16]*Session, 16) - } + /* + if len(m.sessions) == 0 { + m.sessions = make(map[uint16]*Session, 16) + } + */ } func (m *SessionManager) Get(id uint16) (*Session, bool) { @@ -127,8 +139,7 @@ func (m *SessionManager) Close() error { m.closed = true for _, s := range m.sessions { - common.Close(s.input) - common.Close(s.output) + s.Close(true) } m.sessions = nil @@ -142,13 +153,42 @@ type Session struct { parent *SessionManager ID uint16 transferType protocol.TransferType + closed bool + XUDP *XUDP } // Close closes all resources associated with this session. -func (s *Session) Close() error { - common.Close(s.output) - common.Close(s.input) - s.parent.Remove(s.ID) +func (s *Session) Close(locked bool) error { + if !locked { + s.parent.Lock() + defer s.parent.Unlock() + } + locked = true + if s.closed { + return nil + } + s.closed = true + if s.XUDP == nil { + common.Interrupt(s.input) + common.Close(s.output) + } else { + // Stop existing handle(), then trigger writer.Close(). + // Note that s.output may be dispatcher.SizeStatWriter. + s.input.(*pipe.Reader).ReturnAnError(io.EOF) + runtime.Gosched() + // If the error set by ReturnAnError still exists, clear it. + s.input.(*pipe.Reader).Recover() + XUDPManager.Lock() + if s.XUDP.Status == Active { + s.XUDP.Expire = time.Now().Add(time.Minute) + s.XUDP.Status = Expiring + if xudp.Show { + fmt.Printf("XUDP put: %v\n", s.XUDP.GlobalID) + } + } + XUDPManager.Unlock() + } + s.parent.Remove(locked, s.ID) return nil } @@ -159,3 +199,47 @@ func (s *Session) NewReader(reader *buf.BufferedReader, dest *net.Destination) b } return NewPacketReader(reader, dest) } + +const ( + Initializing = 0 + Active = 1 + Expiring = 2 +) + +type XUDP struct { + GlobalID [8]byte + Status uint64 + Expire time.Time + Mux *Session +} + +func (x *XUDP) Interrupt() { + common.Interrupt(x.Mux.input) + common.Close(x.Mux.output) +} + +var XUDPManager struct { + sync.Mutex + Map map[[8]byte]*XUDP +} + +func init() { + XUDPManager.Map = make(map[[8]byte]*XUDP) + go func() { + for { + time.Sleep(time.Minute) + now := time.Now() + XUDPManager.Lock() + for id, x := range XUDPManager.Map { + if x.Status == Expiring && now.After(x.Expire) { + x.Interrupt() + delete(XUDPManager.Map, id) + if xudp.Show { + fmt.Printf("XUDP del: %v\n", id) + } + } + } + XUDPManager.Unlock() + } + }() +} diff --git a/common/mux/session_test.go b/common/mux/session_test.go index 7139df10..d81ad8c4 100644 --- a/common/mux/session_test.go +++ b/common/mux/session_test.go @@ -44,7 +44,7 @@ func TestSessionManagerClose(t *testing.T) { if m.CloseIfNoSession() { t.Error("able to close") } - m.Remove(s.ID) + m.Remove(false, s.ID) if !m.CloseIfNoSession() { t.Error("not able to close") } diff --git a/common/mux/writer.go b/common/mux/writer.go index f7a22b2d..a6dc551d 100644 --- a/common/mux/writer.go +++ b/common/mux/writer.go @@ -15,15 +15,17 @@ type Writer struct { followup bool hasError bool transferType protocol.TransferType + globalID [8]byte } -func NewWriter(id uint16, dest net.Destination, writer buf.Writer, transferType protocol.TransferType) *Writer { +func NewWriter(id uint16, dest net.Destination, writer buf.Writer, transferType protocol.TransferType, globalID [8]byte) *Writer { return &Writer{ id: id, dest: dest, writer: writer, followup: false, transferType: transferType, + globalID: globalID, } } @@ -40,6 +42,7 @@ func (w *Writer) getNextFrameMeta() FrameMetadata { meta := FrameMetadata{ SessionID: w.id, Target: w.dest, + GlobalID: w.globalID, } if w.followup { diff --git a/common/session/context.go b/common/session/context.go index 2959807e..71e4b154 100644 --- a/common/session/context.go +++ b/common/session/context.go @@ -2,10 +2,14 @@ package session import ( "context" + _ "unsafe" "github.com/xtls/xray-core/features/routing" ) +//go:linkname IndependentCancelCtx context.newCancelCtx +func IndependentCancelCtx(parent context.Context) context.Context + type sessionKey int const ( @@ -17,6 +21,7 @@ const ( sockoptSessionKey trackedConnectionErrorKey dispatcherKey + timeoutOnlyKey ) // ContextWithID returns a new context with the given ID. @@ -131,3 +136,14 @@ func DispatcherFromContext(ctx context.Context) routing.Dispatcher { } return nil } + +func ContextWithTimeoutOnly(ctx context.Context, only bool) context.Context { + return context.WithValue(ctx, timeoutOnlyKey, only) +} + +func TimeoutOnlyFromContext(ctx context.Context) bool { + if val, ok := ctx.Value(timeoutOnlyKey).(bool); ok { + return val + } + return false +} diff --git a/common/session/session.go b/common/session/session.go index 656a2404..83c48fde 100644 --- a/common/session/session.go +++ b/common/session/session.go @@ -42,6 +42,8 @@ type Inbound struct { Gateway net.Destination // Tag of the inbound proxy that handles the connection. Tag string + // Name of the inbound proxy that handles the connection. + Name string // User is the user that authencates for the inbound. May be nil if the protocol allows anounymous traffic. User *protocol.MemoryUser // Conn is actually internet.Connection. May be nil. diff --git a/common/task/task.go b/common/task/task.go index 52b0d44b..eeba1dcd 100644 --- a/common/task/task.go +++ b/common/task/task.go @@ -38,6 +38,12 @@ func Run(ctx context.Context, tasks ...func() error) error { }(task) } + /* + if altctx := ctx.Value("altctx"); altctx != nil { + ctx = altctx.(context.Context) + } + */ + for i := 0; i < n; i++ { select { case err := <-done: @@ -48,5 +54,11 @@ func Run(ctx context.Context, tasks ...func() error) error { } } + /* + if cancel := ctx.Value("cancel"); cancel != nil { + cancel.(context.CancelFunc)() + } + */ + return nil } diff --git a/common/xudp/xudp.go b/common/xudp/xudp.go index 80a35e41..65096d16 100644 --- a/common/xudp/xudp.go +++ b/common/xudp/xudp.go @@ -1,30 +1,76 @@ package xudp import ( + "context" + "crypto/rand" + "encoding/base64" + "fmt" "io" + "os" + "strings" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" + "github.com/xtls/xray-core/common/session" + "lukechampine.com/blake3" ) -var addrParser = protocol.NewAddressParser( +var AddrParser = protocol.NewAddressParser( protocol.AddressFamilyByte(byte(protocol.AddressTypeIPv4), net.AddressFamilyIPv4), protocol.AddressFamilyByte(byte(protocol.AddressTypeDomain), net.AddressFamilyDomain), protocol.AddressFamilyByte(byte(protocol.AddressTypeIPv6), net.AddressFamilyIPv6), protocol.PortThenAddress(), ) -func NewPacketWriter(writer buf.Writer, dest net.Destination) *PacketWriter { +var ( + Show bool + BaseKey [32]byte +) + +const ( + EnvShow = "XRAY_XUDP_SHOW" + EnvBaseKey = "XRAY_XUDP_BASEKEY" +) + +func init() { + if strings.ToLower(os.Getenv(EnvShow)) == "true" { + Show = true + } + if raw := os.Getenv(EnvBaseKey); raw != "" { + if key, _ := base64.RawURLEncoding.DecodeString(raw); len(key) == len(BaseKey) { + copy(BaseKey[:], key) + return + } else { + panic(EnvBaseKey + ": invalid value: " + raw) + } + } + rand.Read(BaseKey[:]) +} + +func GetGlobalID(ctx context.Context) (globalID [8]byte) { + if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Source.Network == net.Network_UDP && + (inbound.Name == "dokodemo-door" || inbound.Name == "socks" || inbound.Name == "shadowsocks") { + h := blake3.New(8, BaseKey[:]) + h.Write([]byte(inbound.Source.String())) + copy(globalID[:], h.Sum(nil)) + fmt.Printf("XUDP inbound.Source.String(): %v\tglobalID: %v\n", inbound.Source.String(), globalID) + } + return +} + +func NewPacketWriter(writer buf.Writer, dest net.Destination, globalID [8]byte) *PacketWriter { return &PacketWriter{ - Writer: writer, - Dest: dest, + Writer: writer, + Dest: dest, + GlobalID: globalID, } } type PacketWriter struct { - Writer buf.Writer - Dest net.Destination + Writer buf.Writer + Dest net.Destination + GlobalID [8]byte } func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { @@ -42,14 +88,17 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { eb.WriteByte(1) // New eb.WriteByte(1) // Opt eb.WriteByte(2) // UDP - addrParser.WriteAddressPort(eb, w.Dest.Address, w.Dest.Port) + AddrParser.WriteAddressPort(eb, w.Dest.Address, w.Dest.Port) + if b.UDP != nil { // make sure it's user's proxy request + eb.Write(w.GlobalID[:]) + } w.Dest.Network = net.Network_Unknown } else { eb.WriteByte(2) // Keep eb.WriteByte(1) if b.UDP != nil { eb.WriteByte(2) - addrParser.WriteAddressPort(eb, b.UDP.Address, b.UDP.Port) + AddrParser.WriteAddressPort(eb, b.UDP.Address, b.UDP.Port) } } l := eb.Len() - 2 @@ -98,7 +147,7 @@ func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) { case 2: if l != 4 { b.Advance(5) - addr, port, err := addrParser.ReadAddressPort(nil, b) + addr, port, err := AddrParser.ReadAddressPort(nil, b) if err != nil { b.Release() return nil, err diff --git a/go.mod b/go.mod index 7d534bac..76d7c0d7 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( google.golang.org/protobuf v1.30.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h12.io/socks v1.0.3 + lukechampine.com/blake3 v1.1.7 ) require ( @@ -55,5 +56,4 @@ require ( google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - lukechampine.com/blake3 v1.1.7 // indirect ) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 949e5534..2306e380 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -10,6 +10,7 @@ import ( "github.com/xtls/xray-core/app/dispatcher" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/app/stats" + "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/serial" core "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/transport/internet" @@ -107,8 +108,9 @@ func (c *SniffingConfig) Build() (*proxyman.SniffingConfig, error) { } type MuxConfig struct { - Enabled bool `json:"enabled"` - Concurrency int16 `json:"concurrency"` + Enabled bool `json:"enabled"` + Concurrency int16 `json:"concurrency"` + Only string `json:"only"` } // Build creates MultiplexingConfig, Concurrency < 0 completely disables mux. @@ -116,16 +118,23 @@ func (m *MuxConfig) Build() *proxyman.MultiplexingConfig { if m.Concurrency < 0 { return nil } - - var con uint32 = 8 - if m.Concurrency > 0 { - con = uint32(m.Concurrency) + if m.Concurrency == 0 { + m.Concurrency = 8 } - return &proxyman.MultiplexingConfig{ + config := &proxyman.MultiplexingConfig{ Enabled: m.Enabled, - Concurrency: con, + Concurrency: uint32(m.Concurrency), } + + switch strings.ToLower(m.Only) { + case "tcp": + config.Only = uint32(net.Network_TCP) + case "udp": + config.Only = uint32(net.Network_UDP) + } + + return config } type InboundDetourAllocationConfig struct { diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index ae123c28..be05e4f7 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -148,6 +148,10 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet. } } + if session.TimeoutOnlyFromContext(ctx) { + ctx, _ = context.WithCancel(context.Background()) + } + ctx, cancel := context.WithCancel(ctx) timer := signal.CancelAfterInactivity(ctx, cancel, h.timeout) diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index d0fb69f9..42d8256f 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -103,6 +103,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st inbound := session.InboundFromContext(ctx) if inbound != nil { + inbound.Name = "dokodemo-door" inbound.User = &protocol.MemoryUser{ Level: d.config.UserLevel, } diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 15ebc22b..8630ab9c 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -149,9 +149,20 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } defer conn.Close() + var newCtx context.Context + var newCancel context.CancelFunc + if session.TimeoutOnlyFromContext(ctx) { + newCtx, newCancel = context.WithCancel(context.Background()) + } + plcy := h.policy() ctx, cancel := context.WithCancel(ctx) - timer := signal.CancelAfterInactivity(ctx, cancel, plcy.Timeouts.ConnectionIdle) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + if newCancel != nil { + newCancel() + } + }, plcy.Timeouts.ConnectionIdle) requestDone := func() error { defer timer.SetTimeout(plcy.Timeouts.DownlinkOnly) @@ -186,6 +197,10 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte return nil } + if newCtx != nil { + ctx = newCtx + } + if err := task.Run(ctx, requestDone, task.OnSuccess(responseDone, task.Close(output))); err != nil { return newError("connection ends").Base(err) } diff --git a/proxy/http/client.go b/proxy/http/client.go index 71a10e69..b1661011 100644 --- a/proxy/http/client.go +++ b/proxy/http/client.go @@ -128,8 +128,19 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter p = c.policyManager.ForLevel(user.Level) } + var newCtx context.Context + var newCancel context.CancelFunc + if session.TimeoutOnlyFromContext(ctx) { + newCtx, newCancel = context.WithCancel(context.Background()) + } + ctx, cancel := context.WithCancel(ctx) - timer := signal.CancelAfterInactivity(ctx, cancel, p.Timeouts.ConnectionIdle) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + if newCancel != nil { + newCancel() + } + }, p.Timeouts.ConnectionIdle) requestFunc := func() error { defer timer.SetTimeout(p.Timeouts.DownlinkOnly) @@ -140,6 +151,10 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter return buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer)) } + if newCtx != nil { + ctx = newCtx + } + responseDonePost := task.OnSuccess(responseFunc, task.Close(link.Writer)) if err := task.Run(ctx, requestFunc, responseDonePost); err != nil { return newError("connection ends").Base(err) diff --git a/proxy/http/server.go b/proxy/http/server.go index cdcf2e3a..6b00fe2b 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -85,6 +85,7 @@ type readerOnly struct { func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error { inbound := session.InboundFromContext(ctx) if inbound != nil { + inbound.Name = "http" inbound.User = &protocol.MemoryUser{ Level: s.config.UserLevel, } diff --git a/proxy/shadowsocks/client.go b/proxy/shadowsocks/client.go index 2d8a4e81..e22b11c7 100644 --- a/proxy/shadowsocks/client.go +++ b/proxy/shadowsocks/client.go @@ -96,9 +96,24 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter } request.User = user + var newCtx context.Context + var newCancel context.CancelFunc + if session.TimeoutOnlyFromContext(ctx) { + newCtx, newCancel = context.WithCancel(context.Background()) + } + sessionPolicy := c.policyManager.ForLevel(user.Level) ctx, cancel := context.WithCancel(ctx) - timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + if newCancel != nil { + newCancel() + } + }, sessionPolicy.Timeouts.ConnectionIdle) + + if newCtx != nil { + ctx = newCtx + } if request.Command == protocol.RequestCommandTCP { requestDone := func() error { diff --git a/proxy/shadowsocks/server.go b/proxy/shadowsocks/server.go index 140c6704..1d89db5e 100644 --- a/proxy/shadowsocks/server.go +++ b/proxy/shadowsocks/server.go @@ -113,6 +113,7 @@ func (s *Server) handleUDPPayload(ctx context.Context, conn stat.Connection, dis if inbound == nil { panic("no inbound metadata") } + inbound.Name = "shadowsocks" var dest *net.Destination diff --git a/proxy/shadowsocks_2022/inbound.go b/proxy/shadowsocks_2022/inbound.go index 550aadd1..1c2ae1d2 100644 --- a/proxy/shadowsocks_2022/inbound.go +++ b/proxy/shadowsocks_2022/inbound.go @@ -3,7 +3,7 @@ package shadowsocks_2022 import ( "context" - "github.com/sagernet/sing-shadowsocks" + shadowsocks "github.com/sagernet/sing-shadowsocks" "github.com/sagernet/sing-shadowsocks/shadowaead_2022" C "github.com/sagernet/sing/common" B "github.com/sagernet/sing/common/buf" @@ -64,6 +64,7 @@ func (i *Inbound) Network() []net.Network { func (i *Inbound) Process(ctx context.Context, network net.Network, connection stat.Connection, dispatcher routing.Dispatcher) error { inbound := session.InboundFromContext(ctx) + inbound.Name = "shadowsocks-2022" var metadata M.Metadata if inbound.Source.IsValid() { diff --git a/proxy/shadowsocks_2022/inbound_multi.go b/proxy/shadowsocks_2022/inbound_multi.go index 695de8e2..77a34427 100644 --- a/proxy/shadowsocks_2022/inbound_multi.go +++ b/proxy/shadowsocks_2022/inbound_multi.go @@ -153,6 +153,7 @@ func (i *MultiUserInbound) Network() []net.Network { func (i *MultiUserInbound) Process(ctx context.Context, network net.Network, connection stat.Connection, dispatcher routing.Dispatcher) error { inbound := session.InboundFromContext(ctx) + inbound.Name = "shadowsocks-2022-multi" var metadata M.Metadata if inbound.Source.IsValid() { diff --git a/proxy/shadowsocks_2022/inbound_relay.go b/proxy/shadowsocks_2022/inbound_relay.go index 3e0043ee..d07babb8 100644 --- a/proxy/shadowsocks_2022/inbound_relay.go +++ b/proxy/shadowsocks_2022/inbound_relay.go @@ -85,6 +85,7 @@ func (i *RelayInbound) Network() []net.Network { func (i *RelayInbound) Process(ctx context.Context, network net.Network, connection stat.Connection, dispatcher routing.Dispatcher) error { inbound := session.InboundFromContext(ctx) + inbound.Name = "shadowsocks-2022-relay" var metadata M.Metadata if inbound.Source.IsValid() { diff --git a/proxy/shadowsocks_2022/outbound.go b/proxy/shadowsocks_2022/outbound.go index eb38c017..41e239dc 100644 --- a/proxy/shadowsocks_2022/outbound.go +++ b/proxy/shadowsocks_2022/outbound.go @@ -6,7 +6,7 @@ import ( "runtime" "time" - "github.com/sagernet/sing-shadowsocks" + shadowsocks "github.com/sagernet/sing-shadowsocks" "github.com/sagernet/sing-shadowsocks/shadowaead_2022" C "github.com/sagernet/sing/common" B "github.com/sagernet/sing/common/buf" @@ -88,6 +88,10 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int return newError("failed to connect to server").Base(err) } + if session.TimeoutOnlyFromContext(ctx) { + ctx, _ = context.WithCancel(context.Background()) + } + if network == net.Network_TCP { serverConn := o.method.DialEarlyConn(connection, toSocksaddr(destination)) var handshake bool diff --git a/proxy/socks/client.go b/proxy/socks/client.go index f1690bec..1993aa0b 100644 --- a/proxy/socks/client.go +++ b/proxy/socks/client.go @@ -151,8 +151,19 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter newError("failed to clear deadline after handshake").Base(err).WriteToLog(session.ExportIDToError(ctx)) } + var newCtx context.Context + var newCancel context.CancelFunc + if session.TimeoutOnlyFromContext(ctx) { + newCtx, newCancel = context.WithCancel(context.Background()) + } + ctx, cancel := context.WithCancel(ctx) - timer := signal.CancelAfterInactivity(ctx, cancel, p.Timeouts.ConnectionIdle) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + if newCancel != nil { + newCancel() + } + }, p.Timeouts.ConnectionIdle) var requestFunc func() error var responseFunc func() error @@ -183,6 +194,10 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter } } + if newCtx != nil { + ctx = newCtx + } + responseDonePost := task.OnSuccess(responseFunc, task.Close(link.Writer)) if err := task.Run(ctx, requestFunc, responseDonePost); err != nil { return newError("connection ends").Base(err) diff --git a/proxy/socks/server.go b/proxy/socks/server.go index ce15163c..184ecd08 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -64,6 +64,7 @@ func (s *Server) Network() []net.Network { // Process implements proxy.Inbound. func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error { if inbound := session.InboundFromContext(ctx); inbound != nil { + inbound.Name = "socks" inbound.User = &protocol.MemoryUser{ Level: s.config.UserLevel, } diff --git a/proxy/trojan/client.go b/proxy/trojan/client.go index ffd10359..2605239d 100644 --- a/proxy/trojan/client.go +++ b/proxy/trojan/client.go @@ -93,9 +93,20 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter Flow: account.Flow, } + var newCtx context.Context + var newCancel context.CancelFunc + if session.TimeoutOnlyFromContext(ctx) { + newCtx, newCancel = context.WithCancel(context.Background()) + } + sessionPolicy := c.policyManager.ForLevel(user.Level) ctx, cancel := context.WithCancel(ctx) - timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + if newCancel != nil { + newCancel() + } + }, sessionPolicy.Timeouts.ConnectionIdle) postRequest := func() error { defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly) @@ -149,6 +160,10 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter return buf.Copy(reader, link.Writer, buf.UpdateActivity(timer)) } + if newCtx != nil { + ctx = newCtx + } + responseDoneAndCloseWriter := task.OnSuccess(getResponse, task.Close(link.Writer)) if err := task.Run(ctx, postRequest, responseDoneAndCloseWriter); err != nil { return newError("connection ends").Base(err) diff --git a/proxy/trojan/server.go b/proxy/trojan/server.go index 029d4eff..368374ff 100644 --- a/proxy/trojan/server.go +++ b/proxy/trojan/server.go @@ -217,6 +217,7 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con if inbound == nil { panic("no inbound metadata") } + inbound.Name = "trojan" inbound.User = user sessionPolicy = s.policyManager.ForLevel(user.Level) diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index b3def4bb..c8a69444 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -438,6 +438,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s if inbound == nil { panic("no inbound metadata") } + inbound.Name = "vless" inbound.User = request.User account := request.User.Account.(*vless.MemoryAccount) diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index b7bc6964..cb2a1b76 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -170,9 +170,20 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } } + var newCtx context.Context + var newCancel context.CancelFunc + if session.TimeoutOnlyFromContext(ctx) { + newCtx, newCancel = context.WithCancel(context.Background()) + } + sessionPolicy := h.policyManager.ForLevel(request.User.Level) ctx, cancel := context.WithCancel(ctx) - timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + if newCancel != nil { + newCancel() + } + }, sessionPolicy.Timeouts.ConnectionIdle) clientReader := link.Reader // .(*pipe.Reader) clientWriter := link.Writer // .(*pipe.Writer) @@ -200,7 +211,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte // default: serverWriter := bufferWriter serverWriter := encoding.EncodeBodyAddons(bufferWriter, request, requestAddons) if request.Command == protocol.RequestCommandMux && request.Port == 666 { - serverWriter = xudp.NewPacketWriter(serverWriter, target) + serverWriter = xudp.NewPacketWriter(serverWriter, target, xudp.GetGlobalID(ctx)) } userUUID := account.ID.Bytes() timeoutReader, ok := clientReader.(buf.TimeoutReader) @@ -300,6 +311,10 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte return nil } + if newCtx != nil { + ctx = newCtx + } + if err := task.Run(ctx, postRequest, task.OnSuccess(getResponse, task.Close(clientWriter))); err != nil { return newError("connection ends").Base(err).AtInfo() } diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index 00b07f14..eb24a6c6 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -287,6 +287,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s if inbound == nil { panic("no inbound metadata") } + inbound.Name = "vmess" inbound.User = request.User sessionPolicy = h.policyManager.ForLevel(request.User.Level) diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index e7c6466e..64c29225 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -138,11 +138,22 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte behaviorSeed := crc64.Checksum(hashkdf.Sum(nil), crc64.MakeTable(crc64.ISO)) + var newCtx context.Context + var newCancel context.CancelFunc + if session.TimeoutOnlyFromContext(ctx) { + newCtx, newCancel = context.WithCancel(context.Background()) + } + session := encoding.NewClientSession(ctx, isAEAD, protocol.DefaultIDHash, int64(behaviorSeed)) sessionPolicy := h.policyManager.ForLevel(request.User.Level) ctx, cancel := context.WithCancel(ctx) - timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + if newCancel != nil { + newCancel() + } + }, sessionPolicy.Timeouts.ConnectionIdle) if request.Command == protocol.RequestCommandUDP && h.cone && request.Port != 53 && request.Port != 443 { request.Command = protocol.RequestCommandMux @@ -164,7 +175,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } bodyWriter2 := bodyWriter if request.Command == protocol.RequestCommandMux && request.Port == 666 { - bodyWriter = xudp.NewPacketWriter(bodyWriter, target) + bodyWriter = xudp.NewPacketWriter(bodyWriter, target, xudp.GetGlobalID(ctx)) } if err := buf.CopyOnceTimeout(input, bodyWriter, time.Millisecond*100); err != nil && err != buf.ErrNotTimeoutReader && err != buf.ErrReadTimeout { return newError("failed to write first payload").Base(err) @@ -208,6 +219,10 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte return buf.Copy(bodyReader, output, buf.UpdateActivity(timer)) } + if newCtx != nil { + ctx = newCtx + } + responseDonePost := task.OnSuccess(responseDone, task.Close(output)) if err := task.Run(ctx, requestDone, responseDonePost); err != nil { return newError("connection ends").Base(err) diff --git a/proxy/wireguard/wireguard.go b/proxy/wireguard/wireguard.go index 2b7e1c87..0d4994f5 100644 --- a/proxy/wireguard/wireguard.go +++ b/proxy/wireguard/wireguard.go @@ -127,10 +127,21 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte addr = net.IPAddress(ips[0]) } + var newCtx context.Context + var newCancel context.CancelFunc + if session.TimeoutOnlyFromContext(ctx) { + newCtx, newCancel = context.WithCancel(context.Background()) + } + p := h.policyManager.ForLevel(0) ctx, cancel := context.WithCancel(ctx) - timer := signal.CancelAfterInactivity(ctx, cancel, p.Timeouts.ConnectionIdle) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + if newCancel != nil { + newCancel() + } + }, p.Timeouts.ConnectionIdle) addrPort := netip.AddrPortFrom(toNetIpAddr(addr), destination.Port.Value()) var requestFunc func() error @@ -166,6 +177,10 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } } + if newCtx != nil { + ctx = newCtx + } + responseDonePost := task.OnSuccess(responseFunc, task.Close(link.Writer)) if err := task.Run(ctx, requestFunc, responseDonePost); err != nil { return newError("connection ends").Base(err) diff --git a/transport/pipe/impl.go b/transport/pipe/impl.go index 14a18e63..a60bc485 100644 --- a/transport/pipe/impl.go +++ b/transport/pipe/impl.go @@ -37,6 +37,7 @@ type pipe struct { readSignal *signal.Notifier writeSignal *signal.Notifier done *done.Instance + errChan chan error option pipeOption state state } @@ -92,6 +93,8 @@ func (p *pipe) ReadMultiBuffer() (buf.MultiBuffer, error) { select { case <-p.readSignal.Wait(): case <-p.done.Wait(): + case err = <-p.errChan: + return nil, err } } } diff --git a/transport/pipe/pipe.go b/transport/pipe/pipe.go index 0b22c2db..735cc091 100644 --- a/transport/pipe/pipe.go +++ b/transport/pipe/pipe.go @@ -59,6 +59,7 @@ func New(opts ...Option) (*Reader, *Writer) { readSignal: signal.NewNotifier(), writeSignal: signal.NewNotifier(), done: done.New(), + errChan: make(chan error, 1), option: pipeOption{ limit: -1, }, diff --git a/transport/pipe/reader.go b/transport/pipe/reader.go index 66733436..79f0ac03 100644 --- a/transport/pipe/reader.go +++ b/transport/pipe/reader.go @@ -25,3 +25,17 @@ func (r *Reader) ReadMultiBufferTimeout(d time.Duration) (buf.MultiBuffer, error func (r *Reader) Interrupt() { r.pipe.Interrupt() } + +// ReturnAnError makes ReadMultiBuffer return an error, only once. +func (r *Reader) ReturnAnError(err error) { + r.pipe.errChan <- err +} + +// Recover catches an error set by ReturnAnError, if exists. +func (r *Reader) Recover() (err error) { + select { + case err = <-r.pipe.errChan: + default: + } + return +} From 54ad0e96a0d4728c45f7101bebf5b568ab1974de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Apr 2023 00:59:29 +0000 Subject: [PATCH 017/867] Bump golang.org/x/net from 0.8.0 to 0.9.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.8.0 to 0.9.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](https://github.com/golang/net/compare/v0.8.0...v0.9.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 76d7c0d7..fa91017b 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/xtls/reality v0.0.0-20230331223127-176a94313eda go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 golang.org/x/crypto v0.7.0 - golang.org/x/net v0.8.0 + golang.org/x/net v0.9.0 golang.org/x/sync v0.1.0 golang.org/x/sys v0.7.0 google.golang.org/grpc v1.54.0 @@ -50,7 +50,7 @@ require ( go.uber.org/atomic v1.10.0 // indirect golang.org/x/exp v0.0.0-20230307190834-24139beb5833 // indirect golang.org/x/mod v0.9.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/text v0.9.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.7.0 // indirect google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect diff --git a/go.sum b/go.sum index 44f624c3..a49be94a 100644 --- a/go.sum +++ b/go.sum @@ -227,8 +227,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -261,8 +261,8 @@ golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= From 15cf31f30a1bce7027041574ace9079d9ddb4fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MisakaNo=20=E3=81=AE=20=E5=B0=8F=E7=A0=B4=E7=AB=99?= <122191366+Misaka-blog@users.noreply.github.com> Date: Fri, 7 Apr 2023 18:20:56 +0800 Subject: [PATCH 018/867] Add sbox-reality to README/Others/sing-box (#1909) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 77b6185e..596cdbc2 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ - [meta_for_ios](https://t.me/meta_for_ios) - [sing-box](https://github.com/SagerNet/sing-box) - [installReality](https://github.com/BoxXt/installReality) + - [sbox-reality](https://github.com/Misaka-blog/sbox-reality) - [sing-box-for-ios](https://github.com/SagerNet/sing-box-for-ios) ## Contributing From 76b27a37cb9d1f82baef901949d3fabc03fa63fa Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 7 Apr 2023 19:13:20 +0800 Subject: [PATCH 019/867] Update common/xudp/xudp.go and common/mux/server.go --- common/mux/server.go | 3 +++ common/xudp/xudp.go | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/common/mux/server.go b/common/mux/server.go index e64e038f..b3c22a61 100644 --- a/common/mux/server.go +++ b/common/mux/server.go @@ -177,6 +177,9 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, // Actually, it won't return an error in Xray-core's implementations. link, err := w.dispatcher.Dispatch(ctx, meta.Target) if err != nil { + XUDPManager.Lock() + delete(XUDPManager.Map, x.GlobalID) + XUDPManager.Unlock() err = newError("failed to dispatch request to ", meta.Target).Base(err) if xudp.Show { fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err) diff --git a/common/xudp/xudp.go b/common/xudp/xudp.go index 65096d16..32dda614 100644 --- a/common/xudp/xudp.go +++ b/common/xudp/xudp.go @@ -25,7 +25,7 @@ var AddrParser = protocol.NewAddressParser( var ( Show bool - BaseKey [32]byte + BaseKey []byte ) const ( @@ -37,24 +37,24 @@ func init() { if strings.ToLower(os.Getenv(EnvShow)) == "true" { Show = true } - if raw := os.Getenv(EnvBaseKey); raw != "" { - if key, _ := base64.RawURLEncoding.DecodeString(raw); len(key) == len(BaseKey) { - copy(BaseKey[:], key) + if raw, found := os.LookupEnv(EnvBaseKey); found { + if BaseKey, _ = base64.RawURLEncoding.DecodeString(raw); len(BaseKey) == 32 { return - } else { - panic(EnvBaseKey + ": invalid value: " + raw) } + panic(EnvBaseKey + ": invalid value: " + raw) } - rand.Read(BaseKey[:]) + rand.Read(BaseKey) } func GetGlobalID(ctx context.Context) (globalID [8]byte) { if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Source.Network == net.Network_UDP && (inbound.Name == "dokodemo-door" || inbound.Name == "socks" || inbound.Name == "shadowsocks") { - h := blake3.New(8, BaseKey[:]) + h := blake3.New(8, BaseKey) h.Write([]byte(inbound.Source.String())) copy(globalID[:], h.Sum(nil)) - fmt.Printf("XUDP inbound.Source.String(): %v\tglobalID: %v\n", inbound.Source.String(), globalID) + if Show { + fmt.Printf("XUDP inbound.Source.String(): %v\tglobalID: %v\n", inbound.Source.String(), globalID) + } } return } From 05d24d6827f313d5a2a2a633e3b83a8cac7d26a5 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 8 Apr 2023 20:56:54 -0400 Subject: [PATCH 020/867] Amend XUDP related logs - Useful for debug XUDP improvements - Move XUDP log in core log - Freedom connection log show local port --- common/mux/server.go | 19 ++++--------------- common/mux/session.go | 10 ++-------- proxy/freedom/freedom.go | 2 +- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/common/mux/server.go b/common/mux/server.go index b3c22a61..55e3a674 100644 --- a/common/mux/server.go +++ b/common/mux/server.go @@ -2,7 +2,6 @@ package mux import ( "context" - "fmt" "io" "github.com/xtls/xray-core/common" @@ -12,7 +11,6 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" - "github.com/xtls/xray-core/common/xudp" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport" @@ -148,9 +146,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, } else { if x.Status == Initializing { // nearly impossible XUDPManager.Unlock() - if xudp.Show { - fmt.Printf("XUDP hit: %v err: conflict\n", meta.GlobalID) - } + newError("XUDP hit ", meta.GlobalID).Base(errors.New("conflict")).AtWarning().WriteToLog(session.ExportIDToError(ctx)) // It's not a good idea to return an err here, so just let client wait. // Client will receive an End frame after sending a Keep frame. return nil @@ -168,9 +164,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, b.Release() mb = nil } - if xudp.Show { - fmt.Printf("XUDP hit: %v err: %v\n", meta.GlobalID, err) - } + newError("XUDP hit ", meta.GlobalID).Base(err).WriteToLog(session.ExportIDToError(ctx)) } if mb != nil { ctx = session.ContextWithTimeoutOnly(ctx, true) @@ -180,10 +174,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, XUDPManager.Lock() delete(XUDPManager.Map, x.GlobalID) XUDPManager.Unlock() - err = newError("failed to dispatch request to ", meta.Target).Base(err) - if xudp.Show { - fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err) - } + err = newError("XUDP new ", meta.GlobalID).Base(errors.New("failed to dispatch request to ", meta.Target).Base(err)) return err // it will break the whole Mux connection } link.Writer.WriteMultiBuffer(mb) // it's meaningless to test a new pipe @@ -191,9 +182,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, input: link.Reader, output: link.Writer, } - if xudp.Show { - fmt.Printf("XUDP new: %v err: %v\n", meta.GlobalID, err) - } + newError("XUDP new ", meta.GlobalID).Base(err).WriteToLog(session.ExportIDToError(ctx)) } x.Mux = &Session{ input: x.Mux.input, diff --git a/common/mux/session.go b/common/mux/session.go index 650e3545..69597440 100644 --- a/common/mux/session.go +++ b/common/mux/session.go @@ -1,7 +1,6 @@ package mux import ( - "fmt" "io" "runtime" "sync" @@ -11,7 +10,6 @@ import ( "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" - "github.com/xtls/xray-core/common/xudp" "github.com/xtls/xray-core/transport/pipe" ) @@ -182,9 +180,7 @@ func (s *Session) Close(locked bool) error { if s.XUDP.Status == Active { s.XUDP.Expire = time.Now().Add(time.Minute) s.XUDP.Status = Expiring - if xudp.Show { - fmt.Printf("XUDP put: %v\n", s.XUDP.GlobalID) - } + newError("XUDP put ", s.XUDP.GlobalID).AtDebug().WriteToLog() } XUDPManager.Unlock() } @@ -234,9 +230,7 @@ func init() { if x.Status == Expiring && now.After(x.Expire) { x.Interrupt() delete(XUDPManager.Map, id) - if xudp.Show { - fmt.Printf("XUDP del: %v\n", id) - } + newError("XUDP del ", id).AtDebug().WriteToLog() } } XUDPManager.Unlock() diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 8630ab9c..93804a81 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -117,7 +117,6 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte UDPOverride.Port = destination.Port } } - newError("opening connection to ", destination).WriteToLog(session.ExportIDToError(ctx)) input := link.Reader output := link.Writer @@ -148,6 +147,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte return newError("failed to open connection to ", destination).Base(err) } defer conn.Close() + newError("connection opened to ", destination, ", local endpoint ", conn.LocalAddr(), ", remote endpoint ", conn.RemoteAddr()).WriteToLog(session.ExportIDToError(ctx)) var newCtx context.Context var newCancel context.CancelFunc From 29d7865d78289b07376e65cd1e68f25692bda950 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 10 Apr 2023 10:15:16 +0800 Subject: [PATCH 021/867] Refine "only" in Mux config --- app/proxyman/config.pb.go | 2 +- app/proxyman/config.proto | 2 +- infra/conf/xray.go | 15 +++++++++++---- infra/conf/xray_test.go | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index 03613e88..c3b221c4 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -595,7 +595,7 @@ type MultiplexingConfig struct { Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` // Max number of concurrent connections that one Mux connection can handle. Concurrency uint32 `protobuf:"varint,2,opt,name=concurrency,proto3" json:"concurrency,omitempty"` - // Both(0), TCP(1), UDP(2). + // Both(0), TCP(net.Network_TCP), UDP(net.Network_UDP). Only uint32 `protobuf:"varint,3,opt,name=only,proto3" json:"only,omitempty"` } diff --git a/app/proxyman/config.proto b/app/proxyman/config.proto index 54f63436..8f282aa2 100644 --- a/app/proxyman/config.proto +++ b/app/proxyman/config.proto @@ -98,6 +98,6 @@ message MultiplexingConfig { bool enabled = 1; // Max number of concurrent connections that one Mux connection can handle. uint32 concurrency = 2; - // Both(0), TCP(1), UDP(2). + // Both(0), TCP(net.Network_TCP), UDP(net.Network_UDP). uint32 only = 3; } diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 2306e380..63ffccf5 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -114,9 +114,9 @@ type MuxConfig struct { } // Build creates MultiplexingConfig, Concurrency < 0 completely disables mux. -func (m *MuxConfig) Build() *proxyman.MultiplexingConfig { +func (m *MuxConfig) Build() (*proxyman.MultiplexingConfig, error) { if m.Concurrency < 0 { - return nil + return nil, nil } if m.Concurrency == 0 { m.Concurrency = 8 @@ -128,13 +128,16 @@ func (m *MuxConfig) Build() *proxyman.MultiplexingConfig { } switch strings.ToLower(m.Only) { + case "", "both": case "tcp": config.Only = uint32(net.Network_TCP) case "udp": config.Only = uint32(net.Network_UDP) + default: + return nil, newError(`unknown "only": `, m.Only) } - return config + return config, nil } type InboundDetourAllocationConfig struct { @@ -348,7 +351,11 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) { } if c.MuxSettings != nil { - senderSettings.MultiplexSettings = c.MuxSettings.Build() + ms, err := c.MuxSettings.Build() + if err != nil { + return nil, newError("failed to build Mux config.").Base(err) + } + senderSettings.MultiplexSettings = ms } settings := []byte("{}") diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index 8c8151de..02d868fe 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -357,7 +357,7 @@ func TestMuxConfig_Build(t *testing.T) { t.Run(tt.name, func(t *testing.T) { m := &MuxConfig{} common.Must(json.Unmarshal([]byte(tt.fields), m)) - if got := m.Build(); !reflect.DeepEqual(got, tt.want) { + if got, _ := m.Build(); !reflect.DeepEqual(got, tt.want) { t.Errorf("MuxConfig.Build() = %v, want %v", got, tt.want) } }) From 24a2be43ef997f500602127259d8d076d0c913c5 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 10 Apr 2023 10:36:07 +0800 Subject: [PATCH 022/867] Replace "only" with "xudpConcurrency" in Mux config --- app/proxyman/config.pb.go | 37 +++++----- app/proxyman/config.proto | 6 +- app/proxyman/outbound/handler.go | 116 ++++++++++++++++++++----------- common/mux/client.go | 1 - infra/conf/xray.go | 35 +++------- infra/conf/xray_test.go | 7 +- 6 files changed, 112 insertions(+), 90 deletions(-) diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index c3b221c4..664e6670 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -594,9 +594,9 @@ type MultiplexingConfig struct { // Whether or not Mux is enabled. Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` // Max number of concurrent connections that one Mux connection can handle. - Concurrency uint32 `protobuf:"varint,2,opt,name=concurrency,proto3" json:"concurrency,omitempty"` - // Both(0), TCP(net.Network_TCP), UDP(net.Network_UDP). - Only uint32 `protobuf:"varint,3,opt,name=only,proto3" json:"only,omitempty"` + Concurrency int32 `protobuf:"varint,2,opt,name=concurrency,proto3" json:"concurrency,omitempty"` + // Transport XUDP in another Mux. + XudpConcurrency int32 `protobuf:"varint,3,opt,name=xudpConcurrency,proto3" json:"xudpConcurrency,omitempty"` } func (x *MultiplexingConfig) Reset() { @@ -638,16 +638,16 @@ func (x *MultiplexingConfig) GetEnabled() bool { return false } -func (x *MultiplexingConfig) GetConcurrency() uint32 { +func (x *MultiplexingConfig) GetConcurrency() int32 { if x != nil { return x.Concurrency } return 0 } -func (x *MultiplexingConfig) GetOnly() uint32 { +func (x *MultiplexingConfig) GetXudpConcurrency() int32 { if x != nil { - return x.Only + return x.XudpConcurrency } return 0 } @@ -865,22 +865,23 @@ var file_app_proxyman_config_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x6d, 0x75, 0x6c, 0x74, 0x69, - 0x70, 0x6c, 0x65, 0x78, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x64, 0x0a, 0x12, + 0x70, 0x6c, 0x65, 0x78, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x7a, 0x0a, 0x12, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0d, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x12, - 0x0a, 0x04, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x6f, 0x6e, - 0x6c, 0x79, 0x2a, 0x23, 0x0a, 0x0e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x63, 0x6f, 0x6c, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x00, 0x12, 0x07, - 0x0a, 0x03, 0x54, 0x4c, 0x53, 0x10, 0x01, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, - 0x50, 0x01, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, - 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, - 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61, - 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x05, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x28, + 0x0a, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, + 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x43, 0x6f, 0x6e, + 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x2a, 0x23, 0x0a, 0x0e, 0x4b, 0x6e, 0x6f, 0x77, + 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, + 0x54, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x4c, 0x53, 0x10, 0x01, 0x42, 0x55, 0x0a, + 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x50, 0x01, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, + 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, + 0x79, 0x6d, 0x61, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/app/proxyman/config.proto b/app/proxyman/config.proto index 8f282aa2..dc755fef 100644 --- a/app/proxyman/config.proto +++ b/app/proxyman/config.proto @@ -97,7 +97,7 @@ message MultiplexingConfig { // Whether or not Mux is enabled. bool enabled = 1; // Max number of concurrent connections that one Mux connection can handle. - uint32 concurrency = 2; - // Both(0), TCP(net.Network_TCP), UDP(net.Network_UDP). - uint32 only = 3; + int32 concurrency = 2; + // Transport XUDP in another Mux. + int32 xudpConcurrency = 3; } diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 89e2862d..4de70df2 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -57,6 +57,7 @@ type Handler struct { proxy proxy.Outbound outboundManager outbound.Manager mux *mux.ClientManager + xudp *mux.ClientManager uplinkCounter stats.Counter downlinkCounter stats.Counter } @@ -106,23 +107,49 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbou } if h.senderSettings != nil && h.senderSettings.MultiplexSettings != nil { - config := h.senderSettings.MultiplexSettings - if config.Concurrency < 1 || config.Concurrency > 1024 { - return nil, newError("invalid mux concurrency: ", config.Concurrency).AtWarning() - } - h.mux = &mux.ClientManager{ - Enabled: config.Enabled, - Picker: &mux.IncrementalWorkerPicker{ - Factory: &mux.DialingWorkerFactory{ - Proxy: proxyHandler, - Dialer: h, - Strategy: mux.ClientStrategy{ - MaxConcurrency: config.Concurrency, - MaxConnection: 128, + if config := h.senderSettings.MultiplexSettings; config.Enabled { + if config.Concurrency < 0 { + h.mux = &mux.ClientManager{Enabled: false} + } + if config.Concurrency == 0 { + config.Concurrency = 8 // same as before + } + if config.Concurrency > 0 { + h.mux = &mux.ClientManager{ + Enabled: true, + Picker: &mux.IncrementalWorkerPicker{ + Factory: &mux.DialingWorkerFactory{ + Proxy: proxyHandler, + Dialer: h, + Strategy: mux.ClientStrategy{ + MaxConcurrency: uint32(config.Concurrency), + MaxConnection: 128, + }, + }, }, - }, - }, - Only: config.Only, + } + } + if config.XudpConcurrency < 0 { + h.xudp = &mux.ClientManager{Enabled: false} + } + if config.XudpConcurrency == 0 { + h.xudp = nil // same as before + } + if config.XudpConcurrency > 0 { + h.xudp = &mux.ClientManager{ + Enabled: true, + Picker: &mux.IncrementalWorkerPicker{ + Factory: &mux.DialingWorkerFactory{ + Proxy: proxyHandler, + Dialer: h, + Strategy: mux.ClientStrategy{ + MaxConcurrency: uint32(config.XudpConcurrency), + MaxConnection: 128, + }, + }, + }, + } + } } } @@ -137,33 +164,44 @@ func (h *Handler) Tag() string { // Dispatch implements proxy.Outbound.Dispatch. func (h *Handler) Dispatch(ctx context.Context, link *transport.Link) { - outbound := session.OutboundFromContext(ctx) - if h.mux != nil && (h.mux.Enabled || session.MuxPreferedFromContext(ctx)) && - (h.mux.Only == 0 || (outbound != nil && h.mux.Only == uint32(outbound.Target.Network))) { - if err := h.mux.Dispatch(ctx, link); err != nil { - err := newError("failed to process mux outbound traffic").Base(err) - session.SubmitOutboundErrorToOriginator(ctx, err) - err.WriteToLog(session.ExportIDToError(ctx)) - common.Interrupt(link.Writer) - } - } else { - err := h.proxy.Process(ctx, link, h) - if err != nil { - if errors.Is(err, io.EOF) || errors.Is(err, io.ErrClosedPipe) || errors.Is(err, context.Canceled) { - err = nil + if h.mux != nil { + test := func(err error) { + if err != nil { + err := newError("failed to process mux outbound traffic").Base(err) + session.SubmitOutboundErrorToOriginator(ctx, err) + err.WriteToLog(session.ExportIDToError(ctx)) + common.Interrupt(link.Writer) } } - if err != nil { - // Ensure outbound ray is properly closed. - err := newError("failed to process outbound traffic").Base(err) - session.SubmitOutboundErrorToOriginator(ctx, err) - err.WriteToLog(session.ExportIDToError(ctx)) - common.Interrupt(link.Writer) - } else { - common.Must(common.Close(link.Writer)) + if h.xudp != nil && session.OutboundFromContext(ctx).Target.Network == net.Network_UDP { + if !h.xudp.Enabled { + goto out + } + test(h.xudp.Dispatch(ctx, link)) + return + } + if h.mux.Enabled { + test(h.mux.Dispatch(ctx, link)) + return } - common.Interrupt(link.Reader) } +out: + err := h.proxy.Process(ctx, link, h) + if err != nil { + if errors.Is(err, io.EOF) || errors.Is(err, io.ErrClosedPipe) || errors.Is(err, context.Canceled) { + err = nil + } + } + if err != nil { + // Ensure outbound ray is properly closed. + err := newError("failed to process outbound traffic").Base(err) + session.SubmitOutboundErrorToOriginator(ctx, err) + err.WriteToLog(session.ExportIDToError(ctx)) + common.Interrupt(link.Writer) + } else { + common.Must(common.Close(link.Writer)) + } + common.Interrupt(link.Reader) } // Address implements internet.Dialer. diff --git a/common/mux/client.go b/common/mux/client.go index f933ef4c..88621be0 100644 --- a/common/mux/client.go +++ b/common/mux/client.go @@ -24,7 +24,6 @@ import ( type ClientManager struct { Enabled bool // wheather mux is enabled from user config Picker WorkerPicker - Only uint32 } func (m *ClientManager) Dispatch(ctx context.Context, link *transport.Link) error { diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 63ffccf5..07c667fe 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -10,7 +10,6 @@ import ( "github.com/xtls/xray-core/app/dispatcher" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/app/stats" - "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/serial" core "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/transport/internet" @@ -108,36 +107,18 @@ func (c *SniffingConfig) Build() (*proxyman.SniffingConfig, error) { } type MuxConfig struct { - Enabled bool `json:"enabled"` - Concurrency int16 `json:"concurrency"` - Only string `json:"only"` + Enabled bool `json:"enabled"` + Concurrency int16 `json:"concurrency"` + XudpConcurrency int16 `json:"xudpConcurrency"` } // Build creates MultiplexingConfig, Concurrency < 0 completely disables mux. func (m *MuxConfig) Build() (*proxyman.MultiplexingConfig, error) { - if m.Concurrency < 0 { - return nil, nil - } - if m.Concurrency == 0 { - m.Concurrency = 8 - } - - config := &proxyman.MultiplexingConfig{ - Enabled: m.Enabled, - Concurrency: uint32(m.Concurrency), - } - - switch strings.ToLower(m.Only) { - case "", "both": - case "tcp": - config.Only = uint32(net.Network_TCP) - case "udp": - config.Only = uint32(net.Network_UDP) - default: - return nil, newError(`unknown "only": `, m.Only) - } - - return config, nil + return &proxyman.MultiplexingConfig{ + Enabled: m.Enabled, + Concurrency: int32(m.Concurrency), + XudpConcurrency: int32(m.XudpConcurrency), + }, nil } type InboundDetourAllocationConfig struct { diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index 02d868fe..91b82eea 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -345,13 +345,16 @@ func TestMuxConfig_Build(t *testing.T) { }}, {"empty def", `{}`, &proxyman.MultiplexingConfig{ Enabled: false, - Concurrency: 8, + Concurrency: 0, }}, {"not enable", `{"enabled": false, "concurrency": 4}`, &proxyman.MultiplexingConfig{ Enabled: false, Concurrency: 4, }}, - {"forbidden", `{"enabled": false, "concurrency": -1}`, nil}, + {"forbidden", `{"enabled": false, "concurrency": -1}`, &proxyman.MultiplexingConfig{ + Enabled: false, + Concurrency: -1, + }}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { From 01b7e5e9be034421c948e59c64977aee16f67d1e Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 12 Apr 2023 23:20:26 +0800 Subject: [PATCH 023/867] XUDP Global ID should be empty if "cone" is disabled (client side) --- common/xudp/xudp.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/xudp/xudp.go b/common/xudp/xudp.go index 32dda614..a162334a 100644 --- a/common/xudp/xudp.go +++ b/common/xudp/xudp.go @@ -47,6 +47,9 @@ func init() { } func GetGlobalID(ctx context.Context) (globalID [8]byte) { + if cone := ctx.Value("cone"); cone == nil || !cone.(bool) { // cone is nil only in some unit tests + return + } if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Source.Network == net.Network_UDP && (inbound.Name == "dokodemo-door" || inbound.Name == "socks" || inbound.Name == "shadowsocks") { h := blake3.New(8, BaseKey) From b33b0bc89d0308bc3287bec109b0941db9b75edc Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 12 Apr 2023 23:20:38 +0800 Subject: [PATCH 024/867] Allow multiple XUDP in Mux when using XTLS Vision (server side) --- common/mux/server.go | 6 ++++++ common/session/context.go | 13 +++++++++++++ proxy/vless/inbound/inbound.go | 4 +++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/common/mux/server.go b/common/mux/server.go index 55e3a674..47a6d3dc 100644 --- a/common/mux/server.go +++ b/common/mux/server.go @@ -132,6 +132,12 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, ctx = log.ContextWithAccessMessage(ctx, msg) } + if network := session.AllowedNetworkFromContext(ctx); network != net.Network_Unknown { + if meta.Target.Network != network { + return newError("unexpected network ", meta.Target.Network) // it will break the whole Mux connection + } + } + if meta.GlobalID != [8]byte{} { mb, err := NewPacketReader(reader, &meta.Target).ReadMultiBuffer() if err != nil { diff --git a/common/session/context.go b/common/session/context.go index 71e4b154..329a5a65 100644 --- a/common/session/context.go +++ b/common/session/context.go @@ -4,6 +4,7 @@ import ( "context" _ "unsafe" + "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/features/routing" ) @@ -22,6 +23,7 @@ const ( trackedConnectionErrorKey dispatcherKey timeoutOnlyKey + allowedNetworkKey ) // ContextWithID returns a new context with the given ID. @@ -147,3 +149,14 @@ func TimeoutOnlyFromContext(ctx context.Context) bool { } return false } + +func ContextWithAllowedNetwork(ctx context.Context, network net.Network) context.Context { + return context.WithValue(ctx, allowedNetworkKey, network) +} + +func AllowedNetworkFromContext(ctx context.Context) net.Network { + if val, ok := ctx.Value(allowedNetworkKey).(net.Network); ok { + return val + } + return net.Network_Unknown +} diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index c8a69444..8d9b9b43 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -495,7 +495,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s return newError(account.ID.String() + " is not able to use " + requestAddons.Flow).AtWarning() } case "": - if account.Flow == vless.XRV && (request.Command == protocol.RequestCommandTCP || isMuxAndNotXUDP(request, first)) { + if account.Flow == vless.XRV && request.Command == protocol.RequestCommandTCP { return newError(account.ID.String() + " is not able to use \"\". Note that the pure TLS proxy has certain TLS in TLS characters.").AtWarning() } default: @@ -510,6 +510,8 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s Reason: "", Email: request.User.Email, }) + } else if account.Flow == vless.XRV { + ctx = session.ContextWithAllowedNetwork(ctx, net.Network_UDP) } sessionPolicy = h.policyManager.ForLevel(request.User.Level) From 4f601530fabf045b0dc08e5526426ba7331c1133 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 14 Apr 2023 22:51:09 +0000 Subject: [PATCH 025/867] Allow multiple XUDP in Mux when using XTLS Vision (client side) --- proxy/vless/outbound/outbound.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index cb2a1b76..4cdae764 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -136,10 +136,10 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte case vless.XRV: switch request.Command { case protocol.RequestCommandMux: - return newError(requestAddons.Flow + " doesn't support Mux").AtWarning() + requestAddons.Flow = "" // let server break Mux connections that contain TCP requests case protocol.RequestCommandUDP: if !allowUDP443 && request.Port == 443 { - return newError(requestAddons.Flow + " stopped UDP/443").AtInfo() + return newError("XTLS rejected UDP/443 traffic").AtInfo() } requestAddons.Flow = "" case protocol.RequestCommandTCP: From 06c9e50c521ad73074a1d9c10c447c5dc1c00ae2 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 14 Apr 2023 22:51:18 +0000 Subject: [PATCH 026/867] Add "xudpProxyUDP443" to Mux config & XUDP rejects UDP/443 traffic by default (client side, excluding reverse proxy) --- app/proxyman/config.pb.go | 46 ++++++++++++++++++++------------ app/proxyman/config.proto | 2 ++ app/proxyman/outbound/handler.go | 14 +++++++++- infra/conf/xray.go | 15 ++++++++--- infra/conf/xray_test.go | 24 +++++++++++------ 5 files changed, 72 insertions(+), 29 deletions(-) diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index 664e6670..cd50e664 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -597,6 +597,8 @@ type MultiplexingConfig struct { Concurrency int32 `protobuf:"varint,2,opt,name=concurrency,proto3" json:"concurrency,omitempty"` // Transport XUDP in another Mux. XudpConcurrency int32 `protobuf:"varint,3,opt,name=xudpConcurrency,proto3" json:"xudpConcurrency,omitempty"` + // "reject" (default), "allow" or "skip". + XudpProxyUDP443 string `protobuf:"bytes,4,opt,name=xudpProxyUDP443,proto3" json:"xudpProxyUDP443,omitempty"` } func (x *MultiplexingConfig) Reset() { @@ -652,6 +654,13 @@ func (x *MultiplexingConfig) GetXudpConcurrency() int32 { return 0 } +func (x *MultiplexingConfig) GetXudpProxyUDP443() string { + if x != nil { + return x.XudpProxyUDP443 + } + return "" +} + type AllocationStrategy_AllocationStrategyConcurrency struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -865,23 +874,26 @@ var file_app_proxyman_config_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x6d, 0x75, 0x6c, 0x74, 0x69, - 0x70, 0x6c, 0x65, 0x78, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x7a, 0x0a, 0x12, - 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x20, 0x0a, 0x0b, - 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x28, - 0x0a, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, - 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x43, 0x6f, 0x6e, - 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x2a, 0x23, 0x0a, 0x0e, 0x4b, 0x6e, 0x6f, 0x77, - 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, - 0x54, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x4c, 0x53, 0x10, 0x01, 0x42, 0x55, 0x0a, - 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x50, 0x01, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, - 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, - 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, - 0x79, 0x6d, 0x61, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x6c, 0x65, 0x78, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0xa4, 0x01, 0x0a, + 0x12, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x20, 0x0a, + 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, + 0x28, 0x0a, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x63, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x43, 0x6f, + 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x78, 0x75, 0x64, + 0x70, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x55, 0x44, 0x50, 0x34, 0x34, 0x33, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x55, 0x44, 0x50, + 0x34, 0x34, 0x33, 0x2a, 0x23, 0x0a, 0x0e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x00, 0x12, + 0x07, 0x0a, 0x03, 0x54, 0x4c, 0x53, 0x10, 0x01, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, + 0x6e, 0x50, 0x01, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, + 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, + 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/app/proxyman/config.proto b/app/proxyman/config.proto index dc755fef..5d063eba 100644 --- a/app/proxyman/config.proto +++ b/app/proxyman/config.proto @@ -100,4 +100,6 @@ message MultiplexingConfig { int32 concurrency = 2; // Transport XUDP in another Mux. int32 xudpConcurrency = 3; + // "reject" (default), "allow" or "skip". + string xudpProxyUDP443 = 4; } diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 4de70df2..e91bcb07 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -58,6 +58,7 @@ type Handler struct { outboundManager outbound.Manager mux *mux.ClientManager xudp *mux.ClientManager + udp443 string uplinkCounter stats.Counter downlinkCounter stats.Counter } @@ -150,6 +151,7 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbou }, } } + h.udp443 = config.XudpProxyUDP443 } } @@ -173,7 +175,17 @@ func (h *Handler) Dispatch(ctx context.Context, link *transport.Link) { common.Interrupt(link.Writer) } } - if h.xudp != nil && session.OutboundFromContext(ctx).Target.Network == net.Network_UDP { + outbound := session.OutboundFromContext(ctx) + if outbound.Target.Network == net.Network_UDP && outbound.Target.Port == 443 { + switch h.udp443 { + case "reject": + test(newError("XUDP rejected UDP/443 traffic").AtInfo()) + return + case "skip": + goto out + } + } + if h.xudp != nil && outbound.Target.Network == net.Network_UDP { if !h.xudp.Enabled { goto out } diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 07c667fe..8b6d05f4 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -107,17 +107,26 @@ func (c *SniffingConfig) Build() (*proxyman.SniffingConfig, error) { } type MuxConfig struct { - Enabled bool `json:"enabled"` - Concurrency int16 `json:"concurrency"` - XudpConcurrency int16 `json:"xudpConcurrency"` + Enabled bool `json:"enabled"` + Concurrency int16 `json:"concurrency"` + XudpConcurrency int16 `json:"xudpConcurrency"` + XudpProxyUDP443 string `json:"xudpProxyUDP443"` } // Build creates MultiplexingConfig, Concurrency < 0 completely disables mux. func (m *MuxConfig) Build() (*proxyman.MultiplexingConfig, error) { + switch m.XudpProxyUDP443 { + case "": + m.XudpProxyUDP443 = "reject" + case "reject", "allow", "skip": + default: + return nil, newError(`unknown "xudpProxyUDP443": `, m.XudpProxyUDP443) + } return &proxyman.MultiplexingConfig{ Enabled: m.Enabled, Concurrency: int32(m.Concurrency), XudpConcurrency: int32(m.XudpConcurrency), + XudpProxyUDP443: m.XudpProxyUDP443, }, nil } diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index 91b82eea..b39da7c9 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -340,20 +340,28 @@ func TestMuxConfig_Build(t *testing.T) { want *proxyman.MultiplexingConfig }{ {"default", `{"enabled": true, "concurrency": 16}`, &proxyman.MultiplexingConfig{ - Enabled: true, - Concurrency: 16, + Enabled: true, + Concurrency: 16, + XudpConcurrency: 0, + XudpProxyUDP443: "reject", }}, {"empty def", `{}`, &proxyman.MultiplexingConfig{ - Enabled: false, - Concurrency: 0, + Enabled: false, + Concurrency: 0, + XudpConcurrency: 0, + XudpProxyUDP443: "reject", }}, {"not enable", `{"enabled": false, "concurrency": 4}`, &proxyman.MultiplexingConfig{ - Enabled: false, - Concurrency: 4, + Enabled: false, + Concurrency: 4, + XudpConcurrency: 0, + XudpProxyUDP443: "reject", }}, {"forbidden", `{"enabled": false, "concurrency": -1}`, &proxyman.MultiplexingConfig{ - Enabled: false, - Concurrency: -1, + Enabled: false, + Concurrency: -1, + XudpConcurrency: 0, + XudpProxyUDP443: "reject", }}, } for _, tt := range tests { From 9f8e9e8e64ece63258e03b0c6941a95fd8cfaaf9 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 15 Apr 2023 20:21:21 -0400 Subject: [PATCH 027/867] Add xudp buffer test --- common/xudp/xudp.go | 2 +- common/xudp/xudp_test.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 common/xudp/xudp_test.go diff --git a/common/xudp/xudp.go b/common/xudp/xudp.go index a162334a..a3df4e8b 100644 --- a/common/xudp/xudp.go +++ b/common/xudp/xudp.go @@ -150,7 +150,7 @@ func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) { case 2: if l != 4 { b.Advance(5) - addr, port, err := AddrParser.ReadAddressPort(nil, b) + addr, port, err := AddrParser.ReadAddressPort(nil, b) // read addr will read all content and clear b if err != nil { b.Release() return nil, err diff --git a/common/xudp/xudp_test.go b/common/xudp/xudp_test.go new file mode 100644 index 00000000..dd720a81 --- /dev/null +++ b/common/xudp/xudp_test.go @@ -0,0 +1,36 @@ +package xudp + +import ( + "testing" + + "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/net" +) + +func TestXudpReadWrite(t *testing.T) { + addr, _ := net.ParseDestination("tcp:127.0.0.1:1345") + mb := make(buf.MultiBuffer, 0, 16) + m := buf.MultiBufferContainer { + MultiBuffer: mb, + } + var arr [8]byte + writer := NewPacketWriter(&m, addr, arr) + + source := make(buf.MultiBuffer, 0, 16) + b := buf.New() + b.WriteByte('a') + b.UDP = &addr + source = append(source, b) + writer.WriteMultiBuffer(source) + + reader := NewPacketReader(&m) + dest, err := reader.ReadMultiBuffer() + common.Must(err) + if dest[0].Byte(0) != 'a' { + t.Error("failed to parse xudp buffer") + } + if dest[0].UDP.Port != 1345 { + t.Error("failed to parse xudp buffer") + } +} \ No newline at end of file From b4c1a560265569682f8c26687331d467dc9811e5 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 16 Apr 2023 21:15:27 +0000 Subject: [PATCH 028/867] XUDP practice: MUST check the flag first & Add more comments --- common/mux/frame.go | 8 +++++--- common/mux/server.go | 2 +- common/xudp/xudp.go | 15 ++++++++------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/common/mux/frame.go b/common/mux/frame.go index ab57d771..d53ac202 100644 --- a/common/mux/frame.go +++ b/common/mux/frame.go @@ -82,8 +82,8 @@ func (f FrameMetadata) WriteTo(b *buf.Buffer) error { if err := addrParser.WriteAddressPort(b, f.Target.Address, f.Target.Port); err != nil { return err } - if b.UDP != nil { - b.Write(f.GlobalID[:]) + if b.UDP != nil { // make sure it's user's proxy request + b.Write(f.GlobalID[:]) // no need to check whether it's empty } } else if b.UDP != nil { b.WriteByte(byte(TargetNetworkUDP)) @@ -126,7 +126,8 @@ func (f *FrameMetadata) UnmarshalFromBuffer(b *buf.Buffer) error { f.Option = bitmask.Byte(b.Byte(3)) f.Target.Network = net.Network_Unknown - if f.SessionStatus == SessionStatusNew || (f.SessionStatus == SessionStatusKeep && b.Len() != 4) { + if f.SessionStatus == SessionStatusNew || (f.SessionStatus == SessionStatusKeep && b.Len() > 4 && + TargetNetwork(b.Byte(4)) == TargetNetworkUDP) { // MUST check the flag first if b.Len() < 8 { return newError("insufficient buffer: ", b.Len()) } @@ -148,6 +149,7 @@ func (f *FrameMetadata) UnmarshalFromBuffer(b *buf.Buffer) error { } } + // Application data is essential, to test whether the pipe is closed. if f.SessionStatus == SessionStatusNew && f.Option.Has(OptionData) && f.Target.Network == net.Network_UDP && b.Len() >= 8 { copy(f.GlobalID[:], b.Bytes()) diff --git a/common/mux/server.go b/common/mux/server.go index 47a6d3dc..2d33189f 100644 --- a/common/mux/server.go +++ b/common/mux/server.go @@ -138,7 +138,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, } } - if meta.GlobalID != [8]byte{} { + if meta.GlobalID != [8]byte{} { // MUST ignore empty Global ID mb, err := NewPacketReader(reader, &meta.Target).ReadMultiBuffer() if err != nil { return err diff --git a/common/xudp/xudp.go b/common/xudp/xudp.go index a3df4e8b..513247c3 100644 --- a/common/xudp/xudp.go +++ b/common/xudp/xudp.go @@ -86,21 +86,21 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { } eb := buf.New() - eb.Write([]byte{0, 0, 0, 0}) + eb.Write([]byte{0, 0, 0, 0}) // Meta data length; Mux Session ID if w.Dest.Network == net.Network_UDP { eb.WriteByte(1) // New eb.WriteByte(1) // Opt eb.WriteByte(2) // UDP AddrParser.WriteAddressPort(eb, w.Dest.Address, w.Dest.Port) if b.UDP != nil { // make sure it's user's proxy request - eb.Write(w.GlobalID[:]) + eb.Write(w.GlobalID[:]) // no need to check whether it's empty } w.Dest.Network = net.Network_Unknown } else { eb.WriteByte(2) // Keep - eb.WriteByte(1) + eb.WriteByte(1) // Opt if b.UDP != nil { - eb.WriteByte(2) + eb.WriteByte(2) // UDP AddrParser.WriteAddressPort(eb, b.UDP.Address, b.UDP.Port) } } @@ -148,9 +148,10 @@ func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) { discard := false switch b.Byte(2) { case 2: - if l != 4 { + if l > 4 && b.Byte(4) == 2 { // MUST check the flag first b.Advance(5) - addr, port, err := AddrParser.ReadAddressPort(nil, b) // read addr will read all content and clear b + // b.Clear() will be called automatically if all data had been read. + addr, port, err := AddrParser.ReadAddressPort(nil, b) if err != nil { b.Release() return nil, err @@ -167,6 +168,7 @@ func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) { b.Release() return nil, io.EOF } + b.Clear() // in case there is padding (empty bytes) attached if b.Byte(3) == 1 { if _, err := io.ReadFull(r.Reader, r.cache); err != nil { b.Release() @@ -174,7 +176,6 @@ func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) { } length := int32(r.cache[0])<<8 | int32(r.cache[1]) if length > 0 { - b.Clear() if _, err := b.ReadFullFrom(r.Reader, length); err != nil { b.Release() return nil, err From 242f3b0e0b635699db26a991aa6c0cd47927e8b6 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 16 Apr 2023 21:15:36 +0000 Subject: [PATCH 029/867] XTLS protocol: Apply Vision's padding to XUDP Mux & Minor fixes It's recommended to enable XUDP Mux when using XTLS Vision Thank @yuhan6665 for testing --- proxy/vless/encoding/encoding.go | 7 +++++-- proxy/vless/inbound/inbound.go | 10 ++++------ proxy/vless/outbound/outbound.go | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index 27d1fb01..f668c402 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -21,6 +21,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/reality" "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" ) @@ -227,8 +228,10 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater if ok { iConn = statConn.Connection } - if xc, ok := iConn.(*tls.Conn); ok { - iConn = xc.NetConn() + if tlsConn, ok := iConn.(*tls.Conn); ok { + iConn = tlsConn.NetConn() + } else if realityConn, ok := iConn.(*reality.Conn); ok { + iConn = realityConn.NetConn() } if tc, ok := iConn.(*net.TCPConn); ok { newError("XtlsRead splice").WriteToLog(session.ExportIDToError(ctx)) diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index 8d9b9b43..688c98a3 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -456,10 +456,10 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s case vless.XRV: if account.Flow == requestAddons.Flow { switch request.Command { - case protocol.RequestCommandMux: - return newError(requestAddons.Flow + " doesn't support Mux").AtWarning() case protocol.RequestCommandUDP: return newError(requestAddons.Flow + " doesn't support UDP").AtWarning() + case protocol.RequestCommandMux: + fallthrough // we will break Mux connections that contain TCP requests case protocol.RequestCommandTCP: var t reflect.Type var p uintptr @@ -474,10 +474,8 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s netConn = realityConn.NetConn() t = reflect.TypeOf(realityConn.Conn).Elem() p = uintptr(unsafe.Pointer(realityConn.Conn)) - } else if _, ok := iConn.(*tls.UConn); ok { - return newError("XTLS only supports UTLS fingerprint for the outbound.").AtWarning() } else { - return newError("XTLS only supports TCP, mKCP and DomainSocket for now.").AtWarning() + return newError("XTLS only supports TLS and REALITY directly for now.").AtWarning() } if pc, ok := netConn.(*proxyproto.Conn); ok { netConn = pc.Raw() @@ -495,7 +493,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s return newError(account.ID.String() + " is not able to use " + requestAddons.Flow).AtWarning() } case "": - if account.Flow == vless.XRV && request.Command == protocol.RequestCommandTCP { + if account.Flow == vless.XRV && (request.Command == protocol.RequestCommandTCP || isMuxAndNotXUDP(request, first)) { return newError(account.ID.String() + " is not able to use \"\". Note that the pure TLS proxy has certain TLS in TLS characters.").AtWarning() } default: diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index 4cdae764..4f42ea9f 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -135,13 +135,13 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte fallthrough case vless.XRV: switch request.Command { - case protocol.RequestCommandMux: - requestAddons.Flow = "" // let server break Mux connections that contain TCP requests case protocol.RequestCommandUDP: if !allowUDP443 && request.Port == 443 { return newError("XTLS rejected UDP/443 traffic").AtInfo() } requestAddons.Flow = "" + case protocol.RequestCommandMux: + fallthrough // let server break Mux connections that contain TCP requests case protocol.RequestCommandTCP: var t reflect.Type var p uintptr @@ -158,7 +158,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte t = reflect.TypeOf(realityConn.Conn).Elem() p = uintptr(unsafe.Pointer(realityConn.Conn)) } else { - return newError("XTLS only supports TCP, mKCP and DomainSocket for now.").AtWarning() + return newError("XTLS only supports TLS and REALITY directly for now.").AtWarning() } if sc, ok := netConn.(syscall.Conn); ok { rawConn, _ = sc.SyscallConn() From 039e5f207888cec57768cbea4f030ebeb34a85f7 Mon Sep 17 00:00:00 2001 From: Vigilans Date: Sat, 18 Feb 2023 05:47:59 +0800 Subject: [PATCH 030/867] Correctly implement quic sniffer's frame parsing --- common/protocol/quic/sniff.go | 105 +++++++++++++++++++++++++++------- 1 file changed, 83 insertions(+), 22 deletions(-) diff --git a/common/protocol/quic/sniff.go b/common/protocol/quic/sniff.go index 71c14428..bf461464 100644 --- a/common/protocol/quic/sniff.go +++ b/common/protocol/quic/sniff.go @@ -10,6 +10,7 @@ import ( "github.com/quic-go/quic-go/quicvarint" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/bytespool" "github.com/xtls/xray-core/common/errors" ptls "github.com/xtls/xray-core/common/protocol/tls" "golang.org/x/crypto/hkdf" @@ -141,7 +142,7 @@ func SniffQUIC(b []byte) (*SniffHeader, error) { packetNumber = uint32(n) } - if packetNumber != 0 { + if packetNumber != 0 && packetNumber != 1 { return nil, errNotQuicInitial } @@ -159,32 +160,92 @@ func SniffQUIC(b []byte) (*SniffHeader, error) { return nil, err } buffer = buf.FromBytes(decrypted) - frameType, err := buffer.ReadByte() - if err != nil { - return nil, io.ErrUnexpectedEOF + + cryptoLen := uint(0) + cryptoData := bytespool.Alloc(buffer.Len()) + defer bytespool.Free(cryptoData) + for i := 0; !buffer.IsEmpty(); i++ { + frameType := byte(0x0) // Default to PADDING frame + for frameType == 0x0 && !buffer.IsEmpty() { + frameType, _ = buffer.ReadByte() + } + switch frameType { + case 0x00: // PADDING frame + case 0x01: // PING frame + case 0x02, 0x03: // ACK frame + if _, err = quicvarint.Read(buffer); err != nil { // Field: Largest Acknowledged + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { // Field: ACK Delay + return nil, io.ErrUnexpectedEOF + } + ackRangeCount, err := quicvarint.Read(buffer) // Field: ACK Range Count + if err != nil { + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { // Field: First ACK Range + return nil, io.ErrUnexpectedEOF + } + for i := 0; i < int(ackRangeCount); i++ { // Field: ACK Range + if _, err = quicvarint.Read(buffer); err != nil { // Field: ACK Range -> Gap + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { // Field: ACK Range -> ACK Range Length + return nil, io.ErrUnexpectedEOF + } + } + if frameType == 0x03 { + if _, err = quicvarint.Read(buffer); err != nil { // Field: ECN Counts -> ECT0 Count + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { // Field: ECN Counts -> ECT1 Count + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { //nolint:misspell // Field: ECN Counts -> ECT-CE Count + return nil, io.ErrUnexpectedEOF + } + } + case 0x06: // CRYPTO frame, we will use this frame + offset, err := quicvarint.Read(buffer) // Field: Offset + if err != nil { + return nil, io.ErrUnexpectedEOF + } + length, err := quicvarint.Read(buffer) // Field: Length + if err != nil || length > uint64(buffer.Len()) { + return nil, io.ErrUnexpectedEOF + } + if cryptoLen < uint(offset+length) { + cryptoLen = uint(offset + length) + } + if _, err := buffer.Read(cryptoData[offset : offset+length]); err != nil { // Field: Crypto Data + return nil, io.ErrUnexpectedEOF + } + case 0x1c: // CONNECTION_CLOSE frame, only 0x1c is permitted in initial packet + if _, err = quicvarint.Read(buffer); err != nil { // Field: Error Code + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { // Field: Frame Type + return nil, io.ErrUnexpectedEOF + } + length, err := quicvarint.Read(buffer) // Field: Reason Phrase Length + if err != nil { + return nil, io.ErrUnexpectedEOF + } + if _, err := buffer.ReadBytes(int32(length)); err != nil { // Field: Reason Phrase + return nil, io.ErrUnexpectedEOF + } + default: + // Only above frame types are permitted in initial packet. + // See https://www.rfc-editor.org/rfc/rfc9000.html#section-17.2.2-8 + return nil, errNotQuicInitial + } } - if frameType != 0x6 { - // not crypto frame - return &SniffHeader{domain: ""}, nil - } - if common.Error2(quicvarint.Read(buffer)) != nil { - return nil, io.ErrUnexpectedEOF - } - dataLen, err := quicvarint.Read(buffer) - if err != nil { - return nil, io.ErrUnexpectedEOF - } - if dataLen > uint64(buffer.Len()) { - return nil, io.ErrUnexpectedEOF - } - frameData, err := buffer.ReadBytes(int32(dataLen)) - common.Must(err) + tlsHdr := &ptls.SniffHeader{} - err = ptls.ReadClientHello(frameData, tlsHdr) + err = ptls.ReadClientHello(cryptoData[:cryptoLen], tlsHdr) if err != nil { return nil, err } - return &SniffHeader{domain: tlsHdr.Domain()}, nil } From 197bc78ea19a9bb2dbb4b1a683a78b89f6f21f77 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 12 Apr 2023 09:51:18 -0400 Subject: [PATCH 031/867] Turn off Quic qlog since it jam the regular test info --- transport/internet/quic/qlogWriter.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/transport/internet/quic/qlogWriter.go b/transport/internet/quic/qlogWriter.go index 1b7913e6..dd13f419 100644 --- a/transport/internet/quic/qlogWriter.go +++ b/transport/internet/quic/qlogWriter.go @@ -1,22 +1,18 @@ package quic -import ( - "fmt" - - "github.com/xtls/xray-core/common/log" -) - type QlogWriter struct { connID []byte } func (w *QlogWriter) Write(b []byte) (int, error) { - if len(b) > 1 { // skip line separator "0a" in qlog - log.Record(&log.GeneralMessage{ - Severity: log.Severity_Debug, - Content: fmt.Sprintf("[%x] %s", w.connID, b), - }) - } + // to much log, only turn on when debug Quic + + // if len(b) > 1 { // skip line separator "0a" in qlog + // log.Record(&log.GeneralMessage{ + // Severity: log.Severity_Debug, + // Content: fmt.Sprintf("[%x] %s", w.connID, b), + // }) + // } return len(b), nil } From ac8109eef8ec80423fea2e7c56b17eccec6df1e7 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 17 Apr 2023 23:21:56 +0000 Subject: [PATCH 032/867] Update README.md --- README.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 596cdbc2..fb85b407 100644 --- a/README.md +++ b/README.md @@ -26,18 +26,19 @@ - [teddysun/xray](https://hub.docker.com/r/teddysun/xray) - Web Panel - [X-UI](https://github.com/FranzKafkaYu/x-ui), [X-UI-English](https://github.com/NidukaAkalanka/x-ui-english), [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [X-UI](https://github.com/diditra/x-ui) + - [Xray-UI](https://github.com/qist/xray-ui), [X-UI](https://github.com/sing-web/x-ui) - [Hiddify](https://github.com/hiddify/hiddify-config) - [Marzban](https://github.com/Gozargah/Marzban) + - [Libertea](https://github.com/VZiChoushaDui/Libertea) - One Click - - [Xray-script](https://github.com/kirin10000/Xray-script), [Xray-script](https://github.com/zxcvos/Xray-script), [xray_script](https://github.com/tdjnodj/xray_script) + - [Xray-script](https://github.com/kirin10000/Xray-script), [Xray-REALITY](https://github.com/zxcvos/Xray-script), [LetsXray](https://github.com/tdjnodj/LetsXray) - [XTool](https://github.com/LordPenguin666/XTool), [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [xray-reality](https://github.com/sajjaddg/xray-reality) - [v2ray-agent](https://github.com/mack-a/v2ray-agent), [Xray_onekey](https://github.com/wulabing/Xray_onekey), [ProxySU](https://github.com/proxysu/ProxySU) - Magisk - - [Xray4Magisk](https://github.com/CerteKim/Xray4Magisk) + - [Xray4Magisk](https://github.com/Asterisk4Magisk/Xray4Magisk) - [Xray_For_Magisk](https://github.com/E7KMbb/Xray_For_Magisk) - Homebrew - `brew install xray` - - [(Tap) Repository 0](https://github.com/N4FA/homebrew-xray) ## Usage @@ -52,6 +53,7 @@ - Tutorial - [XTLS Vision](https://github.com/chika0801/Xray-install) - [REALITY (English)](https://cscot.pages.dev/2023/03/02/Xray-REALITY-tutorial/) + - [XTLS-Iran-Reality (English)](https://github.com/SasukeFreestyle/XTLS-Iran-Reality) ## GUI Clients @@ -66,7 +68,7 @@ - [v2rayNG](https://github.com/2dust/v2rayNG) - [X-flutter](https://github.com/XTLS/X-flutter) - iOS & macOS arm64 - - [Mango](https://github.com/daemooon/Mango) + - [Mango](https://github.com/arror/Mango) - [Wings X](https://apps.apple.com/app/wings-x/id6446119727) - macOS arm64 & x64 - [V2RayXS](https://github.com/tzmax/V2RayXS) @@ -77,8 +79,11 @@ - iOS & macOS arm64 - [Shadowrocket](https://apps.apple.com/app/shadowrocket/id932747118) - [Stash](https://apps.apple.com/app/stash/id1596063349) -- API Wrapper +- Xray Wrapper - [xtlsapi](https://github.com/hiddify/xtlsapi) + - [AndroidLibXrayLite](https://github.com/2dust/AndroidLibXrayLite) + - [XrayKit](https://github.com/arror/XrayKit) + - [libxray](https://github.com/KouYiGuo/libxray) - [XrayR](https://github.com/XrayR-project/XrayR) - [XrayR-release](https://github.com/XrayR-project/XrayR-release) - [XrayR-V2Board](https://github.com/missuo/XrayR-V2Board) From d3060c28f826ba62f5f77085fa1dc2a20f5cd19f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 17 Apr 2023 23:22:12 +0000 Subject: [PATCH 033/867] v1.8.1 --- core/core.go | 2 +- go.mod | 29 +++++++++++++------------ go.sum | 61 ++++++++++++++++++++++++++-------------------------- 3 files changed, 47 insertions(+), 45 deletions(-) diff --git a/core/core.go b/core/core.go index 05148110..07ec158d 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 0 + Version_z byte = 1 ) var ( diff --git a/go.mod b/go.mod index fa91017b..879bd20d 100644 --- a/go.mod +++ b/go.mod @@ -12,16 +12,16 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.33.0 - github.com/refraction-networking/utls v1.3.1 - github.com/sagernet/sing v0.2.1 - github.com/sagernet/sing-shadowsocks v0.2.0 + github.com/refraction-networking/utls v1.3.2 + github.com/sagernet/sing v0.2.3 + github.com/sagernet/sing-shadowsocks v0.2.1 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.2 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230331223127-176a94313eda go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 - golang.org/x/crypto v0.7.0 + golang.org/x/crypto v0.8.0 golang.org/x/net v0.9.0 golang.org/x/sync v0.1.0 golang.org/x/sys v0.7.0 @@ -37,23 +37,24 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect github.com/francoispqt/gojay v1.2.13 // indirect - github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect + github.com/gaukas/godicttls v0.0.3 // indirect + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 // indirect - github.com/klauspost/compress v1.16.0 // indirect + github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect + github.com/klauspost/compress v1.16.5 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect - github.com/onsi/ginkgo/v2 v2.9.0 // indirect + github.com/onsi/ginkgo/v2 v2.9.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/quic-go/qtls-go1-19 v0.2.1 // indirect - github.com/quic-go/qtls-go1-20 v0.1.1 // indirect + github.com/quic-go/qtls-go1-19 v0.3.2 // indirect + github.com/quic-go/qtls-go1-20 v0.2.2 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect go.uber.org/atomic v1.10.0 // indirect - golang.org/x/exp v0.0.0-20230307190834-24139beb5833 // indirect - golang.org/x/mod v0.9.0 // indirect + golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect + golang.org/x/mod v0.10.0 // indirect golang.org/x/text v0.9.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.7.0 // indirect - google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 // indirect + golang.org/x/tools v0.8.0 // indirect + google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index a49be94a..b7e81d05 100644 --- a/go.sum +++ b/go.sum @@ -33,14 +33,16 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/gaukas/godicttls v0.0.3 h1:YNDIf0d9adcxOijiLrEzpfZGAkNwLRzPaG6OjU7EITk= +github.com/gaukas/godicttls v0.0.3/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3A65HN+7CMjSDP/gofXL4CZt1V4= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= @@ -76,8 +78,8 @@ github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+u github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10 h1:CqYfpuYIjnlNxM3msdyPRKabhXZWbKjf3Q8BWROFBso= -github.com/google/pprof v0.0.0-20230228050547-1710fef4ab10/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/pprof v0.0.0-20230406165453-00490a63f317 h1:hFhpt7CTmR3DX+b4R19ydQFtofxT0Sv3QsKNMVQYTMQ= +github.com/google/pprof v0.0.0-20230406165453-00490a63f317/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -91,8 +93,8 @@ github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= -github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= +github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= @@ -112,9 +114,9 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.9.0 h1:Tugw2BKlNHTMfG+CheOITkYvk4LAh6MFOvikhGVnhE8= -github.com/onsi/ginkgo/v2 v2.9.0/go.mod h1:4xkjoL/tZv4SMWeww56BU5kAt19mVB47gTWxmrTcxyk= -github.com/onsi/gomega v1.27.1 h1:rfztXRbg6nv/5f+Raen9RcGoSecHIFgBBLQK3Wdj754= +github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= +github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= +github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= @@ -130,21 +132,21 @@ github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1: github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/quic-go/qtls-go1-19 v0.2.1 h1:aJcKNMkH5ASEJB9FXNeZCyTEIHU1J7MmHyz1Q1TSG1A= -github.com/quic-go/qtls-go1-19 v0.2.1/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= -github.com/quic-go/qtls-go1-20 v0.1.1 h1:KbChDlg82d3IHqaj2bn6GfKRj84Per2VGf5XV3wSwQk= -github.com/quic-go/qtls-go1-20 v0.1.1/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= +github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc86Z5U= +github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= +github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= +github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0= github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA= -github.com/refraction-networking/utls v1.3.1 h1:3zVomUqx7nCmyGuU/6kYA/jp5NcqX8KQSGko8pY5Ch4= -github.com/refraction-networking/utls v1.3.1/go.mod h1:kHXvVB66a4BzVRYC4Em7e1HAfp7uwOCCw0+2CZ3sMY8= +github.com/refraction-networking/utls v1.3.2 h1:o+AkWB57mkcoW36ET7uJ002CpBWHu0KPxi6vzxvPnv8= +github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvjQpqP7L2vcm/9KUfm/E= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.1 h1:r0STYeyfKBBtoAHsBtW1dQonxG+3Qidde7/1VAMhdn8= -github.com/sagernet/sing v0.2.1/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= -github.com/sagernet/sing-shadowsocks v0.2.0 h1:ILDWL7pwWfkPLEbviE/MyCgfjaBmJY/JVVY+5jhSb58= -github.com/sagernet/sing-shadowsocks v0.2.0/go.mod h1:ysYzszRLpNzJSorvlWRMuzU6Vchsp7sd52q+JNY4axw= +github.com/sagernet/sing v0.2.3 h1:V50MvZ4c3Iij2lYFWPlzL1PyipwSzjGeN9x+Ox89vpk= +github.com/sagernet/sing v0.2.3/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= +github.com/sagernet/sing-shadowsocks v0.2.1 h1:FvdLQOqpvxHBJUcUe4fvgiYP2XLLwH5i1DtXQviVEPw= +github.com/sagernet/sing-shadowsocks v0.2.1/go.mod h1:T/OgurSjsAe+Ug3+6PprXjmgHFmJidjOvQcjXGTKb3I= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c/go.mod h1:euOmN6O5kk9dQmgSS8Df4psAl3TCjxOz0NW60EWkSaI= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= @@ -178,7 +180,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= @@ -203,18 +204,18 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= +golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= +golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230307190834-24139beb5833 h1:SChBja7BCQewoTAU7IgvucQKMIXrEpFxNMs0spT3/5s= -golang.org/x/exp v0.0.0-20230307190834-24139beb5833/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= +golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs= -golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -276,8 +277,8 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= +golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -296,8 +297,8 @@ google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4 h1:DdoeryqhaXp1LtT/emMP1BRJPHHKFi5akj/nbx/zNTA= -google.golang.org/genproto v0.0.0-20230306155012-7f2fa6fef1f4/go.mod h1:NWraEVixdDnqcqQ30jipen1STv2r/n24Wb7twVTGR4s= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= +google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= From ca32496a38f2727b2b7edfc92d3ac22feb95b6ad Mon Sep 17 00:00:00 2001 From: kunson Date: Mon, 17 Apr 2023 05:45:16 +0800 Subject: [PATCH 034/867] feat : support docker build --- .github/docker/Dockerfile | 21 +++++++++++++++ .github/docker/files/config.json | 19 ++++++++++++++ .github/workflows/docker.yml | 45 ++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 .github/docker/Dockerfile create mode 100644 .github/docker/files/config.json create mode 100644 .github/workflows/docker.yml diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile new file mode 100644 index 00000000..36f356f8 --- /dev/null +++ b/.github/docker/Dockerfile @@ -0,0 +1,21 @@ +# syntax=docker/dockerfile:1 +FROM --platform=$BUILDPLATFORM golang:alpine AS build +WORKDIR /src +COPY . . +ARG TARGETOS TARGETARCH +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main + +FROM --platform=${TARGETPLATFORM} alpine:latest +WORKDIR /root +COPY .github/docker/files/config.json /etc/xray/config.json +COPY --from=build /src/xray /usr/bin/xray +RUN set -ex \ + && apk add --no-cache tzdata ca-certificates \ + && mkdir -p /var/log/xray /usr/share/xray \ + && chmod +x /usr/bin/xray \ + && wget -O /usr/share/xray/geosite.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat \ + && wget -O /usr/share/xray/geoip.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat + +VOLUME /etc/xray +ENV TZ=Asia/Shanghai +CMD [ "/usr/bin/xray", "-config", "/etc/xray/config.json" ] \ No newline at end of file diff --git a/.github/docker/files/config.json b/.github/docker/files/config.json new file mode 100644 index 00000000..9dded728 --- /dev/null +++ b/.github/docker/files/config.json @@ -0,0 +1,19 @@ +{ + "inbounds": [{ + "port": 9000, + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "1eb6e917-774b-4a84-aff6-b058577c60a5", + "level": 1, + "alterId": 64 + } + ] + } + }], + "outbounds": [{ + "protocol": "freedom", + "settings": {} + }] +} \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..a9c4d5f8 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,45 @@ +name: Build docker image + +on: + push: + branches: + - '*' + +jobs: + build-image: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - uses: actions/checkout@v3 + - name: Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.actor }}/xray-core + flavor: latest=true + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - # Add support for more platforms with QEMU (optional) + # https://github.com/docker/setup-qemu-action + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + file: .github/docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 69aa3f48ccc36135c873d359ab5d6dabb0f3dde1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B0=E5=A4=A9=E9=9B=AA=E5=9C=B0?= Date: Thu, 20 Apr 2023 23:36:25 +0800 Subject: [PATCH 035/867] Fix : docker build when repo on organization. (#1973) * feat : support docker build * fix : ghcr build login when organization --------- Co-authored-by: kunson --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a9c4d5f8..4021b65f 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -16,7 +16,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: ghcr.io/${{ github.actor }}/xray-core + images: ghcr.io/${{ github.repository_owner }}/xray-core flavor: latest=true tags: | type=ref,event=branch @@ -26,7 +26,7 @@ jobs: uses: docker/login-action@v2 with: registry: ghcr.io - username: ${{ github.actor }} + username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - # Add support for more platforms with QEMU (optional) # https://github.com/docker/setup-qemu-action From d9994538bcf6e074c4f9cfa31331ed9cf6673221 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Apr 2023 00:58:54 +0000 Subject: [PATCH 036/867] Bump github.com/quic-go/quic-go from 0.33.0 to 0.34.0 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.33.0 to 0.34.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.33.0...v0.34.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 879bd20d..36733221 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/miekg/dns v1.1.53 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.33.0 + github.com/quic-go/quic-go v0.34.0 github.com/refraction-networking/utls v1.3.2 github.com/sagernet/sing v0.2.3 github.com/sagernet/sing-shadowsocks v0.2.1 diff --git a/go.sum b/go.sum index b7e81d05..4e681dc1 100644 --- a/go.sum +++ b/go.sum @@ -136,8 +136,8 @@ github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc8 github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= -github.com/quic-go/quic-go v0.33.0 h1:ItNoTDN/Fm/zBlq769lLJc8ECe9gYaW40veHCCco7y0= -github.com/quic-go/quic-go v0.33.0/go.mod h1:YMuhaAV9/jIu0XclDXwZPAsP/2Kgr5yMYhe9oxhhOFA= +github.com/quic-go/quic-go v0.34.0 h1:OvOJ9LFjTySgwOTYUZmNoq0FzVicP8YujpV0kB7m2lU= +github.com/quic-go/quic-go v0.34.0/go.mod h1:+4CVgVppm0FNjpG3UcX8Joi/frKOH7/ciD5yGcwOO1g= github.com/refraction-networking/utls v1.3.2 h1:o+AkWB57mkcoW36ET7uJ002CpBWHu0KPxi6vzxvPnv8= github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvjQpqP7L2vcm/9KUfm/E= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From 90d915ea0505e7d5172abc8aeda5d5d039696cb3 Mon Sep 17 00:00:00 2001 From: yichya QC Date: Sun, 12 Mar 2023 17:44:41 +0800 Subject: [PATCH 037/867] feat: add tcp_user_timeout ```json {"streamSettings":{"sockopt": {"tcpUserTimeout": 10000}}} ``` run `gofmt -w -s .` as well --- common/xudp/xudp_test.go | 4 +-- infra/conf/transport_internet.go | 2 ++ transport/internet/config.pb.go | 55 +++++++++++++++++------------ transport/internet/config.proto | 2 ++ transport/internet/sockopt_linux.go | 27 ++++++++------ 5 files changed, 55 insertions(+), 35 deletions(-) diff --git a/common/xudp/xudp_test.go b/common/xudp/xudp_test.go index dd720a81..78ddfa27 100644 --- a/common/xudp/xudp_test.go +++ b/common/xudp/xudp_test.go @@ -11,7 +11,7 @@ import ( func TestXudpReadWrite(t *testing.T) { addr, _ := net.ParseDestination("tcp:127.0.0.1:1345") mb := make(buf.MultiBuffer, 0, 16) - m := buf.MultiBufferContainer { + m := buf.MultiBufferContainer{ MultiBuffer: mb, } var arr [8]byte @@ -33,4 +33,4 @@ func TestXudpReadWrite(t *testing.T) { if dest[0].UDP.Port != 1345 { t.Error("failed to parse xudp buffer") } -} \ No newline at end of file +} diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 7424c548..976a49d4 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -617,6 +617,7 @@ type SocketConfig struct { TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"` TCPCongestion string `json:"tcpCongestion"` TCPWindowClamp int32 `json:"tcpWindowClamp"` + TCPUserTimeout int32 `json:"tcpUserTimeout"` V6only bool `json:"v6only"` Interface string `json:"interface"` } @@ -669,6 +670,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { TcpKeepAliveIdle: c.TCPKeepAliveIdle, TcpCongestion: c.TCPCongestion, TcpWindowClamp: c.TCPWindowClamp, + TcpUserTimeout: c.TCPUserTimeout, V6Only: c.V6only, Interface: c.Interface, }, nil diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 90dcd786..8021c6db 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -428,6 +428,7 @@ type SocketConfig struct { Interface string `protobuf:"bytes,13,opt,name=interface,proto3" json:"interface,omitempty"` V6Only bool `protobuf:"varint,14,opt,name=v6only,proto3" json:"v6only,omitempty"` TcpWindowClamp int32 `protobuf:"varint,15,opt,name=tcp_window_clamp,json=tcpWindowClamp,proto3" json:"tcp_window_clamp,omitempty"` + TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` } func (x *SocketConfig) Reset() { @@ -567,6 +568,13 @@ func (x *SocketConfig) GetTcpWindowClamp() int32 { return 0 } +func (x *SocketConfig) GetTcpUserTimeout() int32 { + if x != nil { + return x.TcpUserTimeout + } + return 0 +} + var File_transport_internet_config_proto protoreflect.FileDescriptor var file_transport_internet_config_proto_rawDesc = []byte{ @@ -619,7 +627,7 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x12, 0x30, 0x0a, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, - 0x78, 0x79, 0x22, 0xc8, 0x05, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, + 0x78, 0x79, 0x22, 0xf2, 0x05, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, @@ -660,27 +668,30 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, - 0x70, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x22, 0x2f, 0x0a, 0x0a, - 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, - 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, - 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x5a, 0x0a, - 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x6f, 0x6c, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x55, - 0x44, 0x50, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, - 0x0a, 0x09, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, - 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x05, 0x2a, 0x41, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, - 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, - 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, - 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x42, 0x67, 0x0a, 0x1b, - 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, - 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, - 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, + 0x74, 0x63, 0x70, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, + 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, 0x72, 0x54, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, + 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, + 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x5a, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x07, 0x0a, 0x03, + 0x54, 0x43, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x01, 0x12, 0x08, + 0x0a, 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, 0x62, 0x53, + 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, + 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, 0x6b, 0x65, + 0x74, 0x10, 0x05, 0x2a, 0x41, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, + 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, + 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, + 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, + 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/config.proto b/transport/internet/config.proto index 574d698e..1d5ef6bf 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -104,4 +104,6 @@ message SocketConfig { bool v6only = 14; int32 tcp_window_clamp = 15; + + int32 tcp_user_timeout = 16; } diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index ea023f53..7f366de8 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -7,13 +7,6 @@ import ( "golang.org/x/sys/unix" ) -const ( - // For incoming connections. - TCP_FASTOPEN = 23 - // For out-going connections. - TCP_FASTOPEN_CONNECT = 30 -) - func bindAddr(fd uintptr, ip []byte, port uint32) error { setReuseAddr(fd) setReusePort(fd) @@ -59,8 +52,8 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf tfo = 1 } if tfo >= 0 { - if err := syscall.SetsockoptInt(int(fd), syscall.SOL_TCP, TCP_FASTOPEN_CONNECT, tfo); err != nil { - return newError("failed to set TCP_FASTOPEN_CONNECT=", tfo).Base(err) + if err := syscall.SetsockoptInt(int(fd), syscall.SOL_TCP, unix.TCP_FASTOPEN_CONNECT, tfo); err != nil { + return newError("failed to set TCP_FASTOPEN_CONNECT", tfo).Base(err) } } @@ -95,6 +88,12 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf return newError("failed to set TCP_WINDOW_CLAMP", err) } } + + if config.TcpUserTimeout > 0 { + if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_USER_TIMEOUT, int(config.TcpUserTimeout)); err != nil { + return newError("failed to set TCP_USER_TIMEOUT", err) + } + } } if config.Tproxy.IsEnabled() { @@ -115,8 +114,8 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) if isTCPSocket(network) { tfo := config.ParseTFOValue() if tfo >= 0 { - if err := syscall.SetsockoptInt(int(fd), syscall.SOL_TCP, TCP_FASTOPEN, tfo); err != nil { - return newError("failed to set TCP_FASTOPEN=", tfo).Base(err) + if err := syscall.SetsockoptInt(int(fd), syscall.SOL_TCP, unix.TCP_FASTOPEN, tfo); err != nil { + return newError("failed to set TCP_FASTOPEN", tfo).Base(err) } } @@ -151,6 +150,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) return newError("failed to set TCP_WINDOW_CLAMP", err) } } + + if config.TcpUserTimeout > 0 { + if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_USER_TIMEOUT, int(config.TcpUserTimeout)); err != nil { + return newError("failed to set TCP_USER_TIMEOUT", err) + } + } } if config.Tproxy.IsEnabled() { From 18e5b0963f2c0f128ca0668ce237533bc8c7e71d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 23 Apr 2023 19:31:41 +0800 Subject: [PATCH 038/867] Update dependencies --- app/dispatcher/default.go | 40 +++--- app/proxyman/outbound/handler.go | 2 +- common/singbridge/destination.go | 46 +++++++ common/singbridge/dialer.go | 59 +++++++++ common/singbridge/error.go | 10 ++ common/singbridge/handler.go | 51 ++++++++ common/singbridge/logger.go | 71 +++++++++++ common/singbridge/packet.go | 82 ++++++++++++ common/singbridge/pipe.go | 61 +++++++++ common/singbridge/reader.go | 66 ++++++++++ go.mod | 2 +- go.sum | 2 + proxy/shadowsocks_2022/inbound.go | 18 +-- proxy/shadowsocks_2022/inbound_multi.go | 18 +-- proxy/shadowsocks_2022/inbound_relay.go | 20 ++- proxy/shadowsocks_2022/outbound.go | 24 +--- proxy/shadowsocks_2022/shadowsocks_2022.go | 142 --------------------- transport/internet/system_dialer.go | 16 +-- transport/internet/system_listener.go | 21 ++- transport/internet/system_listener_test.go | 10 +- 20 files changed, 523 insertions(+), 238 deletions(-) create mode 100644 common/singbridge/destination.go create mode 100644 common/singbridge/dialer.go create mode 100644 common/singbridge/error.go create mode 100644 common/singbridge/handler.go create mode 100644 common/singbridge/logger.go create mode 100644 common/singbridge/packet.go create mode 100644 common/singbridge/pipe.go create mode 100644 common/singbridge/reader.go diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 7328d213..35307cef 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -342,29 +342,27 @@ func (d *DefaultDispatcher) DispatchLink(ctx context.Context, destination net.De } sniffingRequest := content.SniffingRequest if !sniffingRequest.Enabled { - go d.routedDispatch(ctx, outbound, destination) + d.routedDispatch(ctx, outbound, destination) } else { - go func() { - cReader := &cachedReader{ - reader: outbound.Reader.(*pipe.Reader), + cReader := &cachedReader{ + reader: outbound.Reader.(*pipe.Reader), + } + outbound.Reader = cReader + result, err := sniffer(ctx, cReader, sniffingRequest.MetadataOnly, destination.Network) + if err == nil { + content.Protocol = result.Protocol() + } + if err == nil && d.shouldOverride(ctx, result, sniffingRequest, destination) { + domain := result.Domain() + newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx)) + destination.Address = net.ParseAddress(domain) + if sniffingRequest.RouteOnly && result.Protocol() != "fakedns" { + ob.RouteTarget = destination + } else { + ob.Target = destination } - outbound.Reader = cReader - result, err := sniffer(ctx, cReader, sniffingRequest.MetadataOnly, destination.Network) - if err == nil { - content.Protocol = result.Protocol() - } - if err == nil && d.shouldOverride(ctx, result, sniffingRequest, destination) { - domain := result.Domain() - newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx)) - destination.Address = net.ParseAddress(domain) - if sniffingRequest.RouteOnly && result.Protocol() != "fakedns" { - ob.RouteTarget = destination - } else { - ob.Target = destination - } - } - d.routedDispatch(ctx, outbound, destination) - }() + } + d.routedDispatch(ctx, outbound, destination) } return nil diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index e91bcb07..b477dd6b 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -211,7 +211,7 @@ out: err.WriteToLog(session.ExportIDToError(ctx)) common.Interrupt(link.Writer) } else { - common.Must(common.Close(link.Writer)) + common.Close(link.Writer) } common.Interrupt(link.Reader) } diff --git a/common/singbridge/destination.go b/common/singbridge/destination.go new file mode 100644 index 00000000..7a89c9ef --- /dev/null +++ b/common/singbridge/destination.go @@ -0,0 +1,46 @@ +package singbridge + +import ( + M "github.com/sagernet/sing/common/metadata" + N "github.com/sagernet/sing/common/network" + "github.com/xtls/xray-core/common/net" +) + +func ToNetwork(network string) net.Network { + switch N.NetworkName(network) { + case N.NetworkTCP: + return net.Network_TCP + case N.NetworkUDP: + return net.Network_UDP + default: + return net.Network_Unknown + } +} + +func ToDestination(socksaddr M.Socksaddr, network net.Network) net.Destination { + if socksaddr.IsFqdn() { + return net.Destination{ + Network: network, + Address: net.DomainAddress(socksaddr.Fqdn), + Port: net.Port(socksaddr.Port), + } + } else { + return net.Destination{ + Network: network, + Address: net.IPAddress(socksaddr.Addr.AsSlice()), + Port: net.Port(socksaddr.Port), + } + } +} + +func ToSocksaddr(destination net.Destination) M.Socksaddr { + var addr M.Socksaddr + switch destination.Address.Family() { + case net.AddressFamilyDomain: + addr.Fqdn = destination.Address.Domain() + default: + addr.Addr = M.AddrFromIP(destination.Address.IP()) + } + addr.Port = uint16(destination.Port) + return addr +} diff --git a/common/singbridge/dialer.go b/common/singbridge/dialer.go new file mode 100644 index 00000000..dfc128d8 --- /dev/null +++ b/common/singbridge/dialer.go @@ -0,0 +1,59 @@ +package singbridge + +import ( + "context" + "os" + + M "github.com/sagernet/sing/common/metadata" + N "github.com/sagernet/sing/common/network" + "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/proxy" + "github.com/xtls/xray-core/transport" + "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/pipe" +) + +var _ N.Dialer = (*XrayDialer)(nil) + +type XrayDialer struct { + internet.Dialer +} + +func NewDialer(dialer internet.Dialer) *XrayDialer { + return &XrayDialer{dialer} +} + +func (d *XrayDialer) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) { + return d.Dialer.Dial(ctx, ToDestination(destination, ToNetwork(network))) +} + +func (d *XrayDialer) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) { + return nil, os.ErrInvalid +} + +type XrayOutboundDialer struct { + outbound proxy.Outbound + dialer internet.Dialer +} + +func NewOutboundDialer(outbound proxy.Outbound, dialer internet.Dialer) *XrayOutboundDialer { + return &XrayOutboundDialer{outbound, dialer} +} + +func (d *XrayOutboundDialer) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) { + ctx = session.ContextWithOutbound(context.Background(), &session.Outbound{ + Target: ToDestination(destination, ToNetwork(network)), + }) + opts := []pipe.Option{pipe.WithSizeLimit(64 * 1024)} + uplinkReader, uplinkWriter := pipe.New(opts...) + downlinkReader, downlinkWriter := pipe.New(opts...) + conn := cnc.NewConnection(cnc.ConnectionInputMulti(downlinkWriter), cnc.ConnectionOutputMulti(uplinkReader)) + go d.outbound.Process(ctx, &transport.Link{Reader: downlinkReader, Writer: uplinkWriter}, d.dialer) + return conn, nil +} + +func (d *XrayOutboundDialer) ListenPacket(ctx context.Context, destination M.Socksaddr) (net.PacketConn, error) { + return nil, os.ErrInvalid +} diff --git a/common/singbridge/error.go b/common/singbridge/error.go new file mode 100644 index 00000000..ac9e6351 --- /dev/null +++ b/common/singbridge/error.go @@ -0,0 +1,10 @@ +package singbridge + +import E "github.com/sagernet/sing/common/exceptions" + +func ReturnError(err error) error { + if E.IsClosedOrCanceled(err) { + return nil + } + return err +} diff --git a/common/singbridge/handler.go b/common/singbridge/handler.go new file mode 100644 index 00000000..18d4ad71 --- /dev/null +++ b/common/singbridge/handler.go @@ -0,0 +1,51 @@ +package singbridge + +import ( + "context" + "io" + + M "github.com/sagernet/sing/common/metadata" + N "github.com/sagernet/sing/common/network" + "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/features/routing" + "github.com/xtls/xray-core/transport" +) + +var ( + _ N.TCPConnectionHandler = (*Dispatcher)(nil) + _ N.UDPConnectionHandler = (*Dispatcher)(nil) +) + +type Dispatcher struct { + upstream routing.Dispatcher + newErrorFunc func(values ...any) *errors.Error +} + +func NewDispatcher(dispatcher routing.Dispatcher, newErrorFunc func(values ...any) *errors.Error) *Dispatcher { + return &Dispatcher{ + upstream: dispatcher, + newErrorFunc: newErrorFunc, + } +} + +func (d *Dispatcher) NewConnection(ctx context.Context, conn net.Conn, metadata M.Metadata) error { + xConn := NewConn(conn) + return d.upstream.DispatchLink(ctx, ToDestination(metadata.Destination, net.Network_TCP), &transport.Link{ + Reader: xConn, + Writer: xConn, + }) +} + +func (d *Dispatcher) NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata M.Metadata) error { + return d.upstream.DispatchLink(ctx, ToDestination(metadata.Destination, net.Network_UDP), &transport.Link{ + Reader: buf.NewPacketReader(conn.(io.Reader)), + Writer: buf.NewWriter(conn.(io.Writer)), + }) +} + +func (d *Dispatcher) NewError(ctx context.Context, err error) { + d.newErrorFunc(err).WriteToLog(session.ExportIDToError(ctx)) +} diff --git a/common/singbridge/logger.go b/common/singbridge/logger.go new file mode 100644 index 00000000..c1702363 --- /dev/null +++ b/common/singbridge/logger.go @@ -0,0 +1,71 @@ +package singbridge + +import ( + "context" + + "github.com/sagernet/sing/common/logger" + "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/common/session" +) + +var _ logger.ContextLogger = (*XrayLogger)(nil) + +type XrayLogger struct { + newError func(values ...any) *errors.Error +} + +func NewLogger(newErrorFunc func(values ...any) *errors.Error) *XrayLogger { + return &XrayLogger{ + newErrorFunc, + } +} + +func (l *XrayLogger) Trace(args ...any) { +} + +func (l *XrayLogger) Debug(args ...any) { + l.newError(args...).AtDebug().WriteToLog() +} + +func (l *XrayLogger) Info(args ...any) { + l.newError(args...).AtInfo().WriteToLog() +} + +func (l *XrayLogger) Warn(args ...any) { + l.newError(args...).AtWarning().WriteToLog() +} + +func (l *XrayLogger) Error(args ...any) { + l.newError(args...).AtError().WriteToLog() +} + +func (l *XrayLogger) Fatal(args ...any) { +} + +func (l *XrayLogger) Panic(args ...any) { +} + +func (l *XrayLogger) TraceContext(ctx context.Context, args ...any) { +} + +func (l *XrayLogger) DebugContext(ctx context.Context, args ...any) { + l.newError(args...).AtDebug().WriteToLog(session.ExportIDToError(ctx)) +} + +func (l *XrayLogger) InfoContext(ctx context.Context, args ...any) { + l.newError(args...).AtInfo().WriteToLog(session.ExportIDToError(ctx)) +} + +func (l *XrayLogger) WarnContext(ctx context.Context, args ...any) { + l.newError(args...).AtWarning().WriteToLog(session.ExportIDToError(ctx)) +} + +func (l *XrayLogger) ErrorContext(ctx context.Context, args ...any) { + l.newError(args...).AtError().WriteToLog(session.ExportIDToError(ctx)) +} + +func (l *XrayLogger) FatalContext(ctx context.Context, args ...any) { +} + +func (l *XrayLogger) PanicContext(ctx context.Context, args ...any) { +} diff --git a/common/singbridge/packet.go b/common/singbridge/packet.go new file mode 100644 index 00000000..fef955e7 --- /dev/null +++ b/common/singbridge/packet.go @@ -0,0 +1,82 @@ +package singbridge + +import ( + "context" + + B "github.com/sagernet/sing/common/buf" + "github.com/sagernet/sing/common/bufio" + M "github.com/sagernet/sing/common/metadata" + "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/transport" +) + +func CopyPacketConn(ctx context.Context, inboundConn net.Conn, link *transport.Link, destination net.Destination, serverConn net.PacketConn) error { + conn := &PacketConnWrapper{ + Reader: link.Reader, + Writer: link.Writer, + Dest: destination, + Conn: inboundConn, + } + return ReturnError(bufio.CopyPacketConn(ctx, conn, bufio.NewPacketConn(serverConn))) +} + +type PacketConnWrapper struct { + buf.Reader + buf.Writer + net.Conn + Dest net.Destination + cached buf.MultiBuffer +} + +func (w *PacketConnWrapper) ReadPacket(buffer *B.Buffer) (M.Socksaddr, error) { + if w.cached != nil { + mb, bb := buf.SplitFirst(w.cached) + if bb == nil { + w.cached = nil + } else { + buffer.Write(bb.Bytes()) + w.cached = mb + var destination net.Destination + if bb.UDP != nil { + destination = *bb.UDP + } else { + destination = w.Dest + } + bb.Release() + return ToSocksaddr(destination), nil + } + } + mb, err := w.ReadMultiBuffer() + if err != nil { + return M.Socksaddr{}, err + } + nb, bb := buf.SplitFirst(mb) + if bb == nil { + return M.Socksaddr{}, nil + } else { + buffer.Write(bb.Bytes()) + w.cached = nb + var destination net.Destination + if bb.UDP != nil { + destination = *bb.UDP + } else { + destination = w.Dest + } + bb.Release() + return ToSocksaddr(destination), nil + } +} + +func (w *PacketConnWrapper) WritePacket(buffer *B.Buffer, destination M.Socksaddr) error { + vBuf := buf.New() + vBuf.Write(buffer.Bytes()) + endpoint := ToDestination(destination, net.Network_UDP) + vBuf.UDP = &endpoint + return w.Writer.WriteMultiBuffer(buf.MultiBuffer{vBuf}) +} + +func (w *PacketConnWrapper) Close() error { + buf.ReleaseMulti(w.cached) + return nil +} diff --git a/common/singbridge/pipe.go b/common/singbridge/pipe.go new file mode 100644 index 00000000..d04ebda4 --- /dev/null +++ b/common/singbridge/pipe.go @@ -0,0 +1,61 @@ +package singbridge + +import ( + "context" + "io" + "net" + + "github.com/sagernet/sing/common/bufio" + "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/transport" +) + +func CopyConn(ctx context.Context, inboundConn net.Conn, link *transport.Link, serverConn net.Conn) error { + conn := &PipeConnWrapper{ + W: link.Writer, + Conn: inboundConn, + } + if ir, ok := link.Reader.(io.Reader); ok { + conn.R = ir + } else { + conn.R = &buf.BufferedReader{Reader: link.Reader} + } + return ReturnError(bufio.CopyConn(ctx, conn, serverConn)) +} + +type PipeConnWrapper struct { + R io.Reader + W buf.Writer + net.Conn +} + +func (w *PipeConnWrapper) Close() error { + return nil +} + +func (w *PipeConnWrapper) Read(b []byte) (n int, err error) { + return w.R.Read(b) +} + +func (w *PipeConnWrapper) Write(p []byte) (n int, err error) { + n = len(p) + var mb buf.MultiBuffer + pLen := len(p) + for pLen > 0 { + buffer := buf.New() + if pLen > buf.Size { + _, err = buffer.Write(p[:buf.Size]) + p = p[buf.Size:] + } else { + buffer.Write(p) + } + pLen -= int(buffer.Len()) + mb = append(mb, buffer) + } + err = w.W.WriteMultiBuffer(mb) + if err != nil { + n = 0 + buf.ReleaseMulti(mb) + } + return +} diff --git a/common/singbridge/reader.go b/common/singbridge/reader.go new file mode 100644 index 00000000..1ace1845 --- /dev/null +++ b/common/singbridge/reader.go @@ -0,0 +1,66 @@ +package singbridge + +import ( + "time" + + "github.com/sagernet/sing/common" + "github.com/sagernet/sing/common/bufio" + N "github.com/sagernet/sing/common/network" + "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/net" +) + +var ( + _ buf.Reader = (*Conn)(nil) + _ buf.TimeoutReader = (*Conn)(nil) + _ buf.Writer = (*Conn)(nil) +) + +type Conn struct { + net.Conn + writer N.VectorisedWriter +} + +func NewConn(conn net.Conn) *Conn { + writer, _ := bufio.CreateVectorisedWriter(conn) + return &Conn{ + Conn: conn, + writer: writer, + } +} + +func (c *Conn) ReadMultiBuffer() (buf.MultiBuffer, error) { + buffer, err := buf.ReadBuffer(c.Conn) + if err != nil { + return nil, err + } + return buf.MultiBuffer{buffer}, nil +} + +func (c *Conn) ReadMultiBufferTimeout(duration time.Duration) (buf.MultiBuffer, error) { + err := c.SetReadDeadline(time.Now().Add(duration)) + if err != nil { + return nil, err + } + defer c.SetReadDeadline(time.Time{}) + return c.ReadMultiBuffer() +} + +func (c *Conn) WriteMultiBuffer(bufferList buf.MultiBuffer) error { + defer buf.ReleaseMulti(bufferList) + if c.writer != nil { + bytesList := make([][]byte, len(bufferList)) + for i, buffer := range bufferList { + bytesList[i] = buffer.Bytes() + } + return common.Error(bufio.WriteVectorised(c.writer, bytesList)) + } + // Since this conn is only used by tun, we don't force buffer writes to merge. + for _, buffer := range bufferList { + _, err := c.Conn.Write(buffer.Bytes()) + if err != nil { + return err + } + } + return nil +} diff --git a/go.mod b/go.mod index 36733221..bf6a6c3a 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.34.0 github.com/refraction-networking/utls v1.3.2 - github.com/sagernet/sing v0.2.3 + github.com/sagernet/sing v0.2.4 github.com/sagernet/sing-shadowsocks v0.2.1 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index 4e681dc1..f8df0400 100644 --- a/go.sum +++ b/go.sum @@ -145,6 +145,8 @@ github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstv github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/sagernet/sing v0.2.3 h1:V50MvZ4c3Iij2lYFWPlzL1PyipwSzjGeN9x+Ox89vpk= github.com/sagernet/sing v0.2.3/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= +github.com/sagernet/sing v0.2.4 h1:gC8BR5sglbJZX23RtMyFa8EETP9YEUADhfbEzU1yVbo= +github.com/sagernet/sing v0.2.4/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= github.com/sagernet/sing-shadowsocks v0.2.1 h1:FvdLQOqpvxHBJUcUe4fvgiYP2XLLwH5i1DtXQviVEPw= github.com/sagernet/sing-shadowsocks v0.2.1/go.mod h1:T/OgurSjsAe+Ug3+6PprXjmgHFmJidjOvQcjXGTKb3I= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= diff --git a/proxy/shadowsocks_2022/inbound.go b/proxy/shadowsocks_2022/inbound.go index 1c2ae1d2..bb298c09 100644 --- a/proxy/shadowsocks_2022/inbound.go +++ b/proxy/shadowsocks_2022/inbound.go @@ -17,6 +17,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/singbridge" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport/internet/stat" ) @@ -74,7 +75,7 @@ func (i *Inbound) Process(ctx context.Context, network net.Network, connection s ctx = session.ContextWithDispatcher(ctx, dispatcher) if network == net.Network_TCP { - return returnError(i.service.NewConnection(ctx, connection, metadata)) + return singbridge.ReturnError(i.service.NewConnection(ctx, connection, metadata)) } else { reader := buf.NewReader(connection) pc := &natPacketConn{connection} @@ -82,7 +83,7 @@ func (i *Inbound) Process(ctx context.Context, network net.Network, connection s mb, err := reader.ReadMultiBuffer() if err != nil { buf.ReleaseMulti(mb) - return returnError(err) + return singbridge.ReturnError(err) } for _, buffer := range mb { packet := B.As(buffer.Bytes()).ToOwned() @@ -112,16 +113,11 @@ func (i *Inbound) NewConnection(ctx context.Context, conn net.Conn, metadata M.M }) newError("tunnelling request to tcp:", metadata.Destination).WriteToLog(session.ExportIDToError(ctx)) dispatcher := session.DispatcherFromContext(ctx) - link, err := dispatcher.Dispatch(ctx, toDestination(metadata.Destination, net.Network_TCP)) + link, err := dispatcher.Dispatch(ctx, singbridge.ToDestination(metadata.Destination, net.Network_TCP)) if err != nil { return err } - outConn := &pipeConnWrapper{ - &buf.BufferedReader{Reader: link.Reader}, - link.Writer, - conn, - } - return bufio.CopyConn(ctx, conn, outConn) + return singbridge.CopyConn(ctx, nil, link, conn) } func (i *Inbound) NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata M.Metadata) error { @@ -138,12 +134,12 @@ func (i *Inbound) NewPacketConnection(ctx context.Context, conn N.PacketConn, me }) newError("tunnelling request to udp:", metadata.Destination).WriteToLog(session.ExportIDToError(ctx)) dispatcher := session.DispatcherFromContext(ctx) - destination := toDestination(metadata.Destination, net.Network_UDP) + destination := singbridge.ToDestination(metadata.Destination, net.Network_UDP) link, err := dispatcher.Dispatch(ctx, destination) if err != nil { return err } - outConn := &packetConnWrapper{ + outConn := &singbridge.PacketConnWrapper{ Reader: link.Reader, Writer: link.Writer, Dest: destination, diff --git a/proxy/shadowsocks_2022/inbound_multi.go b/proxy/shadowsocks_2022/inbound_multi.go index 77a34427..04cac573 100644 --- a/proxy/shadowsocks_2022/inbound_multi.go +++ b/proxy/shadowsocks_2022/inbound_multi.go @@ -21,6 +21,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/singbridge" "github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport/internet/stat" @@ -163,7 +164,7 @@ func (i *MultiUserInbound) Process(ctx context.Context, network net.Network, con ctx = session.ContextWithDispatcher(ctx, dispatcher) if network == net.Network_TCP { - return returnError(i.service.NewConnection(ctx, connection, metadata)) + return singbridge.ReturnError(i.service.NewConnection(ctx, connection, metadata)) } else { reader := buf.NewReader(connection) pc := &natPacketConn{connection} @@ -171,7 +172,7 @@ func (i *MultiUserInbound) Process(ctx context.Context, network net.Network, con mb, err := reader.ReadMultiBuffer() if err != nil { buf.ReleaseMulti(mb) - return returnError(err) + return singbridge.ReturnError(err) } for _, buffer := range mb { packet := B.As(buffer.Bytes()).ToOwned() @@ -203,16 +204,11 @@ func (i *MultiUserInbound) NewConnection(ctx context.Context, conn net.Conn, met }) newError("tunnelling request to tcp:", metadata.Destination).WriteToLog(session.ExportIDToError(ctx)) dispatcher := session.DispatcherFromContext(ctx) - link, err := dispatcher.Dispatch(ctx, toDestination(metadata.Destination, net.Network_TCP)) + link, err := dispatcher.Dispatch(ctx, singbridge.ToDestination(metadata.Destination, net.Network_TCP)) if err != nil { return err } - outConn := &pipeConnWrapper{ - &buf.BufferedReader{Reader: link.Reader}, - link.Writer, - conn, - } - return bufio.CopyConn(ctx, conn, outConn) + return singbridge.CopyConn(ctx, conn, link, conn) } func (i *MultiUserInbound) NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata M.Metadata) error { @@ -231,12 +227,12 @@ func (i *MultiUserInbound) NewPacketConnection(ctx context.Context, conn N.Packe }) newError("tunnelling request to udp:", metadata.Destination).WriteToLog(session.ExportIDToError(ctx)) dispatcher := session.DispatcherFromContext(ctx) - destination := toDestination(metadata.Destination, net.Network_UDP) + destination := singbridge.ToDestination(metadata.Destination, net.Network_UDP) link, err := dispatcher.Dispatch(ctx, destination) if err != nil { return err } - outConn := &packetConnWrapper{ + outConn := &singbridge.PacketConnWrapper{ Reader: link.Reader, Writer: link.Writer, Dest: destination, diff --git a/proxy/shadowsocks_2022/inbound_relay.go b/proxy/shadowsocks_2022/inbound_relay.go index d07babb8..c3f8e675 100644 --- a/proxy/shadowsocks_2022/inbound_relay.go +++ b/proxy/shadowsocks_2022/inbound_relay.go @@ -19,6 +19,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/singbridge" "github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport/internet/stat" @@ -66,7 +67,7 @@ func NewRelayServer(ctx context.Context, config *RelayServerConfig) (*RelayInbou C.MapIndexed(config.Destinations, func(index int, it *RelayDestination) int { return index }), C.Map(config.Destinations, func(it *RelayDestination) string { return it.Key }), C.Map(config.Destinations, func(it *RelayDestination) M.Socksaddr { - return toSocksaddr(net.Destination{ + return singbridge.ToSocksaddr(net.Destination{ Address: it.Address.AsAddress(), Port: net.Port(it.Port), }) @@ -95,7 +96,7 @@ func (i *RelayInbound) Process(ctx context.Context, network net.Network, connect ctx = session.ContextWithDispatcher(ctx, dispatcher) if network == net.Network_TCP { - return returnError(i.service.NewConnection(ctx, connection, metadata)) + return singbridge.ReturnError(i.service.NewConnection(ctx, connection, metadata)) } else { reader := buf.NewReader(connection) pc := &natPacketConn{connection} @@ -103,7 +104,7 @@ func (i *RelayInbound) Process(ctx context.Context, network net.Network, connect mb, err := reader.ReadMultiBuffer() if err != nil { buf.ReleaseMulti(mb) - return returnError(err) + return singbridge.ReturnError(err) } for _, buffer := range mb { packet := B.As(buffer.Bytes()).ToOwned() @@ -135,16 +136,11 @@ func (i *RelayInbound) NewConnection(ctx context.Context, conn net.Conn, metadat }) newError("tunnelling request to tcp:", metadata.Destination).WriteToLog(session.ExportIDToError(ctx)) dispatcher := session.DispatcherFromContext(ctx) - link, err := dispatcher.Dispatch(ctx, toDestination(metadata.Destination, net.Network_TCP)) + link, err := dispatcher.Dispatch(ctx, singbridge.ToDestination(metadata.Destination, net.Network_TCP)) if err != nil { return err } - outConn := &pipeConnWrapper{ - &buf.BufferedReader{Reader: link.Reader}, - link.Writer, - conn, - } - return bufio.CopyConn(ctx, conn, outConn) + return singbridge.CopyConn(ctx, nil, link, conn) } func (i *RelayInbound) NewPacketConnection(ctx context.Context, conn N.PacketConn, metadata M.Metadata) error { @@ -163,12 +159,12 @@ func (i *RelayInbound) NewPacketConnection(ctx context.Context, conn N.PacketCon }) newError("tunnelling request to udp:", metadata.Destination).WriteToLog(session.ExportIDToError(ctx)) dispatcher := session.DispatcherFromContext(ctx) - destination := toDestination(metadata.Destination, net.Network_UDP) + destination := singbridge.ToDestination(metadata.Destination, net.Network_UDP) link, err := dispatcher.Dispatch(ctx, destination) if err != nil { return err } - outConn := &packetConnWrapper{ + outConn := &singbridge.PacketConnWrapper{ Reader: link.Reader, Writer: link.Writer, Dest: destination, diff --git a/proxy/shadowsocks_2022/outbound.go b/proxy/shadowsocks_2022/outbound.go index 41e239dc..151ea0e2 100644 --- a/proxy/shadowsocks_2022/outbound.go +++ b/proxy/shadowsocks_2022/outbound.go @@ -2,7 +2,6 @@ package shadowsocks_2022 import ( "context" - "io" "runtime" "time" @@ -17,6 +16,7 @@ import ( "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/singbridge" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" ) @@ -93,7 +93,7 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int } if network == net.Network_TCP { - serverConn := o.method.DialEarlyConn(connection, toSocksaddr(destination)) + serverConn := o.method.DialEarlyConn(connection, singbridge.ToSocksaddr(destination)) var handshake bool if timeoutReader, isTimeoutReader := link.Reader.(buf.TimeoutReader); isTimeoutReader { mb, err := timeoutReader.ReadMultiBufferTimeout(time.Millisecond * 100) @@ -128,17 +128,7 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int return newError("client handshake").Base(err) } } - conn := &pipeConnWrapper{ - W: link.Writer, - Conn: inboundConn, - } - if ir, ok := link.Reader.(io.Reader); ok { - conn.R = ir - } else { - conn.R = &buf.BufferedReader{Reader: link.Reader} - } - - return returnError(bufio.CopyConn(ctx, conn, serverConn)) + return singbridge.CopyConn(ctx, inboundConn, link, serverConn) } else { var packetConn N.PacketConn if pc, isPacketConn := inboundConn.(N.PacketConn); isPacketConn { @@ -146,7 +136,7 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int } else if nc, isNetPacket := inboundConn.(net.PacketConn); isNetPacket { packetConn = bufio.NewPacketConn(nc) } else { - packetConn = &packetConnWrapper{ + packetConn = &singbridge.PacketConnWrapper{ Reader: link.Reader, Writer: link.Writer, Conn: inboundConn, @@ -155,14 +145,14 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int } if o.uotClient != nil { - uConn, err := o.uotClient.DialEarlyConn(o.method.DialEarlyConn(connection, uot.RequestDestination(o.uotClient.Version)), false, toSocksaddr(destination)) + uConn, err := o.uotClient.DialEarlyConn(o.method.DialEarlyConn(connection, uot.RequestDestination(o.uotClient.Version)), false, singbridge.ToSocksaddr(destination)) if err != nil { return err } - return returnError(bufio.CopyPacketConn(ctx, packetConn, uConn)) + return singbridge.ReturnError(bufio.CopyPacketConn(ctx, packetConn, uConn)) } else { serverConn := o.method.DialPacketConn(connection) - return returnError(bufio.CopyPacketConn(ctx, packetConn, serverConn)) + return singbridge.ReturnError(bufio.CopyPacketConn(ctx, packetConn, serverConn)) } } } diff --git a/proxy/shadowsocks_2022/shadowsocks_2022.go b/proxy/shadowsocks_2022/shadowsocks_2022.go index 945c4499..4f8d88ab 100644 --- a/proxy/shadowsocks_2022/shadowsocks_2022.go +++ b/proxy/shadowsocks_2022/shadowsocks_2022.go @@ -1,145 +1,3 @@ package shadowsocks_2022 -import ( - "io" - - B "github.com/sagernet/sing/common/buf" - E "github.com/sagernet/sing/common/exceptions" - M "github.com/sagernet/sing/common/metadata" - "github.com/xtls/xray-core/common/buf" - "github.com/xtls/xray-core/common/net" -) - //go:generate go run github.com/xtls/xray-core/common/errors/errorgen - -func toDestination(socksaddr M.Socksaddr, network net.Network) net.Destination { - if socksaddr.IsFqdn() { - return net.Destination{ - Network: network, - Address: net.DomainAddress(socksaddr.Fqdn), - Port: net.Port(socksaddr.Port), - } - } else { - return net.Destination{ - Network: network, - Address: net.IPAddress(socksaddr.Addr.AsSlice()), - Port: net.Port(socksaddr.Port), - } - } -} - -func toSocksaddr(destination net.Destination) M.Socksaddr { - var addr M.Socksaddr - switch destination.Address.Family() { - case net.AddressFamilyDomain: - addr.Fqdn = destination.Address.Domain() - default: - addr.Addr = M.AddrFromIP(destination.Address.IP()) - } - addr.Port = uint16(destination.Port) - return addr -} - -type pipeConnWrapper struct { - R io.Reader - W buf.Writer - net.Conn -} - -func (w *pipeConnWrapper) Close() error { - return nil -} - -func (w *pipeConnWrapper) Read(b []byte) (n int, err error) { - return w.R.Read(b) -} - -func (w *pipeConnWrapper) Write(p []byte) (n int, err error) { - n = len(p) - var mb buf.MultiBuffer - pLen := len(p) - for pLen > 0 { - buffer := buf.New() - if pLen > buf.Size { - _, err = buffer.Write(p[:buf.Size]) - p = p[buf.Size:] - } else { - buffer.Write(p) - } - pLen -= int(buffer.Len()) - mb = append(mb, buffer) - } - err = w.W.WriteMultiBuffer(mb) - if err != nil { - n = 0 - buf.ReleaseMulti(mb) - } - return -} - -type packetConnWrapper struct { - buf.Reader - buf.Writer - net.Conn - Dest net.Destination - cached buf.MultiBuffer -} - -func (w *packetConnWrapper) ReadPacket(buffer *B.Buffer) (M.Socksaddr, error) { - if w.cached != nil { - mb, bb := buf.SplitFirst(w.cached) - if bb == nil { - w.cached = nil - } else { - buffer.Write(bb.Bytes()) - w.cached = mb - var destination net.Destination - if bb.UDP != nil { - destination = *bb.UDP - } else { - destination = w.Dest - } - bb.Release() - return toSocksaddr(destination), nil - } - } - mb, err := w.ReadMultiBuffer() - if err != nil { - return M.Socksaddr{}, err - } - nb, bb := buf.SplitFirst(mb) - if bb == nil { - return M.Socksaddr{}, nil - } else { - buffer.Write(bb.Bytes()) - w.cached = nb - var destination net.Destination - if bb.UDP != nil { - destination = *bb.UDP - } else { - destination = w.Dest - } - bb.Release() - return toSocksaddr(destination), nil - } -} - -func (w *packetConnWrapper) WritePacket(buffer *B.Buffer, destination M.Socksaddr) error { - vBuf := buf.New() - vBuf.Write(buffer.Bytes()) - endpoint := toDestination(destination, net.Network_UDP) - vBuf.UDP = &endpoint - return w.Writer.WriteMultiBuffer(buf.MultiBuffer{vBuf}) -} - -func (w *packetConnWrapper) Close() error { - buf.ReleaseMulti(w.cached) - return nil -} - -func returnError(err error) error { - if E.IsClosed(err) { - return nil - } - return err -} diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index 93cf404e..5a68144d 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -5,6 +5,7 @@ import ( "syscall" "time" + "github.com/sagernet/sing/common/control" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/features/dns" @@ -18,7 +19,7 @@ type SystemDialer interface { } type DefaultSystemDialer struct { - controllers []controller + controllers []control.Func dns dns.Client obm outbound.Manager } @@ -81,6 +82,11 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne if sockopt != nil || len(d.controllers) > 0 { dialer.Control = func(network, address string, c syscall.RawConn) error { + for _, ctl := range d.controllers { + if err := ctl(network, address, c); err != nil { + newError("failed to apply external controller").Base(err).WriteToLog(session.ExportIDToError(ctx)) + } + } return c.Control(func(fd uintptr) { if sockopt != nil { if err := applyOutboundSocketOptions(network, address, fd, sockopt); err != nil { @@ -92,12 +98,6 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne } } } - - for _, ctl := range d.controllers { - if err := ctl(network, address, fd); err != nil { - newError("failed to apply external controller").Base(err).WriteToLog(session.ExportIDToError(ctx)) - } - } }) } } @@ -185,7 +185,7 @@ func UseAlternativeSystemDialer(dialer SystemDialer) { // It only works when effective dialer is the default dialer. // // xray:api:beta -func RegisterDialerController(ctl func(network, address string, fd uintptr) error) error { +func RegisterDialerController(ctl control.Func) error { if ctl == nil { return newError("nil listener controller") } diff --git a/transport/internet/system_listener.go b/transport/internet/system_listener.go index 04694383..60979062 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -10,21 +10,26 @@ import ( "time" "github.com/pires/go-proxyproto" + "github.com/sagernet/sing/common/control" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/session" ) var effectiveListener = DefaultListener{} -type controller func(network, address string, fd uintptr) error - type DefaultListener struct { - controllers []controller + controllers []control.Func } -func getControlFunc(ctx context.Context, sockopt *SocketConfig, controllers []controller) func(network, address string, c syscall.RawConn) error { +func getControlFunc(ctx context.Context, sockopt *SocketConfig, controllers []control.Func) func(network, address string, c syscall.RawConn) error { return func(network, address string, c syscall.RawConn) error { return c.Control(func(fd uintptr) { + for _, controller := range controllers { + if err := controller(network, address, c); err != nil { + newError("failed to apply external controller").Base(err).WriteToLog(session.ExportIDToError(ctx)) + } + } + if sockopt != nil { if err := applyInboundSocketOptions(network, fd, sockopt); err != nil { newError("failed to apply socket options to incoming connection").Base(err).WriteToLog(session.ExportIDToError(ctx)) @@ -32,12 +37,6 @@ func getControlFunc(ctx context.Context, sockopt *SocketConfig, controllers []co } setReusePort(fd) - - for _, controller := range controllers { - if err := controller(network, address, fd); err != nil { - newError("failed to apply external controller").Base(err).WriteToLog(session.ExportIDToError(ctx)) - } - } }) } } @@ -117,7 +116,7 @@ func (dl *DefaultListener) ListenPacket(ctx context.Context, addr net.Addr, sock // The controller can be used to operate on file descriptors before they are put into use. // // xray:api:beta -func RegisterListenerController(controller func(network, address string, fd uintptr) error) error { +func RegisterListenerController(controller control.Func) error { if controller == nil { return newError("nil listener controller") } diff --git a/transport/internet/system_listener_test.go b/transport/internet/system_listener_test.go index 0fcc9a95..390888e7 100644 --- a/transport/internet/system_listener_test.go +++ b/transport/internet/system_listener_test.go @@ -3,8 +3,10 @@ package internet_test import ( "context" "net" + "syscall" "testing" + "github.com/sagernet/sing/common/control" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/transport/internet" ) @@ -12,9 +14,11 @@ import ( func TestRegisterListenerController(t *testing.T) { var gotFd uintptr - common.Must(internet.RegisterListenerController(func(network string, addr string, fd uintptr) error { - gotFd = fd - return nil + common.Must(internet.RegisterListenerController(func(network, address string, conn syscall.RawConn) error { + return control.Raw(conn, func(fd uintptr) error { + gotFd = fd + return nil + }) })) conn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{ From dd81ad53425c656371089577ff1bb856239a9ca1 Mon Sep 17 00:00:00 2001 From: xqzr <34030394+xqzr@users.noreply.github.com> Date: Sun, 30 Apr 2023 08:03:30 +0800 Subject: [PATCH 039/867] Add `tcpMaxSeg` to `sockopt` (#2002) --- infra/conf/transport_internet.go | 2 ++ transport/internet/config.pb.go | 14 ++++++++++++-- transport/internet/config.proto | 2 ++ transport/internet/sockopt_linux.go | 13 +++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 976a49d4..0da0fb64 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -617,6 +617,7 @@ type SocketConfig struct { TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"` TCPCongestion string `json:"tcpCongestion"` TCPWindowClamp int32 `json:"tcpWindowClamp"` + TCPMaxSeg int32 `json:"tcpMaxSeg"` TCPUserTimeout int32 `json:"tcpUserTimeout"` V6only bool `json:"v6only"` Interface string `json:"interface"` @@ -670,6 +671,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { TcpKeepAliveIdle: c.TCPKeepAliveIdle, TcpCongestion: c.TCPCongestion, TcpWindowClamp: c.TCPWindowClamp, + TcpMaxSeg: c.TCPMaxSeg, TcpUserTimeout: c.TCPUserTimeout, V6Only: c.V6only, Interface: c.Interface, diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 8021c6db..1d16101c 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -429,6 +429,7 @@ type SocketConfig struct { V6Only bool `protobuf:"varint,14,opt,name=v6only,proto3" json:"v6only,omitempty"` TcpWindowClamp int32 `protobuf:"varint,15,opt,name=tcp_window_clamp,json=tcpWindowClamp,proto3" json:"tcp_window_clamp,omitempty"` TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` + TcpMaxSeg int32 `protobuf:"varint,17,opt,name=tcp_max_seg,json=tcpMaxSeg,proto3" json:"tcp_max_seg,omitempty"` } func (x *SocketConfig) Reset() { @@ -575,6 +576,13 @@ func (x *SocketConfig) GetTcpUserTimeout() int32 { return 0 } +func (x *SocketConfig) GetTcpMaxSeg() int32 { + if x != nil { + return x.TcpMaxSeg + } + return 0 +} + var File_transport_internet_config_proto protoreflect.FileDescriptor var file_transport_internet_config_proto_rawDesc = []byte{ @@ -627,7 +635,7 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x12, 0x30, 0x0a, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, - 0x78, 0x79, 0x22, 0xf2, 0x05, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, + 0x78, 0x79, 0x22, 0x92, 0x06, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, @@ -671,7 +679,9 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x70, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, 0x72, 0x54, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x61, + 0x78, 0x5f, 0x73, 0x65, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x63, 0x70, + 0x4d, 0x61, 0x78, 0x53, 0x65, 0x67, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x5a, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, diff --git a/transport/internet/config.proto b/transport/internet/config.proto index 1d5ef6bf..cbfd7b54 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -106,4 +106,6 @@ message SocketConfig { int32 tcp_window_clamp = 15; int32 tcp_user_timeout = 16; + + int32 tcp_max_seg = 17; } diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index 7f366de8..01888e94 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -94,6 +94,13 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf return newError("failed to set TCP_USER_TIMEOUT", err) } } + + if config.TcpMaxSeg > 0 { + if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_MAXSEG, int(config.TcpMaxSeg)); err != nil { + return newError("failed to set TCP_MAXSEG", err) + } + } + } if config.Tproxy.IsEnabled() { @@ -156,6 +163,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) return newError("failed to set TCP_USER_TIMEOUT", err) } } + + if config.TcpMaxSeg > 0 { + if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_MAXSEG, int(config.TcpMaxSeg)); err != nil { + return newError("failed to set TCP_MAXSEG", err) + } + } } if config.Tproxy.IsEnabled() { From ae518cce52935f423601fed973b6eb4f7bb64bf8 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 29 Apr 2023 23:05:53 -0400 Subject: [PATCH 040/867] Update docker.yml limit docker build to main branch --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4021b65f..6c51d0b5 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,7 +3,7 @@ name: Build docker image on: push: branches: - - '*' + - main jobs: build-image: @@ -42,4 +42,4 @@ jobs: file: .github/docker/Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file + labels: ${{ steps.meta.outputs.labels }} From bfd5da2f0020e9856602c1d624cdf2e7914e545e Mon Sep 17 00:00:00 2001 From: Zeyu Chen Date: Wed, 26 Apr 2023 22:35:12 +0800 Subject: [PATCH 041/867] fix: dns empty response --- app/dns/dns.go | 2 +- app/dns/dns_test.go | 3 ++- common/errors/multi_error.go | 17 +++++++++++++++++ proxy/dns/dns.go | 3 ++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/dns/dns.go b/app/dns/dns.go index af5f285b..6efcb825 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -215,7 +215,7 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, error) { newError("failed to lookup ip for domain ", domain, " at server ", client.Name()).Base(err).WriteToLog() errs = append(errs, err) } - if err != context.Canceled && err != context.DeadlineExceeded && err != errExpectedIPNonMatch { + if err != context.Canceled && err != context.DeadlineExceeded && err != errExpectedIPNonMatch && err != dns.ErrEmptyResponse { return nil, err } } diff --git a/app/dns/dns_test.go b/app/dns/dns_test.go index b3a8def8..74c7a125 100644 --- a/app/dns/dns_test.go +++ b/app/dns/dns_test.go @@ -13,6 +13,7 @@ import ( _ "github.com/xtls/xray-core/app/proxyman/outbound" "github.com/xtls/xray-core/app/router" "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/common/serial" "github.com/xtls/xray-core/core" @@ -260,7 +261,7 @@ func TestUDPServer(t *testing.T) { IPv6Enable: true, FakeEnable: false, }) - if err != feature_dns.ErrEmptyResponse { + if !errors.AllEqual(feature_dns.ErrEmptyResponse, errors.Cause(err)) { t.Fatal("error: ", err) } if len(ips) != 0 { diff --git a/common/errors/multi_error.go b/common/errors/multi_error.go index 8f19c97a..8066ac9e 100644 --- a/common/errors/multi_error.go +++ b/common/errors/multi_error.go @@ -28,3 +28,20 @@ func Combine(maybeError ...error) error { } return errs } + +func AllEqual(expected error, actual error) bool { + switch errs := actual.(type) { + case multiError: + if len(errs) == 0 { + return false + } + for _, err := range errs { + if err != expected { + return false + } + } + return true + default: + return errs == expected + } +} diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index be05e4f7..4aa5dac0 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -8,6 +8,7 @@ import ( "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" dns_proto "github.com/xtls/xray-core/common/protocol/dns" "github.com/xtls/xray-core/common/session" @@ -232,7 +233,7 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string, } rcode := dns.RCodeFromError(err) - if rcode == 0 && len(ips) == 0 && err != dns.ErrEmptyResponse { + if rcode == 0 && len(ips) == 0 && !errors.AllEqual(dns.ErrEmptyResponse, errors.Cause(err)) { newError("ip query").Base(err).WriteToLog() return } From f3231fb94e2b49d38f63451eae8279bd913f826c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 May 2023 01:07:41 +0000 Subject: [PATCH 042/867] Bump github.com/miekg/dns from 1.1.53 to 1.1.54 Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.53 to 1.1.54. - [Release notes](https://github.com/miekg/dns/releases) - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.53...v1.1.54) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index bf6a6c3a..67269489 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/golang/protobuf v1.5.3 github.com/google/go-cmp v0.5.9 github.com/gorilla/websocket v1.5.0 - github.com/miekg/dns v1.1.53 + github.com/miekg/dns v1.1.54 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.34.0 diff --git a/go.sum b/go.sum index f8df0400..eb711a08 100644 --- a/go.sum +++ b/go.sum @@ -108,8 +108,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= -github.com/miekg/dns v1.1.53 h1:ZBkuHr5dxHtB1caEOlZTLPo7D3L3TWckgUUs/RHfDxw= -github.com/miekg/dns v1.1.53/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= +github.com/miekg/dns v1.1.54 h1:5jon9mWcb0sFJGpnI99tOMhCPyJ+RPVz5b63MQG0VWI= +github.com/miekg/dns v1.1.54/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= @@ -143,8 +143,6 @@ github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvj github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.3 h1:V50MvZ4c3Iij2lYFWPlzL1PyipwSzjGeN9x+Ox89vpk= -github.com/sagernet/sing v0.2.3/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= github.com/sagernet/sing v0.2.4 h1:gC8BR5sglbJZX23RtMyFa8EETP9YEUADhfbEzU1yVbo= github.com/sagernet/sing v0.2.4/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= github.com/sagernet/sing-shadowsocks v0.2.1 h1:FvdLQOqpvxHBJUcUe4fvgiYP2XLLwH5i1DtXQviVEPw= From 37c8957495e43bc8d8826503885b0a3ab76b46a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 May 2023 00:59:55 +0000 Subject: [PATCH 043/867] Bump golang.org/x/sys from 0.7.0 to 0.8.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.7.0 to 0.8.0. - [Commits](https://github.com/golang/sys/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 67269489..0e5d650a 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( golang.org/x/crypto v0.8.0 golang.org/x/net v0.9.0 golang.org/x/sync v0.1.0 - golang.org/x/sys v0.7.0 + golang.org/x/sys v0.8.0 google.golang.org/grpc v1.54.0 google.golang.org/protobuf v1.30.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c diff --git a/go.sum b/go.sum index eb711a08..fbde3b7c 100644 --- a/go.sum +++ b/go.sum @@ -255,8 +255,8 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From a514d48baeec83432e4564acec87c38346de326d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 May 2023 14:20:07 +0000 Subject: [PATCH 044/867] Bump google.golang.org/grpc from 1.54.0 to 1.55.0 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.54.0 to 1.55.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.54.0...v1.55.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0e5d650a..3ccdc3f0 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/net v0.9.0 golang.org/x/sync v0.1.0 golang.org/x/sys v0.8.0 - google.golang.org/grpc v1.54.0 + google.golang.org/grpc v1.55.0 google.golang.org/protobuf v1.30.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index fbde3b7c..828788ea 100644 --- a/go.sum +++ b/go.sum @@ -305,8 +305,8 @@ google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3 google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.54.0 h1:EhTqbhiYeixwWQtAEZAxmV9MGqcjEU2mFx52xCzNyag= -google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= +google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= +google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From 1f2ffb522290a80c94325266c98e22582235bc51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 May 2023 14:20:07 +0000 Subject: [PATCH 045/867] Bump golang.org/x/sync from 0.1.0 to 0.2.0 Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.1.0 to 0.2.0. - [Commits](https://github.com/golang/sync/compare/v0.1.0...v0.2.0) --- updated-dependencies: - dependency-name: golang.org/x/sync dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3ccdc3f0..24b5980f 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 golang.org/x/crypto v0.8.0 golang.org/x/net v0.9.0 - golang.org/x/sync v0.1.0 + golang.org/x/sync v0.2.0 golang.org/x/sys v0.8.0 google.golang.org/grpc v1.55.0 google.golang.org/protobuf v1.30.0 diff --git a/go.sum b/go.sum index 828788ea..e797d88e 100644 --- a/go.sum +++ b/go.sum @@ -241,8 +241,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= +golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= From 6cc5d1de449365df5ecd56cd38cfea27d996a557 Mon Sep 17 00:00:00 2001 From: Hiddify <114227601+hiddify1@users.noreply.github.com> Date: Sat, 6 May 2023 04:20:50 +0200 Subject: [PATCH 046/867] Add HiddifyN and HiddifyNG to README/GUI Clients (#2028) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fb85b407..d0b3bbf4 100644 --- a/README.md +++ b/README.md @@ -63,9 +63,11 @@ - [luci-app-xray](https://github.com/yichya/luci-app-xray) ([openwrt-xray](https://github.com/yichya/openwrt-xray)) - Windows - [v2rayN](https://github.com/2dust/v2rayN) + - [HiddifyN](https://github.com/hiddify/HiddifyN) - [Invisible Man - Xray](https://github.com/InvisibleManVPN/InvisibleMan-XRayClient) - Android - [v2rayNG](https://github.com/2dust/v2rayNG) + - [HiddifyNG](https://github.com/hiddify/HiddifyNG) - [X-flutter](https://github.com/XTLS/X-flutter) - iOS & macOS arm64 - [Mango](https://github.com/arror/Mango) From d9af02812f22aad5d415fb0b01b855d21c2d1078 Mon Sep 17 00:00:00 2001 From: rurirei <72071920+rurirei@users.noreply.github.com> Date: Sat, 6 May 2023 03:18:08 +0000 Subject: [PATCH 047/867] Add ctx to UDP dispatcherConn (#2024) --- transport/internet/udp/dispatcher.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/transport/internet/udp/dispatcher.go b/transport/internet/udp/dispatcher.go index 48b90b63..32c8c8ac 100644 --- a/transport/internet/udp/dispatcher.go +++ b/transport/internet/udp/dispatcher.go @@ -142,12 +142,14 @@ type dispatcherConn struct { dispatcher *Dispatcher cache chan *udp.Packet done *done.Instance + ctx context.Context } func DialDispatcher(ctx context.Context, dispatcher routing.Dispatcher) (net.PacketConn, error) { c := &dispatcherConn{ cache: make(chan *udp.Packet, 16), done: done.New(), + ctx: ctx, } d := &Dispatcher{ @@ -197,8 +199,7 @@ func (c *dispatcherConn) WriteTo(p []byte, addr net.Addr) (int, error) { n := copy(raw, p) buffer.Resize(0, int32(n)) - ctx := context.Background() - c.dispatcher.Dispatch(ctx, net.DestinationFromAddr(addr), buffer) + c.dispatcher.Dispatch(c.ctx, net.DestinationFromAddr(addr), buffer) return n, nil } From ecedc5117334ac641ce7ed2b8f5c8cc486acdfe0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 May 2023 00:58:47 +0000 Subject: [PATCH 048/867] Bump golang.org/x/net from 0.9.0 to 0.10.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.9.0 to 0.10.0. - [Commits](https://github.com/golang/net/compare/v0.9.0...v0.10.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 24b5980f..e3cf7006 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/xtls/reality v0.0.0-20230331223127-176a94313eda go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 golang.org/x/crypto v0.8.0 - golang.org/x/net v0.9.0 + golang.org/x/net v0.10.0 golang.org/x/sync v0.2.0 golang.org/x/sys v0.8.0 google.golang.org/grpc v1.55.0 diff --git a/go.sum b/go.sum index e797d88e..7c2228f5 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From 70b8b2aaca72a5f67b33cdb5611ba195fdac1382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=97=8D+85CD?= <50108258+kwaa@users.noreply.github.com> Date: Tue, 9 May 2023 19:25:33 +0800 Subject: [PATCH 049/867] refactor(dockerfile): set entrypoint --- .github/docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index 36f356f8..ad1e8c3d 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -18,4 +18,5 @@ RUN set -ex \ VOLUME /etc/xray ENV TZ=Asia/Shanghai -CMD [ "/usr/bin/xray", "-config", "/etc/xray/config.json" ] \ No newline at end of file +ENTRYPOINT [ "/usr/bin/xray" ] +CMD [ "-config", "/etc/xray/config.json" ] From cb7e08100058e69725fd1b1fb4fae1fcf50e82c8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 14 May 2023 23:42:26 +0000 Subject: [PATCH 050/867] Bump golang.org/x/crypto from 0.8.0 to 0.9.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.8.0 to 0.9.0. - [Commits](https://github.com/golang/crypto/compare/v0.8.0...v0.9.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e3cf7006..506d830e 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230331223127-176a94313eda go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 - golang.org/x/crypto v0.8.0 + golang.org/x/crypto v0.9.0 golang.org/x/net v0.10.0 golang.org/x/sync v0.2.0 golang.org/x/sys v0.8.0 diff --git a/go.sum b/go.sum index 7c2228f5..40a1c4ee 100644 --- a/go.sum +++ b/go.sum @@ -204,8 +204,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ= -golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= From e7324700edf886afea14845c648f40abdf6e9818 Mon Sep 17 00:00:00 2001 From: jcdong98 Date: Fri, 12 May 2023 20:11:58 +0800 Subject: [PATCH 051/867] Fix memory leak caused by Wireguard outbound --- proxy/wireguard/wireguard.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/proxy/wireguard/wireguard.go b/proxy/wireguard/wireguard.go index 0d4994f5..53e7dcd5 100644 --- a/proxy/wireguard/wireguard.go +++ b/proxy/wireguard/wireguard.go @@ -152,6 +152,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte if err != nil { return newError("failed to create TCP connection").Base(err) } + defer conn.Close() requestFunc = func() error { defer timer.SetTimeout(p.Timeouts.DownlinkOnly) @@ -166,6 +167,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte if err != nil { return newError("failed to create UDP connection").Base(err) } + defer conn.Close() requestFunc = func() error { defer timer.SetTimeout(p.Timeouts.DownlinkOnly) @@ -183,6 +185,8 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte responseDonePost := task.OnSuccess(responseFunc, task.Close(link.Writer)) if err := task.Run(ctx, requestFunc, responseDonePost); err != nil { + common.Interrupt(link.Reader) + common.Interrupt(link.Writer) return newError("connection ends").Base(err) } From bb26f8576bc8bdcdc4b112314a9d6950b97b99ec Mon Sep 17 00:00:00 2001 From: Matin Baloochestani Date: Sat, 13 May 2023 22:41:23 +0330 Subject: [PATCH 052/867] Add Linux GUI client to README.md This commit adds v2rayA user interface (GUI) client. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index d0b3bbf4..5a096a9d 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ - macOS arm64 & x64 - [V2RayXS](https://github.com/tzmax/V2RayXS) - [Wings X](https://apps.apple.com/app/wings-x/id6446119727) +- Linux + - [v2rayA](https://github.com/v2rayA/v2rayA) ## Others that support VLESS, XTLS, REALITY, XUDP, PLUX... From f58fededc5a8f1d2095fc59784ac59f353b6a9b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 May 2023 00:59:23 +0000 Subject: [PATCH 053/867] Bump lukechampine.com/blake3 from 1.1.7 to 1.2.1 Bumps [lukechampine.com/blake3](https://github.com/lukechampine/blake3) from 1.1.7 to 1.2.1. - [Commits](https://github.com/lukechampine/blake3/compare/v1.1.7...v1.2.1) --- updated-dependencies: - dependency-name: lukechampine.com/blake3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 506d830e..936c6d57 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( google.golang.org/protobuf v1.30.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h12.io/socks v1.0.3 - lukechampine.com/blake3 v1.1.7 + lukechampine.com/blake3 v1.2.1 ) require ( diff --git a/go.sum b/go.sum index 40a1c4ee..4e9ca5ff 100644 --- a/go.sum +++ b/go.sum @@ -95,7 +95,6 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -339,7 +338,7 @@ honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= -lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= +lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= +lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= From 19d3a4faba312e00891e308a0192ba95d8f40209 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 May 2023 00:59:34 +0000 Subject: [PATCH 054/867] Bump github.com/stretchr/testify from 1.8.2 to 1.8.3 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.2 to 1.8.3. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.8.2...v1.8.3) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 936c6d57..41fa574e 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/sagernet/sing-shadowsocks v0.2.1 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.3 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230331223127-176a94313eda go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 diff --git a/go.sum b/go.sum index 4e9ca5ff..961f7d70 100644 --- a/go.sum +++ b/go.sum @@ -176,14 +176,10 @@ github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5k github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF8gHIiADmOVOV5LS43gt3ONnlEl3xkwI= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= From 51b29224274befd57ce2e9a5e1d28529b568f6a6 Mon Sep 17 00:00:00 2001 From: chika0801 <88967758+chika0801@users.noreply.github.com> Date: Sun, 21 May 2023 11:21:52 +0800 Subject: [PATCH 055/867] Replace Wings X with FoXray in README/GUI Clients (#2091) --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5a096a9d..bcbd7039 100644 --- a/README.md +++ b/README.md @@ -71,10 +71,10 @@ - [X-flutter](https://github.com/XTLS/X-flutter) - iOS & macOS arm64 - [Mango](https://github.com/arror/Mango) - - [Wings X](https://apps.apple.com/app/wings-x/id6446119727) + - [FoXray](https://apps.apple.com/app/foxray/id6448898396) - macOS arm64 & x64 - [V2RayXS](https://github.com/tzmax/V2RayXS) - - [Wings X](https://apps.apple.com/app/wings-x/id6446119727) + - [FoXray](https://apps.apple.com/app/foxray/id6448898396) - Linux - [v2rayA](https://github.com/v2rayA/v2rayA) @@ -87,7 +87,6 @@ - [xtlsapi](https://github.com/hiddify/xtlsapi) - [AndroidLibXrayLite](https://github.com/2dust/AndroidLibXrayLite) - [XrayKit](https://github.com/arror/XrayKit) - - [libxray](https://github.com/KouYiGuo/libxray) - [XrayR](https://github.com/XrayR-project/XrayR) - [XrayR-release](https://github.com/XrayR-project/XrayR-release) - [XrayR-V2Board](https://github.com/missuo/XrayR-V2Board) From c80646a045c2d8b2d7d68a63036f21c37c4c1c0d Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 20 May 2023 23:40:56 -0400 Subject: [PATCH 056/867] Clean code dependencies on github.com/miekg/dns (#2099) --- transport/internet/headers/dns/dns.go | 71 ++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/transport/internet/headers/dns/dns.go b/transport/internet/headers/dns/dns.go index a7366d1a..df209ff6 100644 --- a/transport/internet/headers/dns/dns.go +++ b/transport/internet/headers/dns/dns.go @@ -3,8 +3,8 @@ package dns import ( "context" "encoding/binary" + "errors" - "github.com/miekg/dns" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/dice" ) @@ -36,7 +36,7 @@ func NewDNS(ctx context.Context, config interface{}) (interface{}, error) { buf := make([]byte, 0x100) - off1, err := dns.PackDomainName(dns.Fqdn(config.(*Config).Domain), buf, 0, nil, false) + off1, err := packDomainName(config.(*Config).Domain + ".", buf) if err != nil { return nil, err } @@ -51,6 +51,73 @@ func NewDNS(ctx context.Context, config interface{}) (interface{}, error) { }, nil } +// copied from github.com/miekg/dns +func packDomainName(s string, msg []byte) (off1 int, err error) { + off := 0 + ls := len(s) + // Each dot ends a segment of the name. + // We trade each dot byte for a length byte. + // Except for escaped dots (\.), which are normal dots. + // There is also a trailing zero. + + // Emit sequence of counted strings, chopping at dots. + var ( + begin int + bs []byte + ) + for i := 0; i < ls; i++ { + var c byte + if bs == nil { + c = s[i] + } else { + c = bs[i] + } + + switch c { + case '\\': + if off+1 > len(msg) { + return len(msg), errors.New("buffer size too small") + } + + if bs == nil { + bs = []byte(s) + } + + copy(bs[i:ls-1], bs[i+1:]) + ls-- + case '.': + labelLen := i - begin + if labelLen >= 1<<6 { // top two bits of length must be clear + return len(msg), errors.New("bad rdata") + } + + // off can already (we're in a loop) be bigger than len(msg) + // this happens when a name isn't fully qualified + if off+1+labelLen > len(msg) { + return len(msg), errors.New("buffer size too small") + } + + // The following is covered by the length check above. + msg[off] = byte(labelLen) + + if bs == nil { + copy(msg[off+1:], s[begin:i]) + } else { + copy(msg[off+1:], bs[begin:i]) + } + off += 1 + labelLen + begin = i + 1 + default: + } + } + + if off < len(msg) { + msg[off] = 0 + } + + return off + 1, nil +} + func init() { common.Must(common.RegisterConfig((*Config)(nil), NewDNS)) } From 5f5ae375714abd67eb2f0a0f2e86410b6f29f7c2 Mon Sep 17 00:00:00 2001 From: sambali9 <120097517+sambali9@users.noreply.github.com> Date: Mon, 22 May 2023 04:59:58 +0200 Subject: [PATCH 057/867] Added tcp fragmentation for freedom outbound (#2021) * Added tcp fragmentation for freedom outbound * Added TCP_NODELAY to outbound sockopt * Changed fragment parameters to accept ranges and changed strategy to use length * Changed packetNumber to packets, supporting range. * Refactored the freedom fragment logic * Refine Write() --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- infra/conf/freedom.go | 98 +++++++++++- infra/conf/transport_internet.go | 6 +- proxy/freedom/config.pb.go | 208 +++++++++++++++++++++----- proxy/freedom/config.proto | 10 ++ proxy/freedom/freedom.go | 66 +++++++- transport/internet/config.pb.go | 56 ++++--- transport/internet/config.proto | 2 + transport/internet/sockopt_darwin.go | 6 + transport/internet/sockopt_linux.go | 6 + transport/internet/sockopt_windows.go | 5 + 10 files changed, 392 insertions(+), 71 deletions(-) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 60dfd5b8..b3790278 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -2,6 +2,7 @@ package conf import ( "net" + "strconv" "strings" "github.com/golang/protobuf/proto" @@ -11,10 +12,17 @@ import ( ) type FreedomConfig struct { - DomainStrategy string `json:"domainStrategy"` - Timeout *uint32 `json:"timeout"` - Redirect string `json:"redirect"` - UserLevel uint32 `json:"userLevel"` + DomainStrategy string `json:"domainStrategy"` + Timeout *uint32 `json:"timeout"` + Redirect string `json:"redirect"` + UserLevel uint32 `json:"userLevel"` + Fragment *Fragment `json:"fragment"` +} + +type Fragment struct { + Packets string `json:"packets"` + Length string `json:"length"` + Interval string `json:"interval"` } // Build implements Buildable @@ -30,6 +38,88 @@ func (c *FreedomConfig) Build() (proto.Message, error) { config.DomainStrategy = freedom.Config_USE_IP6 } + if c.Fragment != nil { + if len(c.Fragment.Interval) == 0 || len(c.Fragment.Length) == 0 { + return nil, newError("Invalid interval or length") + } + intervalMinMax := strings.Split(c.Fragment.Interval, "-") + var minInterval, maxInterval int64 + var err, err2 error + if len(intervalMinMax) == 2 { + minInterval, err = strconv.ParseInt(intervalMinMax[0], 10, 64) + maxInterval, err2 = strconv.ParseInt(intervalMinMax[1], 10, 64) + } else { + minInterval, err = strconv.ParseInt(intervalMinMax[0], 10, 64) + maxInterval = minInterval + } + if err != nil { + return nil, newError("Invalid minimum interval: ", err).Base(err) + } + if err2 != nil { + return nil, newError("Invalid maximum interval: ", err2).Base(err2) + } + + lengthMinMax := strings.Split(c.Fragment.Length, "-") + var minLength, maxLength int64 + if len(lengthMinMax) == 2 { + minLength, err = strconv.ParseInt(lengthMinMax[0], 10, 64) + maxLength, err2 = strconv.ParseInt(lengthMinMax[1], 10, 64) + + } else { + minLength, err = strconv.ParseInt(lengthMinMax[0], 10, 64) + maxLength = minLength + } + if err != nil { + return nil, newError("Invalid minimum length: ", err).Base(err) + } + if err2 != nil { + return nil, newError("Invalid maximum length: ", err2).Base(err2) + } + + if minInterval > maxInterval { + minInterval, maxInterval = maxInterval, minInterval + } + if minLength > maxLength { + minLength, maxLength = maxLength, minLength + } + + config.Fragment = &freedom.Fragment{ + MinInterval: int32(minInterval), + MaxInterval: int32(maxInterval), + MinLength: int32(minLength), + MaxLength: int32(maxLength), + } + + if len(c.Fragment.Packets) > 0 { + packetRange := strings.Split(c.Fragment.Packets, "-") + var startPacket, endPacket int64 + if len(packetRange) == 2 { + startPacket, err = strconv.ParseInt(packetRange[0], 10, 64) + endPacket, err2 = strconv.ParseInt(packetRange[1], 10, 64) + } else { + startPacket, err = strconv.ParseInt(packetRange[0], 10, 64) + endPacket = startPacket + } + if err != nil { + return nil, newError("Invalid start packet: ", err).Base(err) + } + if err2 != nil { + return nil, newError("Invalid end packet: ", err2).Base(err2) + } + if startPacket > endPacket { + return nil, newError("Invalid packet range: ", c.Fragment.Packets) + } + if startPacket < 1 { + return nil, newError("Cannot start from packet 0") + } + config.Fragment.StartPacket = int32(startPacket) + config.Fragment.EndPacket = int32(endPacket) + } else { + config.Fragment.StartPacket = 0 + config.Fragment.EndPacket = 0 + } + } + if c.Timeout != nil { config.Timeout = *c.Timeout } diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 0da0fb64..958edfad 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -617,7 +617,8 @@ type SocketConfig struct { TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"` TCPCongestion string `json:"tcpCongestion"` TCPWindowClamp int32 `json:"tcpWindowClamp"` - TCPMaxSeg int32 `json:"tcpMaxSeg"` + TCPMaxSeg int32 `json:"tcpMaxSeg"` + TcpNoDelay bool `json:"tcpNoDelay"` TCPUserTimeout int32 `json:"tcpUserTimeout"` V6only bool `json:"v6only"` Interface string `json:"interface"` @@ -671,7 +672,8 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { TcpKeepAliveIdle: c.TCPKeepAliveIdle, TcpCongestion: c.TCPCongestion, TcpWindowClamp: c.TCPWindowClamp, - TcpMaxSeg: c.TCPMaxSeg, + TcpMaxSeg: c.TCPMaxSeg, + TcpNoDelay: c.TcpNoDelay, TcpUserTimeout: c.TCPUserTimeout, V6Only: c.V6only, Interface: c.Interface, diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 5c95bce7..0bfc4cba 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -70,7 +70,7 @@ func (x Config_DomainStrategy) Number() protoreflect.EnumNumber { // Deprecated: Use Config_DomainStrategy.Descriptor instead. func (Config_DomainStrategy) EnumDescriptor() ([]byte, []int) { - return file_proxy_freedom_config_proto_rawDescGZIP(), []int{1, 0} + return file_proxy_freedom_config_proto_rawDescGZIP(), []int{2, 0} } type DestinationOverride struct { @@ -120,6 +120,93 @@ func (x *DestinationOverride) GetServer() *protocol.ServerEndpoint { return nil } +type Fragment struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MinInterval int32 `protobuf:"varint,1,opt,name=min_interval,json=minInterval,proto3" json:"min_interval,omitempty"` + MaxInterval int32 `protobuf:"varint,2,opt,name=max_interval,json=maxInterval,proto3" json:"max_interval,omitempty"` + MinLength int32 `protobuf:"varint,3,opt,name=min_length,json=minLength,proto3" json:"min_length,omitempty"` + MaxLength int32 `protobuf:"varint,4,opt,name=max_length,json=maxLength,proto3" json:"max_length,omitempty"` + StartPacket int32 `protobuf:"varint,5,opt,name=start_packet,json=startPacket,proto3" json:"start_packet,omitempty"` + EndPacket int32 `protobuf:"varint,6,opt,name=end_packet,json=endPacket,proto3" json:"end_packet,omitempty"` +} + +func (x *Fragment) Reset() { + *x = Fragment{} + if protoimpl.UnsafeEnabled { + mi := &file_proxy_freedom_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Fragment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Fragment) ProtoMessage() {} + +func (x *Fragment) ProtoReflect() protoreflect.Message { + mi := &file_proxy_freedom_config_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Fragment.ProtoReflect.Descriptor instead. +func (*Fragment) Descriptor() ([]byte, []int) { + return file_proxy_freedom_config_proto_rawDescGZIP(), []int{1} +} + +func (x *Fragment) GetMinInterval() int32 { + if x != nil { + return x.MinInterval + } + return 0 +} + +func (x *Fragment) GetMaxInterval() int32 { + if x != nil { + return x.MaxInterval + } + return 0 +} + +func (x *Fragment) GetMinLength() int32 { + if x != nil { + return x.MinLength + } + return 0 +} + +func (x *Fragment) GetMaxLength() int32 { + if x != nil { + return x.MaxLength + } + return 0 +} + +func (x *Fragment) GetStartPacket() int32 { + if x != nil { + return x.StartPacket + } + return 0 +} + +func (x *Fragment) GetEndPacket() int32 { + if x != nil { + return x.EndPacket + } + return 0 +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -130,12 +217,13 @@ type Config struct { Timeout uint32 `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` DestinationOverride *DestinationOverride `protobuf:"bytes,3,opt,name=destination_override,json=destinationOverride,proto3" json:"destination_override,omitempty"` UserLevel uint32 `protobuf:"varint,4,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` + Fragment *Fragment `protobuf:"bytes,5,opt,name=fragment,proto3" json:"fragment,omitempty"` } func (x *Config) Reset() { *x = Config{} if protoimpl.UnsafeEnabled { - mi := &file_proxy_freedom_config_proto_msgTypes[1] + mi := &file_proxy_freedom_config_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -148,7 +236,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_proxy_freedom_config_proto_msgTypes[1] + mi := &file_proxy_freedom_config_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -161,7 +249,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_proxy_freedom_config_proto_rawDescGZIP(), []int{1} + return file_proxy_freedom_config_proto_rawDescGZIP(), []int{2} } func (x *Config) GetDomainStrategy() Config_DomainStrategy { @@ -193,6 +281,13 @@ func (x *Config) GetUserLevel() uint32 { return 0 } +func (x *Config) GetFragment() *Fragment { + if x != nil { + return x.Fragment + } + return nil +} + var File_proxy_freedom_config_proto protoreflect.FileDescriptor var file_proxy_freedom_config_proto_rawDesc = []byte{ @@ -206,33 +301,50 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, - 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0xb8, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, - 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x1c, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, - 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07, 0x74, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x5a, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x13, 0x64, 0x65, - 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, - 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65, 0x6c, - 0x22, 0x41, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, - 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, - 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, - 0x36, 0x10, 0x03, 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x50, 0x01, 0x5a, - 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, - 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x2f, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0xd0, 0x01, 0x0a, 0x08, 0x46, 0x72, 0x61, + 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x6d, 0x69, 0x6e, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x61, 0x78, 0x5f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, + 0x6d, 0x61, 0x78, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, + 0x69, 0x6e, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x09, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x61, + 0x78, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, + 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x61, + 0x72, 0x74, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x1d, 0x0a, 0x0a, + 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x09, 0x65, 0x6e, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x22, 0xf2, 0x02, 0x0a, 0x06, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, + 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, + 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, + 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x1c, 0x0a, 0x07, 0x74, 0x69, + 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, + 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x5a, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, + 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74, + 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52, + 0x13, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, + 0x72, 0x69, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, + 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, + 0x76, 0x65, 0x6c, 0x12, 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, 0x6d, + 0x65, 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x41, 0x0a, + 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, + 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, + 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, + 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, + 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, + 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x66, 0x72, + 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -248,22 +360,24 @@ func file_proxy_freedom_config_proto_rawDescGZIP() []byte { } var file_proxy_freedom_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_proxy_freedom_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_proxy_freedom_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_proxy_freedom_config_proto_goTypes = []interface{}{ (Config_DomainStrategy)(0), // 0: xray.proxy.freedom.Config.DomainStrategy (*DestinationOverride)(nil), // 1: xray.proxy.freedom.DestinationOverride - (*Config)(nil), // 2: xray.proxy.freedom.Config - (*protocol.ServerEndpoint)(nil), // 3: xray.common.protocol.ServerEndpoint + (*Fragment)(nil), // 2: xray.proxy.freedom.Fragment + (*Config)(nil), // 3: xray.proxy.freedom.Config + (*protocol.ServerEndpoint)(nil), // 4: xray.common.protocol.ServerEndpoint } var file_proxy_freedom_config_proto_depIdxs = []int32{ - 3, // 0: xray.proxy.freedom.DestinationOverride.server:type_name -> xray.common.protocol.ServerEndpoint + 4, // 0: xray.proxy.freedom.DestinationOverride.server:type_name -> xray.common.protocol.ServerEndpoint 0, // 1: xray.proxy.freedom.Config.domain_strategy:type_name -> xray.proxy.freedom.Config.DomainStrategy 1, // 2: xray.proxy.freedom.Config.destination_override:type_name -> xray.proxy.freedom.DestinationOverride - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 2, // 3: xray.proxy.freedom.Config.fragment:type_name -> xray.proxy.freedom.Fragment + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_proxy_freedom_config_proto_init() } @@ -285,6 +399,18 @@ func file_proxy_freedom_config_proto_init() { } } file_proxy_freedom_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Fragment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proxy_freedom_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Config); i { case 0: return &v.state @@ -303,7 +429,7 @@ func file_proxy_freedom_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proxy_freedom_config_proto_rawDesc, NumEnums: 1, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/proxy/freedom/config.proto b/proxy/freedom/config.proto index 7578a43f..4422edd3 100644 --- a/proxy/freedom/config.proto +++ b/proxy/freedom/config.proto @@ -12,6 +12,15 @@ message DestinationOverride { xray.common.protocol.ServerEndpoint server = 1; } +message Fragment { + int32 min_interval = 1; + int32 max_interval = 2; + int32 min_length = 3; + int32 max_length = 4; + int32 start_packet = 5; + int32 end_packet = 6; +} + message Config { enum DomainStrategy { AS_IS = 0; @@ -23,4 +32,5 @@ message Config { uint32 timeout = 2 [deprecated = true]; DestinationOverride destination_override = 3; uint32 user_level = 4; + Fragment fragment = 5; } diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 93804a81..d5d147bd 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -4,6 +4,9 @@ package freedom import ( "context" + "crypto/rand" + "io" + "math/big" "time" "github.com/xtls/xray-core/common" @@ -169,7 +172,21 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte var writer buf.Writer if destination.Network == net.Network_TCP { - writer = buf.NewWriter(conn) + if h.config.Fragment != nil { + writer = buf.NewWriter( + &FragmentWriter{ + Writer: conn, + minLength: int(h.config.Fragment.MinLength), + maxLength: int(h.config.Fragment.MaxLength), + minInterval: time.Duration(h.config.Fragment.MinInterval) * time.Millisecond, + maxInterval: time.Duration(h.config.Fragment.MaxInterval) * time.Millisecond, + startPacket: int(h.config.Fragment.StartPacket), + endPacket: int(h.config.Fragment.EndPacket), + PacketCount: 0, + }) + } else { + writer = buf.NewWriter(conn) + } } else { writer = NewPacketWriter(conn, h, ctx, UDPOverride) } @@ -324,3 +341,50 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { } return nil } + +type FragmentWriter struct { + io.Writer + minLength int + maxLength int + minInterval time.Duration + maxInterval time.Duration + startPacket int + endPacket int + PacketCount int +} + +func (w *FragmentWriter) Write(buf []byte) (int, error) { + w.PacketCount += 1 + if (w.startPacket != 0 && (w.PacketCount < w.startPacket || w.PacketCount > w.endPacket)) || len(buf) <= w.minLength { + return w.Writer.Write(buf) + } + + nTotal := 0 + for { + randomBytesTo := int(randBetween(int64(w.minLength), int64(w.maxLength))) + nTotal + if randomBytesTo > len(buf) { + randomBytesTo = len(buf) + } + n, err := w.Writer.Write(buf[nTotal:randomBytesTo]) + if err != nil { + return nTotal + n, err + } + nTotal += n + + if nTotal >= len(buf) { + return nTotal, nil + } + + randomInterval := randBetween(int64(w.minInterval), int64(w.maxInterval)) + time.Sleep(time.Duration(randomInterval)) + } +} + +// stolen from github.com/xtls/xray-core/transport/internet/reality +func randBetween(left int64, right int64) int64 { + if left == right { + return left + } + bigInt, _ := rand.Int(rand.Reader, big.NewInt(right-left)) + return left + bigInt.Int64() +} diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 1d16101c..20b582c6 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v4.22.0 +// protoc v3.12.4 // source: transport/internet/config.proto package internet @@ -430,6 +430,7 @@ type SocketConfig struct { TcpWindowClamp int32 `protobuf:"varint,15,opt,name=tcp_window_clamp,json=tcpWindowClamp,proto3" json:"tcp_window_clamp,omitempty"` TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` TcpMaxSeg int32 `protobuf:"varint,17,opt,name=tcp_max_seg,json=tcpMaxSeg,proto3" json:"tcp_max_seg,omitempty"` + TcpNoDelay bool `protobuf:"varint,18,opt,name=tcp_no_delay,json=tcpNoDelay,proto3" json:"tcp_no_delay,omitempty"` } func (x *SocketConfig) Reset() { @@ -583,6 +584,13 @@ func (x *SocketConfig) GetTcpMaxSeg() int32 { return 0 } +func (x *SocketConfig) GetTcpNoDelay() bool { + if x != nil { + return x.TcpNoDelay + } + return false +} + var File_transport_internet_config_proto protoreflect.FileDescriptor var file_transport_internet_config_proto_rawDesc = []byte{ @@ -635,7 +643,7 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x12, 0x30, 0x0a, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, - 0x78, 0x79, 0x22, 0x92, 0x06, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, + 0x78, 0x79, 0x22, 0xb4, 0x06, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, @@ -681,27 +689,29 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x65, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x63, 0x70, - 0x4d, 0x61, 0x78, 0x53, 0x65, 0x67, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, - 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, - 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x5a, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x07, 0x0a, 0x03, - 0x54, 0x43, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x01, 0x12, 0x08, - 0x0a, 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, 0x62, 0x53, - 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, - 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, 0x6b, 0x65, - 0x74, 0x10, 0x05, 0x2a, 0x41, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, - 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, - 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, - 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, - 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x4d, 0x61, 0x78, 0x53, 0x65, 0x67, 0x12, 0x20, 0x0a, 0x0c, 0x74, 0x63, 0x70, 0x5f, 0x6e, 0x6f, + 0x5f, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x74, 0x63, + 0x70, 0x4e, 0x6f, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, + 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, + 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, + 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x5a, 0x0a, 0x11, 0x54, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x07, + 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x01, + 0x12, 0x08, 0x0a, 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, + 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, + 0x50, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, + 0x6b, 0x65, 0x74, 0x10, 0x05, 0x2a, 0x41, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, + 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, + 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, + 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, + 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/config.proto b/transport/internet/config.proto index cbfd7b54..7fdc8ca2 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -108,4 +108,6 @@ message SocketConfig { int32 tcp_user_timeout = 16; int32 tcp_max_seg = 17; + + bool tcp_no_delay = 18; } diff --git a/transport/internet/sockopt_darwin.go b/transport/internet/sockopt_darwin.go index 5a50efa7..37ced27b 100644 --- a/transport/internet/sockopt_darwin.go +++ b/transport/internet/sockopt_darwin.go @@ -126,6 +126,12 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf return newError("failed to unset SO_KEEPALIVE", err) } } + + if config.TcpNoDelay { + if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_NODELAY, 1); err != nil { + return newError("failed to set TCP_NODELAY", err) + } + } } return nil diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index 01888e94..56f24be8 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -101,6 +101,12 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf } } + if config.TcpNoDelay { + if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_NODELAY, 1); err != nil { + return newError("failed to set TCP_NODELAY", err) + } + } + } if config.Tproxy.IsEnabled() { diff --git a/transport/internet/sockopt_windows.go b/transport/internet/sockopt_windows.go index ccc7b039..703a53c2 100644 --- a/transport/internet/sockopt_windows.go +++ b/transport/internet/sockopt_windows.go @@ -34,6 +34,11 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf return newError("failed to unset SO_KEEPALIVE", err) } } + if config.TcpNoDelay { + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1); err != nil { + return newError("failed to set TCP_NODELAY", err) + } + } } return nil From 6b8e36f6eeacd6cd348547a9bde17b935720ae11 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 31 May 2023 00:59:03 +0000 Subject: [PATCH 058/867] Bump github.com/stretchr/testify from 1.8.3 to 1.8.4 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.3 to 1.8.4. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.8.3...v1.8.4) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 41fa574e..5d069097 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/sagernet/sing-shadowsocks v0.2.1 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb - github.com/stretchr/testify v1.8.3 + github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230331223127-176a94313eda go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 diff --git a/go.sum b/go.sum index 961f7d70..8efc6300 100644 --- a/go.sum +++ b/go.sum @@ -178,8 +178,8 @@ github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF8gHIiADmOVOV5LS43gt3ONnlEl3xkwI= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= From 86b4b81f1d126e9bb3c463c987e54e12a0177d02 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Jun 2023 00:59:07 +0000 Subject: [PATCH 059/867] Bump github.com/quic-go/quic-go from 0.34.0 to 0.35.1 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.34.0 to 0.35.1. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.34.0...v0.35.1) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- app/dns/nameserver_quic.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- transport/internet/quic/dialer.go | 16 ++++++++-------- transport/internet/quic/hub.go | 17 +++++++++-------- transport/internet/quic/qlogWriter.go | 4 +++- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index a362ec84..a312b784 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -374,7 +374,7 @@ func (s *QUICNameServer) openConnection() (quic.Connection, error) { HandshakeIdleTimeout: handshakeTimeout, } - conn, err := quic.DialAddrContext(context.Background(), s.destination.NetAddr(), tlsConfig.GetTLSConfig(tls.WithNextProto("http/1.1", http2.NextProtoTLS, NextProtoDQ)), quicConfig) + conn, err := quic.DialAddr(context.Background(), s.destination.NetAddr(), tlsConfig.GetTLSConfig(tls.WithNextProto("http/1.1", http2.NextProtoTLS, NextProtoDQ)), quicConfig) log.Record(&log.AccessMessage{ From: "DNS", To: s.destination, diff --git a/go.mod b/go.mod index 5d069097..883de3c9 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/miekg/dns v1.1.54 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.34.0 + github.com/quic-go/quic-go v0.35.1 github.com/refraction-networking/utls v1.3.2 github.com/sagernet/sing v0.2.4 github.com/sagernet/sing-shadowsocks v0.2.1 diff --git a/go.sum b/go.sum index 8efc6300..135e85e2 100644 --- a/go.sum +++ b/go.sum @@ -135,8 +135,8 @@ github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc8 github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= -github.com/quic-go/quic-go v0.34.0 h1:OvOJ9LFjTySgwOTYUZmNoq0FzVicP8YujpV0kB7m2lU= -github.com/quic-go/quic-go v0.34.0/go.mod h1:+4CVgVppm0FNjpG3UcX8Joi/frKOH7/ciD5yGcwOO1g= +github.com/quic-go/quic-go v0.35.1 h1:b0kzj6b/cQAf05cT0CkQubHM31wiA+xH3IBkxP62poo= +github.com/quic-go/quic-go v0.35.1/go.mod h1:+4CVgVppm0FNjpG3UcX8Joi/frKOH7/ciD5yGcwOO1g= github.com/refraction-networking/utls v1.3.2 h1:o+AkWB57mkcoW36ET7uJ002CpBWHu0KPxi6vzxvPnv8= github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvjQpqP7L2vcm/9KUfm/E= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= diff --git a/transport/internet/quic/dialer.go b/transport/internet/quic/dialer.go index 0b9483ce..f0d8e4e1 100644 --- a/transport/internet/quic/dialer.go +++ b/transport/internet/quic/dialer.go @@ -2,7 +2,6 @@ package quic import ( "context" - "io" "sync" "time" @@ -140,15 +139,13 @@ func (s *clientConnections) openConnection(ctx context.Context, destAddr net.Add } quicConfig := &quic.Config{ - ConnectionIDLength: 12, KeepAlivePeriod: 0, HandshakeIdleTimeout: time.Second * 8, MaxIdleTimeout: time.Second * 300, - Tracer: qlog.NewTracer(func(_ logging.Perspective, connID []byte) io.WriteCloser { - return &QlogWriter{connID: connID} - }), + Tracer: func(ctx context.Context, p logging.Perspective, ci quic.ConnectionID) logging.ConnectionTracer { + return qlog.NewConnectionTracer( &QlogWriter{connID: ci}, p, ci); + }, } - udpConn, _ := rawConn.(*net.UDPConn) if udpConn == nil { udpConn = rawConn.(*internet.PacketConnWrapper).Conn.(*net.UDPConn) @@ -158,8 +155,11 @@ func (s *clientConnections) openConnection(ctx context.Context, destAddr net.Add rawConn.Close() return nil, err } - - conn, err := quic.DialContext(context.Background(), sysConn, destAddr, "", tlsConfig.GetTLSConfig(tls.WithDestination(dest)), quicConfig) + tr := quic.Transport{ + ConnectionIDLength: 12, + Conn: sysConn, + } + conn, err := tr.Dial(context.Background(), destAddr, tlsConfig.GetTLSConfig(tls.WithDestination(dest)), quicConfig) if err != nil { sysConn.Close() return nil, err diff --git a/transport/internet/quic/hub.go b/transport/internet/quic/hub.go index 9b6481c5..15f072ec 100644 --- a/transport/internet/quic/hub.go +++ b/transport/internet/quic/hub.go @@ -2,7 +2,6 @@ package quic import ( "context" - "io" "time" "github.com/quic-go/quic-go" @@ -19,7 +18,7 @@ import ( // Listener is an internet.Listener that listens for TCP connections. type Listener struct { rawConn *sysConn - listener quic.Listener + listener *quic.Listener done *done.Instance addConn internet.ConnHandler } @@ -104,15 +103,14 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti } quicConfig := &quic.Config{ - ConnectionIDLength: 12, KeepAlivePeriod: 0, HandshakeIdleTimeout: time.Second * 8, MaxIdleTimeout: time.Second * 300, MaxIncomingStreams: 32, MaxIncomingUniStreams: -1, - Tracer: qlog.NewTracer(func(_ logging.Perspective, connID []byte) io.WriteCloser { - return &QlogWriter{connID: connID} - }), + Tracer: func(ctx context.Context, p logging.Perspective, ci quic.ConnectionID) logging.ConnectionTracer { + return qlog.NewConnectionTracer( &QlogWriter{connID: ci}, p, ci); + }, } conn, err := wrapSysConn(rawConn.(*net.UDPConn), config) @@ -120,8 +118,11 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti conn.Close() return nil, err } - - qListener, err := quic.Listen(conn, tlsConfig.GetTLSConfig(), quicConfig) + tr := quic.Transport{ + ConnectionIDLength: 12, + Conn: conn, + } + qListener, err := tr.Listen(tlsConfig.GetTLSConfig(), quicConfig) if err != nil { conn.Close() return nil, err diff --git a/transport/internet/quic/qlogWriter.go b/transport/internet/quic/qlogWriter.go index dd13f419..54284d29 100644 --- a/transport/internet/quic/qlogWriter.go +++ b/transport/internet/quic/qlogWriter.go @@ -1,7 +1,9 @@ package quic +import "github.com/quic-go/quic-go" + type QlogWriter struct { - connID []byte + connID quic.ConnectionID } func (w *QlogWriter) Write(b []byte) (int, error) { From a4e80f01e4c6fe6973fa4fc6cce0caf1843d183c Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 4 Jun 2023 08:45:38 -0400 Subject: [PATCH 060/867] Add tls serverName to DoQ --- app/dns/nameserver_quic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index a312b784..e82a6a3d 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -373,7 +373,7 @@ func (s *QUICNameServer) openConnection() (quic.Connection, error) { quicConfig := &quic.Config{ HandshakeIdleTimeout: handshakeTimeout, } - + tlsConfig.ServerName = s.destination.Address.String() conn, err := quic.DialAddr(context.Background(), s.destination.NetAddr(), tlsConfig.GetTLSConfig(tls.WithNextProto("http/1.1", http2.NextProtoTLS, NextProtoDQ)), quicConfig) log.Record(&log.AccessMessage{ From: "DNS", From 038f849dd314c60524f46f2db5a06f7f51562602 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 7 Jun 2023 18:33:16 +0000 Subject: [PATCH 061/867] Update README.md Co-authored-by: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Co-authored-by: yiguous <133725318+yiguous@users.noreply.github.com> --- README.md | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index bcbd7039..00a2a811 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ - [Marzban](https://github.com/Gozargah/Marzban) - [Libertea](https://github.com/VZiChoushaDui/Libertea) - One Click - - [Xray-script](https://github.com/kirin10000/Xray-script), [Xray-REALITY](https://github.com/zxcvos/Xray-script), [LetsXray](https://github.com/tdjnodj/LetsXray) - - [XTool](https://github.com/LordPenguin666/XTool), [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [xray-reality](https://github.com/sajjaddg/xray-reality) + - [Xray-REALITY](https://github.com/zxcvos/Xray-script), [xray-reality](https://github.com/sajjaddg/xray-reality), [reality-ezpz](https://github.com/aleskxyz/reality-ezpz) + - [Xray-script](https://github.com/kirin10000/Xray-script), [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [XTool](https://github.com/LordPenguin666/XTool) - [v2ray-agent](https://github.com/mack-a/v2ray-agent), [Xray_onekey](https://github.com/wulabing/Xray_onekey), [ProxySU](https://github.com/proxysu/ProxySU) - Magisk - [Xray4Magisk](https://github.com/Asterisk4Magisk/Xray4Magisk) @@ -82,8 +82,8 @@ - iOS & macOS arm64 - [Shadowrocket](https://apps.apple.com/app/shadowrocket/id932747118) - - [Stash](https://apps.apple.com/app/stash/id1596063349) - Xray Wrapper + - [XTLS/libXray](https://github.com/XTLS/libXray) - [xtlsapi](https://github.com/hiddify/xtlsapi) - [AndroidLibXrayLite](https://github.com/2dust/AndroidLibXrayLite) - [XrayKit](https://github.com/arror/XrayKit) @@ -106,23 +106,8 @@ ## Credits -This repo relies on the following third-party projects: - -- Special thanks: - - [v2fly/v2ray-core](https://github.com/v2fly/v2ray-core) -- In production: - - [ghodss/yaml](https://github.com/ghodss/yaml) - - [gorilla/websocket](https://github.com/gorilla/websocket) - - [quic-go/quic-go](https://github.com/quic-go/quic-go) - - [pelletier/go-toml](https://github.com/pelletier/go-toml) - - [pires/go-proxyproto](https://github.com/pires/go-proxyproto) - - [refraction-networking/utls](https://github.com/refraction-networking/utls) - - [seiflotfy/cuckoofilter](https://github.com/seiflotfy/cuckoofilter) - - [google/starlark-go](https://github.com/google/starlark-go) -- For testing only: - - [miekg/dns](https://github.com/miekg/dns) - - [stretchr/testify](https://github.com/stretchr/testify) - - [h12w/socks](https://github.com/h12w/socks) +- [Xray-core v1.0.0](https://github.com/XTLS/Xray-core/releases/tag/v1.0.0) was forked from [v2fly-core 9a03cc5](https://github.com/v2fly/v2ray-core/commit/9a03cc5c98d04cc28320fcee26dbc236b3291256), and we have made & accumulated a huge number of enhancements over time, check [the release notes for each version](https://github.com/XTLS/Xray-core/releases). +- For third-party projects used in [Xray-core](https://github.com/XTLS/Xray-core), check your local or [the latest go.mod](https://github.com/XTLS/Xray-core/blob/main/go.mod). ## Compilation From c9f517108cd731056383ee21effd742a3e86f87c Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Tue, 6 Jun 2023 23:38:34 -0400 Subject: [PATCH 062/867] Remove mtproto --- infra/conf/mtproto.go | 67 -------- infra/conf/mtproto_test.go | 40 ----- infra/conf/xray.go | 2 - main/distro/all/all.go | 1 - proxy/mtproto/auth.go | 148 ---------------- proxy/mtproto/auth_test.go | 52 ------ proxy/mtproto/client.go | 76 --------- proxy/mtproto/config.go | 24 --- proxy/mtproto/config.pb.go | 272 ------------------------------ proxy/mtproto/config.proto | 22 --- proxy/mtproto/errors.generated.go | 9 - proxy/mtproto/mtproto.go | 3 - proxy/mtproto/server.go | 160 ------------------ 13 files changed, 876 deletions(-) delete mode 100644 infra/conf/mtproto.go delete mode 100644 infra/conf/mtproto_test.go delete mode 100644 proxy/mtproto/auth.go delete mode 100644 proxy/mtproto/auth_test.go delete mode 100644 proxy/mtproto/client.go delete mode 100644 proxy/mtproto/config.go delete mode 100644 proxy/mtproto/config.pb.go delete mode 100644 proxy/mtproto/config.proto delete mode 100644 proxy/mtproto/errors.generated.go delete mode 100644 proxy/mtproto/mtproto.go delete mode 100644 proxy/mtproto/server.go diff --git a/infra/conf/mtproto.go b/infra/conf/mtproto.go deleted file mode 100644 index 88b02af5..00000000 --- a/infra/conf/mtproto.go +++ /dev/null @@ -1,67 +0,0 @@ -package conf - -import ( - "encoding/hex" - "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" -) - -type MTProtoAccount struct { - Secret string `json:"secret"` -} - -// Build implements Buildable -func (a *MTProtoAccount) Build() (*mtproto.Account, error) { - if len(a.Secret) != 32 { - return nil, newError("MTProto secret must have 32 chars") - } - secret, err := hex.DecodeString(a.Secret) - if err != nil { - return nil, newError("failed to decode secret: ", a.Secret).Base(err) - } - return &mtproto.Account{ - Secret: secret, - }, nil -} - -type MTProtoServerConfig struct { - Users []json.RawMessage `json:"users"` -} - -func (c *MTProtoServerConfig) Build() (proto.Message, error) { - config := &mtproto.ServerConfig{} - - if len(c.Users) == 0 { - return nil, newError("zero MTProto users configured.") - } - config.User = make([]*protocol.User, len(c.Users)) - for idx, rawData := range c.Users { - user := new(protocol.User) - if err := json.Unmarshal(rawData, user); err != nil { - return nil, newError("invalid MTProto user").Base(err) - } - account := new(MTProtoAccount) - if err := json.Unmarshal(rawData, account); err != nil { - return nil, newError("invalid MTProto user").Base(err) - } - accountProto, err := account.Build() - if err != nil { - return nil, newError("failed to parse MTProto user").Base(err) - } - user.Account = serial.ToTypedMessage(accountProto) - config.User[idx] = user - } - - return config, nil -} - -type MTProtoClientConfig struct{} - -func (c *MTProtoClientConfig) Build() (proto.Message, error) { - config := new(mtproto.ClientConfig) - return config, nil -} diff --git a/infra/conf/mtproto_test.go b/infra/conf/mtproto_test.go deleted file mode 100644 index f44cb19a..00000000 --- a/infra/conf/mtproto_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package conf_test - -import ( - "testing" - - "github.com/xtls/xray-core/common/protocol" - "github.com/xtls/xray-core/common/serial" - . "github.com/xtls/xray-core/infra/conf" - "github.com/xtls/xray-core/proxy/mtproto" -) - -func TestMTProtoServerConfig(t *testing.T) { - creator := func() Buildable { - return new(MTProtoServerConfig) - } - - runMultiTestCase(t, []TestCase{ - { - Input: `{ - "users": [{ - "email": "love@example.com", - "level": 1, - "secret": "b0cbcef5a486d9636472ac27f8e11a9d" - }] - }`, - Parser: loadJSON(creator), - Output: &mtproto.ServerConfig{ - User: []*protocol.User{ - { - Email: "love@example.com", - Level: 1, - Account: serial.ToTypedMessage(&mtproto.Account{ - Secret: []byte{176, 203, 206, 245, 164, 134, 217, 99, 100, 114, 172, 39, 248, 225, 26, 157}, - }), - }, - }, - }, - }, - }) -} diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 8b6d05f4..7bfc53e3 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -24,7 +24,6 @@ var ( "vless": func() interface{} { return new(VLessInboundConfig) }, "vmess": func() interface{} { return new(VMessInboundConfig) }, "trojan": func() interface{} { return new(TrojanServerConfig) }, - "mtproto": func() interface{} { return new(MTProtoServerConfig) }, }, "protocol", "settings") outboundConfigLoader = NewJSONConfigLoader(ConfigCreatorCache{ @@ -37,7 +36,6 @@ var ( "vless": func() interface{} { return new(VLessOutboundConfig) }, "vmess": func() interface{} { return new(VMessOutboundConfig) }, "trojan": func() interface{} { return new(TrojanClientConfig) }, - "mtproto": func() interface{} { return new(MTProtoClientConfig) }, "dns": func() interface{} { return new(DNSOutboundConfig) }, "wireguard": func() interface{} { return new(WireGuardConfig) }, }, "protocol", "settings") diff --git a/main/distro/all/all.go b/main/distro/all/all.go index 0e38fcf6..d383e043 100644 --- a/main/distro/all/all.go +++ b/main/distro/all/all.go @@ -40,7 +40,6 @@ import ( _ "github.com/xtls/xray-core/proxy/freedom" _ "github.com/xtls/xray-core/proxy/http" _ "github.com/xtls/xray-core/proxy/loopback" - _ "github.com/xtls/xray-core/proxy/mtproto" _ "github.com/xtls/xray-core/proxy/shadowsocks" _ "github.com/xtls/xray-core/proxy/socks" _ "github.com/xtls/xray-core/proxy/trojan" diff --git a/proxy/mtproto/auth.go b/proxy/mtproto/auth.go deleted file mode 100644 index cdd66d6f..00000000 --- a/proxy/mtproto/auth.go +++ /dev/null @@ -1,148 +0,0 @@ -package mtproto - -import ( - "context" - "crypto/rand" - "crypto/sha256" - "io" - "sync" - - "github.com/xtls/xray-core/common" -) - -const ( - HeaderSize = 64 -) - -type SessionContext struct { - ConnectionType [4]byte - DataCenterID uint16 -} - -func DefaultSessionContext() SessionContext { - return SessionContext{ - ConnectionType: [4]byte{0xef, 0xef, 0xef, 0xef}, - DataCenterID: 0, - } -} - -type contextKey int32 - -const ( - sessionContextKey contextKey = iota -) - -func ContextWithSessionContext(ctx context.Context, c SessionContext) context.Context { - return context.WithValue(ctx, sessionContextKey, c) -} - -func SessionContextFromContext(ctx context.Context) SessionContext { - if c := ctx.Value(sessionContextKey); c != nil { - return c.(SessionContext) - } - return DefaultSessionContext() -} - -type Authentication struct { - Header [HeaderSize]byte - DecodingKey [32]byte - EncodingKey [32]byte - DecodingNonce [16]byte - EncodingNonce [16]byte -} - -func (a *Authentication) DataCenterID() uint16 { - x := ((int16(a.Header[61]) << 8) | int16(a.Header[60])) - if x < 0 { - x = -x - } - return uint16(x) - 1 -} - -func (a *Authentication) ConnectionType() [4]byte { - var x [4]byte - copy(x[:], a.Header[56:60]) - return x -} - -func (a *Authentication) ApplySecret(b []byte) { - a.DecodingKey = sha256.Sum256(append(a.DecodingKey[:], b...)) - a.EncodingKey = sha256.Sum256(append(a.EncodingKey[:], b...)) -} - -func generateRandomBytes(random []byte, connType [4]byte) { - for { - common.Must2(rand.Read(random)) - - if random[0] == 0xef { - continue - } - - val := (uint32(random[3]) << 24) | (uint32(random[2]) << 16) | (uint32(random[1]) << 8) | uint32(random[0]) - if val == 0x44414548 || val == 0x54534f50 || val == 0x20544547 || val == 0x4954504f || val == 0xeeeeeeee { - continue - } - - if (uint32(random[7])<<24)|(uint32(random[6])<<16)|(uint32(random[5])<<8)|uint32(random[4]) == 0x00000000 { - continue - } - - copy(random[56:60], connType[:]) - - return - } -} - -func NewAuthentication(sc SessionContext) *Authentication { - auth := getAuthenticationObject() - random := auth.Header[:] - generateRandomBytes(random, sc.ConnectionType) - copy(auth.EncodingKey[:], random[8:]) - copy(auth.EncodingNonce[:], random[8+32:]) - keyivInverse := Inverse(random[8 : 8+32+16]) - copy(auth.DecodingKey[:], keyivInverse) - copy(auth.DecodingNonce[:], keyivInverse[32:]) - return auth -} - -func ReadAuthentication(reader io.Reader) (*Authentication, error) { - auth := getAuthenticationObject() - - if _, err := io.ReadFull(reader, auth.Header[:]); err != nil { - putAuthenticationObject(auth) - return nil, err - } - - copy(auth.DecodingKey[:], auth.Header[8:]) - copy(auth.DecodingNonce[:], auth.Header[8+32:]) - keyivInverse := Inverse(auth.Header[8 : 8+32+16]) - copy(auth.EncodingKey[:], keyivInverse) - copy(auth.EncodingNonce[:], keyivInverse[32:]) - - return auth, nil -} - -// Inverse returns a new byte array. It is a sequence of bytes when the input is read from end to beginning.Inverse -// Visible for testing only. -func Inverse(b []byte) []byte { - lenb := len(b) - b2 := make([]byte, lenb) - for i, v := range b { - b2[lenb-i-1] = v - } - return b2 -} - -var authPool = sync.Pool{ - New: func() interface{} { - return new(Authentication) - }, -} - -func getAuthenticationObject() *Authentication { - return authPool.Get().(*Authentication) -} - -func putAuthenticationObject(auth *Authentication) { - authPool.Put(auth) -} diff --git a/proxy/mtproto/auth_test.go b/proxy/mtproto/auth_test.go deleted file mode 100644 index a05bc743..00000000 --- a/proxy/mtproto/auth_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package mtproto_test - -import ( - "bytes" - "crypto/rand" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/xtls/xray-core/common" - . "github.com/xtls/xray-core/proxy/mtproto" -) - -func TestInverse(t *testing.T) { - const size = 64 - b := make([]byte, 64) - for b[0] == b[size-1] { - common.Must2(rand.Read(b)) - } - - bi := Inverse(b) - if b[0] == bi[0] { - t.Fatal("seems bytes are not inversed: ", b[0], "vs", bi[0]) - } - - bii := Inverse(bi) - if r := cmp.Diff(bii, b); r != "" { - t.Fatal(r) - } -} - -func TestAuthenticationReadWrite(t *testing.T) { - a := NewAuthentication(DefaultSessionContext()) - b := bytes.NewReader(a.Header[:]) - a2, err := ReadAuthentication(b) - common.Must(err) - - if r := cmp.Diff(a.EncodingKey[:], a2.DecodingKey[:]); r != "" { - t.Error("decoding key: ", r) - } - - if r := cmp.Diff(a.EncodingNonce[:], a2.DecodingNonce[:]); r != "" { - t.Error("decoding nonce: ", r) - } - - if r := cmp.Diff(a.DecodingKey[:], a2.EncodingKey[:]); r != "" { - t.Error("encoding key: ", r) - } - - if r := cmp.Diff(a.DecodingNonce[:], a2.EncodingNonce[:]); r != "" { - t.Error("encoding nonce: ", r) - } -} diff --git a/proxy/mtproto/client.go b/proxy/mtproto/client.go deleted file mode 100644 index 6825fdae..00000000 --- a/proxy/mtproto/client.go +++ /dev/null @@ -1,76 +0,0 @@ -package mtproto - -import ( - "context" - - "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/common/buf" - "github.com/xtls/xray-core/common/crypto" - "github.com/xtls/xray-core/common/net" - "github.com/xtls/xray-core/common/session" - "github.com/xtls/xray-core/common/task" - "github.com/xtls/xray-core/transport" - "github.com/xtls/xray-core/transport/internet" -) - -type Client struct{} - -func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) { - return &Client{}, nil -} - -func (c *Client) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error { - outbound := session.OutboundFromContext(ctx) - if outbound == nil || !outbound.Target.IsValid() { - return newError("unknown destination.") - } - dest := outbound.Target - if dest.Network != net.Network_TCP { - return newError("not TCP traffic", dest) - } - - conn, err := dialer.Dial(ctx, dest) - if err != nil { - return newError("failed to dial to ", dest).Base(err).AtWarning() - } - defer conn.Close() - - sc := SessionContextFromContext(ctx) - auth := NewAuthentication(sc) - defer putAuthenticationObject(auth) - - request := func() error { - encryptor := crypto.NewAesCTRStream(auth.EncodingKey[:], auth.EncodingNonce[:]) - - var header [HeaderSize]byte - encryptor.XORKeyStream(header[:], auth.Header[:]) - copy(header[:56], auth.Header[:]) - - if _, err := conn.Write(header[:]); err != nil { - return newError("failed to write auth header").Base(err) - } - - connWriter := buf.NewWriter(crypto.NewCryptionWriter(encryptor, conn)) - return buf.Copy(link.Reader, connWriter) - } - - response := func() error { - decryptor := crypto.NewAesCTRStream(auth.DecodingKey[:], auth.DecodingNonce[:]) - - connReader := buf.NewReader(crypto.NewCryptionReader(decryptor, conn)) - return buf.Copy(connReader, link.Writer) - } - - responseDoneAndCloseWriter := task.OnSuccess(response, task.Close(link.Writer)) - if err := task.Run(ctx, request, responseDoneAndCloseWriter); err != nil { - return newError("connection ends").Base(err) - } - - return nil -} - -func init() { - common.Must(common.RegisterConfig((*ClientConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { - return NewClient(ctx, config.(*ClientConfig)) - })) -} diff --git a/proxy/mtproto/config.go b/proxy/mtproto/config.go deleted file mode 100644 index fcd203d7..00000000 --- a/proxy/mtproto/config.go +++ /dev/null @@ -1,24 +0,0 @@ -package mtproto - -import ( - "github.com/xtls/xray-core/common/protocol" -) - -func (a *Account) Equals(another protocol.Account) bool { - aa, ok := another.(*Account) - if !ok { - return false - } - - if len(a.Secret) != len(aa.Secret) { - return false - } - - for i, v := range a.Secret { - if v != aa.Secret[i] { - return false - } - } - - return true -} diff --git a/proxy/mtproto/config.pb.go b/proxy/mtproto/config.pb.go deleted file mode 100644 index 425c7672..00000000 --- a/proxy/mtproto/config.pb.go +++ /dev/null @@ -1,272 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: proxy/mtproto/config.proto - -package mtproto - -import ( - protocol "github.com/xtls/xray-core/common/protocol" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Account struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Secret []byte `protobuf:"bytes,1,opt,name=secret,proto3" json:"secret,omitempty"` -} - -func (x *Account) Reset() { - *x = Account{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_mtproto_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Account) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Account) ProtoMessage() {} - -func (x *Account) ProtoReflect() protoreflect.Message { - mi := &file_proxy_mtproto_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Account.ProtoReflect.Descriptor instead. -func (*Account) Descriptor() ([]byte, []int) { - return file_proxy_mtproto_config_proto_rawDescGZIP(), []int{0} -} - -func (x *Account) GetSecret() []byte { - if x != nil { - return x.Secret - } - return nil -} - -type ServerConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // User is a list of users that allowed to connect to this inbound. - // Although this is a repeated field, only the first user is effective for - // now. - User []*protocol.User `protobuf:"bytes,1,rep,name=user,proto3" json:"user,omitempty"` -} - -func (x *ServerConfig) Reset() { - *x = ServerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_mtproto_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ServerConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ServerConfig) ProtoMessage() {} - -func (x *ServerConfig) ProtoReflect() protoreflect.Message { - mi := &file_proxy_mtproto_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ServerConfig.ProtoReflect.Descriptor instead. -func (*ServerConfig) Descriptor() ([]byte, []int) { - return file_proxy_mtproto_config_proto_rawDescGZIP(), []int{1} -} - -func (x *ServerConfig) GetUser() []*protocol.User { - if x != nil { - return x.User - } - return nil -} - -type ClientConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *ClientConfig) Reset() { - *x = ClientConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_mtproto_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *ClientConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*ClientConfig) ProtoMessage() {} - -func (x *ClientConfig) ProtoReflect() protoreflect.Message { - mi := &file_proxy_mtproto_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use ClientConfig.ProtoReflect.Descriptor instead. -func (*ClientConfig) Descriptor() ([]byte, []int) { - return file_proxy_mtproto_config_proto_rawDescGZIP(), []int{2} -} - -var File_proxy_mtproto_config_proto protoreflect.FileDescriptor - -var file_proxy_mtproto_config_proto_rawDesc = []byte{ - 0x0a, 0x1a, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x6d, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, - 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x6d, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x1a, 0x1a, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, - 0x6c, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x21, 0x0a, 0x07, - 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x22, - 0x3e, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, - 0x2e, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, - 0x0e, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, - 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x2e, 0x6d, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x6d, 0x74, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, - 0x79, 0x2e, 0x4d, 0x74, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} - -var ( - file_proxy_mtproto_config_proto_rawDescOnce sync.Once - file_proxy_mtproto_config_proto_rawDescData = file_proxy_mtproto_config_proto_rawDesc -) - -func file_proxy_mtproto_config_proto_rawDescGZIP() []byte { - file_proxy_mtproto_config_proto_rawDescOnce.Do(func() { - file_proxy_mtproto_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_proxy_mtproto_config_proto_rawDescData) - }) - return file_proxy_mtproto_config_proto_rawDescData -} - -var file_proxy_mtproto_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_proxy_mtproto_config_proto_goTypes = []interface{}{ - (*Account)(nil), // 0: xray.proxy.mtproto.Account - (*ServerConfig)(nil), // 1: xray.proxy.mtproto.ServerConfig - (*ClientConfig)(nil), // 2: xray.proxy.mtproto.ClientConfig - (*protocol.User)(nil), // 3: xray.common.protocol.User -} -var file_proxy_mtproto_config_proto_depIdxs = []int32{ - 3, // 0: xray.proxy.mtproto.ServerConfig.user:type_name -> xray.common.protocol.User - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_proxy_mtproto_config_proto_init() } -func file_proxy_mtproto_config_proto_init() { - if File_proxy_mtproto_config_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_proxy_mtproto_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Account); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_mtproto_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ServerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_mtproto_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ClientConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_proxy_mtproto_config_proto_rawDesc, - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_proxy_mtproto_config_proto_goTypes, - DependencyIndexes: file_proxy_mtproto_config_proto_depIdxs, - MessageInfos: file_proxy_mtproto_config_proto_msgTypes, - }.Build() - File_proxy_mtproto_config_proto = out.File - file_proxy_mtproto_config_proto_rawDesc = nil - file_proxy_mtproto_config_proto_goTypes = nil - file_proxy_mtproto_config_proto_depIdxs = nil -} diff --git a/proxy/mtproto/config.proto b/proxy/mtproto/config.proto deleted file mode 100644 index 65997bc0..00000000 --- a/proxy/mtproto/config.proto +++ /dev/null @@ -1,22 +0,0 @@ -syntax = "proto3"; - -package xray.proxy.mtproto; -option csharp_namespace = "Xray.Proxy.Mtproto"; -option go_package = "github.com/xtls/xray-core/proxy/mtproto"; -option java_package = "com.xray.proxy.mtproto"; -option java_multiple_files = true; - -import "common/protocol/user.proto"; - -message Account { - bytes secret = 1; -} - -message ServerConfig { - // User is a list of users that allowed to connect to this inbound. - // Although this is a repeated field, only the first user is effective for - // now. - repeated xray.common.protocol.User user = 1; -} - -message ClientConfig {} diff --git a/proxy/mtproto/errors.generated.go b/proxy/mtproto/errors.generated.go deleted file mode 100644 index 012202d6..00000000 --- a/proxy/mtproto/errors.generated.go +++ /dev/null @@ -1,9 +0,0 @@ -package mtproto - -import "github.com/xtls/xray-core/common/errors" - -type errPathObjHolder struct{} - -func newError(values ...interface{}) *errors.Error { - return errors.New(values...).WithPathObj(errPathObjHolder{}) -} diff --git a/proxy/mtproto/mtproto.go b/proxy/mtproto/mtproto.go deleted file mode 100644 index af7983a5..00000000 --- a/proxy/mtproto/mtproto.go +++ /dev/null @@ -1,3 +0,0 @@ -package mtproto - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/proxy/mtproto/server.go b/proxy/mtproto/server.go deleted file mode 100644 index 2079df1f..00000000 --- a/proxy/mtproto/server.go +++ /dev/null @@ -1,160 +0,0 @@ -package mtproto - -import ( - "bytes" - "context" - "time" - - "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/common/buf" - "github.com/xtls/xray-core/common/crypto" - "github.com/xtls/xray-core/common/net" - "github.com/xtls/xray-core/common/protocol" - "github.com/xtls/xray-core/common/session" - "github.com/xtls/xray-core/common/signal" - "github.com/xtls/xray-core/common/task" - "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{ - net.ParseAddress("149.154.175.50"), - net.ParseAddress("149.154.167.51"), - net.ParseAddress("149.154.175.100"), - net.ParseAddress("149.154.167.91"), - net.ParseAddress("149.154.171.5"), -} - -type Server struct { - user *protocol.User - account *Account - policy policy.Manager -} - -func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) { - if len(config.User) == 0 { - return nil, newError("no user configured.") - } - - user := config.User[0] - rawAccount, err := config.User[0].GetTypedAccount() - if err != nil { - return nil, newError("invalid account").Base(err) - } - account, ok := rawAccount.(*Account) - if !ok { - return nil, newError("not a MTProto account") - } - - v := core.MustFromContext(ctx) - - return &Server{ - user: user, - account: account, - policy: v.GetFeature(policy.ManagerType()).(policy.Manager), - }, nil -} - -func (s *Server) Network() []net.Network { - return []net.Network{net.Network_TCP} -} - -var ( - ctype1 = []byte{0xef, 0xef, 0xef, 0xef} - ctype2 = []byte{0xee, 0xee, 0xee, 0xee} -) - -func isValidConnectionType(c [4]byte) bool { - if bytes.Equal(c[:], ctype1) { - return true - } - if bytes.Equal(c[:], ctype2) { - return true - } - return false -} - -func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error { - sPolicy := s.policy.ForLevel(s.user.Level) - - if err := conn.SetDeadline(time.Now().Add(sPolicy.Timeouts.Handshake)); err != nil { - newError("failed to set deadline").Base(err).WriteToLog(session.ExportIDToError(ctx)) - } - auth, err := ReadAuthentication(conn) - if err != nil { - return newError("failed to read authentication header").Base(err) - } - defer putAuthenticationObject(auth) - - if err := conn.SetDeadline(time.Time{}); err != nil { - newError("failed to clear deadline").Base(err).WriteToLog(session.ExportIDToError(ctx)) - } - - auth.ApplySecret(s.account.Secret) - - decryptor := crypto.NewAesCTRStream(auth.DecodingKey[:], auth.DecodingNonce[:]) - decryptor.XORKeyStream(auth.Header[:], auth.Header[:]) - - ct := auth.ConnectionType() - if !isValidConnectionType(ct) { - return newError("invalid connection type: ", ct) - } - - dcID := auth.DataCenterID() - if dcID >= uint16(len(dcList)) { - return newError("invalid datacenter id: ", dcID) - } - - dest := net.Destination{ - Network: net.Network_TCP, - Address: dcList[dcID], - Port: net.Port(443), - } - - ctx, cancel := context.WithCancel(ctx) - timer := signal.CancelAfterInactivity(ctx, cancel, sPolicy.Timeouts.ConnectionIdle) - ctx = policy.ContextWithBufferPolicy(ctx, sPolicy.Buffer) - - sc := SessionContext{ - ConnectionType: ct, - DataCenterID: dcID, - } - ctx = ContextWithSessionContext(ctx, sc) - - link, err := dispatcher.Dispatch(ctx, dest) - if err != nil { - return newError("failed to dispatch request to: ", dest).Base(err) - } - - request := func() error { - defer timer.SetTimeout(sPolicy.Timeouts.DownlinkOnly) - - reader := buf.NewReader(crypto.NewCryptionReader(decryptor, conn)) - return buf.Copy(reader, link.Writer, buf.UpdateActivity(timer)) - } - - response := func() error { - defer timer.SetTimeout(sPolicy.Timeouts.UplinkOnly) - - encryptor := crypto.NewAesCTRStream(auth.EncodingKey[:], auth.EncodingNonce[:]) - writer := buf.NewWriter(crypto.NewCryptionWriter(encryptor, conn)) - return buf.Copy(link.Reader, writer, buf.UpdateActivity(timer)) - } - - responseDoneAndCloseWriter := task.OnSuccess(response, task.Close(link.Writer)) - if err := task.Run(ctx, request, responseDoneAndCloseWriter); err != nil { - common.Interrupt(link.Reader) - common.Interrupt(link.Writer) - return newError("connection ends").Base(err) - } - - return nil -} - -func init() { - common.Must(common.RegisterConfig((*ServerConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { - return NewServer(ctx, config.(*ServerConfig)) - })) -} From d11d72be6ccb7f7e00a3bd05755ff77743a8f413 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 21 May 2023 12:03:42 -0400 Subject: [PATCH 063/867] Update proto file and fix protoc version parsing The new protoc cli return version v23.1, so we parse the file version v4.23.1 without "4." --- app/commander/config.pb.go | 4 +- app/dispatcher/config.pb.go | 4 +- app/dns/config.pb.go | 12 +++--- app/dns/fakedns/fakedns.pb.go | 4 +- app/log/command/config.pb.go | 4 +- app/log/command/config_grpc.pb.go | 12 ++++-- app/log/config.pb.go | 4 +- app/metrics/config.pb.go | 4 +- app/observatory/command/command.pb.go | 4 +- app/observatory/command/command_grpc.pb.go | 12 ++++-- app/observatory/config.pb.go | 4 +- app/policy/config.pb.go | 4 +- app/proxyman/command/command.pb.go | 4 +- app/proxyman/command/command_grpc.pb.go | 37 ++++++++++++------- app/proxyman/config.pb.go | 8 ++-- app/reverse/config.pb.go | 4 +- app/router/command/command.pb.go | 4 +- app/router/command/command_grpc.pb.go | 15 +++++--- app/router/config.pb.go | 20 +++++----- app/stats/command/command.pb.go | 4 +- app/stats/command/command_grpc.pb.go | 22 +++++++---- app/stats/config.pb.go | 4 +- common/log/log.pb.go | 4 +- common/net/address.pb.go | 4 +- common/net/destination.pb.go | 4 +- common/net/network.pb.go | 6 +-- common/net/port.pb.go | 4 +- common/protocol/headers.pb.go | 4 +- common/protocol/server_spec.pb.go | 4 +- common/protocol/user.pb.go | 4 +- common/serial/typed_message.pb.go | 4 +- core/config.pb.go | 8 ++-- infra/vprotogen/main.go | 4 +- proxy/blackhole/config.pb.go | 4 +- proxy/dns/config.pb.go | 4 +- proxy/dokodemo/config.pb.go | 12 +++--- proxy/freedom/config.pb.go | 8 ++-- proxy/http/config.pb.go | 8 ++-- proxy/loopback/config.pb.go | 4 +- proxy/shadowsocks/config.pb.go | 4 +- proxy/shadowsocks_2022/config.pb.go | 4 +- proxy/socks/config.pb.go | 8 ++-- proxy/trojan/config.pb.go | 4 +- proxy/vless/account.pb.go | 4 +- proxy/vless/encoding/addons.pb.go | 4 +- proxy/vless/inbound/config.pb.go | 4 +- proxy/vless/outbound/config.pb.go | 4 +- proxy/vmess/account.pb.go | 4 +- proxy/vmess/inbound/config.pb.go | 4 +- proxy/vmess/outbound/config.pb.go | 4 +- proxy/wireguard/config.pb.go | 4 +- transport/global/config.pb.go | 6 +-- transport/internet/config.pb.go | 12 +++--- transport/internet/domainsocket/config.pb.go | 4 +- transport/internet/grpc/config.pb.go | 4 +- transport/internet/grpc/encoding/stream.pb.go | 4 +- .../internet/grpc/encoding/stream_grpc.pb.go | 13 +++++-- transport/internet/headers/dns/config.pb.go | 4 +- transport/internet/headers/http/config.pb.go | 4 +- transport/internet/headers/noop/config.pb.go | 4 +- transport/internet/headers/srtp/config.pb.go | 4 +- transport/internet/headers/tls/config.pb.go | 4 +- transport/internet/headers/utp/config.pb.go | 4 +- .../internet/headers/wechat/config.pb.go | 4 +- .../internet/headers/wireguard/config.pb.go | 4 +- transport/internet/http/config.pb.go | 4 +- transport/internet/kcp/config.pb.go | 4 +- transport/internet/quic/config.pb.go | 4 +- transport/internet/reality/config.pb.go | 4 +- transport/internet/tcp/config.pb.go | 4 +- transport/internet/tls/config.pb.go | 4 +- transport/internet/udp/config.pb.go | 4 +- transport/internet/websocket/config.pb.go | 4 +- 73 files changed, 238 insertions(+), 205 deletions(-) diff --git a/app/commander/config.pb.go b/app/commander/config.pb.go index 1ebbe094..73037653 100644 --- a/app/commander/config.pb.go +++ b/app/commander/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/commander/config.proto package commander diff --git a/app/dispatcher/config.pb.go b/app/dispatcher/config.pb.go index 04e8d7a3..e0a55ab2 100644 --- a/app/dispatcher/config.pb.go +++ b/app/dispatcher/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/dispatcher/config.proto package dispatcher diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index 7474c04a..d5bc18d2 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/dns/config.proto package dns @@ -219,14 +219,14 @@ type Config struct { // the moment. A special value 'localhost' as a domain address can be set to // use DNS on local system. // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in app/dns/config.proto. NameServers []*net.Endpoint `protobuf:"bytes,1,rep,name=NameServers,proto3" json:"NameServers,omitempty"` // NameServer list used by this DNS client. NameServer []*NameServer `protobuf:"bytes,5,rep,name=name_server,json=nameServer,proto3" json:"name_server,omitempty"` // Static hosts. Domain to IP. // Deprecated. Use static_hosts. // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in app/dns/config.proto. Hosts map[string]*net.IPOrDomain `protobuf:"bytes,2,rep,name=Hosts,proto3" json:"Hosts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes // (IPv6). @@ -273,7 +273,7 @@ func (*Config) Descriptor() ([]byte, []int) { return file_app_dns_config_proto_rawDescGZIP(), []int{1} } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in app/dns/config.proto. func (x *Config) GetNameServers() []*net.Endpoint { if x != nil { return x.NameServers @@ -288,7 +288,7 @@ func (x *Config) GetNameServer() []*NameServer { return nil } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in app/dns/config.proto. func (x *Config) GetHosts() map[string]*net.IPOrDomain { if x != nil { return x.Hosts diff --git a/app/dns/fakedns/fakedns.pb.go b/app/dns/fakedns/fakedns.pb.go index 8cf02aee..dc9970f9 100644 --- a/app/dns/fakedns/fakedns.pb.go +++ b/app/dns/fakedns/fakedns.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/dns/fakedns/fakedns.proto package fakedns diff --git a/app/log/command/config.pb.go b/app/log/command/config.pb.go index ceda9127..6a3d6602 100644 --- a/app/log/command/config.pb.go +++ b/app/log/command/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/log/command/config.proto package command diff --git a/app/log/command/config_grpc.pb.go b/app/log/command/config_grpc.pb.go index 653c395c..93a695b0 100644 --- a/app/log/command/config_grpc.pb.go +++ b/app/log/command/config_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.23.1 // source: app/log/command/config.proto package command @@ -18,6 +18,10 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + LoggerService_RestartLogger_FullMethodName = "/xray.app.log.command.LoggerService/RestartLogger" +) + // LoggerServiceClient is the client API for LoggerService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -35,7 +39,7 @@ func NewLoggerServiceClient(cc grpc.ClientConnInterface) LoggerServiceClient { func (c *loggerServiceClient) RestartLogger(ctx context.Context, in *RestartLoggerRequest, opts ...grpc.CallOption) (*RestartLoggerResponse, error) { out := new(RestartLoggerResponse) - err := c.cc.Invoke(ctx, "/xray.app.log.command.LoggerService/RestartLogger", in, out, opts...) + err := c.cc.Invoke(ctx, LoggerService_RestartLogger_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -80,7 +84,7 @@ func _LoggerService_RestartLogger_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.log.command.LoggerService/RestartLogger", + FullMethod: LoggerService_RestartLogger_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(LoggerServiceServer).RestartLogger(ctx, req.(*RestartLoggerRequest)) diff --git a/app/log/config.pb.go b/app/log/config.pb.go index a70d2923..0bc09d40 100644 --- a/app/log/config.pb.go +++ b/app/log/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/log/config.proto package log diff --git a/app/metrics/config.pb.go b/app/metrics/config.pb.go index 24c5629e..2cf67618 100644 --- a/app/metrics/config.pb.go +++ b/app/metrics/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/metrics/config.proto package metrics diff --git a/app/observatory/command/command.pb.go b/app/observatory/command/command.pb.go index c5ffdce5..9eab1533 100644 --- a/app/observatory/command/command.pb.go +++ b/app/observatory/command/command.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/observatory/command/command.proto package command diff --git a/app/observatory/command/command_grpc.pb.go b/app/observatory/command/command_grpc.pb.go index 2a3da93e..b0a59779 100644 --- a/app/observatory/command/command_grpc.pb.go +++ b/app/observatory/command/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.23.1 // source: app/observatory/command/command.proto package command @@ -18,6 +18,10 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + ObservatoryService_GetOutboundStatus_FullMethodName = "/xray.core.app.observatory.command.ObservatoryService/GetOutboundStatus" +) + // ObservatoryServiceClient is the client API for ObservatoryService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -35,7 +39,7 @@ func NewObservatoryServiceClient(cc grpc.ClientConnInterface) ObservatoryService func (c *observatoryServiceClient) GetOutboundStatus(ctx context.Context, in *GetOutboundStatusRequest, opts ...grpc.CallOption) (*GetOutboundStatusResponse, error) { out := new(GetOutboundStatusResponse) - err := c.cc.Invoke(ctx, "/xray.core.app.observatory.command.ObservatoryService/GetOutboundStatus", in, out, opts...) + err := c.cc.Invoke(ctx, ObservatoryService_GetOutboundStatus_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -80,7 +84,7 @@ func _ObservatoryService_GetOutboundStatus_Handler(srv interface{}, ctx context. } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.core.app.observatory.command.ObservatoryService/GetOutboundStatus", + FullMethod: ObservatoryService_GetOutboundStatus_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(ObservatoryServiceServer).GetOutboundStatus(ctx, req.(*GetOutboundStatusRequest)) diff --git a/app/observatory/config.pb.go b/app/observatory/config.pb.go index a6d36ead..741da506 100644 --- a/app/observatory/config.pb.go +++ b/app/observatory/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/observatory/config.proto package observatory diff --git a/app/policy/config.pb.go b/app/policy/config.pb.go index 66da6d11..9841fff0 100644 --- a/app/policy/config.pb.go +++ b/app/policy/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/policy/config.proto package policy diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index 5730955c..9add8afb 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/proxyman/command/command.proto package command diff --git a/app/proxyman/command/command_grpc.pb.go b/app/proxyman/command/command_grpc.pb.go index 979b101f..0765fc80 100644 --- a/app/proxyman/command/command_grpc.pb.go +++ b/app/proxyman/command/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.23.1 // source: app/proxyman/command/command.proto package command @@ -18,6 +18,15 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + HandlerService_AddInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddInbound" + HandlerService_RemoveInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveInbound" + HandlerService_AlterInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterInbound" + HandlerService_AddOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddOutbound" + HandlerService_RemoveOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveOutbound" + HandlerService_AlterOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterOutbound" +) + // HandlerServiceClient is the client API for HandlerService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -40,7 +49,7 @@ func NewHandlerServiceClient(cc grpc.ClientConnInterface) HandlerServiceClient { func (c *handlerServiceClient) AddInbound(ctx context.Context, in *AddInboundRequest, opts ...grpc.CallOption) (*AddInboundResponse, error) { out := new(AddInboundResponse) - err := c.cc.Invoke(ctx, "/xray.app.proxyman.command.HandlerService/AddInbound", in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_AddInbound_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -49,7 +58,7 @@ func (c *handlerServiceClient) AddInbound(ctx context.Context, in *AddInboundReq func (c *handlerServiceClient) RemoveInbound(ctx context.Context, in *RemoveInboundRequest, opts ...grpc.CallOption) (*RemoveInboundResponse, error) { out := new(RemoveInboundResponse) - err := c.cc.Invoke(ctx, "/xray.app.proxyman.command.HandlerService/RemoveInbound", in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_RemoveInbound_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -58,7 +67,7 @@ func (c *handlerServiceClient) RemoveInbound(ctx context.Context, in *RemoveInbo func (c *handlerServiceClient) AlterInbound(ctx context.Context, in *AlterInboundRequest, opts ...grpc.CallOption) (*AlterInboundResponse, error) { out := new(AlterInboundResponse) - err := c.cc.Invoke(ctx, "/xray.app.proxyman.command.HandlerService/AlterInbound", in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_AlterInbound_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -67,7 +76,7 @@ func (c *handlerServiceClient) AlterInbound(ctx context.Context, in *AlterInboun func (c *handlerServiceClient) AddOutbound(ctx context.Context, in *AddOutboundRequest, opts ...grpc.CallOption) (*AddOutboundResponse, error) { out := new(AddOutboundResponse) - err := c.cc.Invoke(ctx, "/xray.app.proxyman.command.HandlerService/AddOutbound", in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_AddOutbound_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -76,7 +85,7 @@ func (c *handlerServiceClient) AddOutbound(ctx context.Context, in *AddOutboundR func (c *handlerServiceClient) RemoveOutbound(ctx context.Context, in *RemoveOutboundRequest, opts ...grpc.CallOption) (*RemoveOutboundResponse, error) { out := new(RemoveOutboundResponse) - err := c.cc.Invoke(ctx, "/xray.app.proxyman.command.HandlerService/RemoveOutbound", in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_RemoveOutbound_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -85,7 +94,7 @@ func (c *handlerServiceClient) RemoveOutbound(ctx context.Context, in *RemoveOut func (c *handlerServiceClient) AlterOutbound(ctx context.Context, in *AlterOutboundRequest, opts ...grpc.CallOption) (*AlterOutboundResponse, error) { out := new(AlterOutboundResponse) - err := c.cc.Invoke(ctx, "/xray.app.proxyman.command.HandlerService/AlterOutbound", in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_AlterOutbound_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -150,7 +159,7 @@ func _HandlerService_AddInbound_Handler(srv interface{}, ctx context.Context, de } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.proxyman.command.HandlerService/AddInbound", + FullMethod: HandlerService_AddInbound_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(HandlerServiceServer).AddInbound(ctx, req.(*AddInboundRequest)) @@ -168,7 +177,7 @@ func _HandlerService_RemoveInbound_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.proxyman.command.HandlerService/RemoveInbound", + FullMethod: HandlerService_RemoveInbound_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(HandlerServiceServer).RemoveInbound(ctx, req.(*RemoveInboundRequest)) @@ -186,7 +195,7 @@ func _HandlerService_AlterInbound_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.proxyman.command.HandlerService/AlterInbound", + FullMethod: HandlerService_AlterInbound_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(HandlerServiceServer).AlterInbound(ctx, req.(*AlterInboundRequest)) @@ -204,7 +213,7 @@ func _HandlerService_AddOutbound_Handler(srv interface{}, ctx context.Context, d } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.proxyman.command.HandlerService/AddOutbound", + FullMethod: HandlerService_AddOutbound_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(HandlerServiceServer).AddOutbound(ctx, req.(*AddOutboundRequest)) @@ -222,7 +231,7 @@ func _HandlerService_RemoveOutbound_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.proxyman.command.HandlerService/RemoveOutbound", + FullMethod: HandlerService_RemoveOutbound_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(HandlerServiceServer).RemoveOutbound(ctx, req.(*RemoveOutboundRequest)) @@ -240,7 +249,7 @@ func _HandlerService_AlterOutbound_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.proxyman.command.HandlerService/AlterOutbound", + FullMethod: HandlerService_AlterOutbound_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(HandlerServiceServer).AlterOutbound(ctx, req.(*AlterOutboundRequest)) diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index cd50e664..cabc09dd 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/proxyman/config.proto package proxyman @@ -326,7 +326,7 @@ type ReceiverConfig struct { // Override domains for the given protocol. // Deprecated. Use sniffing_settings. // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in app/proxyman/config.proto. DomainOverride []KnownProtocols `protobuf:"varint,7,rep,packed,name=domain_override,json=domainOverride,proto3,enum=xray.app.proxyman.KnownProtocols" json:"domain_override,omitempty"` SniffingSettings *SniffingConfig `protobuf:"bytes,8,opt,name=sniffing_settings,json=sniffingSettings,proto3" json:"sniffing_settings,omitempty"` } @@ -398,7 +398,7 @@ func (x *ReceiverConfig) GetReceiveOriginalDestination() bool { return false } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in app/proxyman/config.proto. func (x *ReceiverConfig) GetDomainOverride() []KnownProtocols { if x != nil { return x.DomainOverride diff --git a/app/reverse/config.pb.go b/app/reverse/config.pb.go index c5478280..0e1bc941 100644 --- a/app/reverse/config.pb.go +++ b/app/reverse/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/reverse/config.proto package reverse diff --git a/app/router/command/command.pb.go b/app/router/command/command.pb.go index 41c52388..eb7c8530 100644 --- a/app/router/command/command.pb.go +++ b/app/router/command/command.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/router/command/command.proto package command diff --git a/app/router/command/command_grpc.pb.go b/app/router/command/command_grpc.pb.go index 50c6de29..4d3b4ab4 100644 --- a/app/router/command/command_grpc.pb.go +++ b/app/router/command/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.23.1 // source: app/router/command/command.proto package command @@ -18,6 +18,11 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + RoutingService_SubscribeRoutingStats_FullMethodName = "/xray.app.router.command.RoutingService/SubscribeRoutingStats" + RoutingService_TestRoute_FullMethodName = "/xray.app.router.command.RoutingService/TestRoute" +) + // RoutingServiceClient is the client API for RoutingService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -35,7 +40,7 @@ func NewRoutingServiceClient(cc grpc.ClientConnInterface) RoutingServiceClient { } func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error) { - stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], "/xray.app.router.command.RoutingService/SubscribeRoutingStats", opts...) + stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], RoutingService_SubscribeRoutingStats_FullMethodName, opts...) if err != nil { return nil, err } @@ -68,7 +73,7 @@ func (x *routingServiceSubscribeRoutingStatsClient) Recv() (*RoutingContext, err func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error) { out := new(RoutingContext) - err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/TestRoute", in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_TestRoute_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -138,7 +143,7 @@ func _RoutingService_TestRoute_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.router.command.RoutingService/TestRoute", + FullMethod: RoutingService_TestRoute_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoutingServiceServer).TestRoute(ctx, req.(*TestRouteRequest)) diff --git a/app/router/config.pb.go b/app/router/config.pb.go index 0089a1a8..6b54e0d6 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/router/config.proto package router @@ -486,7 +486,7 @@ type RoutingRule struct { // List of CIDRs for target IP address matching. // Deprecated. Use geoip below. // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in app/router/config.proto. Cidr []*CIDR `protobuf:"bytes,3,rep,name=cidr,proto3" json:"cidr,omitempty"` // List of GeoIPs for target IP address matching. If this entry exists, the // cidr above will have no effect. GeoIP fields with the same country code are @@ -496,19 +496,19 @@ type RoutingRule struct { // A range of port [from, to]. If the destination port is in this range, this // rule takes effect. Deprecated. Use port_list. // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in app/router/config.proto. PortRange *net.PortRange `protobuf:"bytes,4,opt,name=port_range,json=portRange,proto3" json:"port_range,omitempty"` // List of ports. PortList *net.PortList `protobuf:"bytes,14,opt,name=port_list,json=portList,proto3" json:"port_list,omitempty"` // List of networks. Deprecated. Use networks. // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in app/router/config.proto. NetworkList *net.NetworkList `protobuf:"bytes,5,opt,name=network_list,json=networkList,proto3" json:"network_list,omitempty"` // List of networks for matching. Networks []net.Network `protobuf:"varint,13,rep,packed,name=networks,proto3,enum=xray.common.net.Network" json:"networks,omitempty"` // List of CIDRs for source IP address matching. // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in app/router/config.proto. SourceCidr []*CIDR `protobuf:"bytes,6,rep,name=source_cidr,json=sourceCidr,proto3" json:"source_cidr,omitempty"` // List of GeoIPs for source IP address matching. If this entry exists, the // source_cidr above will have no effect. @@ -582,7 +582,7 @@ func (x *RoutingRule) GetDomain() []*Domain { return nil } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in app/router/config.proto. func (x *RoutingRule) GetCidr() []*CIDR { if x != nil { return x.Cidr @@ -597,7 +597,7 @@ func (x *RoutingRule) GetGeoip() []*GeoIP { return nil } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in app/router/config.proto. func (x *RoutingRule) GetPortRange() *net.PortRange { if x != nil { return x.PortRange @@ -612,7 +612,7 @@ func (x *RoutingRule) GetPortList() *net.PortList { return nil } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in app/router/config.proto. func (x *RoutingRule) GetNetworkList() *net.NetworkList { if x != nil { return x.NetworkList @@ -627,7 +627,7 @@ func (x *RoutingRule) GetNetworks() []net.Network { return nil } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in app/router/config.proto. func (x *RoutingRule) GetSourceCidr() []*CIDR { if x != nil { return x.SourceCidr diff --git a/app/stats/command/command.pb.go b/app/stats/command/command.pb.go index 005722b6..6d4d0d38 100644 --- a/app/stats/command/command.pb.go +++ b/app/stats/command/command.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/stats/command/command.proto package command diff --git a/app/stats/command/command_grpc.pb.go b/app/stats/command/command_grpc.pb.go index 38e9d3fb..cbd02485 100644 --- a/app/stats/command/command_grpc.pb.go +++ b/app/stats/command/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.23.1 // source: app/stats/command/command.proto package command @@ -18,6 +18,12 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + StatsService_GetStats_FullMethodName = "/xray.app.stats.command.StatsService/GetStats" + StatsService_QueryStats_FullMethodName = "/xray.app.stats.command.StatsService/QueryStats" + StatsService_GetSysStats_FullMethodName = "/xray.app.stats.command.StatsService/GetSysStats" +) + // StatsServiceClient is the client API for StatsService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -37,7 +43,7 @@ func NewStatsServiceClient(cc grpc.ClientConnInterface) StatsServiceClient { func (c *statsServiceClient) GetStats(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) { out := new(GetStatsResponse) - err := c.cc.Invoke(ctx, "/xray.app.stats.command.StatsService/GetStats", in, out, opts...) + err := c.cc.Invoke(ctx, StatsService_GetStats_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -46,7 +52,7 @@ func (c *statsServiceClient) GetStats(ctx context.Context, in *GetStatsRequest, func (c *statsServiceClient) QueryStats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) { out := new(QueryStatsResponse) - err := c.cc.Invoke(ctx, "/xray.app.stats.command.StatsService/QueryStats", in, out, opts...) + err := c.cc.Invoke(ctx, StatsService_QueryStats_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -55,7 +61,7 @@ func (c *statsServiceClient) QueryStats(ctx context.Context, in *QueryStatsReque func (c *statsServiceClient) GetSysStats(ctx context.Context, in *SysStatsRequest, opts ...grpc.CallOption) (*SysStatsResponse, error) { out := new(SysStatsResponse) - err := c.cc.Invoke(ctx, "/xray.app.stats.command.StatsService/GetSysStats", in, out, opts...) + err := c.cc.Invoke(ctx, StatsService_GetSysStats_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -108,7 +114,7 @@ func _StatsService_GetStats_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.stats.command.StatsService/GetStats", + FullMethod: StatsService_GetStats_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(StatsServiceServer).GetStats(ctx, req.(*GetStatsRequest)) @@ -126,7 +132,7 @@ func _StatsService_QueryStats_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.stats.command.StatsService/QueryStats", + FullMethod: StatsService_QueryStats_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(StatsServiceServer).QueryStats(ctx, req.(*QueryStatsRequest)) @@ -144,7 +150,7 @@ func _StatsService_GetSysStats_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.stats.command.StatsService/GetSysStats", + FullMethod: StatsService_GetSysStats_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(StatsServiceServer).GetSysStats(ctx, req.(*SysStatsRequest)) diff --git a/app/stats/config.pb.go b/app/stats/config.pb.go index 99c573b5..216da044 100644 --- a/app/stats/config.pb.go +++ b/app/stats/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: app/stats/config.proto package stats diff --git a/common/log/log.pb.go b/common/log/log.pb.go index 321ae16b..92ea0811 100644 --- a/common/log/log.pb.go +++ b/common/log/log.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: common/log/log.proto package log diff --git a/common/net/address.pb.go b/common/net/address.pb.go index 5757a018..82240db3 100644 --- a/common/net/address.pb.go +++ b/common/net/address.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: common/net/address.proto package net diff --git a/common/net/destination.pb.go b/common/net/destination.pb.go index 2d557b84..ea6339cb 100644 --- a/common/net/destination.pb.go +++ b/common/net/destination.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: common/net/destination.proto package net diff --git a/common/net/network.pb.go b/common/net/network.pb.go index 699557f7..18e0df4b 100644 --- a/common/net/network.pb.go +++ b/common/net/network.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: common/net/network.proto package net @@ -24,7 +24,7 @@ type Network int32 const ( Network_Unknown Network = 0 - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in common/net/network.proto. Network_RawTCP Network = 1 Network_TCP Network = 2 Network_UDP Network = 3 diff --git a/common/net/port.pb.go b/common/net/port.pb.go index cae70bc9..255bd940 100644 --- a/common/net/port.pb.go +++ b/common/net/port.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: common/net/port.proto package net diff --git a/common/protocol/headers.pb.go b/common/protocol/headers.pb.go index 4096d56f..1392fc62 100644 --- a/common/protocol/headers.pb.go +++ b/common/protocol/headers.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: common/protocol/headers.proto package protocol diff --git a/common/protocol/server_spec.pb.go b/common/protocol/server_spec.pb.go index ea12a4bb..da698518 100644 --- a/common/protocol/server_spec.pb.go +++ b/common/protocol/server_spec.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: common/protocol/server_spec.proto package protocol diff --git a/common/protocol/user.pb.go b/common/protocol/user.pb.go index bc3b2bf8..6f063e73 100644 --- a/common/protocol/user.pb.go +++ b/common/protocol/user.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: common/protocol/user.proto package protocol diff --git a/common/serial/typed_message.pb.go b/common/serial/typed_message.pb.go index 7bdbbf3a..b03f2aaa 100644 --- a/common/serial/typed_message.pb.go +++ b/common/serial/typed_message.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: common/serial/typed_message.proto package serial diff --git a/core/config.pb.go b/core/config.pb.go index 2364674d..c36e7fd0 100644 --- a/core/config.pb.go +++ b/core/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: core/config.proto package core @@ -42,7 +42,7 @@ type Config struct { // Deprecated. Each inbound and outbound should choose their own transport // config. Date to remove: 2020-01-13 // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in core/config.proto. Transport *global.Config `protobuf:"bytes,5,opt,name=transport,proto3" json:"transport,omitempty"` // Configuration for extensions. The config may not work if corresponding // extension is not loaded into Xray. Xray will ignore such config during @@ -103,7 +103,7 @@ func (x *Config) GetApp() []*serial.TypedMessage { return nil } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in core/config.proto. func (x *Config) GetTransport() *global.Config { if x != nil { return x.Transport diff --git a/infra/vprotogen/main.go b/infra/vprotogen/main.go index df920751..10aaa254 100644 --- a/infra/vprotogen/main.go +++ b/infra/vprotogen/main.go @@ -108,7 +108,7 @@ func getProjectProtocVersion(url string) (string, error) { if err != nil { return "", fmt.Errorf("can not read from body") } - versionRegexp := regexp.MustCompile(`\/\/\s*protoc\s*v(\d+\.\d+\.\d+)`) + versionRegexp := regexp.MustCompile(`\/\/\s*protoc\s*v\d+\.(\d+\.\d+)`) matched := versionRegexp.FindStringSubmatch(string(body)) return matched[1], nil } @@ -120,7 +120,7 @@ func getInstalledProtocVersion(protocPath string) (string, error) { if cmdErr != nil { return "", cmdErr } - versionRegexp := regexp.MustCompile(`protoc\s*(\d+\.\d+\.\d+)`) + versionRegexp := regexp.MustCompile(`protoc\s*(\d+\.\d+)`) matched := versionRegexp.FindStringSubmatch(string(output)) return matched[1], nil } diff --git a/proxy/blackhole/config.pb.go b/proxy/blackhole/config.pb.go index 54d2279e..2bc838c6 100644 --- a/proxy/blackhole/config.pb.go +++ b/proxy/blackhole/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/blackhole/config.proto package blackhole diff --git a/proxy/dns/config.pb.go b/proxy/dns/config.pb.go index 653fe141..8da51b44 100644 --- a/proxy/dns/config.pb.go +++ b/proxy/dns/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/dns/config.proto package dns diff --git a/proxy/dokodemo/config.pb.go b/proxy/dokodemo/config.pb.go index 82eb0704..6e43def1 100644 --- a/proxy/dokodemo/config.pb.go +++ b/proxy/dokodemo/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/dokodemo/config.proto package dokodemo @@ -31,11 +31,11 @@ type Config struct { // List of networks that the Dokodemo accepts. // Deprecated. Use networks. // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in proxy/dokodemo/config.proto. NetworkList *net.NetworkList `protobuf:"bytes,3,opt,name=network_list,json=networkList,proto3" json:"network_list,omitempty"` // List of networks that the Dokodemo accepts. Networks []net.Network `protobuf:"varint,7,rep,packed,name=networks,proto3,enum=xray.common.net.Network" json:"networks,omitempty"` - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in proxy/dokodemo/config.proto. Timeout uint32 `protobuf:"varint,4,opt,name=timeout,proto3" json:"timeout,omitempty"` FollowRedirect bool `protobuf:"varint,5,opt,name=follow_redirect,json=followRedirect,proto3" json:"follow_redirect,omitempty"` UserLevel uint32 `protobuf:"varint,6,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` @@ -87,7 +87,7 @@ func (x *Config) GetPort() uint32 { return 0 } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in proxy/dokodemo/config.proto. func (x *Config) GetNetworkList() *net.NetworkList { if x != nil { return x.NetworkList @@ -102,7 +102,7 @@ func (x *Config) GetNetworks() []net.Network { return nil } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in proxy/dokodemo/config.proto. func (x *Config) GetTimeout() uint32 { if x != nil { return x.Timeout diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 0bfc4cba..2e2fb403 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/freedom/config.proto package freedom @@ -213,7 +213,7 @@ type Config struct { unknownFields protoimpl.UnknownFields DomainStrategy Config_DomainStrategy `protobuf:"varint,1,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.proxy.freedom.Config_DomainStrategy" json:"domain_strategy,omitempty"` - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in proxy/freedom/config.proto. Timeout uint32 `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` DestinationOverride *DestinationOverride `protobuf:"bytes,3,opt,name=destination_override,json=destinationOverride,proto3" json:"destination_override,omitempty"` UserLevel uint32 `protobuf:"varint,4,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` @@ -259,7 +259,7 @@ func (x *Config) GetDomainStrategy() Config_DomainStrategy { return Config_AS_IS } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in proxy/freedom/config.proto. func (x *Config) GetTimeout() uint32 { if x != nil { return x.Timeout diff --git a/proxy/http/config.pb.go b/proxy/http/config.pb.go index 813a56c8..986a038a 100644 --- a/proxy/http/config.pb.go +++ b/proxy/http/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/http/config.proto package http @@ -82,7 +82,7 @@ type ServerConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in proxy/http/config.proto. Timeout uint32 `protobuf:"varint,1,opt,name=timeout,proto3" json:"timeout,omitempty"` Accounts map[string]string `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` AllowTransparent bool `protobuf:"varint,3,opt,name=allow_transparent,json=allowTransparent,proto3" json:"allow_transparent,omitempty"` @@ -121,7 +121,7 @@ func (*ServerConfig) Descriptor() ([]byte, []int) { return file_proxy_http_config_proto_rawDescGZIP(), []int{1} } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in proxy/http/config.proto. func (x *ServerConfig) GetTimeout() uint32 { if x != nil { return x.Timeout diff --git a/proxy/loopback/config.pb.go b/proxy/loopback/config.pb.go index c13c14af..e25f8425 100644 --- a/proxy/loopback/config.pb.go +++ b/proxy/loopback/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/loopback/config.proto package loopback diff --git a/proxy/shadowsocks/config.pb.go b/proxy/shadowsocks/config.pb.go index 5e89e40f..5fc221da 100644 --- a/proxy/shadowsocks/config.pb.go +++ b/proxy/shadowsocks/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/shadowsocks/config.proto package shadowsocks diff --git a/proxy/shadowsocks_2022/config.pb.go b/proxy/shadowsocks_2022/config.pb.go index fd51459e..8ccb848a 100644 --- a/proxy/shadowsocks_2022/config.pb.go +++ b/proxy/shadowsocks_2022/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/shadowsocks_2022/config.proto package shadowsocks_2022 diff --git a/proxy/socks/config.pb.go b/proxy/socks/config.pb.go index 3cb7d172..a1daa276 100644 --- a/proxy/socks/config.pb.go +++ b/proxy/socks/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/socks/config.proto package socks @@ -186,7 +186,7 @@ type ServerConfig struct { Accounts map[string]string `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Address *net.IPOrDomain `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` UdpEnabled bool `protobuf:"varint,4,opt,name=udp_enabled,json=udpEnabled,proto3" json:"udp_enabled,omitempty"` - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in proxy/socks/config.proto. Timeout uint32 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` UserLevel uint32 `protobuf:"varint,6,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` } @@ -251,7 +251,7 @@ func (x *ServerConfig) GetUdpEnabled() bool { return false } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in proxy/socks/config.proto. func (x *ServerConfig) GetTimeout() uint32 { if x != nil { return x.Timeout diff --git a/proxy/trojan/config.pb.go b/proxy/trojan/config.pb.go index 17b485da..6d81350f 100644 --- a/proxy/trojan/config.pb.go +++ b/proxy/trojan/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/trojan/config.proto package trojan diff --git a/proxy/vless/account.pb.go b/proxy/vless/account.pb.go index a52fc8f1..1d055185 100644 --- a/proxy/vless/account.pb.go +++ b/proxy/vless/account.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/vless/account.proto package vless diff --git a/proxy/vless/encoding/addons.pb.go b/proxy/vless/encoding/addons.pb.go index a5b97f81..b78c878c 100644 --- a/proxy/vless/encoding/addons.pb.go +++ b/proxy/vless/encoding/addons.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/vless/encoding/addons.proto package encoding diff --git a/proxy/vless/inbound/config.pb.go b/proxy/vless/inbound/config.pb.go index 4061e120..f15f9114 100644 --- a/proxy/vless/inbound/config.pb.go +++ b/proxy/vless/inbound/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/vless/inbound/config.proto package inbound diff --git a/proxy/vless/outbound/config.pb.go b/proxy/vless/outbound/config.pb.go index 4d1b7938..5bd8912a 100644 --- a/proxy/vless/outbound/config.pb.go +++ b/proxy/vless/outbound/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/vless/outbound/config.proto package outbound diff --git a/proxy/vmess/account.pb.go b/proxy/vmess/account.pb.go index 0f2f6159..67f2586e 100644 --- a/proxy/vmess/account.pb.go +++ b/proxy/vmess/account.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/vmess/account.proto package vmess diff --git a/proxy/vmess/inbound/config.pb.go b/proxy/vmess/inbound/config.pb.go index fc7bf36f..a301cede 100644 --- a/proxy/vmess/inbound/config.pb.go +++ b/proxy/vmess/inbound/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/vmess/inbound/config.proto package inbound diff --git a/proxy/vmess/outbound/config.pb.go b/proxy/vmess/outbound/config.pb.go index 700127a8..b68cbffa 100644 --- a/proxy/vmess/outbound/config.pb.go +++ b/proxy/vmess/outbound/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/vmess/outbound/config.proto package outbound diff --git a/proxy/wireguard/config.pb.go b/proxy/wireguard/config.pb.go index 75d5787b..442d78f0 100644 --- a/proxy/wireguard/config.pb.go +++ b/proxy/wireguard/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: proxy/wireguard/config.proto package wireguard diff --git a/transport/global/config.pb.go b/transport/global/config.pb.go index eb0fcd0d..1d763122 100644 --- a/transport/global/config.pb.go +++ b/transport/global/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/global/config.proto package global @@ -24,7 +24,7 @@ const ( // Global transport settings. This affects all type of connections that go // through Xray. Deprecated. Use each settings in StreamConfig. // -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in transport/global/config.proto. type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 20b582c6..a186199f 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/config.proto package internet @@ -191,7 +191,7 @@ type TransportConfig struct { // Type of network that this settings supports. // Deprecated. Use the string form below. // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in transport/internet/config.proto. Protocol TransportProtocol `protobuf:"varint,1,opt,name=protocol,proto3,enum=xray.transport.internet.TransportProtocol" json:"protocol,omitempty"` // Type of network that this settings supports. ProtocolName string `protobuf:"bytes,3,opt,name=protocol_name,json=protocolName,proto3" json:"protocol_name,omitempty"` @@ -231,7 +231,7 @@ func (*TransportConfig) Descriptor() ([]byte, []int) { return file_transport_internet_config_proto_rawDescGZIP(), []int{0} } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in transport/internet/config.proto. func (x *TransportConfig) GetProtocol() TransportProtocol { if x != nil { return x.Protocol @@ -260,7 +260,7 @@ type StreamConfig struct { // Effective network. Deprecated. Use the string form below. // - // Deprecated: Do not use. + // Deprecated: Marked as deprecated in transport/internet/config.proto. Protocol TransportProtocol `protobuf:"varint,1,opt,name=protocol,proto3,enum=xray.transport.internet.TransportProtocol" json:"protocol,omitempty"` // Effective network. ProtocolName string `protobuf:"bytes,5,opt,name=protocol_name,json=protocolName,proto3" json:"protocol_name,omitempty"` @@ -304,7 +304,7 @@ func (*StreamConfig) Descriptor() ([]byte, []int) { return file_transport_internet_config_proto_rawDescGZIP(), []int{1} } -// Deprecated: Do not use. +// Deprecated: Marked as deprecated in transport/internet/config.proto. func (x *StreamConfig) GetProtocol() TransportProtocol { if x != nil { return x.Protocol diff --git a/transport/internet/domainsocket/config.pb.go b/transport/internet/domainsocket/config.pb.go index 23628e02..6089cf34 100644 --- a/transport/internet/domainsocket/config.pb.go +++ b/transport/internet/domainsocket/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/domainsocket/config.proto package domainsocket diff --git a/transport/internet/grpc/config.pb.go b/transport/internet/grpc/config.pb.go index 52d03fd1..91289606 100644 --- a/transport/internet/grpc/config.pb.go +++ b/transport/internet/grpc/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/grpc/config.proto package grpc diff --git a/transport/internet/grpc/encoding/stream.pb.go b/transport/internet/grpc/encoding/stream.pb.go index c605613d..96cf41bd 100644 --- a/transport/internet/grpc/encoding/stream.pb.go +++ b/transport/internet/grpc/encoding/stream.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/grpc/encoding/stream.proto package encoding diff --git a/transport/internet/grpc/encoding/stream_grpc.pb.go b/transport/internet/grpc/encoding/stream_grpc.pb.go index ab75a5d8..e7cc8a5e 100644 --- a/transport/internet/grpc/encoding/stream_grpc.pb.go +++ b/transport/internet/grpc/encoding/stream_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.23.1 // source: transport/internet/grpc/encoding/stream.proto package encoding @@ -18,6 +18,11 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + GRPCService_Tun_FullMethodName = "/xray.transport.internet.grpc.encoding.GRPCService/Tun" + GRPCService_TunMulti_FullMethodName = "/xray.transport.internet.grpc.encoding.GRPCService/TunMulti" +) + // GRPCServiceClient is the client API for GRPCService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -35,7 +40,7 @@ func NewGRPCServiceClient(cc grpc.ClientConnInterface) GRPCServiceClient { } func (c *gRPCServiceClient) Tun(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunClient, error) { - stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[0], "/xray.transport.internet.grpc.encoding.GRPCService/Tun", opts...) + stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[0], GRPCService_Tun_FullMethodName, opts...) if err != nil { return nil, err } @@ -66,7 +71,7 @@ func (x *gRPCServiceTunClient) Recv() (*Hunk, error) { } func (c *gRPCServiceClient) TunMulti(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error) { - stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[1], "/xray.transport.internet.grpc.encoding.GRPCService/TunMulti", opts...) + stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[1], GRPCService_TunMulti_FullMethodName, opts...) if err != nil { return nil, err } diff --git a/transport/internet/headers/dns/config.pb.go b/transport/internet/headers/dns/config.pb.go index d42f537e..aeadae6a 100644 --- a/transport/internet/headers/dns/config.pb.go +++ b/transport/internet/headers/dns/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/headers/dns/config.proto package dns diff --git a/transport/internet/headers/http/config.pb.go b/transport/internet/headers/http/config.pb.go index 382ced84..786bd928 100644 --- a/transport/internet/headers/http/config.pb.go +++ b/transport/internet/headers/http/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/headers/http/config.proto package http diff --git a/transport/internet/headers/noop/config.pb.go b/transport/internet/headers/noop/config.pb.go index 534b3701..cd8880a8 100644 --- a/transport/internet/headers/noop/config.pb.go +++ b/transport/internet/headers/noop/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/headers/noop/config.proto package noop diff --git a/transport/internet/headers/srtp/config.pb.go b/transport/internet/headers/srtp/config.pb.go index 5c0f9cff..553349e8 100644 --- a/transport/internet/headers/srtp/config.pb.go +++ b/transport/internet/headers/srtp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/headers/srtp/config.proto package srtp diff --git a/transport/internet/headers/tls/config.pb.go b/transport/internet/headers/tls/config.pb.go index 7867f69c..8d940553 100644 --- a/transport/internet/headers/tls/config.pb.go +++ b/transport/internet/headers/tls/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/headers/tls/config.proto package tls diff --git a/transport/internet/headers/utp/config.pb.go b/transport/internet/headers/utp/config.pb.go index c7658b0b..9dff1aed 100644 --- a/transport/internet/headers/utp/config.pb.go +++ b/transport/internet/headers/utp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/headers/utp/config.proto package utp diff --git a/transport/internet/headers/wechat/config.pb.go b/transport/internet/headers/wechat/config.pb.go index 1b624b59..02c4f50d 100644 --- a/transport/internet/headers/wechat/config.pb.go +++ b/transport/internet/headers/wechat/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/headers/wechat/config.proto package wechat diff --git a/transport/internet/headers/wireguard/config.pb.go b/transport/internet/headers/wireguard/config.pb.go index 8d3be7a1..68c72d96 100644 --- a/transport/internet/headers/wireguard/config.pb.go +++ b/transport/internet/headers/wireguard/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/headers/wireguard/config.proto package wireguard diff --git a/transport/internet/http/config.pb.go b/transport/internet/http/config.pb.go index f87a59e8..6abb97dd 100644 --- a/transport/internet/http/config.pb.go +++ b/transport/internet/http/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/http/config.proto package http diff --git a/transport/internet/kcp/config.pb.go b/transport/internet/kcp/config.pb.go index 0e10dac4..8b6dbd40 100644 --- a/transport/internet/kcp/config.pb.go +++ b/transport/internet/kcp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/kcp/config.proto package kcp diff --git a/transport/internet/quic/config.pb.go b/transport/internet/quic/config.pb.go index 36aa03da..0b850900 100644 --- a/transport/internet/quic/config.pb.go +++ b/transport/internet/quic/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/quic/config.proto package quic diff --git a/transport/internet/reality/config.pb.go b/transport/internet/reality/config.pb.go index a140d9ab..799e30d4 100644 --- a/transport/internet/reality/config.pb.go +++ b/transport/internet/reality/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/reality/config.proto package reality diff --git a/transport/internet/tcp/config.pb.go b/transport/internet/tcp/config.pb.go index c2b949de..1ff79f64 100644 --- a/transport/internet/tcp/config.pb.go +++ b/transport/internet/tcp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/tcp/config.proto package tcp diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index d02fa112..65c18e6b 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/tls/config.proto package tls diff --git a/transport/internet/udp/config.pb.go b/transport/internet/udp/config.pb.go index c01b0e60..b3921e46 100644 --- a/transport/internet/udp/config.pb.go +++ b/transport/internet/udp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/udp/config.proto package udp diff --git a/transport/internet/websocket/config.pb.go b/transport/internet/websocket/config.pb.go index 9ba5c1c8..7880a1a5 100644 --- a/transport/internet/websocket/config.pb.go +++ b/transport/internet/websocket/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 +// protoc-gen-go v1.30.0 +// protoc v4.23.1 // source: transport/internet/websocket/config.proto package websocket From bf4b1fab3c97d44c4381c16ed4c96b91589dac3b Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 21 May 2023 11:26:22 -0400 Subject: [PATCH 064/867] Simplify http attrabute matching In the past, we use Starlark script, it is over engineered and barely used. By switching to simple key value string contains logic we can reduce core size about 0.7MB --- app/router/condition.go | 42 +++-------- app/router/condition_test.go | 4 +- app/router/config.go | 10 ++- app/router/config.pb.go | 138 ++++++++++++++++++----------------- app/router/config.proto | 2 +- go.mod | 1 - go.sum | 41 ----------- infra/conf/router.go | 22 +++--- 8 files changed, 103 insertions(+), 157 deletions(-) diff --git a/app/router/condition.go b/app/router/condition.go index cdcb6747..326c13ff 100644 --- a/app/router/condition.go +++ b/app/router/condition.go @@ -6,8 +6,6 @@ import ( "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 { @@ -284,44 +282,22 @@ func (m *ProtocolMatcher) Apply(ctx routing.Context) bool { } type AttributeMatcher struct { - program *starlark.Program -} - -func NewAttributeMatcher(code string) (*AttributeMatcher, error) { - starFile, err := syntax.Parse("attr.star", "satisfied=("+code+")", 0) - if err != nil { - return nil, newError("attr rule").Base(err) - } - p, err := starlark.FileProgram(starFile, func(name string) bool { - return name == "attrs" - }) - if err != nil { - return nil, err - } - return &AttributeMatcher{ - program: p, - }, nil + configuredKeys map[string]string } // Match implements attributes matching. func (m *AttributeMatcher) Match(attrs map[string]string) bool { - attrsDict := new(starlark.Dict) + // headers are insensitive most likely. So we do a convert + httpHeaders := make(map[string]string) for key, value := range attrs { - attrsDict.SetKey(starlark.String(key), starlark.String(value)) + httpHeaders[strings.ToLower(key)] = strings.ToLower(value) } - - predefined := make(starlark.StringDict) - predefined["attrs"] = attrsDict - - thread := &starlark.Thread{ - Name: "matcher", + for key, value := range m.configuredKeys { + if a, ok := httpHeaders[key]; !ok || !strings.Contains(a, value) { + return false + } } - results, err := m.program.Init(thread, predefined) - if err != nil { - newError("attr matcher").Base(err).WriteToLog() - } - satisfied := results["satisfied"] - return satisfied != nil && bool(satisfied.Truth()) + return true } // Apply implements Condition. diff --git a/app/router/condition_test.go b/app/router/condition_test.go index 5d98eb43..ca1999ef 100644 --- a/app/router/condition_test.go +++ b/app/router/condition_test.go @@ -308,7 +308,9 @@ func TestRoutingRule(t *testing.T) { { rule: &RoutingRule{ Protocol: []string{"http"}, - Attributes: "attrs[':path'].startswith('/test')", + Attributes: map[string]string { + ":path": "/test", + }, }, test: []ruleTest{ { diff --git a/app/router/config.go b/app/router/config.go index 9bb4bc46..3f4fd7c5 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -1,6 +1,8 @@ package router import ( + "strings" + "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/features/routing" @@ -143,11 +145,11 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) { } if len(rr.Attributes) > 0 { - cond, err := NewAttributeMatcher(rr.Attributes) - if err != nil { - return nil, err + configuredKeys := make(map[string]string) + for key, value := range rr.Attributes { + configuredKeys[strings.ToLower(key)] = strings.ToLower(value) } - conds.Add(cond) + conds.Add(&AttributeMatcher{configuredKeys}) } if conds.Len() == 0 { diff --git a/app/router/config.pb.go b/app/router/config.pb.go index 6b54e0d6..3fd01cc7 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -514,12 +514,12 @@ type RoutingRule struct { // source_cidr above will have no effect. SourceGeoip []*GeoIP `protobuf:"bytes,11,rep,name=source_geoip,json=sourceGeoip,proto3" json:"source_geoip,omitempty"` // List of ports for source port matching. - SourcePortList *net.PortList `protobuf:"bytes,16,opt,name=source_port_list,json=sourcePortList,proto3" json:"source_port_list,omitempty"` - UserEmail []string `protobuf:"bytes,7,rep,name=user_email,json=userEmail,proto3" json:"user_email,omitempty"` - InboundTag []string `protobuf:"bytes,8,rep,name=inbound_tag,json=inboundTag,proto3" json:"inbound_tag,omitempty"` - Protocol []string `protobuf:"bytes,9,rep,name=protocol,proto3" json:"protocol,omitempty"` - Attributes string `protobuf:"bytes,15,opt,name=attributes,proto3" json:"attributes,omitempty"` - DomainMatcher string `protobuf:"bytes,17,opt,name=domain_matcher,json=domainMatcher,proto3" json:"domain_matcher,omitempty"` + SourcePortList *net.PortList `protobuf:"bytes,16,opt,name=source_port_list,json=sourcePortList,proto3" json:"source_port_list,omitempty"` + UserEmail []string `protobuf:"bytes,7,rep,name=user_email,json=userEmail,proto3" json:"user_email,omitempty"` + InboundTag []string `protobuf:"bytes,8,rep,name=inbound_tag,json=inboundTag,proto3" json:"inbound_tag,omitempty"` + Protocol []string `protobuf:"bytes,9,rep,name=protocol,proto3" json:"protocol,omitempty"` + Attributes map[string]string `protobuf:"bytes,15,rep,name=attributes,proto3" json:"attributes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + DomainMatcher string `protobuf:"bytes,17,opt,name=domain_matcher,json=domainMatcher,proto3" json:"domain_matcher,omitempty"` } func (x *RoutingRule) Reset() { @@ -670,11 +670,11 @@ func (x *RoutingRule) GetProtocol() []string { return nil } -func (x *RoutingRule) GetAttributes() string { +func (x *RoutingRule) GetAttributes() map[string]string { if x != nil { return x.Attributes } - return "" + return nil } func (x *RoutingRule) GetDomainMatcher() string { @@ -969,7 +969,7 @@ var file_app_router_config_proto_rawDesc = []byte{ 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x52, - 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0xb5, 0x06, 0x0a, 0x0b, 0x52, 0x6f, 0x75, 0x74, 0x69, + 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0xa2, 0x07, 0x0a, 0x0b, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x25, 0x0a, 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, @@ -1015,43 +1015,49 @@ var file_app_router_config_proto_rawDesc = []byte{ 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x74, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x61, - 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, 0x11, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, - 0x42, 0x0c, 0x0a, 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x61, 0x67, 0x22, 0x6a, - 0x0a, 0x0d, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, - 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, - 0x67, 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, 0x65, - 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x6f, 0x75, - 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1a, - 0x0a, 0x08, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x22, 0x9b, 0x02, 0x0a, 0x06, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4f, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, - 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, - 0x6c, 0x65, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x0e, 0x62, 0x61, 0x6c, 0x61, - 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, - 0x65, 0x72, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, - 0x52, 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x22, - 0x47, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, - 0x79, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x73, 0x49, 0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, - 0x73, 0x65, 0x49, 0x70, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x70, 0x49, 0x66, 0x4e, 0x6f, - 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x70, 0x4f, 0x6e, - 0x44, 0x65, 0x6d, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x50, - 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, - 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, - 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0xaa, 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, - 0x70, 0x70, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x4c, 0x0a, 0x0a, 0x61, 0x74, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, + 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x2e, 0x41, 0x74, 0x74, 0x72, + 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x61, 0x74, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x1a, 0x3d, + 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0c, 0x0a, + 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x61, 0x67, 0x22, 0x6a, 0x0a, 0x0d, 0x42, + 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, + 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x2b, + 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, + 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, + 0x75, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x22, 0x9b, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x12, 0x4f, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, + 0x74, 0x65, 0x72, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, + 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x0e, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, + 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, + 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x62, + 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x47, 0x0a, 0x0e, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, + 0x0a, 0x04, 0x41, 0x73, 0x49, 0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x49, + 0x70, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x70, 0x49, 0x66, 0x4e, 0x6f, 0x6e, 0x4d, 0x61, + 0x74, 0x63, 0x68, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x70, 0x4f, 0x6e, 0x44, 0x65, 0x6d, + 0x61, 0x6e, 0x64, 0x10, 0x03, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x24, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, + 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, + 0x75, 0x74, 0x65, 0x72, 0xaa, 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, + 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1067,7 +1073,7 @@ func file_app_router_config_proto_rawDescGZIP() []byte { } var file_app_router_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_app_router_config_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_app_router_config_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_app_router_config_proto_goTypes = []interface{}{ (Domain_Type)(0), // 0: xray.app.router.Domain.Type (Config_DomainStrategy)(0), // 1: xray.app.router.Config.DomainStrategy @@ -1081,10 +1087,11 @@ var file_app_router_config_proto_goTypes = []interface{}{ (*BalancingRule)(nil), // 9: xray.app.router.BalancingRule (*Config)(nil), // 10: xray.app.router.Config (*Domain_Attribute)(nil), // 11: xray.app.router.Domain.Attribute - (*net.PortRange)(nil), // 12: xray.common.net.PortRange - (*net.PortList)(nil), // 13: xray.common.net.PortList - (*net.NetworkList)(nil), // 14: xray.common.net.NetworkList - (net.Network)(0), // 15: xray.common.net.Network + nil, // 12: xray.app.router.RoutingRule.AttributesEntry + (*net.PortRange)(nil), // 13: xray.common.net.PortRange + (*net.PortList)(nil), // 14: xray.common.net.PortList + (*net.NetworkList)(nil), // 15: xray.common.net.NetworkList + (net.Network)(0), // 16: xray.common.net.Network } var file_app_router_config_proto_depIdxs = []int32{ 0, // 0: xray.app.router.Domain.type:type_name -> xray.app.router.Domain.Type @@ -1096,21 +1103,22 @@ var file_app_router_config_proto_depIdxs = []int32{ 2, // 6: xray.app.router.RoutingRule.domain:type_name -> xray.app.router.Domain 3, // 7: xray.app.router.RoutingRule.cidr:type_name -> xray.app.router.CIDR 4, // 8: xray.app.router.RoutingRule.geoip:type_name -> xray.app.router.GeoIP - 12, // 9: xray.app.router.RoutingRule.port_range:type_name -> xray.common.net.PortRange - 13, // 10: xray.app.router.RoutingRule.port_list:type_name -> xray.common.net.PortList - 14, // 11: xray.app.router.RoutingRule.network_list:type_name -> xray.common.net.NetworkList - 15, // 12: xray.app.router.RoutingRule.networks:type_name -> xray.common.net.Network + 13, // 9: xray.app.router.RoutingRule.port_range:type_name -> xray.common.net.PortRange + 14, // 10: xray.app.router.RoutingRule.port_list:type_name -> xray.common.net.PortList + 15, // 11: xray.app.router.RoutingRule.network_list:type_name -> xray.common.net.NetworkList + 16, // 12: xray.app.router.RoutingRule.networks:type_name -> xray.common.net.Network 3, // 13: xray.app.router.RoutingRule.source_cidr:type_name -> xray.app.router.CIDR 4, // 14: xray.app.router.RoutingRule.source_geoip:type_name -> xray.app.router.GeoIP - 13, // 15: xray.app.router.RoutingRule.source_port_list:type_name -> xray.common.net.PortList - 1, // 16: xray.app.router.Config.domain_strategy:type_name -> xray.app.router.Config.DomainStrategy - 8, // 17: xray.app.router.Config.rule:type_name -> xray.app.router.RoutingRule - 9, // 18: xray.app.router.Config.balancing_rule:type_name -> xray.app.router.BalancingRule - 19, // [19:19] is the sub-list for method output_type - 19, // [19:19] is the sub-list for method input_type - 19, // [19:19] is the sub-list for extension type_name - 19, // [19:19] is the sub-list for extension extendee - 0, // [0:19] is the sub-list for field type_name + 14, // 15: xray.app.router.RoutingRule.source_port_list:type_name -> xray.common.net.PortList + 12, // 16: xray.app.router.RoutingRule.attributes:type_name -> xray.app.router.RoutingRule.AttributesEntry + 1, // 17: xray.app.router.Config.domain_strategy:type_name -> xray.app.router.Config.DomainStrategy + 8, // 18: xray.app.router.Config.rule:type_name -> xray.app.router.RoutingRule + 9, // 19: xray.app.router.Config.balancing_rule:type_name -> xray.app.router.BalancingRule + 20, // [20:20] is the sub-list for method output_type + 20, // [20:20] is the sub-list for method input_type + 20, // [20:20] is the sub-list for extension type_name + 20, // [20:20] is the sub-list for extension extendee + 0, // [0:20] is the sub-list for field type_name } func init() { file_app_router_config_proto_init() } @@ -1254,7 +1262,7 @@ func file_app_router_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_router_config_proto_rawDesc, NumEnums: 2, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 0, }, diff --git a/app/router/config.proto b/app/router/config.proto index 2886077a..ab9957f3 100644 --- a/app/router/config.proto +++ b/app/router/config.proto @@ -119,7 +119,7 @@ message RoutingRule { repeated string inbound_tag = 8; repeated string protocol = 9; - string attributes = 15; + map attributes = 15; string domain_matcher = 17; } diff --git a/go.mod b/go.mod index 883de3c9..629c89e5 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,6 @@ require ( github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230331223127-176a94313eda - go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 golang.org/x/crypto v0.9.0 golang.org/x/net v0.10.0 golang.org/x/sync v0.2.0 diff --git a/go.sum b/go.sum index 135e85e2..6b73d1d3 100644 --- a/go.sum +++ b/go.sum @@ -14,10 +14,6 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -27,8 +23,6 @@ github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165/go.mod h1:c9O8+fp github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 h1:y7y0Oa6UawqTFPCDw9JG6pdKt4F9pAhHv0B7FMGaGD0= github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= @@ -52,13 +46,6 @@ github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -66,11 +53,6 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= @@ -128,7 +110,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc86Z5U= @@ -189,8 +170,6 @@ github.com/xtls/reality v0.0.0-20230331223127-176a94313eda h1:psRJD2RrZbnI0OWyHv github.com/xtls/reality v0.0.0-20230331223127-176a94313eda/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= -go.starlark.net v0.0.0-20230302034142-4b1e35fe2254 h1:Ss6D3hLXTM0KobyBYEAygXzFfGcjnmfEJOBgSbemCtg= -go.starlark.net v0.0.0-20230302034142-4b1e35fe2254/go.mod h1:jxU+3+j+71eXOW14274+SmmuW82qJzl6iZSeqEtTGds= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= @@ -207,7 +186,6 @@ golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZ golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= @@ -218,7 +196,6 @@ golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -247,13 +224,10 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -268,8 +242,6 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= @@ -290,26 +262,14 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= @@ -333,7 +293,6 @@ h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= diff --git a/infra/conf/router.go b/infra/conf/router.go index e10317bd..135454bc 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -504,17 +504,17 @@ func ToCidrList(ips StringList) ([]*router.GeoIP, error) { func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) { type RawFieldRule struct { RouterRule - Domain *StringList `json:"domain"` - Domains *StringList `json:"domains"` - IP *StringList `json:"ip"` - Port *PortList `json:"port"` - Network *NetworkList `json:"network"` - SourceIP *StringList `json:"source"` - SourcePort *PortList `json:"sourcePort"` - User *StringList `json:"user"` - InboundTag *StringList `json:"inboundTag"` - Protocols *StringList `json:"protocol"` - Attributes string `json:"attrs"` + Domain *StringList `json:"domain"` + Domains *StringList `json:"domains"` + IP *StringList `json:"ip"` + Port *PortList `json:"port"` + Network *NetworkList `json:"network"` + SourceIP *StringList `json:"source"` + SourcePort *PortList `json:"sourcePort"` + User *StringList `json:"user"` + InboundTag *StringList `json:"inboundTag"` + Protocols *StringList `json:"protocol"` + Attributes map[string]string `json:"attrs"` } rawFieldRule := new(RawFieldRule) err := json.Unmarshal(msg, rawFieldRule) From 9112cfd39c2105d5b513275f9659b26e92fa7b67 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Mon, 12 Jun 2023 10:32:25 -0400 Subject: [PATCH 065/867] Clean legacy vmess (#2199) * Remove legacy Vmess * validators * protos --- .github/docker/files/config.json | 3 +- common/protocol/headers.go | 6 +- common/protocol/headers.pb.go | 30 ++--- common/protocol/headers.proto | 3 +- common/protocol/id.go | 33 ----- infra/conf/vmess.go | 9 +- infra/conf/vmess_test.go | 1 - proxy/vmess/account.go | 13 -- proxy/vmess/account.pb.go | 41 +++--- proxy/vmess/account.proto | 2 - proxy/vmess/encoding/auth.go | 29 +---- proxy/vmess/encoding/auth_test.go | 26 ---- proxy/vmess/encoding/client.go | 157 +++++++---------------- proxy/vmess/encoding/commands.go | 9 +- proxy/vmess/encoding/commands_test.go | 2 - proxy/vmess/encoding/encoding_test.go | 12 +- proxy/vmess/encoding/server.go | 142 ++++----------------- proxy/vmess/inbound/config.pb.go | 75 ++++------- proxy/vmess/inbound/config.proto | 3 +- proxy/vmess/inbound/inbound.go | 45 +------ proxy/vmess/outbound/command.go | 3 +- proxy/vmess/outbound/outbound.go | 13 +- proxy/vmess/validator.go | 175 ++------------------------ proxy/vmess/validator_test.go | 75 +---------- proxy/vmess/vmessCtxInterface.go | 4 - 25 files changed, 150 insertions(+), 761 deletions(-) delete mode 100644 proxy/vmess/encoding/auth_test.go delete mode 100644 proxy/vmess/vmessCtxInterface.go diff --git a/.github/docker/files/config.json b/.github/docker/files/config.json index 9dded728..10675856 100644 --- a/.github/docker/files/config.json +++ b/.github/docker/files/config.json @@ -6,8 +6,7 @@ "clients": [ { "id": "1eb6e917-774b-4a84-aff6-b058577c60a5", - "level": 1, - "alterId": 64 + "level": 1 } ] } diff --git a/common/protocol/headers.go b/common/protocol/headers.go index 0058d1c5..261e21d9 100644 --- a/common/protocol/headers.go +++ b/common/protocol/headers.go @@ -30,11 +30,10 @@ func (c RequestCommand) TransferType() TransferType { } const ( - // RequestOptionChunkStream indicates request payload is chunked. Each chunk consists of length, authentication and payload. + // [DEPRECATED 2023-06] RequestOptionChunkStream indicates request payload is chunked. Each chunk consists of length, authentication and payload. RequestOptionChunkStream bitmask.Byte = 0x01 - // RequestOptionConnectionReuse indicates client side expects to reuse the connection. - RequestOptionConnectionReuse bitmask.Byte = 0x02 + // 0x02 legacy setting RequestOptionChunkMasking bitmask.Byte = 0x04 @@ -76,7 +75,6 @@ type CommandSwitchAccount struct { Port net.Port ID uuid.UUID Level uint32 - AlterIds uint16 ValidMin byte } diff --git a/common/protocol/headers.pb.go b/common/protocol/headers.pb.go index 1392fc62..b90db8c7 100644 --- a/common/protocol/headers.pb.go +++ b/common/protocol/headers.pb.go @@ -24,7 +24,6 @@ type SecurityType int32 const ( SecurityType_UNKNOWN SecurityType = 0 - SecurityType_LEGACY SecurityType = 1 SecurityType_AUTO SecurityType = 2 SecurityType_AES128_GCM SecurityType = 3 SecurityType_CHACHA20_POLY1305 SecurityType = 4 @@ -36,7 +35,6 @@ const ( var ( SecurityType_name = map[int32]string{ 0: "UNKNOWN", - 1: "LEGACY", 2: "AUTO", 3: "AES128_GCM", 4: "CHACHA20_POLY1305", @@ -45,7 +43,6 @@ var ( } SecurityType_value = map[string]int32{ "UNKNOWN": 0, - "LEGACY": 1, "AUTO": 2, "AES128_GCM": 3, "CHACHA20_POLY1305": 4, @@ -139,20 +136,19 @@ var file_common_protocol_headers_proto_rawDesc = []byte{ 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x22, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x2a, - 0x6c, 0x0a, 0x0c, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, - 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, - 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x55, 0x54, 0x4f, - 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x41, 0x45, 0x53, 0x31, 0x32, 0x38, 0x5f, 0x47, 0x43, 0x4d, - 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x48, 0x41, 0x43, 0x48, 0x41, 0x32, 0x30, 0x5f, 0x50, - 0x4f, 0x4c, 0x59, 0x31, 0x33, 0x30, 0x35, 0x10, 0x04, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, - 0x45, 0x10, 0x05, 0x12, 0x08, 0x0a, 0x04, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x06, 0x42, 0x5e, 0x0a, - 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0xaa, 0x02, 0x14, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x60, 0x0a, 0x0c, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x0b, 0x0a, 0x07, 0x55, 0x4e, 0x4b, 0x4e, 0x4f, 0x57, 0x4e, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, + 0x41, 0x55, 0x54, 0x4f, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x41, 0x45, 0x53, 0x31, 0x32, 0x38, + 0x5f, 0x47, 0x43, 0x4d, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x43, 0x48, 0x41, 0x43, 0x48, 0x41, + 0x32, 0x30, 0x5f, 0x50, 0x4f, 0x4c, 0x59, 0x31, 0x33, 0x30, 0x35, 0x10, 0x04, 0x12, 0x08, 0x0a, + 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x05, 0x12, 0x08, 0x0a, 0x04, 0x5a, 0x45, 0x52, 0x4f, 0x10, + 0x06, 0x42, 0x5e, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x50, 0x01, 0x5a, + 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, + 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0xaa, 0x02, 0x14, 0x58, 0x72, 0x61, + 0x79, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/common/protocol/headers.proto b/common/protocol/headers.proto index cb0b8ff0..1ae3537f 100644 --- a/common/protocol/headers.proto +++ b/common/protocol/headers.proto @@ -8,11 +8,10 @@ option java_multiple_files = true; enum SecurityType { UNKNOWN = 0; - LEGACY = 1; AUTO = 2; AES128_GCM = 3; CHACHA20_POLY1305 = 4; - NONE = 5; + NONE = 5; // [DEPRECATED 2023-06] ZERO = 6; } diff --git a/common/protocol/id.go b/common/protocol/id.go index 2a1eb17a..211fc578 100644 --- a/common/protocol/id.go +++ b/common/protocol/id.go @@ -1,9 +1,7 @@ package protocol import ( - "crypto/hmac" "crypto/md5" - "hash" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/uuid" @@ -13,12 +11,6 @@ const ( IDBytesLen = 16 ) -type IDHash func(key []byte) hash.Hash - -func DefaultIDHash(key []byte) hash.Hash { - return hmac.New(md5.New, key) -} - // The ID of en entity, in the form of a UUID. type ID struct { uuid uuid.UUID @@ -55,28 +47,3 @@ func NewID(uuid uuid.UUID) *ID { md5hash.Sum(id.cmdKey[:0]) return id } - -func nextID(u *uuid.UUID) uuid.UUID { - md5hash := md5.New() - common.Must2(md5hash.Write(u.Bytes())) - common.Must2(md5hash.Write([]byte("16167dc8-16b6-4e6d-b8bb-65dd68113a81"))) - var newid uuid.UUID - for { - md5hash.Sum(newid[:0]) - if !newid.Equals(u) { - return newid - } - common.Must2(md5hash.Write([]byte("533eff8a-4113-4b10-b5ce-0f5d76b98cd2"))) - } -} - -func NewAlterIDs(primary *ID, alterIDCount uint16) []*ID { - alterIDs := make([]*ID, alterIDCount) - prevID := primary.UUID() - for idx := range alterIDs { - newid := nextID(&prevID) - alterIDs[idx] = NewID(newid) - prevID = newid - } - return alterIDs -} diff --git a/infra/conf/vmess.go b/infra/conf/vmess.go index c646bebb..e3361646 100644 --- a/infra/conf/vmess.go +++ b/infra/conf/vmess.go @@ -15,7 +15,6 @@ import ( type VMessAccount struct { ID string `json:"id"` - AlterIds uint16 `json:"alterId"` Security string `json:"security"` Experiments string `json:"experiments"` } @@ -39,7 +38,6 @@ func (a *VMessAccount) Build() *vmess.Account { } return &vmess.Account{ Id: a.ID, - AlterId: uint32(a.AlterIds), SecuritySettings: &protocol.SecurityConfig{ Type: st, }, @@ -63,14 +61,12 @@ type FeaturesConfig struct { } type VMessDefaultConfig struct { - AlterIDs uint16 `json:"alterId"` Level byte `json:"level"` } // Build implements Buildable func (c *VMessDefaultConfig) Build() *inbound.DefaultConfig { config := new(inbound.DefaultConfig) - config.AlterId = uint32(c.AlterIDs) config.Level = uint32(c.Level) return config } @@ -80,14 +76,11 @@ type VMessInboundConfig struct { Features *FeaturesConfig `json:"features"` Defaults *VMessDefaultConfig `json:"default"` DetourConfig *VMessDetourConfig `json:"detour"` - SecureOnly bool `json:"disableInsecureEncryption"` } // Build implements Buildable func (c *VMessInboundConfig) Build() (proto.Message, error) { - config := &inbound.Config{ - SecureEncryptionOnly: c.SecureOnly, - } + config := &inbound.Config{} if c.Defaults != nil { config.Default = c.Defaults.Build() diff --git a/infra/conf/vmess_test.go b/infra/conf/vmess_test.go index 17cda04d..8adda170 100644 --- a/infra/conf/vmess_test.go +++ b/infra/conf/vmess_test.go @@ -105,7 +105,6 @@ func TestVMessInbound(t *testing.T) { Detour: &inbound.DetourConfig{ To: "tag_to_detour", }, - SecureEncryptionOnly: true, }, }, }) diff --git a/proxy/vmess/account.go b/proxy/vmess/account.go index 809bca21..d0a776e6 100644 --- a/proxy/vmess/account.go +++ b/proxy/vmess/account.go @@ -3,7 +3,6 @@ package vmess import ( "strings" - "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/uuid" ) @@ -12,8 +11,6 @@ import ( type MemoryAccount struct { // ID is the main ID of the account. ID *protocol.ID - // AlterIDs are the alternative IDs of the account. - AlterIDs []*protocol.ID // Security type of the account. Used for client connections. Security protocol.SecurityType @@ -21,21 +18,12 @@ type MemoryAccount struct { NoTerminationSignal bool } -// AnyValidID returns an ID that is either the main ID or one of the alternative IDs if any. -func (a *MemoryAccount) AnyValidID() *protocol.ID { - if len(a.AlterIDs) == 0 { - return a.ID - } - return a.AlterIDs[dice.Roll(len(a.AlterIDs))] -} - // Equals implements protocol.Account. func (a *MemoryAccount) Equals(account protocol.Account) bool { vmessAccount, ok := account.(*MemoryAccount) if !ok { return false } - // TODO: handle AlterIds difference return a.ID.Equals(vmessAccount.ID) } @@ -55,7 +43,6 @@ func (a *Account) AsAccount() (protocol.Account, error) { } return &MemoryAccount{ ID: protoID, - AlterIDs: protocol.NewAlterIDs(protoID, uint16(a.AlterId)), Security: a.SecuritySettings.GetSecurityType(), AuthenticatedLengthExperiment: AuthenticatedLength, NoTerminationSignal: NoTerminationSignal, diff --git a/proxy/vmess/account.pb.go b/proxy/vmess/account.pb.go index 67f2586e..9938cfb1 100644 --- a/proxy/vmess/account.pb.go +++ b/proxy/vmess/account.pb.go @@ -29,8 +29,6 @@ type Account struct { // ID of the account, in the form of a UUID, e.g., // "66ad4540-b58c-4ad2-9926-ea63445a9b57". Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - // Number of alternative IDs. Client and server must share the same number. - AlterId uint32 `protobuf:"varint,2,opt,name=alter_id,json=alterId,proto3" json:"alter_id,omitempty"` // Security settings. Only applies to client side. SecuritySettings *protocol.SecurityConfig `protobuf:"bytes,3,opt,name=security_settings,json=securitySettings,proto3" json:"security_settings,omitempty"` // Define tests enabled for this account @@ -76,13 +74,6 @@ func (x *Account) GetId() string { return "" } -func (x *Account) GetAlterId() uint32 { - if x != nil { - return x.AlterId - } - return 0 -} - func (x *Account) GetSecuritySettings() *protocol.SecurityConfig { if x != nil { return x.SecuritySettings @@ -104,24 +95,22 @@ var file_proxy_vmess_account_proto_rawDesc = []byte{ 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x1a, 0x1d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x68, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xac, 0x01, 0x0a, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x91, 0x01, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x6c, 0x74, 0x65, - 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x61, 0x6c, 0x74, 0x65, - 0x72, 0x49, 0x64, 0x12, 0x51, 0x0a, 0x11, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, - 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x74, 0x65, 0x73, 0x74, 0x73, 0x5f, - 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, - 0x65, 0x73, 0x74, 0x73, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x42, 0x52, 0x0a, 0x14, 0x63, - 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x6d, - 0x65, 0x73, 0x73, 0x50, 0x01, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x76, 0x6d, 0x65, 0x73, 0x73, 0xaa, 0x02, 0x10, 0x58, - 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x56, 0x6d, 0x65, 0x73, 0x73, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x51, 0x0a, 0x11, 0x73, 0x65, 0x63, 0x75, + 0x72, 0x69, 0x74, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, + 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x63, 0x75, 0x72, + 0x69, 0x74, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x73, 0x65, 0x63, 0x75, 0x72, + 0x69, 0x74, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x74, + 0x65, 0x73, 0x74, 0x73, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x73, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, + 0x42, 0x52, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x50, 0x01, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x76, 0x6d, 0x65, 0x73, + 0x73, 0xaa, 0x02, 0x10, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x56, + 0x6d, 0x65, 0x73, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/vmess/account.proto b/proxy/vmess/account.proto index 98dc681e..3fac6399 100644 --- a/proxy/vmess/account.proto +++ b/proxy/vmess/account.proto @@ -12,8 +12,6 @@ message Account { // ID of the account, in the form of a UUID, e.g., // "66ad4540-b58c-4ad2-9926-ea63445a9b57". string id = 1; - // Number of alternative IDs. Client and server must share the same number. - uint32 alter_id = 2; // Security settings. Only applies to client side. xray.common.protocol.SecurityConfig security_settings = 3; // Define tests enabled for this account diff --git a/proxy/vmess/encoding/auth.go b/proxy/vmess/encoding/auth.go index 09689cea..5d9623b1 100644 --- a/proxy/vmess/encoding/auth.go +++ b/proxy/vmess/encoding/auth.go @@ -17,6 +17,7 @@ func Authenticate(b []byte) uint32 { return fnv1hash.Sum32() } +// [DEPRECATED 2023-06] type NoOpAuthenticator struct{} func (NoOpAuthenticator) NonceSize() int { @@ -37,34 +38,6 @@ func (NoOpAuthenticator) Open(dst, nonce, ciphertext, additionalData []byte) ([] return append(dst[:0], ciphertext...), nil } -// FnvAuthenticator is an AEAD based on Fnv hash. -type FnvAuthenticator struct{} - -// NonceSize implements AEAD.NonceSize(). -func (*FnvAuthenticator) NonceSize() int { - return 0 -} - -// Overhead impelements AEAD.Overhead(). -func (*FnvAuthenticator) Overhead() int { - return 4 -} - -// Seal implements AEAD.Seal(). -func (*FnvAuthenticator) Seal(dst, nonce, plaintext, additionalData []byte) []byte { - dst = append(dst, 0, 0, 0, 0) - binary.BigEndian.PutUint32(dst, Authenticate(plaintext)) - return append(dst, plaintext...) -} - -// Open implements AEAD.Open(). -func (*FnvAuthenticator) Open(dst, nonce, ciphertext, additionalData []byte) ([]byte, error) { - if binary.BigEndian.Uint32(ciphertext[:4]) != Authenticate(ciphertext[4:]) { - return dst, newError("invalid authentication") - } - return append(dst, ciphertext[4:]...), nil -} - // GenerateChacha20Poly1305Key generates a 32-byte key from a given 16-byte array. func GenerateChacha20Poly1305Key(b []byte) []byte { key := make([]byte, 32) diff --git a/proxy/vmess/encoding/auth_test.go b/proxy/vmess/encoding/auth_test.go deleted file mode 100644 index ae83076f..00000000 --- a/proxy/vmess/encoding/auth_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package encoding_test - -import ( - "crypto/rand" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/xtls/xray-core/common" - . "github.com/xtls/xray-core/proxy/vmess/encoding" -) - -func TestFnvAuth(t *testing.T) { - fnvAuth := new(FnvAuthenticator) - - expectedText := make([]byte, 256) - _, err := rand.Read(expectedText) - common.Must(err) - - buffer := make([]byte, 512) - b := fnvAuth.Seal(buffer[:0], nil, expectedText, nil) - b, err = fnvAuth.Open(buffer[:0], nil, b, nil) - common.Must(err) - if r := cmp.Diff(b, expectedText); r != "" { - t.Error(r) - } -} diff --git a/proxy/vmess/encoding/client.go b/proxy/vmess/encoding/client.go index ba08843e..0b7a0098 100644 --- a/proxy/vmess/encoding/client.go +++ b/proxy/vmess/encoding/client.go @@ -5,11 +5,9 @@ import ( "context" "crypto/aes" "crypto/cipher" - "crypto/md5" "crypto/rand" "crypto/sha256" "encoding/binary" - "hash" "hash/fnv" "io" @@ -20,24 +18,13 @@ import ( "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/common/drain" "github.com/xtls/xray-core/common/protocol" - "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 { - common.Must2(serial.WriteUint64(h, uint64(t))) - common.Must2(serial.WriteUint64(h, uint64(t))) - common.Must2(serial.WriteUint64(h, uint64(t))) - common.Must2(serial.WriteUint64(h, uint64(t))) - return h.Sum(nil) -} - // ClientSession stores connection session info for VMess client. type ClientSession struct { - isAEAD bool - idHash protocol.IDHash requestBodyKey [16]byte requestBodyIV [16]byte responseBodyKey [16]byte @@ -49,11 +36,8 @@ type ClientSession struct { } // NewClientSession creates a new ClientSession. -func NewClientSession(ctx context.Context, isAEAD bool, idHash protocol.IDHash, behaviorSeed int64) *ClientSession { - session := &ClientSession{ - isAEAD: isAEAD, - idHash: idHash, - } +func NewClientSession(ctx context.Context, behaviorSeed int64) *ClientSession { + session := &ClientSession{} randomBytes := make([]byte, 33) // 16 + 16 + 1 common.Must2(rand.Read(randomBytes)) @@ -61,15 +45,10 @@ func NewClientSession(ctx context.Context, isAEAD bool, idHash protocol.IDHash, copy(session.requestBodyIV[:], randomBytes[16:32]) session.responseHeader = randomBytes[32] - if !session.isAEAD { - session.responseBodyKey = md5.Sum(session.requestBodyKey[:]) - session.responseBodyIV = md5.Sum(session.requestBodyIV[:]) - } else { - BodyKey := sha256.Sum256(session.requestBodyKey[:]) - copy(session.responseBodyKey[:], BodyKey[:16]) - BodyIV := sha256.Sum256(session.requestBodyIV[:]) - copy(session.responseBodyIV[:], BodyIV[:16]) - } + BodyKey := sha256.Sum256(session.requestBodyKey[:]) + copy(session.responseBodyKey[:], BodyKey[:16]) + BodyIV := sha256.Sum256(session.requestBodyIV[:]) + copy(session.responseBodyIV[:], BodyIV[:16]) { var err error session.readDrainer, err = drain.NewBehaviorSeedLimitedDrainer(behaviorSeed, 18, 3266, 64) @@ -83,13 +62,7 @@ func NewClientSession(ctx context.Context, isAEAD bool, idHash protocol.IDHash, } func (c *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writer io.Writer) error { - timestamp := protocol.NewTimestampGenerator(protocol.NowTime(), 30)() account := header.User.Account.(*vmess.MemoryAccount) - if !c.isAEAD { - idHash := c.idHash(account.AnyValidID().Bytes()) - common.Must2(serial.WriteUint64(idHash, uint64(timestamp))) - common.Must2(writer.Write(idHash.Sum(nil))) - } buffer := buf.New() defer buffer.Release() @@ -121,17 +94,10 @@ func (c *ClientSession) EncodeRequestHeader(header *protocol.RequestHeader, writ fnv1a.Sum(hashBytes[:0]) } - if !c.isAEAD { - iv := hashTimestamp(md5.New(), timestamp) - aesStream := crypto.NewAesEncryptionStream(account.ID.CmdKey(), iv) - aesStream.XORKeyStream(buffer.Bytes(), buffer.Bytes()) - common.Must2(writer.Write(buffer.Bytes())) - } else { - var fixedLengthCmdKey [16]byte - copy(fixedLengthCmdKey[:], account.ID.CmdKey()) - vmessout := vmessaead.SealVMessAEADHeader(fixedLengthCmdKey, buffer.Bytes()) - common.Must2(io.Copy(writer, bytes.NewReader(vmessout))) - } + var fixedLengthCmdKey [16]byte + copy(fixedLengthCmdKey[:], account.ID.CmdKey()) + vmessout := vmessaead.SealVMessAEADHeader(fixedLengthCmdKey, buffer.Bytes()) + common.Must2(io.Copy(writer, bytes.NewReader(vmessout))) return nil } @@ -165,19 +131,6 @@ func (c *ClientSession) EncodeRequestBody(request *protocol.RequestHeader, write } return buf.NewWriter(writer), nil - case protocol.SecurityType_LEGACY: - aesStream := crypto.NewAesEncryptionStream(c.requestBodyKey[:], c.requestBodyIV[:]) - cryptionWriter := crypto.NewCryptionWriter(aesStream, writer) - if request.Option.Has(protocol.RequestOptionChunkStream) { - auth := &crypto.AEADAuthenticator{ - AEAD: new(FnvAuthenticator), - NonceGenerator: crypto.GenerateEmptyBytes(), - AdditionalDataGenerator: crypto.GenerateEmptyBytes(), - } - return crypto.NewAuthenticationWriter(auth, sizeParser, cryptionWriter, request.Command.TransferType(), padding), nil - } - - return &buf.SequentialWriter{Writer: cryptionWriter}, nil case protocol.SecurityType_AES128_GCM: aead := crypto.NewAesGcm(c.requestBodyKey[:]) auth := &crypto.AEADAuthenticator{ @@ -225,53 +178,48 @@ func (c *ClientSession) EncodeRequestBody(request *protocol.RequestHeader, write } func (c *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.ResponseHeader, error) { - if !c.isAEAD { - aesStream := crypto.NewAesDecryptionStream(c.responseBodyKey[:], c.responseBodyIV[:]) - c.responseReader = crypto.NewCryptionReader(aesStream, reader) - } else { - aeadResponseHeaderLengthEncryptionKey := vmessaead.KDF16(c.responseBodyKey[:], vmessaead.KDFSaltConstAEADRespHeaderLenKey) - aeadResponseHeaderLengthEncryptionIV := vmessaead.KDF(c.responseBodyIV[:], vmessaead.KDFSaltConstAEADRespHeaderLenIV)[:12] + aeadResponseHeaderLengthEncryptionKey := vmessaead.KDF16(c.responseBodyKey[:], vmessaead.KDFSaltConstAEADRespHeaderLenKey) + aeadResponseHeaderLengthEncryptionIV := vmessaead.KDF(c.responseBodyIV[:], vmessaead.KDFSaltConstAEADRespHeaderLenIV)[:12] - aeadResponseHeaderLengthEncryptionKeyAESBlock := common.Must2(aes.NewCipher(aeadResponseHeaderLengthEncryptionKey)).(cipher.Block) - aeadResponseHeaderLengthEncryptionAEAD := common.Must2(cipher.NewGCM(aeadResponseHeaderLengthEncryptionKeyAESBlock)).(cipher.AEAD) + aeadResponseHeaderLengthEncryptionKeyAESBlock := common.Must2(aes.NewCipher(aeadResponseHeaderLengthEncryptionKey)).(cipher.Block) + aeadResponseHeaderLengthEncryptionAEAD := common.Must2(cipher.NewGCM(aeadResponseHeaderLengthEncryptionKeyAESBlock)).(cipher.AEAD) - var aeadEncryptedResponseHeaderLength [18]byte - var decryptedResponseHeaderLength int - var decryptedResponseHeaderLengthBinaryDeserializeBuffer uint16 + var aeadEncryptedResponseHeaderLength [18]byte + var decryptedResponseHeaderLength int + var decryptedResponseHeaderLengthBinaryDeserializeBuffer uint16 - if n, err := io.ReadFull(reader, aeadEncryptedResponseHeaderLength[:]); err != nil { - c.readDrainer.AcknowledgeReceive(n) - return nil, drain.WithError(c.readDrainer, reader, newError("Unable to Read Header Len").Base(err)) - } else { // nolint: golint - c.readDrainer.AcknowledgeReceive(n) - } - if decryptedResponseHeaderLengthBinaryBuffer, err := aeadResponseHeaderLengthEncryptionAEAD.Open(nil, aeadResponseHeaderLengthEncryptionIV, aeadEncryptedResponseHeaderLength[:], nil); err != nil { - return nil, drain.WithError(c.readDrainer, reader, newError("Failed To Decrypt Length").Base(err)) - } else { // nolint: golint - common.Must(binary.Read(bytes.NewReader(decryptedResponseHeaderLengthBinaryBuffer), binary.BigEndian, &decryptedResponseHeaderLengthBinaryDeserializeBuffer)) - decryptedResponseHeaderLength = int(decryptedResponseHeaderLengthBinaryDeserializeBuffer) - } + if n, err := io.ReadFull(reader, aeadEncryptedResponseHeaderLength[:]); err != nil { + c.readDrainer.AcknowledgeReceive(n) + return nil, drain.WithError(c.readDrainer, reader, newError("Unable to Read Header Len").Base(err)) + } else { // nolint: golint + c.readDrainer.AcknowledgeReceive(n) + } + if decryptedResponseHeaderLengthBinaryBuffer, err := aeadResponseHeaderLengthEncryptionAEAD.Open(nil, aeadResponseHeaderLengthEncryptionIV, aeadEncryptedResponseHeaderLength[:], nil); err != nil { + return nil, drain.WithError(c.readDrainer, reader, newError("Failed To Decrypt Length").Base(err)) + } else { // nolint: golint + common.Must(binary.Read(bytes.NewReader(decryptedResponseHeaderLengthBinaryBuffer), binary.BigEndian, &decryptedResponseHeaderLengthBinaryDeserializeBuffer)) + decryptedResponseHeaderLength = int(decryptedResponseHeaderLengthBinaryDeserializeBuffer) + } - aeadResponseHeaderPayloadEncryptionKey := vmessaead.KDF16(c.responseBodyKey[:], vmessaead.KDFSaltConstAEADRespHeaderPayloadKey) - aeadResponseHeaderPayloadEncryptionIV := vmessaead.KDF(c.responseBodyIV[:], vmessaead.KDFSaltConstAEADRespHeaderPayloadIV)[:12] + aeadResponseHeaderPayloadEncryptionKey := vmessaead.KDF16(c.responseBodyKey[:], vmessaead.KDFSaltConstAEADRespHeaderPayloadKey) + aeadResponseHeaderPayloadEncryptionIV := vmessaead.KDF(c.responseBodyIV[:], vmessaead.KDFSaltConstAEADRespHeaderPayloadIV)[:12] - aeadResponseHeaderPayloadEncryptionKeyAESBlock := common.Must2(aes.NewCipher(aeadResponseHeaderPayloadEncryptionKey)).(cipher.Block) - aeadResponseHeaderPayloadEncryptionAEAD := common.Must2(cipher.NewGCM(aeadResponseHeaderPayloadEncryptionKeyAESBlock)).(cipher.AEAD) + aeadResponseHeaderPayloadEncryptionKeyAESBlock := common.Must2(aes.NewCipher(aeadResponseHeaderPayloadEncryptionKey)).(cipher.Block) + aeadResponseHeaderPayloadEncryptionAEAD := common.Must2(cipher.NewGCM(aeadResponseHeaderPayloadEncryptionKeyAESBlock)).(cipher.AEAD) - encryptedResponseHeaderBuffer := make([]byte, decryptedResponseHeaderLength+16) + encryptedResponseHeaderBuffer := make([]byte, decryptedResponseHeaderLength+16) - if n, err := io.ReadFull(reader, encryptedResponseHeaderBuffer); err != nil { - c.readDrainer.AcknowledgeReceive(n) - return nil, drain.WithError(c.readDrainer, reader, newError("Unable to Read Header Data").Base(err)) - } else { // nolint: golint - c.readDrainer.AcknowledgeReceive(n) - } + if n, err := io.ReadFull(reader, encryptedResponseHeaderBuffer); err != nil { + c.readDrainer.AcknowledgeReceive(n) + return nil, drain.WithError(c.readDrainer, reader, newError("Unable to Read Header Data").Base(err)) + } else { // nolint: golint + c.readDrainer.AcknowledgeReceive(n) + } - if decryptedResponseHeaderBuffer, err := aeadResponseHeaderPayloadEncryptionAEAD.Open(nil, aeadResponseHeaderPayloadEncryptionIV, encryptedResponseHeaderBuffer, nil); err != nil { - return nil, drain.WithError(c.readDrainer, reader, newError("Failed To Decrypt Payload").Base(err)) - } else { // nolint: golint - c.responseReader = bytes.NewReader(decryptedResponseHeaderBuffer) - } + if decryptedResponseHeaderBuffer, err := aeadResponseHeaderPayloadEncryptionAEAD.Open(nil, aeadResponseHeaderPayloadEncryptionIV, encryptedResponseHeaderBuffer, nil); err != nil { + return nil, drain.WithError(c.readDrainer, reader, newError("Failed To Decrypt Payload").Base(err)) + } else { // nolint: golint + c.responseReader = bytes.NewReader(decryptedResponseHeaderBuffer) } buffer := buf.StackNew() @@ -302,10 +250,8 @@ func (c *ClientSession) DecodeResponseHeader(reader io.Reader) (*protocol.Respon header.Command = command } } - if c.isAEAD { - aesStream := crypto.NewAesDecryptionStream(c.responseBodyKey[:], c.responseBodyIV[:]) - c.responseReader = crypto.NewCryptionReader(aesStream, reader) - } + aesStream := crypto.NewAesDecryptionStream(c.responseBodyKey[:], c.responseBodyIV[:]) + c.responseReader = crypto.NewCryptionReader(aesStream, reader) return header, nil } @@ -340,17 +286,6 @@ func (c *ClientSession) DecodeResponseBody(request *protocol.RequestHeader, read } return buf.NewReader(reader), nil - case protocol.SecurityType_LEGACY: - if request.Option.Has(protocol.RequestOptionChunkStream) { - auth := &crypto.AEADAuthenticator{ - AEAD: new(FnvAuthenticator), - NonceGenerator: crypto.GenerateEmptyBytes(), - AdditionalDataGenerator: crypto.GenerateEmptyBytes(), - } - return crypto.NewAuthenticationReader(auth, sizeParser, c.responseReader, request.Command.TransferType(), padding), nil - } - - return buf.NewReader(c.responseReader), nil case protocol.SecurityType_AES128_GCM: aead := crypto.NewAesGcm(c.responseBodyKey[:]) diff --git a/proxy/vmess/encoding/commands.go b/proxy/vmess/encoding/commands.go index 1b420021..5a4d3708 100644 --- a/proxy/vmess/encoding/commands.go +++ b/proxy/vmess/encoding/commands.go @@ -101,7 +101,7 @@ func (f *CommandSwitchAccountFactory) Marshal(command interface{}, writer io.Wri idBytes := cmd.ID.Bytes() common.Must2(writer.Write(idBytes)) - common.Must2(serial.WriteUint16(writer, cmd.AlterIds)) + common.Must2(serial.WriteUint16(writer, 0)) // compatible with legacy alterId common.Must2(writer.Write([]byte{byte(cmd.Level)})) common.Must2(writer.Write([]byte{cmd.ValidMin})) @@ -130,12 +130,7 @@ func (f *CommandSwitchAccountFactory) Unmarshal(data []byte) (interface{}, error return nil, ErrInsufficientLength } cmd.ID, _ = uuid.ParseBytes(data[idStart : idStart+16]) - alterIDStart := idStart + 16 - if len(data) < alterIDStart+2 { - return nil, ErrInsufficientLength - } - cmd.AlterIds = binary.BigEndian.Uint16(data[alterIDStart : alterIDStart+2]) - levelStart := alterIDStart + 2 + levelStart := idStart + 16 + 2 if len(data) < levelStart+1 { return nil, ErrInsufficientLength } diff --git a/proxy/vmess/encoding/commands_test.go b/proxy/vmess/encoding/commands_test.go index 17892bb6..c5415959 100644 --- a/proxy/vmess/encoding/commands_test.go +++ b/proxy/vmess/encoding/commands_test.go @@ -16,7 +16,6 @@ func TestSwitchAccount(t *testing.T) { sa := &protocol.CommandSwitchAccount{ Port: 1234, ID: uuid.New(), - AlterIds: 1024, Level: 128, ValidMin: 16, } @@ -40,7 +39,6 @@ func TestSwitchAccountBugOffByOne(t *testing.T) { sa := &protocol.CommandSwitchAccount{ Port: 1234, ID: uuid.New(), - AlterIds: 1024, Level: 128, ValidMin: 16, } diff --git a/proxy/vmess/encoding/encoding_test.go b/proxy/vmess/encoding/encoding_test.go index a8fd8f3a..ddae29e1 100644 --- a/proxy/vmess/encoding/encoding_test.go +++ b/proxy/vmess/encoding/encoding_test.go @@ -41,7 +41,7 @@ func TestRequestSerialization(t *testing.T) { } buffer := buf.New() - client := NewClientSession(context.TODO(), true, protocol.DefaultIDHash, 0) + client := NewClientSession(context.TODO(), 0) common.Must(client.EncodeRequestHeader(expectedRequest, buffer)) buffer2 := buf.New() @@ -50,7 +50,7 @@ func TestRequestSerialization(t *testing.T) { sessionHistory := NewSessionHistory() defer common.Close(sessionHistory) - userValidator := vmess.NewTimedUserValidator(protocol.DefaultIDHash) + userValidator := vmess.NewTimedUserValidator() userValidator.Add(user) defer common.Close(userValidator) @@ -90,7 +90,7 @@ func TestInvalidRequest(t *testing.T) { } buffer := buf.New() - client := NewClientSession(context.TODO(), true, protocol.DefaultIDHash, 0) + client := NewClientSession(context.TODO(), 0) common.Must(client.EncodeRequestHeader(expectedRequest, buffer)) buffer2 := buf.New() @@ -99,7 +99,7 @@ func TestInvalidRequest(t *testing.T) { sessionHistory := NewSessionHistory() defer common.Close(sessionHistory) - userValidator := vmess.NewTimedUserValidator(protocol.DefaultIDHash) + userValidator := vmess.NewTimedUserValidator() userValidator.Add(user) defer common.Close(userValidator) @@ -130,7 +130,7 @@ func TestMuxRequest(t *testing.T) { } buffer := buf.New() - client := NewClientSession(context.TODO(), true, protocol.DefaultIDHash, 0) + client := NewClientSession(context.TODO(), 0) common.Must(client.EncodeRequestHeader(expectedRequest, buffer)) buffer2 := buf.New() @@ -139,7 +139,7 @@ func TestMuxRequest(t *testing.T) { sessionHistory := NewSessionHistory() defer common.Close(sessionHistory) - userValidator := vmess.NewTimedUserValidator(protocol.DefaultIDHash) + userValidator := vmess.NewTimedUserValidator() userValidator.Add(user) defer common.Close(userValidator) diff --git a/proxy/vmess/encoding/server.go b/proxy/vmess/encoding/server.go index 4bdb6fb7..371bfdc0 100644 --- a/proxy/vmess/encoding/server.go +++ b/proxy/vmess/encoding/server.go @@ -4,7 +4,6 @@ import ( "bytes" "crypto/aes" "crypto/cipher" - "crypto/md5" "crypto/sha256" "encoding/binary" "hash/fnv" @@ -102,10 +101,6 @@ type ServerSession struct { responseBodyIV [16]byte responseWriter io.Writer responseHeader byte - - isAEADRequest bool - - isAEADForced bool } // NewServerSession creates a new ServerSession, using the given UserValidator. @@ -117,17 +112,12 @@ func NewServerSession(validator *vmess.TimedUserValidator, sessionHistory *Sessi } } -// SetAEADForced sets isAEADForced for a ServerSession. -func (s *ServerSession) SetAEADForced(isAEADForced bool) { - s.isAEADForced = isAEADForced -} - func parseSecurityType(b byte) protocol.SecurityType { if _, f := protocol.SecurityType_name[int32(b)]; f { st := protocol.SecurityType(b) // For backward compatibility. if st == protocol.SecurityType_UNKNOWN { - st = protocol.SecurityType_LEGACY + st = protocol.SecurityType_AUTO } return st } @@ -183,26 +173,6 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader, isDrain bool) (*pr } } decryptor = bytes.NewReader(aeadData) - s.isAEADRequest = true - - case errorAEAD == vmessaead.ErrNotFound: - userLegacy, timestamp, valid, userValidationError := s.userValidator.Get(buffer.Bytes()) - if !valid || userValidationError != nil { - return nil, drainConnection(newError("invalid user").Base(userValidationError)) - } - if s.isAEADForced { - return nil, drainConnection(newError("invalid user: VMessAEAD is enforced and a non VMessAEAD connection is received. You can still disable this security feature with environment variable xray.vmess.aead.forced = false . You will not be able to enable legacy header workaround in the future.")) - } - if s.userValidator.ShouldShowLegacyWarn() { - newError("Critical Warning: potentially invalid user: a non VMessAEAD connection is received. From 2022 Jan 1st, this kind of connection will be rejected by default. You should update or replace your client software now. This message will not be shown for further violation on this inbound.").AtWarning().WriteToLog() - } - user = userLegacy - iv := hashTimestamp(md5.New(), timestamp) - vmessAccount = userLegacy.Account.(*vmess.MemoryAccount) - - aesStream := crypto.NewAesDecryptionStream(vmessAccount.ID.CmdKey(), iv) - decryptor = crypto.NewCryptionReader(aesStream, reader) - default: return nil, drainConnection(newError("invalid user").Base(errorAEAD)) } @@ -225,15 +195,7 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader, isDrain bool) (*pr sid.key = s.requestBodyKey sid.nonce = s.requestBodyIV if !s.sessionHistory.addIfNotExits(sid) { - if !s.isAEADRequest { - drainErr := s.userValidator.BurnTaintFuse(fixedSizeAuthID[:]) - if drainErr != nil { - return nil, drainConnection(newError("duplicated session id, possibly under replay attack, and failed to taint userHash").Base(drainErr)) - } - return nil, drainConnection(newError("duplicated session id, possibly under replay attack, userHash tainted")) - } else { - return nil, newError("duplicated session id, possibly under replay attack, but this is a AEAD request") - } + return nil, newError("duplicated session id, possibly under replay attack, but this is a AEAD request") } s.responseHeader = buffer.Byte(33) // 1 byte @@ -257,25 +219,11 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader, isDrain bool) (*pr if paddingLen > 0 { if _, err := buffer.ReadFullFrom(decryptor, int32(paddingLen)); err != nil { - if !s.isAEADRequest { - burnErr := s.userValidator.BurnTaintFuse(fixedSizeAuthID[:]) - if burnErr != nil { - return nil, newError("failed to read padding, failed to taint userHash").Base(burnErr).Base(err) - } - return nil, newError("failed to read padding, userHash tainted").Base(err) - } return nil, newError("failed to read padding").Base(err) } } if _, err := buffer.ReadFullFrom(decryptor, 4); err != nil { - if !s.isAEADRequest { - burnErr := s.userValidator.BurnTaintFuse(fixedSizeAuthID[:]) - if burnErr != nil { - return nil, newError("failed to read checksum, failed to taint userHash").Base(burnErr).Base(err) - } - return nil, newError("failed to read checksum, userHash tainted").Base(err) - } return nil, newError("failed to read checksum").Base(err) } @@ -285,17 +233,7 @@ func (s *ServerSession) DecodeRequestHeader(reader io.Reader, isDrain bool) (*pr expectedHash := binary.BigEndian.Uint32(buffer.BytesFrom(-4)) if actualHash != expectedHash { - if !s.isAEADRequest { - Autherr := newError("invalid auth, legacy userHash tainted") - burnErr := s.userValidator.BurnTaintFuse(fixedSizeAuthID[:]) - if burnErr != nil { - Autherr = newError("invalid auth, can't taint legacy userHash").Base(burnErr) - } - // It is possible that we are under attack described in https://github.com/xray/xray-core/issues/2523 - return nil, drainConnection(Autherr) - } else { - return nil, newError("invalid auth, but this is a AEAD request") - } + return nil, newError("invalid auth, but this is a AEAD request") } if request.Address == nil { @@ -340,19 +278,6 @@ func (s *ServerSession) DecodeRequestBody(request *protocol.RequestHeader, reade } return buf.NewReader(reader), nil - case protocol.SecurityType_LEGACY: - aesStream := crypto.NewAesDecryptionStream(s.requestBodyKey[:], s.requestBodyIV[:]) - cryptionReader := crypto.NewCryptionReader(aesStream, reader) - if request.Option.Has(protocol.RequestOptionChunkStream) { - auth := &crypto.AEADAuthenticator{ - AEAD: new(FnvAuthenticator), - NonceGenerator: crypto.GenerateEmptyBytes(), - AdditionalDataGenerator: crypto.GenerateEmptyBytes(), - } - return crypto.NewAuthenticationReader(auth, sizeParser, cryptionReader, request.Command.TransferType(), padding), nil - } - return buf.NewReader(cryptionReader), nil - case protocol.SecurityType_AES128_GCM: aead := crypto.NewAesGcm(s.requestBodyKey[:]) auth := &crypto.AEADAuthenticator{ @@ -403,25 +328,17 @@ func (s *ServerSession) DecodeRequestBody(request *protocol.RequestHeader, reade // EncodeResponseHeader writes encoded response header into the given writer. func (s *ServerSession) EncodeResponseHeader(header *protocol.ResponseHeader, writer io.Writer) { var encryptionWriter io.Writer - if !s.isAEADRequest { - s.responseBodyKey = md5.Sum(s.requestBodyKey[:]) - s.responseBodyIV = md5.Sum(s.requestBodyIV[:]) - } else { - BodyKey := sha256.Sum256(s.requestBodyKey[:]) - copy(s.responseBodyKey[:], BodyKey[:16]) - BodyIV := sha256.Sum256(s.requestBodyIV[:]) - copy(s.responseBodyIV[:], BodyIV[:16]) - } + BodyKey := sha256.Sum256(s.requestBodyKey[:]) + copy(s.responseBodyKey[:], BodyKey[:16]) + BodyIV := sha256.Sum256(s.requestBodyIV[:]) + copy(s.responseBodyIV[:], BodyIV[:16]) aesStream := crypto.NewAesEncryptionStream(s.responseBodyKey[:], s.responseBodyIV[:]) encryptionWriter = crypto.NewCryptionWriter(aesStream, writer) s.responseWriter = encryptionWriter aeadEncryptedHeaderBuffer := bytes.NewBuffer(nil) - - if s.isAEADRequest { - encryptionWriter = aeadEncryptedHeaderBuffer - } + encryptionWriter = aeadEncryptedHeaderBuffer common.Must2(encryptionWriter.Write([]byte{s.responseHeader, byte(header.Option)})) err := MarshalCommand(header.Command, encryptionWriter) @@ -429,31 +346,29 @@ func (s *ServerSession) EncodeResponseHeader(header *protocol.ResponseHeader, wr common.Must2(encryptionWriter.Write([]byte{0x00, 0x00})) } - if s.isAEADRequest { - aeadResponseHeaderLengthEncryptionKey := vmessaead.KDF16(s.responseBodyKey[:], vmessaead.KDFSaltConstAEADRespHeaderLenKey) - aeadResponseHeaderLengthEncryptionIV := vmessaead.KDF(s.responseBodyIV[:], vmessaead.KDFSaltConstAEADRespHeaderLenIV)[:12] + aeadResponseHeaderLengthEncryptionKey := vmessaead.KDF16(s.responseBodyKey[:], vmessaead.KDFSaltConstAEADRespHeaderLenKey) + aeadResponseHeaderLengthEncryptionIV := vmessaead.KDF(s.responseBodyIV[:], vmessaead.KDFSaltConstAEADRespHeaderLenIV)[:12] - aeadResponseHeaderLengthEncryptionKeyAESBlock := common.Must2(aes.NewCipher(aeadResponseHeaderLengthEncryptionKey)).(cipher.Block) - aeadResponseHeaderLengthEncryptionAEAD := common.Must2(cipher.NewGCM(aeadResponseHeaderLengthEncryptionKeyAESBlock)).(cipher.AEAD) + aeadResponseHeaderLengthEncryptionKeyAESBlock := common.Must2(aes.NewCipher(aeadResponseHeaderLengthEncryptionKey)).(cipher.Block) + aeadResponseHeaderLengthEncryptionAEAD := common.Must2(cipher.NewGCM(aeadResponseHeaderLengthEncryptionKeyAESBlock)).(cipher.AEAD) - aeadResponseHeaderLengthEncryptionBuffer := bytes.NewBuffer(nil) + aeadResponseHeaderLengthEncryptionBuffer := bytes.NewBuffer(nil) - decryptedResponseHeaderLengthBinaryDeserializeBuffer := uint16(aeadEncryptedHeaderBuffer.Len()) + decryptedResponseHeaderLengthBinaryDeserializeBuffer := uint16(aeadEncryptedHeaderBuffer.Len()) - common.Must(binary.Write(aeadResponseHeaderLengthEncryptionBuffer, binary.BigEndian, decryptedResponseHeaderLengthBinaryDeserializeBuffer)) + common.Must(binary.Write(aeadResponseHeaderLengthEncryptionBuffer, binary.BigEndian, decryptedResponseHeaderLengthBinaryDeserializeBuffer)) - AEADEncryptedLength := aeadResponseHeaderLengthEncryptionAEAD.Seal(nil, aeadResponseHeaderLengthEncryptionIV, aeadResponseHeaderLengthEncryptionBuffer.Bytes(), nil) - common.Must2(io.Copy(writer, bytes.NewReader(AEADEncryptedLength))) + AEADEncryptedLength := aeadResponseHeaderLengthEncryptionAEAD.Seal(nil, aeadResponseHeaderLengthEncryptionIV, aeadResponseHeaderLengthEncryptionBuffer.Bytes(), nil) + common.Must2(io.Copy(writer, bytes.NewReader(AEADEncryptedLength))) - aeadResponseHeaderPayloadEncryptionKey := vmessaead.KDF16(s.responseBodyKey[:], vmessaead.KDFSaltConstAEADRespHeaderPayloadKey) - aeadResponseHeaderPayloadEncryptionIV := vmessaead.KDF(s.responseBodyIV[:], vmessaead.KDFSaltConstAEADRespHeaderPayloadIV)[:12] + aeadResponseHeaderPayloadEncryptionKey := vmessaead.KDF16(s.responseBodyKey[:], vmessaead.KDFSaltConstAEADRespHeaderPayloadKey) + aeadResponseHeaderPayloadEncryptionIV := vmessaead.KDF(s.responseBodyIV[:], vmessaead.KDFSaltConstAEADRespHeaderPayloadIV)[:12] - aeadResponseHeaderPayloadEncryptionKeyAESBlock := common.Must2(aes.NewCipher(aeadResponseHeaderPayloadEncryptionKey)).(cipher.Block) - aeadResponseHeaderPayloadEncryptionAEAD := common.Must2(cipher.NewGCM(aeadResponseHeaderPayloadEncryptionKeyAESBlock)).(cipher.AEAD) + aeadResponseHeaderPayloadEncryptionKeyAESBlock := common.Must2(aes.NewCipher(aeadResponseHeaderPayloadEncryptionKey)).(cipher.Block) + aeadResponseHeaderPayloadEncryptionAEAD := common.Must2(cipher.NewGCM(aeadResponseHeaderPayloadEncryptionKeyAESBlock)).(cipher.AEAD) - aeadEncryptedHeaderPayload := aeadResponseHeaderPayloadEncryptionAEAD.Seal(nil, aeadResponseHeaderPayloadEncryptionIV, aeadEncryptedHeaderBuffer.Bytes(), nil) - common.Must2(io.Copy(writer, bytes.NewReader(aeadEncryptedHeaderPayload))) - } + aeadEncryptedHeaderPayload := aeadResponseHeaderPayloadEncryptionAEAD.Seal(nil, aeadResponseHeaderPayloadEncryptionIV, aeadEncryptedHeaderBuffer.Bytes(), nil) + common.Must2(io.Copy(writer, bytes.NewReader(aeadEncryptedHeaderPayload))) } // EncodeResponseBody returns a Writer that auto-encrypt content written by caller. @@ -487,17 +402,6 @@ func (s *ServerSession) EncodeResponseBody(request *protocol.RequestHeader, writ } return buf.NewWriter(writer), nil - case protocol.SecurityType_LEGACY: - if request.Option.Has(protocol.RequestOptionChunkStream) { - auth := &crypto.AEADAuthenticator{ - AEAD: new(FnvAuthenticator), - NonceGenerator: crypto.GenerateEmptyBytes(), - AdditionalDataGenerator: crypto.GenerateEmptyBytes(), - } - return crypto.NewAuthenticationWriter(auth, sizeParser, s.responseWriter, request.Command.TransferType(), padding), nil - } - return &buf.SequentialWriter{Writer: s.responseWriter}, nil - case protocol.SecurityType_AES128_GCM: aead := crypto.NewAesGcm(s.responseBodyKey[:]) auth := &crypto.AEADAuthenticator{ diff --git a/proxy/vmess/inbound/config.pb.go b/proxy/vmess/inbound/config.pb.go index a301cede..663256aa 100644 --- a/proxy/vmess/inbound/config.pb.go +++ b/proxy/vmess/inbound/config.pb.go @@ -73,8 +73,7 @@ type DefaultConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - AlterId uint32 `protobuf:"varint,1,opt,name=alter_id,json=alterId,proto3" json:"alter_id,omitempty"` - Level uint32 `protobuf:"varint,2,opt,name=level,proto3" json:"level,omitempty"` + Level uint32 `protobuf:"varint,2,opt,name=level,proto3" json:"level,omitempty"` } func (x *DefaultConfig) Reset() { @@ -109,13 +108,6 @@ func (*DefaultConfig) Descriptor() ([]byte, []int) { return file_proxy_vmess_inbound_config_proto_rawDescGZIP(), []int{1} } -func (x *DefaultConfig) GetAlterId() uint32 { - if x != nil { - return x.AlterId - } - return 0 -} - func (x *DefaultConfig) GetLevel() uint32 { if x != nil { return x.Level @@ -128,10 +120,9 @@ type Config struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - User []*protocol.User `protobuf:"bytes,1,rep,name=user,proto3" json:"user,omitempty"` - Default *DefaultConfig `protobuf:"bytes,2,opt,name=default,proto3" json:"default,omitempty"` - Detour *DetourConfig `protobuf:"bytes,3,opt,name=detour,proto3" json:"detour,omitempty"` - SecureEncryptionOnly bool `protobuf:"varint,4,opt,name=secure_encryption_only,json=secureEncryptionOnly,proto3" json:"secure_encryption_only,omitempty"` + User []*protocol.User `protobuf:"bytes,1,rep,name=user,proto3" json:"user,omitempty"` + Default *DefaultConfig `protobuf:"bytes,2,opt,name=default,proto3" json:"default,omitempty"` + Detour *DetourConfig `protobuf:"bytes,3,opt,name=detour,proto3" json:"detour,omitempty"` // 4 is for legacy setting } func (x *Config) Reset() { @@ -187,13 +178,6 @@ func (x *Config) GetDetour() *DetourConfig { return nil } -func (x *Config) GetSecureEncryptionOnly() bool { - if x != nil { - return x.SecureEncryptionOnly - } - return false -} - var File_proxy_vmess_inbound_config_proto protoreflect.FileDescriptor var file_proxy_vmess_inbound_config_proto_rawDesc = []byte{ @@ -204,34 +188,29 @@ var file_proxy_vmess_inbound_config_proto_rawDesc = []byte{ 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x1e, 0x0a, 0x0c, 0x44, 0x65, 0x74, 0x6f, 0x75, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x74, 0x6f, 0x22, 0x40, 0x0a, 0x0d, 0x44, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x6c, 0x74, - 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07, 0x61, 0x6c, 0x74, - 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x22, 0xf1, 0x01, 0x0a, 0x06, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2e, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, - 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x41, 0x0a, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, - 0x64, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, - 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x3e, 0x0a, 0x06, 0x64, 0x65, 0x74, 0x6f, - 0x75, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6e, 0x62, 0x6f, - 0x75, 0x6e, 0x64, 0x2e, 0x44, 0x65, 0x74, 0x6f, 0x75, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x06, 0x64, 0x65, 0x74, 0x6f, 0x75, 0x72, 0x12, 0x34, 0x0a, 0x16, 0x73, 0x65, 0x63, 0x75, - 0x72, 0x65, 0x5f, 0x65, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x6e, - 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x14, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, - 0x45, 0x6e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x6e, 0x6c, 0x79, 0x42, 0x6a, - 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x2e, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x50, 0x01, - 0x5a, 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x2f, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x2f, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0xaa, - 0x02, 0x18, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x56, 0x6d, 0x65, - 0x73, 0x73, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x74, 0x6f, 0x22, 0x25, 0x0a, 0x0d, 0x44, 0x65, 0x66, 0x61, + 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, + 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x22, + 0xbb, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2e, 0x0a, 0x04, 0x75, 0x73, + 0x65, 0x72, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, + 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x41, 0x0a, 0x07, 0x64, 0x65, + 0x66, 0x61, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x2e, 0x69, + 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x2e, 0x44, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x07, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x12, 0x3e, 0x0a, + 0x06, 0x64, 0x65, 0x74, 0x6f, 0x75, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x76, 0x6d, 0x65, 0x73, 0x73, + 0x2e, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x2e, 0x44, 0x65, 0x74, 0x6f, 0x75, 0x72, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x06, 0x64, 0x65, 0x74, 0x6f, 0x75, 0x72, 0x42, 0x6a, 0x0a, + 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, + 0x76, 0x6d, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x50, 0x01, 0x5a, + 0x2d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, + 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2f, 0x76, 0x6d, 0x65, 0x73, 0x73, 0x2f, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0xaa, 0x02, + 0x18, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x56, 0x6d, 0x65, 0x73, + 0x73, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/proxy/vmess/inbound/config.proto b/proxy/vmess/inbound/config.proto index 9fc7e36f..7da1d581 100644 --- a/proxy/vmess/inbound/config.proto +++ b/proxy/vmess/inbound/config.proto @@ -13,7 +13,6 @@ message DetourConfig { } message DefaultConfig { - uint32 alter_id = 1; uint32 level = 2; } @@ -21,5 +20,5 @@ message Config { repeated xray.common.protocol.User user = 1; DefaultConfig default = 2; DetourConfig detour = 3; - bool secure_encryption_only = 4; + // 4 is for legacy setting } diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index eb24a6c6..f427bc6b 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -14,7 +14,6 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/log" "github.com/xtls/xray-core/common/net" - "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/common/signal" @@ -29,23 +28,16 @@ import ( "github.com/xtls/xray-core/transport/internet/stat" ) -var ( - aeadForced = false - aeadForced2022 = false -) - type userByEmail struct { sync.Mutex cache map[string]*protocol.MemoryUser defaultLevel uint32 - defaultAlterIDs uint16 } func newUserByEmail(config *DefaultConfig) *userByEmail { return &userByEmail{ cache: make(map[string]*protocol.MemoryUser), defaultLevel: config.Level, - defaultAlterIDs: uint16(config.AlterId), } } @@ -77,7 +69,6 @@ func (v *userByEmail) Get(email string) (*protocol.MemoryUser, bool) { id := uuid.New() rawAccount := &vmess.Account{ Id: id.String(), - AlterId: uint32(v.defaultAlterIDs), } account, err := rawAccount.AsAccount() common.Must(err) @@ -112,7 +103,6 @@ type Handler struct { usersByEmail *userByEmail detours *DetourConfig sessionHistory *encoding.SessionHistory - secure bool } // New creates a new VMess inbound handler. @@ -121,11 +111,10 @@ func New(ctx context.Context, config *Config) (*Handler, error) { handler := &Handler{ policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), inboundHandlerManager: v.GetFeature(feature_inbound.ManagerType()).(feature_inbound.Manager), - clients: vmess.NewTimedUserValidator(protocol.DefaultIDHash), + clients: vmess.NewTimedUserValidator(), detours: config.Detour, usersByEmail: newUserByEmail(config.GetDefaultValue()), sessionHistory: encoding.NewSessionHistory(), - secure: config.SecureEncryptionOnly, } for _, user := range config.User { @@ -145,7 +134,6 @@ func New(ctx context.Context, config *Config) (*Handler, error) { // Close implements common.Closable. func (h *Handler) Close() error { return errors.Combine( - h.clients.Close(), h.sessionHistory.Close(), common.Close(h.usersByEmail)) } @@ -219,10 +207,6 @@ func transferResponse(timer signal.ActivityUpdater, session *encoding.ServerSess return nil } -func isInsecureEncryption(s protocol.SecurityType) bool { - return s == protocol.SecurityType_NONE || s == protocol.SecurityType_LEGACY || s == protocol.SecurityType_UNKNOWN -} - // Process implements proxy.Inbound.Process(). func (h *Handler) Process(ctx context.Context, network net.Network, connection stat.Connection, dispatcher routing.Dispatcher) error { sessionPolicy := h.policyManager.ForLevel(0) @@ -241,7 +225,6 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s reader := &buf.BufferedReader{Reader: buf.NewReader(connection)} svrSession := encoding.NewServerSession(h.clients, h.sessionHistory) - svrSession.SetAEADForced(aeadForced) request, err := svrSession.DecodeRequestHeader(reader, isDrain) if err != nil { if errors.Cause(err) != io.EOF { @@ -256,17 +239,6 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s return err } - if h.secure && isInsecureEncryption(request.Security) { - log.Record(&log.AccessMessage{ - From: connection.RemoteAddr(), - To: "", - Status: log.AccessRejected, - Reason: "Insecure encryption", - Email: request.User.Email, - }) - return newError("client is using insecure encryption: ", request.Security) - } - if request.Command != protocol.RequestCommandMux { ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{ From: connection.RemoteAddr(), @@ -361,7 +333,6 @@ func (h *Handler) generateCommand(ctx context.Context, request *protocol.Request return &protocol.CommandSwitchAccount{ Port: port, ID: account.ID.UUID(), - AlterIds: uint16(len(account.AlterIDs)), Level: user.Level, ValidMin: byte(availableMin), } @@ -376,18 +347,4 @@ func init() { common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { return New(ctx, config.(*Config)) })) - - defaultFlagValue := "NOT_DEFINED_AT_ALL" - - if time.Now().Year() >= 2022 { - defaultFlagValue = "true_by_default_2022" - } - - isAeadForced := platform.NewEnvFlag("xray.vmess.aead.forced").GetValue(func() string { return defaultFlagValue }) - aeadForced = (isAeadForced == "true") - - if isAeadForced == "true_by_default_2022" { - aeadForced = true - aeadForced2022 = true - } } diff --git a/proxy/vmess/outbound/command.go b/proxy/vmess/outbound/command.go index 00c6fac5..07df935c 100644 --- a/proxy/vmess/outbound/command.go +++ b/proxy/vmess/outbound/command.go @@ -12,9 +12,8 @@ import ( func (h *Handler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) { rawAccount := &vmess.Account{ Id: cmd.ID.String(), - AlterId: uint32(cmd.AlterIds), SecuritySettings: &protocol.SecurityConfig{ - Type: protocol.SecurityType_LEGACY, + Type: protocol.SecurityType_AUTO, }, } diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index 64c29225..fc77f07f 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -128,11 +128,6 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte input := link.Reader output := link.Writer - isAEAD := false - if !aeadDisabled && len(account.AlterIDs) == 0 { - isAEAD = true - } - hashkdf := hmac.New(sha256.New, []byte("VMessBF")) hashkdf.Write(account.ID.Bytes()) @@ -144,7 +139,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte newCtx, newCancel = context.WithCancel(context.Background()) } - session := encoding.NewClientSession(ctx, isAEAD, protocol.DefaultIDHash, int64(behaviorSeed)) + session := encoding.NewClientSession(ctx, int64(behaviorSeed)) sessionPolicy := h.policyManager.ForLevel(request.User.Level) ctx, cancel := context.WithCancel(ctx) @@ -233,7 +228,6 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte var ( enablePadding = false - aeadDisabled = false ) func shouldEnablePadding(s protocol.SecurityType) bool { @@ -251,9 +245,4 @@ func init() { if paddingValue != defaultFlagValue { enablePadding = true } - - isAeadDisabled := platform.NewEnvFlag("xray.vmess.aead.disabled").GetValue(func() string { return defaultFlagValue }) - if isAeadDisabled == "true" { - aeadDisabled = true - } } diff --git a/proxy/vmess/validator.go b/proxy/vmess/validator.go index c638a23b..6cc96927 100644 --- a/proxy/vmess/validator.go +++ b/proxy/vmess/validator.go @@ -6,146 +6,39 @@ import ( "hash/crc64" "strings" "sync" - "sync/atomic" - "time" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/common/protocol" - "github.com/xtls/xray-core/common/serial" - "github.com/xtls/xray-core/common/task" "github.com/xtls/xray-core/proxy/vmess/aead" ) -const ( - updateInterval = 10 * time.Second - cacheDurationSec = 120 -) - -type user struct { - user protocol.MemoryUser - lastSec protocol.Timestamp -} - // TimedUserValidator is a user Validator based on time. type TimedUserValidator struct { sync.RWMutex - users []*user - userHash map[[16]byte]indexTimePair - hasher protocol.IDHash - baseTime protocol.Timestamp - task *task.Periodic + users []*protocol.MemoryUser behaviorSeed uint64 behaviorFused bool aeadDecoderHolder *aead.AuthIDDecoderHolder - - legacyWarnShown bool -} - -type indexTimePair struct { - user *user - timeInc uint32 - - taintedFuse *uint32 } // NewTimedUserValidator creates a new TimedUserValidator. -func NewTimedUserValidator(hasher protocol.IDHash) *TimedUserValidator { +func NewTimedUserValidator() *TimedUserValidator { tuv := &TimedUserValidator{ - users: make([]*user, 0, 16), - userHash: make(map[[16]byte]indexTimePair, 1024), - hasher: hasher, - baseTime: protocol.Timestamp(time.Now().Unix() - cacheDurationSec*2), + users: make([]*protocol.MemoryUser, 0, 16), aeadDecoderHolder: aead.NewAuthIDDecoderHolder(), } - tuv.task = &task.Periodic{ - Interval: updateInterval, - Execute: func() error { - tuv.updateUserHash() - return nil - }, - } - common.Must(tuv.task.Start()) 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 - genHashForID := func(id *protocol.ID) { - idHash := v.hasher(id.Bytes()) - genBeginSec := user.lastSec - if genBeginSec < nowSec-cacheDurationSec { - genBeginSec = nowSec - cacheDurationSec - } - for ts := genBeginSec; ts <= genEndSec; ts++ { - common.Must2(serial.WriteUint64(idHash, uint64(ts))) - idHash.Sum(hashValue[:0]) - idHash.Reset() - - v.userHash[hashValue] = indexTimePair{ - user: user, - timeInc: uint32(ts - v.baseTime), - taintedFuse: new(uint32), - } - } - } - - account := user.user.Account.(*MemoryAccount) - - genHashForID(account.ID) - for _, id := range account.AlterIDs { - genHashForID(id) - } - user.lastSec = genEndSec -} - -func (v *TimedUserValidator) removeExpiredHashes(expire uint32) { - for key, pair := range v.userHash { - if pair.timeInc < expire { - delete(v.userHash, key) - } - } -} - -func (v *TimedUserValidator) updateUserHash() { - now := time.Now() - nowSec := protocol.Timestamp(now.Unix()) - - v.Lock() - defer v.Unlock() - - for _, user := range v.users { - v.generateNewHashes(nowSec, user) - } - - expire := protocol.Timestamp(now.Unix() - cacheDurationSec) - if expire > v.baseTime { - v.removeExpiredHashes(uint32(expire - v.baseTime)) - } -} - func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error { v.Lock() defer v.Unlock() - nowSec := time.Now().Unix() + v.users = append(v.users, u) - uu := &user{ - user: *u, - lastSec: protocol.Timestamp(nowSec - cacheDurationSec), - } - v.users = append(v.users, uu) - v.generateNewHashes(protocol.Timestamp(nowSec), uu) - - account := uu.user.Account.(*MemoryAccount) + account := u.Account.(*MemoryAccount) if !v.behaviorFused { hashkdf := hmac.New(sha256.New, []byte("VMESSBSKDF")) hashkdf.Write(account.ID.Bytes()) @@ -159,25 +52,6 @@ func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error { return nil } -func (v *TimedUserValidator) Get(userHash []byte) (*protocol.MemoryUser, protocol.Timestamp, bool, error) { - v.RLock() - defer v.RUnlock() - - v.behaviorFused = true - - var fixedSizeHash [16]byte - copy(fixedSizeHash[:], userHash) - pair, found := v.userHash[fixedSizeHash] - if found { - user := pair.user.user - if atomic.LoadUint32(pair.taintedFuse) == 0 { - return &user, protocol.Timestamp(pair.timeInc) + v.baseTime, true, nil - } - return nil, 0, false, ErrTainted - } - return nil, 0, false, ErrNotFound -} - func (v *TimedUserValidator) GetAEAD(userHash []byte) (*protocol.MemoryUser, bool, error) { v.RLock() defer v.RUnlock() @@ -199,10 +73,10 @@ func (v *TimedUserValidator) Remove(email string) bool { email = strings.ToLower(email) idx := -1 for i, u := range v.users { - if strings.EqualFold(u.user.Email, email) { + if strings.EqualFold(u.Email, email) { idx = i var cmdkeyfl [16]byte - copy(cmdkeyfl[:], u.user.Account.(*MemoryAccount).ID.CmdKey()) + copy(cmdkeyfl[:], u.Account.(*MemoryAccount).ID.CmdKey()) v.aeadDecoderHolder.RemoveUser(cmdkeyfl) break } @@ -219,11 +93,6 @@ func (v *TimedUserValidator) Remove(email string) bool { return true } -// Close implements common.Closable. -func (v *TimedUserValidator) Close() error { - return v.task.Close() -} - func (v *TimedUserValidator) GetBehaviorSeed() uint64 { v.Lock() defer v.Unlock() @@ -235,36 +104,6 @@ func (v *TimedUserValidator) GetBehaviorSeed() uint64 { return v.behaviorSeed } -func (v *TimedUserValidator) BurnTaintFuse(userHash []byte) error { - v.RLock() - defer v.RUnlock() - - var userHashFL [16]byte - copy(userHashFL[:], userHash) - - pair, found := v.userHash[userHashFL] - if found { - if atomic.CompareAndSwapUint32(pair.taintedFuse, 0, 1) { - return nil - } - return ErrTainted - } - return ErrNotFound -} - -/* - ShouldShowLegacyWarn will return whether a Legacy Warning should be shown - -Not guaranteed to only return true once for every inbound, but it is okay. -*/ -func (v *TimedUserValidator) ShouldShowLegacyWarn() bool { - if v.legacyWarnShown { - return false - } - v.legacyWarnShown = true - return true -} - var ErrNotFound = newError("Not Found") var ErrTainted = newError("ErrTainted") diff --git a/proxy/vmess/validator_test.go b/proxy/vmess/validator_test.go index ee170655..83313cbc 100644 --- a/proxy/vmess/validator_test.go +++ b/proxy/vmess/validator_test.go @@ -5,7 +5,6 @@ import ( "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/protocol" - "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/uuid" . "github.com/xtls/xray-core/proxy/vmess" ) @@ -16,81 +15,9 @@ func toAccount(a *Account) protocol.Account { return account } -func TestUserValidator(t *testing.T) { - hasher := protocol.DefaultIDHash - v := NewTimedUserValidator(hasher) - defer common.Close(v) - - id := uuid.New() - user := &protocol.MemoryUser{ - Email: "test", - Account: toAccount(&Account{ - Id: id.String(), - }), - } - common.Must(v.Add(user)) - - { - 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) - - euser, ets, found, _ := v.Get(userHash) - if !found { - t.Fatal("user not found") - } - if euser.Email != user.Email { - t.Error("unexpected user email: ", euser.Email, " want ", user.Email) - } - if int64(ets) != ts { - t.Error("unexpected timestamp: ", ets, " want ", ts) - } - } - - testSmallLag(0) - testSmallLag(40) - testSmallLag(-40) - testSmallLag(80) - testSmallLag(-80) - testSmallLag(120) - testSmallLag(-120) - } - - { - 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) - - euser, _, found, _ := v.Get(userHash) - if found || euser != nil { - t.Error("unexpected user") - } - } - - testBigLag(121) - testBigLag(-121) - testBigLag(310) - testBigLag(-310) - testBigLag(500) - testBigLag(-500) - } - - if v := v.Remove(user.Email); !v { - t.Error("unable to remove user") - } - if v := v.Remove(user.Email); v { - t.Error("remove user twice") - } -} - func BenchmarkUserValidator(b *testing.B) { for i := 0; i < b.N; i++ { - hasher := protocol.DefaultIDHash - v := NewTimedUserValidator(hasher) + v := NewTimedUserValidator() for j := 0; j < 1500; j++ { id := uuid.New() diff --git a/proxy/vmess/vmessCtxInterface.go b/proxy/vmess/vmessCtxInterface.go deleted file mode 100644 index 5d26f9e5..00000000 --- a/proxy/vmess/vmessCtxInterface.go +++ /dev/null @@ -1,4 +0,0 @@ -package vmess - -// example -const AlterID = "VMessCtxInterface_AlterID" From 8852d0209936f577daf209de9754625cea818db1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Jun 2023 00:59:09 +0000 Subject: [PATCH 066/867] Bump golang.org/x/sys from 0.8.0 to 0.9.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.8.0 to 0.9.0. - [Commits](https://github.com/golang/sys/compare/v0.8.0...v0.9.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 629c89e5..6ca4745d 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( golang.org/x/crypto v0.9.0 golang.org/x/net v0.10.0 golang.org/x/sync v0.2.0 - golang.org/x/sys v0.8.0 + golang.org/x/sys v0.9.0 google.golang.org/grpc v1.55.0 google.golang.org/protobuf v1.30.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c diff --git a/go.sum b/go.sum index 6b73d1d3..741608d4 100644 --- a/go.sum +++ b/go.sum @@ -225,8 +225,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= +golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From ca6af4c19ddcef09821e2c33e91e075bf661d44a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 00:59:41 +0000 Subject: [PATCH 067/867] Bump golang.org/x/crypto from 0.9.0 to 0.10.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.9.0 to 0.10.0. - [Commits](https://github.com/golang/crypto/compare/v0.9.0...v0.10.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 6ca4745d..6d2c6762 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230331223127-176a94313eda - golang.org/x/crypto v0.9.0 + golang.org/x/crypto v0.10.0 golang.org/x/net v0.10.0 golang.org/x/sync v0.2.0 golang.org/x/sys v0.9.0 @@ -50,7 +50,7 @@ require ( go.uber.org/atomic v1.10.0 // indirect golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect golang.org/x/mod v0.10.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/text v0.10.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.8.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect diff --git a/go.sum b/go.sum index 741608d4..4e5bf3de 100644 --- a/go.sum +++ b/go.sum @@ -178,8 +178,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= +golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= @@ -231,8 +231,8 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= +golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= From e8616c60871187b95fde09bf1c0cccf0ee8b88e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 02:27:06 +0000 Subject: [PATCH 068/867] Bump golang.org/x/net from 0.10.0 to 0.11.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/net/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6d2c6762..583eac3e 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230331223127-176a94313eda golang.org/x/crypto v0.10.0 - golang.org/x/net v0.10.0 + golang.org/x/net v0.11.0 golang.org/x/sync v0.2.0 golang.org/x/sys v0.9.0 google.golang.org/grpc v1.55.0 diff --git a/go.sum b/go.sum index 4e5bf3de..e8214a5c 100644 --- a/go.sum +++ b/go.sum @@ -200,8 +200,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= +golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From 37e1e401a87e5083586b08ade6963adce332f038 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:22:36 +0000 Subject: [PATCH 069/867] Bump golang.org/x/sync from 0.2.0 to 0.3.0 (#2210) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 583eac3e..c15f8890 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/xtls/reality v0.0.0-20230331223127-176a94313eda golang.org/x/crypto v0.10.0 golang.org/x/net v0.11.0 - golang.org/x/sync v0.2.0 + golang.org/x/sync v0.3.0 golang.org/x/sys v0.9.0 google.golang.org/grpc v1.55.0 google.golang.org/protobuf v1.30.0 diff --git a/go.sum b/go.sum index e8214a5c..de4084a7 100644 --- a/go.sum +++ b/go.sum @@ -213,8 +213,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= -golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= From 65b467e448d7450f832dbf7dbf2eac610d0c3a2e Mon Sep 17 00:00:00 2001 From: Hellojack <106379370+H1JK@users.noreply.github.com> Date: Fri, 16 Jun 2023 00:22:53 +0800 Subject: [PATCH 070/867] REALITY protocol: Add ChaCha20-Poly1305 auth mode (#2212) https://github.com/XTLS/REALITY/pull/4 --- go.mod | 2 +- go.sum | 4 ++-- transport/internet/reality/reality.go | 17 +++++++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index c15f8890..8fd18217 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e - github.com/xtls/reality v0.0.0-20230331223127-176a94313eda + github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983 golang.org/x/crypto v0.10.0 golang.org/x/net v0.11.0 golang.org/x/sync v0.3.0 diff --git a/go.sum b/go.sum index de4084a7..1f53d6d2 100644 --- a/go.sum +++ b/go.sum @@ -166,8 +166,8 @@ github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/xtls/reality v0.0.0-20230331223127-176a94313eda h1:psRJD2RrZbnI0OWyHvXfgYCPqlRM5q5SPDcjDoDBWhE= -github.com/xtls/reality v0.0.0-20230331223127-176a94313eda/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= +github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983 h1:AMyzgjkh54WocjQSlCnT1LhDc/BKiUqtNOv40AkpURs= +github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 6355687b..ff2d3f38 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -30,12 +30,16 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/transport/internet/tls" + "golang.org/x/crypto/chacha20poly1305" "golang.org/x/crypto/hkdf" "golang.org/x/net/http2" ) //go:generate go run github.com/xtls/xray-core/common/errors/errorgen +//go:linkname aesgcmPreferred github.com/refraction-networking/utls.aesgcmPreferred +func aesgcmPreferred(ciphers []uint16) bool + type Conn struct { *reality.Conn } @@ -136,11 +140,16 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati if _, err := hkdf.New(sha256.New, uConn.AuthKey, hello.Random[:20], []byte("REALITY")).Read(uConn.AuthKey); err != nil { return nil, err } - if config.Show { - fmt.Printf("REALITY localAddr: %v\tuConn.AuthKey[:16]: %v\n", localAddr, uConn.AuthKey[:16]) + var aead cipher.AEAD + if aesgcmPreferred(hello.CipherSuites) { + block, _ := aes.NewCipher(uConn.AuthKey) + aead, _ = cipher.NewGCM(block) + } else { + aead, _ = chacha20poly1305.New(uConn.AuthKey) + } + if config.Show { + fmt.Printf("REALITY localAddr: %v\tuConn.AuthKey[:16]: %v\tAEAD: %T\n", localAddr, uConn.AuthKey[:16], aead) } - block, _ := aes.NewCipher(uConn.AuthKey) - aead, _ := cipher.NewGCM(block) aead.Seal(hello.SessionId[:0], hello.Random[20:], hello.SessionId[:16], hello.Raw) copy(hello.Raw[39:], hello.SessionId) } From 084f4f2e4c5d0a058b885341ee27dc450b0ceaf3 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 15 Jun 2023 16:37:46 +0000 Subject: [PATCH 071/867] Update comments in reality.go --- transport/internet/reality/reality.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index ff2d3f38..e55f9417 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -124,10 +124,11 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati uConn.BuildHandshakeState() hello := uConn.HandshakeState.Hello hello.SessionId = make([]byte, 32) - copy(hello.Raw[39:], hello.SessionId) // the location of session ID + copy(hello.Raw[39:], hello.SessionId) // the fixed location of `Session ID` hello.SessionId[0] = core.Version_x hello.SessionId[1] = core.Version_y hello.SessionId[2] = core.Version_z + hello.SessionId[3] = 0 // reserved binary.BigEndian.PutUint32(hello.SessionId[4:], uint32(time.Now().Unix())) copy(hello.SessionId[8:], config.ShortId) if config.Show { From def5807c647e10a660ca1f4ac870c040d276a15f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 18 Jun 2023 10:06:33 +0000 Subject: [PATCH 072/867] Bump google.golang.org/grpc from 1.55.0 to 1.56.0 (#2216) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8fd18217..0ad66d30 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( golang.org/x/net v0.11.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.9.0 - google.golang.org/grpc v1.55.0 + google.golang.org/grpc v1.56.0 google.golang.org/protobuf v1.30.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 1f53d6d2..0fa9578a 100644 --- a/go.sum +++ b/go.sum @@ -268,8 +268,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.55.0 h1:3Oj82/tFSCeUrRTg/5E/7d/W5A1tj6Ky1ABAuZuv5ag= -google.golang.org/grpc v1.55.0/go.mod h1:iYEXKGkEBhg1PjZQvoYEVPTDkHo1/bjTnfwTeGONTY8= +google.golang.org/grpc v1.56.0 h1:+y7Bs8rtMd07LeXmL3NxcTLn7mUkbKZqEpPhMNkwJEE= +google.golang.org/grpc v1.56.0/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= From 9122d0f056ed5b0e6fc9b290fdc7b39f47b49a39 Mon Sep 17 00:00:00 2001 From: rrouzbeh Date: Sun, 18 Jun 2023 07:12:42 -0700 Subject: [PATCH 073/867] Add TLS Hello Fragmentation for freedom outbound (#2131) * Replace TCP Segmentation with TLS Hello Fragmentation * Update infra/conf/freedom.go * Refine proxy/freedom/freedom.go --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- infra/conf/freedom.go | 15 ++++-- proxy/freedom/freedom.go | 98 +++++++++++++++++++++++++++++++++++----- 2 files changed, 98 insertions(+), 15 deletions(-) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index b3790278..c3510477 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -90,7 +90,17 @@ func (c *FreedomConfig) Build() (proto.Message, error) { MaxLength: int32(maxLength), } - if len(c.Fragment.Packets) > 0 { + switch strings.ToLower(c.Fragment.Packets) { + case "tlshello": + // TLS Hello Fragmentation (into multiple handshake messages) + config.Fragment.StartPacket = 0 + config.Fragment.EndPacket = 1 + case "": + // TCP Segmentation (all packets) + config.Fragment.StartPacket = 0 + config.Fragment.EndPacket = 0 + default: + // TCP Segmentation (range) packetRange := strings.Split(c.Fragment.Packets, "-") var startPacket, endPacket int64 if len(packetRange) == 2 { @@ -114,9 +124,6 @@ func (c *FreedomConfig) Build() (proto.Message, error) { } config.Fragment.StartPacket = int32(startPacket) config.Fragment.EndPacket = int32(endPacket) - } else { - config.Fragment.StartPacket = 0 - config.Fragment.EndPacket = 0 } } diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index d5d147bd..b881ffde 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -5,6 +5,7 @@ package freedom import ( "context" "crypto/rand" + "encoding/binary" "io" "math/big" "time" @@ -12,6 +13,7 @@ import ( "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/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/retry" "github.com/xtls/xray-core/common/session" @@ -173,17 +175,28 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte var writer buf.Writer if destination.Network == net.Network_TCP { if h.config.Fragment != nil { - writer = buf.NewWriter( - &FragmentWriter{ - Writer: conn, - minLength: int(h.config.Fragment.MinLength), - maxLength: int(h.config.Fragment.MaxLength), - minInterval: time.Duration(h.config.Fragment.MinInterval) * time.Millisecond, - maxInterval: time.Duration(h.config.Fragment.MaxInterval) * time.Millisecond, - startPacket: int(h.config.Fragment.StartPacket), - endPacket: int(h.config.Fragment.EndPacket), - PacketCount: 0, - }) + if h.config.Fragment.StartPacket == 0 && h.config.Fragment.EndPacket == 1 { + newError("FRAGMENT", int(h.config.Fragment.MaxLength)).WriteToLog(session.ExportIDToError(ctx)) + writer = buf.NewWriter( + &FragmentedClientHelloConn{ + Conn: conn, + maxLength: int(h.config.Fragment.MaxLength), + minInterval: time.Duration(h.config.Fragment.MinInterval) * time.Millisecond, + maxInterval: time.Duration(h.config.Fragment.MaxInterval) * time.Millisecond, + }) + } else { + writer = buf.NewWriter( + &FragmentWriter{ + Writer: conn, + minLength: int(h.config.Fragment.MinLength), + maxLength: int(h.config.Fragment.MaxLength), + minInterval: time.Duration(h.config.Fragment.MinInterval) * time.Millisecond, + maxInterval: time.Duration(h.config.Fragment.MaxInterval) * time.Millisecond, + startPacket: int(h.config.Fragment.StartPacket), + endPacket: int(h.config.Fragment.EndPacket), + PacketCount: 0, + }) + } } else { writer = buf.NewWriter(conn) } @@ -388,3 +401,66 @@ func randBetween(left int64, right int64) int64 { bigInt, _ := rand.Int(rand.Reader, big.NewInt(right-left)) return left + bigInt.Int64() } + +type FragmentedClientHelloConn struct { + net.Conn + PacketCount int + minLength int + maxLength int + minInterval time.Duration + maxInterval time.Duration +} + +func (c *FragmentedClientHelloConn) Write(b []byte) (n int, err error) { + if len(b) >= 5 && b[0] == 22 && c.PacketCount == 0 { + n, err = sendFragmentedClientHello(c, b, c.minLength, c.maxLength) + + if err == nil { + c.PacketCount++ + return n, err + } + } + + return c.Conn.Write(b) +} + +func sendFragmentedClientHello(conn *FragmentedClientHelloConn, clientHello []byte, minFragmentSize, maxFragmentSize int) (n int, err error) { + if len(clientHello) < 5 || clientHello[0] != 22 { + return 0, errors.New("not a valid TLS ClientHello message") + } + + clientHelloLen := (int(clientHello[3]) << 8) | int(clientHello[4]) + + clientHelloData := clientHello[5:] + for i := 0; i < clientHelloLen; { + fragmentEnd := i + int(randBetween(int64(minFragmentSize), int64(maxFragmentSize))) + if fragmentEnd > clientHelloLen { + fragmentEnd = clientHelloLen + } + + fragment := clientHelloData[i:fragmentEnd] + i = fragmentEnd + + err = writeFragmentedRecord(conn, 22, fragment, clientHello) + if err != nil { + return 0, err + } + } + + return len(clientHello), nil +} + +func writeFragmentedRecord(c *FragmentedClientHelloConn, contentType uint8, data []byte, clientHello []byte) error { + header := make([]byte, 5) + header[0] = byte(clientHello[0]) + + tlsVersion := (int(clientHello[1]) << 8) | int(clientHello[2]) + binary.BigEndian.PutUint16(header[1:], uint16(tlsVersion)) + + binary.BigEndian.PutUint16(header[3:], uint16(len(data))) + _, err := c.Conn.Write(append(header, data...)) + randomInterval := randBetween(int64(c.minInterval), int64(c.maxInterval)) + time.Sleep(time.Duration(randomInterval)) + + return err +} From 62e881b01a9a752c7ceb39c085d38b2afad33c79 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 18 Jun 2023 15:33:30 +0000 Subject: [PATCH 074/867] 5*60 -> 2*60 --- app/proxyman/inbound/worker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 5b227c06..8ed4090a 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -362,7 +362,7 @@ func (w *udpWorker) clean() error { } for addr, conn := range w.activeConn { - if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 5*60 { // TODO Timeout too small + if nowSec-atomic.LoadInt64(&conn.lastActivityTime) > 2*60 { if !conn.inactive { conn.setInactive() delete(w.activeConn, addr) From 667279af57e8aca8e1da588a740e4e2d8da53bd1 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 18 Jun 2023 17:20:16 +0000 Subject: [PATCH 075/867] Add "nonIPQuery" to DNS outbound ("drop" by default) And fixed a memory leak And regenerated *.pb.go --- common/protocol/headers.pb.go | 2 +- infra/conf/dns_proxy.go | 16 ++++++++++++---- proxy/dns/config.pb.go | 28 +++++++++++++++++++--------- proxy/dns/config.proto | 1 + proxy/dns/dns.go | 5 +++++ 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/common/protocol/headers.pb.go b/common/protocol/headers.pb.go index b90db8c7..96c427d4 100644 --- a/common/protocol/headers.pb.go +++ b/common/protocol/headers.pb.go @@ -27,7 +27,7 @@ const ( SecurityType_AUTO SecurityType = 2 SecurityType_AES128_GCM SecurityType = 3 SecurityType_CHACHA20_POLY1305 SecurityType = 4 - SecurityType_NONE SecurityType = 5 + SecurityType_NONE SecurityType = 5 // [DEPRECATED 2023-06] SecurityType_ZERO SecurityType = 6 ) diff --git a/infra/conf/dns_proxy.go b/infra/conf/dns_proxy.go index 90a5d65e..15630cfe 100644 --- a/infra/conf/dns_proxy.go +++ b/infra/conf/dns_proxy.go @@ -7,10 +7,11 @@ import ( ) type DNSOutboundConfig struct { - Network Network `json:"network"` - Address *Address `json:"address"` - Port uint16 `json:"port"` - UserLevel uint32 `json:"userLevel"` + Network Network `json:"network"` + Address *Address `json:"address"` + Port uint16 `json:"port"` + UserLevel uint32 `json:"userLevel"` + NonIPQuery string `json:"nonIPQuery"` } func (c *DNSOutboundConfig) Build() (proto.Message, error) { @@ -24,5 +25,12 @@ func (c *DNSOutboundConfig) Build() (proto.Message, error) { if c.Address != nil { config.Server.Address = c.Address.Build() } + switch c.NonIPQuery { + case "": + c.NonIPQuery = "drop" + case "drop", "skip": + default: + return nil, newError(`unknown "nonIPQuery": `, c.NonIPQuery) + } return config, nil } diff --git a/proxy/dns/config.pb.go b/proxy/dns/config.pb.go index 8da51b44..24016460 100644 --- a/proxy/dns/config.pb.go +++ b/proxy/dns/config.pb.go @@ -28,8 +28,9 @@ type Config struct { // Server is the DNS server address. If specified, this address overrides the // original one. - Server *net.Endpoint `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"` - UserLevel uint32 `protobuf:"varint,2,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` + Server *net.Endpoint `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"` + UserLevel uint32 `protobuf:"varint,2,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` + Non_IPQuery string `protobuf:"bytes,3,opt,name=non_IP_query,json=nonIPQuery,proto3" json:"non_IP_query,omitempty"` } func (x *Config) Reset() { @@ -78,6 +79,13 @@ func (x *Config) GetUserLevel() uint32 { return 0 } +func (x *Config) GetNon_IPQuery() string { + if x != nil { + return x.Non_IPQuery + } + return "" +} + var File_proxy_dns_config_proto protoreflect.FileDescriptor var file_proxy_dns_config_proto_rawDesc = []byte{ @@ -85,18 +93,20 @@ var file_proxy_dns_config_proto_rawDesc = []byte{ 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x1c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5a, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7c, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x31, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, 0x76, - 0x65, 0x6c, 0x42, 0x4c, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x64, 0x6e, 0x73, 0x50, 0x01, 0x5a, 0x23, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, - 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x64, 0x6e, 0x73, 0xaa, - 0x02, 0x0e, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x44, 0x6e, 0x73, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x6c, 0x12, 0x20, 0x0a, 0x0c, 0x6e, 0x6f, 0x6e, 0x5f, 0x49, 0x50, 0x5f, 0x71, 0x75, 0x65, + 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6e, 0x6f, 0x6e, 0x49, 0x50, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x42, 0x4c, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x64, 0x6e, 0x73, 0x50, 0x01, 0x5a, 0x23, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, + 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x64, 0x6e, + 0x73, 0xaa, 0x02, 0x0e, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x44, + 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/dns/config.proto b/proxy/dns/config.proto index 0b324725..e9304a51 100644 --- a/proxy/dns/config.proto +++ b/proxy/dns/config.proto @@ -13,4 +13,5 @@ message Config { // original one. xray.common.net.Endpoint server = 1; uint32 user_level = 2; + string non_IP_query = 3; } diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index 4aa5dac0..d8a3244d 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -44,6 +44,7 @@ type Handler struct { ownLinkVerifier ownLinkVerifier server net.Destination timeout time.Duration + nonIPQuery string } func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager policy.Manager) error { @@ -57,6 +58,7 @@ func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager polic if config.Server != nil { h.server = config.Server.AsDestination() } + h.nonIPQuery = config.Non_IPQuery return nil } @@ -175,6 +177,9 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet. isIPQuery, domain, id, qType := parseIPQuery(b.Bytes()) if isIPQuery { go h.handleIPQuery(id, qType, domain, writer) + } + if isIPQuery || h.nonIPQuery == "drop" { + b.Release() continue } } From ee2176392815cdc98b0a5b29fd9ba565ebf7ebb5 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 18 Jun 2023 17:42:17 +0000 Subject: [PATCH 076/867] Run "go fmt ./..." --- app/router/condition_test.go | 4 ++-- infra/conf/vmess.go | 4 ++-- proxy/vmess/encoding/auth.go | 2 +- proxy/vmess/inbound/inbound.go | 10 +++++----- proxy/vmess/outbound/command.go | 2 +- proxy/vmess/validator.go | 2 +- transport/internet/headers/dns/dns.go | 6 +++--- transport/internet/quic/dialer.go | 2 +- transport/internet/quic/hub.go | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/router/condition_test.go b/app/router/condition_test.go index ca1999ef..395a04c9 100644 --- a/app/router/condition_test.go +++ b/app/router/condition_test.go @@ -307,8 +307,8 @@ func TestRoutingRule(t *testing.T) { }, { rule: &RoutingRule{ - Protocol: []string{"http"}, - Attributes: map[string]string { + Protocol: []string{"http"}, + Attributes: map[string]string{ ":path": "/test", }, }, diff --git a/infra/conf/vmess.go b/infra/conf/vmess.go index e3361646..93d0e75b 100644 --- a/infra/conf/vmess.go +++ b/infra/conf/vmess.go @@ -37,7 +37,7 @@ func (a *VMessAccount) Build() *vmess.Account { st = protocol.SecurityType_AUTO } return &vmess.Account{ - Id: a.ID, + Id: a.ID, SecuritySettings: &protocol.SecurityConfig{ Type: st, }, @@ -61,7 +61,7 @@ type FeaturesConfig struct { } type VMessDefaultConfig struct { - Level byte `json:"level"` + Level byte `json:"level"` } // Build implements Buildable diff --git a/proxy/vmess/encoding/auth.go b/proxy/vmess/encoding/auth.go index 5d9623b1..99bdaa49 100644 --- a/proxy/vmess/encoding/auth.go +++ b/proxy/vmess/encoding/auth.go @@ -17,7 +17,7 @@ func Authenticate(b []byte) uint32 { return fnv1hash.Sum32() } -// [DEPRECATED 2023-06] +// [DEPRECATED 2023-06] type NoOpAuthenticator struct{} func (NoOpAuthenticator) NonceSize() int { diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index f427bc6b..f48a26e1 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -30,14 +30,14 @@ import ( type userByEmail struct { sync.Mutex - cache map[string]*protocol.MemoryUser - defaultLevel uint32 + cache map[string]*protocol.MemoryUser + defaultLevel uint32 } func newUserByEmail(config *DefaultConfig) *userByEmail { return &userByEmail{ - cache: make(map[string]*protocol.MemoryUser), - defaultLevel: config.Level, + cache: make(map[string]*protocol.MemoryUser), + defaultLevel: config.Level, } } @@ -68,7 +68,7 @@ func (v *userByEmail) Get(email string) (*protocol.MemoryUser, bool) { if !found { id := uuid.New() rawAccount := &vmess.Account{ - Id: id.String(), + Id: id.String(), } account, err := rawAccount.AsAccount() common.Must(err) diff --git a/proxy/vmess/outbound/command.go b/proxy/vmess/outbound/command.go index 07df935c..2d4747dc 100644 --- a/proxy/vmess/outbound/command.go +++ b/proxy/vmess/outbound/command.go @@ -11,7 +11,7 @@ import ( func (h *Handler) handleSwitchAccount(cmd *protocol.CommandSwitchAccount) { rawAccount := &vmess.Account{ - Id: cmd.ID.String(), + Id: cmd.ID.String(), SecuritySettings: &protocol.SecurityConfig{ Type: protocol.SecurityType_AUTO, }, diff --git a/proxy/vmess/validator.go b/proxy/vmess/validator.go index 6cc96927..bc844061 100644 --- a/proxy/vmess/validator.go +++ b/proxy/vmess/validator.go @@ -15,7 +15,7 @@ import ( // TimedUserValidator is a user Validator based on time. type TimedUserValidator struct { sync.RWMutex - users []*protocol.MemoryUser + users []*protocol.MemoryUser behaviorSeed uint64 behaviorFused bool diff --git a/transport/internet/headers/dns/dns.go b/transport/internet/headers/dns/dns.go index df209ff6..b6345213 100644 --- a/transport/internet/headers/dns/dns.go +++ b/transport/internet/headers/dns/dns.go @@ -36,7 +36,7 @@ func NewDNS(ctx context.Context, config interface{}) (interface{}, error) { buf := make([]byte, 0x100) - off1, err := packDomainName(config.(*Config).Domain + ".", buf) + off1, err := packDomainName(config.(*Config).Domain+".", buf) if err != nil { return nil, err } @@ -62,8 +62,8 @@ func packDomainName(s string, msg []byte) (off1 int, err error) { // Emit sequence of counted strings, chopping at dots. var ( - begin int - bs []byte + begin int + bs []byte ) for i := 0; i < ls; i++ { var c byte diff --git a/transport/internet/quic/dialer.go b/transport/internet/quic/dialer.go index f0d8e4e1..f6083561 100644 --- a/transport/internet/quic/dialer.go +++ b/transport/internet/quic/dialer.go @@ -143,7 +143,7 @@ func (s *clientConnections) openConnection(ctx context.Context, destAddr net.Add HandshakeIdleTimeout: time.Second * 8, MaxIdleTimeout: time.Second * 300, Tracer: func(ctx context.Context, p logging.Perspective, ci quic.ConnectionID) logging.ConnectionTracer { - return qlog.NewConnectionTracer( &QlogWriter{connID: ci}, p, ci); + return qlog.NewConnectionTracer(&QlogWriter{connID: ci}, p, ci) }, } udpConn, _ := rawConn.(*net.UDPConn) diff --git a/transport/internet/quic/hub.go b/transport/internet/quic/hub.go index 15f072ec..8bab5bf3 100644 --- a/transport/internet/quic/hub.go +++ b/transport/internet/quic/hub.go @@ -109,7 +109,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti MaxIncomingStreams: 32, MaxIncomingUniStreams: -1, Tracer: func(ctx context.Context, p logging.Perspective, ci quic.ConnectionID) logging.ConnectionTracer { - return qlog.NewConnectionTracer( &QlogWriter{connID: ci}, p, ci); + return qlog.NewConnectionTracer(&QlogWriter{connID: ci}, p, ci) }, } From 72bbc5ae0e8173b550847eebb8df5102f5893eae Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 18 Jun 2023 20:43:20 +0000 Subject: [PATCH 077/867] v1.8.2 --- core/core.go | 2 +- go.mod | 22 +++++++++++----------- go.sum | 50 +++++++++++++++++++++++++------------------------- 3 files changed, 37 insertions(+), 37 deletions(-) diff --git a/core/core.go b/core/core.go index 07ec158d..23bd11e8 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 1 + Version_z byte = 2 ) var ( diff --git a/go.mod b/go.mod index 0ad66d30..d8f3566c 100644 --- a/go.mod +++ b/go.mod @@ -13,8 +13,8 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.35.1 github.com/refraction-networking/utls v1.3.2 - github.com/sagernet/sing v0.2.4 - github.com/sagernet/sing-shadowsocks v0.2.1 + github.com/sagernet/sing v0.2.5 + github.com/sagernet/sing-shadowsocks v0.2.2 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 @@ -39,21 +39,21 @@ require ( github.com/gaukas/godicttls v0.0.3 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect - github.com/klauspost/compress v1.16.5 // indirect - github.com/klauspost/cpuid/v2 v2.2.4 // indirect - github.com/onsi/ginkgo/v2 v2.9.2 // indirect + github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect + github.com/klauspost/compress v1.16.6 // indirect + github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/onsi/ginkgo/v2 v2.11.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/quic-go/qtls-go1-19 v0.3.2 // indirect github.com/quic-go/qtls-go1-20 v0.2.2 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect - go.uber.org/atomic v1.10.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect - golang.org/x/mod v0.10.0 // indirect + go.uber.org/atomic v1.11.0 // indirect + golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect + golang.org/x/mod v0.11.0 // indirect golang.org/x/text v0.10.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.8.0 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + golang.org/x/tools v0.10.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 0fa9578a..4d21ae0a 100644 --- a/go.sum +++ b/go.sum @@ -34,7 +34,7 @@ github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3 github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -60,8 +60,8 @@ github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+u github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20230406165453-00490a63f317 h1:hFhpt7CTmR3DX+b4R19ydQFtofxT0Sv3QsKNMVQYTMQ= -github.com/google/pprof v0.0.0-20230406165453-00490a63f317/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk= +github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 h1:hR7/MlvK23p6+lIw9SN1TigNLn9ZnF3W4SYRKq2gAHs= +github.com/google/pprof v0.0.0-20230602150820-91b7bce49751/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -75,10 +75,10 @@ github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.16.5 h1:IFV2oUNUzZaz+XyusxpLzpzS8Pt5rh0Z16For/djlyI= -github.com/klauspost/compress v1.16.5/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/klauspost/compress v1.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk= +github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= +github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -95,9 +95,9 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= -github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= -github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= +github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= +github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= +github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= @@ -123,10 +123,10 @@ github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvj github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.4 h1:gC8BR5sglbJZX23RtMyFa8EETP9YEUADhfbEzU1yVbo= -github.com/sagernet/sing v0.2.4/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= -github.com/sagernet/sing-shadowsocks v0.2.1 h1:FvdLQOqpvxHBJUcUe4fvgiYP2XLLwH5i1DtXQviVEPw= -github.com/sagernet/sing-shadowsocks v0.2.1/go.mod h1:T/OgurSjsAe+Ug3+6PprXjmgHFmJidjOvQcjXGTKb3I= +github.com/sagernet/sing v0.2.5 h1:N8sUluR8GZvR9DqUiH3FA3vBb4m/EDdOVTYUrDzJvmY= +github.com/sagernet/sing v0.2.5/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= +github.com/sagernet/sing-shadowsocks v0.2.2 h1:ezSdVhrmIcwDXmCZF3bOJVMuVtTQWpda+1Op+Ie2TA4= +github.com/sagernet/sing-shadowsocks v0.2.2/go.mod h1:JIBWG6a7orB2HxBxYElViQFLUQxFVG7DuqIj8gD7uCQ= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c/go.mod h1:euOmN6O5kk9dQmgSS8Df4psAl3TCjxOz0NW60EWkSaI= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= @@ -170,8 +170,8 @@ github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983 h1:AMyzgjkh54WocjQSlC github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -181,14 +181,14 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= +golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= +golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -224,7 +224,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -244,8 +244,8 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= -golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= +golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -262,8 +262,8 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= From 253a4224672a00496f92cd96840c1e5aefa83940 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 19 Jun 2023 00:33:59 +0000 Subject: [PATCH 078/867] Fix "nonIPQuery" --- infra/conf/dns_proxy.go | 1 + 1 file changed, 1 insertion(+) diff --git a/infra/conf/dns_proxy.go b/infra/conf/dns_proxy.go index 15630cfe..564084e0 100644 --- a/infra/conf/dns_proxy.go +++ b/infra/conf/dns_proxy.go @@ -32,5 +32,6 @@ func (c *DNSOutboundConfig) Build() (proto.Message, error) { default: return nil, newError(`unknown "nonIPQuery": `, c.NonIPQuery) } + config.Non_IPQuery = c.NonIPQuery return config, nil } From 6f9df63c701bb7f71abe335112b6b3819481feaa Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 19 Jun 2023 00:35:46 +0000 Subject: [PATCH 079/867] v1.8.3 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 23bd11e8..4d704306 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 2 + Version_z byte = 3 ) var ( From a9ed1a03aa39f24a663f1f64d37bc3998df96315 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 19 Jun 2023 00:51:03 +0000 Subject: [PATCH 080/867] Fix dns_proxy_test.go --- infra/conf/dns_proxy_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/infra/conf/dns_proxy_test.go b/infra/conf/dns_proxy_test.go index 805ac323..5c5dfecd 100644 --- a/infra/conf/dns_proxy_test.go +++ b/infra/conf/dns_proxy_test.go @@ -27,6 +27,7 @@ func TestDnsProxyConfig(t *testing.T) { Address: net.NewIPOrDomain(net.IPAddress([]byte{8, 8, 8, 8})), Port: 53, }, + Non_IPQuery: "drop", }, }, }) From 4f8f49024b024d450f2bc7b3e23422bf983e5a7f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 19 Jun 2023 01:07:19 +0000 Subject: [PATCH 081/867] Fix xray_test.go --- infra/conf/xray_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index b39da7c9..a4898457 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -221,7 +221,8 @@ func TestXrayConfig(t *testing.T) { }, }), ProxySettings: serial.ToTypedMessage(&dns_proxy.Config{ - Server: &net.Endpoint{}, + Server: &net.Endpoint{}, + Non_IPQuery: "drop", }), }, }, From 449affc7311a352a3895dbc2a47e7391f99dc994 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Jun 2023 00:58:34 +0000 Subject: [PATCH 082/867] Bump github.com/miekg/dns from 1.1.54 to 1.1.55 Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.54 to 1.1.55. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.54...v1.1.55) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d8f3566c..3932ac27 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/golang/protobuf v1.5.3 github.com/google/go-cmp v0.5.9 github.com/gorilla/websocket v1.5.0 - github.com/miekg/dns v1.1.54 + github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.35.1 diff --git a/go.sum b/go.sum index 4d21ae0a..fa995566 100644 --- a/go.sum +++ b/go.sum @@ -89,8 +89,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= -github.com/miekg/dns v1.1.54 h1:5jon9mWcb0sFJGpnI99tOMhCPyJ+RPVz5b63MQG0VWI= -github.com/miekg/dns v1.1.54/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= +github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= +github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= From 828a6320768d0ab41b89e4119287ce18d3e8de1f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Jun 2023 00:58:38 +0000 Subject: [PATCH 083/867] Bump github.com/sagernet/sing from 0.2.5 to 0.2.6 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.2.5 to 0.2.6. - [Commits](https://github.com/sagernet/sing/compare/v0.2.5...v0.2.6) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3932ac27..1be0b808 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.35.1 github.com/refraction-networking/utls v1.3.2 - github.com/sagernet/sing v0.2.5 + github.com/sagernet/sing v0.2.6 github.com/sagernet/sing-shadowsocks v0.2.2 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index fa995566..6a9f0b8f 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,8 @@ github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvj github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.5 h1:N8sUluR8GZvR9DqUiH3FA3vBb4m/EDdOVTYUrDzJvmY= -github.com/sagernet/sing v0.2.5/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= +github.com/sagernet/sing v0.2.6 h1:Fvqv7/Bwc72ERT6dE8yQLLY6SMc/syO3VMCtxVO4DNw= +github.com/sagernet/sing v0.2.6/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= github.com/sagernet/sing-shadowsocks v0.2.2 h1:ezSdVhrmIcwDXmCZF3bOJVMuVtTQWpda+1Op+Ie2TA4= github.com/sagernet/sing-shadowsocks v0.2.2/go.mod h1:JIBWG6a7orB2HxBxYElViQFLUQxFVG7DuqIj8gD7uCQ= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= From 6d8fe7315f3f1ead41da329e967d665d4f3e51c4 Mon Sep 17 00:00:00 2001 From: Eken Chan Date: Thu, 22 Jun 2023 14:43:22 +0800 Subject: [PATCH 084/867] XRV should work without rawConn --- proxy/vless/encoding/encoding.go | 6 +++++- proxy/vless/inbound/inbound.go | 4 ++-- proxy/vless/outbound/outbound.go | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index f668c402..cf962492 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -247,7 +247,11 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater } } } - reader = buf.NewReadVReader(conn, rawConn, nil) + if rawConn != nil { + reader = buf.NewReadVReader(conn, rawConn, nil) + } else { + reader = buf.NewReader(conn) + } ct = counter newError("XtlsRead readV").WriteToLog(session.ExportIDToError(ctx)) } diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index 688c98a3..8653e1e3 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -539,7 +539,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s var err error - if rawConn != nil { + if requestAddons.Flow == vless.XRV { var counter stats.Counter if statConn != nil { counter = statConn.ReadCounter @@ -591,7 +591,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s } var err error - if rawConn != nil && requestAddons.Flow == vless.XRV { + if requestAddons.Flow == vless.XRV { var counter stats.Counter if statConn != nil { counter = statConn.WriteCounter diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index 4f42ea9f..12962a47 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -247,7 +247,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } var err error - if rawConn != nil && requestAddons.Flow == vless.XRV { + if requestAddons.Flow == vless.XRV { if tlsConn, ok := iConn.(*tls.Conn); ok { if tlsConn.ConnectionState().Version != gotls.VersionTLS13 { return newError(`failed to use `+requestAddons.Flow+`, found outer tls version `, tlsConn.ConnectionState().Version).AtWarning() @@ -292,7 +292,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte serverReader = xudp.NewPacketReader(conn) } - if rawConn != nil { + if requestAddons.Flow == vless.XRV { var counter stats.Counter if statConn != nil { counter = statConn.ReadCounter From 6152868dfe2c5c08b731665b00f5c9352a35f0c1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Jun 2023 00:59:02 +0000 Subject: [PATCH 085/867] Bump google.golang.org/grpc from 1.56.0 to 1.56.1 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.56.0 to 1.56.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.56.0...v1.56.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1be0b808..332f282f 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( golang.org/x/net v0.11.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.9.0 - google.golang.org/grpc v1.56.0 + google.golang.org/grpc v1.56.1 google.golang.org/protobuf v1.30.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 6a9f0b8f..0e210d65 100644 --- a/go.sum +++ b/go.sum @@ -268,8 +268,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.56.0 h1:+y7Bs8rtMd07LeXmL3NxcTLn7mUkbKZqEpPhMNkwJEE= -google.golang.org/grpc v1.56.0/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.56.1 h1:z0dNfjIl0VpaZ9iSVjA6daGatAYwPGstTjt5vkRMFkQ= +google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= From 07389eca9618ad50ecb9cf524857ceef16ac392a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Jun 2023 00:59:14 +0000 Subject: [PATCH 086/867] Bump github.com/quic-go/quic-go from 0.35.1 to 0.36.0 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.35.1 to 0.36.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.35.1...v0.36.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 332f282f..495b1618 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.35.1 + github.com/quic-go/quic-go v0.36.0 github.com/refraction-networking/utls v1.3.2 github.com/sagernet/sing v0.2.6 github.com/sagernet/sing-shadowsocks v0.2.2 diff --git a/go.sum b/go.sum index 0e210d65..304ef222 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,8 @@ github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc8 github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= -github.com/quic-go/quic-go v0.35.1 h1:b0kzj6b/cQAf05cT0CkQubHM31wiA+xH3IBkxP62poo= -github.com/quic-go/quic-go v0.35.1/go.mod h1:+4CVgVppm0FNjpG3UcX8Joi/frKOH7/ciD5yGcwOO1g= +github.com/quic-go/quic-go v0.36.0 h1:JIrO7p7Ug6hssFcARjWDiqS2RAKJHCiwPxBAA989rbI= +github.com/quic-go/quic-go v0.36.0/go.mod h1:zPetvwDlILVxt15n3hr3Gf/I3mDf7LpLKPhR4Ez0AZQ= github.com/refraction-networking/utls v1.3.2 h1:o+AkWB57mkcoW36ET7uJ002CpBWHu0KPxi6vzxvPnv8= github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvjQpqP7L2vcm/9KUfm/E= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From a6c5c579307a8b38b2121eab578547627a0206b3 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Tue, 27 Jun 2023 04:04:09 -0400 Subject: [PATCH 087/867] Support regex matching with attr (#2258) * Support regex matching with attr * Add test case * Optimizing regex parsing at core start * simpliy --- app/router/condition.go | 11 ++++++----- app/router/condition_test.go | 13 +++++++++++++ app/router/config.go | 5 +++-- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/app/router/condition.go b/app/router/condition.go index 326c13ff..29056555 100644 --- a/app/router/condition.go +++ b/app/router/condition.go @@ -1,6 +1,7 @@ package router import ( + "regexp" "strings" "github.com/xtls/xray-core/common/net" @@ -282,18 +283,18 @@ func (m *ProtocolMatcher) Apply(ctx routing.Context) bool { } type AttributeMatcher struct { - configuredKeys map[string]string + configuredKeys map[string]*regexp.Regexp } // Match implements attributes matching. func (m *AttributeMatcher) Match(attrs map[string]string) bool { - // headers are insensitive most likely. So we do a convert + // header keys are case insensitive most likely. So we do a convert httpHeaders := make(map[string]string) for key, value := range attrs { - httpHeaders[strings.ToLower(key)] = strings.ToLower(value) + httpHeaders[strings.ToLower(key)] = value } - for key, value := range m.configuredKeys { - if a, ok := httpHeaders[key]; !ok || !strings.Contains(a, value) { + for key, regex := range m.configuredKeys { + if a, ok := httpHeaders[key]; !ok || !regex.MatchString(a) { return false } } diff --git a/app/router/condition_test.go b/app/router/condition_test.go index 395a04c9..fd898417 100644 --- a/app/router/condition_test.go +++ b/app/router/condition_test.go @@ -319,6 +319,19 @@ func TestRoutingRule(t *testing.T) { }, }, }, + { + rule: &RoutingRule{ + Attributes: map[string]string{ + "Custom": "p([a-z]+)ch", + }, + }, + test: []ruleTest{ + { + input: withContent(&session.Content{Attributes: map[string]string{"custom": "peach"}}), + output: true, + }, + }, + }, } for _, test := range cases { diff --git a/app/router/config.go b/app/router/config.go index 3f4fd7c5..80b88781 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -1,6 +1,7 @@ package router import ( + "regexp" "strings" "github.com/xtls/xray-core/common/net" @@ -145,9 +146,9 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) { } if len(rr.Attributes) > 0 { - configuredKeys := make(map[string]string) + configuredKeys := make(map[string]*regexp.Regexp) for key, value := range rr.Attributes { - configuredKeys[strings.ToLower(key)] = strings.ToLower(value) + configuredKeys[strings.ToLower(key)] = regexp.MustCompile(value) } conds.Add(&AttributeMatcher{configuredKeys}) } From fb0cd0db4d881330797af97a5b3b0258765edc78 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Jun 2023 08:04:26 +0000 Subject: [PATCH 088/867] Bump google.golang.org/protobuf from 1.30.0 to 1.31.0 (#2264) Bumps google.golang.org/protobuf from 1.30.0 to 1.31.0. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 495b1618..57d2446e 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/sync v0.3.0 golang.org/x/sys v0.9.0 google.golang.org/grpc v1.56.1 - google.golang.org/protobuf v1.30.0 + google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h12.io/socks v1.0.3 lukechampine.com/blake3 v1.2.1 diff --git a/go.sum b/go.sum index 304ef222..25331267 100644 --- a/go.sum +++ b/go.sum @@ -272,8 +272,8 @@ google.golang.org/grpc v1.56.1 h1:z0dNfjIl0VpaZ9iSVjA6daGatAYwPGstTjt5vkRMFkQ= google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= From 34b68518fd649e2502e12c4676ee47633617d560 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Jun 2023 08:04:42 +0000 Subject: [PATCH 089/867] Bump github.com/sagernet/sing from 0.2.6 to 0.2.7 (#2265) Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.2.6 to 0.2.7. - [Commits](https://github.com/sagernet/sing/compare/v0.2.6...v0.2.7) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 57d2446e..0249c0ea 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.36.0 github.com/refraction-networking/utls v1.3.2 - github.com/sagernet/sing v0.2.6 + github.com/sagernet/sing v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.2 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index 25331267..833a9e37 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,8 @@ github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvj github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.6 h1:Fvqv7/Bwc72ERT6dE8yQLLY6SMc/syO3VMCtxVO4DNw= -github.com/sagernet/sing v0.2.6/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= +github.com/sagernet/sing v0.2.7 h1:cOy0FfPS8q7m0aJ51wS7LRQAGc9wF+fWhHtBDj99wy8= +github.com/sagernet/sing v0.2.7/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= github.com/sagernet/sing-shadowsocks v0.2.2 h1:ezSdVhrmIcwDXmCZF3bOJVMuVtTQWpda+1Op+Ie2TA4= github.com/sagernet/sing-shadowsocks v0.2.2/go.mod h1:JIBWG6a7orB2HxBxYElViQFLUQxFVG7DuqIj8gD7uCQ= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= From 46d8bb58fc193edf3d72e5d51395ea1a336605a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Jul 2023 01:21:02 +0000 Subject: [PATCH 090/867] Bump github.com/quic-go/quic-go from 0.36.0 to 0.36.1 (#2286) Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.36.0 to 0.36.1. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.36.0...v0.36.1) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0249c0ea..a878bb2f 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.36.0 + github.com/quic-go/quic-go v0.36.1 github.com/refraction-networking/utls v1.3.2 github.com/sagernet/sing v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.2 diff --git a/go.sum b/go.sum index 833a9e37..d824c4c9 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,8 @@ github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc8 github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= -github.com/quic-go/quic-go v0.36.0 h1:JIrO7p7Ug6hssFcARjWDiqS2RAKJHCiwPxBAA989rbI= -github.com/quic-go/quic-go v0.36.0/go.mod h1:zPetvwDlILVxt15n3hr3Gf/I3mDf7LpLKPhR4Ez0AZQ= +github.com/quic-go/quic-go v0.36.1 h1:WsG73nVtnDy1TiACxFxhQ3TqaW+DipmqzLEtNlAwZyY= +github.com/quic-go/quic-go v0.36.1/go.mod h1:zPetvwDlILVxt15n3hr3Gf/I3mDf7LpLKPhR4Ez0AZQ= github.com/refraction-networking/utls v1.3.2 h1:o+AkWB57mkcoW36ET7uJ002CpBWHu0KPxi6vzxvPnv8= github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvjQpqP7L2vcm/9KUfm/E= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From b870cc097b7d0aee11c90f218105d870f2215365 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Jul 2023 00:56:44 +0000 Subject: [PATCH 091/867] Bump golang.org/x/sys from 0.9.0 to 0.10.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.9.0 to 0.10.0. - [Commits](https://github.com/golang/sys/compare/v0.9.0...v0.10.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a878bb2f..154c6ee5 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( golang.org/x/crypto v0.10.0 golang.org/x/net v0.11.0 golang.org/x/sync v0.3.0 - golang.org/x/sys v0.9.0 + golang.org/x/sys v0.10.0 google.golang.org/grpc v1.56.1 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c diff --git a/go.sum b/go.sum index d824c4c9..3ffe2061 100644 --- a/go.sum +++ b/go.sum @@ -225,8 +225,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From a1ff507ef2de79082a593b2d2642b8f872863354 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Jul 2023 00:20:57 +0000 Subject: [PATCH 092/867] Bump golang.org/x/crypto from 0.10.0 to 0.11.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/crypto/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 154c6ee5..e96b651d 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983 - golang.org/x/crypto v0.10.0 + golang.org/x/crypto v0.11.0 golang.org/x/net v0.11.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.10.0 @@ -50,7 +50,7 @@ require ( go.uber.org/atomic v1.11.0 // indirect golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect golang.org/x/mod v0.11.0 // indirect - golang.org/x/text v0.10.0 // indirect + golang.org/x/text v0.11.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.10.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect diff --git a/go.sum b/go.sum index 3ffe2061..e4c28878 100644 --- a/go.sum +++ b/go.sum @@ -178,8 +178,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM= -golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= @@ -231,8 +231,8 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= -golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= From 846d3ebd6c2d63a3bad23bc50141d9cb7c87d142 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Jul 2023 06:34:06 +0000 Subject: [PATCH 093/867] Bump golang.org/x/net from 0.11.0 to 0.12.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.11.0 to 0.12.0. - [Commits](https://github.com/golang/net/compare/v0.11.0...v0.12.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e96b651d..162037c7 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983 golang.org/x/crypto v0.11.0 - golang.org/x/net v0.11.0 + golang.org/x/net v0.12.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.10.0 google.golang.org/grpc v1.56.1 diff --git a/go.sum b/go.sum index e4c28878..8a2c5db1 100644 --- a/go.sum +++ b/go.sum @@ -200,8 +200,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU= -golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From 6d4194415d903523eb243a172f0beb1621c9267a Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 6 Jul 2023 15:18:05 +0000 Subject: [PATCH 094/867] Clean unnecessary code in Trojan --- infra/conf/trojan.go | 59 ++++++++++++++------------------- proxy/trojan/client.go | 18 +++------- proxy/trojan/config.go | 2 -- proxy/trojan/config.pb.go | 69 +++++++++++++++++---------------------- proxy/trojan/config.proto | 3 +- proxy/trojan/protocol.go | 1 - proxy/trojan/server.go | 4 +-- proxy/trojan/trojan.go | 4 +-- 8 files changed, 63 insertions(+), 97 deletions(-) diff --git a/infra/conf/trojan.go b/infra/conf/trojan.go index e7d8738b..e9d78f8a 100644 --- a/infra/conf/trojan.go +++ b/infra/conf/trojan.go @@ -30,13 +30,14 @@ type TrojanClientConfig struct { // Build implements Buildable func (c *TrojanClientConfig) Build() (proto.Message, error) { - config := new(trojan.ClientConfig) - if len(c.Servers) == 0 { return nil, newError("0 Trojan server configured.") } - serverSpecs := make([]*protocol.ServerEndpoint, len(c.Servers)) + config := &trojan.ClientConfig{ + Server: make([]*protocol.ServerEndpoint, len(c.Servers)), + } + for idx, rec := range c.Servers { if rec.Address == nil { return nil, newError("Trojan server address is not set.") @@ -47,34 +48,25 @@ func (c *TrojanClientConfig) Build() (proto.Message, error) { if rec.Password == "" { return nil, newError("Trojan password is not specified.") } - account := &trojan.Account{ - Password: rec.Password, - Flow: rec.Flow, + if rec.Flow != "" { + return nil, newError(`Trojan doesn't support "flow" anymore.`) } - switch account.Flow { - case "": - default: - return nil, newError(`Trojan servers: "flow" doesn't support "` + account.Flow + `" in this version`) - } - - trojan := &protocol.ServerEndpoint{ + config.Server[idx] = &protocol.ServerEndpoint{ Address: rec.Address.Build(), Port: uint32(rec.Port), User: []*protocol.User{ { - Level: uint32(rec.Level), - Email: rec.Email, - Account: serial.ToTypedMessage(account), + Level: uint32(rec.Level), + Email: rec.Email, + Account: serial.ToTypedMessage(&trojan.Account{ + Password: rec.Password, + }), }, }, } - - serverSpecs[idx] = trojan } - config.Server = serverSpecs - return config, nil } @@ -105,25 +97,22 @@ type TrojanServerConfig struct { // Build implements Buildable func (c *TrojanServerConfig) Build() (proto.Message, error) { - config := new(trojan.ServerConfig) - config.Users = make([]*protocol.User, len(c.Clients)) + config := &trojan.ServerConfig{ + Users: make([]*protocol.User, len(c.Clients)), + } + for idx, rawUser := range c.Clients { - user := new(protocol.User) - account := &trojan.Account{ - Password: rawUser.Password, - Flow: rawUser.Flow, + if rawUser.Flow != "" { + return nil, newError(`Trojan doesn't support "flow" anymore.`) } - switch account.Flow { - case "": - default: - return nil, newError(`Trojan clients: "flow" doesn't support "` + account.Flow + `" in this version`) + config.Users[idx] = &protocol.User{ + Level: uint32(rawUser.Level), + Email: rawUser.Email, + Account: serial.ToTypedMessage(&trojan.Account{ + Password: rawUser.Password, + }), } - - user.Email = rawUser.Email - user.Level = uint32(rawUser.Level) - user.Account = serial.ToTypedMessage(account) - config.Users[idx] = user } if c.Fallback != nil { diff --git a/proxy/trojan/client.go b/proxy/trojan/client.go index 2605239d..0c6f16d3 100644 --- a/proxy/trojan/client.go +++ b/proxy/trojan/client.go @@ -77,22 +77,12 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter defer conn.Close() - iConn := conn - statConn, ok := iConn.(*stat.CounterConnection) - if ok { - iConn = statConn.Connection - } - user := server.PickUser() account, ok := user.Account.(*MemoryAccount) if !ok { return newError("user account is not valid") } - connWriter := &ConnWriter{ - Flow: account.Flow, - } - var newCtx context.Context var newCancel context.CancelFunc if session.TimeoutOnlyFromContext(ctx) { @@ -113,9 +103,11 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter bufferWriter := buf.NewBufferedWriter(buf.NewWriter(conn)) - connWriter.Writer = bufferWriter - connWriter.Target = destination - connWriter.Account = account + connWriter := &ConnWriter{ + Writer: bufferWriter, + Target: destination, + Account: account, + } var bodyWriter buf.Writer if destination.Network == net.Network_UDP { diff --git a/proxy/trojan/config.go b/proxy/trojan/config.go index ffac7854..a02dfe98 100644 --- a/proxy/trojan/config.go +++ b/proxy/trojan/config.go @@ -13,7 +13,6 @@ import ( type MemoryAccount struct { Password string Key []byte - Flow string } // AsAccount implements protocol.AsAccount. @@ -23,7 +22,6 @@ func (a *Account) AsAccount() (protocol.Account, error) { return &MemoryAccount{ Password: password, Key: key, - Flow: a.Flow, }, nil } diff --git a/proxy/trojan/config.pb.go b/proxy/trojan/config.pb.go index 6d81350f..49374001 100644 --- a/proxy/trojan/config.pb.go +++ b/proxy/trojan/config.pb.go @@ -27,7 +27,6 @@ type Account struct { unknownFields protoimpl.UnknownFields Password string `protobuf:"bytes,1,opt,name=password,proto3" json:"password,omitempty"` - Flow string `protobuf:"bytes,2,opt,name=flow,proto3" json:"flow,omitempty"` } func (x *Account) Reset() { @@ -69,13 +68,6 @@ func (x *Account) GetPassword() string { return "" } -func (x *Account) GetFlow() string { - if x != nil { - return x.Flow - } - return "" -} - type Fallback struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -216,7 +208,7 @@ type ServerConfig struct { unknownFields protoimpl.UnknownFields Users []*protocol.User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` - Fallbacks []*Fallback `protobuf:"bytes,3,rep,name=fallbacks,proto3" json:"fallbacks,omitempty"` + Fallbacks []*Fallback `protobuf:"bytes,2,rep,name=fallbacks,proto3" json:"fallbacks,omitempty"` } func (x *ServerConfig) Reset() { @@ -274,38 +266,37 @@ var file_proxy_trojan_config_proto_rawDesc = []byte{ 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x21, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x73, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x39, 0x0a, + 0x65, 0x72, 0x5f, 0x73, 0x70, 0x65, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x25, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, - 0x77, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x6c, 0x6f, 0x77, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x66, 0x6c, 0x6f, 0x77, 0x22, 0x82, 0x01, 0x0a, 0x08, 0x46, 0x61, 0x6c, - 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x6c, 0x70, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x6c, 0x70, 0x6e, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x78, 0x76, 0x65, - 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, 0x78, 0x76, 0x65, 0x72, 0x22, 0x4c, 0x0a, - 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3c, 0x0a, - 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x45, 0x6e, 0x64, 0x70, 0x6f, - 0x69, 0x6e, 0x74, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0x7b, 0x0a, 0x0c, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x30, 0x0a, 0x05, 0x75, - 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, - 0x6c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x39, 0x0a, - 0x09, 0x66, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x74, 0x72, - 0x6f, 0x6a, 0x61, 0x6e, 0x2e, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x09, 0x66, - 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x73, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x74, 0x72, 0x6f, 0x6a, 0x61, - 0x6e, 0x50, 0x01, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, - 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x74, 0x72, 0x6f, 0x6a, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, - 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x54, 0x72, 0x6f, 0x6a, 0x61, 0x6e, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x77, 0x6f, 0x72, 0x64, 0x22, 0x82, 0x01, 0x0a, 0x08, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x61, 0x6c, 0x70, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x61, 0x6c, 0x70, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x64, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x78, 0x76, 0x65, 0x72, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x04, 0x78, 0x76, 0x65, 0x72, 0x22, 0x4c, 0x0a, 0x0c, 0x43, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3c, 0x0a, 0x06, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, + 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0x7b, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x30, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x39, 0x0a, 0x09, 0x66, 0x61, 0x6c, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x74, 0x72, 0x6f, 0x6a, 0x61, 0x6e, + 0x2e, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x09, 0x66, 0x61, 0x6c, 0x6c, 0x62, + 0x61, 0x63, 0x6b, 0x73, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x74, 0x72, 0x6f, 0x6a, 0x61, 0x6e, 0x50, 0x01, 0x5a, + 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, + 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2f, 0x74, 0x72, 0x6f, 0x6a, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, + 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x54, 0x72, 0x6f, 0x6a, 0x61, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/trojan/config.proto b/proxy/trojan/config.proto index 6ebed36b..4229e2ed 100644 --- a/proxy/trojan/config.proto +++ b/proxy/trojan/config.proto @@ -11,7 +11,6 @@ import "common/protocol/server_spec.proto"; message Account { string password = 1; - string flow = 2; } message Fallback { @@ -29,5 +28,5 @@ message ClientConfig { message ServerConfig { repeated xray.common.protocol.User users = 1; - repeated Fallback fallbacks = 3; + repeated Fallback fallbacks = 2; } diff --git a/proxy/trojan/protocol.go b/proxy/trojan/protocol.go index 363cf9e0..6fcfb4d4 100644 --- a/proxy/trojan/protocol.go +++ b/proxy/trojan/protocol.go @@ -31,7 +31,6 @@ type ConnWriter struct { io.Writer Target net.Destination Account *MemoryAccount - Flow string headerSent bool } diff --git a/proxy/trojan/server.go b/proxy/trojan/server.go index 368374ff..41245ba4 100644 --- a/proxy/trojan/server.go +++ b/proxy/trojan/server.go @@ -234,7 +234,7 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con }) newError("received request for ", destination).WriteToLog(sid) - return s.handleConnection(ctx, sessionPolicy, destination, clientReader, buf.NewWriter(conn), dispatcher, iConn, statConn) + return s.handleConnection(ctx, sessionPolicy, destination, clientReader, buf.NewWriter(conn), dispatcher) } func (s *Server) handleUDPPayload(ctx context.Context, clientReader *PacketReader, clientWriter *PacketWriter, dispatcher routing.Dispatcher) error { @@ -300,7 +300,7 @@ 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, statConn *stat.CounterConnection, + clientWriter buf.Writer, dispatcher routing.Dispatcher, ) error { ctx, cancel := context.WithCancel(ctx) timer := signal.CancelAfterInactivity(ctx, cancel, sessionPolicy.Timeouts.ConnectionIdle) diff --git a/proxy/trojan/trojan.go b/proxy/trojan/trojan.go index 4639b7d9..d0cf5de4 100644 --- a/proxy/trojan/trojan.go +++ b/proxy/trojan/trojan.go @@ -1,5 +1,3 @@ package trojan -const ( - muxCoolAddress = "v1.mux.cool" -) +//go:generate go run github.com/xtls/xray-core/common/errors/errorgen From f0f3b417f779d1d76d9d515bd0070877d9975019 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 6 Jul 2023 16:30:39 +0000 Subject: [PATCH 095/867] Refactor: Fragmentation https://github.com/XTLS/Xray-core/commit/5f5ae375714abd67eb2f0a0f2e86410b6f29f7c2 https://github.com/XTLS/Xray-core/commit/9122d0f056ed5b0e6fc9b290fdc7b39f47b49a39 --- infra/conf/freedom.go | 134 ++++++++++++++--------------- proxy/freedom/config.pb.go | 62 +++++++------- proxy/freedom/config.proto | 12 +-- proxy/freedom/freedom.go | 171 +++++++++++++------------------------ 4 files changed, 161 insertions(+), 218 deletions(-) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index c3510477..60c5b7f1 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -39,91 +39,89 @@ func (c *FreedomConfig) Build() (proto.Message, error) { } if c.Fragment != nil { - if len(c.Fragment.Interval) == 0 || len(c.Fragment.Length) == 0 { - return nil, newError("Invalid interval or length") - } - intervalMinMax := strings.Split(c.Fragment.Interval, "-") - var minInterval, maxInterval int64 + config.Fragment = new(freedom.Fragment) var err, err2 error - if len(intervalMinMax) == 2 { - minInterval, err = strconv.ParseInt(intervalMinMax[0], 10, 64) - maxInterval, err2 = strconv.ParseInt(intervalMinMax[1], 10, 64) - } else { - minInterval, err = strconv.ParseInt(intervalMinMax[0], 10, 64) - maxInterval = minInterval - } - if err != nil { - return nil, newError("Invalid minimum interval: ", err).Base(err) - } - if err2 != nil { - return nil, newError("Invalid maximum interval: ", err2).Base(err2) - } - - lengthMinMax := strings.Split(c.Fragment.Length, "-") - var minLength, maxLength int64 - if len(lengthMinMax) == 2 { - minLength, err = strconv.ParseInt(lengthMinMax[0], 10, 64) - maxLength, err2 = strconv.ParseInt(lengthMinMax[1], 10, 64) - - } else { - minLength, err = strconv.ParseInt(lengthMinMax[0], 10, 64) - maxLength = minLength - } - if err != nil { - return nil, newError("Invalid minimum length: ", err).Base(err) - } - if err2 != nil { - return nil, newError("Invalid maximum length: ", err2).Base(err2) - } - - if minInterval > maxInterval { - minInterval, maxInterval = maxInterval, minInterval - } - if minLength > maxLength { - minLength, maxLength = maxLength, minLength - } - - config.Fragment = &freedom.Fragment{ - MinInterval: int32(minInterval), - MaxInterval: int32(maxInterval), - MinLength: int32(minLength), - MaxLength: int32(maxLength), - } switch strings.ToLower(c.Fragment.Packets) { case "tlshello": // TLS Hello Fragmentation (into multiple handshake messages) - config.Fragment.StartPacket = 0 - config.Fragment.EndPacket = 1 + config.Fragment.PacketsFrom = 0 + config.Fragment.PacketsTo = 1 case "": // TCP Segmentation (all packets) - config.Fragment.StartPacket = 0 - config.Fragment.EndPacket = 0 + config.Fragment.PacketsFrom = 0 + config.Fragment.PacketsTo = 0 default: // TCP Segmentation (range) - packetRange := strings.Split(c.Fragment.Packets, "-") - var startPacket, endPacket int64 - if len(packetRange) == 2 { - startPacket, err = strconv.ParseInt(packetRange[0], 10, 64) - endPacket, err2 = strconv.ParseInt(packetRange[1], 10, 64) + packetsFromTo := strings.Split(c.Fragment.Packets, "-") + if len(packetsFromTo) == 2 { + config.Fragment.PacketsFrom, err = strconv.ParseUint(packetsFromTo[0], 10, 64) + config.Fragment.PacketsTo, err2 = strconv.ParseUint(packetsFromTo[1], 10, 64) } else { - startPacket, err = strconv.ParseInt(packetRange[0], 10, 64) - endPacket = startPacket + config.Fragment.PacketsFrom, err = strconv.ParseUint(packetsFromTo[0], 10, 64) + config.Fragment.PacketsTo = config.Fragment.PacketsFrom } if err != nil { - return nil, newError("Invalid start packet: ", err).Base(err) + return nil, newError("Invalid PacketsFrom").Base(err) } if err2 != nil { - return nil, newError("Invalid end packet: ", err2).Base(err2) + return nil, newError("Invalid PacketsTo").Base(err2) } - if startPacket > endPacket { - return nil, newError("Invalid packet range: ", c.Fragment.Packets) + if config.Fragment.PacketsFrom > config.Fragment.PacketsTo { + config.Fragment.PacketsFrom, config.Fragment.PacketsTo = config.Fragment.PacketsTo, config.Fragment.PacketsFrom } - if startPacket < 1 { - return nil, newError("Cannot start from packet 0") + if config.Fragment.PacketsFrom == 0 { + return nil, newError("PacketsFrom can't be 0") + } + } + + { + if c.Fragment.Length == "" { + return nil, newError("Length can't be empty") + } + lengthMinMax := strings.Split(c.Fragment.Length, "-") + if len(lengthMinMax) == 2 { + config.Fragment.LengthMin, err = strconv.ParseUint(lengthMinMax[0], 10, 64) + config.Fragment.LengthMax, err2 = strconv.ParseUint(lengthMinMax[1], 10, 64) + } else { + config.Fragment.LengthMin, err = strconv.ParseUint(lengthMinMax[0], 10, 64) + config.Fragment.LengthMax = config.Fragment.LengthMin + } + if err != nil { + return nil, newError("Invalid LengthMin").Base(err) + } + if err2 != nil { + return nil, newError("Invalid LengthMax").Base(err2) + } + if config.Fragment.LengthMin > config.Fragment.LengthMax { + config.Fragment.LengthMin, config.Fragment.LengthMax = config.Fragment.LengthMax, config.Fragment.LengthMin + } + if config.Fragment.LengthMin == 0 { + return nil, newError("LengthMin can't be 0") + } + } + + { + if c.Fragment.Interval == "" { + return nil, newError("Interval can't be empty") + } + intervalMinMax := strings.Split(c.Fragment.Interval, "-") + if len(intervalMinMax) == 2 { + config.Fragment.IntervalMin, err = strconv.ParseUint(intervalMinMax[0], 10, 64) + config.Fragment.IntervalMax, err2 = strconv.ParseUint(intervalMinMax[1], 10, 64) + } else { + config.Fragment.IntervalMin, err = strconv.ParseUint(intervalMinMax[0], 10, 64) + config.Fragment.IntervalMax = config.Fragment.IntervalMin + } + if err != nil { + return nil, newError("Invalid IntervalMin").Base(err) + } + if err2 != nil { + return nil, newError("Invalid IntervalMax").Base(err2) + } + if config.Fragment.IntervalMin > config.Fragment.IntervalMax { + config.Fragment.IntervalMin, config.Fragment.IntervalMax = config.Fragment.IntervalMax, config.Fragment.IntervalMin } - config.Fragment.StartPacket = int32(startPacket) - config.Fragment.EndPacket = int32(endPacket) } } diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 2e2fb403..7561f7fd 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -125,12 +125,12 @@ type Fragment struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - MinInterval int32 `protobuf:"varint,1,opt,name=min_interval,json=minInterval,proto3" json:"min_interval,omitempty"` - MaxInterval int32 `protobuf:"varint,2,opt,name=max_interval,json=maxInterval,proto3" json:"max_interval,omitempty"` - MinLength int32 `protobuf:"varint,3,opt,name=min_length,json=minLength,proto3" json:"min_length,omitempty"` - MaxLength int32 `protobuf:"varint,4,opt,name=max_length,json=maxLength,proto3" json:"max_length,omitempty"` - StartPacket int32 `protobuf:"varint,5,opt,name=start_packet,json=startPacket,proto3" json:"start_packet,omitempty"` - EndPacket int32 `protobuf:"varint,6,opt,name=end_packet,json=endPacket,proto3" json:"end_packet,omitempty"` + PacketsFrom uint64 `protobuf:"varint,1,opt,name=packets_from,json=packetsFrom,proto3" json:"packets_from,omitempty"` + PacketsTo uint64 `protobuf:"varint,2,opt,name=packets_to,json=packetsTo,proto3" json:"packets_to,omitempty"` + LengthMin uint64 `protobuf:"varint,3,opt,name=length_min,json=lengthMin,proto3" json:"length_min,omitempty"` + LengthMax uint64 `protobuf:"varint,4,opt,name=length_max,json=lengthMax,proto3" json:"length_max,omitempty"` + IntervalMin uint64 `protobuf:"varint,5,opt,name=interval_min,json=intervalMin,proto3" json:"interval_min,omitempty"` + IntervalMax uint64 `protobuf:"varint,6,opt,name=interval_max,json=intervalMax,proto3" json:"interval_max,omitempty"` } func (x *Fragment) Reset() { @@ -165,44 +165,44 @@ func (*Fragment) Descriptor() ([]byte, []int) { return file_proxy_freedom_config_proto_rawDescGZIP(), []int{1} } -func (x *Fragment) GetMinInterval() int32 { +func (x *Fragment) GetPacketsFrom() uint64 { if x != nil { - return x.MinInterval + return x.PacketsFrom } return 0 } -func (x *Fragment) GetMaxInterval() int32 { +func (x *Fragment) GetPacketsTo() uint64 { if x != nil { - return x.MaxInterval + return x.PacketsTo } return 0 } -func (x *Fragment) GetMinLength() int32 { +func (x *Fragment) GetLengthMin() uint64 { if x != nil { - return x.MinLength + return x.LengthMin } return 0 } -func (x *Fragment) GetMaxLength() int32 { +func (x *Fragment) GetLengthMax() uint64 { if x != nil { - return x.MaxLength + return x.LengthMax } return 0 } -func (x *Fragment) GetStartPacket() int32 { +func (x *Fragment) GetIntervalMin() uint64 { if x != nil { - return x.StartPacket + return x.IntervalMin } return 0 } -func (x *Fragment) GetEndPacket() int32 { +func (x *Fragment) GetIntervalMax() uint64 { if x != nil { - return x.EndPacket + return x.IntervalMax } return 0 } @@ -302,19 +302,19 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x22, 0xd0, 0x01, 0x0a, 0x08, 0x46, 0x72, 0x61, - 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x69, 0x6e, 0x5f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x6d, 0x69, 0x6e, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x61, 0x78, 0x5f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, - 0x6d, 0x61, 0x78, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, - 0x69, 0x6e, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x09, 0x6d, 0x69, 0x6e, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x61, - 0x78, 0x5f, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, - 0x6d, 0x61, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x61, - 0x72, 0x74, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x1d, 0x0a, 0x0a, - 0x65, 0x6e, 0x64, 0x5f, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x09, 0x65, 0x6e, 0x64, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x22, 0xf2, 0x02, 0x0a, 0x06, + 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x73, + 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x70, 0x61, 0x63, + 0x6b, 0x65, 0x74, 0x73, 0x46, 0x72, 0x6f, 0x6d, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x63, 0x6b, + 0x65, 0x74, 0x73, 0x5f, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x70, 0x61, + 0x63, 0x6b, 0x65, 0x74, 0x73, 0x54, 0x6f, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x65, 0x6e, 0x67, 0x74, + 0x68, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6c, 0x65, 0x6e, + 0x67, 0x74, 0x68, 0x4d, 0x69, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6c, 0x65, 0x6e, 0x67, + 0x74, 0x68, 0x4d, 0x61, 0x78, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, + 0x6c, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x76, 0x61, 0x6c, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0xf2, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, diff --git a/proxy/freedom/config.proto b/proxy/freedom/config.proto index 4422edd3..53524e19 100644 --- a/proxy/freedom/config.proto +++ b/proxy/freedom/config.proto @@ -13,12 +13,12 @@ message DestinationOverride { } message Fragment { - int32 min_interval = 1; - int32 max_interval = 2; - int32 min_length = 3; - int32 max_length = 4; - int32 start_packet = 5; - int32 end_packet = 6; + uint64 packets_from = 1; + uint64 packets_to = 2; + uint64 length_min = 3; + uint64 length_max = 4; + uint64 interval_min = 5; + uint64 interval_max = 6; } message Config { diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index b881ffde..c6907b4c 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -5,7 +5,6 @@ package freedom import ( "context" "crypto/rand" - "encoding/binary" "io" "math/big" "time" @@ -13,7 +12,6 @@ import ( "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/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/retry" "github.com/xtls/xray-core/common/session" @@ -175,28 +173,12 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte var writer buf.Writer if destination.Network == net.Network_TCP { if h.config.Fragment != nil { - if h.config.Fragment.StartPacket == 0 && h.config.Fragment.EndPacket == 1 { - newError("FRAGMENT", int(h.config.Fragment.MaxLength)).WriteToLog(session.ExportIDToError(ctx)) - writer = buf.NewWriter( - &FragmentedClientHelloConn{ - Conn: conn, - maxLength: int(h.config.Fragment.MaxLength), - minInterval: time.Duration(h.config.Fragment.MinInterval) * time.Millisecond, - maxInterval: time.Duration(h.config.Fragment.MaxInterval) * time.Millisecond, - }) - } else { - writer = buf.NewWriter( - &FragmentWriter{ - Writer: conn, - minLength: int(h.config.Fragment.MinLength), - maxLength: int(h.config.Fragment.MaxLength), - minInterval: time.Duration(h.config.Fragment.MinInterval) * time.Millisecond, - maxInterval: time.Duration(h.config.Fragment.MaxInterval) * time.Millisecond, - startPacket: int(h.config.Fragment.StartPacket), - endPacket: int(h.config.Fragment.EndPacket), - PacketCount: 0, - }) - } + newError("FRAGMENT", h.config.Fragment.PacketsFrom, h.config.Fragment.PacketsTo, h.config.Fragment.LengthMin, h.config.Fragment.LengthMax, + h.config.Fragment.IntervalMin, h.config.Fragment.IntervalMax).AtDebug().WriteToLog(session.ExportIDToError(ctx)) + writer = buf.NewWriter(&FragmentWriter{ + fragment: h.config.Fragment, + writer: conn, + }) } else { writer = buf.NewWriter(conn) } @@ -356,40 +338,66 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { } type FragmentWriter struct { - io.Writer - minLength int - maxLength int - minInterval time.Duration - maxInterval time.Duration - startPacket int - endPacket int - PacketCount int + fragment *Fragment + writer io.Writer + count uint64 } -func (w *FragmentWriter) Write(buf []byte) (int, error) { - w.PacketCount += 1 - if (w.startPacket != 0 && (w.PacketCount < w.startPacket || w.PacketCount > w.endPacket)) || len(buf) <= w.minLength { - return w.Writer.Write(buf) +func (f *FragmentWriter) Write(b []byte) (int, error) { + f.count++ + + if f.fragment.PacketsFrom == 0 && f.fragment.PacketsTo == 1 { + if f.count != 1 || len(b) <= 5 || b[0] != 22 { + return f.writer.Write(b) + } + recordLen := 5 + ((int(b[3]) << 8) | int(b[4])) + data := b[5:recordLen] + buf := make([]byte, 1024) + for from := 0; ; { + to := from + int(randBetween(int64(f.fragment.LengthMin), int64(f.fragment.LengthMax))) + if to > len(data) { + to = len(data) + } + copy(buf[:3], b) + copy(buf[5:], data[from:to]) + l := to - from + from = to + buf[3] = byte(l >> 8) + buf[4] = byte(l) + _, err := f.writer.Write(buf[:5+l]) + time.Sleep(time.Duration(randBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond) + if err != nil { + return 0, err + } + if from == len(data) { + if len(b) > recordLen { + n, err := f.writer.Write(b[recordLen:]) + if err != nil { + return recordLen + n, err + } + } + return len(b), nil + } + } } - nTotal := 0 - for { - randomBytesTo := int(randBetween(int64(w.minLength), int64(w.maxLength))) + nTotal - if randomBytesTo > len(buf) { - randomBytesTo = len(buf) + if f.fragment.PacketsFrom != 0 && (f.count < f.fragment.PacketsFrom || f.count > f.fragment.PacketsTo) { + return f.writer.Write(b) + } + for from := 0; ; { + to := from + int(randBetween(int64(f.fragment.LengthMin), int64(f.fragment.LengthMax))) + if to > len(b) { + to = len(b) } - n, err := w.Writer.Write(buf[nTotal:randomBytesTo]) + n, err := f.writer.Write(b[from:to]) + from += n + time.Sleep(time.Duration(randBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond) if err != nil { - return nTotal + n, err + return from, err } - nTotal += n - - if nTotal >= len(buf) { - return nTotal, nil + if from >= len(b) { + return from, nil } - - randomInterval := randBetween(int64(w.minInterval), int64(w.maxInterval)) - time.Sleep(time.Duration(randomInterval)) } } @@ -401,66 +409,3 @@ func randBetween(left int64, right int64) int64 { bigInt, _ := rand.Int(rand.Reader, big.NewInt(right-left)) return left + bigInt.Int64() } - -type FragmentedClientHelloConn struct { - net.Conn - PacketCount int - minLength int - maxLength int - minInterval time.Duration - maxInterval time.Duration -} - -func (c *FragmentedClientHelloConn) Write(b []byte) (n int, err error) { - if len(b) >= 5 && b[0] == 22 && c.PacketCount == 0 { - n, err = sendFragmentedClientHello(c, b, c.minLength, c.maxLength) - - if err == nil { - c.PacketCount++ - return n, err - } - } - - return c.Conn.Write(b) -} - -func sendFragmentedClientHello(conn *FragmentedClientHelloConn, clientHello []byte, minFragmentSize, maxFragmentSize int) (n int, err error) { - if len(clientHello) < 5 || clientHello[0] != 22 { - return 0, errors.New("not a valid TLS ClientHello message") - } - - clientHelloLen := (int(clientHello[3]) << 8) | int(clientHello[4]) - - clientHelloData := clientHello[5:] - for i := 0; i < clientHelloLen; { - fragmentEnd := i + int(randBetween(int64(minFragmentSize), int64(maxFragmentSize))) - if fragmentEnd > clientHelloLen { - fragmentEnd = clientHelloLen - } - - fragment := clientHelloData[i:fragmentEnd] - i = fragmentEnd - - err = writeFragmentedRecord(conn, 22, fragment, clientHello) - if err != nil { - return 0, err - } - } - - return len(clientHello), nil -} - -func writeFragmentedRecord(c *FragmentedClientHelloConn, contentType uint8, data []byte, clientHello []byte) error { - header := make([]byte, 5) - header[0] = byte(clientHello[0]) - - tlsVersion := (int(clientHello[1]) << 8) | int(clientHello[2]) - binary.BigEndian.PutUint16(header[1:], uint16(tlsVersion)) - - binary.BigEndian.PutUint16(header[3:], uint16(len(data))) - _, err := c.Conn.Write(append(header, data...)) - randomInterval := randBetween(int64(c.minInterval), int64(c.maxInterval)) - time.Sleep(time.Duration(randomInterval)) - - return err -} From dca57aab2669ffdff5fc87020e41899f548d8308 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Jul 2023 00:27:17 +0000 Subject: [PATCH 096/867] Bump google.golang.org/grpc from 1.56.1 to 1.56.2 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.56.1 to 1.56.2. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.56.1...v1.56.2) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 162037c7..6c47723d 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( golang.org/x/net v0.12.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.10.0 - google.golang.org/grpc v1.56.1 + google.golang.org/grpc v1.56.2 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 8a2c5db1..9e00d906 100644 --- a/go.sum +++ b/go.sum @@ -268,8 +268,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.56.1 h1:z0dNfjIl0VpaZ9iSVjA6daGatAYwPGstTjt5vkRMFkQ= -google.golang.org/grpc v1.56.1/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= +google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From 929f286c2cbeb76913e9679205d68017402d71fc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 13 Jul 2023 00:31:59 +0000 Subject: [PATCH 097/867] Bump github.com/quic-go/quic-go from 0.36.1 to 0.36.2 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.36.1 to 0.36.2. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.36.1...v0.36.2) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6c47723d..8fc28fd2 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.36.1 + github.com/quic-go/quic-go v0.36.2 github.com/refraction-networking/utls v1.3.2 github.com/sagernet/sing v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.2 diff --git a/go.sum b/go.sum index 9e00d906..284fb64b 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,8 @@ github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc8 github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= -github.com/quic-go/quic-go v0.36.1 h1:WsG73nVtnDy1TiACxFxhQ3TqaW+DipmqzLEtNlAwZyY= -github.com/quic-go/quic-go v0.36.1/go.mod h1:zPetvwDlILVxt15n3hr3Gf/I3mDf7LpLKPhR4Ez0AZQ= +github.com/quic-go/quic-go v0.36.2 h1:ZX/UNQ4gvpCv2RmwdbA6lrRjF6EBm5yZ7TMoT4NQVrA= +github.com/quic-go/quic-go v0.36.2/go.mod h1:zPetvwDlILVxt15n3hr3Gf/I3mDf7LpLKPhR4Ez0AZQ= github.com/refraction-networking/utls v1.3.2 h1:o+AkWB57mkcoW36ET7uJ002CpBWHu0KPxi6vzxvPnv8= github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvjQpqP7L2vcm/9KUfm/E= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From 8eb3cfe1444afc8217a9e11373957eba828669ea Mon Sep 17 00:00:00 2001 From: cty123 Date: Sat, 15 Jul 2023 23:58:08 +0200 Subject: [PATCH 098/867] fix: Patch potential nil pointer deference in proxy::http::client::fillRequestHeader(). --- proxy/http/client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/proxy/http/client.go b/proxy/http/client.go index b1661011..f597a502 100644 --- a/proxy/http/client.go +++ b/proxy/http/client.go @@ -172,6 +172,10 @@ func fillRequestHeader(ctx context.Context, header []*Header) ([]*Header, error) inbound := session.InboundFromContext(ctx) outbound := session.OutboundFromContext(ctx) + if inbound == nil || outbound == nil { + return nil, newError("missing inbound or outbound metadata from context") + } + data := struct { Source net.Destination Target net.Destination From 2df418abf1df4ad4a2d962bf21d26ed027ebd828 Mon Sep 17 00:00:00 2001 From: cty123 Date: Sun, 16 Jul 2023 23:02:15 +0200 Subject: [PATCH 099/867] fix: Check if address is nil for IsValid() function. --- common/net/destination.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/net/destination.go b/common/net/destination.go index 055395e9..2d0d09ed 100644 --- a/common/net/destination.go +++ b/common/net/destination.go @@ -113,7 +113,7 @@ func (d Destination) String() string { // IsValid returns true if this Destination is valid. func (d Destination) IsValid() bool { - return d.Network != Network_Unknown + return d.Address != nil && d.Network != Network_Unknown } // AsDestination converts current Endpoint into Destination. From 7aeca337298e3344c2ef983d1b6e0f1547ae83eb Mon Sep 17 00:00:00 2001 From: cty123 Date: Tue, 18 Jul 2023 22:11:09 +0200 Subject: [PATCH 100/867] fix: revert previous change on IsValid() function; add validation in getUoTConnection(); --- app/proxyman/outbound/uot.go | 3 +++ common/net/destination.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/proxyman/outbound/uot.go b/app/proxyman/outbound/uot.go index 4610bd79..f3c7426e 100644 --- a/app/proxyman/outbound/uot.go +++ b/app/proxyman/outbound/uot.go @@ -11,6 +11,9 @@ import ( ) func (h *Handler) getUoTConnection(ctx context.Context, dest net.Destination) (stat.Connection, error) { + if dest.Address == nil { + return nil, newError("nil destination address") + } if !dest.Address.Family().IsDomain() { return nil, os.ErrInvalid } diff --git a/common/net/destination.go b/common/net/destination.go index 2d0d09ed..055395e9 100644 --- a/common/net/destination.go +++ b/common/net/destination.go @@ -113,7 +113,7 @@ func (d Destination) String() string { // IsValid returns true if this Destination is valid. func (d Destination) IsValid() bool { - return d.Address != nil && d.Network != Network_Unknown + return d.Network != Network_Unknown } // AsDestination converts current Endpoint into Destination. From b68a43f4fc2ae40aab344b1c720984326904f10f Mon Sep 17 00:00:00 2001 From: cty123 Date: Wed, 19 Jul 2023 00:28:51 +0200 Subject: [PATCH 101/867] fix: correct the logic of converting SocksAddr into net.Destination. --- common/singbridge/destination.go | 8 +++++++- proxy/shadowsocks_2022/inbound_multi.go | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/common/singbridge/destination.go b/common/singbridge/destination.go index 7a89c9ef..98aed258 100644 --- a/common/singbridge/destination.go +++ b/common/singbridge/destination.go @@ -18,19 +18,25 @@ func ToNetwork(network string) net.Network { } func ToDestination(socksaddr M.Socksaddr, network net.Network) net.Destination { + // IsFqdn() implicitly checks if the domain name is valid if socksaddr.IsFqdn() { return net.Destination{ Network: network, Address: net.DomainAddress(socksaddr.Fqdn), Port: net.Port(socksaddr.Port), } - } else { + } + + // IsIP() implicitly checks if the IP address is valid + if socksaddr.IsIP() { return net.Destination{ Network: network, Address: net.IPAddress(socksaddr.Addr.AsSlice()), Port: net.Port(socksaddr.Port), } } + + return net.Destination{} } func ToSocksaddr(destination net.Destination) M.Socksaddr { diff --git a/proxy/shadowsocks_2022/inbound_multi.go b/proxy/shadowsocks_2022/inbound_multi.go index 04cac573..c9927476 100644 --- a/proxy/shadowsocks_2022/inbound_multi.go +++ b/proxy/shadowsocks_2022/inbound_multi.go @@ -204,7 +204,12 @@ func (i *MultiUserInbound) NewConnection(ctx context.Context, conn net.Conn, met }) newError("tunnelling request to tcp:", metadata.Destination).WriteToLog(session.ExportIDToError(ctx)) dispatcher := session.DispatcherFromContext(ctx) - link, err := dispatcher.Dispatch(ctx, singbridge.ToDestination(metadata.Destination, net.Network_TCP)) + destination := singbridge.ToDestination(metadata.Destination, net.Network_TCP) + if !destination.IsValid() { + return newError("invalid destination") + } + + link, err := dispatcher.Dispatch(ctx, destination) if err != nil { return err } From 4a496f94e80b6c9e2c8e687227f4abb48c9ecdd9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jul 2023 00:56:06 +0000 Subject: [PATCH 102/867] Bump github.com/refraction-networking/utls from 1.3.2 to 1.3.3 Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.3.2 to 1.3.3. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.3.2...v1.3.3) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8fc28fd2..aac94b41 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.36.2 - github.com/refraction-networking/utls v1.3.2 + github.com/refraction-networking/utls v1.3.3 github.com/sagernet/sing v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.2 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c diff --git a/go.sum b/go.sum index 284fb64b..4324d979 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8G github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= github.com/quic-go/quic-go v0.36.2 h1:ZX/UNQ4gvpCv2RmwdbA6lrRjF6EBm5yZ7TMoT4NQVrA= github.com/quic-go/quic-go v0.36.2/go.mod h1:zPetvwDlILVxt15n3hr3Gf/I3mDf7LpLKPhR4Ez0AZQ= -github.com/refraction-networking/utls v1.3.2 h1:o+AkWB57mkcoW36ET7uJ002CpBWHu0KPxi6vzxvPnv8= -github.com/refraction-networking/utls v1.3.2/go.mod h1:fmoaOww2bxzzEpIKOebIsnBvjQpqP7L2vcm/9KUfm/E= +github.com/refraction-networking/utls v1.3.3 h1:f/TBLX7KBciRyFH3bwupp+CE4fzoYKCirhdRcC490sw= +github.com/refraction-networking/utls v1.3.3/go.mod h1:DlecWW1LMlMJu+9qpzzQqdHDT/C2LAe03EdpLUz/RL8= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= From 316034226cbe964065c46e1b3cc31dc492778f08 Mon Sep 17 00:00:00 2001 From: KatyushaScarlet Date: Mon, 17 Jul 2023 15:09:02 +0800 Subject: [PATCH 103/867] CI: Add Linux loong64 build task --- .github/build/friendly-filenames.json | 3 ++- .github/workflows/release.yml | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/build/friendly-filenames.json b/.github/build/friendly-filenames.json index 65c20300..f7a3e526 100644 --- a/.github/build/friendly-filenames.json +++ b/.github/build/friendly-filenames.json @@ -22,6 +22,7 @@ "linux-ppc64le": { "friendlyName": "linux-ppc64le" }, "linux-ppc64": { "friendlyName": "linux-ppc64" }, "linux-riscv64": { "friendlyName": "linux-riscv64" }, + "linux-loong64": { "friendlyName": "linux-loong64" }, "linux-s390x": { "friendlyName": "linux-s390x" }, "openbsd-386": { "friendlyName": "openbsd-32" }, "openbsd-amd64": { "friendlyName": "openbsd-64" }, @@ -31,4 +32,4 @@ "windows-amd64": { "friendlyName": "windows-64" }, "windows-arm64": { "friendlyName": "windows-arm64-v8a" }, "windows-arm7": { "friendlyName": "windows-arm32-v7a" } -} \ No newline at end of file +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 98ee485a..03c18811 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -105,12 +105,14 @@ jobs: goarch: arm goarm: 7 # BEGIN Other architectures - # BEGIN riscv64 & ARM64 + # BEGIN riscv64 & ARM64 & LOONG64 - goos: linux goarch: arm64 - goos: linux goarch: riscv64 - # END riscv64 & ARM64 + - goos: linux + goarch: loong64 + # END riscv64 & ARM64 & LOONG64 # BEGIN MIPS - goos: linux goarch: mips64 From e603b97ab4f2faeae723381860e7720569723bc4 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 21 Jul 2023 14:42:09 +0000 Subject: [PATCH 104/867] Add NekoRay and V2rayU to README/GUI Clients Closes https://github.com/XTLS/Xray-core/issues/2354 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 00a2a811..3e67915b 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ - [luci-app-xray](https://github.com/yichya/luci-app-xray) ([openwrt-xray](https://github.com/yichya/openwrt-xray)) - Windows - [v2rayN](https://github.com/2dust/v2rayN) + - [NekoRay](https://github.com/Matsuridayo/nekoray) - [HiddifyN](https://github.com/hiddify/HiddifyN) - [Invisible Man - Xray](https://github.com/InvisibleManVPN/InvisibleMan-XRayClient) - Android @@ -73,10 +74,12 @@ - [Mango](https://github.com/arror/Mango) - [FoXray](https://apps.apple.com/app/foxray/id6448898396) - macOS arm64 & x64 + - [V2rayU](https://github.com/yanue/V2rayU) - [V2RayXS](https://github.com/tzmax/V2RayXS) - [FoXray](https://apps.apple.com/app/foxray/id6448898396) - Linux - [v2rayA](https://github.com/v2rayA/v2rayA) + - [NekoRay](https://github.com/Matsuridayo/nekoray) ## Others that support VLESS, XTLS, REALITY, XUDP, PLUX... From 51769fdde1ca663dcb08d942618e480bee13109f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 22 Jul 2023 06:06:25 +0800 Subject: [PATCH 105/867] H2 transport: Abandon `client` if `client.Do(request)` failed See https://github.com/golang/go/issues/30702 Fixes https://github.com/XTLS/Xray-core/issues/2355 --- transport/internet/http/dialer.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index 010a95a5..f2e55de8 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -173,6 +173,15 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if err != nil { newError("failed to dial to ", dest).Base(err).AtWarning().WriteToLog(session.ExportIDToError(ctx)) wrc.Close() + { + // Abandon `client` if `client.Do(request)` failed + // See https://github.com/golang/go/issues/30702 + globalDialerAccess.Lock() + if globalDialerMap[dialerConf{dest, streamSettings}] == client { + delete(globalDialerMap, dialerConf{dest, streamSettings}) + } + globalDialerAccess.Unlock() + } return } if response.StatusCode != 200 { From 1e9d288b99376799732c0c1842f0b5b659b395f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Jul 2023 00:32:59 +0000 Subject: [PATCH 106/867] Bump google.golang.org/grpc from 1.56.2 to 1.57.0 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.56.2 to 1.57.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.56.2...v1.57.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index aac94b41..ca55dfd7 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( golang.org/x/net v0.12.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.10.0 - google.golang.org/grpc v1.56.2 + google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 4324d979..f4dd0229 100644 --- a/go.sum +++ b/go.sum @@ -268,8 +268,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= -google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= +google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From 81b27aa4cc15f481c11e347ca6e56befbf9514a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 00:27:44 +0000 Subject: [PATCH 107/867] Bump github.com/quic-go/quic-go from 0.36.2 to 0.37.1 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.36.2 to 0.37.1. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.36.2...v0.37.1) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 5 ++--- go.sum | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index ca55dfd7..dd9fde53 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.36.2 + github.com/quic-go/quic-go v0.37.1 github.com/refraction-networking/utls v1.3.3 github.com/sagernet/sing v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.2 @@ -44,8 +44,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/onsi/ginkgo/v2 v2.11.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/quic-go/qtls-go1-19 v0.3.2 // indirect - github.com/quic-go/qtls-go1-20 v0.2.2 // indirect + github.com/quic-go/qtls-go1-20 v0.3.0 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect go.uber.org/atomic v1.11.0 // indirect golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect diff --git a/go.sum b/go.sum index f4dd0229..e88175a6 100644 --- a/go.sum +++ b/go.sum @@ -112,12 +112,10 @@ github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/quic-go/qtls-go1-19 v0.3.2 h1:tFxjCFcTQzK+oMxG6Zcvp4Dq8dx4yD3dDiIiyc86Z5U= -github.com/quic-go/qtls-go1-19 v0.3.2/go.mod h1:ySOI96ew8lnoKPtSqx2BlI5wCpUVPT05RMAlajtnyOI= -github.com/quic-go/qtls-go1-20 v0.2.2 h1:WLOPx6OY/hxtTxKV1Zrq20FtXtDEkeY00CGQm8GEa3E= -github.com/quic-go/qtls-go1-20 v0.2.2/go.mod h1:JKtK6mjbAVcUTN/9jZpvLbGxvdWIKS8uT7EiStoU1SM= -github.com/quic-go/quic-go v0.36.2 h1:ZX/UNQ4gvpCv2RmwdbA6lrRjF6EBm5yZ7TMoT4NQVrA= -github.com/quic-go/quic-go v0.36.2/go.mod h1:zPetvwDlILVxt15n3hr3Gf/I3mDf7LpLKPhR4Ez0AZQ= +github.com/quic-go/qtls-go1-20 v0.3.0 h1:NrCXmDl8BddZwO67vlvEpBTwT89bJfKYygxv4HQvuDk= +github.com/quic-go/qtls-go1-20 v0.3.0/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= +github.com/quic-go/quic-go v0.37.1 h1:M+mcsFq9KoxVjCetIwH65TvusW1UdRBc6zmxI6pkeD0= +github.com/quic-go/quic-go v0.37.1/go.mod h1:XtCUOCALTTWbPyd0IxFfHf6h0sEMubRFvEYHl3QxKw8= github.com/refraction-networking/utls v1.3.3 h1:f/TBLX7KBciRyFH3bwupp+CE4fzoYKCirhdRcC490sw= github.com/refraction-networking/utls v1.3.3/go.mod h1:DlecWW1LMlMJu+9qpzzQqdHDT/C2LAe03EdpLUz/RL8= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From a45c343b89e27cc960ea1f7f011a05df047e15d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Aug 2023 00:19:26 +0000 Subject: [PATCH 108/867] Bump golang.org/x/net from 0.12.0 to 0.13.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.12.0 to 0.13.0. - [Commits](https://github.com/golang/net/compare/v0.12.0...v0.13.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dd9fde53..0595f906 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983 golang.org/x/crypto v0.11.0 - golang.org/x/net v0.12.0 + golang.org/x/net v0.13.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.10.0 google.golang.org/grpc v1.57.0 diff --git a/go.sum b/go.sum index e88175a6..e5b2eea9 100644 --- a/go.sum +++ b/go.sum @@ -198,8 +198,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY= +golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From ce89b5d7de17f228d303c293e0790c8bdf8a3ab6 Mon Sep 17 00:00:00 2001 From: Loren Eteval <139033850+LorenEteval@users.noreply.github.com> Date: Sun, 6 Aug 2023 14:30:37 +0800 Subject: [PATCH 109/867] Add Furious to README/GUI Clients (#2405) --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 3e67915b..761b2ee7 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ - Windows - [v2rayN](https://github.com/2dust/v2rayN) - [NekoRay](https://github.com/Matsuridayo/nekoray) + - [Furious](https://github.com/LorenEteval/Furious) - [HiddifyN](https://github.com/hiddify/HiddifyN) - [Invisible Man - Xray](https://github.com/InvisibleManVPN/InvisibleMan-XRayClient) - Android @@ -76,10 +77,12 @@ - macOS arm64 & x64 - [V2rayU](https://github.com/yanue/V2rayU) - [V2RayXS](https://github.com/tzmax/V2RayXS) + - [Furious](https://github.com/LorenEteval/Furious) - [FoXray](https://apps.apple.com/app/foxray/id6448898396) - Linux - [v2rayA](https://github.com/v2rayA/v2rayA) - [NekoRay](https://github.com/Matsuridayo/nekoray) + - [Furious](https://github.com/LorenEteval/Furious) ## Others that support VLESS, XTLS, REALITY, XUDP, PLUX... @@ -90,6 +93,7 @@ - [xtlsapi](https://github.com/hiddify/xtlsapi) - [AndroidLibXrayLite](https://github.com/2dust/AndroidLibXrayLite) - [XrayKit](https://github.com/arror/XrayKit) + - [Xray-core-python](https://github.com/LorenEteval/Xray-core-python) - [XrayR](https://github.com/XrayR-project/XrayR) - [XrayR-release](https://github.com/XrayR-project/XrayR-release) - [XrayR-V2Board](https://github.com/missuo/XrayR-V2Board) From 017b56adf53d4813d01252157140dd9df5688477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=AC=E8=8A=B1ice?= <67498111+flowerinsnowdh@users.noreply.github.com> Date: Sun, 6 Aug 2023 14:47:31 +0800 Subject: [PATCH 110/867] Recognize .jsonc files automatically (#2398) Closes https://github.com/XTLS/Xray-core/issues/2399 --- core/config.go | 2 +- main/run.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/config.go b/core/config.go index 5892226b..c845e847 100644 --- a/core/config.go +++ b/core/config.go @@ -57,7 +57,7 @@ func GetFormatByExtension(ext string) string { return "yaml" case "toml": return "toml" - case "json": + case "json", "jsonc": return "json" default: return "" diff --git a/main/run.go b/main/run.go index 97967700..1f8a4b88 100644 --- a/main/run.go +++ b/main/run.go @@ -113,13 +113,13 @@ func dirExists(file string) bool { func getRegepxByFormat() string { switch strings.ToLower(*format) { case "json": - return `^.+\.json$` + return `^.+\.(json|jsonc)$` case "toml": return `^.+\.toml$` case "yaml", "yml": return `^.+\.(yaml|yml)$` default: - return `^.+\.(json|toml|yaml|yml)$` + return `^.+\.(json|jsonc|toml|yaml|yml)$` } } From cd547a3f43c5fd03462e4d359e761e9fb345a0ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 00:58:41 +0000 Subject: [PATCH 111/867] Bump golang.org/x/crypto from 0.11.0 to 0.12.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.11.0 to 0.12.0. - [Commits](https://github.com/golang/crypto/compare/v0.11.0...v0.12.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 0595f906..da3d05ba 100644 --- a/go.mod +++ b/go.mod @@ -20,10 +20,10 @@ require ( github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983 - golang.org/x/crypto v0.11.0 + golang.org/x/crypto v0.12.0 golang.org/x/net v0.13.0 golang.org/x/sync v0.3.0 - golang.org/x/sys v0.10.0 + golang.org/x/sys v0.11.0 google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c @@ -49,7 +49,7 @@ require ( go.uber.org/atomic v1.11.0 // indirect golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect golang.org/x/mod v0.11.0 // indirect - golang.org/x/text v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.10.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect diff --git a/go.sum b/go.sum index e5b2eea9..9503325e 100644 --- a/go.sum +++ b/go.sum @@ -176,8 +176,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= @@ -223,14 +223,14 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= From d4806c8e54a4c1cb1f13aa1aaff5a6c8d60e64b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 00:59:06 +0000 Subject: [PATCH 112/867] Bump github.com/quic-go/quic-go from 0.37.1 to 0.37.3 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.37.1 to 0.37.3. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.37.1...v0.37.3) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index da3d05ba..97583fed 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.37.1 + github.com/quic-go/quic-go v0.37.3 github.com/refraction-networking/utls v1.3.3 github.com/sagernet/sing v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.2 @@ -44,7 +44,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/onsi/ginkgo/v2 v2.11.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/quic-go/qtls-go1-20 v0.3.0 // indirect + github.com/quic-go/qtls-go1-20 v0.3.1 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect go.uber.org/atomic v1.11.0 // indirect golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect diff --git a/go.sum b/go.sum index 9503325e..18686edb 100644 --- a/go.sum +++ b/go.sum @@ -112,10 +112,10 @@ github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/quic-go/qtls-go1-20 v0.3.0 h1:NrCXmDl8BddZwO67vlvEpBTwT89bJfKYygxv4HQvuDk= -github.com/quic-go/qtls-go1-20 v0.3.0/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.37.1 h1:M+mcsFq9KoxVjCetIwH65TvusW1UdRBc6zmxI6pkeD0= -github.com/quic-go/quic-go v0.37.1/go.mod h1:XtCUOCALTTWbPyd0IxFfHf6h0sEMubRFvEYHl3QxKw8= +github.com/quic-go/qtls-go1-20 v0.3.1 h1:O4BLOM3hwfVF3AcktIylQXyl7Yi2iBNVy5QsV+ySxbg= +github.com/quic-go/qtls-go1-20 v0.3.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= +github.com/quic-go/quic-go v0.37.3 h1:pkHH3xaMNUNAh6OtgEV/0K6Fz+YIJXhPzgd/ShiRDm4= +github.com/quic-go/quic-go v0.37.3/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU= github.com/refraction-networking/utls v1.3.3 h1:f/TBLX7KBciRyFH3bwupp+CE4fzoYKCirhdRcC490sw= github.com/refraction-networking/utls v1.3.3/go.mod h1:DlecWW1LMlMJu+9qpzzQqdHDT/C2LAe03EdpLUz/RL8= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From d11826ee542bc06728c3436831a9e423666a4475 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Aug 2023 00:44:07 +0000 Subject: [PATCH 113/867] Bump golang.org/x/net from 0.13.0 to 0.14.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.13.0 to 0.14.0. - [Commits](https://github.com/golang/net/compare/v0.13.0...v0.14.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 97583fed..65bb74a5 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983 golang.org/x/crypto v0.12.0 - golang.org/x/net v0.13.0 + golang.org/x/net v0.14.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.11.0 google.golang.org/grpc v1.57.0 diff --git a/go.sum b/go.sum index 18686edb..93324e7a 100644 --- a/go.sum +++ b/go.sum @@ -198,8 +198,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY= -golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From e584b71b6082585d322de84304e2e0ab50deed20 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Aug 2023 00:29:10 +0000 Subject: [PATCH 114/867] Bump github.com/quic-go/quic-go from 0.37.3 to 0.37.4 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.37.3 to 0.37.4. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.37.3...v0.37.4) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 65bb74a5..1fdb91b7 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.37.3 + github.com/quic-go/quic-go v0.37.4 github.com/refraction-networking/utls v1.3.3 github.com/sagernet/sing v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.2 diff --git a/go.sum b/go.sum index 93324e7a..7900b808 100644 --- a/go.sum +++ b/go.sum @@ -114,8 +114,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qtls-go1-20 v0.3.1 h1:O4BLOM3hwfVF3AcktIylQXyl7Yi2iBNVy5QsV+ySxbg= github.com/quic-go/qtls-go1-20 v0.3.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.37.3 h1:pkHH3xaMNUNAh6OtgEV/0K6Fz+YIJXhPzgd/ShiRDm4= -github.com/quic-go/quic-go v0.37.3/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU= +github.com/quic-go/quic-go v0.37.4 h1:ke8B73yMCWGq9MfrCCAw0Uzdm7GaViC3i39dsIdDlH4= +github.com/quic-go/quic-go v0.37.4/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU= github.com/refraction-networking/utls v1.3.3 h1:f/TBLX7KBciRyFH3bwupp+CE4fzoYKCirhdRcC490sw= github.com/refraction-networking/utls v1.3.3/go.mod h1:DlecWW1LMlMJu+9qpzzQqdHDT/C2LAe03EdpLUz/RL8= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From f67167bb3bbfcb0f45393f37005a51024e58864b Mon Sep 17 00:00:00 2001 From: hax0r31337 Date: Thu, 10 Aug 2023 04:43:34 +0000 Subject: [PATCH 115/867] refactor(deps): replace github.com/golang/protobuf with google.golang.org/protobuf --- app/observatory/observer.go | 2 +- app/reverse/bridge.go | 2 +- app/reverse/portal.go | 2 +- app/router/condition_geoip_test.go | 2 +- app/router/condition_test.go | 2 +- common/serial/typed_message.go | 18 +++++++++--------- core/config.go | 2 +- core/functions_test.go | 2 +- core/xray_test.go | 2 +- features/extension/observatory.go | 2 +- go.mod | 2 +- infra/conf/blackhole.go | 2 +- infra/conf/buildable.go | 2 +- infra/conf/dns_proxy.go | 2 +- infra/conf/dns_test.go | 2 +- infra/conf/dokodemo.go | 2 +- infra/conf/freedom.go | 2 +- infra/conf/general_test.go | 2 +- infra/conf/grpc.go | 2 +- infra/conf/http.go | 2 +- infra/conf/loopback.go | 2 +- infra/conf/observatory.go | 2 +- infra/conf/reverse.go | 2 +- infra/conf/router.go | 21 +++++++++++++++++++-- infra/conf/router_test.go | 2 +- infra/conf/shadowsocks.go | 2 +- infra/conf/socks.go | 2 +- infra/conf/transport_authenticators.go | 2 +- infra/conf/transport_internet.go | 2 +- infra/conf/transport_test.go | 2 +- infra/conf/trojan.go | 2 +- infra/conf/vless.go | 2 +- infra/conf/vmess.go | 2 +- infra/conf/wireguard.go | 2 +- infra/conf/xray_test.go | 2 +- proxy/vless/encoding/addons.go | 2 +- testing/scenarios/common.go | 2 +- 37 files changed, 63 insertions(+), 46 deletions(-) diff --git a/app/observatory/observer.go b/app/observatory/observer.go index 576818c4..9d961f66 100644 --- a/app/observatory/observer.go +++ b/app/observatory/observer.go @@ -9,7 +9,6 @@ import ( "sync" "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" @@ -19,6 +18,7 @@ import ( "github.com/xtls/xray-core/features/extension" "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/transport/internet/tagged" + "google.golang.org/protobuf/proto" ) type Observer struct { diff --git a/app/reverse/bridge.go b/app/reverse/bridge.go index 4b86c3a2..be0fdcd9 100644 --- a/app/reverse/bridge.go +++ b/app/reverse/bridge.go @@ -4,7 +4,6 @@ import ( "context" "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" @@ -12,6 +11,7 @@ import ( "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/pipe" + "google.golang.org/protobuf/proto" ) // Bridge is a component in reverse proxy, that relays connections from Portal to local address. diff --git a/app/reverse/portal.go b/app/reverse/portal.go index b0860a6e..fb0b6930 100644 --- a/app/reverse/portal.go +++ b/app/reverse/portal.go @@ -5,7 +5,6 @@ import ( "sync" "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" @@ -15,6 +14,7 @@ import ( "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/pipe" + "google.golang.org/protobuf/proto" ) type Portal struct { diff --git a/app/router/condition_geoip_test.go b/app/router/condition_geoip_test.go index b5a5ef90..1a730021 100644 --- a/app/router/condition_geoip_test.go +++ b/app/router/condition_geoip_test.go @@ -5,12 +5,12 @@ import ( "path/filepath" "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" "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/common/platform/filesystem" + "google.golang.org/protobuf/proto" ) func init() { diff --git a/app/router/condition_test.go b/app/router/condition_test.go index fd898417..b5d59297 100644 --- a/app/router/condition_test.go +++ b/app/router/condition_test.go @@ -6,7 +6,6 @@ import ( "strconv" "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" @@ -18,6 +17,7 @@ import ( "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/features/routing" routing_session "github.com/xtls/xray-core/features/routing/session" + "google.golang.org/protobuf/proto" ) func init() { diff --git a/common/serial/typed_message.go b/common/serial/typed_message.go index e59d1d0d..baecc92e 100644 --- a/common/serial/typed_message.go +++ b/common/serial/typed_message.go @@ -1,10 +1,9 @@ package serial import ( - "errors" - "reflect" - - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" ) // ToTypedMessage converts a proto Message into TypedMessage. @@ -21,16 +20,17 @@ func ToTypedMessage(message proto.Message) *TypedMessage { // GetMessageType returns the name of this proto Message. func GetMessageType(message proto.Message) string { - return proto.MessageName(message) + return string(message.ProtoReflect().Descriptor().FullName()) } // GetInstance creates a new instance of the message with messageType. func GetInstance(messageType string) (interface{}, error) { - mType := proto.MessageType(messageType) - if mType == nil || mType.Elem() == nil { - return nil, errors.New("Serial: Unknown type: " + messageType) + messageTypeDescriptor := protoreflect.FullName(messageType) + mType, err := protoregistry.GlobalTypes.FindMessageByName(messageTypeDescriptor) + if err != nil { + return nil, err } - return reflect.New(mType.Elem()).Interface(), nil + return mType.New().Interface(), nil } // GetInstance converts current TypedMessage into a proto Message. diff --git a/core/config.go b/core/config.go index c845e847..f4077449 100644 --- a/core/config.go +++ b/core/config.go @@ -4,11 +4,11 @@ import ( "io" "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" "github.com/xtls/xray-core/main/confloader" + "google.golang.org/protobuf/proto" ) // ConfigFormat is a configurable format of Xray config file. diff --git a/core/functions_test.go b/core/functions_test.go index 2355cc03..5658de1c 100644 --- a/core/functions_test.go +++ b/core/functions_test.go @@ -7,7 +7,6 @@ import ( "testing" "time" - "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" @@ -18,6 +17,7 @@ import ( "github.com/xtls/xray-core/proxy/freedom" "github.com/xtls/xray-core/testing/servers/tcp" "github.com/xtls/xray-core/testing/servers/udp" + "google.golang.org/protobuf/proto" ) func xor(b []byte) []byte { diff --git a/core/xray_test.go b/core/xray_test.go index 59de0f46..a4a8ec9f 100644 --- a/core/xray_test.go +++ b/core/xray_test.go @@ -3,7 +3,6 @@ package core_test 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" @@ -19,6 +18,7 @@ import ( "github.com/xtls/xray-core/proxy/vmess" "github.com/xtls/xray-core/proxy/vmess/outbound" "github.com/xtls/xray-core/testing/servers/tcp" + "google.golang.org/protobuf/proto" ) func TestXrayDependency(t *testing.T) { diff --git a/features/extension/observatory.go b/features/extension/observatory.go index eb51a61b..8e871030 100644 --- a/features/extension/observatory.go +++ b/features/extension/observatory.go @@ -3,8 +3,8 @@ package extension import ( "context" - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/features" + "google.golang.org/protobuf/proto" ) type Observatory interface { diff --git a/go.mod b/go.mod index 1fdb91b7..e76ded6a 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.20 require ( github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 github.com/golang/mock v1.6.0 - github.com/golang/protobuf v1.5.3 github.com/google/go-cmp v0.5.9 github.com/gorilla/websocket v1.5.0 github.com/miekg/dns v1.1.55 @@ -38,6 +37,7 @@ require ( github.com/francoispqt/gojay v1.2.13 // indirect github.com/gaukas/godicttls v0.0.3 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect github.com/klauspost/compress v1.16.6 // indirect diff --git a/infra/conf/blackhole.go b/infra/conf/blackhole.go index c1551de1..5044a8c0 100644 --- a/infra/conf/blackhole.go +++ b/infra/conf/blackhole.go @@ -3,9 +3,9 @@ package conf import ( "encoding/json" - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/proxy/blackhole" + "google.golang.org/protobuf/proto" ) type NoneResponse struct{} diff --git a/infra/conf/buildable.go b/infra/conf/buildable.go index 1d01cd66..967e9740 100644 --- a/infra/conf/buildable.go +++ b/infra/conf/buildable.go @@ -1,6 +1,6 @@ package conf -import "github.com/golang/protobuf/proto" +import "google.golang.org/protobuf/proto" type Buildable interface { Build() (proto.Message, error) diff --git a/infra/conf/dns_proxy.go b/infra/conf/dns_proxy.go index 564084e0..13a44597 100644 --- a/infra/conf/dns_proxy.go +++ b/infra/conf/dns_proxy.go @@ -1,9 +1,9 @@ package conf import ( - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/proxy/dns" + "google.golang.org/protobuf/proto" ) type DNSOutboundConfig struct { diff --git a/infra/conf/dns_test.go b/infra/conf/dns_test.go index c97c5bea..1c370cd9 100644 --- a/infra/conf/dns_test.go +++ b/infra/conf/dns_test.go @@ -6,7 +6,6 @@ import ( "path/filepath" "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" @@ -14,6 +13,7 @@ import ( "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/common/platform/filesystem" . "github.com/xtls/xray-core/infra/conf" + "google.golang.org/protobuf/proto" ) func init() { diff --git a/infra/conf/dokodemo.go b/infra/conf/dokodemo.go index 03a21d71..2a4b74ea 100644 --- a/infra/conf/dokodemo.go +++ b/infra/conf/dokodemo.go @@ -1,8 +1,8 @@ package conf import ( - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/proxy/dokodemo" + "google.golang.org/protobuf/proto" ) type DokodemoConfig struct { diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 60c5b7f1..21f0616a 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -5,10 +5,10 @@ import ( "strconv" "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" + "google.golang.org/protobuf/proto" ) type FreedomConfig struct { diff --git a/infra/conf/general_test.go b/infra/conf/general_test.go index 1de1109c..4d23b3b5 100644 --- a/infra/conf/general_test.go +++ b/infra/conf/general_test.go @@ -4,9 +4,9 @@ import ( "encoding/json" "testing" - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/common" . "github.com/xtls/xray-core/infra/conf" + "google.golang.org/protobuf/proto" ) func loadJSON(creator func() Buildable) func(string) (proto.Message, error) { diff --git a/infra/conf/grpc.go b/infra/conf/grpc.go index 9085ab4d..18447512 100644 --- a/infra/conf/grpc.go +++ b/infra/conf/grpc.go @@ -1,8 +1,8 @@ package conf import ( - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/transport/internet/grpc" + "google.golang.org/protobuf/proto" ) type GRPCConfig struct { diff --git a/infra/conf/http.go b/infra/conf/http.go index ddeaa69e..b391dbf2 100644 --- a/infra/conf/http.go +++ b/infra/conf/http.go @@ -3,10 +3,10 @@ package conf 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" + "google.golang.org/protobuf/proto" ) type HTTPAccount struct { diff --git a/infra/conf/loopback.go b/infra/conf/loopback.go index b6d83178..87d349ce 100644 --- a/infra/conf/loopback.go +++ b/infra/conf/loopback.go @@ -1,8 +1,8 @@ package conf import ( - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/proxy/loopback" + "google.golang.org/protobuf/proto" ) type LoopbackConfig struct { diff --git a/infra/conf/observatory.go b/infra/conf/observatory.go index 25a4d52c..f51787a4 100644 --- a/infra/conf/observatory.go +++ b/infra/conf/observatory.go @@ -1,9 +1,9 @@ package conf import ( - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/app/observatory" "github.com/xtls/xray-core/infra/conf/cfgcommon/duration" + "google.golang.org/protobuf/proto" ) type ObservatoryConfig struct { diff --git a/infra/conf/reverse.go b/infra/conf/reverse.go index 1b42a63a..f44c9992 100644 --- a/infra/conf/reverse.go +++ b/infra/conf/reverse.go @@ -1,8 +1,8 @@ package conf import ( - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/app/reverse" + "google.golang.org/protobuf/proto" ) type BridgeConfig struct { diff --git a/infra/conf/router.go b/infra/conf/router.go index 135454bc..a9f57cd6 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -6,10 +6,10 @@ import ( "strconv" "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" + "google.golang.org/protobuf/proto" ) type RouterRulesConfig struct { @@ -245,6 +245,23 @@ func loadSite(file, code string) ([]*router.Domain, error) { return SiteCache[index].Domain, nil } +func DecodeVarint(buf []byte) (x uint64, n int) { + for shift := uint(0); shift < 64; shift += 7 { + if n >= len(buf) { + return 0, 0 + } + b := uint64(buf[n]) + n++ + x |= (b & 0x7F) << shift + if (b & 0x80) == 0 { + return x, n + } + } + + // The number is too large to represent in a 64-bit value. + return 0, 0 +} + func find(data, code []byte) []byte { codeL := len(code) if codeL == 0 { @@ -255,7 +272,7 @@ func find(data, code []byte) []byte { if dataL < 2 { return nil } - x, y := proto.DecodeVarint(data[1:]) + x, y := DecodeVarint(data[1:]) if x == 0 && y == 0 { return nil } diff --git a/infra/conf/router_test.go b/infra/conf/router_test.go index 98e31b3a..63dc8e8d 100644 --- a/infra/conf/router_test.go +++ b/infra/conf/router_test.go @@ -7,13 +7,13 @@ import ( "testing" _ "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" "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/common/platform/filesystem" . "github.com/xtls/xray-core/infra/conf" + "google.golang.org/protobuf/proto" ) func init() { diff --git a/infra/conf/shadowsocks.go b/infra/conf/shadowsocks.go index 240d4aaa..3dcbb2f3 100644 --- a/infra/conf/shadowsocks.go +++ b/infra/conf/shadowsocks.go @@ -3,13 +3,13 @@ package conf import ( "strings" - "github.com/golang/protobuf/proto" "github.com/sagernet/sing-shadowsocks/shadowaead_2022" C "github.com/sagernet/sing/common" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/proxy/shadowsocks" "github.com/xtls/xray-core/proxy/shadowsocks_2022" + "google.golang.org/protobuf/proto" ) func cipherFromString(c string) shadowsocks.CipherType { diff --git a/infra/conf/socks.go b/infra/conf/socks.go index 490c24bd..61f6fae2 100644 --- a/infra/conf/socks.go +++ b/infra/conf/socks.go @@ -4,10 +4,10 @@ import ( "encoding/json" "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" + "google.golang.org/protobuf/proto" ) type SocksAccount struct { diff --git a/infra/conf/transport_authenticators.go b/infra/conf/transport_authenticators.go index 46be8588..db9f4a72 100644 --- a/infra/conf/transport_authenticators.go +++ b/infra/conf/transport_authenticators.go @@ -3,7 +3,6 @@ package conf import ( "sort" - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/transport/internet/headers/dns" "github.com/xtls/xray-core/transport/internet/headers/http" "github.com/xtls/xray-core/transport/internet/headers/noop" @@ -12,6 +11,7 @@ import ( "github.com/xtls/xray-core/transport/internet/headers/utp" "github.com/xtls/xray-core/transport/internet/headers/wechat" "github.com/xtls/xray-core/transport/internet/headers/wireguard" + "google.golang.org/protobuf/proto" ) type NoOpAuthenticator struct{} diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 958edfad..55cc8c2e 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -11,7 +11,6 @@ import ( "strings" "syscall" - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/platform/filesystem" "github.com/xtls/xray-core/common/protocol" @@ -26,6 +25,7 @@ import ( "github.com/xtls/xray-core/transport/internet/tcp" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/internet/websocket" + "google.golang.org/protobuf/proto" ) var ( diff --git a/infra/conf/transport_test.go b/infra/conf/transport_test.go index 3afe9729..989c259c 100644 --- a/infra/conf/transport_test.go +++ b/infra/conf/transport_test.go @@ -4,7 +4,6 @@ import ( "encoding/json" "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" @@ -18,6 +17,7 @@ import ( "github.com/xtls/xray-core/transport/internet/quic" "github.com/xtls/xray-core/transport/internet/tcp" "github.com/xtls/xray-core/transport/internet/websocket" + "google.golang.org/protobuf/proto" ) func TestSocketConfig(t *testing.T) { diff --git a/infra/conf/trojan.go b/infra/conf/trojan.go index e9d78f8a..2cd1e520 100644 --- a/infra/conf/trojan.go +++ b/infra/conf/trojan.go @@ -6,11 +6,11 @@ import ( "strconv" "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" "github.com/xtls/xray-core/proxy/trojan" + "google.golang.org/protobuf/proto" ) // TrojanServerTarget is configuration of a single trojan server diff --git a/infra/conf/vless.go b/infra/conf/vless.go index d829cdee..2e5c5d64 100644 --- a/infra/conf/vless.go +++ b/infra/conf/vless.go @@ -6,7 +6,6 @@ import ( "strconv" "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" @@ -14,6 +13,7 @@ import ( "github.com/xtls/xray-core/proxy/vless" "github.com/xtls/xray-core/proxy/vless/inbound" "github.com/xtls/xray-core/proxy/vless/outbound" + "google.golang.org/protobuf/proto" ) type VLessInboundFallback struct { diff --git a/infra/conf/vmess.go b/infra/conf/vmess.go index 93d0e75b..ba319356 100644 --- a/infra/conf/vmess.go +++ b/infra/conf/vmess.go @@ -4,13 +4,13 @@ import ( "encoding/json" "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" "github.com/xtls/xray-core/proxy/vmess" "github.com/xtls/xray-core/proxy/vmess/inbound" "github.com/xtls/xray-core/proxy/vmess/outbound" + "google.golang.org/protobuf/proto" ) type VMessAccount struct { diff --git a/infra/conf/wireguard.go b/infra/conf/wireguard.go index 6b102b14..0c79297b 100644 --- a/infra/conf/wireguard.go +++ b/infra/conf/wireguard.go @@ -4,8 +4,8 @@ import ( "encoding/base64" "encoding/hex" - "github.com/golang/protobuf/proto" "github.com/xtls/xray-core/proxy/wireguard" + "google.golang.org/protobuf/proto" ) type WireGuardPeerConfig struct { diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index a4898457..c7e20ed4 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -5,7 +5,6 @@ import ( "reflect" "testing" - "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" @@ -27,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" + "google.golang.org/protobuf/proto" ) func TestXrayConfig(t *testing.T) { diff --git a/proxy/vless/encoding/addons.go b/proxy/vless/encoding/addons.go index d62e400f..fc8ddc2a 100644 --- a/proxy/vless/encoding/addons.go +++ b/proxy/vless/encoding/addons.go @@ -3,10 +3,10 @@ package encoding 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" + "google.golang.org/protobuf/proto" ) func EncodeHeaderAddons(buffer *buf.Buffer, addons *Addons) error { diff --git a/testing/scenarios/common.go b/testing/scenarios/common.go index f011a64f..8d629c59 100644 --- a/testing/scenarios/common.go +++ b/testing/scenarios/common.go @@ -14,7 +14,6 @@ import ( "testing" "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" @@ -25,6 +24,7 @@ import ( "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/units" core "github.com/xtls/xray-core/core" + "google.golang.org/protobuf/proto" ) func xor(b []byte) []byte { From a343d689444e3ace08252b17ae1cf7f939a283ef Mon Sep 17 00:00:00 2001 From: cty123 Date: Sat, 19 Aug 2023 22:10:59 +0200 Subject: [PATCH 116/867] fix(proxy): removed the udp payload length check when encryption is disabled --- proxy/shadowsocks/protocol.go | 64 +++++++++++---------- proxy/shadowsocks/protocol_test.go | 91 ++++++++++++++++++++++-------- proxy/shadowsocks/validator.go | 5 ++ 3 files changed, 107 insertions(+), 53 deletions(-) diff --git a/proxy/shadowsocks/protocol.go b/proxy/shadowsocks/protocol.go index 3176d118..3a0c7e22 100644 --- a/proxy/shadowsocks/protocol.go +++ b/proxy/shadowsocks/protocol.go @@ -4,6 +4,7 @@ import ( "crypto/hmac" "crypto/rand" "crypto/sha256" + "errors" "hash/crc32" "io" @@ -236,37 +237,37 @@ func EncodeUDPPacket(request *protocol.RequestHeader, payload []byte) (*buf.Buff } func DecodeUDPPacket(validator *Validator, payload *buf.Buffer) (*protocol.RequestHeader, *buf.Buffer, error) { - bs := payload.Bytes() - if len(bs) <= 32 { - return nil, nil, newError("len(bs) <= 32") - } + rawPayload := payload.Bytes() + user, _, d, _, err := validator.Get(rawPayload, protocol.RequestCommandUDP) - user, _, d, _, err := validator.Get(bs, protocol.RequestCommandUDP) - switch err { - case ErrIVNotUnique: + if errors.Is(err, ErrIVNotUnique) { return nil, nil, newError("failed iv check").Base(err) - case ErrNotFound: - return nil, nil, newError("failed to match an user").Base(err) - default: - account := user.Account.(*MemoryAccount) - if account.Cipher.IsAEAD() { - payload.Clear() - payload.Write(d) - } else { - if account.Cipher.IVSize() > 0 { - iv := make([]byte, account.Cipher.IVSize()) - copy(iv, payload.BytesTo(account.Cipher.IVSize())) - } - if err = account.Cipher.DecodePacket(account.Key, payload); err != nil { - return nil, nil, newError("failed to decrypt UDP payload").Base(err) - } - } } - request := &protocol.RequestHeader{ - Version: Version, - User: user, - Command: protocol.RequestCommandUDP, + if errors.Is(err, ErrNotFound) { + return nil, nil, newError("failed to match an user").Base(err) + } + + if err != nil { + return nil, nil, newError("unexpected error").Base(err) + } + + account, ok := user.Account.(*MemoryAccount) + if !ok { + return nil, nil, newError("expected MemoryAccount returned from validator") + } + + if account.Cipher.IsAEAD() { + payload.Clear() + payload.Write(d) + } else { + if account.Cipher.IVSize() > 0 { + iv := make([]byte, account.Cipher.IVSize()) + copy(iv, payload.BytesTo(account.Cipher.IVSize())) + } + if err = account.Cipher.DecodePacket(account.Key, payload); err != nil { + return nil, nil, newError("failed to decrypt UDP payload").Base(err) + } } payload.SetByte(0, payload.Byte(0)&0x0F) @@ -276,8 +277,13 @@ func DecodeUDPPacket(validator *Validator, payload *buf.Buffer) (*protocol.Reque return nil, nil, newError("failed to parse address").Base(err) } - request.Address = addr - request.Port = port + request := &protocol.RequestHeader{ + Version: Version, + User: user, + Command: protocol.RequestCommandUDP, + Address: addr, + Port: port, + } return request, payload, nil } diff --git a/proxy/shadowsocks/protocol_test.go b/proxy/shadowsocks/protocol_test.go index e1b6495e..4083905d 100644 --- a/proxy/shadowsocks/protocol_test.go +++ b/proxy/shadowsocks/protocol_test.go @@ -23,37 +23,80 @@ func equalRequestHeader(x, y *protocol.RequestHeader) bool { })) } -func TestUDPEncoding(t *testing.T) { - request := &protocol.RequestHeader{ - Version: Version, - Command: protocol.RequestCommandUDP, - Address: net.LocalHostIP, - Port: 1234, - User: &protocol.MemoryUser{ - Email: "love@example.com", - Account: toAccount(&Account{ - Password: "password", - CipherType: CipherType_AES_128_GCM, - }), +func TestUDPEncodingDecoding(t *testing.T) { + testRequests := []protocol.RequestHeader{ + { + Version: Version, + Command: protocol.RequestCommandUDP, + Address: net.LocalHostIP, + Port: 1234, + User: &protocol.MemoryUser{ + Email: "love@example.com", + Account: toAccount(&Account{ + Password: "password", + CipherType: CipherType_AES_128_GCM, + }), + }, + }, + { + Version: Version, + Command: protocol.RequestCommandUDP, + Address: net.LocalHostIP, + Port: 1234, + User: &protocol.MemoryUser{ + Email: "love@example.com", + Account: toAccount(&Account{ + Password: "123", + CipherType: CipherType_NONE, + }), + }, }, } - data := buf.New() - common.Must2(data.WriteString("test string")) - encodedData, err := EncodeUDPPacket(request, data.Bytes()) - common.Must(err) + for _, request := range testRequests { + data := buf.New() + common.Must2(data.WriteString("test string")) + encodedData, err := EncodeUDPPacket(&request, data.Bytes()) + common.Must(err) - validator := new(Validator) - validator.Add(request.User) - decodedRequest, decodedData, err := DecodeUDPPacket(validator, encodedData) - common.Must(err) + validator := new(Validator) + validator.Add(request.User) + decodedRequest, decodedData, err := DecodeUDPPacket(validator, encodedData) + common.Must(err) - if r := cmp.Diff(decodedData.Bytes(), data.Bytes()); r != "" { - t.Error("data: ", r) + if r := cmp.Diff(decodedData.Bytes(), data.Bytes()); r != "" { + t.Error("data: ", r) + } + + if equalRequestHeader(decodedRequest, &request) == false { + t.Error("different request") + } + } +} + +func TestUDPDecodingWithPayloadTooShort(t *testing.T) { + testAccounts := []protocol.Account{ + toAccount(&Account{ + Password: "password", + CipherType: CipherType_AES_128_GCM, + }), + toAccount(&Account{ + Password: "password", + CipherType: CipherType_NONE, + }), } - if equalRequestHeader(decodedRequest, request) == false { - t.Error("different request") + for _, account := range testAccounts { + data := buf.New() + data.WriteString("short payload") + validator := new(Validator) + validator.Add(&protocol.MemoryUser{ + Account: account, + }) + _, _, err := DecodeUDPPacket(validator, data) + if err == nil { + t.Fatal("expected error") + } } } diff --git a/proxy/shadowsocks/validator.go b/proxy/shadowsocks/validator.go index 2aa62e06..8888a1c0 100644 --- a/proxy/shadowsocks/validator.go +++ b/proxy/shadowsocks/validator.go @@ -80,6 +80,11 @@ func (v *Validator) Get(bs []byte, command protocol.RequestCommand) (u *protocol for _, user := range v.users { if account := user.Account.(*MemoryAccount); account.Cipher.IsAEAD() { + // AEAD payload decoding requires the payload to be over 32 bytes + if len(bs) < 32 { + continue + } + aeadCipher := account.Cipher.(*AEADCipher) ivLen = aeadCipher.IVSize() iv := bs[:ivLen] From 75c99e283a397e43ccca9c7ead7d8596b1b6f633 Mon Sep 17 00:00:00 2001 From: iamybj <94730407+benjaminyin01@users.noreply.github.com> Date: Sat, 19 Aug 2023 22:19:46 +0800 Subject: [PATCH 117/867] Update README.md A better docker image of xray --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 761b2ee7..f4723d88 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ - Linux Script - [XTLS/Xray-install](https://github.com/XTLS/Xray-install) - Docker + - [iamybj/docker-xray](https://hub.docker.com/r/iamybj/docker-xray) - [teddysun/xray](https://hub.docker.com/r/teddysun/xray) - Web Panel - [X-UI](https://github.com/FranzKafkaYu/x-ui), [X-UI-English](https://github.com/NidukaAkalanka/x-ui-english), [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [X-UI](https://github.com/diditra/x-ui) From 599cfd09b08acb1f000a2e83b4563317872a5158 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Aug 2023 01:01:53 +0000 Subject: [PATCH 118/867] Bump github.com/quic-go/quic-go from 0.37.4 to 0.37.5 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.37.4 to 0.37.5. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.37.4...v0.37.5) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e76ded6a..973250b7 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.37.4 + github.com/quic-go/quic-go v0.37.5 github.com/refraction-networking/utls v1.3.3 github.com/sagernet/sing v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.2 diff --git a/go.sum b/go.sum index 7900b808..4198fcf5 100644 --- a/go.sum +++ b/go.sum @@ -114,8 +114,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qtls-go1-20 v0.3.1 h1:O4BLOM3hwfVF3AcktIylQXyl7Yi2iBNVy5QsV+ySxbg= github.com/quic-go/qtls-go1-20 v0.3.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.37.4 h1:ke8B73yMCWGq9MfrCCAw0Uzdm7GaViC3i39dsIdDlH4= -github.com/quic-go/quic-go v0.37.4/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU= +github.com/quic-go/quic-go v0.37.5 h1:pzkYe8AgaxHi+7KJrYBMF+u2rLO5a9kwyCp2dAsljzk= +github.com/quic-go/quic-go v0.37.5/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU= github.com/refraction-networking/utls v1.3.3 h1:f/TBLX7KBciRyFH3bwupp+CE4fzoYKCirhdRcC490sw= github.com/refraction-networking/utls v1.3.3/go.mod h1:DlecWW1LMlMJu+9qpzzQqdHDT/C2LAe03EdpLUz/RL8= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From efe8f3f4d6cce5ed529c2b1aa0a39b7a08e031a3 Mon Sep 17 00:00:00 2001 From: cty123 Date: Sun, 20 Aug 2023 13:18:39 +0200 Subject: [PATCH 119/867] fix(config): fix grpc cofnig parsing when service name only has one '/' char --- transport/internet/grpc/config.go | 7 ++++++- transport/internet/grpc/config_test.go | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/transport/internet/grpc/config.go b/transport/internet/grpc/config.go index 39eadf31..aab1178e 100644 --- a/transport/internet/grpc/config.go +++ b/transport/internet/grpc/config.go @@ -21,8 +21,13 @@ func (c *Config) getServiceName() string { if !strings.HasPrefix(c.ServiceName, "/") { return url.PathEscape(c.ServiceName) } + // Otherwise new custom paths - rawServiceName := c.ServiceName[1:strings.LastIndex(c.ServiceName, "/")] // trim from first to last '/' + lastIndex := strings.LastIndex(c.ServiceName, "/") + if lastIndex < 1 { + lastIndex = 1 + } + rawServiceName := c.ServiceName[1:lastIndex] // trim from first to last '/' serviceNameParts := strings.Split(rawServiceName, "/") for i := range serviceNameParts { serviceNameParts[i] = url.PathEscape(serviceNameParts[i]) diff --git a/transport/internet/grpc/config_test.go b/transport/internet/grpc/config_test.go index fbc549b4..b159ffdf 100644 --- a/transport/internet/grpc/config_test.go +++ b/transport/internet/grpc/config_test.go @@ -1,8 +1,9 @@ package grpc import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestConfig_GetServiceName(t *testing.T) { @@ -31,6 +32,11 @@ func TestConfig_GetServiceName(t *testing.T) { ServiceName: "/hello /world!/a|b", Expected: "hello%20/world%21", }, + { + TestName: "path with only one '/'", + ServiceName: "/foo", + Expected: "", + }, } for _, test := range tests { t.Run(test.TestName, func(t *testing.T) { From 783ac10842aa424733ee5b9b057e6820c0f593d6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 00:40:57 +0000 Subject: [PATCH 120/867] Bump github.com/quic-go/quic-go from 0.37.5 to 0.37.6 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.37.5 to 0.37.6. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.37.5...v0.37.6) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 973250b7..4b4e8c11 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.37.5 + github.com/quic-go/quic-go v0.37.6 github.com/refraction-networking/utls v1.3.3 github.com/sagernet/sing v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.2 diff --git a/go.sum b/go.sum index 4198fcf5..49facab3 100644 --- a/go.sum +++ b/go.sum @@ -114,8 +114,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qtls-go1-20 v0.3.1 h1:O4BLOM3hwfVF3AcktIylQXyl7Yi2iBNVy5QsV+ySxbg= github.com/quic-go/qtls-go1-20 v0.3.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.37.5 h1:pzkYe8AgaxHi+7KJrYBMF+u2rLO5a9kwyCp2dAsljzk= -github.com/quic-go/quic-go v0.37.5/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU= +github.com/quic-go/quic-go v0.37.6 h1:2IIUmQzT5YNxAiaPGjs++Z4hGOtIR0q79uS5qE9ccfY= +github.com/quic-go/quic-go v0.37.6/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU= github.com/refraction-networking/utls v1.3.3 h1:f/TBLX7KBciRyFH3bwupp+CE4fzoYKCirhdRcC490sw= github.com/refraction-networking/utls v1.3.3/go.mod h1:DlecWW1LMlMJu+9qpzzQqdHDT/C2LAe03EdpLUz/RL8= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From acadf5c0e99ecc94770c991ab1848f7e250e305c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Aug 2023 00:03:57 +0000 Subject: [PATCH 121/867] Bump github.com/quic-go/quic-go from 0.37.6 to 0.38.0 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.37.6 to 0.38.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.37.6...v0.38.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 4b4e8c11..2625a6ab 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.37.6 + github.com/quic-go/quic-go v0.38.0 github.com/refraction-networking/utls v1.3.3 github.com/sagernet/sing v0.2.7 github.com/sagernet/sing-shadowsocks v0.2.2 @@ -44,7 +44,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/onsi/ginkgo/v2 v2.11.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/quic-go/qtls-go1-20 v0.3.1 // indirect + github.com/quic-go/qtls-go1-20 v0.3.2 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect go.uber.org/atomic v1.11.0 // indirect golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect diff --git a/go.sum b/go.sum index 49facab3..a98d33c6 100644 --- a/go.sum +++ b/go.sum @@ -112,10 +112,10 @@ github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/quic-go/qtls-go1-20 v0.3.1 h1:O4BLOM3hwfVF3AcktIylQXyl7Yi2iBNVy5QsV+ySxbg= -github.com/quic-go/qtls-go1-20 v0.3.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.37.6 h1:2IIUmQzT5YNxAiaPGjs++Z4hGOtIR0q79uS5qE9ccfY= -github.com/quic-go/quic-go v0.37.6/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU= +github.com/quic-go/qtls-go1-20 v0.3.2 h1:rRgN3WfnKbyik4dBV8A6girlJVxGand/d+jVKbQq5GI= +github.com/quic-go/qtls-go1-20 v0.3.2/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= +github.com/quic-go/quic-go v0.38.0 h1:T45lASr5q/TrVwt+jrVccmqHhPL2XuSyoCLVCpfOSLc= +github.com/quic-go/quic-go v0.38.0/go.mod h1:MPCuRq7KBK2hNcfKj/1iD1BGuN3eAYMeNxp3T42LRUg= github.com/refraction-networking/utls v1.3.3 h1:f/TBLX7KBciRyFH3bwupp+CE4fzoYKCirhdRcC490sw= github.com/refraction-networking/utls v1.3.3/go.mod h1:DlecWW1LMlMJu+9qpzzQqdHDT/C2LAe03EdpLUz/RL8= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From c1db1f4dcec6a8df220d9069618965e0b7d288cd Mon Sep 17 00:00:00 2001 From: computerscot <125355930+computerscot@users.noreply.github.com> Date: Mon, 21 Aug 2023 11:27:13 -0700 Subject: [PATCH 122/867] Add "Xray REALITY with 'steal oneself'" example to README Step-by-step instructions for 'steal oneself' --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f4723d88..ecf67e7d 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ - [XTLS Vision](https://github.com/chika0801/Xray-install) - [REALITY (English)](https://cscot.pages.dev/2023/03/02/Xray-REALITY-tutorial/) - [XTLS-Iran-Reality (English)](https://github.com/SasukeFreestyle/XTLS-Iran-Reality) + - [Xray REALITY with 'steal oneself' (English)](https://computerscot.github.io/vless-xtls-utls-reality-steal-oneself.html) ## GUI Clients From cd1d00086087774320ac3961daf16df63445c716 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 20 Aug 2023 23:12:13 -0400 Subject: [PATCH 123/867] Docker build use 1.20 go --- .github/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index ad1e8c3d..a6678416 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -FROM --platform=$BUILDPLATFORM golang:alpine AS build +FROM --platform=$BUILDPLATFORM golang:1.20-alpine AS build WORKDIR /src COPY . . ARG TARGETOS TARGETARCH From fce86aad332decf332a266b70ad9b39837c93739 Mon Sep 17 00:00:00 2001 From: mengskysama Date: Wed, 23 Aug 2023 01:21:27 +0800 Subject: [PATCH 124/867] fix(common): strmatcher match domain safety --- common/strmatcher/ac_automaton_matcher.go | 6 +++++- common/strmatcher/strmatcher_test.go | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/common/strmatcher/ac_automaton_matcher.go b/common/strmatcher/ac_automaton_matcher.go index ab7c09bd..24be9dac 100644 --- a/common/strmatcher/ac_automaton_matcher.go +++ b/common/strmatcher/ac_automaton_matcher.go @@ -225,7 +225,11 @@ func (ac *ACAutomaton) Match(s string) bool { // 2. the match string is through a fail edge. NOT FULL MATCH // 2.1 Through a fail edge, but there exists a valid node. SUBSTR for i := len(s) - 1; i >= 0; i-- { - idx := char2Index[s[i]] + chr := int(s[i]) + if chr >= len(char2Index) { + return false + } + idx := char2Index[chr] fullMatch = fullMatch && ac.trie[node][idx].edgeType node = ac.trie[node][idx].nextNode switch ac.exists[node].matchType { diff --git a/common/strmatcher/strmatcher_test.go b/common/strmatcher/strmatcher_test.go index 2e48c1b7..408ae628 100644 --- a/common/strmatcher/strmatcher_test.go +++ b/common/strmatcher/strmatcher_test.go @@ -217,6 +217,10 @@ func TestACAutomaton(t *testing.T) { pattern: "vvgoogle.com", res: true, }, + { + pattern: "½", + res: false, + }, } for _, test := range cases2Output { if m := ac.Match(test.pattern); m != test.res { @@ -224,7 +228,6 @@ func TestACAutomaton(t *testing.T) { } } } - { cases3Input := []struct { pattern string From 229851f62144939d46f24f32cb1bf733d390d50a Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 24 Aug 2023 11:13:12 -0400 Subject: [PATCH 125/867] Revert "Docker build use 1.20 go" This reverts commit cd1d00086087774320ac3961daf16df63445c716. --- .github/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index a6678416..ad1e8c3d 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -1,5 +1,5 @@ # syntax=docker/dockerfile:1 -FROM --platform=$BUILDPLATFORM golang:1.20-alpine AS build +FROM --platform=$BUILDPLATFORM golang:alpine AS build WORKDIR /src COPY . . ARG TARGETOS TARGETARCH From d616f6160df2e63787673ec9abfe37becc2e1278 Mon Sep 17 00:00:00 2001 From: douglarek Date: Wed, 23 Aug 2023 22:30:46 +0800 Subject: [PATCH 126/867] Fix go 1.21 build, see https://github.com/XTLS/Xray-core/issues/2466 --- go.mod | 4 ++-- go.sum | 8 ++++---- proxy/wireguard/tun.go | 12 ++++++------ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 2625a6ab..29567642 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/sys v0.11.0 google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 - gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c + gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.2.1 ) @@ -47,7 +47,7 @@ require ( github.com/quic-go/qtls-go1-20 v0.3.2 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect go.uber.org/atomic v1.11.0 // indirect - golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect + golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 // indirect golang.org/x/mod v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect golang.org/x/time v0.3.0 // indirect diff --git a/go.sum b/go.sum index a98d33c6..e0eb4c79 100644 --- a/go.sum +++ b/go.sum @@ -179,8 +179,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= -golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 h1:Di6/M8l0O2lCLc6VVRWhgCiApHV8MnQurBnFSHsQtNY= +golang.org/x/exp v0.0.0-20230725093048-515e97ebf090/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -284,8 +284,8 @@ gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= -gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h1:m5lcgWnL3OElQNVyp3qcncItJ2c0sQlSGjYK2+nJTA4= -gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c/go.mod h1:TIvkJD0sxe8pIob3p6T8IzxXunlp6yfgktvTNp+DGNM= +gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 h1:tE44CyJgxEGzoPtHs9GI7ddKdgEGCREQBP54AmaVM+I= +gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744/go.mod h1:lYEMhXbxgudVhALYsMQrBaUAjM3NMinh8mKL1CJv7rc= h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo= h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/proxy/wireguard/tun.go b/proxy/wireguard/tun.go index 4d1cb7f6..ed6e434f 100644 --- a/proxy/wireguard/tun.go +++ b/proxy/wireguard/tun.go @@ -14,7 +14,7 @@ import ( "github.com/sagernet/wireguard-go/tun" "github.com/xtls/xray-core/features/dns" - "gvisor.dev/gvisor/pkg/bufferv2" + "gvisor.dev/gvisor/pkg/buffer" "gvisor.dev/gvisor/pkg/tcpip" "gvisor.dev/gvisor/pkg/tcpip/adapters/gonet" "gvisor.dev/gvisor/pkg/tcpip/header" @@ -30,7 +30,7 @@ type netTun struct { ep *channel.Endpoint stack *stack.Stack events chan tun.Event - incomingPacket chan *bufferv2.View + incomingPacket chan *buffer.View mtu int dnsClient dns.Client hasV4, hasV6 bool @@ -48,7 +48,7 @@ func CreateNetTUN(localAddresses []netip.Addr, dnsClient dns.Client, mtu int) (t ep: channel.New(1024, uint32(mtu), ""), stack: stack.New(opts), events: make(chan tun.Event, 10), - incomingPacket: make(chan *bufferv2.View), + incomingPacket: make(chan *buffer.View), dnsClient: dnsClient, mtu: mtu, } @@ -66,7 +66,7 @@ func CreateNetTUN(localAddresses []netip.Addr, dnsClient dns.Client, mtu int) (t } protoAddr := tcpip.ProtocolAddress{ Protocol: protoNumber, - AddressWithPrefix: tcpip.Address(ip.AsSlice()).WithPrefix(), + AddressWithPrefix: tcpip.AddrFromSlice(ip.AsSlice()).WithPrefix(), } tcpipErr := dev.stack.AddProtocolAddress(1, protoAddr, stack.AddressProperties{}) if tcpipErr != nil { @@ -116,7 +116,7 @@ func (tun *netTun) Write(buf []byte, offset int) (int, error) { return 0, nil } - pkb := stack.NewPacketBuffer(stack.PacketBufferOptions{Payload: bufferv2.MakeWithData(packet)}) + pkb := stack.NewPacketBuffer(stack.PacketBufferOptions{Payload: buffer.MakeWithData(packet)}) switch packet[0] >> 4 { case 4: tun.ep.InjectInbound(header.IPv4ProtocolNumber, pkb) @@ -172,7 +172,7 @@ func convertToFullAddr(endpoint netip.AddrPort) (tcpip.FullAddress, tcpip.Networ } return tcpip.FullAddress{ NIC: 1, - Addr: tcpip.Address(endpoint.Addr().AsSlice()), + Addr: tcpip.AddrFromSlice(endpoint.Addr().AsSlice()), Port: endpoint.Port(), }, protoNumber } From 1a69baed170a05675185782d11d1e40085fdbfc7 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 26 Aug 2023 06:26:27 +0000 Subject: [PATCH 127/867] Update workflows to use Go 1.21 --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03c18811..8978bef5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -169,7 +169,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' check-latest: true - name: Get project dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 55891af0..d4143b69 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '1.20' + go-version: '1.21' check-latest: true - name: Checkout codebase uses: actions/checkout@v3 From e02474ae1590789a05a84e66d0765ee34f062231 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 26 Aug 2023 07:05:21 +0000 Subject: [PATCH 128/867] Upgrade dependencies --- go.mod | 26 +++++++++++++------------- go.sum | 53 ++++++++++++++++++++++++++++------------------------- 2 files changed, 41 insertions(+), 38 deletions(-) diff --git a/go.mod b/go.mod index 29567642..89ea54a1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/xtls/xray-core -go 1.20 +go 1.21 require ( github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 @@ -10,10 +10,10 @@ require ( github.com/miekg/dns v1.1.55 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.38.0 - github.com/refraction-networking/utls v1.3.3 - github.com/sagernet/sing v0.2.7 - github.com/sagernet/sing-shadowsocks v0.2.2 + github.com/quic-go/quic-go v0.38.1 + github.com/refraction-networking/utls v1.4.3 + github.com/sagernet/sing v0.2.9 + github.com/sagernet/sing-shadowsocks v0.2.4 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 @@ -35,24 +35,24 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect github.com/francoispqt/gojay v1.2.13 // indirect - github.com/gaukas/godicttls v0.0.3 // indirect + github.com/gaukas/godicttls v0.0.4 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 // indirect - github.com/klauspost/compress v1.16.6 // indirect + github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f // indirect + github.com/klauspost/compress v1.16.7 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect - github.com/onsi/ginkgo/v2 v2.11.0 // indirect + github.com/onsi/ginkgo/v2 v2.12.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/quic-go/qtls-go1-20 v0.3.2 // indirect + github.com/quic-go/qtls-go1-20 v0.3.3 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect go.uber.org/atomic v1.11.0 // indirect golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 // indirect - golang.org/x/mod v0.11.0 // indirect + golang.org/x/mod v0.12.0 // indirect golang.org/x/text v0.12.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.10.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect + golang.org/x/tools v0.12.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index e0eb4c79..4f11d8da 100644 --- a/go.sum +++ b/go.sum @@ -27,14 +27,15 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/gaukas/godicttls v0.0.3 h1:YNDIf0d9adcxOijiLrEzpfZGAkNwLRzPaG6OjU7EITk= -github.com/gaukas/godicttls v0.0.3/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI= +github.com/gaukas/godicttls v0.0.4 h1:NlRaXb3J6hAnTmWdsEKb9bcSBD6BvcIjdGdeb0zfXbk= +github.com/gaukas/godicttls v0.0.4/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3A65HN+7CMjSDP/gofXL4CZt1V4= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -60,8 +61,8 @@ github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+u github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 h1:hR7/MlvK23p6+lIw9SN1TigNLn9ZnF3W4SYRKq2gAHs= -github.com/google/pprof v0.0.0-20230602150820-91b7bce49751/go.mod h1:Jh3hGz2jkYak8qXPD19ryItVnUgpgeqzdkY/D0EaeuA= +github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f h1:pDhu5sgp8yJlEF/g6osliIIpF9K4F5jvkULXa4daRDQ= +github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -75,8 +76,8 @@ github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk= -github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= +github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -95,9 +96,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= -github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= -github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc= +github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI= +github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ= +github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= @@ -112,19 +114,19 @@ github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/quic-go/qtls-go1-20 v0.3.2 h1:rRgN3WfnKbyik4dBV8A6girlJVxGand/d+jVKbQq5GI= -github.com/quic-go/qtls-go1-20 v0.3.2/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.38.0 h1:T45lASr5q/TrVwt+jrVccmqHhPL2XuSyoCLVCpfOSLc= -github.com/quic-go/quic-go v0.38.0/go.mod h1:MPCuRq7KBK2hNcfKj/1iD1BGuN3eAYMeNxp3T42LRUg= -github.com/refraction-networking/utls v1.3.3 h1:f/TBLX7KBciRyFH3bwupp+CE4fzoYKCirhdRcC490sw= -github.com/refraction-networking/utls v1.3.3/go.mod h1:DlecWW1LMlMJu+9qpzzQqdHDT/C2LAe03EdpLUz/RL8= +github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM= +github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= +github.com/quic-go/quic-go v0.38.1 h1:M36YWA5dEhEeT+slOu/SwMEucbYd0YFidxG3KlGPZaE= +github.com/quic-go/quic-go v0.38.1/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= +github.com/refraction-networking/utls v1.4.3 h1:BdWS3BSzCwWCFfMIXP3mjLAyQkdmog7diaD/OqFbAzM= +github.com/refraction-networking/utls v1.4.3/go.mod h1:4u9V/awOSBrRw6+federGmVJQfPtemEqLBXkML1b0bo= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.7 h1:cOy0FfPS8q7m0aJ51wS7LRQAGc9wF+fWhHtBDj99wy8= -github.com/sagernet/sing v0.2.7/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= -github.com/sagernet/sing-shadowsocks v0.2.2 h1:ezSdVhrmIcwDXmCZF3bOJVMuVtTQWpda+1Op+Ie2TA4= -github.com/sagernet/sing-shadowsocks v0.2.2/go.mod h1:JIBWG6a7orB2HxBxYElViQFLUQxFVG7DuqIj8gD7uCQ= +github.com/sagernet/sing v0.2.9 h1:3wsTz+JG5Wzy65eZnh6AuCrD2QqcRF6Iq6f7ttmJsAo= +github.com/sagernet/sing v0.2.9/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= +github.com/sagernet/sing-shadowsocks v0.2.4 h1:s/CqXlvFAZhlIoHWUwPw5CoNnQ9Ibki9pckjuugtVfY= +github.com/sagernet/sing-shadowsocks v0.2.4/go.mod h1:80fNKP0wnqlu85GZXV1H1vDPC/2t+dQbFggOw4XuFUM= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c/go.mod h1:euOmN6O5kk9dQmgSS8Df4psAl3TCjxOz0NW60EWkSaI= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= @@ -185,8 +187,8 @@ golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTk golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= -golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -242,8 +244,8 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.10.0 h1:tvDr/iQoUqNdohiYm0LmmKcBk+q86lb9EprIUFhHHGg= -golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -260,8 +262,8 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= @@ -274,6 +276,7 @@ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 2d5475f42896347af4beea5f529dfe2cf41b2200 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 26 Aug 2023 07:45:24 +0000 Subject: [PATCH 129/867] Update transport/internet/reality/reality.go Fixes https://github.com/XTLS/Xray-core/issues/2491 --- transport/internet/reality/reality.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index e55f9417..b430cccc 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -5,6 +5,7 @@ import ( "context" "crypto/aes" "crypto/cipher" + "crypto/ecdh" "crypto/ed25519" "crypto/hmac" "crypto/rand" @@ -134,7 +135,8 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati if config.Show { fmt.Printf("REALITY localAddr: %v\thello.SessionId[:16]: %v\n", localAddr, hello.SessionId[:16]) } - uConn.AuthKey = uConn.HandshakeState.State13.EcdheParams.SharedKey(config.PublicKey) + publicKey, _ := ecdh.X25519().NewPublicKey(config.PublicKey) + uConn.AuthKey, _ = uConn.HandshakeState.State13.EcdheKey.ECDH(publicKey) if uConn.AuthKey == nil { return nil, errors.New("REALITY: SharedKey == nil") } From 10d6b065784efd3f33a02d6d5ad2a1fa162ff346 Mon Sep 17 00:00:00 2001 From: A1lo Date: Sat, 26 Aug 2023 16:23:54 +0800 Subject: [PATCH 130/867] fix(transport): correctly release UDS locker file (#2305) * fix(transport): correctly release UDS locker file * use callback function to do some jobs after create listener --- transport/internet/grpc/hub.go | 5 -- transport/internet/http/hub.go | 8 ---- transport/internet/system_listener.go | 69 +++++++++++++++++++-------- transport/internet/tcp/hub.go | 8 ---- transport/internet/websocket/hub.go | 8 ---- 5 files changed, 49 insertions(+), 49 deletions(-) diff --git a/transport/internet/grpc/hub.go b/transport/internet/grpc/hub.go index d3dd6da5..e55f6f77 100644 --- a/transport/internet/grpc/hub.go +++ b/transport/internet/grpc/hub.go @@ -23,7 +23,6 @@ type Listener struct { handler internet.ConnHandler local net.Addr config *Config - locker *internet.FileLocker // for unix domain socket s *grpc.Server } @@ -110,10 +109,6 @@ func Listen(ctx context.Context, address net.Address, port net.Port, settings *i newError("failed to listen on ", address).Base(err).AtError().WriteToLog(session.ExportIDToError(ctx)) return } - locker := ctx.Value(address.Domain()) - if locker != nil { - listener.locker = locker.(*internet.FileLocker) - } } else { // tcp streamListener, err = internet.ListenSystem(ctx, &net.TCPAddr{ IP: address.IP(), diff --git a/transport/internet/http/hub.go b/transport/internet/http/hub.go index 551f897e..f0260460 100644 --- a/transport/internet/http/hub.go +++ b/transport/internet/http/hub.go @@ -27,7 +27,6 @@ type Listener struct { handler internet.ConnHandler local net.Addr config *Config - locker *internet.FileLocker // for unix domain socket } func (l *Listener) Addr() net.Addr { @@ -35,9 +34,6 @@ func (l *Listener) Addr() net.Addr { } func (l *Listener) Close() error { - if l.locker != nil { - l.locker.Release() - } return l.server.Close() } @@ -180,10 +176,6 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti newError("failed to listen on ", address).Base(err).AtError().WriteToLog(session.ExportIDToError(ctx)) return } - locker := ctx.Value(address.Domain()) - if locker != nil { - listener.locker = locker.(*internet.FileLocker) - } } else { // tcp streamListener, err = internet.ListenSystem(ctx, &net.TCPAddr{ IP: address.IP(), diff --git a/transport/internet/system_listener.go b/transport/internet/system_listener.go index 60979062..1d635897 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -21,6 +21,19 @@ type DefaultListener struct { controllers []control.Func } +type combinedListener struct { + net.Listener + locker *FileLocker // for unix domain socket +} + +func (cl *combinedListener) Close() error { + if cl.locker != nil { + cl.locker.Release() + cl.locker = nil + } + return cl.Listener.Close() +} + func getControlFunc(ctx context.Context, sockopt *SocketConfig, controllers []control.Func) func(network, address string, c syscall.RawConn) error { return func(network, address string, c syscall.RawConn) error { return c.Control(func(fd uintptr) { @@ -44,6 +57,10 @@ func getControlFunc(ctx context.Context, sockopt *SocketConfig, controllers []co func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *SocketConfig) (l net.Listener, err error) { var lc net.ListenConfig var network, address string + // callback is called after the Listen function returns + callback := func(l net.Listener, err error) (net.Listener, error) { + return l, err + } switch addr := addr.(type) { case *net.TCPAddr: @@ -58,23 +75,6 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S network = addr.Network() address = addr.Name - if s := strings.Split(address, ","); len(s) == 2 { - address = s[0] - perm, perr := strconv.ParseUint(s[1], 8, 32) - if perr != nil { - return nil, newError("failed to parse permission: " + s[1]).Base(perr) - } - - defer func(file string, permission os.FileMode) { - if err == nil { - cerr := os.Chmod(address, permission) - if cerr != nil { - err = newError("failed to set permission for " + file).Base(cerr) - } - } - }(address, os.FileMode(perm)) - } - if (runtime.GOOS == "linux" || runtime.GOOS == "android") && address[0] == '@' { // linux abstract unix domain socket is lockfree if len(address) > 1 && address[1] == '@' { @@ -84,19 +84,48 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S address = string(fullAddr) } } else { + // split permission from address + var filePerm *os.FileMode + if s := strings.Split(address, ","); len(s) == 2 { + address = s[0] + perm, perr := strconv.ParseUint(s[1], 8, 32) + if perr != nil { + return nil, newError("failed to parse permission: " + s[1]).Base(perr) + } + + mode := os.FileMode(perm) + filePerm = &mode + } // normal unix domain socket needs lock locker := &FileLocker{ path: address + ".lock", } - err := locker.Acquire() - if err != nil { + if err := locker.Acquire(); err != nil { return nil, err } - ctx = context.WithValue(ctx, address, locker) + + // set callback to combine listener and set permission + callback = func(l net.Listener, err error) (net.Listener, error) { + if err != nil { + locker.Release() + return l, err + } + l = &combinedListener{Listener: l, locker: locker} + if filePerm == nil { + return l, nil + } + err = os.Chmod(address, *filePerm) + if err != nil { + l.Close() + return nil, newError("failed to set permission for " + address).Base(err) + } + return l, nil + } } } l, err = lc.Listen(ctx, network, address) + l, err = callback(l, err) if sockopt != nil && sockopt.AcceptProxyProtocol { policyFunc := func(upstream net.Addr) (proxyproto.Policy, error) { return proxyproto.REQUIRE, nil } l = &proxyproto.Listener{Listener: l, Policy: policyFunc} diff --git a/transport/internet/tcp/hub.go b/transport/internet/tcp/hub.go index 392228c6..d4b4f8b5 100644 --- a/transport/internet/tcp/hub.go +++ b/transport/internet/tcp/hub.go @@ -24,7 +24,6 @@ type Listener struct { authConfig internet.ConnectionAuthenticator config *Config addConn internet.ConnHandler - locker *internet.FileLocker // for unix domain socket } // ListenTCP creates a new Listener based on configurations. @@ -51,10 +50,6 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, streamSe return nil, newError("failed to listen Unix Domain Socket on ", address).Base(err) } newError("listening Unix Domain Socket on ", address).WriteToLog(session.ExportIDToError(ctx)) - locker := ctx.Value(address.Domain()) - if locker != nil { - l.locker = locker.(*internet.FileLocker) - } } else { listener, err = internet.ListenSystem(ctx, &net.TCPAddr{ IP: address.IP(), @@ -133,9 +128,6 @@ func (v *Listener) Addr() net.Addr { // Close implements internet.Listener.Close. func (v *Listener) Close() error { - if v.locker != nil { - v.locker.Release() - } return v.listener.Close() } diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index c0cf3446..7951b1f4 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -75,7 +75,6 @@ type Listener struct { listener net.Listener config *Config addConn internet.ConnHandler - locker *internet.FileLocker // for unix domain socket } func ListenWS(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (internet.Listener, error) { @@ -101,10 +100,6 @@ func ListenWS(ctx context.Context, address net.Address, port net.Port, streamSet return nil, newError("failed to listen unix domain socket(for WS) on ", address).Base(err) } newError("listening unix domain socket(for WS) on ", address).WriteToLog(session.ExportIDToError(ctx)) - locker := ctx.Value(address.Domain()) - if locker != nil { - l.locker = locker.(*internet.FileLocker) - } } else { // tcp listener, err = internet.ListenSystem(ctx, &net.TCPAddr{ IP: address.IP(), @@ -153,9 +148,6 @@ func (ln *Listener) Addr() net.Addr { // Close implements net.Listener.Close(). func (ln *Listener) Close() error { - if ln.locker != nil { - ln.locker.Release() - } return ln.listener.Close() } From b24a4028f148a7171f161a7e4b4d693aaaaea3da Mon Sep 17 00:00:00 2001 From: cty Date: Sat, 26 Aug 2023 17:11:37 +0200 Subject: [PATCH 131/867] fix(app/router): fixed a bug in geoip matching with refactoring (#2489) * Refactor the IP address matching with netipx library * Add a regression test for previous bug Fixes https://github.com/XTLS/Xray-core/issues/1933 --------- Co-authored-by: Loyalsoldier <10487845+Loyalsoldier@users.noreply.github.com> --- app/router/condition_geoip.go | 172 ++++++++--------------------- app/router/condition_geoip_test.go | 36 +++++- app/router/config.go | 39 ------- go.mod | 1 + go.sum | 2 + 5 files changed, 80 insertions(+), 170 deletions(-) diff --git a/app/router/condition_geoip.go b/app/router/condition_geoip.go index eb47be83..09c81fa8 100644 --- a/app/router/condition_geoip.go +++ b/app/router/condition_geoip.go @@ -1,81 +1,49 @@ package router import ( - "encoding/binary" - "sort" + "net/netip" + "strconv" "github.com/xtls/xray-core/common/net" + "go4.org/netipx" ) -type ipv6 struct { - a uint64 - b uint64 -} - type GeoIPMatcher struct { countryCode string reverseMatch bool - ip4 []uint32 - prefix4 []uint8 - ip6 []ipv6 - prefix6 []uint8 -} - -func normalize4(ip uint32, prefix uint8) uint32 { - return (ip >> (32 - prefix)) << (32 - prefix) -} - -func normalize6(ip ipv6, prefix uint8) ipv6 { - if prefix <= 64 { - ip.a = (ip.a >> (64 - prefix)) << (64 - prefix) - ip.b = 0 - } else { - ip.b = (ip.b >> (128 - prefix)) << (128 - prefix) - } - return ip + ip4 *netipx.IPSet + ip6 *netipx.IPSet } func (m *GeoIPMatcher) Init(cidrs []*CIDR) error { - ip4Count := 0 - ip6Count := 0 + var builder4, builder6 netipx.IPSetBuilder for _, cidr := range cidrs { - ip := cidr.Ip + ip := net.IP(cidr.GetIp()) + ipPrefixString := ip.String() + "/" + strconv.Itoa(int(cidr.GetPrefix())) + ipPrefix, err := netip.ParsePrefix(ipPrefixString) + if err != nil { + return err + } + switch len(ip) { - case 4: - ip4Count++ - case 16: - ip6Count++ - default: - return newError("unexpect ip length: ", len(ip)) + case net.IPv4len: + builder4.AddPrefix(ipPrefix) + case net.IPv6len: + builder6.AddPrefix(ipPrefix) } } - cidrList := CIDRList(cidrs) - sort.Sort(&cidrList) + if ip4, err := builder4.IPSet(); err != nil { + return err + } else { + m.ip4 = ip4 + } - m.ip4 = make([]uint32, 0, ip4Count) - m.prefix4 = make([]uint8, 0, ip4Count) - m.ip6 = make([]ipv6, 0, ip6Count) - m.prefix6 = make([]uint8, 0, ip6Count) - - for _, cidr := range cidrList { - ip := cidr.Ip - prefix := uint8(cidr.Prefix) - switch len(ip) { - case 4: - m.ip4 = append(m.ip4, normalize4(binary.BigEndian.Uint32(ip), prefix)) - m.prefix4 = append(m.prefix4, prefix) - case 16: - ip6 := ipv6{ - a: binary.BigEndian.Uint64(ip[0:8]), - b: binary.BigEndian.Uint64(ip[8:16]), - } - ip6 = normalize6(ip6, prefix) - - m.ip6 = append(m.ip6, ip6) - m.prefix6 = append(m.prefix6, prefix) - } + if ip6, err := builder6.IPSet(); err != nil { + return err + } else { + m.ip6 = ip6 } return nil @@ -85,91 +53,37 @@ func (m *GeoIPMatcher) SetReverseMatch(isReverseMatch bool) { m.reverseMatch = isReverseMatch } -func (m *GeoIPMatcher) match4(ip uint32) bool { - if len(m.ip4) == 0 { +func (m *GeoIPMatcher) match4(ip net.IP) bool { + nip, ok := netipx.FromStdIP(ip) + if !ok { return false } - if ip < m.ip4[0] { - return false - } - - size := uint32(len(m.ip4)) - l := uint32(0) - r := size - for l < r { - x := ((l + r) >> 1) - if ip < m.ip4[x] { - r = x - continue - } - - nip := normalize4(ip, m.prefix4[x]) - if nip == m.ip4[x] { - return true - } - - l = x + 1 - } - - return l > 0 && normalize4(ip, m.prefix4[l-1]) == m.ip4[l-1] + return m.ip4.Contains(nip) } -func less6(a ipv6, b ipv6) bool { - return a.a < b.a || (a.a == b.a && a.b < b.b) -} - -func (m *GeoIPMatcher) match6(ip ipv6) bool { - if len(m.ip6) == 0 { +func (m *GeoIPMatcher) match6(ip net.IP) bool { + nip, ok := netipx.FromStdIP(ip) + if !ok { return false } - if less6(ip, m.ip6[0]) { - return false - } - - size := uint32(len(m.ip6)) - l := uint32(0) - r := size - for l < r { - x := (l + r) / 2 - if less6(ip, m.ip6[x]) { - r = x - continue - } - - if normalize6(ip, m.prefix6[x]) == m.ip6[x] { - return true - } - - l = x + 1 - } - - return l > 0 && normalize6(ip, m.prefix6[l-1]) == m.ip6[l-1] + return m.ip6.Contains(nip) } // Match returns true if the given ip is included by the GeoIP. func (m *GeoIPMatcher) Match(ip net.IP) bool { + isMatched := false switch len(ip) { - case 4: - if m.reverseMatch { - return !m.match4(binary.BigEndian.Uint32(ip)) - } - return m.match4(binary.BigEndian.Uint32(ip)) - case 16: - if m.reverseMatch { - return !m.match6(ipv6{ - a: binary.BigEndian.Uint64(ip[0:8]), - b: binary.BigEndian.Uint64(ip[8:16]), - }) - } - return m.match6(ipv6{ - a: binary.BigEndian.Uint64(ip[0:8]), - b: binary.BigEndian.Uint64(ip[8:16]), - }) - default: - return false + case net.IPv4len: + isMatched = m.match4(ip) + case net.IPv6len: + isMatched = m.match6(ip) } + if m.reverseMatch { + return !isMatched + } + return isMatched } // GeoIPMatcherContainer is a container for GeoIPMatchers. It keeps unique copies of GeoIPMatcher by country code. diff --git a/app/router/condition_geoip_test.go b/app/router/condition_geoip_test.go index 1a730021..63bd222e 100644 --- a/app/router/condition_geoip_test.go +++ b/app/router/condition_geoip_test.go @@ -53,7 +53,7 @@ func TestGeoIPMatcherContainer(t *testing.T) { } func TestGeoIPMatcher(t *testing.T) { - cidrList := router.CIDRList{ + cidrList := []*router.CIDR{ {Ip: []byte{0, 0, 0, 0}, Prefix: 8}, {Ip: []byte{10, 0, 0, 0}, Prefix: 8}, {Ip: []byte{100, 64, 0, 0}, Prefix: 10}, @@ -124,8 +124,40 @@ func TestGeoIPMatcher(t *testing.T) { } } +func TestGeoIPMatcherRegression(t *testing.T) { + cidrList := []*router.CIDR{ + {Ip: []byte{98, 108, 20, 0}, Prefix: 22}, + {Ip: []byte{98, 108, 20, 0}, Prefix: 23}, + } + + matcher := &router.GeoIPMatcher{} + common.Must(matcher.Init(cidrList)) + + testCases := []struct { + Input string + Output bool + }{ + { + Input: "98.108.22.11", + Output: true, + }, + { + Input: "98.108.25.0", + Output: false, + }, + } + + for _, testCase := range testCases { + ip := net.ParseAddress(testCase.Input).IP() + actual := matcher.Match(ip) + if actual != testCase.Output { + t.Error("expect input", testCase.Input, "to be", testCase.Output, ", but actually", actual) + } + } +} + func TestGeoIPReverseMatcher(t *testing.T) { - cidrList := router.CIDRList{ + cidrList := []*router.CIDR{ {Ip: []byte{8, 8, 8, 8}, Prefix: 32}, {Ip: []byte{91, 108, 4, 0}, Prefix: 16}, } diff --git a/app/router/config.go b/app/router/config.go index 80b88781..f50f02a1 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -9,45 +9,6 @@ import ( "github.com/xtls/xray-core/features/routing" ) -// CIDRList is an alias of []*CIDR to provide sort.Interface. -type CIDRList []*CIDR - -// Len implements sort.Interface. -func (l *CIDRList) Len() int { - return len(*l) -} - -// Less implements sort.Interface. -func (l *CIDRList) Less(i int, j int) bool { - ci := (*l)[i] - cj := (*l)[j] - - if len(ci.Ip) < len(cj.Ip) { - return true - } - - if len(ci.Ip) > len(cj.Ip) { - return false - } - - for k := 0; k < len(ci.Ip); k++ { - if ci.Ip[k] < cj.Ip[k] { - return true - } - - if ci.Ip[k] > cj.Ip[k] { - return false - } - } - - return ci.Prefix < cj.Prefix -} - -// Swap implements sort.Interface. -func (l *CIDRList) Swap(i int, j int) { - (*l)[i], (*l)[j] = (*l)[j], (*l)[i] -} - type Rule struct { Tag string Balancer *Balancer diff --git a/go.mod b/go.mod index 89ea54a1..579e77da 100644 --- a/go.mod +++ b/go.mod @@ -47,6 +47,7 @@ require ( github.com/quic-go/qtls-go1-20 v0.3.3 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect go.uber.org/atomic v1.11.0 // indirect + go4.org/netipx v0.0.0-20230824141953-6213f710f925 // indirect golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/text v0.12.0 // indirect diff --git a/go.sum b/go.sum index 4f11d8da..da6346cf 100644 --- a/go.sum +++ b/go.sum @@ -173,6 +173,8 @@ go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= +go4.org/netipx v0.0.0-20230824141953-6213f710f925 h1:eeQDDVKFkx0g4Hyy8pHgmZaK0EqB4SD6rvKbUdN3ziQ= +go4.org/netipx v0.0.0-20230824141953-6213f710f925/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= From d92002ad127f64bc1e740cb350eafd693ffadd6d Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 27 Aug 2023 05:55:58 +0000 Subject: [PATCH 132/867] Dialer: Set TimeoutOnly for `gctx` and `hctx` https://github.com/XTLS/Xray-core/issues/2232#issuecomment-1694570914 Thank @cty123 for testing Fixes https://github.com/XTLS/Xray-core/issues/2232 BTW: Use `uConn.HandshakeContext(ctx)` in REALITY --- transport/internet/grpc/dial.go | 12 +++++++----- transport/internet/http/dialer.go | 12 ++++++------ transport/internet/reality/reality.go | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/transport/internet/grpc/dial.go b/transport/internet/grpc/dial.go index 8fd544b5..16af63cd 100644 --- a/transport/internet/grpc/dial.go +++ b/transport/internet/grpc/dial.go @@ -98,16 +98,13 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in MinConnectTimeout: 5 * time.Second, }), grpc.WithContextDialer(func(gctx context.Context, s string) (gonet.Conn, error) { - gctx = session.ContextWithID(gctx, session.IDFromContext(ctx)) - gctx = session.ContextWithOutbound(gctx, session.OutboundFromContext(ctx)) - - rawHost, rawPort, err := net.SplitHostPort(s) select { case <-gctx.Done(): return nil, gctx.Err() default: } + rawHost, rawPort, err := net.SplitHostPort(s) if err != nil { return nil, err } @@ -119,9 +116,14 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in return nil, err } address := net.ParseAddress(rawHost) + + gctx = session.ContextWithID(gctx, session.IDFromContext(ctx)) + gctx = session.ContextWithOutbound(gctx, session.OutboundFromContext(ctx)) + gctx = session.ContextWithTimeoutOnly(gctx, true) + c, err := internet.DialSystem(gctx, net.TCPDestination(address, port), sockopt) if err == nil && realityConfig != nil { - return reality.UClient(c, realityConfig, ctx, dest) + return reality.UClient(c, realityConfig, gctx, dest) } return c, err }), diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index f2e55de8..1ea3a738 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -53,7 +53,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in } transport := &http2.Transport{ - DialTLS: func(network string, addr string, tlsConfig *gotls.Config) (net.Conn, error) { + DialTLSContext: func(hctx context.Context, string, addr string, tlsConfig *gotls.Config) (net.Conn, error) { rawHost, rawPort, err := net.SplitHostPort(addr) if err != nil { return nil, err @@ -67,18 +67,18 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in } address := net.ParseAddress(rawHost) - dctx := context.Background() - dctx = session.ContextWithID(dctx, session.IDFromContext(ctx)) - dctx = session.ContextWithOutbound(dctx, session.OutboundFromContext(ctx)) + hctx = session.ContextWithID(hctx, session.IDFromContext(ctx)) + hctx = session.ContextWithOutbound(hctx, session.OutboundFromContext(ctx)) + hctx = session.ContextWithTimeoutOnly(hctx, true) - pconn, err := internet.DialSystem(dctx, net.TCPDestination(address, port), sockopt) + pconn, err := internet.DialSystem(hctx, net.TCPDestination(address, port), sockopt) if err != nil { newError("failed to dial to " + addr).Base(err).AtError().WriteToLog() return nil, err } if realityConfigs != nil { - return reality.UClient(pconn, realityConfigs, ctx, dest) + return reality.UClient(pconn, realityConfigs, hctx, dest) } var cn tls.Interface diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index b430cccc..30d4e2ae 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -156,7 +156,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati aead.Seal(hello.SessionId[:0], hello.Random[20:], hello.SessionId[:16], hello.Raw) copy(hello.Raw[39:], hello.SessionId) } - if err := uConn.Handshake(); err != nil { + if err := uConn.HandshakeContext(ctx); err != nil { return nil, err } if config.Show { From e013dce1df4bf341b2cb9c9fdef56c4ba3cbd44a Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 28 Aug 2023 17:37:57 +0000 Subject: [PATCH 133/867] Upgrade github.com/xtls/reality to 20230828171259 https://github.com/XTLS/REALITY/commit/e426190d57f6443930a8f9cf3acfbb1a40b1576e --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 579e77da..711b8e47 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,8 @@ require ( github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e - github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983 + github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 + go4.org/netipx v0.0.0-20230824141953-6213f710f925 golang.org/x/crypto v0.12.0 golang.org/x/net v0.14.0 golang.org/x/sync v0.3.0 @@ -47,7 +48,6 @@ require ( github.com/quic-go/qtls-go1-20 v0.3.3 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect go.uber.org/atomic v1.11.0 // indirect - go4.org/netipx v0.0.0-20230824141953-6213f710f925 // indirect golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/text v0.12.0 // indirect diff --git a/go.sum b/go.sum index da6346cf..71abf747 100644 --- a/go.sum +++ b/go.sum @@ -166,8 +166,8 @@ github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983 h1:AMyzgjkh54WocjQSlCnT1LhDc/BKiUqtNOv40AkpURs= -github.com/xtls/reality v0.0.0-20230613075828-e07c3b04b983/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= +github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 h1:T+YCYGfFdzyaKTDCdZn/hEiKvsw6yUfd+e4hze0rCUw= +github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= From b8bd243df5f6ff4929681c82ed945b27f1597d25 Mon Sep 17 00:00:00 2001 From: dyhkwong <50692134+dyhkwong@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:12:36 +0800 Subject: [PATCH 134/867] Fix buffer.UDP destination override (#2356) --- app/dispatcher/default.go | 107 ++++++++----------------------- app/proxyman/outbound/handler.go | 7 +- common/buf/override.go | 38 +++++++++++ common/session/session.go | 5 +- transport/pipe/impl.go | 5 -- transport/pipe/pipe.go | 7 -- 6 files changed, 75 insertions(+), 94 deletions(-) create mode 100644 common/buf/override.go diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 35307cef..5a71ad41 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -4,7 +4,6 @@ package dispatcher import ( "context" - "fmt" "strings" "sync" "time" @@ -135,77 +134,10 @@ func (*DefaultDispatcher) Start() error { // Close implements common.Closable. func (*DefaultDispatcher) Close() error { return nil } -func (d *DefaultDispatcher) getLink(ctx context.Context, network net.Network, sniffing session.SniffingRequest) (*transport.Link, *transport.Link) { - downOpt := pipe.OptionsFromContext(ctx) - upOpt := downOpt - - if network == net.Network_UDP { - var ip2domain *sync.Map // net.IP.String() => domain, this map is used by server side when client turn on fakedns - // Client will send domain address in the buffer.UDP.Address, server record all possible target IP addrs. - // When target replies, server will restore the domain and send back to client. - // Note: this map is not global but per connection context - upOpt = append(upOpt, pipe.OnTransmission(func(mb buf.MultiBuffer) buf.MultiBuffer { - for i, buffer := range mb { - if buffer.UDP == nil { - continue - } - addr := buffer.UDP.Address - if addr.Family().IsIP() { - if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && fkr0.IsIPInIPPool(addr) && sniffing.Enabled { - domain := fkr0.GetDomainFromFakeDNS(addr) - if len(domain) > 0 { - buffer.UDP.Address = net.DomainAddress(domain) - newError("[fakedns client] override with domain: ", domain, " for xUDP buffer at ", i).WriteToLog(session.ExportIDToError(ctx)) - } else { - newError("[fakedns client] failed to find domain! :", addr.String(), " for xUDP buffer at ", i).AtWarning().WriteToLog(session.ExportIDToError(ctx)) - } - } - } else { - if ip2domain == nil { - ip2domain = new(sync.Map) - newError("[fakedns client] create a new map").WriteToLog(session.ExportIDToError(ctx)) - } - domain := addr.Domain() - ips, err := d.dns.LookupIP(domain, dns.IPOption{true, true, false}) - if err == nil { - 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)) - } else { - newError("[fakedns client] failed to look up IP for ", domain, " for xUDP buffer at ", i).Base(err).WriteToLog(session.ExportIDToError(ctx)) - } - } - } - return mb - })) - downOpt = append(downOpt, pipe.OnTransmission(func(mb buf.MultiBuffer) buf.MultiBuffer { - for i, buffer := range mb { - if buffer.UDP == nil { - continue - } - addr := buffer.UDP.Address - if addr.Family().IsIP() { - if ip2domain == nil { - continue - } - if domain, found := ip2domain.Load(addr.IP().String()); found { - buffer.UDP.Address = net.DomainAddress(domain.(string)) - newError("[fakedns client] restore domain: ", domain.(string), " for xUDP buffer at ", i).WriteToLog(session.ExportIDToError(ctx)) - } - } else { - if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok { - fakeIp := fkr0.GetFakeIPForDomain(addr.Domain()) - buffer.UDP.Address = fakeIp[0] - newError("[fakedns client] restore FakeIP: ", buffer.UDP, fmt.Sprintf("%v", fakeIp), " for xUDP buffer at ", i).WriteToLog(session.ExportIDToError(ctx)) - } - } - } - return mb - })) - } - uplinkReader, uplinkWriter := pipe.New(upOpt...) - downlinkReader, downlinkWriter := pipe.New(downOpt...) +func (d *DefaultDispatcher) getLink(ctx context.Context) (*transport.Link, *transport.Link) { + opt := pipe.OptionsFromContext(ctx) + uplinkReader, uplinkWriter := pipe.New(opt...) + downlinkReader, downlinkWriter := pipe.New(opt...) inboundLink := &transport.Link{ Reader: downlinkReader, @@ -263,7 +195,7 @@ func (d *DefaultDispatcher) shouldOverride(ctx context.Context, result SniffResu protocolString = resComp.ProtocolForDomainResult() } for _, p := range request.OverrideDestinationForProtocol { - if strings.HasPrefix(protocolString, p) { + if strings.HasPrefix(protocolString, p) || strings.HasPrefix(protocolString, p) { return true } if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && protocolString != "bittorrent" && p == "fakedns" && @@ -287,7 +219,8 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin panic("Dispatcher: Invalid destination.") } ob := &session.Outbound{ - Target: destination, + OriginalTarget: destination, + Target: destination, } ctx = session.ContextWithOutbound(ctx, ob) content := session.ContentFromContext(ctx) @@ -295,9 +228,8 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin content = new(session.Content) ctx = session.ContextWithContent(ctx, content) } - sniffingRequest := content.SniffingRequest - inbound, outbound := d.getLink(ctx, destination.Network, sniffingRequest) + inbound, outbound := d.getLink(ctx) if !sniffingRequest.Enabled { go d.routedDispatch(ctx, outbound, destination) } else { @@ -314,7 +246,15 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin domain := result.Domain() newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx)) destination.Address = net.ParseAddress(domain) - if sniffingRequest.RouteOnly && result.Protocol() != "fakedns" { + protocol := result.Protocol() + if resComp, ok := result.(SnifferResultComposite); ok { + protocol = resComp.ProtocolForDomainResult() + } + isFakeIP := false + if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && ob.Target.Address.Family().IsIP() && fkr0.IsIPInIPPool(ob.Target.Address) { + isFakeIP = true + } + if sniffingRequest.RouteOnly && protocol != "fakedns" && protocol != "fakedns+others" && !isFakeIP { ob.RouteTarget = destination } else { ob.Target = destination @@ -332,7 +272,8 @@ func (d *DefaultDispatcher) DispatchLink(ctx context.Context, destination net.De return newError("Dispatcher: Invalid destination.") } ob := &session.Outbound{ - Target: destination, + OriginalTarget: destination, + Target: destination, } ctx = session.ContextWithOutbound(ctx, ob) content := session.ContentFromContext(ctx) @@ -356,7 +297,15 @@ func (d *DefaultDispatcher) DispatchLink(ctx context.Context, destination net.De domain := result.Domain() newError("sniffed domain: ", domain).WriteToLog(session.ExportIDToError(ctx)) destination.Address = net.ParseAddress(domain) - if sniffingRequest.RouteOnly && result.Protocol() != "fakedns" { + protocol := result.Protocol() + if resComp, ok := result.(SnifferResultComposite); ok { + protocol = resComp.ProtocolForDomainResult() + } + isFakeIP := false + if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && ob.Target.Address.Family().IsIP() && fkr0.IsIPInIPPool(ob.Target.Address) { + isFakeIP = true + } + if sniffingRequest.RouteOnly && protocol != "fakedns" && protocol != "fakedns+others" && !isFakeIP { ob.RouteTarget = destination } else { ob.Target = destination diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index b477dd6b..adf6537a 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -8,6 +8,7 @@ import ( "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/mux" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net/cnc" @@ -166,6 +167,11 @@ func (h *Handler) Tag() string { // Dispatch implements proxy.Outbound.Dispatch. func (h *Handler) Dispatch(ctx context.Context, link *transport.Link) { + outbound := session.OutboundFromContext(ctx) + if outbound.Target.Network == net.Network_UDP && outbound.OriginalTarget.Address != nil && outbound.OriginalTarget.Address != outbound.Target.Address { + link.Reader = &buf.EndpointOverrideReader{Reader: link.Reader, Dest: outbound.Target.Address, OriginalDest: outbound.OriginalTarget.Address} + link.Writer = &buf.EndpointOverrideWriter{Writer: link.Writer, Dest: outbound.Target.Address, OriginalDest: outbound.OriginalTarget.Address} + } if h.mux != nil { test := func(err error) { if err != nil { @@ -175,7 +181,6 @@ func (h *Handler) Dispatch(ctx context.Context, link *transport.Link) { common.Interrupt(link.Writer) } } - outbound := session.OutboundFromContext(ctx) if outbound.Target.Network == net.Network_UDP && outbound.Target.Port == 443 { switch h.udp443 { case "reject": diff --git a/common/buf/override.go b/common/buf/override.go new file mode 100644 index 00000000..7b2f1554 --- /dev/null +++ b/common/buf/override.go @@ -0,0 +1,38 @@ +package buf + +import ( + "github.com/xtls/xray-core/common/net" +) + +type EndpointOverrideReader struct { + Reader + Dest net.Address + OriginalDest net.Address +} + +func (r *EndpointOverrideReader) ReadMultiBuffer() (MultiBuffer, error) { + mb, err := r.Reader.ReadMultiBuffer() + if err == nil { + for _, b := range mb { + if b.UDP != nil && b.UDP.Address == r.OriginalDest { + b.UDP.Address = r.Dest + } + } + } + return mb, err +} + +type EndpointOverrideWriter struct { + Writer + Dest net.Address + OriginalDest net.Address +} + +func (w *EndpointOverrideWriter) WriteMultiBuffer(mb MultiBuffer) error { + for _, b := range mb { + if b.UDP != nil && b.UDP.Address == w.Dest { + b.UDP.Address = w.OriginalDest + } + } + return w.Writer.WriteMultiBuffer(mb) +} diff --git a/common/session/session.go b/common/session/session.go index 83c48fde..b9609e86 100644 --- a/common/session/session.go +++ b/common/session/session.go @@ -55,8 +55,9 @@ type Inbound struct { // Outbound is the metadata of an outbound connection. type Outbound struct { // Target address of the outbound connection. - Target net.Destination - RouteTarget net.Destination + OriginalTarget net.Destination + Target net.Destination + RouteTarget net.Destination // Gateway address Gateway net.Address } diff --git a/transport/pipe/impl.go b/transport/pipe/impl.go index a60bc485..dbdb050e 100644 --- a/transport/pipe/impl.go +++ b/transport/pipe/impl.go @@ -24,7 +24,6 @@ const ( type pipeOption struct { limit int32 // maximum buffer size in bytes discardOverflow bool - onTransmission func(buffer buf.MultiBuffer) buf.MultiBuffer } func (o *pipeOption) isFull(curSize int32) bool { @@ -141,10 +140,6 @@ func (p *pipe) WriteMultiBuffer(mb buf.MultiBuffer) error { return nil } - if p.option.onTransmission != nil { - mb = p.option.onTransmission(mb) - } - for { err := p.writeMultiBufferInternal(mb) if err == nil { diff --git a/transport/pipe/pipe.go b/transport/pipe/pipe.go index 735cc091..f4b78303 100644 --- a/transport/pipe/pipe.go +++ b/transport/pipe/pipe.go @@ -3,7 +3,6 @@ package pipe import ( "context" - "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/common/signal/done" "github.com/xtls/xray-core/features/policy" @@ -26,12 +25,6 @@ func WithSizeLimit(limit int32) Option { } } -func OnTransmission(hook func(mb buf.MultiBuffer) buf.MultiBuffer) Option { - return func(option *pipeOption) { - option.onTransmission = hook - } -} - // DiscardOverflow returns an Option for Pipe to discard writes if full. func DiscardOverflow() Option { return func(opt *pipeOption) { From f7c20b85dcbd6c2e8acf2589dfaef8a448daf337 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 29 Aug 2023 07:20:10 +0000 Subject: [PATCH 135/867] v1.8.4 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 4d704306..e1128775 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 3 + Version_z byte = 4 ) var ( From 7264750e28be632773117d76e445af7d47398475 Mon Sep 17 00:00:00 2001 From: dyhkwong <50692134+dyhkwong@users.noreply.github.com> Date: Thu, 31 Aug 2023 19:21:35 +0800 Subject: [PATCH 136/867] fix typo in default.go --- app/dispatcher/default.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 5a71ad41..aaa9b410 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -195,7 +195,7 @@ func (d *DefaultDispatcher) shouldOverride(ctx context.Context, result SniffResu protocolString = resComp.ProtocolForDomainResult() } for _, p := range request.OverrideDestinationForProtocol { - if strings.HasPrefix(protocolString, p) || strings.HasPrefix(protocolString, p) { + if strings.HasPrefix(protocolString, p) || strings.HasPrefix(p, protocolString) { return true } if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && protocolString != "bittorrent" && p == "fakedns" && From 853a866622e6e8f63d3db4b29d7da1dbf5bb3207 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 00:43:27 +0000 Subject: [PATCH 137/867] Bump actions/checkout from 3 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6c51d0b5..b7a3292b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -11,7 +11,7 @@ jobs: permissions: packages: write steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Docker metadata id: meta uses: docker/metadata-action@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8978bef5..30b96142 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -158,7 +158,7 @@ jobs: CGO_ENABLED: 0 steps: - name: Checkout codebase - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Show workflow information run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d4143b69..0ab32cd4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: go-version: '1.21' check-latest: true - name: Checkout codebase - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Restore Cache uses: actions/cache/restore@v3 with: From c00e56c0dadf4ec69e0b76a858658cae9709430b Mon Sep 17 00:00:00 2001 From: yylt <34183906+yylt@users.noreply.github.com> Date: Fri, 8 Sep 2023 01:32:27 +0800 Subject: [PATCH 138/867] Add `tcpMptcp` to `sockopt` (#2520) --- infra/conf/transport_internet.go | 2 + transport/internet/config.pb.go | 58 ++++++++++++++++----------- transport/internet/config.proto | 2 + transport/internet/system_dialer.go | 3 ++ transport/internet/system_listener.go | 9 ++++- 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 55cc8c2e..9e10feed 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -622,6 +622,7 @@ type SocketConfig struct { TCPUserTimeout int32 `json:"tcpUserTimeout"` V6only bool `json:"v6only"` Interface string `json:"interface"` + TcpMptcp bool `json:"tcpMptcp"` } // Build implements Buildable. @@ -677,6 +678,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { TcpUserTimeout: c.TCPUserTimeout, V6Only: c.V6only, Interface: c.Interface, + TcpMptcp: c.TcpMptcp, }, nil } diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index a186199f..33519b63 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 -// protoc v4.23.1 +// protoc-gen-go v1.31.0 +// protoc v4.24.1 // source: transport/internet/config.proto package internet @@ -431,6 +431,7 @@ type SocketConfig struct { TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` TcpMaxSeg int32 `protobuf:"varint,17,opt,name=tcp_max_seg,json=tcpMaxSeg,proto3" json:"tcp_max_seg,omitempty"` TcpNoDelay bool `protobuf:"varint,18,opt,name=tcp_no_delay,json=tcpNoDelay,proto3" json:"tcp_no_delay,omitempty"` + TcpMptcp bool `protobuf:"varint,19,opt,name=tcp_mptcp,json=tcpMptcp,proto3" json:"tcp_mptcp,omitempty"` } func (x *SocketConfig) Reset() { @@ -591,6 +592,13 @@ func (x *SocketConfig) GetTcpNoDelay() bool { return false } +func (x *SocketConfig) GetTcpMptcp() bool { + if x != nil { + return x.TcpMptcp + } + return false +} + var File_transport_internet_config_proto protoreflect.FileDescriptor var file_transport_internet_config_proto_rawDesc = []byte{ @@ -643,7 +651,7 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x12, 0x30, 0x0a, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, - 0x78, 0x79, 0x22, 0xb4, 0x06, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, + 0x78, 0x79, 0x22, 0xd1, 0x06, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, @@ -691,27 +699,29 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x78, 0x5f, 0x73, 0x65, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x63, 0x70, 0x4d, 0x61, 0x78, 0x53, 0x65, 0x67, 0x12, 0x20, 0x0a, 0x0c, 0x74, 0x63, 0x70, 0x5f, 0x6e, 0x6f, 0x5f, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x74, 0x63, - 0x70, 0x4e, 0x6f, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, - 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, - 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, - 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x5a, 0x0a, 0x11, 0x54, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x07, - 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x01, - 0x12, 0x08, 0x0a, 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, - 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, - 0x50, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, - 0x6b, 0x65, 0x74, 0x10, 0x05, 0x2a, 0x41, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, - 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, - 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, - 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, - 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x4e, 0x6f, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x63, 0x70, 0x5f, + 0x6d, 0x70, 0x74, 0x63, 0x70, 0x18, 0x13, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74, 0x63, 0x70, + 0x4d, 0x70, 0x74, 0x63, 0x70, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, + 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, + 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, + 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x5a, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x07, 0x0a, 0x03, 0x54, + 0x43, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x01, 0x12, 0x08, 0x0a, + 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, 0x62, 0x53, 0x6f, + 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x04, + 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, + 0x10, 0x05, 0x2a, 0x41, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, + 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, + 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, + 0x49, 0x50, 0x36, 0x10, 0x03, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, + 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/config.proto b/transport/internet/config.proto index 7fdc8ca2..550d00ec 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -110,4 +110,6 @@ message SocketConfig { int32 tcp_max_seg = 17; bool tcp_no_delay = 18; + + bool tcp_mptcp = 19; } diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index 5a68144d..5304595f 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -81,6 +81,9 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne } if sockopt != nil || len(d.controllers) > 0 { + if sockopt != nil && sockopt.TcpMptcp { + dialer.SetMultipathTCP(true) + } dialer.Control = func(network, address string, c syscall.RawConn) error { for _, ctl := range d.controllers { if err := ctl(network, address, c); err != nil { diff --git a/transport/internet/system_listener.go b/transport/internet/system_listener.go index 1d635897..6593f4bc 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -67,8 +67,13 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S network = addr.Network() address = addr.String() lc.Control = getControlFunc(ctx, sockopt, dl.controllers) - if sockopt != nil && (sockopt.TcpKeepAliveInterval != 0 || sockopt.TcpKeepAliveIdle != 0) { - lc.KeepAlive = time.Duration(-1) + if sockopt != nil { + if sockopt.TcpKeepAliveInterval != 0 || sockopt.TcpKeepAliveIdle != 0 { + lc.KeepAlive = time.Duration(-1) + } + if sockopt.TcpMptcp { + lc.SetMultipathTCP(true) + } } case *net.UnixAddr: lc.Control = nil From ae2fa30e01fceb2d4565ca1320d00e2515399f05 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 18 Jun 2023 09:12:11 -0400 Subject: [PATCH 139/867] Add Vless tests --- testing/scenarios/vless_test.go | 518 ++++++++++++++++++++++++++++++++ 1 file changed, 518 insertions(+) create mode 100644 testing/scenarios/vless_test.go diff --git a/testing/scenarios/vless_test.go b/testing/scenarios/vless_test.go new file mode 100644 index 00000000..84d82643 --- /dev/null +++ b/testing/scenarios/vless_test.go @@ -0,0 +1,518 @@ +package scenarios + +import ( + // "encoding/base64" + // "encoding/hex" + "testing" + "time" + + "github.com/xtls/xray-core/app/log" + "github.com/xtls/xray-core/app/proxyman" + "github.com/xtls/xray-core/common" + clog "github.com/xtls/xray-core/common/log" + "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/protocol" + "github.com/xtls/xray-core/common/protocol/tls/cert" + "github.com/xtls/xray-core/common/serial" + "github.com/xtls/xray-core/common/uuid" + core "github.com/xtls/xray-core/core" + "github.com/xtls/xray-core/proxy/dokodemo" + "github.com/xtls/xray-core/proxy/freedom" + "github.com/xtls/xray-core/proxy/vless" + "github.com/xtls/xray-core/proxy/vless/inbound" + "github.com/xtls/xray-core/proxy/vless/outbound" + "github.com/xtls/xray-core/testing/servers/tcp" + "github.com/xtls/xray-core/transport/internet" + // "github.com/xtls/xray-core/transport/internet/reality" + transtcp "github.com/xtls/xray-core/transport/internet/tcp" + "github.com/xtls/xray-core/transport/internet/tls" + "golang.org/x/sync/errgroup" +) + +func TestVless(t *testing.T) { + tcpServer := tcp.Server{ + MsgProcessor: xor, + } + dest, err := tcpServer.Start() + common.Must(err) + defer tcpServer.Close() + + userID := protocol.NewID(uuid.New()) + serverPort := tcp.PickPort() + serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: clog.Severity_Debug, + ErrorLogType: log.LogType_Console, + }), + }, + Inbound: []*core.InboundHandlerConfig{ + { + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + }), + ProxySettings: serial.ToTypedMessage(&inbound.Config{ + Clients: []*protocol.User{ + { + Account: serial.ToTypedMessage(&vless.Account{ + Id: userID.String(), + }), + }, + }, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + ProxySettings: serial.ToTypedMessage(&freedom.Config{}), + }, + }, + } + + clientPort := tcp.PickPort() + clientConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: clog.Severity_Debug, + ErrorLogType: log.LogType_Console, + }), + }, + Inbound: []*core.InboundHandlerConfig{ + { + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + }), + ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), + NetworkList: &net.NetworkList{ + Network: []net.Network{net.Network_TCP}, + }, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + ProxySettings: serial.ToTypedMessage(&outbound.Config{ + Vnext: []*protocol.ServerEndpoint{ + { + Address: net.NewIPOrDomain(net.LocalHostIP), + Port: uint32(serverPort), + User: []*protocol.User{ + { + Account: serial.ToTypedMessage(&vless.Account{ + Id: userID.String(), + }), + }, + }, + }, + }, + }), + }, + }, + } + + servers, err := InitializeServerConfigs(serverConfig, clientConfig) + common.Must(err) + defer CloseAllServers(servers) + + var errg errgroup.Group + for i := 0; i < 10; i++ { + errg.Go(testTCPConn(clientPort, 1024*1024, time.Second*30)) + } + if err := errg.Wait(); err != nil { + t.Error(err) + } +} + +func TestVlessTls(t *testing.T) { + tcpServer := tcp.Server{ + MsgProcessor: xor, + } + dest, err := tcpServer.Start() + common.Must(err) + defer tcpServer.Close() + + userID := protocol.NewID(uuid.New()) + serverPort := tcp.PickPort() + serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: clog.Severity_Debug, + ErrorLogType: log.LogType_Console, + }), + }, + Inbound: []*core.InboundHandlerConfig{ + { + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + StreamSettings: &internet.StreamConfig{ + Protocol: internet.TransportProtocol_TCP, + SecurityType: serial.GetMessageType(&tls.Config{}), + SecuritySettings: []*serial.TypedMessage{ + serial.ToTypedMessage(&tls.Config{ + Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil))}, + }), + }, + }, + }), + ProxySettings: serial.ToTypedMessage(&inbound.Config{ + Clients: []*protocol.User{ + { + Account: serial.ToTypedMessage(&vless.Account{ + Id: userID.String(), + }), + }, + }, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + ProxySettings: serial.ToTypedMessage(&freedom.Config{}), + }, + }, + } + + clientPort := tcp.PickPort() + clientConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: clog.Severity_Debug, + ErrorLogType: log.LogType_Console, + }), + }, + Inbound: []*core.InboundHandlerConfig{ + { + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + }), + ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), + NetworkList: &net.NetworkList{ + Network: []net.Network{net.Network_TCP}, + }, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + ProxySettings: serial.ToTypedMessage(&outbound.Config{ + Vnext: []*protocol.ServerEndpoint{ + { + Address: net.NewIPOrDomain(net.LocalHostIP), + Port: uint32(serverPort), + User: []*protocol.User{ + { + Account: serial.ToTypedMessage(&vless.Account{ + Id: userID.String(), + }), + }, + }, + }, + }, + }), + SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ + StreamSettings: &internet.StreamConfig{ + Protocol: internet.TransportProtocol_TCP, + TransportSettings: []*internet.TransportConfig{ + { + Protocol: internet.TransportProtocol_TCP, + Settings: serial.ToTypedMessage(&transtcp.Config{}), + }, + }, + SecurityType: serial.GetMessageType(&tls.Config{}), + SecuritySettings: []*serial.TypedMessage{ + serial.ToTypedMessage(&tls.Config{ + AllowInsecure: true, + }), + }, + }, + }), + }, + }, + } + + servers, err := InitializeServerConfigs(serverConfig, clientConfig) + common.Must(err) + defer CloseAllServers(servers) + + var errg errgroup.Group + for i := 0; i < 10; i++ { + errg.Go(testTCPConn(clientPort, 1024*1024, time.Second*30)) + } + if err := errg.Wait(); err != nil { + t.Error(err) + } +} + +func TestVlessXtlsVision(t *testing.T) { + tcpServer := tcp.Server{ + MsgProcessor: xor, + } + dest, err := tcpServer.Start() + common.Must(err) + defer tcpServer.Close() + + userID := protocol.NewID(uuid.New()) + serverPort := tcp.PickPort() + serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: clog.Severity_Debug, + ErrorLogType: log.LogType_Console, + }), + }, + Inbound: []*core.InboundHandlerConfig{ + { + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + StreamSettings: &internet.StreamConfig{ + Protocol: internet.TransportProtocol_TCP, + SecurityType: serial.GetMessageType(&tls.Config{}), + SecuritySettings: []*serial.TypedMessage{ + serial.ToTypedMessage(&tls.Config{ + Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil))}, + }), + }, + }, + }), + ProxySettings: serial.ToTypedMessage(&inbound.Config{ + Clients: []*protocol.User{ + { + Account: serial.ToTypedMessage(&vless.Account{ + Id: userID.String(), + Flow: vless.XRV, + }), + }, + }, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + ProxySettings: serial.ToTypedMessage(&freedom.Config{}), + }, + }, + } + + clientPort := tcp.PickPort() + clientConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: clog.Severity_Debug, + ErrorLogType: log.LogType_Console, + }), + }, + Inbound: []*core.InboundHandlerConfig{ + { + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + }), + ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), + NetworkList: &net.NetworkList{ + Network: []net.Network{net.Network_TCP}, + }, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + ProxySettings: serial.ToTypedMessage(&outbound.Config{ + Vnext: []*protocol.ServerEndpoint{ + { + Address: net.NewIPOrDomain(net.LocalHostIP), + Port: uint32(serverPort), + User: []*protocol.User{ + { + Account: serial.ToTypedMessage(&vless.Account{ + Id: userID.String(), + Flow: vless.XRV, + }), + }, + }, + }, + }, + }), + SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ + StreamSettings: &internet.StreamConfig{ + Protocol: internet.TransportProtocol_TCP, + TransportSettings: []*internet.TransportConfig{ + { + Protocol: internet.TransportProtocol_TCP, + Settings: serial.ToTypedMessage(&transtcp.Config{}), + }, + }, + SecurityType: serial.GetMessageType(&tls.Config{}), + SecuritySettings: []*serial.TypedMessage{ + serial.ToTypedMessage(&tls.Config{ + AllowInsecure: true, + }), + }, + }, + }), + }, + }, + } + + servers, err := InitializeServerConfigs(serverConfig, clientConfig) + common.Must(err) + defer CloseAllServers(servers) + + var errg errgroup.Group + for i := 0; i < 10; i++ { + errg.Go(testTCPConn(clientPort, 1024*1024, time.Second*30)) + } + if err := errg.Wait(); err != nil { + t.Error(err) + } +} + +// func TestVlessXtlsVisionReality(t *testing.T) { +// tcpServer := tcp.Server{ +// MsgProcessor: xor, +// } +// dest, err := tcpServer.Start() +// common.Must(err) +// defer tcpServer.Close() + +// userID := protocol.NewID(uuid.New()) +// serverPort := tcp.PickPort() +// privateKey, _ := base64.RawURLEncoding.DecodeString("aGSYystUbf59_9_6LKRxD27rmSW_-2_nyd9YG_Gwbks") +// publicKey, _ := base64.RawURLEncoding.DecodeString("E59WjnvZcQMu7tR7_BgyhycuEdBS-CtKxfImRCdAvFM") +// shortIds := make([][]byte, 1) +// shortIds[0] = make([]byte, 8) +// hex.Decode(shortIds[0], []byte("0123456789abcdef")) +// serverConfig := &core.Config{ +// App: []*serial.TypedMessage{ +// serial.ToTypedMessage(&log.Config{ +// ErrorLogLevel: clog.Severity_Debug, +// ErrorLogType: log.LogType_Console, +// }), +// }, +// Inbound: []*core.InboundHandlerConfig{ +// { +// ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ +// PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, +// Listen: net.NewIPOrDomain(net.LocalHostIP), +// StreamSettings: &internet.StreamConfig{ +// Protocol: internet.TransportProtocol_TCP, +// SecurityType: serial.GetMessageType(&reality.Config{}), +// SecuritySettings: []*serial.TypedMessage{ +// serial.ToTypedMessage(&reality.Config{ +// Show: true, +// Dest: "www.google.com:443", // use google for now, may fail in some region +// ServerNames: []string{"www.google.com"}, +// PrivateKey: privateKey, +// ShortIds: shortIds, +// }), +// }, +// }, +// }), +// ProxySettings: serial.ToTypedMessage(&inbound.Config{ +// Clients: []*protocol.User{ +// { +// Account: serial.ToTypedMessage(&vless.Account{ +// Id: userID.String(), +// Flow: vless.XRV, +// }), +// }, +// }, +// }), +// }, +// }, +// Outbound: []*core.OutboundHandlerConfig{ +// { +// ProxySettings: serial.ToTypedMessage(&freedom.Config{}), +// }, +// }, +// } + +// clientPort := tcp.PickPort() +// clientConfig := &core.Config{ +// App: []*serial.TypedMessage{ +// serial.ToTypedMessage(&log.Config{ +// ErrorLogLevel: clog.Severity_Debug, +// ErrorLogType: log.LogType_Console, +// }), +// }, +// Inbound: []*core.InboundHandlerConfig{ +// { +// ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ +// PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, +// Listen: net.NewIPOrDomain(net.LocalHostIP), +// }), +// ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ +// Address: net.NewIPOrDomain(dest.Address), +// Port: uint32(dest.Port), +// NetworkList: &net.NetworkList{ +// Network: []net.Network{net.Network_TCP}, +// }, +// }), +// }, +// }, +// Outbound: []*core.OutboundHandlerConfig{ +// { +// ProxySettings: serial.ToTypedMessage(&outbound.Config{ +// Vnext: []*protocol.ServerEndpoint{ +// { +// Address: net.NewIPOrDomain(net.LocalHostIP), +// Port: uint32(serverPort), +// User: []*protocol.User{ +// { +// Account: serial.ToTypedMessage(&vless.Account{ +// Id: userID.String(), +// Flow: vless.XRV, +// }), +// }, +// }, +// }, +// }, +// }), +// SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ +// StreamSettings: &internet.StreamConfig{ +// Protocol: internet.TransportProtocol_TCP, +// TransportSettings: []*internet.TransportConfig{ +// { +// Protocol: internet.TransportProtocol_TCP, +// Settings: serial.ToTypedMessage(&transtcp.Config{}), +// }, +// }, +// SecurityType: serial.GetMessageType(&reality.Config{}), +// SecuritySettings: []*serial.TypedMessage{ +// serial.ToTypedMessage(&reality.Config{ +// Show: true, +// Fingerprint: "chrome", +// ServerName: "www.google.com", +// PublicKey: publicKey, +// ShortId: shortIds[0], +// SpiderX: "/", +// }), +// }, +// }, +// }), +// }, +// }, +// } + +// servers, err := InitializeServerConfigs(serverConfig, clientConfig) +// common.Must(err) +// defer CloseAllServers(servers) + +// var errg errgroup.Group +// for i := 0; i < 1; i++ { +// errg.Go(testTCPConn(clientPort, 1024*1024, time.Second*30)) +// } +// if err := errg.Wait(); err != nil { +// t.Error(err) +// } +// } From efd32b0fb2a4f1b2d2e98b21916cfd9aa0e0b497 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 3 May 2023 22:21:45 -0400 Subject: [PATCH 140/867] Enable splice for freedom outbound (downlink only) - Add outbound name - Add outbound conn in ctx - Refactor splice: it can be turn on from all inbounds and outbounds - Refactor splice: Add splice copy to vless inbound - Fix http error test - Add freedom splice toggle via env var - Populate outbound obj in context - Use CanSpliceCopy to mark a connection - Turn off splice by default --- app/dispatcher/default.go | 20 +++--- app/proxyman/inbound/worker.go | 6 +- app/proxyman/outbound/handler.go | 7 +- common/buf/copy.go | 12 ++++ common/session/session.go | 14 ++++ proxy/blackhole/blackhole.go | 6 ++ proxy/dns/dns.go | 1 + proxy/dokodemo/dokodemo.go | 9 ++- proxy/errors.generated.go | 9 +++ proxy/freedom/freedom.go | 27 ++++++-- proxy/http/client.go | 5 ++ proxy/http/server.go | 9 ++- proxy/loopback/loopback.go | 1 + proxy/proxy.go | 86 +++++++++++++++++++++++++ proxy/shadowsocks/client.go | 5 ++ proxy/shadowsocks/server.go | 10 ++- proxy/shadowsocks_2022/inbound.go | 1 + proxy/shadowsocks_2022/inbound_multi.go | 1 + proxy/shadowsocks_2022/inbound_relay.go | 1 + proxy/shadowsocks_2022/outbound.go | 2 + proxy/socks/client.go | 5 ++ proxy/socks/server.go | 10 +-- proxy/trojan/client.go | 5 ++ proxy/trojan/server.go | 4 +- proxy/vless/encoding/encoding.go | 68 ++++++------------- proxy/vless/inbound/inbound.go | 35 ++-------- proxy/vless/outbound/outbound.go | 47 ++++++-------- proxy/vmess/inbound/inbound.go | 4 +- proxy/vmess/outbound/outbound.go | 16 +++-- proxy/wireguard/wireguard.go | 14 ++-- testing/scenarios/http_test.go | 6 +- testing/scenarios/vmess_test.go | 4 +- 32 files changed, 282 insertions(+), 168 deletions(-) create mode 100644 proxy/errors.generated.go diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index aaa9b410..bfc43608 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -218,11 +218,13 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin if !destination.IsValid() { panic("Dispatcher: Invalid destination.") } - ob := &session.Outbound{ - OriginalTarget: destination, - Target: destination, + ob := session.OutboundFromContext(ctx) + if ob == nil { + ob = &session.Outbound{} + ctx = session.ContextWithOutbound(ctx, ob) } - ctx = session.ContextWithOutbound(ctx, ob) + ob.OriginalTarget = destination + ob.Target = destination content := session.ContentFromContext(ctx) if content == nil { content = new(session.Content) @@ -271,11 +273,13 @@ func (d *DefaultDispatcher) DispatchLink(ctx context.Context, destination net.De if !destination.IsValid() { return newError("Dispatcher: Invalid destination.") } - ob := &session.Outbound{ - OriginalTarget: destination, - Target: destination, + ob := session.OutboundFromContext(ctx) + if ob == nil { + ob = &session.Outbound{} + ctx = session.ContextWithOutbound(ctx, ob) } - ctx = session.ContextWithOutbound(ctx, ob) + ob.OriginalTarget = destination + ob.Target = destination content := session.ContentFromContext(ctx) if content == nil { content = new(session.Content) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 8ed4090a..1fe86655 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -60,6 +60,7 @@ func (w *tcpWorker) callback(conn stat.Connection) { sid := session.NewID() ctx = session.ContextWithID(ctx, sid) + var outbound = &session.Outbound{} if w.recvOrigDest { var dest net.Destination switch getTProxyType(w.stream) { @@ -74,11 +75,10 @@ func (w *tcpWorker) callback(conn stat.Connection) { dest = net.DestinationFromAddr(conn.LocalAddr()) } if dest.IsValid() { - ctx = session.ContextWithOutbound(ctx, &session.Outbound{ - Target: dest, - }) + outbound.Target = dest } } + ctx = session.ContextWithOutbound(ctx, outbound) if w.uplinkCounter != nil || w.downlinkCounter != nil { conn = &stat.CounterConnection{ diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index adf6537a..d290b016 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -274,7 +274,12 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connecti } conn, err := internet.Dial(ctx, dest, h.streamSettings) - return h.getStatCouterConnection(conn), err + conn = h.getStatCouterConnection(conn) + outbound := session.OutboundFromContext(ctx) + if outbound != nil { + outbound.Conn = conn + } + return conn, err } func (h *Handler) getStatCouterConnection(conn stat.Connection) stat.Connection { diff --git a/common/buf/copy.go b/common/buf/copy.go index 601771be..3096dc57 100644 --- a/common/buf/copy.go +++ b/common/buf/copy.go @@ -6,6 +6,7 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/signal" + "github.com/xtls/xray-core/features/stats" ) type dataHandler func(MultiBuffer) @@ -40,6 +41,17 @@ func CountSize(sc *SizeCounter) CopyOption { } } +// AddToStatCounter a CopyOption add to stat counter +func AddToStatCounter(sc stats.Counter) CopyOption { + return func(handler *copyHandler) { + handler.onData = append(handler.onData, func(b MultiBuffer) { + if sc != nil { + sc.Add(int64(b.Len())) + } + }) + } +} + type readError struct { error } diff --git a/common/session/session.go b/common/session/session.go index b9609e86..4af61015 100644 --- a/common/session/session.go +++ b/common/session/session.go @@ -50,6 +50,16 @@ type Inbound struct { Conn net.Conn // Timer of the inbound buf copier. May be nil. Timer *signal.ActivityTimer + // CanSpliceCopy is a property for this connection, set by both inbound and outbound + // 1 = can, 2 = after processing protocol info should be able to, 3 = cannot + CanSpliceCopy int +} + +func(i *Inbound) SetCanSpliceCopy(canSpliceCopy int) int { + if canSpliceCopy > i.CanSpliceCopy { + i.CanSpliceCopy = canSpliceCopy + } + return i.CanSpliceCopy } // Outbound is the metadata of an outbound connection. @@ -60,6 +70,10 @@ type Outbound struct { RouteTarget net.Destination // Gateway address Gateway net.Address + // Name of the outbound proxy that handles the connection. + Name string + // Conn is actually internet.Connection. May be nil. It is currently nil for outbound with proxySettings + Conn net.Conn } // SniffingRequest controls the behavior of content sniffing. diff --git a/proxy/blackhole/blackhole.go b/proxy/blackhole/blackhole.go index b17c60c4..4b819417 100644 --- a/proxy/blackhole/blackhole.go +++ b/proxy/blackhole/blackhole.go @@ -8,6 +8,7 @@ import ( "time" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" ) @@ -30,6 +31,11 @@ func New(ctx context.Context, config *Config) (*Handler, error) { // Process implements OutboundHandler.Dispatch(). func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error { + outbound := session.OutboundFromContext(ctx) + if outbound != nil { + outbound.Name = "blackhole" + } + nBytes := h.response.WriteTo(link.Writer) if nBytes > 0 { // Sleep a little here to make sure the response is sent to client. diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index d8a3244d..415fe991 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -96,6 +96,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet. if outbound == nil || !outbound.Target.IsValid() { return newError("invalid outbound") } + outbound.Name = "dns" srcNetwork := outbound.Target.Network diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 42d8256f..4a4735e8 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -102,11 +102,10 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st } inbound := session.InboundFromContext(ctx) - if inbound != nil { - inbound.Name = "dokodemo-door" - inbound.User = &protocol.MemoryUser{ - Level: d.config.UserLevel, - } + inbound.Name = "dokodemo-door" + inbound.SetCanSpliceCopy(1) + inbound.User = &protocol.MemoryUser{ + Level: d.config.UserLevel, } ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{ diff --git a/proxy/errors.generated.go b/proxy/errors.generated.go new file mode 100644 index 00000000..1a643896 --- /dev/null +++ b/proxy/errors.generated.go @@ -0,0 +1,9 @@ +package proxy + +import "github.com/xtls/xray-core/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index c6907b4c..808f837f 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -13,6 +13,7 @@ import ( "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/common/platform" "github.com/xtls/xray-core/common/retry" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/common/signal" @@ -21,11 +22,14 @@ import ( "github.com/xtls/xray-core/features/dns" "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/features/stats" + "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" ) +var useSplice bool + func init() { common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { h := new(Handler) @@ -36,6 +40,12 @@ func init() { } return h, nil })) + const defaultFlagValue = "NOT_DEFINED_AT_ALL" + value := platform.NewEnvFlag("xray.buf.splice").GetValue(func() string { return defaultFlagValue }) + switch value { + case "auto", "enable": + useSplice = true + } } // Handler handles Freedom connections. @@ -107,6 +117,11 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte if outbound == nil || !outbound.Target.IsValid() { return newError("target not specified.") } + outbound.Name = "freedom" + inbound := session.InboundFromContext(ctx) + if inbound != nil { + inbound.SetCanSpliceCopy(1) + } destination := outbound.Target UDPOverride := net.UDPDestination(nil, 0) if h.config.DestinationOverride != nil { @@ -195,17 +210,17 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte responseDone := func() error { defer timer.SetTimeout(plcy.Timeouts.UplinkOnly) - - var reader buf.Reader if destination.Network == net.Network_TCP { - reader = buf.NewReader(conn) - } else { - reader = NewPacketReader(conn, UDPOverride) + var writeConn net.Conn + if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Conn != nil && useSplice { + writeConn = inbound.Conn + } + return proxy.CopyRawConnIfExist(ctx, conn, writeConn, link.Writer, timer) } + reader := NewPacketReader(conn, UDPOverride) if err := buf.Copy(reader, output, buf.UpdateActivity(timer)); err != nil { return newError("failed to process response").Base(err) } - return nil } diff --git a/proxy/http/client.go b/proxy/http/client.go index f597a502..302e521d 100644 --- a/proxy/http/client.go +++ b/proxy/http/client.go @@ -73,6 +73,11 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter if outbound == nil || !outbound.Target.IsValid() { return newError("target not specified.") } + outbound.Name = "http" + inbound := session.InboundFromContext(ctx) + if inbound != nil { + inbound.SetCanSpliceCopy(2) + } target := outbound.Target targetAddr := target.NetAddr() diff --git a/proxy/http/server.go b/proxy/http/server.go index 6b00fe2b..511d9b08 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -84,11 +84,10 @@ type readerOnly struct { func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error { inbound := session.InboundFromContext(ctx) - if inbound != nil { - inbound.Name = "http" - inbound.User = &protocol.MemoryUser{ - Level: s.config.UserLevel, - } + inbound.Name = "http" + inbound.SetCanSpliceCopy(2) + inbound.User = &protocol.MemoryUser{ + Level: s.config.UserLevel, } reader := bufio.NewReaderSize(readerOnly{conn}, buf.Size) diff --git a/proxy/loopback/loopback.go b/proxy/loopback/loopback.go index 946847f3..30c39bd9 100644 --- a/proxy/loopback/loopback.go +++ b/proxy/loopback/loopback.go @@ -26,6 +26,7 @@ func (l *Loopback) Process(ctx context.Context, link *transport.Link, _ internet if outbound == nil || !outbound.Target.IsValid() { return newError("target not specified.") } + outbound.Name = "loopback" destination := outbound.Target newError("opening connection to ", destination).WriteToLog(session.ExportIDToError(ctx)) diff --git a/proxy/proxy.go b/proxy/proxy.go index fb52605c..12b9631b 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -7,13 +7,24 @@ package proxy import ( "context" + gotls "crypto/tls" + "io" + "runtime" + "github.com/pires/go-proxyproto" + "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" + "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/features/routing" + "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/reality" "github.com/xtls/xray-core/transport/internet/stat" + "github.com/xtls/xray-core/transport/internet/tls" ) // An Inbound processes inbound connections. @@ -47,3 +58,78 @@ type GetInbound interface { type GetOutbound interface { GetOutbound() Outbound } + +// UnwrapRawConn support unwrap stats, tls, utls, reality and proxyproto conn and get raw tcp conn from it +func UnwrapRawConn(conn net.Conn) (net.Conn, stats.Counter, stats.Counter) { + var readCounter, writerCounter stats.Counter + if conn != nil { + statConn, ok := conn.(*stat.CounterConnection) + if ok { + conn = statConn.Connection + readCounter = statConn.ReadCounter + writerCounter = statConn.WriteCounter + } + if xc, ok := conn.(*gotls.Conn); ok { + conn = xc.NetConn() + } else if utlsConn, ok := conn.(*tls.UConn); ok { + conn = utlsConn.NetConn() + } else if realityConn, ok := conn.(*reality.Conn); ok { + conn = realityConn.NetConn() + } else if realityUConn, ok := conn.(*reality.UConn); ok { + conn = realityUConn.NetConn() + } + if pc, ok := conn.(*proxyproto.Conn); ok { + conn = pc.Raw() + // 8192 > 4096, there is no need to process pc's bufReader + } + } + return conn, readCounter, writerCounter +} + +// CopyRawConnIfExist use the most efficient copy method. +// - If caller don't want to turn on splice, do not pass in both reader conn and writer conn +// - writer are from *transport.Link +func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net.Conn, writer buf.Writer, timer signal.ActivityUpdater) error { + readerConn, readCounter, _ := UnwrapRawConn(readerConn) + writerConn, _, writeCounter := UnwrapRawConn(writerConn) + reader := buf.NewReader(readerConn) + if inbound := session.InboundFromContext(ctx); inbound != nil { + if tc, ok := writerConn.(*net.TCPConn); ok && readerConn != nil && writerConn != nil && (runtime.GOOS == "linux" || runtime.GOOS == "android") { + for inbound.CanSpliceCopy != 3 { + if inbound.CanSpliceCopy == 1 { + newError("CopyRawConn splice").WriteToLog(session.ExportIDToError(ctx)) + runtime.Gosched() // necessary + w, err := tc.ReadFrom(readerConn) + if readCounter != nil { + readCounter.Add(w) + } + if writeCounter != nil { + writeCounter.Add(w) + } + if err != nil && errors.Cause(err) != io.EOF { + return err + } + return nil + } + buffer, err := reader.ReadMultiBuffer() + if !buffer.IsEmpty() { + if readCounter != nil { + readCounter.Add(int64(buffer.Len())) + } + timer.Update() + if werr := writer.WriteMultiBuffer(buffer); werr != nil { + return werr + } + } + if err != nil { + return err + } + } + } + } + newError("CopyRawConn readv").WriteToLog(session.ExportIDToError(ctx)) + if err := buf.Copy(reader, writer, buf.UpdateActivity(timer), buf.AddToStatCounter(readCounter)); err != nil { + return newError("failed to process response").Base(err) + } + return nil +} diff --git a/proxy/shadowsocks/client.go b/proxy/shadowsocks/client.go index e22b11c7..57d8f81c 100644 --- a/proxy/shadowsocks/client.go +++ b/proxy/shadowsocks/client.go @@ -53,6 +53,11 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter if outbound == nil || !outbound.Target.IsValid() { return newError("target not specified") } + outbound.Name = "shadowsocks" + inbound := session.InboundFromContext(ctx) + if inbound != nil { + inbound.SetCanSpliceCopy(3) + } destination := outbound.Target network := destination.Network diff --git a/proxy/shadowsocks/server.go b/proxy/shadowsocks/server.go index 1d89db5e..2975ba70 100644 --- a/proxy/shadowsocks/server.go +++ b/proxy/shadowsocks/server.go @@ -71,6 +71,10 @@ func (s *Server) Network() []net.Network { } func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error { + inbound := session.InboundFromContext(ctx) + inbound.Name = "shadowsocks" + inbound.SetCanSpliceCopy(3) + switch network { case net.Network_TCP: return s.handleConnection(ctx, conn, dispatcher) @@ -110,13 +114,7 @@ func (s *Server) handleUDPPayload(ctx context.Context, conn stat.Connection, dis }) inbound := session.InboundFromContext(ctx) - if inbound == nil { - panic("no inbound metadata") - } - inbound.Name = "shadowsocks" - var dest *net.Destination - reader := buf.NewPacketReader(conn) for { mpayload, err := reader.ReadMultiBuffer() diff --git a/proxy/shadowsocks_2022/inbound.go b/proxy/shadowsocks_2022/inbound.go index bb298c09..246fc7f1 100644 --- a/proxy/shadowsocks_2022/inbound.go +++ b/proxy/shadowsocks_2022/inbound.go @@ -66,6 +66,7 @@ func (i *Inbound) Network() []net.Network { func (i *Inbound) Process(ctx context.Context, network net.Network, connection stat.Connection, dispatcher routing.Dispatcher) error { inbound := session.InboundFromContext(ctx) inbound.Name = "shadowsocks-2022" + inbound.SetCanSpliceCopy(3) var metadata M.Metadata if inbound.Source.IsValid() { diff --git a/proxy/shadowsocks_2022/inbound_multi.go b/proxy/shadowsocks_2022/inbound_multi.go index c9927476..c3832a91 100644 --- a/proxy/shadowsocks_2022/inbound_multi.go +++ b/proxy/shadowsocks_2022/inbound_multi.go @@ -155,6 +155,7 @@ func (i *MultiUserInbound) Network() []net.Network { func (i *MultiUserInbound) Process(ctx context.Context, network net.Network, connection stat.Connection, dispatcher routing.Dispatcher) error { inbound := session.InboundFromContext(ctx) inbound.Name = "shadowsocks-2022-multi" + inbound.SetCanSpliceCopy(3) var metadata M.Metadata if inbound.Source.IsValid() { diff --git a/proxy/shadowsocks_2022/inbound_relay.go b/proxy/shadowsocks_2022/inbound_relay.go index c3f8e675..e2cb7d50 100644 --- a/proxy/shadowsocks_2022/inbound_relay.go +++ b/proxy/shadowsocks_2022/inbound_relay.go @@ -87,6 +87,7 @@ func (i *RelayInbound) Network() []net.Network { func (i *RelayInbound) Process(ctx context.Context, network net.Network, connection stat.Connection, dispatcher routing.Dispatcher) error { inbound := session.InboundFromContext(ctx) inbound.Name = "shadowsocks-2022-relay" + inbound.SetCanSpliceCopy(3) var metadata M.Metadata if inbound.Source.IsValid() { diff --git a/proxy/shadowsocks_2022/outbound.go b/proxy/shadowsocks_2022/outbound.go index 151ea0e2..a06daac7 100644 --- a/proxy/shadowsocks_2022/outbound.go +++ b/proxy/shadowsocks_2022/outbound.go @@ -66,12 +66,14 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int inbound := session.InboundFromContext(ctx) if inbound != nil { inboundConn = inbound.Conn + inbound.SetCanSpliceCopy(3) } outbound := session.OutboundFromContext(ctx) if outbound == nil || !outbound.Target.IsValid() { return newError("target not specified") } + outbound.Name = "shadowsocks-2022" destination := outbound.Target network := destination.Network diff --git a/proxy/socks/client.go b/proxy/socks/client.go index 1993aa0b..82591be4 100644 --- a/proxy/socks/client.go +++ b/proxy/socks/client.go @@ -61,6 +61,11 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter if outbound == nil || !outbound.Target.IsValid() { return newError("target not specified.") } + outbound.Name = "socks" + inbound := session.InboundFromContext(ctx) + if inbound != nil { + inbound.SetCanSpliceCopy(2) + } // Destination of the inner request. destination := outbound.Target diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 184ecd08..6964fdf2 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -63,11 +63,11 @@ func (s *Server) Network() []net.Network { // Process implements proxy.Inbound. func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error { - if inbound := session.InboundFromContext(ctx); inbound != nil { - inbound.Name = "socks" - inbound.User = &protocol.MemoryUser{ - Level: s.config.UserLevel, - } + inbound := session.InboundFromContext(ctx) + inbound.Name = "socks" + inbound.SetCanSpliceCopy(2) + inbound.User = &protocol.MemoryUser{ + Level: s.config.UserLevel, } switch network { diff --git a/proxy/trojan/client.go b/proxy/trojan/client.go index 0c6f16d3..d6b95fc0 100644 --- a/proxy/trojan/client.go +++ b/proxy/trojan/client.go @@ -54,6 +54,11 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter if outbound == nil || !outbound.Target.IsValid() { return newError("target not specified") } + outbound.Name = "trojan" + inbound := session.InboundFromContext(ctx) + if inbound != nil { + inbound.SetCanSpliceCopy(3) + } destination := outbound.Target network := destination.Network diff --git a/proxy/trojan/server.go b/proxy/trojan/server.go index 41245ba4..5c3fcd91 100644 --- a/proxy/trojan/server.go +++ b/proxy/trojan/server.go @@ -214,10 +214,8 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con } inbound := session.InboundFromContext(ctx) - if inbound == nil { - panic("no inbound metadata") - } inbound.Name = "trojan" + inbound.SetCanSpliceCopy(3) inbound.User = user sessionPolicy = s.policyManager.ForLevel(user.Level) diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index cf962492..48bda497 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -8,9 +8,7 @@ import ( "crypto/rand" "io" "math/big" - "runtime" "strconv" - "syscall" "time" "github.com/xtls/xray-core/common/buf" @@ -20,10 +18,8 @@ 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/proxy" "github.com/xtls/xray-core/proxy/vless" - "github.com/xtls/xray-core/transport/internet/reality" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/transport/internet/tls" ) const ( @@ -206,13 +202,11 @@ func DecodeResponseHeader(reader io.Reader, request *protocol.RequestHeader) (*A } // XtlsRead filter and read xtls protocol -func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, rawConn syscall.RawConn, - input *bytes.Reader, rawInput *bytes.Buffer, - counter stats.Counter, ctx context.Context, userUUID []byte, numberOfPacketToFilter *int, enableXtls *bool, +func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, input *bytes.Reader, rawInput *bytes.Buffer, + ctx context.Context, userUUID []byte, numberOfPacketToFilter *int, enableXtls *bool, isTLS12orAbove *bool, isTLS *bool, cipher *uint16, remainingServerHello *int32, ) error { err := func() error { - var ct stats.Counter withinPaddingBuffers := true shouldSwitchToDirectCopy := false var remainingContent int32 = -1 @@ -220,40 +214,14 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater currentCommand := 0 for { if shouldSwitchToDirectCopy { - shouldSwitchToDirectCopy = false - if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Conn != nil && (runtime.GOOS == "linux" || runtime.GOOS == "android") { - if _, ok := inbound.User.Account.(*vless.MemoryAccount); inbound.User.Account == nil || ok { - iConn := inbound.Conn - statConn, ok := iConn.(*stat.CounterConnection) - if ok { - iConn = statConn.Connection - } - if tlsConn, ok := iConn.(*tls.Conn); ok { - iConn = tlsConn.NetConn() - } else if realityConn, ok := iConn.(*reality.Conn); ok { - iConn = realityConn.NetConn() - } - if tc, ok := iConn.(*net.TCPConn); ok { - newError("XtlsRead splice").WriteToLog(session.ExportIDToError(ctx)) - runtime.Gosched() // necessary - w, err := tc.ReadFrom(conn) - if counter != nil { - counter.Add(w) - } - if statConn != nil && statConn.WriteCounter != nil { - statConn.WriteCounter.Add(w) - } - return err - } + var writerConn net.Conn + if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Conn != nil { + writerConn = inbound.Conn + if inbound.CanSpliceCopy == 2 { + inbound.CanSpliceCopy = 1 // force the value to 1, don't use setter } } - if rawConn != nil { - reader = buf.NewReadVReader(conn, rawConn, nil) - } else { - reader = buf.NewReader(conn) - } - ct = counter - newError("XtlsRead readV").WriteToLog(session.ExportIDToError(ctx)) + return proxy.CopyRawConnIfExist(ctx, conn, writerConn, writer, timer) } buffer, err := reader.ReadMultiBuffer() if !buffer.IsEmpty() { @@ -292,9 +260,6 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater if *numberOfPacketToFilter > 0 { XtlsFilterTls(buffer, numberOfPacketToFilter, enableXtls, isTLS12orAbove, isTLS, cipher, remainingServerHello, ctx) } - if ct != nil { - ct.Add(int64(buffer.Len())) - } timer.Update() if werr := writer.WriteMultiBuffer(buffer); werr != nil { return werr @@ -312,7 +277,7 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater } // XtlsWrite filter and write xtls protocol -func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, counter stats.Counter, +func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, ctx context.Context, numberOfPacketToFilter *int, enableXtls *bool, isTLS12orAbove *bool, isTLS *bool, cipher *uint16, remainingServerHello *int32, ) error { @@ -349,18 +314,21 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate } if shouldSwitchToDirectCopy { encryptBuffer, directBuffer := buf.SplitMulti(buffer, xtlsSpecIndex+1) - length := encryptBuffer.Len() if !encryptBuffer.IsEmpty() { timer.Update() if werr := writer.WriteMultiBuffer(encryptBuffer); werr != nil { return werr } } - buffer = directBuffer - writer = buf.NewWriter(conn) - ct = counter - newError("XtlsWrite writeV ", xtlsSpecIndex, " ", length, " ", buffer.Len()).WriteToLog(session.ExportIDToError(ctx)) time.Sleep(5 * time.Millisecond) // for some device, the first xtls direct packet fails without this delay + + if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.CanSpliceCopy == 2 { + inbound.CanSpliceCopy = 1 // force the value to 1, don't use setter + } + buffer = directBuffer + rawConn, _, writerCounter := proxy.UnwrapRawConn(conn) + writer = buf.NewWriter(rawConn) + ct = writerCounter } } if !buffer.IsEmpty() { diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index 8653e1e3..388aeecb 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -10,11 +10,9 @@ import ( "reflect" "strconv" "strings" - "syscall" "time" "unsafe" - "github.com/pires/go-proxyproto" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" @@ -30,7 +28,6 @@ import ( feature_inbound "github.com/xtls/xray-core/features/inbound" "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/proxy/vless" "github.com/xtls/xray-core/proxy/vless/encoding" "github.com/xtls/xray-core/transport/internet/reality" @@ -182,8 +179,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s sid := session.ExportIDToError(ctx) iConn := connection - statConn, ok := iConn.(*stat.CounterConnection) - if ok { + if statConn, ok := iConn.(*stat.CounterConnection); ok { iConn = statConn.Connection } @@ -447,14 +443,12 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s // Flow: requestAddons.Flow, } - var netConn net.Conn - var rawConn syscall.RawConn var input *bytes.Reader var rawInput *bytes.Buffer - switch requestAddons.Flow { case vless.XRV: if account.Flow == requestAddons.Flow { + inbound.SetCanSpliceCopy(2) switch request.Command { case protocol.RequestCommandUDP: return newError(requestAddons.Flow + " doesn't support UDP").AtWarning() @@ -467,23 +461,14 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s if tlsConn.ConnectionState().Version != gotls.VersionTLS13 { return newError(`failed to use `+requestAddons.Flow+`, found outer tls version `, tlsConn.ConnectionState().Version).AtWarning() } - netConn = tlsConn.NetConn() t = reflect.TypeOf(tlsConn.Conn).Elem() p = uintptr(unsafe.Pointer(tlsConn.Conn)) } else if realityConn, ok := iConn.(*reality.Conn); ok { - netConn = realityConn.NetConn() t = reflect.TypeOf(realityConn.Conn).Elem() p = uintptr(unsafe.Pointer(realityConn.Conn)) } else { return newError("XTLS only supports TLS and REALITY directly for now.").AtWarning() } - if pc, ok := netConn.(*proxyproto.Conn); ok { - netConn = pc.Raw() - // 8192 > 4096, there is no need to process pc's bufReader - } - if sc, ok := netConn.(syscall.Conn); ok { - rawConn, _ = sc.SyscallConn() - } i, _ := t.FieldByName("input") r, _ := t.FieldByName("rawInput") input = (*bytes.Reader)(unsafe.Pointer(p + i.Offset)) @@ -493,6 +478,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s return newError(account.ID.String() + " is not able to use " + requestAddons.Flow).AtWarning() } case "": + inbound.SetCanSpliceCopy(3) if account.Flow == vless.XRV && (request.Command == protocol.RequestCommandTCP || isMuxAndNotXUDP(request, first)) { return newError(account.ID.String() + " is not able to use \"\". Note that the pure TLS proxy has certain TLS in TLS characters.").AtWarning() } @@ -540,13 +526,8 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s var err error if requestAddons.Flow == vless.XRV { - var counter stats.Counter - if statConn != nil { - counter = statConn.ReadCounter - } - // TODO enable splice - ctx = session.ContextWithInbound(ctx, nil) - err = encoding.XtlsRead(clientReader, serverWriter, timer, netConn, rawConn, input, rawInput, counter, ctx, account.ID.Bytes(), + ctx1 := session.ContextWithInbound(ctx, nil) // TODO enable splice + err = encoding.XtlsRead(clientReader, serverWriter, timer, connection, input, rawInput, ctx1, account.ID.Bytes(), &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) } else { // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer @@ -592,11 +573,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s var err error if requestAddons.Flow == vless.XRV { - var counter stats.Counter - if statConn != nil { - counter = statConn.WriteCounter - } - err = encoding.XtlsWrite(serverReader, clientWriter, timer, netConn, counter, ctx, &numberOfPacketToFilter, + err = encoding.XtlsWrite(serverReader, clientWriter, timer, connection, ctx, &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) } else { // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index 12962a47..bc2e6625 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -7,7 +7,6 @@ import ( "context" gotls "crypto/tls" "reflect" - "syscall" "time" "unsafe" @@ -23,7 +22,6 @@ import ( "github.com/xtls/xray-core/common/xudp" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/policy" - "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" @@ -71,9 +69,15 @@ func New(ctx context.Context, config *Config) (*Handler, error) { // Process implements proxy.Outbound.Process(). func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error { + outbound := session.OutboundFromContext(ctx) + if outbound == nil || !outbound.Target.IsValid() { + return newError("target not specified").AtError() + } + outbound.Name = "vless" + inbound := session.InboundFromContext(ctx) + var rec *protocol.ServerSpec var conn stat.Connection - if err := retry.ExponentialBackoff(5, 200).On(func() error { rec = h.serverPicker.PickServer() var err error @@ -88,16 +92,9 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte defer conn.Close() iConn := conn - statConn, ok := iConn.(*stat.CounterConnection) - if ok { + if statConn, ok := iConn.(*stat.CounterConnection); ok { iConn = statConn.Connection } - - outbound := session.OutboundFromContext(ctx) - if outbound == nil || !outbound.Target.IsValid() { - return newError("target not specified").AtError() - } - target := outbound.Target newError("tunneling request to ", target, " via ", rec.Destination().NetAddr()).AtInfo().WriteToLog(session.ExportIDToError(ctx)) @@ -123,8 +120,6 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte Flow: account.Flow, } - var netConn net.Conn - var rawConn syscall.RawConn var input *bytes.Reader var rawInput *bytes.Buffer allowUDP443 := false @@ -134,6 +129,9 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte requestAddons.Flow = requestAddons.Flow[:16] fallthrough case vless.XRV: + if inbound != nil { + inbound.SetCanSpliceCopy(2) + } switch request.Command { case protocol.RequestCommandUDP: if !allowUDP443 && request.Port == 443 { @@ -146,28 +144,26 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte var t reflect.Type var p uintptr if tlsConn, ok := iConn.(*tls.Conn); ok { - netConn = tlsConn.NetConn() t = reflect.TypeOf(tlsConn.Conn).Elem() p = uintptr(unsafe.Pointer(tlsConn.Conn)) } else if utlsConn, ok := iConn.(*tls.UConn); ok { - netConn = utlsConn.NetConn() t = reflect.TypeOf(utlsConn.Conn).Elem() p = uintptr(unsafe.Pointer(utlsConn.Conn)) } else if realityConn, ok := iConn.(*reality.UConn); ok { - netConn = realityConn.NetConn() t = reflect.TypeOf(realityConn.Conn).Elem() p = uintptr(unsafe.Pointer(realityConn.Conn)) } else { return newError("XTLS only supports TLS and REALITY directly for now.").AtWarning() } - if sc, ok := netConn.(syscall.Conn); ok { - rawConn, _ = sc.SyscallConn() - } i, _ := t.FieldByName("input") r, _ := t.FieldByName("rawInput") input = (*bytes.Reader)(unsafe.Pointer(p + i.Offset)) rawInput = (*bytes.Buffer)(unsafe.Pointer(p + r.Offset)) } + default: + if inbound != nil { + inbound.SetCanSpliceCopy(3) + } } var newCtx context.Context @@ -257,11 +253,8 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte return newError(`failed to use `+requestAddons.Flow+`, found outer tls version `, utlsConn.ConnectionState().Version).AtWarning() } } - var counter stats.Counter - if statConn != nil { - counter = statConn.WriteCounter - } - err = encoding.XtlsWrite(clientReader, serverWriter, timer, netConn, counter, ctx, &numberOfPacketToFilter, + ctx1 := session.ContextWithOutbound(ctx, nil) // TODO enable splice + err = encoding.XtlsWrite(clientReader, serverWriter, timer, conn, ctx1, &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) } else { // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer @@ -293,11 +286,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } if requestAddons.Flow == vless.XRV { - var counter stats.Counter - if statConn != nil { - counter = statConn.ReadCounter - } - err = encoding.XtlsRead(serverReader, clientWriter, timer, netConn, rawConn, input, rawInput, counter, ctx, account.ID.Bytes(), + err = encoding.XtlsRead(serverReader, clientWriter, timer, conn, input, rawInput, ctx, account.ID.Bytes(), &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) } else { // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index f48a26e1..679ea5da 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -256,10 +256,8 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s } inbound := session.InboundFromContext(ctx) - if inbound == nil { - panic("no inbound metadata") - } inbound.Name = "vmess" + inbound.SetCanSpliceCopy(3) inbound.User = request.User sessionPolicy = h.policyManager.ForLevel(request.User.Level) diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index fc77f07f..5e228d68 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -60,9 +60,18 @@ func New(ctx context.Context, config *Config) (*Handler, error) { // Process implements proxy.Outbound.Process(). func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error { + outbound := session.OutboundFromContext(ctx) + if outbound == nil || !outbound.Target.IsValid() { + return newError("target not specified").AtError() + } + outbound.Name = "vmess" + inbound := session.InboundFromContext(ctx) + if inbound != nil { + inbound.SetCanSpliceCopy(3) + } + var rec *protocol.ServerSpec var conn stat.Connection - err := retry.ExponentialBackoff(5, 200).On(func() error { rec = h.serverPicker.PickServer() rawConn, err := dialer.Dial(ctx, rec.Destination()) @@ -78,11 +87,6 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } defer conn.Close() - outbound := session.OutboundFromContext(ctx) - if outbound == nil || !outbound.Target.IsValid() { - return newError("target not specified").AtError() - } - target := outbound.Target newError("tunneling request to ", target, " via ", rec.Destination().NetAddr()).WriteToLog(session.ExportIDToError(ctx)) diff --git a/proxy/wireguard/wireguard.go b/proxy/wireguard/wireguard.go index 53e7dcd5..899dcac5 100644 --- a/proxy/wireguard/wireguard.go +++ b/proxy/wireguard/wireguard.go @@ -75,6 +75,16 @@ func New(ctx context.Context, conf *DeviceConfig) (*Handler, error) { // Process implements OutboundHandler.Dispatch(). func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error { + outbound := session.OutboundFromContext(ctx) + if outbound == nil || !outbound.Target.IsValid() { + return newError("target not specified") + } + outbound.Name = "wireguard" + inbound := session.InboundFromContext(ctx) + if inbound != nil { + inbound.SetCanSpliceCopy(3) + } + if h.bind == nil || h.bind.dialer != dialer || h.net == nil { log.Record(&log.GeneralMessage{ Severity: log.Severity_Info, @@ -101,10 +111,6 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte h.bind = bind } - outbound := session.OutboundFromContext(ctx) - if outbound == nil || !outbound.Target.IsValid() { - return newError("target not specified") - } // Destination of the inner request. destination := outbound.Target command := protocol.RequestCommandTCP diff --git a/testing/scenarios/http_test.go b/testing/scenarios/http_test.go index d6a765bb..b9b112ff 100644 --- a/testing/scenarios/http_test.go +++ b/testing/scenarios/http_test.go @@ -7,6 +7,7 @@ import ( "io" "net/http" "net/url" + "strings" "testing" "time" @@ -128,9 +129,8 @@ func TestHttpError(t *testing.T) { } resp, err := client.Get("http://127.0.0.1:" + dest.Port.String()) - common.Must(err) - if resp.StatusCode != 503 { - t.Error("status: ", resp.StatusCode) + if resp != nil && resp.StatusCode != 503 || err != nil && !strings.Contains(err.Error(), "malformed HTTP status code") { + t.Error("should not receive http response", err) } } } diff --git a/testing/scenarios/vmess_test.go b/testing/scenarios/vmess_test.go index 9f2b0abc..2239b13c 100644 --- a/testing/scenarios/vmess_test.go +++ b/testing/scenarios/vmess_test.go @@ -1174,10 +1174,10 @@ func TestVMessGCMMuxUDP(t *testing.T) { servers, err := InitializeServerConfigs(serverConfig, clientConfig) common.Must(err) - for range "abcd" { + for range "ab" { var errg errgroup.Group for i := 0; i < 16; i++ { - errg.Go(testTCPConn(clientPort, 10240, time.Second*20)) + errg.Go(testTCPConn(clientPort, 1024, time.Second*10)) errg.Go(testUDPConn(clientUDPPort, 1024, time.Second*10)) } if err := errg.Wait(); err != nil { From d6d225c6981812f024f90adab8cefc26a5ac0937 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 2 Sep 2023 11:37:50 -0400 Subject: [PATCH 141/867] Refactor Vision reader writer - Vision now use traffic states to capture two-way info about a connection - XTLS is de-couple with Vision, it only read traffic states to switch to direct copy mode - fix a edge case error when Vision unpadding read 5 command bytes --- proxy/proxy.go | 386 +++++++++++++++++++++++++++++++ proxy/vless/encoding/addons.go | 19 +- proxy/vless/encoding/encoding.go | 356 +++------------------------- proxy/vless/inbound/inbound.go | 25 +- proxy/vless/outbound/outbound.go | 28 +-- 5 files changed, 440 insertions(+), 374 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 12b9631b..142acb77 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -6,10 +6,14 @@ package proxy import ( + "bytes" "context" + "crypto/rand" gotls "crypto/tls" "io" + "math/big" "runtime" + "strconv" "github.com/pires/go-proxyproto" "github.com/xtls/xray-core/common/buf" @@ -27,6 +31,30 @@ import ( "github.com/xtls/xray-core/transport/internet/tls" ) +var ( + Tls13SupportedVersions = []byte{0x00, 0x2b, 0x00, 0x02, 0x03, 0x04} + TlsClientHandShakeStart = []byte{0x16, 0x03} + TlsServerHandShakeStart = []byte{0x16, 0x03, 0x03} + TlsApplicationDataStart = []byte{0x17, 0x03, 0x03} + + Tls13CipherSuiteDic = map[uint16]string{ + 0x1301: "TLS_AES_128_GCM_SHA256", + 0x1302: "TLS_AES_256_GCM_SHA384", + 0x1303: "TLS_CHACHA20_POLY1305_SHA256", + 0x1304: "TLS_AES_128_CCM_SHA256", + 0x1305: "TLS_AES_128_CCM_8_SHA256", + } +) + +const ( + TlsHandshakeTypeClientHello byte = 0x01 + TlsHandshakeTypeServerHello byte = 0x02 + + CommandPaddingContinue byte = 0x00 + CommandPaddingEnd byte = 0x01 + CommandPaddingDirect byte = 0x02 +) + // An Inbound processes inbound connections. type Inbound interface { // Network returns a list of networks that this inbound supports. Connections with not-supported networks will not be passed into Process(). @@ -59,6 +87,364 @@ type GetOutbound interface { GetOutbound() Outbound } +// TrafficState is used to track uplink and downlink of one connection +// It is used by XTLS to determine if switch to raw copy mode, It is used by Vision to calculate padding +type TrafficState struct { + UserUUID []byte + NumberOfPacketToFilter int + EnableXtls bool + IsTLS12orAbove bool + IsTLS bool + Cipher uint16 + RemainingServerHello int32 + + // reader link state + WithinPaddingBuffers bool + ReaderSwitchToDirectCopy bool + RemainingCommand int32 + RemainingContent int32 + RemainingPadding int32 + CurrentCommand int + + // write link state + IsPadding bool + WriterSwitchToDirectCopy bool +} + +func NewTrafficState(userUUID []byte) *TrafficState { + return &TrafficState{ + UserUUID: userUUID, + NumberOfPacketToFilter: 8, + EnableXtls: false, + IsTLS12orAbove: false, + IsTLS: false, + Cipher: 0, + RemainingServerHello: -1, + WithinPaddingBuffers: true, + ReaderSwitchToDirectCopy: false, + RemainingCommand: -1, + RemainingContent: -1, + RemainingPadding: -1, + CurrentCommand: 0, + IsPadding: true, + WriterSwitchToDirectCopy: false, + } +} + +// VisionReader is used to read xtls vision protocol +// Note Vision probably only make sense as the inner most layer of reader, since it need assess traffic state from origin proxy traffic +type VisionReader struct { + buf.Reader + trafficState *TrafficState + ctx context.Context +} + +func NewVisionReader(reader buf.Reader, state *TrafficState, context context.Context) *VisionReader { + return &VisionReader{ + Reader: reader, + trafficState: state, + ctx: context, + } +} + +func (w *VisionReader) ReadMultiBuffer() (buf.MultiBuffer, error) { + buffer, err := w.Reader.ReadMultiBuffer() + if !buffer.IsEmpty() { + if w.trafficState.WithinPaddingBuffers || w.trafficState.NumberOfPacketToFilter > 0 { + mb2 := make(buf.MultiBuffer, 0, len(buffer)) + for _, b := range buffer { + newbuffer := XtlsUnpadding(b, w.trafficState, w.ctx) + if newbuffer.Len() > 0 { + mb2 = append(mb2, newbuffer) + } + } + buffer = mb2 + if w.trafficState.RemainingContent == 0 && w.trafficState.RemainingPadding == 0 { + if w.trafficState.CurrentCommand == 1 { + w.trafficState.WithinPaddingBuffers = false + } else if w.trafficState.CurrentCommand == 2 { + w.trafficState.WithinPaddingBuffers = false + w.trafficState.ReaderSwitchToDirectCopy = true + } else if w.trafficState.CurrentCommand == 0 { + w.trafficState.WithinPaddingBuffers = true + } else { + newError("XtlsRead unknown command ", w.trafficState.CurrentCommand, buffer.Len()).WriteToLog(session.ExportIDToError(w.ctx)) + } + } else if w.trafficState.RemainingContent > 0 || w.trafficState.RemainingPadding > 0 { + w.trafficState.WithinPaddingBuffers = true + } else { + w.trafficState.WithinPaddingBuffers = false + } + } + if w.trafficState.NumberOfPacketToFilter > 0 { + XtlsFilterTls(buffer, w.trafficState, w.ctx) + } + } + return buffer, err +} + +// VisionWriter is used to write xtls vision protocol +// Note Vision probably only make sense as the inner most layer of writer, since it need assess traffic state from origin proxy traffic +type VisionWriter struct { + buf.Writer + trafficState *TrafficState + ctx context.Context + writeOnceUserUUID []byte +} + +func NewVisionWriter(writer buf.Writer, state *TrafficState, context context.Context) *VisionWriter { + w := make([]byte, len(state.UserUUID)) + copy(w, state.UserUUID) + return &VisionWriter{ + Writer: writer, + trafficState: state, + ctx: context, + writeOnceUserUUID: w, + } +} + +func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { + if w.trafficState.NumberOfPacketToFilter > 0 { + XtlsFilterTls(mb, w.trafficState, w.ctx) + } + if w.trafficState.IsPadding { + if len(mb) == 1 && mb[0] == nil { + mb[0] = XtlsPadding(nil, CommandPaddingContinue, &w.writeOnceUserUUID, true, w.ctx) // we do a long padding to hide vless header + return w.Writer.WriteMultiBuffer(mb) + } + mb = ReshapeMultiBuffer(w.ctx, mb) + longPadding := w.trafficState.IsTLS + for i, b := range mb { + if w.trafficState.IsTLS && b.Len() >= 6 && bytes.Equal(TlsApplicationDataStart, b.BytesTo(3)) { + if w.trafficState.EnableXtls { + w.trafficState.WriterSwitchToDirectCopy = true + } + var command byte = CommandPaddingContinue + if i == len(mb) - 1 { + command = CommandPaddingEnd + if w.trafficState.EnableXtls { + command = CommandPaddingDirect + } + } + mb[i] = XtlsPadding(b, command, &w.writeOnceUserUUID, true, w.ctx) + w.trafficState.IsPadding = false // padding going to end + longPadding = false + continue + } else if !w.trafficState.IsTLS12orAbove && w.trafficState.NumberOfPacketToFilter <= 1 { // For compatibility with earlier vision receiver, we finish padding 1 packet early + w.trafficState.IsPadding = false + mb[i] = XtlsPadding(b, CommandPaddingEnd, &w.writeOnceUserUUID, longPadding, w.ctx) + break + } + var command byte = CommandPaddingContinue + if i == len(mb) - 1 && !w.trafficState.IsPadding { + command = CommandPaddingEnd + if w.trafficState.EnableXtls { + command = CommandPaddingDirect + } + } + mb[i] = XtlsPadding(b, command, &w.writeOnceUserUUID, longPadding, w.ctx) + } + } + return w.Writer.WriteMultiBuffer(mb) +} + +// ReshapeMultiBuffer prepare multi buffer for padding stucture (max 21 bytes) +func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBuffer { + needReshape := 0 + for _, b := range buffer { + if b.Len() >= buf.Size-21 { + needReshape += 1 + } + } + if needReshape == 0 { + return buffer + } + mb2 := make(buf.MultiBuffer, 0, len(buffer)+needReshape) + toPrint := "" + for i, buffer1 := range buffer { + if buffer1.Len() >= buf.Size-21 { + index := int32(bytes.LastIndex(buffer1.Bytes(), TlsApplicationDataStart)) + if index <= 0 || index > buf.Size-21 { + index = buf.Size / 2 + } + buffer2 := buf.New() + buffer2.Write(buffer1.BytesFrom(index)) + buffer1.Resize(0, index) + mb2 = append(mb2, buffer1, buffer2) + toPrint += " " + strconv.Itoa(int(buffer1.Len())) + " " + strconv.Itoa(int(buffer2.Len())) + } else { + mb2 = append(mb2, buffer1) + toPrint += " " + strconv.Itoa(int(buffer1.Len())) + } + buffer[i] = nil + } + buffer = buffer[:0] + newError("ReshapeMultiBuffer ", toPrint).WriteToLog(session.ExportIDToError(ctx)) + return mb2 +} + +// XtlsPadding add padding to eliminate length siganature during tls handshake +func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool, ctx context.Context) *buf.Buffer { + var contentLen int32 = 0 + var paddingLen int32 = 0 + if b != nil { + contentLen = b.Len() + } + if contentLen < 900 && longPadding { + l, err := rand.Int(rand.Reader, big.NewInt(500)) + if err != nil { + newError("failed to generate padding").Base(err).WriteToLog(session.ExportIDToError(ctx)) + } + paddingLen = int32(l.Int64()) + 900 - contentLen + } else { + l, err := rand.Int(rand.Reader, big.NewInt(256)) + if err != nil { + newError("failed to generate padding").Base(err).WriteToLog(session.ExportIDToError(ctx)) + } + paddingLen = int32(l.Int64()) + } + if paddingLen > buf.Size-21-contentLen { + paddingLen = buf.Size - 21 - contentLen + } + newbuffer := buf.New() + if userUUID != nil { + newbuffer.Write(*userUUID) + *userUUID = nil + } + newbuffer.Write([]byte{command, byte(contentLen >> 8), byte(contentLen), byte(paddingLen >> 8), byte(paddingLen)}) + if b != nil { + newbuffer.Write(b.Bytes()) + b.Release() + b = nil + } + newbuffer.Extend(paddingLen) + newError("XtlsPadding ", contentLen, " ", paddingLen, " ", command).WriteToLog(session.ExportIDToError(ctx)) + return newbuffer +} + +// XtlsUnpadding remove padding and parse command +func XtlsUnpadding(b *buf.Buffer, s *TrafficState, ctx context.Context) *buf.Buffer { + if s.RemainingCommand == -1 && s.RemainingContent == -1 && s.RemainingPadding == -1 { // inital state + if b.Len() >= 21 && bytes.Equal(s.UserUUID, b.BytesTo(16)) { + b.Advance(16) + s.RemainingCommand = 5 + } else { + return b + } + } + newbuffer := buf.New() + for b.Len() > 0 { + if s.RemainingCommand > 0 { + data, err := b.ReadByte() + if err != nil { + return newbuffer + } + switch s.RemainingCommand { + case 5: + s.CurrentCommand = int(data) + case 4: + s.RemainingContent = int32(data)<<8 + case 3: + s.RemainingContent = s.RemainingContent | int32(data) + case 2: + s.RemainingPadding = int32(data)<<8 + case 1: + s.RemainingPadding = s.RemainingPadding | int32(data) + newError("Xtls Unpadding new block, content ", s.RemainingContent, " padding ", s.RemainingPadding, " command ", s.CurrentCommand).WriteToLog(session.ExportIDToError(ctx)) + } + s.RemainingCommand-- + } else if s.RemainingContent > 0 { + len := s.RemainingContent + if b.Len() < len { + len = b.Len() + } + data, err := b.ReadBytes(len) + if err != nil { + return newbuffer + } + newbuffer.Write(data) + s.RemainingContent -= len + } else { // remainingPadding > 0 + len := s.RemainingPadding + if b.Len() < len { + len = b.Len() + } + b.Advance(len) + s.RemainingPadding -= len + } + if s.RemainingCommand <= 0 && s.RemainingContent <= 0 && s.RemainingPadding <= 0 { // this block done + if s.CurrentCommand == 0 { + s.RemainingCommand = 5 + } else { + s.RemainingCommand = -1 // set to initial state + s.RemainingContent = -1 + s.RemainingPadding = -1 + if b.Len() > 0 { // shouldn't happen + newbuffer.Write(b.Bytes()) + } + break + } + } + } + b.Release() + b = nil + return newbuffer +} + +// XtlsFilterTls filter and recognize tls 1.3 and other info +func XtlsFilterTls(buffer buf.MultiBuffer, trafficState *TrafficState, ctx context.Context) { + for _, b := range buffer { + if b == nil { + continue + } + trafficState.NumberOfPacketToFilter-- + if b.Len() >= 6 { + startsBytes := b.BytesTo(6) + if bytes.Equal(TlsServerHandShakeStart, startsBytes[:3]) && startsBytes[5] == TlsHandshakeTypeServerHello { + trafficState.RemainingServerHello = (int32(startsBytes[3])<<8 | int32(startsBytes[4])) + 5 + trafficState.IsTLS12orAbove = true + trafficState.IsTLS = true + if b.Len() >= 79 && trafficState.RemainingServerHello >= 79 { + sessionIdLen := int32(b.Byte(43)) + cipherSuite := b.BytesRange(43+sessionIdLen+1, 43+sessionIdLen+3) + trafficState.Cipher = uint16(cipherSuite[0])<<8 | uint16(cipherSuite[1]) + } else { + newError("XtlsFilterTls short server hello, tls 1.2 or older? ", b.Len(), " ", trafficState.RemainingServerHello).WriteToLog(session.ExportIDToError(ctx)) + } + } else if bytes.Equal(TlsClientHandShakeStart, startsBytes[:2]) && startsBytes[5] == TlsHandshakeTypeClientHello { + trafficState.IsTLS = true + newError("XtlsFilterTls found tls client hello! ", buffer.Len()).WriteToLog(session.ExportIDToError(ctx)) + } + } + if trafficState.RemainingServerHello > 0 { + end := trafficState.RemainingServerHello + if end > b.Len() { + end = b.Len() + } + trafficState.RemainingServerHello -= b.Len() + if bytes.Contains(b.BytesTo(end), Tls13SupportedVersions) { + v, ok := Tls13CipherSuiteDic[trafficState.Cipher] + if !ok { + v = "Old cipher: " + strconv.FormatUint(uint64(trafficState.Cipher), 16) + } else if v != "TLS_AES_128_CCM_8_SHA256" { + trafficState.EnableXtls = true + } + newError("XtlsFilterTls found tls 1.3! ", b.Len(), " ", v).WriteToLog(session.ExportIDToError(ctx)) + trafficState.NumberOfPacketToFilter = 0 + return + } else if trafficState.RemainingServerHello <= 0 { + newError("XtlsFilterTls found tls 1.2! ", b.Len()).WriteToLog(session.ExportIDToError(ctx)) + trafficState.NumberOfPacketToFilter = 0 + return + } + newError("XtlsFilterTls inconclusive server hello ", b.Len(), " ", trafficState.RemainingServerHello).WriteToLog(session.ExportIDToError(ctx)) + } + if trafficState.NumberOfPacketToFilter <= 0 { + newError("XtlsFilterTls stop filtering", buffer.Len()).WriteToLog(session.ExportIDToError(ctx)) + } + } +} + // UnwrapRawConn support unwrap stats, tls, utls, reality and proxyproto conn and get raw tcp conn from it func UnwrapRawConn(conn net.Conn) (net.Conn, stats.Counter, stats.Counter) { var readCounter, writerCounter stats.Counter diff --git a/proxy/vless/encoding/addons.go b/proxy/vless/encoding/addons.go index fc8ddc2a..e3e5071b 100644 --- a/proxy/vless/encoding/addons.go +++ b/proxy/vless/encoding/addons.go @@ -1,10 +1,12 @@ package encoding import ( + "context" "io" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/protocol" + "github.com/xtls/xray-core/proxy" "github.com/xtls/xray-core/proxy/vless" "google.golang.org/protobuf/proto" ) @@ -58,14 +60,19 @@ func DecodeHeaderAddons(buffer *buf.Buffer, reader io.Reader) (*Addons, error) { } // EncodeBodyAddons returns a Writer that auto-encrypt content written by caller. -func EncodeBodyAddons(writer io.Writer, request *protocol.RequestHeader, addons *Addons) buf.Writer { - switch addons.Flow { - default: - if request.Command == protocol.RequestCommandUDP { - return NewMultiLengthPacketWriter(writer.(buf.Writer)) +func EncodeBodyAddons(writer io.Writer, request *protocol.RequestHeader, requestAddons *Addons, state *proxy.TrafficState, context context.Context) buf.Writer { + if request.Command == protocol.RequestCommandUDP { + w := writer.(buf.Writer) + if requestAddons.Flow == vless.XRV { + w = proxy.NewVisionWriter(w, state, context) } + return NewMultiLengthPacketWriter(w) } - return buf.NewWriter(writer) + w := buf.NewWriter(writer) + if requestAddons.Flow == vless.XRV { + w = proxy.NewVisionWriter(w, state, context) + } + return w } // DecodeBodyAddons returns a Reader from which caller can fetch decrypted body. diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index 48bda497..b7fb66f5 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -5,11 +5,7 @@ package encoding import ( "bytes" "context" - "crypto/rand" "io" - "math/big" - "strconv" - "time" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" @@ -26,30 +22,6 @@ const ( Version = byte(0) ) -var ( - tls13SupportedVersions = []byte{0x00, 0x2b, 0x00, 0x02, 0x03, 0x04} - tlsClientHandShakeStart = []byte{0x16, 0x03} - tlsServerHandShakeStart = []byte{0x16, 0x03, 0x03} - tlsApplicationDataStart = []byte{0x17, 0x03, 0x03} - - Tls13CipherSuiteDic = map[uint16]string{ - 0x1301: "TLS_AES_128_GCM_SHA256", - 0x1302: "TLS_AES_256_GCM_SHA384", - 0x1303: "TLS_CHACHA20_POLY1305_SHA256", - 0x1304: "TLS_AES_128_CCM_SHA256", - 0x1305: "TLS_AES_128_CCM_8_SHA256", - } -) - -const ( - tlsHandshakeTypeClientHello byte = 0x01 - tlsHandshakeTypeServerHello byte = 0x02 - - CommandPaddingContinue byte = 0x00 - CommandPaddingEnd byte = 0x01 - CommandPaddingDirect byte = 0x02 -) - var addrParser = protocol.NewAddressParser( protocol.AddressFamilyByte(byte(protocol.AddressTypeIPv4), net.AddressFamilyIPv4), protocol.AddressFamilyByte(byte(protocol.AddressTypeDomain), net.AddressFamilyDomain), @@ -202,18 +174,11 @@ func DecodeResponseHeader(reader io.Reader, request *protocol.RequestHeader) (*A } // XtlsRead filter and read xtls protocol -func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, input *bytes.Reader, rawInput *bytes.Buffer, - ctx context.Context, userUUID []byte, numberOfPacketToFilter *int, enableXtls *bool, - isTLS12orAbove *bool, isTLS *bool, cipher *uint16, remainingServerHello *int32, -) error { +func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, input *bytes.Reader, rawInput *bytes.Buffer, trafficState *proxy.TrafficState, ctx context.Context) error { err := func() error { - withinPaddingBuffers := true - shouldSwitchToDirectCopy := false - var remainingContent int32 = -1 - var remainingPadding int32 = -1 - currentCommand := 0 + visionReader := proxy.NewVisionReader(reader, trafficState, ctx) for { - if shouldSwitchToDirectCopy { + if trafficState.ReaderSwitchToDirectCopy { var writerConn net.Conn if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Conn != nil { writerConn = inbound.Conn @@ -223,44 +188,22 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater } return proxy.CopyRawConnIfExist(ctx, conn, writerConn, writer, timer) } - buffer, err := reader.ReadMultiBuffer() + buffer, err := visionReader.ReadMultiBuffer() if !buffer.IsEmpty() { - if withinPaddingBuffers || *numberOfPacketToFilter > 0 { - buffer = XtlsUnpadding(ctx, buffer, userUUID, &remainingContent, &remainingPadding, ¤tCommand) - if remainingContent == 0 && remainingPadding == 0 { - if currentCommand == 1 { - withinPaddingBuffers = false - remainingContent = -1 - remainingPadding = -1 // set to initial state to parse the next padding - } else if currentCommand == 2 { - withinPaddingBuffers = false - shouldSwitchToDirectCopy = true - // XTLS Vision processes struct TLS Conn's input and rawInput - if inputBuffer, err := buf.ReadFrom(input); err == nil { - if !inputBuffer.IsEmpty() { - buffer, _ = buf.MergeMulti(buffer, inputBuffer) - } - } - if rawInputBuffer, err := buf.ReadFrom(rawInput); err == nil { - if !rawInputBuffer.IsEmpty() { - buffer, _ = buf.MergeMulti(buffer, rawInputBuffer) - } - } - } else if currentCommand == 0 { - withinPaddingBuffers = true - } else { - newError("XtlsRead unknown command ", currentCommand, buffer.Len()).WriteToLog(session.ExportIDToError(ctx)) + timer.Update() + if trafficState.ReaderSwitchToDirectCopy { + // XTLS Vision processes struct TLS Conn's input and rawInput + if inputBuffer, err := buf.ReadFrom(input); err == nil { + if !inputBuffer.IsEmpty() { + buffer, _ = buf.MergeMulti(buffer, inputBuffer) + } + } + if rawInputBuffer, err := buf.ReadFrom(rawInput); err == nil { + if !rawInputBuffer.IsEmpty() { + buffer, _ = buf.MergeMulti(buffer, rawInputBuffer) } - } else if remainingContent > 0 || remainingPadding > 0 { - withinPaddingBuffers = true - } else { - withinPaddingBuffers = false } } - if *numberOfPacketToFilter > 0 { - XtlsFilterTls(buffer, numberOfPacketToFilter, enableXtls, isTLS12orAbove, isTLS, cipher, remainingServerHello, ctx) - } - timer.Update() if werr := writer.WriteMultiBuffer(buffer); werr != nil { return werr } @@ -277,68 +220,27 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater } // XtlsWrite filter and write xtls protocol -func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, - ctx context.Context, numberOfPacketToFilter *int, enableXtls *bool, isTLS12orAbove *bool, isTLS *bool, - cipher *uint16, remainingServerHello *int32, -) error { +func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, trafficState *proxy.TrafficState, ctx context.Context) error { err := func() error { var ct stats.Counter - isPadding := true - shouldSwitchToDirectCopy := false for { buffer, err := reader.ReadMultiBuffer() + if trafficState.WriterSwitchToDirectCopy { + if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.CanSpliceCopy == 2 { + inbound.CanSpliceCopy = 1 // force the value to 1, don't use setter + } + rawConn, _, writerCounter := proxy.UnwrapRawConn(conn) + writer = buf.NewWriter(rawConn) + ct = writerCounter + trafficState.WriterSwitchToDirectCopy = false + } if !buffer.IsEmpty() { - if *numberOfPacketToFilter > 0 { - XtlsFilterTls(buffer, numberOfPacketToFilter, enableXtls, isTLS12orAbove, isTLS, cipher, remainingServerHello, ctx) + if ct != nil { + ct.Add(int64(buffer.Len())) } - if isPadding { - buffer = ReshapeMultiBuffer(ctx, buffer) - var xtlsSpecIndex int - for i, b := range buffer { - if *isTLS && b.Len() >= 6 && bytes.Equal(tlsApplicationDataStart, b.BytesTo(3)) { - var command byte = CommandPaddingEnd - if *enableXtls { - shouldSwitchToDirectCopy = true - xtlsSpecIndex = i - command = CommandPaddingDirect - } - isPadding = false - buffer[i] = XtlsPadding(b, command, nil, *isTLS, ctx) - break - } else if !*isTLS12orAbove && *numberOfPacketToFilter <= 1 { // For compatibility with earlier vision receiver, we finish padding 1 packet early - isPadding = false - buffer[i] = XtlsPadding(b, CommandPaddingEnd, nil, *isTLS, ctx) - break - } - buffer[i] = XtlsPadding(b, CommandPaddingContinue, nil, *isTLS, ctx) - } - if shouldSwitchToDirectCopy { - encryptBuffer, directBuffer := buf.SplitMulti(buffer, xtlsSpecIndex+1) - if !encryptBuffer.IsEmpty() { - timer.Update() - if werr := writer.WriteMultiBuffer(encryptBuffer); werr != nil { - return werr - } - } - time.Sleep(5 * time.Millisecond) // for some device, the first xtls direct packet fails without this delay - - if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.CanSpliceCopy == 2 { - inbound.CanSpliceCopy = 1 // force the value to 1, don't use setter - } - buffer = directBuffer - rawConn, _, writerCounter := proxy.UnwrapRawConn(conn) - writer = buf.NewWriter(rawConn) - ct = writerCounter - } - } - if !buffer.IsEmpty() { - if ct != nil { - ct.Add(int64(buffer.Len())) - } - timer.Update() - if werr := writer.WriteMultiBuffer(buffer); werr != nil { - return werr - } + timer.Update() + if werr := writer.WriteMultiBuffer(buffer); werr != nil { + return werr } } if err != nil { @@ -351,201 +253,3 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate } return nil } - -// XtlsFilterTls filter and recognize tls 1.3 and other info -func XtlsFilterTls(buffer buf.MultiBuffer, numberOfPacketToFilter *int, enableXtls *bool, isTLS12orAbove *bool, isTLS *bool, - cipher *uint16, remainingServerHello *int32, ctx context.Context, -) { - for _, b := range buffer { - *numberOfPacketToFilter-- - if b.Len() >= 6 { - startsBytes := b.BytesTo(6) - if bytes.Equal(tlsServerHandShakeStart, startsBytes[:3]) && startsBytes[5] == tlsHandshakeTypeServerHello { - *remainingServerHello = (int32(startsBytes[3])<<8 | int32(startsBytes[4])) + 5 - *isTLS12orAbove = true - *isTLS = true - if b.Len() >= 79 && *remainingServerHello >= 79 { - sessionIdLen := int32(b.Byte(43)) - cipherSuite := b.BytesRange(43+sessionIdLen+1, 43+sessionIdLen+3) - *cipher = uint16(cipherSuite[0])<<8 | uint16(cipherSuite[1]) - } else { - newError("XtlsFilterTls short server hello, tls 1.2 or older? ", b.Len(), " ", *remainingServerHello).WriteToLog(session.ExportIDToError(ctx)) - } - } else if bytes.Equal(tlsClientHandShakeStart, startsBytes[:2]) && startsBytes[5] == tlsHandshakeTypeClientHello { - *isTLS = true - newError("XtlsFilterTls found tls client hello! ", buffer.Len()).WriteToLog(session.ExportIDToError(ctx)) - } - } - if *remainingServerHello > 0 { - end := *remainingServerHello - if end > b.Len() { - end = b.Len() - } - *remainingServerHello -= b.Len() - if bytes.Contains(b.BytesTo(end), tls13SupportedVersions) { - v, ok := Tls13CipherSuiteDic[*cipher] - if !ok { - v = "Old cipher: " + strconv.FormatUint(uint64(*cipher), 16) - } else if v != "TLS_AES_128_CCM_8_SHA256" { - *enableXtls = true - } - newError("XtlsFilterTls found tls 1.3! ", b.Len(), " ", v).WriteToLog(session.ExportIDToError(ctx)) - *numberOfPacketToFilter = 0 - return - } else if *remainingServerHello <= 0 { - newError("XtlsFilterTls found tls 1.2! ", b.Len()).WriteToLog(session.ExportIDToError(ctx)) - *numberOfPacketToFilter = 0 - return - } - newError("XtlsFilterTls inconclusive server hello ", b.Len(), " ", *remainingServerHello).WriteToLog(session.ExportIDToError(ctx)) - } - if *numberOfPacketToFilter <= 0 { - newError("XtlsFilterTls stop filtering", buffer.Len()).WriteToLog(session.ExportIDToError(ctx)) - } - } -} - -// ReshapeMultiBuffer prepare multi buffer for padding stucture (max 21 bytes) -func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBuffer { - needReshape := 0 - for _, b := range buffer { - if b.Len() >= buf.Size-21 { - needReshape += 1 - } - } - if needReshape == 0 { - return buffer - } - mb2 := make(buf.MultiBuffer, 0, len(buffer)+needReshape) - toPrint := "" - for i, buffer1 := range buffer { - if buffer1.Len() >= buf.Size-21 { - index := int32(bytes.LastIndex(buffer1.Bytes(), tlsApplicationDataStart)) - if index <= 0 || index > buf.Size-21 { - index = buf.Size / 2 - } - buffer2 := buf.New() - buffer2.Write(buffer1.BytesFrom(index)) - buffer1.Resize(0, index) - mb2 = append(mb2, buffer1, buffer2) - toPrint += " " + strconv.Itoa(int(buffer1.Len())) + " " + strconv.Itoa(int(buffer2.Len())) - } else { - mb2 = append(mb2, buffer1) - toPrint += " " + strconv.Itoa(int(buffer1.Len())) - } - buffer[i] = nil - } - buffer = buffer[:0] - newError("ReshapeMultiBuffer ", toPrint).WriteToLog(session.ExportIDToError(ctx)) - return mb2 -} - -// XtlsPadding add padding to eliminate length siganature during tls handshake -func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool, ctx context.Context) *buf.Buffer { - var contentLen int32 = 0 - var paddingLen int32 = 0 - if b != nil { - contentLen = b.Len() - } - if contentLen < 900 && longPadding { - l, err := rand.Int(rand.Reader, big.NewInt(500)) - if err != nil { - newError("failed to generate padding").Base(err).WriteToLog(session.ExportIDToError(ctx)) - } - paddingLen = int32(l.Int64()) + 900 - contentLen - } else { - l, err := rand.Int(rand.Reader, big.NewInt(256)) - if err != nil { - newError("failed to generate padding").Base(err).WriteToLog(session.ExportIDToError(ctx)) - } - paddingLen = int32(l.Int64()) - } - if paddingLen > buf.Size-21-contentLen { - paddingLen = buf.Size - 21 - contentLen - } - newbuffer := buf.New() - if userUUID != nil { - newbuffer.Write(*userUUID) - *userUUID = nil - } - newbuffer.Write([]byte{command, byte(contentLen >> 8), byte(contentLen), byte(paddingLen >> 8), byte(paddingLen)}) - if b != nil { - newbuffer.Write(b.Bytes()) - b.Release() - b = nil - } - newbuffer.Extend(paddingLen) - newError("XtlsPadding ", contentLen, " ", paddingLen, " ", command).WriteToLog(session.ExportIDToError(ctx)) - return newbuffer -} - -// XtlsUnpadding remove padding and parse command -func XtlsUnpadding(ctx context.Context, buffer buf.MultiBuffer, userUUID []byte, remainingContent *int32, remainingPadding *int32, currentCommand *int) buf.MultiBuffer { - posindex := 0 - var posByte int32 = 0 - if *remainingContent == -1 && *remainingPadding == -1 { - for i, b := range buffer { - if b.Len() >= 21 && bytes.Equal(userUUID, b.BytesTo(16)) { - posindex = i - posByte = 16 - *remainingContent = 0 - *remainingPadding = 0 - *currentCommand = 0 - break - } - } - } - if *remainingContent == -1 && *remainingPadding == -1 { - return buffer - } - mb2 := make(buf.MultiBuffer, 0, len(buffer)) - for i := 0; i < posindex; i++ { - newbuffer := buf.New() - newbuffer.Write(buffer[i].Bytes()) - mb2 = append(mb2, newbuffer) - } - for i := posindex; i < len(buffer); i++ { - b := buffer[i] - for posByte < b.Len() { - if *remainingContent <= 0 && *remainingPadding <= 0 { - if *currentCommand == 1 { // possible buffer after padding, no need to worry about xtls (command 2) - len := b.Len() - posByte - newbuffer := buf.New() - newbuffer.Write(b.BytesRange(posByte, posByte+len)) - mb2 = append(mb2, newbuffer) - posByte += len - } else { - paddingInfo := b.BytesRange(posByte, posByte+5) - *currentCommand = int(paddingInfo[0]) - *remainingContent = int32(paddingInfo[1])<<8 | int32(paddingInfo[2]) - *remainingPadding = int32(paddingInfo[3])<<8 | int32(paddingInfo[4]) - newError("Xtls Unpadding new block", i, " ", posByte, " content ", *remainingContent, " padding ", *remainingPadding, " ", paddingInfo[0]).WriteToLog(session.ExportIDToError(ctx)) - posByte += 5 - } - } else if *remainingContent > 0 { - len := *remainingContent - if b.Len() < posByte+*remainingContent { - len = b.Len() - posByte - } - newbuffer := buf.New() - newbuffer.Write(b.BytesRange(posByte, posByte+len)) - mb2 = append(mb2, newbuffer) - *remainingContent -= len - posByte += len - } else { // remainingPadding > 0 - len := *remainingPadding - if b.Len() < posByte+*remainingPadding { - len = b.Len() - posByte - } - *remainingPadding -= len - posByte += len - } - if posByte == b.Len() { - posByte = 0 - break - } - } - } - buf.ReleaseMulti(buffer) - return mb2 -} diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index 388aeecb..4cd3fcb1 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -28,6 +28,7 @@ import ( feature_inbound "github.com/xtls/xray-core/features/inbound" "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/features/routing" + "github.com/xtls/xray-core/proxy" "github.com/xtls/xray-core/proxy/vless" "github.com/xtls/xray-core/proxy/vless/encoding" "github.com/xtls/xray-core/transport/internet/reality" @@ -510,13 +511,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s serverReader := link.Reader // .(*pipe.Reader) serverWriter := link.Writer // .(*pipe.Writer) - enableXtls := false - isTLS12orAbove := false - isTLS := false - var cipher uint16 = 0 - var remainingServerHello int32 = -1 - numberOfPacketToFilter := 8 - + trafficState := proxy.NewTrafficState(account.ID.Bytes()) postRequest := func() error { defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly) @@ -527,8 +522,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s if requestAddons.Flow == vless.XRV { ctx1 := session.ContextWithInbound(ctx, nil) // TODO enable splice - err = encoding.XtlsRead(clientReader, serverWriter, timer, connection, input, rawInput, ctx1, account.ID.Bytes(), - &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) + err = encoding.XtlsRead(clientReader, serverWriter, timer, connection, input, rawInput, trafficState, ctx1) } else { // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer)) @@ -550,19 +544,11 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s } // default: clientWriter := bufferWriter - clientWriter := encoding.EncodeBodyAddons(bufferWriter, request, responseAddons) - userUUID := account.ID.Bytes() + clientWriter := encoding.EncodeBodyAddons(bufferWriter, request, requestAddons, trafficState, ctx) multiBuffer, err1 := serverReader.ReadMultiBuffer() if err1 != nil { return err1 // ... } - if requestAddons.Flow == vless.XRV { - encoding.XtlsFilterTls(multiBuffer, &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello, ctx) - multiBuffer = encoding.ReshapeMultiBuffer(ctx, multiBuffer) - for i, b := range multiBuffer { - multiBuffer[i] = encoding.XtlsPadding(b, encoding.CommandPaddingContinue, &userUUID, isTLS, ctx) - } - } if err := clientWriter.WriteMultiBuffer(multiBuffer); err != nil { return err // ... } @@ -573,8 +559,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s var err error if requestAddons.Flow == vless.XRV { - err = encoding.XtlsWrite(serverReader, clientWriter, timer, connection, ctx, &numberOfPacketToFilter, - &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) + err = encoding.XtlsWrite(serverReader, clientWriter, timer, connection, trafficState, ctx) } else { // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer)) diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index bc2e6625..cd30617c 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -22,6 +22,7 @@ import ( "github.com/xtls/xray-core/common/xudp" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/policy" + "github.com/xtls/xray-core/proxy" "github.com/xtls/xray-core/proxy/vless" "github.com/xtls/xray-core/proxy/vless/encoding" "github.com/xtls/xray-core/transport" @@ -183,13 +184,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte clientReader := link.Reader // .(*pipe.Reader) clientWriter := link.Writer // .(*pipe.Writer) - enableXtls := false - isTLS12orAbove := false - isTLS := false - var cipher uint16 = 0 - var remainingServerHello int32 = -1 - numberOfPacketToFilter := 8 - + trafficState := proxy.NewTrafficState(account.ID.Bytes()) if request.Command == protocol.RequestCommandUDP && h.cone && request.Port != 53 && request.Port != 443 { request.Command = protocol.RequestCommandMux request.Address = net.DomainAddress("v1.mux.cool") @@ -205,22 +200,14 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } // default: serverWriter := bufferWriter - serverWriter := encoding.EncodeBodyAddons(bufferWriter, request, requestAddons) + serverWriter := encoding.EncodeBodyAddons(bufferWriter, request, requestAddons, trafficState, ctx) if request.Command == protocol.RequestCommandMux && request.Port == 666 { serverWriter = xudp.NewPacketWriter(serverWriter, target, xudp.GetGlobalID(ctx)) } - userUUID := account.ID.Bytes() timeoutReader, ok := clientReader.(buf.TimeoutReader) if ok { multiBuffer, err1 := timeoutReader.ReadMultiBufferTimeout(time.Millisecond * 500) if err1 == nil { - if requestAddons.Flow == vless.XRV { - encoding.XtlsFilterTls(multiBuffer, &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello, ctx) - multiBuffer = encoding.ReshapeMultiBuffer(ctx, multiBuffer) - for i, b := range multiBuffer { - multiBuffer[i] = encoding.XtlsPadding(b, encoding.CommandPaddingContinue, &userUUID, isTLS, ctx) - } - } if err := serverWriter.WriteMultiBuffer(multiBuffer); err != nil { return err // ... } @@ -228,10 +215,9 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte return err1 } else if requestAddons.Flow == vless.XRV { mb := make(buf.MultiBuffer, 1) - mb[0] = encoding.XtlsPadding(nil, encoding.CommandPaddingContinue, &userUUID, true, ctx) // we do a long padding to hide vless header newError("Insert padding with empty content to camouflage VLESS header ", mb.Len()).WriteToLog(session.ExportIDToError(ctx)) if err := serverWriter.WriteMultiBuffer(mb); err != nil { - return err + return err // ... } } } else { @@ -254,8 +240,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } } ctx1 := session.ContextWithOutbound(ctx, nil) // TODO enable splice - err = encoding.XtlsWrite(clientReader, serverWriter, timer, conn, ctx1, &numberOfPacketToFilter, - &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) + err = encoding.XtlsWrite(clientReader, serverWriter, timer, conn, trafficState, ctx1) } else { // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer)) @@ -286,8 +271,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } if requestAddons.Flow == vless.XRV { - err = encoding.XtlsRead(serverReader, clientWriter, timer, conn, input, rawInput, ctx, account.ID.Bytes(), - &numberOfPacketToFilter, &enableXtls, &isTLS12orAbove, &isTLS, &cipher, &remainingServerHello) + err = encoding.XtlsRead(serverReader, clientWriter, timer, conn, input, rawInput, trafficState, ctx) } else { // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer)) From 490591efcc04fa27719d4f995e37580a971f2352 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 00:16:02 +0000 Subject: [PATCH 142/867] Bump docker/login-action from 2 to 3 Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3. - [Release notes](https://github.com/docker/login-action/releases) - [Commits](https://github.com/docker/login-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/login-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index b7a3292b..39d0ef31 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -23,7 +23,7 @@ jobs: type=ref,event=pr type=semver,pattern={{version}} - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} From 852a7d41620bf8a16c113eddb22e47ba89cf9a3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 00:16:05 +0000 Subject: [PATCH 143/867] Bump docker/setup-buildx-action from 2 to 3 Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-buildx-action/releases) - [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-buildx-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 39d0ef31..a35d2b70 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -33,7 +33,7 @@ jobs: name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Build and push uses: docker/build-push-action@v4 with: From 850f617a6f940d026d34ffad92755c761caf34d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 00:16:09 +0000 Subject: [PATCH 144/867] Bump docker/build-push-action from 4 to 5 Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v4...v5) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a35d2b70..0ced18da 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -35,7 +35,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 From e66797e79a95871a1937bd366ce17821e9945b5e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 00:16:13 +0000 Subject: [PATCH 145/867] Bump docker/setup-qemu-action from 2 to 3 Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2 to 3. - [Release notes](https://github.com/docker/setup-qemu-action/releases) - [Commits](https://github.com/docker/setup-qemu-action/compare/v2...v3) --- updated-dependencies: - dependency-name: docker/setup-qemu-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0ced18da..d3c157ca 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -31,7 +31,7 @@ jobs: - # Add support for more platforms with QEMU (optional) # https://github.com/docker/setup-qemu-action name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push From 92bec537f1d7b7dd414e00d947694adc7b0fef4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 00:16:17 +0000 Subject: [PATCH 146/867] Bump docker/metadata-action from 4 to 5 Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4 to 5. - [Release notes](https://github.com/docker/metadata-action/releases) - [Upgrade guide](https://github.com/docker/metadata-action/blob/master/UPGRADE.md) - [Commits](https://github.com/docker/metadata-action/compare/v4...v5) --- updated-dependencies: - dependency-name: docker/metadata-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d3c157ca..b839d986 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 - name: Docker metadata id: meta - uses: docker/metadata-action@v4 + uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository_owner }}/xray-core flavor: latest=true From 585d5ba7c8b64f6da60837546a70bbcfd2350c64 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 17 Sep 2023 12:55:54 -0400 Subject: [PATCH 147/867] Fix Vision reader --- proxy/proxy.go | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 142acb77..f07af8c3 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -159,21 +159,15 @@ func (w *VisionReader) ReadMultiBuffer() (buf.MultiBuffer, error) { } } buffer = mb2 - if w.trafficState.RemainingContent == 0 && w.trafficState.RemainingPadding == 0 { - if w.trafficState.CurrentCommand == 1 { - w.trafficState.WithinPaddingBuffers = false - } else if w.trafficState.CurrentCommand == 2 { - w.trafficState.WithinPaddingBuffers = false - w.trafficState.ReaderSwitchToDirectCopy = true - } else if w.trafficState.CurrentCommand == 0 { - w.trafficState.WithinPaddingBuffers = true - } else { - newError("XtlsRead unknown command ", w.trafficState.CurrentCommand, buffer.Len()).WriteToLog(session.ExportIDToError(w.ctx)) - } - } else if w.trafficState.RemainingContent > 0 || w.trafficState.RemainingPadding > 0 { + if w.trafficState.RemainingContent > 0 || w.trafficState.RemainingPadding > 0 || w.trafficState.CurrentCommand == 0 { w.trafficState.WithinPaddingBuffers = true - } else { + } else if w.trafficState.CurrentCommand == 1 { w.trafficState.WithinPaddingBuffers = false + } else if w.trafficState.CurrentCommand == 2 { + w.trafficState.WithinPaddingBuffers = false + w.trafficState.ReaderSwitchToDirectCopy = true + } else { + newError("XtlsRead unknown command ", w.trafficState.CurrentCommand, buffer.Len()).WriteToLog(session.ExportIDToError(w.ctx)) } } if w.trafficState.NumberOfPacketToFilter > 0 { From 8b0b8793ed4d3be9a1baa2911f4b149d82aae574 Mon Sep 17 00:00:00 2001 From: 0xland <98829546+0xland@users.noreply.github.com> Date: Mon, 18 Sep 2023 03:35:42 +0100 Subject: [PATCH 148/867] Add Streisand to README/GUI Clients --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ecf67e7d..a91c4373 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ - iOS & macOS arm64 - [Mango](https://github.com/arror/Mango) - [FoXray](https://apps.apple.com/app/foxray/id6448898396) + - [Streisand](https://apps.apple.com/app/streisand/id6450534064) - macOS arm64 & x64 - [V2rayU](https://github.com/yanue/V2rayU) - [V2RayXS](https://github.com/tzmax/V2RayXS) From 444db2acfffa82b85f94aada2a8092ace07349e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 00:57:24 +0000 Subject: [PATCH 149/867] Bump golang.org/x/crypto from 0.12.0 to 0.13.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.12.0 to 0.13.0. - [Commits](https://github.com/golang/crypto/compare/v0.12.0...v0.13.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 711b8e47..beb23f1f 100644 --- a/go.mod +++ b/go.mod @@ -20,10 +20,10 @@ require ( github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 go4.org/netipx v0.0.0-20230824141953-6213f710f925 - golang.org/x/crypto v0.12.0 + golang.org/x/crypto v0.13.0 golang.org/x/net v0.14.0 golang.org/x/sync v0.3.0 - golang.org/x/sys v0.11.0 + golang.org/x/sys v0.12.0 google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 @@ -50,7 +50,7 @@ require ( go.uber.org/atomic v1.11.0 // indirect golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/text v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.12.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect diff --git a/go.sum b/go.sum index 71abf747..36d47ce3 100644 --- a/go.sum +++ b/go.sum @@ -180,8 +180,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= +golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= +golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 h1:Di6/M8l0O2lCLc6VVRWhgCiApHV8MnQurBnFSHsQtNY= golang.org/x/exp v0.0.0-20230725093048-515e97ebf090/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= @@ -227,14 +227,14 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= From 6ec82a6792dd89893b5b64eb4d1696bd8eb72cf4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:04:04 +0000 Subject: [PATCH 150/867] Bump github.com/miekg/dns from 1.1.55 to 1.1.56 Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.55 to 1.1.56. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.55...v1.1.56) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index beb23f1f..137b090f 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.5.9 github.com/gorilla/websocket v1.5.0 - github.com/miekg/dns v1.1.55 + github.com/miekg/dns v1.1.56 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.38.1 @@ -21,7 +21,7 @@ require ( github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 go4.org/netipx v0.0.0-20230824141953-6213f710f925 golang.org/x/crypto v0.13.0 - golang.org/x/net v0.14.0 + golang.org/x/net v0.15.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.12.0 google.golang.org/grpc v1.57.0 @@ -52,7 +52,7 @@ require ( golang.org/x/mod v0.12.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.12.0 // indirect + golang.org/x/tools v0.13.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 36d47ce3..bb87c79f 100644 --- a/go.sum +++ b/go.sum @@ -90,8 +90,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= -github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= -github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= +github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE= +github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= @@ -202,8 +202,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= +golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -246,8 +246,8 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= -golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= +golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= +golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 36321b8750846eaf1e64747cc0be88878edc0e76 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:04:05 +0000 Subject: [PATCH 151/867] Bump google.golang.org/grpc from 1.57.0 to 1.58.1 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.57.0 to 1.58.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.57.0...v1.58.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 137b090f..e98a6f11 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( golang.org/x/net v0.15.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.12.0 - google.golang.org/grpc v1.57.0 + google.golang.org/grpc v1.58.1 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index bb87c79f..d4b097b9 100644 --- a/go.sum +++ b/go.sum @@ -270,8 +270,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= -google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= +google.golang.org/grpc v1.58.1 h1:OL+Vz23DTtrrldqHK49FUOPHyY75rvFqJfXC84NYW58= +google.golang.org/grpc v1.58.1/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From cf575be678682b9e1aa02d3c8ec8f7b03874d1b0 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 21 Sep 2023 15:34:30 -0400 Subject: [PATCH 152/867] Fix unwrap tls conn --- proxy/proxy.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index f07af8c3..a14ddace 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -9,7 +9,6 @@ import ( "bytes" "context" "crypto/rand" - gotls "crypto/tls" "io" "math/big" "runtime" @@ -449,7 +448,7 @@ func UnwrapRawConn(conn net.Conn) (net.Conn, stats.Counter, stats.Counter) { readCounter = statConn.ReadCounter writerCounter = statConn.WriteCounter } - if xc, ok := conn.(*gotls.Conn); ok { + if xc, ok := conn.(*tls.Conn); ok { conn = xc.NetConn() } else if utlsConn, ok := conn.(*tls.UConn); ok { conn = utlsConn.NetConn() From 4f6042c69f41b7b9632ae421fc99c14532319cd5 Mon Sep 17 00:00:00 2001 From: cty123 Date: Tue, 19 Sep 2023 23:03:19 +0200 Subject: [PATCH 153/867] feat(dns): Support DNS queryStrategy config per NameServer. --- app/dns/config.pb.go | 183 +++++++++++++++++--------------- app/dns/config.proto | 1 + app/dns/nameserver.go | 46 ++++++-- app/dns/nameserver_doh.go | 38 ++++--- app/dns/nameserver_doh_test.go | 50 ++++++++- app/dns/nameserver_quic.go | 30 +++--- app/dns/nameserver_quic_test.go | 48 ++++++++- app/dns/nameserver_tcp.go | 47 ++++---- app/dns/nameserver_tcp_test.go | 52 ++++++++- infra/conf/dns.go | 52 +++++---- 10 files changed, 379 insertions(+), 168 deletions(-) diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index d5bc18d2..8a066a9e 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -134,6 +134,7 @@ type NameServer struct { PrioritizedDomain []*NameServer_PriorityDomain `protobuf:"bytes,2,rep,name=prioritized_domain,json=prioritizedDomain,proto3" json:"prioritized_domain,omitempty"` Geoip []*router.GeoIP `protobuf:"bytes,3,rep,name=geoip,proto3" json:"geoip,omitempty"` OriginalRules []*NameServer_OriginalRule `protobuf:"bytes,4,rep,name=original_rules,json=originalRules,proto3" json:"original_rules,omitempty"` + QueryStrategy QueryStrategy `protobuf:"varint,7,opt,name=query_strategy,json=queryStrategy,proto3,enum=xray.app.dns.QueryStrategy" json:"query_strategy,omitempty"` } func (x *NameServer) Reset() { @@ -210,6 +211,13 @@ func (x *NameServer) GetOriginalRules() []*NameServer_OriginalRule { return nil } +func (x *NameServer) GetQueryStrategy() QueryStrategy { + if x != nil { + return x.QueryStrategy + } + return QueryStrategy_USE_IP +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -538,7 +546,7 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xee, 0x03, 0x0a, 0x0a, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb2, 0x04, 0x0a, 0x0a, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, @@ -559,77 +567,81 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x52, - 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x1a, 0x5e, - 0x0a, 0x0e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, - 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x36, - 0x0a, 0x0c, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x75, - 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0xef, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x3f, 0x0a, 0x0b, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, - 0x74, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0b, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x73, 0x12, 0x39, 0x0a, 0x0b, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, - 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x39, 0x0a, - 0x05, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x42, 0x02, 0x18, - 0x01, 0x52, 0x05, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, - 0x68, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x0b, 0x73, - 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, - 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x22, 0x0a, 0x0c, - 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, - 0x12, 0x42, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x67, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, - 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x64, - 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x36, - 0x0a, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, - 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, - 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x1a, 0x55, 0x0a, 0x0a, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x31, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x92, 0x01, - 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, - 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, - 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x70, - 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x2a, 0x45, 0x0a, 0x12, 0x44, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, - 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x64, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x4b, 0x65, 0x79, 0x77, 0x6f, - 0x72, 0x64, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x65, 0x67, 0x65, 0x78, 0x10, 0x03, 0x2a, - 0x35, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, - 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, - 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, - 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x42, 0x46, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, - 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0xaa, - 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x44, 0x6e, 0x73, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x42, + 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x67, 0x79, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, + 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, + 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, + 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, + 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, + 0x69, 0x6e, 0x1a, 0x36, 0x0a, 0x0c, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, + 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0xef, 0x05, 0x0a, 0x06, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3f, 0x0a, 0x0b, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x64, + 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0b, 0x4e, 0x61, 0x6d, 0x65, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x12, 0x39, 0x0a, 0x0b, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x72, 0x12, 0x39, 0x0a, 0x05, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x42, 0x02, 0x18, 0x01, 0x52, 0x05, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, + 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, + 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x74, 0x61, + 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, + 0x67, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, + 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, + 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, + 0x61, 0x63, 0x68, 0x65, 0x12, 0x42, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, + 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, + 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, + 0x63, 0x6b, 0x12, 0x36, 0x0a, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, + 0x61, 0x63, 0x6b, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x1a, 0x55, 0x0a, 0x0a, 0x48, 0x6f, + 0x73, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x31, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x1a, 0x92, 0x01, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, + 0x67, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, + 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, + 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x70, 0x12, + 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x2a, 0x45, 0x0a, 0x12, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, + 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, + 0x53, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x4b, + 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x65, 0x67, 0x65, + 0x78, 0x10, 0x03, 0x2a, 0x35, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x00, + 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x01, 0x12, 0x0b, 0x0a, + 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x42, 0x46, 0x0a, 0x10, 0x63, 0x6f, + 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x50, 0x01, + 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, + 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x44, + 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -664,19 +676,20 @@ var file_app_dns_config_proto_depIdxs = []int32{ 4, // 1: xray.app.dns.NameServer.prioritized_domain:type_name -> xray.app.dns.NameServer.PriorityDomain 9, // 2: xray.app.dns.NameServer.geoip:type_name -> xray.app.router.GeoIP 5, // 3: xray.app.dns.NameServer.original_rules:type_name -> xray.app.dns.NameServer.OriginalRule - 8, // 4: xray.app.dns.Config.NameServers:type_name -> xray.common.net.Endpoint - 2, // 5: xray.app.dns.Config.name_server:type_name -> xray.app.dns.NameServer - 6, // 6: xray.app.dns.Config.Hosts:type_name -> xray.app.dns.Config.HostsEntry - 7, // 7: xray.app.dns.Config.static_hosts:type_name -> xray.app.dns.Config.HostMapping - 1, // 8: xray.app.dns.Config.query_strategy:type_name -> xray.app.dns.QueryStrategy - 0, // 9: xray.app.dns.NameServer.PriorityDomain.type:type_name -> xray.app.dns.DomainMatchingType - 10, // 10: xray.app.dns.Config.HostsEntry.value:type_name -> xray.common.net.IPOrDomain - 0, // 11: xray.app.dns.Config.HostMapping.type:type_name -> xray.app.dns.DomainMatchingType - 12, // [12:12] is the sub-list for method output_type - 12, // [12:12] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 1, // 4: xray.app.dns.NameServer.query_strategy:type_name -> xray.app.dns.QueryStrategy + 8, // 5: xray.app.dns.Config.NameServers:type_name -> xray.common.net.Endpoint + 2, // 6: xray.app.dns.Config.name_server:type_name -> xray.app.dns.NameServer + 6, // 7: xray.app.dns.Config.Hosts:type_name -> xray.app.dns.Config.HostsEntry + 7, // 8: xray.app.dns.Config.static_hosts:type_name -> xray.app.dns.Config.HostMapping + 1, // 9: xray.app.dns.Config.query_strategy:type_name -> xray.app.dns.QueryStrategy + 0, // 10: xray.app.dns.NameServer.PriorityDomain.type:type_name -> xray.app.dns.DomainMatchingType + 10, // 11: xray.app.dns.Config.HostsEntry.value:type_name -> xray.common.net.IPOrDomain + 0, // 12: xray.app.dns.Config.HostMapping.type:type_name -> xray.app.dns.DomainMatchingType + 13, // [13:13] is the sub-list for method output_type + 13, // [13:13] is the sub-list for method input_type + 13, // [13:13] is the sub-list for extension type_name + 13, // [13:13] is the sub-list for extension extendee + 0, // [0:13] is the sub-list for field type_name } func init() { file_app_dns_config_proto_init() } diff --git a/app/dns/config.proto b/app/dns/config.proto index e2059e38..2c420651 100644 --- a/app/dns/config.proto +++ b/app/dns/config.proto @@ -28,6 +28,7 @@ message NameServer { repeated PriorityDomain prioritized_domain = 2; repeated xray.app.router.GeoIP geoip = 3; repeated OriginalRule original_rules = 4; + QueryStrategy query_strategy = 7; } enum DomainMatchingType { diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index d6f9b272..d5423b84 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -35,7 +35,7 @@ type Client struct { var errExpectedIPNonMatch = errors.New("expectIPs not match") // NewServer creates a name server object according to the network destination url. -func NewServer(dest net.Destination, dispatcher routing.Dispatcher) (Server, error) { +func NewServer(dest net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) (Server, error) { if address := dest.Address; address.Family().IsDomain() { u, err := url.Parse(address.Domain()) if err != nil { @@ -45,15 +45,15 @@ func NewServer(dest net.Destination, dispatcher routing.Dispatcher) (Server, err case strings.EqualFold(u.String(), "localhost"): return NewLocalNameServer(), nil case strings.EqualFold(u.Scheme, "https"): // DOH Remote mode - return NewDoHNameServer(u, dispatcher) + return NewDoHNameServer(u, dispatcher, queryStrategy) case strings.EqualFold(u.Scheme, "https+local"): // DOH Local mode - return NewDoHLocalNameServer(u), nil + return NewDoHLocalNameServer(u, queryStrategy), nil case strings.EqualFold(u.Scheme, "quic+local"): // DNS-over-QUIC Local mode - return NewQUICNameServer(u) + return NewQUICNameServer(u, queryStrategy) case strings.EqualFold(u.Scheme, "tcp"): // DNS-over-TCP Remote mode - return NewTCPNameServer(u, dispatcher) + return NewTCPNameServer(u, dispatcher, queryStrategy) case strings.EqualFold(u.Scheme, "tcp+local"): // DNS-over-TCP Local mode - return NewTCPLocalNameServer(u) + return NewTCPLocalNameServer(u, queryStrategy) case strings.EqualFold(u.String(), "fakedns"): return NewFakeDNSServer(), nil } @@ -68,12 +68,19 @@ func NewServer(dest net.Destination, dispatcher routing.Dispatcher) (Server, err } // NewClient creates a DNS client managing a name server with client IP, domain rules and expected IPs. -func NewClient(ctx context.Context, ns *NameServer, clientIP net.IP, container router.GeoIPMatcherContainer, matcherInfos *[]*DomainMatcherInfo, updateDomainRule func(strmatcher.Matcher, int, []*DomainMatcherInfo) error) (*Client, error) { +func NewClient( + ctx context.Context, + ns *NameServer, + clientIP net.IP, + container router.GeoIPMatcherContainer, + matcherInfos *[]*DomainMatcherInfo, + updateDomainRule func(strmatcher.Matcher, int, []*DomainMatcherInfo) error, +) (*Client, error) { client := &Client{} err := core.RequireFeatures(ctx, func(dispatcher routing.Dispatcher) error { // Create a new server for each client for now - server, err := NewServer(ns.Address.AsDestination(), dispatcher) + server, err := NewServer(ns.Address.AsDestination(), dispatcher, ns.GetQueryStrategy()) if err != nil { return newError("failed to create nameserver").Base(err).AtWarning() } @@ -160,7 +167,7 @@ func NewClient(ctx context.Context, ns *NameServer, clientIP net.IP, container r func NewSimpleClient(ctx context.Context, endpoint *net.Endpoint, clientIP net.IP) (*Client, error) { client := &Client{} err := core.RequireFeatures(ctx, func(dispatcher routing.Dispatcher) error { - server, err := NewServer(endpoint.AsDestination(), dispatcher) + server, err := NewServer(endpoint.AsDestination(), dispatcher, QueryStrategy_USE_IP) if err != nil { return newError("failed to create nameserver").Base(err).AtWarning() } @@ -218,3 +225,24 @@ func (c *Client) MatchExpectedIPs(domain string, ips []net.IP) ([]net.IP, error) newError("domain ", domain, " expectIPs ", newIps, " matched at server ", c.Name()).AtDebug().WriteToLog() return newIps, nil } + +func ResolveIpOptionOverride(queryStrategy QueryStrategy, ipOption dns.IPOption) dns.IPOption { + switch queryStrategy { + case QueryStrategy_USE_IP: + return ipOption + case QueryStrategy_USE_IP4: + return dns.IPOption{ + IPv4Enable: ipOption.IPv4Enable, + IPv6Enable: false, + FakeEnable: false, + } + case QueryStrategy_USE_IP6: + return dns.IPOption{ + IPv4Enable: false, + IPv6Enable: ipOption.IPv6Enable, + FakeEnable: false, + } + default: + return ipOption + } +} diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index fecc5efb..8657e3fb 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -31,19 +31,20 @@ import ( type DoHNameServer struct { dispatcher routing.Dispatcher sync.RWMutex - ips map[string]*record - pub *pubsub.Service - cleanup *task.Periodic - reqID uint32 - httpClient *http.Client - dohURL string - name string + ips map[string]*record + pub *pubsub.Service + cleanup *task.Periodic + reqID uint32 + httpClient *http.Client + dohURL string + name string + queryStrategy QueryStrategy } // NewDoHNameServer creates DOH server object for remote resolving. -func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher) (*DoHNameServer, error) { +func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) (*DoHNameServer, error) { newError("DNS: created Remote DOH client for ", url.String()).AtInfo().WriteToLog() - s := baseDOHNameServer(url, "DOH") + s := baseDOHNameServer(url, "DOH", queryStrategy) s.dispatcher = dispatcher tr := &http.Transport{ @@ -90,9 +91,9 @@ func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher) (*DoHNameServ } // NewDoHLocalNameServer creates DOH client object for local resolving -func NewDoHLocalNameServer(url *url.URL) *DoHNameServer { +func NewDoHLocalNameServer(url *url.URL, queryStrategy QueryStrategy) *DoHNameServer { url.Scheme = "https" - s := baseDOHNameServer(url, "DOHL") + s := baseDOHNameServer(url, "DOHL", queryStrategy) tr := &http.Transport{ IdleConnTimeout: 90 * time.Second, ForceAttemptHTTP2: true, @@ -122,12 +123,13 @@ func NewDoHLocalNameServer(url *url.URL) *DoHNameServer { return s } -func baseDOHNameServer(url *url.URL, prefix string) *DoHNameServer { +func baseDOHNameServer(url *url.URL, prefix string, queryStrategy QueryStrategy) *DoHNameServer { s := &DoHNameServer{ - ips: make(map[string]*record), - pub: pubsub.NewService(), - name: prefix + "//" + url.Host, - dohURL: url.String(), + ips: make(map[string]*record), + pub: pubsub.NewService(), + name: prefix + "//" + url.Host, + dohURL: url.String(), + queryStrategy: queryStrategy, } s.cleanup = &task.Periodic{ Interval: time.Minute, @@ -353,6 +355,10 @@ func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt // QueryIP implements Server. func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, error) { // nolint: dupl fqdn := Fqdn(domain) + option = ResolveIpOptionOverride(s.queryStrategy, option) + if !option.IPv4Enable && !option.IPv6Enable { + return nil, dns_feature.ErrEmptyResponse + } if disableCache { newError("DNS cache is disabled. Querying IP for ", domain, " at ", s.name).AtDebug().WriteToLog() diff --git a/app/dns/nameserver_doh_test.go b/app/dns/nameserver_doh_test.go index f5cae5a6..ae4f9cc7 100644 --- a/app/dns/nameserver_doh_test.go +++ b/app/dns/nameserver_doh_test.go @@ -17,7 +17,7 @@ func TestDOHNameServer(t *testing.T) { url, err := url.Parse("https+local://1.1.1.1/dns-query") common.Must(err) - s := NewDoHLocalNameServer(url) + s := NewDoHLocalNameServer(url, QueryStrategy_USE_IP) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, @@ -34,7 +34,7 @@ func TestDOHNameServerWithCache(t *testing.T) { url, err := url.Parse("https+local://1.1.1.1/dns-query") common.Must(err) - s := NewDoHLocalNameServer(url) + s := NewDoHLocalNameServer(url, QueryStrategy_USE_IP) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, @@ -57,3 +57,49 @@ func TestDOHNameServerWithCache(t *testing.T) { t.Fatal(r) } } + +func TestDOHNameServerWithIPv4Override(t *testing.T) { + url, err := url.Parse("https+local://1.1.1.1/dns-query") + common.Must(err) + + s := NewDoHLocalNameServer(url, QueryStrategy_USE_IP4) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + IPv4Enable: true, + IPv6Enable: true, + }, false) + cancel() + common.Must(err) + if len(ips) == 0 { + t.Error("expect some ips, but got 0") + } + + for _, ip := range ips { + if len(ip) != net.IPv4len { + t.Error("expect only IPv4 response from DNS query") + } + } +} + +func TestDOHNameServerWithIPv6Override(t *testing.T) { + url, err := url.Parse("https+local://1.1.1.1/dns-query") + common.Must(err) + + s := NewDoHLocalNameServer(url, QueryStrategy_USE_IP6) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + IPv4Enable: true, + IPv6Enable: true, + }, false) + cancel() + common.Must(err) + if len(ips) == 0 { + t.Error("expect some ips, but got 0") + } + + for _, ip := range ips { + if len(ip) != net.IPv6len { + t.Error("expect only IPv6 response from DNS query") + } + } +} diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index e82a6a3d..9e702564 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -31,17 +31,18 @@ const handshakeTimeout = time.Second * 8 // QUICNameServer implemented DNS over QUIC type QUICNameServer struct { sync.RWMutex - ips map[string]*record - pub *pubsub.Service - cleanup *task.Periodic - reqID uint32 - name string - destination *net.Destination - connection quic.Connection + ips map[string]*record + pub *pubsub.Service + cleanup *task.Periodic + reqID uint32 + name string + destination *net.Destination + connection quic.Connection + queryStrategy QueryStrategy } // NewQUICNameServer creates DNS-over-QUIC client object for local resolving -func NewQUICNameServer(url *url.URL) (*QUICNameServer, error) { +func NewQUICNameServer(url *url.URL, queryStrategy QueryStrategy) (*QUICNameServer, error) { newError("DNS: created Local DNS-over-QUIC client for ", url.String()).AtInfo().WriteToLog() var err error @@ -55,10 +56,11 @@ func NewQUICNameServer(url *url.URL) (*QUICNameServer, error) { dest := net.UDPDestination(net.ParseAddress(url.Hostname()), port) s := &QUICNameServer{ - ips: make(map[string]*record), - pub: pubsub.NewService(), - name: url.String(), - destination: &dest, + ips: make(map[string]*record), + pub: pubsub.NewService(), + name: url.String(), + destination: &dest, + queryStrategy: queryStrategy, } s.cleanup = &task.Periodic{ Interval: time.Minute, @@ -269,6 +271,10 @@ func (s *QUICNameServer) findIPsForDomain(domain string, option dns_feature.IPOp // QueryIP is called from dns.Server->queryIPTimeout func (s *QUICNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, error) { fqdn := Fqdn(domain) + option = ResolveIpOptionOverride(s.queryStrategy, option) + if !option.IPv4Enable && !option.IPv6Enable { + return nil, dns_feature.ErrEmptyResponse + } if disableCache { newError("DNS cache is disabled. Querying IP for ", domain, " at ", s.name).AtDebug().WriteToLog() diff --git a/app/dns/nameserver_quic_test.go b/app/dns/nameserver_quic_test.go index cf445b43..ef50d7d9 100644 --- a/app/dns/nameserver_quic_test.go +++ b/app/dns/nameserver_quic_test.go @@ -16,7 +16,7 @@ import ( func TestQUICNameServer(t *testing.T) { url, err := url.Parse("quic://dns.adguard.com") common.Must(err) - s, err := NewQUICNameServer(url) + s, err := NewQUICNameServer(url, QueryStrategy_USE_IP) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ @@ -40,3 +40,49 @@ func TestQUICNameServer(t *testing.T) { t.Fatal(r) } } + +func TestQUICNameServerWithIPv4Override(t *testing.T) { + url, err := url.Parse("quic://dns.adguard.com") + common.Must(err) + s, err := NewQUICNameServer(url, QueryStrategy_USE_IP4) + common.Must(err) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) + ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ + IPv4Enable: true, + IPv6Enable: true, + }, false) + cancel() + common.Must(err) + if len(ips) == 0 { + t.Error("expect some ips, but got 0") + } + + for _, ip := range ips { + if len(ip) != net.IPv4len { + t.Error("expect only IPv4 response from DNS query") + } + } +} + +func TestQUICNameServerWithIPv6Override(t *testing.T) { + url, err := url.Parse("quic://dns.adguard.com") + common.Must(err) + s, err := NewQUICNameServer(url, QueryStrategy_USE_IP6) + common.Must(err) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) + ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ + IPv4Enable: true, + IPv6Enable: true, + }, false) + cancel() + common.Must(err) + if len(ips) == 0 { + t.Error("expect some ips, but got 0") + } + + for _, ip := range ips { + if len(ip) != net.IPv6len { + t.Error("expect only IPv6 response from DNS query") + } + } +} diff --git a/app/dns/nameserver_tcp.go b/app/dns/nameserver_tcp.go index cf63ac21..4ed723e1 100644 --- a/app/dns/nameserver_tcp.go +++ b/app/dns/nameserver_tcp.go @@ -27,18 +27,23 @@ import ( // TCPNameServer implemented DNS over TCP (RFC7766). type TCPNameServer struct { sync.RWMutex - name string - destination *net.Destination - ips map[string]*record - pub *pubsub.Service - cleanup *task.Periodic - reqID uint32 - dial func(context.Context) (net.Conn, error) + name string + destination *net.Destination + ips map[string]*record + pub *pubsub.Service + cleanup *task.Periodic + reqID uint32 + dial func(context.Context) (net.Conn, error) + queryStrategy QueryStrategy } // NewTCPNameServer creates DNS over TCP server object for remote resolving. -func NewTCPNameServer(url *url.URL, dispatcher routing.Dispatcher) (*TCPNameServer, error) { - s, err := baseTCPNameServer(url, "TCP") +func NewTCPNameServer( + url *url.URL, + dispatcher routing.Dispatcher, + queryStrategy QueryStrategy, +) (*TCPNameServer, error) { + s, err := baseTCPNameServer(url, "TCP", queryStrategy) if err != nil { return nil, err } @@ -59,8 +64,8 @@ func NewTCPNameServer(url *url.URL, dispatcher routing.Dispatcher) (*TCPNameServ } // NewTCPLocalNameServer creates DNS over TCP client object for local resolving -func NewTCPLocalNameServer(url *url.URL) (*TCPNameServer, error) { - s, err := baseTCPNameServer(url, "TCPL") +func NewTCPLocalNameServer(url *url.URL, queryStrategy QueryStrategy) (*TCPNameServer, error) { + s, err := baseTCPNameServer(url, "TCPL", queryStrategy) if err != nil { return nil, err } @@ -72,22 +77,22 @@ func NewTCPLocalNameServer(url *url.URL) (*TCPNameServer, error) { return s, nil } -func baseTCPNameServer(url *url.URL, prefix string) (*TCPNameServer, error) { - var err error +func baseTCPNameServer(url *url.URL, prefix string, queryStrategy QueryStrategy) (*TCPNameServer, error) { port := net.Port(53) if url.Port() != "" { - port, err = net.PortFromString(url.Port()) - if err != nil { + var err error + if port, err = net.PortFromString(url.Port()); err != nil { return nil, err } } dest := net.TCPDestination(net.ParseAddress(url.Hostname()), port) s := &TCPNameServer{ - destination: &dest, - ips: make(map[string]*record), - pub: pubsub.NewService(), - name: prefix + "//" + dest.NetAddr(), + destination: &dest, + ips: make(map[string]*record), + pub: pubsub.NewService(), + name: prefix + "//" + dest.NetAddr(), + queryStrategy: queryStrategy, } s.cleanup = &task.Periodic{ Interval: time.Minute, @@ -308,6 +313,10 @@ func (s *TCPNameServer) findIPsForDomain(domain string, option dns_feature.IPOpt // QueryIP implements Server. func (s *TCPNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, error) { fqdn := Fqdn(domain) + option = ResolveIpOptionOverride(s.queryStrategy, option) + if !option.IPv4Enable && !option.IPv6Enable { + return nil, dns_feature.ErrEmptyResponse + } if disableCache { newError("DNS cache is disabled. Querying IP for ", domain, " at ", s.name).AtDebug().WriteToLog() diff --git a/app/dns/nameserver_tcp_test.go b/app/dns/nameserver_tcp_test.go index da362355..6b2b2465 100644 --- a/app/dns/nameserver_tcp_test.go +++ b/app/dns/nameserver_tcp_test.go @@ -16,7 +16,7 @@ import ( func TestTCPLocalNameServer(t *testing.T) { url, err := url.Parse("tcp+local://8.8.8.8") common.Must(err) - s, err := NewTCPLocalNameServer(url) + s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ @@ -33,7 +33,7 @@ func TestTCPLocalNameServer(t *testing.T) { func TestTCPLocalNameServerWithCache(t *testing.T) { url, err := url.Parse("tcp+local://8.8.8.8") common.Must(err) - s, err := NewTCPLocalNameServer(url) + s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ @@ -57,3 +57,51 @@ func TestTCPLocalNameServerWithCache(t *testing.T) { t.Fatal(r) } } + +func TestTCPLocalNameServerWithIPv4Override(t *testing.T) { + url, err := url.Parse("tcp+local://8.8.8.8") + common.Must(err) + s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP4) + common.Must(err) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + IPv4Enable: true, + IPv6Enable: true, + }, false) + cancel() + common.Must(err) + + if len(ips) == 0 { + t.Error("expect some ips, but got 0") + } + + for _, ip := range ips { + if len(ip) != net.IPv4len { + t.Error("expect only IPv4 response from DNS query") + } + } +} + +func TestTCPLocalNameServerWithIPv6Override(t *testing.T) { + url, err := url.Parse("tcp+local://8.8.8.8") + common.Must(err) + s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP6) + common.Must(err) + ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) + ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + IPv4Enable: true, + IPv6Enable: true, + }, false) + cancel() + common.Must(err) + + if len(ips) == 0 { + t.Error("expect some ips, but got 0") + } + + for _, ip := range ips { + if len(ip) != net.IPv6len { + t.Error("expect only IPv6 response from DNS query") + } + } +} diff --git a/infra/conf/dns.go b/infra/conf/dns.go index 3265b819..a0f3155c 100644 --- a/infra/conf/dns.go +++ b/infra/conf/dns.go @@ -11,12 +11,13 @@ import ( ) type NameServerConfig struct { - Address *Address - ClientIP *Address - Port uint16 - SkipFallback bool - Domains []string - ExpectIPs StringList + Address *Address + ClientIP *Address + Port uint16 + SkipFallback bool + Domains []string + ExpectIPs StringList + QueryStrategy string } func (c *NameServerConfig) UnmarshalJSON(data []byte) error { @@ -27,12 +28,13 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { } var advanced struct { - Address *Address `json:"address"` - ClientIP *Address `json:"clientIp"` - Port uint16 `json:"port"` - SkipFallback bool `json:"skipFallback"` - Domains []string `json:"domains"` - ExpectIPs StringList `json:"expectIps"` + Address *Address `json:"address"` + ClientIP *Address `json:"clientIp"` + Port uint16 `json:"port"` + SkipFallback bool `json:"skipFallback"` + Domains []string `json:"domains"` + ExpectIPs StringList `json:"expectIps"` + QueryStrategy string `json:"queryStrategy"` } if err := json.Unmarshal(data, &advanced); err == nil { c.Address = advanced.Address @@ -41,6 +43,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { c.SkipFallback = advanced.SkipFallback c.Domains = advanced.Domains c.ExpectIPs = advanced.ExpectIPs + c.QueryStrategy = advanced.QueryStrategy return nil } @@ -112,6 +115,7 @@ func (c *NameServerConfig) Build() (*dns.NameServer, error) { PrioritizedDomain: domains, Geoip: geoipList, OriginalRules: originalRules, + QueryStrategy: resolveQueryStrategy(c.QueryStrategy), }, nil } @@ -311,6 +315,7 @@ func (c *DNSConfig) Build() (*dns.Config, error) { DisableCache: c.DisableCache, DisableFallback: c.DisableFallback, DisableFallbackIfMatch: c.DisableFallbackIfMatch, + QueryStrategy: resolveQueryStrategy(c.QueryStrategy), } if c.ClientIP != nil { @@ -320,16 +325,6 @@ func (c *DNSConfig) Build() (*dns.Config, error) { config.ClientIp = []byte(c.ClientIP.IP()) } - config.QueryStrategy = dns.QueryStrategy_USE_IP - switch strings.ToLower(c.QueryStrategy) { - case "useip", "use_ip", "use-ip": - config.QueryStrategy = dns.QueryStrategy_USE_IP - case "useip4", "useipv4", "use_ip4", "use_ipv4", "use_ip_v4", "use-ip4", "use-ipv4", "use-ip-v4": - config.QueryStrategy = dns.QueryStrategy_USE_IP4 - case "useip6", "useipv6", "use_ip6", "use_ipv6", "use_ip_v6", "use-ip6", "use-ipv6", "use-ip-v6": - config.QueryStrategy = dns.QueryStrategy_USE_IP6 - } - for _, server := range c.Servers { ns, err := server.Build() if err != nil { @@ -348,3 +343,16 @@ func (c *DNSConfig) Build() (*dns.Config, error) { return config, nil } + +func resolveQueryStrategy(queryStrategy string) dns.QueryStrategy { + switch strings.ToLower(queryStrategy) { + case "useip", "use_ip", "use-ip": + return dns.QueryStrategy_USE_IP + case "useip4", "useipv4", "use_ip4", "use_ipv4", "use_ip_v4", "use-ip4", "use-ipv4", "use-ip-v4": + return dns.QueryStrategy_USE_IP4 + case "useip6", "useipv6", "use_ip6", "use_ipv6", "use_ip_v6", "use-ip6", "use-ipv6", "use-ip-v6": + return dns.QueryStrategy_USE_IP6 + default: + return dns.QueryStrategy_USE_IP + } +} From 07ae08126c74df9492f38bceb00cc2a37149466c Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Wed, 20 Sep 2023 19:08:48 +0400 Subject: [PATCH 154/867] binding socket interface to sockopt_darwin.go --- transport/internet/sockopt_darwin.go | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/transport/internet/sockopt_darwin.go b/transport/internet/sockopt_darwin.go index 37ced27b..d8724c77 100644 --- a/transport/internet/sockopt_darwin.go +++ b/transport/internet/sockopt_darwin.go @@ -1,6 +1,7 @@ package internet import ( + network "net" "os" "syscall" "unsafe" @@ -106,6 +107,14 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf return err } } + if config.Interface != "" { + InterfaceIndex := getInterfaceIndexByName(config.Interface) + if InterfaceIndex != 0 { + if err := unix.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_BOUND_IF, InterfaceIndex); err != nil { + return newError("failed to set Interface").Base(err) + } + } + } if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 { if config.TcpKeepAliveIdle > 0 { @@ -148,6 +157,15 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) return err } } + if config.Interface != "" { + InterfaceIndex := getInterfaceIndexByName(config.Interface) + if InterfaceIndex != 0 { + if err := unix.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_BOUND_IF, InterfaceIndex); err != nil { + return newError("failed to set Interface").Base(err) + } + } + } + if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 { if config.TcpKeepAliveIdle > 0 { if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil { @@ -183,3 +201,24 @@ func setReuseAddr(fd uintptr) error { func setReusePort(fd uintptr) error { return nil } +func getInterfaceIndexByName(name string) int { + ifaces, err := network.Interfaces() + if err == nil { + for _, iface := range ifaces { + if (iface.Flags&network.FlagUp == network.FlagUp) && (iface.Flags&network.FlagLoopback != network.FlagLoopback) { + addrs, _ := iface.Addrs() + for _, addr := range addrs { + if ipnet, ok := addr.(*network.IPNet); ok && !ipnet.IP.IsLoopback() { + if ipnet.IP.To4() != nil { + if iface.Name == name { + return iface.Index + } + } + } + } + } + + } + } + return 0 +} From 1a72e55ea5f98305e29217abdfe2491038e8ff5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 00:05:17 +0000 Subject: [PATCH 155/867] Bump github.com/refraction-networking/utls from 1.4.3 to 1.5.3 Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.4.3 to 1.5.3. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.4.3...v1.5.3) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 3 ++- go.sum | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e98a6f11..3122c4d2 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.38.1 - github.com/refraction-networking/utls v1.4.3 + github.com/refraction-networking/utls v1.5.3 github.com/sagernet/sing v0.2.9 github.com/sagernet/sing-shadowsocks v0.2.4 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c @@ -33,6 +33,7 @@ require ( require ( github.com/andybalholm/brotli v1.0.5 // indirect + github.com/cloudflare/circl v1.3.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect github.com/francoispqt/gojay v1.2.13 // indirect diff --git a/go.sum b/go.sum index d4b097b9..148c924d 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= +github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -118,8 +120,8 @@ github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eU github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.38.1 h1:M36YWA5dEhEeT+slOu/SwMEucbYd0YFidxG3KlGPZaE= github.com/quic-go/quic-go v0.38.1/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= -github.com/refraction-networking/utls v1.4.3 h1:BdWS3BSzCwWCFfMIXP3mjLAyQkdmog7diaD/OqFbAzM= -github.com/refraction-networking/utls v1.4.3/go.mod h1:4u9V/awOSBrRw6+federGmVJQfPtemEqLBXkML1b0bo= +github.com/refraction-networking/utls v1.5.3 h1:Ds5Ocg1+MC1ahNx5iBEcHe0jHeLaA/fLey61EENm7ro= +github.com/refraction-networking/utls v1.5.3/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= From db3ac2a97708860a31c88e853ed7c5eb436c4527 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 00:24:12 +0000 Subject: [PATCH 156/867] Bump google.golang.org/grpc from 1.58.1 to 1.58.2 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.1 to 1.58.2. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.58.1...v1.58.2) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3122c4d2..514be06e 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( golang.org/x/net v0.15.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.12.0 - google.golang.org/grpc v1.58.1 + google.golang.org/grpc v1.58.2 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 148c924d..3a5510a1 100644 --- a/go.sum +++ b/go.sum @@ -272,8 +272,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.58.1 h1:OL+Vz23DTtrrldqHK49FUOPHyY75rvFqJfXC84NYW58= -google.golang.org/grpc v1.58.1/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= +google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From 27450c95bdc1a4b8de7b731016ca9f89cf618091 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:37:07 +0000 Subject: [PATCH 157/867] Bump github.com/sagernet/sing from 0.2.9 to 0.2.11 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.2.9 to 0.2.11. - [Commits](https://github.com/sagernet/sing/compare/v0.2.9...v0.2.11) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 514be06e..fce75789 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.38.1 github.com/refraction-networking/utls v1.5.3 - github.com/sagernet/sing v0.2.9 + github.com/sagernet/sing v0.2.11 github.com/sagernet/sing-shadowsocks v0.2.4 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index 3a5510a1..d59ab8a8 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/refraction-networking/utls v1.5.3/go.mod h1:SPuDbBmgLGp8s+HLNc83Fuavw github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.9 h1:3wsTz+JG5Wzy65eZnh6AuCrD2QqcRF6Iq6f7ttmJsAo= -github.com/sagernet/sing v0.2.9/go.mod h1:Ta8nHnDLAwqySzKhGoKk4ZIB+vJ3GTKj7UPrWYvM+4w= +github.com/sagernet/sing v0.2.11 h1:mu0S6d8y/xSVxilOqRd32Fmire5SZz9nT3t9NEHwUMY= +github.com/sagernet/sing v0.2.11/go.mod h1:GQ673iPfUnkbK/dIPkfd1Xh1MjOGo36gkl/mkiHY7Jg= github.com/sagernet/sing-shadowsocks v0.2.4 h1:s/CqXlvFAZhlIoHWUwPw5CoNnQ9Ibki9pckjuugtVfY= github.com/sagernet/sing-shadowsocks v0.2.4/go.mod h1:80fNKP0wnqlu85GZXV1H1vDPC/2t+dQbFggOw4XuFUM= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= From 57ed75eb6708b53054e56ae124cd1c471e4f4482 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Sep 2023 14:38:33 +0000 Subject: [PATCH 158/867] Bump github.com/sagernet/sing-shadowsocks from 0.2.4 to 0.2.5 Bumps [github.com/sagernet/sing-shadowsocks](https://github.com/sagernet/sing-shadowsocks) from 0.2.4 to 0.2.5. - [Commits](https://github.com/sagernet/sing-shadowsocks/compare/v0.2.4...v0.2.5) --- updated-dependencies: - dependency-name: github.com/sagernet/sing-shadowsocks dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fce75789..84029947 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/quic-go/quic-go v0.38.1 github.com/refraction-networking/utls v1.5.3 github.com/sagernet/sing v0.2.11 - github.com/sagernet/sing-shadowsocks v0.2.4 + github.com/sagernet/sing-shadowsocks v0.2.5 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index d59ab8a8..7cf12912 100644 --- a/go.sum +++ b/go.sum @@ -127,8 +127,8 @@ github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstv github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/sagernet/sing v0.2.11 h1:mu0S6d8y/xSVxilOqRd32Fmire5SZz9nT3t9NEHwUMY= github.com/sagernet/sing v0.2.11/go.mod h1:GQ673iPfUnkbK/dIPkfd1Xh1MjOGo36gkl/mkiHY7Jg= -github.com/sagernet/sing-shadowsocks v0.2.4 h1:s/CqXlvFAZhlIoHWUwPw5CoNnQ9Ibki9pckjuugtVfY= -github.com/sagernet/sing-shadowsocks v0.2.4/go.mod h1:80fNKP0wnqlu85GZXV1H1vDPC/2t+dQbFggOw4XuFUM= +github.com/sagernet/sing-shadowsocks v0.2.5 h1:qxIttos4xu6ii7MTVJYA8EFQR7Q3KG6xMqmLJIFtBaY= +github.com/sagernet/sing-shadowsocks v0.2.5/go.mod h1:MGWGkcU2xW2G2mfArT9/QqpVLOGU+dBaahZCtPHdt7A= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c/go.mod h1:euOmN6O5kk9dQmgSS8Df4psAl3TCjxOz0NW60EWkSaI= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= From 772936906a9cedfbd32ece09ce83ff1606728cf0 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 29 Sep 2023 22:30:24 -0400 Subject: [PATCH 159/867] Add reality test --- testing/scenarios/vless_test.go | 277 ++++++++++++++++---------------- 1 file changed, 139 insertions(+), 138 deletions(-) diff --git a/testing/scenarios/vless_test.go b/testing/scenarios/vless_test.go index 84d82643..ddb0bdb7 100644 --- a/testing/scenarios/vless_test.go +++ b/testing/scenarios/vless_test.go @@ -1,8 +1,8 @@ package scenarios import ( - // "encoding/base64" - // "encoding/hex" + "encoding/base64" + "encoding/hex" "testing" "time" @@ -23,7 +23,7 @@ import ( "github.com/xtls/xray-core/proxy/vless/outbound" "github.com/xtls/xray-core/testing/servers/tcp" "github.com/xtls/xray-core/transport/internet" - // "github.com/xtls/xray-core/transport/internet/reality" + "github.com/xtls/xray-core/transport/internet/reality" transtcp "github.com/xtls/xray-core/transport/internet/tcp" "github.com/xtls/xray-core/transport/internet/tls" "golang.org/x/sync/errgroup" @@ -377,142 +377,143 @@ func TestVlessXtlsVision(t *testing.T) { } } -// func TestVlessXtlsVisionReality(t *testing.T) { -// tcpServer := tcp.Server{ -// MsgProcessor: xor, -// } -// dest, err := tcpServer.Start() -// common.Must(err) -// defer tcpServer.Close() +func TestVlessXtlsVisionReality(t *testing.T) { + tcpServer := tcp.Server{ + MsgProcessor: xor, + } + dest, err := tcpServer.Start() + common.Must(err) + defer tcpServer.Close() -// userID := protocol.NewID(uuid.New()) -// serverPort := tcp.PickPort() -// privateKey, _ := base64.RawURLEncoding.DecodeString("aGSYystUbf59_9_6LKRxD27rmSW_-2_nyd9YG_Gwbks") -// publicKey, _ := base64.RawURLEncoding.DecodeString("E59WjnvZcQMu7tR7_BgyhycuEdBS-CtKxfImRCdAvFM") -// shortIds := make([][]byte, 1) -// shortIds[0] = make([]byte, 8) -// hex.Decode(shortIds[0], []byte("0123456789abcdef")) -// serverConfig := &core.Config{ -// App: []*serial.TypedMessage{ -// serial.ToTypedMessage(&log.Config{ -// ErrorLogLevel: clog.Severity_Debug, -// ErrorLogType: log.LogType_Console, -// }), -// }, -// Inbound: []*core.InboundHandlerConfig{ -// { -// ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ -// PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, -// Listen: net.NewIPOrDomain(net.LocalHostIP), -// StreamSettings: &internet.StreamConfig{ -// Protocol: internet.TransportProtocol_TCP, -// SecurityType: serial.GetMessageType(&reality.Config{}), -// SecuritySettings: []*serial.TypedMessage{ -// serial.ToTypedMessage(&reality.Config{ -// Show: true, -// Dest: "www.google.com:443", // use google for now, may fail in some region -// ServerNames: []string{"www.google.com"}, -// PrivateKey: privateKey, -// ShortIds: shortIds, -// }), -// }, -// }, -// }), -// ProxySettings: serial.ToTypedMessage(&inbound.Config{ -// Clients: []*protocol.User{ -// { -// Account: serial.ToTypedMessage(&vless.Account{ -// Id: userID.String(), -// Flow: vless.XRV, -// }), -// }, -// }, -// }), -// }, -// }, -// Outbound: []*core.OutboundHandlerConfig{ -// { -// ProxySettings: serial.ToTypedMessage(&freedom.Config{}), -// }, -// }, -// } + userID := protocol.NewID(uuid.New()) + serverPort := tcp.PickPort() + privateKey, _ := base64.RawURLEncoding.DecodeString("aGSYystUbf59_9_6LKRxD27rmSW_-2_nyd9YG_Gwbks") + publicKey, _ := base64.RawURLEncoding.DecodeString("E59WjnvZcQMu7tR7_BgyhycuEdBS-CtKxfImRCdAvFM") + shortIds := make([][]byte, 1) + shortIds[0] = make([]byte, 8) + hex.Decode(shortIds[0], []byte("0123456789abcdef")) + serverConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: clog.Severity_Debug, + ErrorLogType: log.LogType_Console, + }), + }, + Inbound: []*core.InboundHandlerConfig{ + { + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + StreamSettings: &internet.StreamConfig{ + Protocol: internet.TransportProtocol_TCP, + SecurityType: serial.GetMessageType(&reality.Config{}), + SecuritySettings: []*serial.TypedMessage{ + serial.ToTypedMessage(&reality.Config{ + Show: true, + Dest: "www.google.com:443", // use google for now, may fail in some region + ServerNames: []string{"www.google.com"}, + PrivateKey: privateKey, + ShortIds: shortIds, + Type: "tcp", + }), + }, + }, + }), + ProxySettings: serial.ToTypedMessage(&inbound.Config{ + Clients: []*protocol.User{ + { + Account: serial.ToTypedMessage(&vless.Account{ + Id: userID.String(), + Flow: vless.XRV, + }), + }, + }, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + ProxySettings: serial.ToTypedMessage(&freedom.Config{}), + }, + }, + } -// clientPort := tcp.PickPort() -// clientConfig := &core.Config{ -// App: []*serial.TypedMessage{ -// serial.ToTypedMessage(&log.Config{ -// ErrorLogLevel: clog.Severity_Debug, -// ErrorLogType: log.LogType_Console, -// }), -// }, -// Inbound: []*core.InboundHandlerConfig{ -// { -// ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ -// PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, -// Listen: net.NewIPOrDomain(net.LocalHostIP), -// }), -// ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ -// Address: net.NewIPOrDomain(dest.Address), -// Port: uint32(dest.Port), -// NetworkList: &net.NetworkList{ -// Network: []net.Network{net.Network_TCP}, -// }, -// }), -// }, -// }, -// Outbound: []*core.OutboundHandlerConfig{ -// { -// ProxySettings: serial.ToTypedMessage(&outbound.Config{ -// Vnext: []*protocol.ServerEndpoint{ -// { -// Address: net.NewIPOrDomain(net.LocalHostIP), -// Port: uint32(serverPort), -// User: []*protocol.User{ -// { -// Account: serial.ToTypedMessage(&vless.Account{ -// Id: userID.String(), -// Flow: vless.XRV, -// }), -// }, -// }, -// }, -// }, -// }), -// SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ -// StreamSettings: &internet.StreamConfig{ -// Protocol: internet.TransportProtocol_TCP, -// TransportSettings: []*internet.TransportConfig{ -// { -// Protocol: internet.TransportProtocol_TCP, -// Settings: serial.ToTypedMessage(&transtcp.Config{}), -// }, -// }, -// SecurityType: serial.GetMessageType(&reality.Config{}), -// SecuritySettings: []*serial.TypedMessage{ -// serial.ToTypedMessage(&reality.Config{ -// Show: true, -// Fingerprint: "chrome", -// ServerName: "www.google.com", -// PublicKey: publicKey, -// ShortId: shortIds[0], -// SpiderX: "/", -// }), -// }, -// }, -// }), -// }, -// }, -// } + clientPort := tcp.PickPort() + clientConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&log.Config{ + ErrorLogLevel: clog.Severity_Debug, + ErrorLogType: log.LogType_Console, + }), + }, + Inbound: []*core.InboundHandlerConfig{ + { + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + }), + ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), + NetworkList: &net.NetworkList{ + Network: []net.Network{net.Network_TCP}, + }, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + ProxySettings: serial.ToTypedMessage(&outbound.Config{ + Vnext: []*protocol.ServerEndpoint{ + { + Address: net.NewIPOrDomain(net.LocalHostIP), + Port: uint32(serverPort), + User: []*protocol.User{ + { + Account: serial.ToTypedMessage(&vless.Account{ + Id: userID.String(), + Flow: vless.XRV, + }), + }, + }, + }, + }, + }), + SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ + StreamSettings: &internet.StreamConfig{ + Protocol: internet.TransportProtocol_TCP, + TransportSettings: []*internet.TransportConfig{ + { + Protocol: internet.TransportProtocol_TCP, + Settings: serial.ToTypedMessage(&transtcp.Config{}), + }, + }, + SecurityType: serial.GetMessageType(&reality.Config{}), + SecuritySettings: []*serial.TypedMessage{ + serial.ToTypedMessage(&reality.Config{ + Show: true, + Fingerprint: "chrome", + ServerName: "www.google.com", + PublicKey: publicKey, + ShortId: shortIds[0], + SpiderX: "/", + }), + }, + }, + }), + }, + }, + } -// servers, err := InitializeServerConfigs(serverConfig, clientConfig) -// common.Must(err) -// defer CloseAllServers(servers) + servers, err := InitializeServerConfigs(serverConfig, clientConfig) + common.Must(err) + defer CloseAllServers(servers) -// var errg errgroup.Group -// for i := 0; i < 1; i++ { -// errg.Go(testTCPConn(clientPort, 1024*1024, time.Second*30)) -// } -// if err := errg.Wait(); err != nil { -// t.Error(err) -// } -// } + var errg errgroup.Group + for i := 0; i < 1; i++ { + errg.Go(testTCPConn(clientPort, 1024*1024, time.Second*30)) + } + if err := errg.Wait(); err != nil { + t.Error(err) + } +} From e244db76fbf871cc61f2f4d99f2676be27c2d9e8 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 29 Sep 2023 22:56:57 -0400 Subject: [PATCH 160/867] Update all dependencies --- go.mod | 17 ++++++++-------- go.sum | 34 ++++++++++++++++--------------- transport/internet/quic/dialer.go | 2 +- transport/internet/quic/hub.go | 2 +- 4 files changed, 29 insertions(+), 26 deletions(-) diff --git a/go.mod b/go.mod index 84029947..a9dae3b6 100644 --- a/go.mod +++ b/go.mod @@ -10,9 +10,9 @@ require ( github.com/miekg/dns v1.1.56 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.38.1 + github.com/quic-go/quic-go v0.39.0 github.com/refraction-networking/utls v1.5.3 - github.com/sagernet/sing v0.2.11 + github.com/sagernet/sing v0.2.12 github.com/sagernet/sing-shadowsocks v0.2.5 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb @@ -41,20 +41,21 @@ require ( github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f // indirect - github.com/klauspost/compress v1.16.7 // indirect + github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect + github.com/klauspost/compress v1.17.0 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect - github.com/onsi/ginkgo/v2 v2.12.0 // indirect + github.com/onsi/ginkgo/v2 v2.12.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/quic-go/qtls-go1-20 v0.3.3 // indirect + github.com/quic-go/qtls-go1-20 v0.3.4 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect go.uber.org/atomic v1.11.0 // indirect - golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 // indirect + go.uber.org/mock v0.3.0 // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.13.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7cf12912..faa51913 100644 --- a/go.sum +++ b/go.sum @@ -63,8 +63,8 @@ github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+u github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f h1:pDhu5sgp8yJlEF/g6osliIIpF9K4F5jvkULXa4daRDQ= -github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 h1:pUa4ghanp6q4IJHwE9RwLgmVFfReJN+KbQ8ExNEUUoQ= +github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -78,8 +78,8 @@ github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= -github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= +github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -98,8 +98,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.12.0 h1:UIVDowFPwpg6yMUpPjGkYvf06K3RAiJXUhCxEwQVHRI= -github.com/onsi/ginkgo/v2 v2.12.0/go.mod h1:ZNEzXISYlqpb8S36iN71ifqLi3vVD1rVJGvWRCJOUpQ= +github.com/onsi/ginkgo/v2 v2.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA= +github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= @@ -116,17 +116,17 @@ github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM= -github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.38.1 h1:M36YWA5dEhEeT+slOu/SwMEucbYd0YFidxG3KlGPZaE= -github.com/quic-go/quic-go v0.38.1/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= +github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= +github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= +github.com/quic-go/quic-go v0.39.0 h1:AgP40iThFMY0bj8jGxROhw3S0FMGa8ryqsmi9tBH3So= +github.com/quic-go/quic-go v0.39.0/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= github.com/refraction-networking/utls v1.5.3 h1:Ds5Ocg1+MC1ahNx5iBEcHe0jHeLaA/fLey61EENm7ro= github.com/refraction-networking/utls v1.5.3/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.11 h1:mu0S6d8y/xSVxilOqRd32Fmire5SZz9nT3t9NEHwUMY= -github.com/sagernet/sing v0.2.11/go.mod h1:GQ673iPfUnkbK/dIPkfd1Xh1MjOGo36gkl/mkiHY7Jg= +github.com/sagernet/sing v0.2.12 h1:wwdLm3c4qvU4hW8tNtadh60V5z2FGlDZSYYGRzHhD74= +github.com/sagernet/sing v0.2.12/go.mod h1:GQ673iPfUnkbK/dIPkfd1Xh1MjOGo36gkl/mkiHY7Jg= github.com/sagernet/sing-shadowsocks v0.2.5 h1:qxIttos4xu6ii7MTVJYA8EFQR7Q3KG6xMqmLJIFtBaY= github.com/sagernet/sing-shadowsocks v0.2.5/go.mod h1:MGWGkcU2xW2G2mfArT9/QqpVLOGU+dBaahZCtPHdt7A= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= @@ -174,6 +174,8 @@ github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1 go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= +go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= go4.org/netipx v0.0.0-20230824141953-6213f710f925 h1:eeQDDVKFkx0g4Hyy8pHgmZaK0EqB4SD6rvKbUdN3ziQ= go4.org/netipx v0.0.0-20230824141953-6213f710f925/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= @@ -185,8 +187,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 h1:Di6/M8l0O2lCLc6VVRWhgCiApHV8MnQurBnFSHsQtNY= -golang.org/x/exp v0.0.0-20230725093048-515e97ebf090/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -266,8 +268,8 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= diff --git a/transport/internet/quic/dialer.go b/transport/internet/quic/dialer.go index f6083561..1358dac7 100644 --- a/transport/internet/quic/dialer.go +++ b/transport/internet/quic/dialer.go @@ -142,7 +142,7 @@ func (s *clientConnections) openConnection(ctx context.Context, destAddr net.Add KeepAlivePeriod: 0, HandshakeIdleTimeout: time.Second * 8, MaxIdleTimeout: time.Second * 300, - Tracer: func(ctx context.Context, p logging.Perspective, ci quic.ConnectionID) logging.ConnectionTracer { + Tracer: func(ctx context.Context, p logging.Perspective, ci quic.ConnectionID) *logging.ConnectionTracer { return qlog.NewConnectionTracer(&QlogWriter{connID: ci}, p, ci) }, } diff --git a/transport/internet/quic/hub.go b/transport/internet/quic/hub.go index 8bab5bf3..7f7ea86f 100644 --- a/transport/internet/quic/hub.go +++ b/transport/internet/quic/hub.go @@ -108,7 +108,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti MaxIdleTimeout: time.Second * 300, MaxIncomingStreams: 32, MaxIncomingUniStreams: -1, - Tracer: func(ctx context.Context, p logging.Perspective, ci quic.ConnectionID) logging.ConnectionTracer { + Tracer: func(ctx context.Context, p logging.Perspective, ci quic.ConnectionID) *logging.ConnectionTracer { return qlog.NewConnectionTracer(&QlogWriter{connID: ci}, p, ci) }, } From 1e1ee5e39b3f4f4222674d07f06b0ec391d5bbee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 00:20:01 +0000 Subject: [PATCH 161/867] Bump golang.org/x/net from 0.15.0 to 0.16.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.15.0 to 0.16.0. - [Commits](https://github.com/golang/net/compare/v0.15.0...v0.16.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index a9dae3b6..d47ac1bf 100644 --- a/go.mod +++ b/go.mod @@ -20,10 +20,10 @@ require ( github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 go4.org/netipx v0.0.0-20230824141953-6213f710f925 - golang.org/x/crypto v0.13.0 - golang.org/x/net v0.15.0 + golang.org/x/crypto v0.14.0 + golang.org/x/net v0.16.0 golang.org/x/sync v0.3.0 - golang.org/x/sys v0.12.0 + golang.org/x/sys v0.13.0 google.golang.org/grpc v1.58.2 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 diff --git a/go.sum b/go.sum index faa51913..fb1cec48 100644 --- a/go.sum +++ b/go.sum @@ -184,8 +184,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= @@ -206,8 +206,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= -golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= +golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -231,8 +231,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= -golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 73df64a9f28b542cd1cb1c6394f5a8495fad9cfb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 01:15:06 +0000 Subject: [PATCH 162/867] Bump github.com/sagernet/sing from 0.2.12 to 0.2.13 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.2.12 to 0.2.13. - [Commits](https://github.com/sagernet/sing/compare/v0.2.12...v0.2.13) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d47ac1bf..97b11ee6 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.39.0 github.com/refraction-networking/utls v1.5.3 - github.com/sagernet/sing v0.2.12 + github.com/sagernet/sing v0.2.13 github.com/sagernet/sing-shadowsocks v0.2.5 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index fb1cec48..55bfa5a4 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/refraction-networking/utls v1.5.3/go.mod h1:SPuDbBmgLGp8s+HLNc83Fuavw github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.12 h1:wwdLm3c4qvU4hW8tNtadh60V5z2FGlDZSYYGRzHhD74= -github.com/sagernet/sing v0.2.12/go.mod h1:GQ673iPfUnkbK/dIPkfd1Xh1MjOGo36gkl/mkiHY7Jg= +github.com/sagernet/sing v0.2.13 h1:ohczGKWP+Yn3zlQXSvFn+6EKSELGggBi66D5rqpYRQ0= +github.com/sagernet/sing v0.2.13/go.mod h1:AhNEHu0GXrpqkuzvTwvC8+j2cQUU/dh+zLEmq4C99pg= github.com/sagernet/sing-shadowsocks v0.2.5 h1:qxIttos4xu6ii7MTVJYA8EFQR7Q3KG6xMqmLJIFtBaY= github.com/sagernet/sing-shadowsocks v0.2.5/go.mod h1:MGWGkcU2xW2G2mfArT9/QqpVLOGU+dBaahZCtPHdt7A= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= From 707ef51fb11ad126578e32cfcbbb95b96f3fa454 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:24:35 +0000 Subject: [PATCH 163/867] Bump golang.org/x/net from 0.16.0 to 0.17.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.16.0 to 0.17.0. - [Commits](https://github.com/golang/net/compare/v0.16.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 97b11ee6..65392e2d 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 go4.org/netipx v0.0.0-20230824141953-6213f710f925 golang.org/x/crypto v0.14.0 - golang.org/x/net v0.16.0 + golang.org/x/net v0.17.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.13.0 google.golang.org/grpc v1.58.2 diff --git a/go.sum b/go.sum index 55bfa5a4..d32a33a9 100644 --- a/go.sum +++ b/go.sum @@ -206,8 +206,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= -golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From c0af4f85c28fdbf9abf922fb97b46b7fbb5034e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:24:40 +0000 Subject: [PATCH 164/867] Bump github.com/google/go-cmp from 0.5.9 to 0.6.0 Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.9 to 0.6.0. - [Release notes](https://github.com/google/go-cmp/releases) - [Commits](https://github.com/google/go-cmp/compare/v0.5.9...v0.6.0) --- updated-dependencies: - dependency-name: github.com/google/go-cmp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 65392e2d..f51942ed 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 github.com/golang/mock v1.6.0 - github.com/google/go-cmp v0.5.9 + github.com/google/go-cmp v0.6.0 github.com/gorilla/websocket v1.5.0 github.com/miekg/dns v1.1.56 github.com/pelletier/go-toml v1.9.5 diff --git a/go.sum b/go.sum index d32a33a9..42b05cf7 100644 --- a/go.sum +++ b/go.sum @@ -57,8 +57,8 @@ github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= From 394fac6c6cc47c68f0861d944f37b907831d2f49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:24:46 +0000 Subject: [PATCH 165/867] Bump github.com/refraction-networking/utls from 1.5.3 to 1.5.4 Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.5.3 to 1.5.4. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.5.3...v1.5.4) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f51942ed..6b36121a 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.39.0 - github.com/refraction-networking/utls v1.5.3 + github.com/refraction-networking/utls v1.5.4 github.com/sagernet/sing v0.2.13 github.com/sagernet/sing-shadowsocks v0.2.5 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c diff --git a/go.sum b/go.sum index 42b05cf7..7dd810c2 100644 --- a/go.sum +++ b/go.sum @@ -120,8 +120,8 @@ github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNV github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.39.0 h1:AgP40iThFMY0bj8jGxROhw3S0FMGa8ryqsmi9tBH3So= github.com/quic-go/quic-go v0.39.0/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= -github.com/refraction-networking/utls v1.5.3 h1:Ds5Ocg1+MC1ahNx5iBEcHe0jHeLaA/fLey61EENm7ro= -github.com/refraction-networking/utls v1.5.3/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= +github.com/refraction-networking/utls v1.5.4 h1:9k6EO2b8TaOGsQ7Pl7p9w6PUhx18/ZCeT0WNTZ7Uw4o= +github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= From aeec8dfe253c4eac98e23a0d78e2e957fb168dac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 00:24:55 +0000 Subject: [PATCH 166/867] Bump google.golang.org/grpc from 1.58.2 to 1.58.3 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.2 to 1.58.3. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.58.2...v1.58.3) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6b36121a..8837a652 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( golang.org/x/net v0.17.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.13.0 - google.golang.org/grpc v1.58.2 + google.golang.org/grpc v1.58.3 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 7dd810c2..a068f14e 100644 --- a/go.sum +++ b/go.sum @@ -274,8 +274,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= -google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From 3ffdf93fc259e3b6cba5f6d9f4b90cb2a98ed551 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 00:47:20 +0000 Subject: [PATCH 167/867] Bump github.com/sagernet/sing from 0.2.13 to 0.2.14 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.2.13 to 0.2.14. - [Commits](https://github.com/sagernet/sing/compare/v0.2.13...v0.2.14) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8837a652..043fc6ee 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.39.0 github.com/refraction-networking/utls v1.5.4 - github.com/sagernet/sing v0.2.13 + github.com/sagernet/sing v0.2.14 github.com/sagernet/sing-shadowsocks v0.2.5 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index a068f14e..d347c02f 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83Fuavw github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.13 h1:ohczGKWP+Yn3zlQXSvFn+6EKSELGggBi66D5rqpYRQ0= -github.com/sagernet/sing v0.2.13/go.mod h1:AhNEHu0GXrpqkuzvTwvC8+j2cQUU/dh+zLEmq4C99pg= +github.com/sagernet/sing v0.2.14 h1:L3AXDh22nsOOYz2nTRU1JvpRsmzViWKI1B8TsQYG1eY= +github.com/sagernet/sing v0.2.14/go.mod h1:AhNEHu0GXrpqkuzvTwvC8+j2cQUU/dh+zLEmq4C99pg= github.com/sagernet/sing-shadowsocks v0.2.5 h1:qxIttos4xu6ii7MTVJYA8EFQR7Q3KG6xMqmLJIFtBaY= github.com/sagernet/sing-shadowsocks v0.2.5/go.mod h1:MGWGkcU2xW2G2mfArT9/QqpVLOGU+dBaahZCtPHdt7A= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= From 6177ec7fafb7281a1945e63633ec580831e02abf Mon Sep 17 00:00:00 2001 From: hossinasaadi Date: Tue, 3 Oct 2023 15:53:02 +0400 Subject: [PATCH 168/867] add bindAddr for darwin --- transport/internet/sockopt_darwin.go | 32 ++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/transport/internet/sockopt_darwin.go b/transport/internet/sockopt_darwin.go index d8724c77..de405538 100644 --- a/transport/internet/sockopt_darwin.go +++ b/transport/internet/sockopt_darwin.go @@ -165,7 +165,7 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) } } } - + if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 { if config.TcpKeepAliveIdle > 0 { if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil { @@ -191,14 +191,42 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) } func bindAddr(fd uintptr, address []byte, port uint32) error { - return nil + setReuseAddr(fd) + setReusePort(fd) + + var sockaddr unix.Sockaddr + + switch len(address) { + case net.IPv4len: + a4 := &unix.SockaddrInet4{ + Port: int(port), + } + copy(a4.Addr[:], address) + sockaddr = a4 + case net.IPv6len: + a6 := &unix.SockaddrInet6{ + Port: int(port), + } + copy(a6.Addr[:], address) + sockaddr = a6 + default: + return newError("unexpected length of ip") + } + + return unix.Bind(int(fd), sockaddr) } func setReuseAddr(fd uintptr) error { + if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEADDR, 1); err != nil { + return newError("failed to set SO_REUSEADDR").Base(err).AtWarning() + } return nil } func setReusePort(fd uintptr) error { + if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1); err != nil { + return newError("failed to set SO_REUSEPORT").Base(err).AtWarning() + } return nil } func getInterfaceIndexByName(name string) int { From e4c0fd7c001bb32c441711878970dd2446edd292 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 00:55:33 +0000 Subject: [PATCH 169/867] Bump github.com/quic-go/quic-go from 0.39.0 to 0.39.1 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.39.0 to 0.39.1. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.39.0...v0.39.1) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 043fc6ee..9ef527d7 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/miekg/dns v1.1.56 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.39.0 + github.com/quic-go/quic-go v0.39.1 github.com/refraction-networking/utls v1.5.4 github.com/sagernet/sing v0.2.14 github.com/sagernet/sing-shadowsocks v0.2.5 diff --git a/go.sum b/go.sum index d347c02f..c675cbc4 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.39.0 h1:AgP40iThFMY0bj8jGxROhw3S0FMGa8ryqsmi9tBH3So= -github.com/quic-go/quic-go v0.39.0/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= +github.com/quic-go/quic-go v0.39.1 h1:d/m3oaN/SD2c+f7/yEjZxe2zEVotXprnrCCJ2y/ZZFE= +github.com/quic-go/quic-go v0.39.1/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= github.com/refraction-networking/utls v1.5.4 h1:9k6EO2b8TaOGsQ7Pl7p9w6PUhx18/ZCeT0WNTZ7Uw4o= github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From f5e71b9db7f102323c15dc97fd0f5b7fa96bfd0b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 00:55:44 +0000 Subject: [PATCH 170/867] Bump google.golang.org/grpc from 1.58.3 to 1.59.0 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.58.3 to 1.59.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.58.3...v1.59.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9ef527d7..213b174f 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( golang.org/x/net v0.17.0 golang.org/x/sync v0.3.0 golang.org/x/sys v0.13.0 - google.golang.org/grpc v1.58.3 + google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index c675cbc4..e4d07989 100644 --- a/go.sum +++ b/go.sum @@ -274,8 +274,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= -google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From 291061e9da6a5e1777f79c76e8c0859df8db821c Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 21 Oct 2023 03:12:46 -0400 Subject: [PATCH 171/867] Fix an edge case reshaping buffer too long --- proxy/proxy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index a14ddace..4dcb6bf9 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -257,7 +257,7 @@ func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBu for i, buffer1 := range buffer { if buffer1.Len() >= buf.Size-21 { index := int32(bytes.LastIndex(buffer1.Bytes(), TlsApplicationDataStart)) - if index <= 0 || index > buf.Size-21 { + if index < 21 || index > buf.Size-21 { index = buf.Size / 2 } buffer2 := buf.New() From 4f8b73bb1f482e04bd5f946e8c1de95a8688dbf1 Mon Sep 17 00:00:00 2001 From: hossinasaadi Date: Sat, 21 Oct 2023 15:43:37 +0400 Subject: [PATCH 172/867] fix override Inbounds in multi config --- infra/conf/xray.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 7bfc53e3..c5459c44 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -489,16 +489,16 @@ func (c *Config) Override(o *Config, fn string) { // update the Inbound in slice if the only one in overide config has same tag if len(o.InboundConfigs) > 0 { - if len(c.InboundConfigs) > 0 && len(o.InboundConfigs) == 1 { - if idx := c.findInboundTag(o.InboundConfigs[0].Tag); idx > -1 { - c.InboundConfigs[idx] = o.InboundConfigs[0] + for i := range o.InboundConfigs { + if idx := c.findInboundTag(o.InboundConfigs[i].Tag); idx > -1 { + c.InboundConfigs[idx] = o.InboundConfigs[i] ctllog.Println("[", fn, "] updated inbound with tag: ", o.InboundConfigs[0].Tag) + } else { - c.InboundConfigs = append(c.InboundConfigs, o.InboundConfigs[0]) + c.InboundConfigs = append(c.InboundConfigs, o.InboundConfigs[i]) ctllog.Println("[", fn, "] appended inbound with tag: ", o.InboundConfigs[0].Tag) } - } else { - c.InboundConfigs = o.InboundConfigs + } } From 42d586df091a7871e820917232fa27b2e2829866 Mon Sep 17 00:00:00 2001 From: hossinasaadi Date: Sat, 21 Oct 2023 15:43:58 +0400 Subject: [PATCH 173/867] log inbound override status --- infra/conf/xray.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index c5459c44..e1f1f48c 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -492,11 +492,11 @@ func (c *Config) Override(o *Config, fn string) { for i := range o.InboundConfigs { if idx := c.findInboundTag(o.InboundConfigs[i].Tag); idx > -1 { c.InboundConfigs[idx] = o.InboundConfigs[i] - ctllog.Println("[", fn, "] updated inbound with tag: ", o.InboundConfigs[0].Tag) + newError("[", fn, "] updated inbound with tag: ", o.InboundConfigs[i].Tag).AtInfo().WriteToLog() } else { c.InboundConfigs = append(c.InboundConfigs, o.InboundConfigs[i]) - ctllog.Println("[", fn, "] appended inbound with tag: ", o.InboundConfigs[0].Tag) + newError("[", fn, "] appended inbound with tag: ", o.InboundConfigs[i].Tag).AtInfo().WriteToLog() } } From 71fee07175360d31460267414903cc249bb6d9e1 Mon Sep 17 00:00:00 2001 From: hossinasaadi Date: Mon, 23 Oct 2023 00:23:56 +0400 Subject: [PATCH 174/867] fix inbounds-replaceall test --- infra/conf/xray_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index c7e20ed4..fef9ab58 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -427,7 +427,7 @@ func TestConfig_Override(t *testing.T) { &Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}}, &Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}}, "", - &Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}}, + &Config{InboundConfigs: []InboundDetourConfig{{Tag: "pos0"}, {Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}}, }, { "replace/notag-append", From 67c66faaed7203fc0020183f8ae024b55da35f60 Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Tue, 24 Oct 2023 05:04:58 +0330 Subject: [PATCH 175/867] Override outbounds in multi config files (#2659) * fix override outbounds in multi config * log outbounds override status * fix prepend bug * improve outbounds-prepend test * fix prepend outbound * fix outbounds-prepend test --- infra/conf/xray.go | 22 ++++++++++++---------- infra/conf/xray_test.go | 6 +++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index e1f1f48c..558e2baa 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -504,21 +504,23 @@ func (c *Config) Override(o *Config, fn string) { // update the Outbound in slice if the only one in overide config has same tag if len(o.OutboundConfigs) > 0 { - if len(c.OutboundConfigs) > 0 && len(o.OutboundConfigs) == 1 { - if idx := c.findOutboundTag(o.OutboundConfigs[0].Tag); idx > -1 { - c.OutboundConfigs[idx] = o.OutboundConfigs[0] - ctllog.Println("[", fn, "] updated outbound with tag: ", o.OutboundConfigs[0].Tag) + outboundPrepends := []OutboundDetourConfig{} + for i := range o.OutboundConfigs { + if idx := c.findOutboundTag(o.OutboundConfigs[i].Tag); idx > -1 { + c.OutboundConfigs[idx] = o.OutboundConfigs[i] + newError("[", fn, "] updated outbound with tag: ", o.OutboundConfigs[i].Tag).AtInfo().WriteToLog() } else { if strings.Contains(strings.ToLower(fn), "tail") { - c.OutboundConfigs = append(c.OutboundConfigs, o.OutboundConfigs[0]) - ctllog.Println("[", fn, "] appended outbound with tag: ", o.OutboundConfigs[0].Tag) + c.OutboundConfigs = append(c.OutboundConfigs, o.OutboundConfigs[i]) + newError("[", fn, "] appended outbound with tag: ", o.OutboundConfigs[i].Tag).AtInfo().WriteToLog() } else { - c.OutboundConfigs = append(o.OutboundConfigs, c.OutboundConfigs...) - ctllog.Println("[", fn, "] prepended outbound with tag: ", o.OutboundConfigs[0].Tag) + outboundPrepends = append(outboundPrepends, o.OutboundConfigs[i]) + newError("[", fn, "] prepend outbound with tag: ", o.OutboundConfigs[i].Tag).AtInfo().WriteToLog() } } - } else { - c.OutboundConfigs = o.OutboundConfigs + } + if !strings.Contains(strings.ToLower(fn), "tail") && len(outboundPrepends) > 0 { + c.OutboundConfigs = append(outboundPrepends, c.OutboundConfigs...) } } } diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index fef9ab58..a53cd216 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -445,10 +445,10 @@ func TestConfig_Override(t *testing.T) { }, { "replace/outbounds-prepend", - &Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}}}, - &Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}}, + &Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos0"}, {Protocol: "vmess", Tag: "pos1"}, {Tag: "pos3"}}}, + &Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}, {Tag: "pos4", Protocol: "kcp"}}}, "config.json", - &Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos1", Protocol: "kcp"}, {Tag: "pos2", Protocol: "kcp"}}}, + &Config{OutboundConfigs: []OutboundDetourConfig{{Tag: "pos2", Protocol: "kcp"}, {Tag: "pos4", Protocol: "kcp"}, {Tag: "pos0"}, {Tag: "pos1", Protocol: "kcp"}, {Tag: "pos3"}}}, }, { "replace/outbounds-append", From 3eba6a78fe7ccf0cc4834e644741d20bd0b8acfc Mon Sep 17 00:00:00 2001 From: lilendian0x00 Date: Tue, 24 Oct 2023 12:15:03 -0700 Subject: [PATCH 176/867] Added xray-knife tool to the README.md file --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a91c4373..7d84f044 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,8 @@ - iOS & macOS arm64 - [Shadowrocket](https://apps.apple.com/app/shadowrocket/id932747118) +- Xray Tools + - [xray-knife](https://github.com/lilendian0x00/xray-knife) - Xray Wrapper - [XTLS/libXray](https://github.com/XTLS/libXray) - [xtlsapi](https://github.com/hiddify/xtlsapi) From 3d92f3f8b5d18f949b11ccd5b6bc7e63b3e6c482 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 00:44:34 +0000 Subject: [PATCH 177/867] Bump github.com/quic-go/quic-go from 0.39.1 to 0.39.2 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.39.1 to 0.39.2. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.39.1...v0.39.2) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 213b174f..45d4d0f2 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/miekg/dns v1.1.56 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.39.1 + github.com/quic-go/quic-go v0.39.2 github.com/refraction-networking/utls v1.5.4 github.com/sagernet/sing v0.2.14 github.com/sagernet/sing-shadowsocks v0.2.5 diff --git a/go.sum b/go.sum index e4d07989..54c3512f 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.39.1 h1:d/m3oaN/SD2c+f7/yEjZxe2zEVotXprnrCCJ2y/ZZFE= -github.com/quic-go/quic-go v0.39.1/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= +github.com/quic-go/quic-go v0.39.2 h1:hmwAf8zAHlvan0Y5PXxeeBFZEW17IW99sXLry8I2kjk= +github.com/quic-go/quic-go v0.39.2/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= github.com/refraction-networking/utls v1.5.4 h1:9k6EO2b8TaOGsQ7Pl7p9w6PUhx18/ZCeT0WNTZ7Uw4o= github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From e241e5bda626354d70a1ca473b2058df338a3435 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 26 Oct 2023 14:15:04 +0000 Subject: [PATCH 178/867] Bump github.com/sagernet/sing from 0.2.14 to 0.2.15 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.2.14 to 0.2.15. - [Commits](https://github.com/sagernet/sing/compare/v0.2.14...v0.2.15) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 45d4d0f2..6acee6a1 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.39.2 github.com/refraction-networking/utls v1.5.4 - github.com/sagernet/sing v0.2.14 + github.com/sagernet/sing v0.2.15 github.com/sagernet/sing-shadowsocks v0.2.5 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index 54c3512f..b4e00a97 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83Fuavw github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.14 h1:L3AXDh22nsOOYz2nTRU1JvpRsmzViWKI1B8TsQYG1eY= -github.com/sagernet/sing v0.2.14/go.mod h1:AhNEHu0GXrpqkuzvTwvC8+j2cQUU/dh+zLEmq4C99pg= +github.com/sagernet/sing v0.2.15 h1:PFwyiMzkyJkq+YGOVznJUsRVOT6EoVxRGIsllLuvHXA= +github.com/sagernet/sing v0.2.15/go.mod h1:AhNEHu0GXrpqkuzvTwvC8+j2cQUU/dh+zLEmq4C99pg= github.com/sagernet/sing-shadowsocks v0.2.5 h1:qxIttos4xu6ii7MTVJYA8EFQR7Q3KG6xMqmLJIFtBaY= github.com/sagernet/sing-shadowsocks v0.2.5/go.mod h1:MGWGkcU2xW2G2mfArT9/QqpVLOGU+dBaahZCtPHdt7A= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= From 4f05e0ac2bedf3faccf6732a5eaee55116ccabb3 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 28 Oct 2023 17:24:54 -0400 Subject: [PATCH 179/867] Unify environment var readers --- common/buf/readv_reader.go | 2 +- common/platform/others.go | 6 ++---- common/platform/platform.go | 14 ++++++++++++++ common/xudp/xudp.go | 13 ++++--------- core/xray.go | 5 +++-- infra/conf/common.go | 6 +++--- proxy/freedom/freedom.go | 2 +- proxy/vmess/outbound/outbound.go | 2 +- transport/internet/websocket/dialer.go | 5 +++-- 9 files changed, 32 insertions(+), 23 deletions(-) diff --git a/common/buf/readv_reader.go b/common/buf/readv_reader.go index f897ccca..bcd0f0ed 100644 --- a/common/buf/readv_reader.go +++ b/common/buf/readv_reader.go @@ -147,7 +147,7 @@ var useReadv bool func init() { const defaultFlagValue = "NOT_DEFINED_AT_ALL" - value := platform.NewEnvFlag("xray.buf.readv").GetValue(func() string { return defaultFlagValue }) + value := platform.NewEnvFlag(platform.UseReadV).GetValue(func() string { return defaultFlagValue }) switch value { case defaultFlagValue, "auto", "enable": useReadv = true diff --git a/common/platform/others.go b/common/platform/others.go index ff45a054..fe22d1de 100644 --- a/common/platform/others.go +++ b/common/platform/others.go @@ -17,15 +17,13 @@ func LineSeparator() string { } func GetToolLocation(file string) string { - const name = "xray.location.tool" - toolPath := EnvFlag{Name: name, AltName: NormalizeEnvName(name)}.GetValue(getExecutableDir) + toolPath := NewEnvFlag(UnixToolLocation).GetValue(getExecutableDir) return filepath.Join(toolPath, file) } // GetAssetLocation searches for `file` in certain locations func GetAssetLocation(file string) string { - const name = "xray.location.asset" - assetPath := NewEnvFlag(name).GetValue(getExecutableDir) + assetPath := NewEnvFlag(UnixAssetLocation).GetValue(getExecutableDir) defPath := filepath.Join(assetPath, file) for _, p := range []string{ defPath, diff --git a/common/platform/platform.go b/common/platform/platform.go index d5149db4..bccf6f9d 100644 --- a/common/platform/platform.go +++ b/common/platform/platform.go @@ -84,3 +84,17 @@ func GetConfDirPath() string { configPath := NewEnvFlag(name).GetValue(func() string { return "" }) return configPath } + +const ( + UnixToolLocation = "xray.location.tool" + UnixAssetLocation = "xray.location.asset" + + UseReadV = "xray.buf.readv" + UseFreedomSplice = "xray.buf.splice" + UseVmessPadding = "xray.vmess.padding" + UseCone = "xray.cone.disabled" + + BrowserDialerAddress = "xray.browser.dialer" + XUDPLog = "xray.xudp.show" + XUDPBaseKey = "xray.xudp.basekey" +) diff --git a/common/xudp/xudp.go b/common/xudp/xudp.go index 513247c3..2fc5166c 100644 --- a/common/xudp/xudp.go +++ b/common/xudp/xudp.go @@ -6,11 +6,11 @@ import ( "encoding/base64" "fmt" "io" - "os" "strings" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/session" "lukechampine.com/blake3" @@ -28,20 +28,15 @@ var ( BaseKey []byte ) -const ( - EnvShow = "XRAY_XUDP_SHOW" - EnvBaseKey = "XRAY_XUDP_BASEKEY" -) - func init() { - if strings.ToLower(os.Getenv(EnvShow)) == "true" { + if strings.ToLower(platform.NewEnvFlag(platform.XUDPLog).GetValue(func() string { return "" })) == "true" { Show = true } - if raw, found := os.LookupEnv(EnvBaseKey); found { + if raw := platform.NewEnvFlag(platform.XUDPBaseKey).GetValue(func() string { return "" }); raw != "" { if BaseKey, _ = base64.RawURLEncoding.DecodeString(raw); len(BaseKey) == 32 { return } - panic(EnvBaseKey + ": invalid value: " + raw) + panic(platform.XUDPBaseKey + ": invalid value: " + raw) } rand.Read(BaseKey) } diff --git a/core/xray.go b/core/xray.go index 5c7518f9..20484c60 100644 --- a/core/xray.go +++ b/core/xray.go @@ -2,11 +2,11 @@ package core import ( "context" - "os" "reflect" "sync" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/features" "github.com/xtls/xray-core/features/dns" @@ -181,7 +181,8 @@ func NewWithContext(ctx context.Context, config *Config) (*Instance, error) { } func initInstanceWithConfig(config *Config, server *Instance) (bool, error) { - server.ctx = context.WithValue(server.ctx, "cone", os.Getenv("XRAY_CONE_DISABLED") != "true") + server.ctx = context.WithValue(server.ctx, "cone", + platform.NewEnvFlag(platform.UseCone).GetValue(func() string { return "" }) != "true") if config.Transport != nil { features.PrintDeprecatedFeatureWarning("global transport settings") diff --git a/infra/conf/common.go b/infra/conf/common.go index f8f56056..20868b83 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -2,10 +2,10 @@ package conf import ( "encoding/json" - "os" "strings" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/common/protocol" ) @@ -46,7 +46,7 @@ func (v *Address) UnmarshalJSON(data []byte) error { return newError("invalid address: ", string(data)).Base(err) } if strings.HasPrefix(rawStr, "env:") { - rawStr = os.Getenv(rawStr[4:]) + rawStr = platform.NewEnvFlag(rawStr[4:]).GetValue(func() string { return "" }) } v.Address = net.ParseAddress(rawStr) @@ -118,7 +118,7 @@ func parseIntPort(data []byte) (net.Port, error) { func parseStringPort(s string) (net.Port, net.Port, error) { if strings.HasPrefix(s, "env:") { - s = os.Getenv(s[4:]) + s = platform.NewEnvFlag(s[4:]).GetValue(func() string { return "" }) } pair := strings.SplitN(s, "-", 2) diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 808f837f..9af57e01 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -41,7 +41,7 @@ func init() { return h, nil })) const defaultFlagValue = "NOT_DEFINED_AT_ALL" - value := platform.NewEnvFlag("xray.buf.splice").GetValue(func() string { return defaultFlagValue }) + value := platform.NewEnvFlag(platform.UseFreedomSplice).GetValue(func() string { return defaultFlagValue }) switch value { case "auto", "enable": useSplice = true diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index 5e228d68..c3c55d95 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -245,7 +245,7 @@ func init() { const defaultFlagValue = "NOT_DEFINED_AT_ALL" - paddingValue := platform.NewEnvFlag("xray.vmess.padding").GetValue(func() string { return defaultFlagValue }) + paddingValue := platform.NewEnvFlag(platform.UseVmessPadding).GetValue(func() string { return defaultFlagValue }) if paddingValue != defaultFlagValue { enablePadding = true } diff --git a/transport/internet/websocket/dialer.go b/transport/internet/websocket/dialer.go index 5017cb50..1ab9379e 100644 --- a/transport/internet/websocket/dialer.go +++ b/transport/internet/websocket/dialer.go @@ -8,12 +8,12 @@ import ( "io" gonet "net" "net/http" - "os" "time" "github.com/gorilla/websocket" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/stat" @@ -26,7 +26,8 @@ var webpage []byte var conns chan *websocket.Conn func init() { - if addr := os.Getenv("XRAY_BROWSER_DIALER"); addr != "" { + addr := platform.NewEnvFlag(platform.BrowserDialerAddress).GetValue(func() string { return "" }) + if addr != "" { conns = make(chan *websocket.Conn, 256) go http.ListenAndServe(addr, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/websocket" { From 999bdc58d348e359f4b75ecb165d311c0b476795 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 28 Oct 2023 17:25:25 -0400 Subject: [PATCH 180/867] Turn on freedom splice by default --- proxy/freedom/freedom.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 9af57e01..3eb5b8a3 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -43,7 +43,7 @@ func init() { const defaultFlagValue = "NOT_DEFINED_AT_ALL" value := platform.NewEnvFlag(platform.UseFreedomSplice).GetValue(func() string { return defaultFlagValue }) switch value { - case "auto", "enable": + case defaultFlagValue, "auto", "enable": useSplice = true } } From 11b61b02c8c64f7fa8b38cf527a2632e3787c50f Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 28 Oct 2023 18:21:57 -0400 Subject: [PATCH 181/867] Refine environment var Address some review comments --- common/platform/others.go | 4 ++-- common/platform/platform.go | 41 +++++++++++++++++++------------------ common/platform/windows.go | 6 ++---- features/policy/policy.go | 6 +----- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/common/platform/others.go b/common/platform/others.go index fe22d1de..7401a526 100644 --- a/common/platform/others.go +++ b/common/platform/others.go @@ -17,13 +17,13 @@ func LineSeparator() string { } func GetToolLocation(file string) string { - toolPath := NewEnvFlag(UnixToolLocation).GetValue(getExecutableDir) + toolPath := NewEnvFlag(ToolLocation).GetValue(getExecutableDir) return filepath.Join(toolPath, file) } // GetAssetLocation searches for `file` in certain locations func GetAssetLocation(file string) string { - assetPath := NewEnvFlag(UnixAssetLocation).GetValue(getExecutableDir) + assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir) defPath := filepath.Join(assetPath, file) for _, p := range []string{ defPath, diff --git a/common/platform/platform.go b/common/platform/platform.go index bccf6f9d..51e25447 100644 --- a/common/platform/platform.go +++ b/common/platform/platform.go @@ -7,6 +7,24 @@ import ( "strings" ) +const ( + PluginLocation = "xray.location.plugin" + ConfigLocation = "xray.location.config" + ConfdirLocation = "xray.location.confdir" + ToolLocation = "xray.location.tool" + AssetLocation = "xray.location.asset" + + UseReadV = "xray.buf.readv" + UseFreedomSplice = "xray.buf.splice" + UseVmessPadding = "xray.vmess.padding" + UseCone = "xray.cone.disabled" + + BufferSize = "xray.ray.buffer.size" + BrowserDialerAddress = "xray.browser.dialer" + XUDPLog = "xray.xudp.show" + XUDPBaseKey = "xray.xudp.basekey" +) + type EnvFlag struct { Name string AltName string @@ -67,34 +85,17 @@ func getExecutableSubDir(dir string) func() string { } func GetPluginDirectory() string { - const name = "xray.location.plugin" - pluginDir := NewEnvFlag(name).GetValue(getExecutableSubDir("plugins")) + pluginDir := NewEnvFlag(PluginLocation).GetValue(getExecutableSubDir("plugins")) return pluginDir } func GetConfigurationPath() string { - const name = "xray.location.config" - configPath := NewEnvFlag(name).GetValue(getExecutableDir) + configPath := NewEnvFlag(ConfigLocation).GetValue(getExecutableDir) return filepath.Join(configPath, "config.json") } // GetConfDirPath reads "xray.location.confdir" func GetConfDirPath() string { - const name = "xray.location.confdir" - configPath := NewEnvFlag(name).GetValue(func() string { return "" }) + configPath := NewEnvFlag(ConfdirLocation).GetValue(func() string { return "" }) return configPath } - -const ( - UnixToolLocation = "xray.location.tool" - UnixAssetLocation = "xray.location.asset" - - UseReadV = "xray.buf.readv" - UseFreedomSplice = "xray.buf.splice" - UseVmessPadding = "xray.vmess.padding" - UseCone = "xray.cone.disabled" - - BrowserDialerAddress = "xray.browser.dialer" - XUDPLog = "xray.xudp.show" - XUDPBaseKey = "xray.xudp.basekey" -) diff --git a/common/platform/windows.go b/common/platform/windows.go index a568d5ae..2aeca80c 100644 --- a/common/platform/windows.go +++ b/common/platform/windows.go @@ -15,14 +15,12 @@ func LineSeparator() string { } func GetToolLocation(file string) string { - const name = "xray.location.tool" - toolPath := EnvFlag{Name: name, AltName: NormalizeEnvName(name)}.GetValue(getExecutableDir) + toolPath := NewEnvFlag(ToolLocation).GetValue(getExecutableDir) return filepath.Join(toolPath, file+".exe") } // GetAssetLocation searches for `file` in the excutable dir func GetAssetLocation(file string) string { - const name = "xray.location.asset" - assetPath := NewEnvFlag(name).GetValue(getExecutableDir) + assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir) return filepath.Join(assetPath, file) } diff --git a/features/policy/policy.go b/features/policy/policy.go index c3d48e6a..4d3f7ecf 100644 --- a/features/policy/policy.go +++ b/features/policy/policy.go @@ -83,12 +83,8 @@ func ManagerType() interface{} { var defaultBufferSize int32 func init() { - const key = "xray.ray.buffer.size" const defaultValue = -17 - size := platform.EnvFlag{ - Name: key, - AltName: platform.NormalizeEnvName(key), - }.GetValueAsInt(defaultValue) + size := platform.NewEnvFlag(platform.BufferSize).GetValueAsInt(defaultValue) switch size { case 0: From f86fe6f91a9eec42f8f044a08bac063d06e01efe Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 00:18:03 +0000 Subject: [PATCH 182/867] Bump github.com/quic-go/quic-go from 0.39.2 to 0.39.3 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.39.2 to 0.39.3. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.39.2...v0.39.3) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6acee6a1..4ed26d5e 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/miekg/dns v1.1.56 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.39.2 + github.com/quic-go/quic-go v0.39.3 github.com/refraction-networking/utls v1.5.4 github.com/sagernet/sing v0.2.15 github.com/sagernet/sing-shadowsocks v0.2.5 diff --git a/go.sum b/go.sum index b4e00a97..628abbe5 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.39.2 h1:hmwAf8zAHlvan0Y5PXxeeBFZEW17IW99sXLry8I2kjk= -github.com/quic-go/quic-go v0.39.2/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= +github.com/quic-go/quic-go v0.39.3 h1:o3YB6t2SR+HU/pgwF29kJ6g4jJIJEwEZ8CKia1h1TKg= +github.com/quic-go/quic-go v0.39.3/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= github.com/refraction-networking/utls v1.5.4 h1:9k6EO2b8TaOGsQ7Pl7p9w6PUhx18/ZCeT0WNTZ7Uw4o= github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From d24a636c7523a6830327344a610cd3c40afddd2a Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 28 Oct 2023 21:31:08 -0400 Subject: [PATCH 183/867] Move some log from stdout to ray log --- common/xudp/errors.generated.go | 9 +++++++++ common/xudp/xudp.go | 2 +- transport/internet/reality/reality.go | 17 +++++++++-------- transport/internet/websocket/dialer.go | 3 +-- 4 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 common/xudp/errors.generated.go diff --git a/common/xudp/errors.generated.go b/common/xudp/errors.generated.go new file mode 100644 index 00000000..e14625a8 --- /dev/null +++ b/common/xudp/errors.generated.go @@ -0,0 +1,9 @@ +package xudp + +import "github.com/xtls/xray-core/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/common/xudp/xudp.go b/common/xudp/xudp.go index 2fc5166c..af18119f 100644 --- a/common/xudp/xudp.go +++ b/common/xudp/xudp.go @@ -51,7 +51,7 @@ func GetGlobalID(ctx context.Context) (globalID [8]byte) { h.Write([]byte(inbound.Source.String())) copy(globalID[:], h.Sum(nil)) if Show { - fmt.Printf("XUDP inbound.Source.String(): %v\tglobalID: %v\n", inbound.Source.String(), globalID) + newError(fmt.Sprintf("XUDP inbound.Source.String(): %v\tglobalID: %v\n", inbound.Source.String(), globalID)).WriteToLog(session.ExportIDToError(ctx)) } } return diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 30d4e2ae..de8a6ac6 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -29,6 +29,7 @@ import ( "github.com/xtls/reality" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/transport/internet/tls" "golang.org/x/crypto/chacha20poly1305" @@ -133,7 +134,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati binary.BigEndian.PutUint32(hello.SessionId[4:], uint32(time.Now().Unix())) copy(hello.SessionId[8:], config.ShortId) if config.Show { - fmt.Printf("REALITY localAddr: %v\thello.SessionId[:16]: %v\n", localAddr, hello.SessionId[:16]) + newError(fmt.Sprintf("REALITY localAddr: %v\thello.SessionId[:16]: %v\n", localAddr, hello.SessionId[:16])).WriteToLog(session.ExportIDToError(ctx)) } publicKey, _ := ecdh.X25519().NewPublicKey(config.PublicKey) uConn.AuthKey, _ = uConn.HandshakeState.State13.EcdheKey.ECDH(publicKey) @@ -151,7 +152,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati aead, _ = chacha20poly1305.New(uConn.AuthKey) } if config.Show { - fmt.Printf("REALITY localAddr: %v\tuConn.AuthKey[:16]: %v\tAEAD: %T\n", localAddr, uConn.AuthKey[:16], aead) + newError(fmt.Sprintf("REALITY localAddr: %v\tuConn.AuthKey[:16]: %v\tAEAD: %T\n", localAddr, uConn.AuthKey[:16], aead)).WriteToLog(session.ExportIDToError(ctx)) } aead.Seal(hello.SessionId[:0], hello.Random[20:], hello.SessionId[:16], hello.Raw) copy(hello.Raw[39:], hello.SessionId) @@ -160,14 +161,14 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati return nil, err } if config.Show { - fmt.Printf("REALITY localAddr: %v\tuConn.Verified: %v\n", localAddr, uConn.Verified) + newError(fmt.Sprintf("REALITY localAddr: %v\tuConn.Verified: %v\n", localAddr, uConn.Verified)).WriteToLog(session.ExportIDToError(ctx)) } if !uConn.Verified { go func() { client := &http.Client{ Transport: &http2.Transport{ DialTLSContext: func(ctx context.Context, network, addr string, cfg *gotls.Config) (net.Conn, error) { - fmt.Printf("REALITY localAddr: %v\tDialTLSContext\n", localAddr) + newError(fmt.Sprintf("REALITY localAddr: %v\tDialTLSContext\n", localAddr)).WriteToLog(session.ExportIDToError(ctx)) return uConn, nil }, }, @@ -201,7 +202,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati } req.Header.Set("User-Agent", fingerprint.Client) // TODO: User-Agent map if first && config.Show { - fmt.Printf("REALITY localAddr: %v\treq.UserAgent(): %v\n", localAddr, req.UserAgent()) + newError(fmt.Sprintf("REALITY localAddr: %v\treq.UserAgent(): %v\n", localAddr, req.UserAgent())).WriteToLog(session.ExportIDToError(ctx)) } times := 1 if !first { @@ -228,9 +229,9 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati } req.URL.Path = getPathLocked(paths) if config.Show { - fmt.Printf("REALITY localAddr: %v\treq.Referer(): %v\n", localAddr, req.Referer()) - fmt.Printf("REALITY localAddr: %v\tlen(body): %v\n", localAddr, len(body)) - fmt.Printf("REALITY localAddr: %v\tlen(paths): %v\n", localAddr, len(paths)) + newError(fmt.Sprintf("REALITY localAddr: %v\treq.Referer(): %v\n", localAddr, req.Referer())).WriteToLog(session.ExportIDToError(ctx)) + newError(fmt.Sprintf("REALITY localAddr: %v\tlen(body): %v\n", localAddr, len(body))).WriteToLog(session.ExportIDToError(ctx)) + newError(fmt.Sprintf("REALITY localAddr: %v\tlen(paths): %v\n", localAddr, len(paths))).WriteToLog(session.ExportIDToError(ctx)) } maps.Unlock() if !first { diff --git a/transport/internet/websocket/dialer.go b/transport/internet/websocket/dialer.go index 1ab9379e..02b73a66 100644 --- a/transport/internet/websocket/dialer.go +++ b/transport/internet/websocket/dialer.go @@ -4,7 +4,6 @@ import ( "context" _ "embed" "encoding/base64" - "fmt" "io" gonet "net" "net/http" @@ -34,7 +33,7 @@ func init() { if conn, err := upgrader.Upgrade(w, r, nil); err == nil { conns <- conn } else { - fmt.Println("unexpected error") + newError("Browser dialer http upgrade unexpected error").AtError().WriteToLog() } } else { w.Write(webpage) From 3500f5b577ce9f29810507f88d5bd5c3513ecafa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Nov 2023 00:38:05 +0000 Subject: [PATCH 184/867] Bump github.com/quic-go/quic-go from 0.39.3 to 0.40.0 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.39.3 to 0.40.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.39.3...v0.40.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 4ed26d5e..917ad184 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/miekg/dns v1.1.56 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.39.3 + github.com/quic-go/quic-go v0.40.0 github.com/refraction-networking/utls v1.5.4 github.com/sagernet/sing v0.2.15 github.com/sagernet/sing-shadowsocks v0.2.5 @@ -46,7 +46,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/onsi/ginkgo/v2 v2.12.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/quic-go/qtls-go1-20 v0.3.4 // indirect + github.com/quic-go/qtls-go1-20 v0.4.1 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/mock v0.3.0 // indirect diff --git a/go.sum b/go.sum index 628abbe5..a009a4bb 100644 --- a/go.sum +++ b/go.sum @@ -116,10 +116,10 @@ github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/quic-go/qtls-go1-20 v0.3.4 h1:MfFAPULvst4yoMgY9QmtpYmfij/em7O8UUi+bNVm7Cg= -github.com/quic-go/qtls-go1-20 v0.3.4/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.39.3 h1:o3YB6t2SR+HU/pgwF29kJ6g4jJIJEwEZ8CKia1h1TKg= -github.com/quic-go/quic-go v0.39.3/go.mod h1:T09QsDQWjLiQ74ZmacDfqZmhY/NLnw5BC40MANNNZ1Q= +github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs= +github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= +github.com/quic-go/quic-go v0.40.0 h1:GYd1iznlKm7dpHD7pOVpUvItgMPo/jrMgDWZhMCecqw= +github.com/quic-go/quic-go v0.40.0/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c= github.com/refraction-networking/utls v1.5.4 h1:9k6EO2b8TaOGsQ7Pl7p9w6PUhx18/ZCeT0WNTZ7Uw4o= github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From 1d89ae2847f951cb1c4105e6aba4c4163c672731 Mon Sep 17 00:00:00 2001 From: Ikko Eltociear Ashimine Date: Mon, 6 Nov 2023 03:49:08 +0900 Subject: [PATCH 185/867] Fix typo in xray.go overide -> override --- infra/conf/xray.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 558e2baa..dfc34a8c 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -487,7 +487,7 @@ func (c *Config) Override(o *Config, fn string) { } // deprecated attrs - // update the Inbound in slice if the only one in overide config has same tag + // update the Inbound in slice if the only one in override config has same tag if len(o.InboundConfigs) > 0 { for i := range o.InboundConfigs { if idx := c.findInboundTag(o.InboundConfigs[i].Tag); idx > -1 { @@ -502,7 +502,7 @@ func (c *Config) Override(o *Config, fn string) { } } - // update the Outbound in slice if the only one in overide config has same tag + // update the Outbound in slice if the only one in override config has same tag if len(o.OutboundConfigs) > 0 { outboundPrepends := []OutboundDetourConfig{} for i := range o.OutboundConfigs { From d25a2e0224ae34eacd25f5dedbbf221fa56a596c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 01:11:27 +0000 Subject: [PATCH 186/867] Bump github.com/gorilla/websocket from 1.5.0 to 1.5.1 Bumps [github.com/gorilla/websocket](https://github.com/gorilla/websocket) from 1.5.0 to 1.5.1. - [Release notes](https://github.com/gorilla/websocket/releases) - [Commits](https://github.com/gorilla/websocket/compare/v1.5.0...v1.5.1) --- updated-dependencies: - dependency-name: github.com/gorilla/websocket dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 917ad184..707b3b3a 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.6.0 - github.com/gorilla/websocket v1.5.0 + github.com/gorilla/websocket v1.5.1 github.com/miekg/dns v1.1.56 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 diff --git a/go.sum b/go.sum index a009a4bb..754220d4 100644 --- a/go.sum +++ b/go.sum @@ -68,8 +68,8 @@ github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98/go.mod h1:czg5+yv1E0Z github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= -github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= +github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364 h1:5XxdakFhqd9dnXoAZy1Mb2R/DZ6D1e+0bGC/JhucGYI= From ee981524b0e9c6d37c16b867efc85a7a474d0a3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 01:11:33 +0000 Subject: [PATCH 187/867] Bump golang.org/x/sync from 0.3.0 to 0.5.0 Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.3.0 to 0.5.0. - [Commits](https://github.com/golang/sync/compare/v0.3.0...v0.5.0) --- updated-dependencies: - dependency-name: golang.org/x/sync dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 707b3b3a..d3d61604 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( go4.org/netipx v0.0.0-20230824141953-6213f710f925 golang.org/x/crypto v0.14.0 golang.org/x/net v0.17.0 - golang.org/x/sync v0.3.0 + golang.org/x/sync v0.5.0 golang.org/x/sys v0.13.0 google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 diff --git a/go.sum b/go.sum index 754220d4..77053871 100644 --- a/go.sum +++ b/go.sum @@ -219,8 +219,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= -golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= +golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= From 631301a6e134c9154d9a9fe9e6e69d4ebca55fea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:55:35 +0000 Subject: [PATCH 188/867] Bump golang.org/x/sys from 0.13.0 to 0.14.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.13.0 to 0.14.0. - [Commits](https://github.com/golang/sys/compare/v0.13.0...v0.14.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d3d61604..084ef7f0 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( golang.org/x/crypto v0.14.0 golang.org/x/net v0.17.0 golang.org/x/sync v0.5.0 - golang.org/x/sys v0.13.0 + golang.org/x/sys v0.14.0 google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 diff --git a/go.sum b/go.sum index 77053871..1e099d82 100644 --- a/go.sum +++ b/go.sum @@ -231,8 +231,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 7f8ddda1c245d34b208191f907911db745247624 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:56:10 +0000 Subject: [PATCH 189/867] Bump github.com/sagernet/sing from 0.2.15 to 0.2.17 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.2.15 to 0.2.17. - [Commits](https://github.com/sagernet/sing/compare/v0.2.15...v0.2.17) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 084ef7f0..985d7ed5 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.40.0 github.com/refraction-networking/utls v1.5.4 - github.com/sagernet/sing v0.2.15 + github.com/sagernet/sing v0.2.17 github.com/sagernet/sing-shadowsocks v0.2.5 github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index 1e099d82..64f712bd 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83Fuavw github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.15 h1:PFwyiMzkyJkq+YGOVznJUsRVOT6EoVxRGIsllLuvHXA= -github.com/sagernet/sing v0.2.15/go.mod h1:AhNEHu0GXrpqkuzvTwvC8+j2cQUU/dh+zLEmq4C99pg= +github.com/sagernet/sing v0.2.17 h1:vMPKb3MV0Aa5ws4dCJkRI8XEjrsUcDn810czd0FwmzI= +github.com/sagernet/sing v0.2.17/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= github.com/sagernet/sing-shadowsocks v0.2.5 h1:qxIttos4xu6ii7MTVJYA8EFQR7Q3KG6xMqmLJIFtBaY= github.com/sagernet/sing-shadowsocks v0.2.5/go.mod h1:MGWGkcU2xW2G2mfArT9/QqpVLOGU+dBaahZCtPHdt7A= github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= From ea67c98eaf1cfd4108fbf1d99075427b3f63a5b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 9 Nov 2023 00:36:48 +0000 Subject: [PATCH 190/867] Bump golang.org/x/net from 0.17.0 to 0.18.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.17.0 to 0.18.0. - [Commits](https://github.com/golang/net/compare/v0.17.0...v0.18.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 985d7ed5..81d90e10 100644 --- a/go.mod +++ b/go.mod @@ -20,8 +20,8 @@ require ( github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 go4.org/netipx v0.0.0-20230824141953-6213f710f925 - golang.org/x/crypto v0.14.0 - golang.org/x/net v0.17.0 + golang.org/x/crypto v0.15.0 + golang.org/x/net v0.18.0 golang.org/x/sync v0.5.0 golang.org/x/sys v0.14.0 google.golang.org/grpc v1.59.0 @@ -52,7 +52,7 @@ require ( go.uber.org/mock v0.3.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.13.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect diff --git a/go.sum b/go.sum index 64f712bd..4876802d 100644 --- a/go.sum +++ b/go.sum @@ -184,8 +184,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= +golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= @@ -206,8 +206,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= +golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -237,8 +237,8 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= From 5ae3791a8e62cdb6ef7efdf6489a74679d8528b0 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 12 Nov 2023 15:10:01 -0500 Subject: [PATCH 191/867] feat : upgrade wireguard go sdk (#2716) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: kunson Co-authored-by: 世界 --- go.mod | 10 +- go.sum | 23 ++- proxy/wireguard/bind.go | 78 ++++++-- proxy/wireguard/tun.go | 348 +++++++-------------------------- proxy/wireguard/tun_default.go | 42 ++++ proxy/wireguard/tun_linux.go | 223 +++++++++++++++++++++ proxy/wireguard/wireguard.go | 152 ++++++++------ 7 files changed, 514 insertions(+), 362 deletions(-) create mode 100644 proxy/wireguard/tun_default.go create mode 100644 proxy/wireguard/tun_linux.go diff --git a/go.mod b/go.mod index 81d90e10..f3abbad1 100644 --- a/go.mod +++ b/go.mod @@ -14,19 +14,19 @@ require ( github.com/refraction-networking/utls v1.5.4 github.com/sagernet/sing v0.2.17 github.com/sagernet/sing-shadowsocks v0.2.5 - github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e + github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 go4.org/netipx v0.0.0-20230824141953-6213f710f925 golang.org/x/crypto v0.15.0 golang.org/x/net v0.18.0 golang.org/x/sync v0.5.0 golang.org/x/sys v0.14.0 + golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 - gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.2.1 ) @@ -48,14 +48,16 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/quic-go/qtls-go1-20 v0.4.1 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect - go.uber.org/atomic v1.11.0 // indirect + github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect go.uber.org/mock v0.3.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.13.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 // indirect + golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259 // indirect ) diff --git a/go.sum b/go.sum index 4876802d..3195b2b6 100644 --- a/go.sum +++ b/go.sum @@ -129,8 +129,6 @@ github.com/sagernet/sing v0.2.17 h1:vMPKb3MV0Aa5ws4dCJkRI8XEjrsUcDn810czd0FwmzI= github.com/sagernet/sing v0.2.17/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= github.com/sagernet/sing-shadowsocks v0.2.5 h1:qxIttos4xu6ii7MTVJYA8EFQR7Q3KG6xMqmLJIFtBaY= github.com/sagernet/sing-shadowsocks v0.2.5/go.mod h1:MGWGkcU2xW2G2mfArT9/QqpVLOGU+dBaahZCtPHdt7A= -github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c h1:vK2wyt9aWYHHvNLWniwijBu/n4pySypiKRhN32u/JGo= -github.com/sagernet/wireguard-go v0.0.0-20221116151939-c99467f53f2c/go.mod h1:euOmN6O5kk9dQmgSS8Df4psAl3TCjxOz0NW60EWkSaI= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= @@ -168,12 +166,15 @@ github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= +github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 h1:tkMT5pTye+1NlKIXETU78NXw0fyjnaNHmJyyLyzw8+U= +github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3/go.mod h1:cAAsePK2e15YDAMJNyOpGYEWNe4sIghTY7gpz4cX/Ik= +github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= +github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg= +github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 h1:T+YCYGfFdzyaKTDCdZn/hEiKvsw6yUfd+e4hze0rCUw= github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= @@ -227,9 +228,11 @@ golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= @@ -256,6 +259,10 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg= +golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= +golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb h1:c5tyN8sSp8jSDxdCCDXVOpJwYXXhmTkNMt+g0zTSOic= +golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= @@ -268,8 +275,8 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13 h1:N3bU/SQDCDyD6R528GJ/PwW9KjYcJA3dgyH+MovAkIM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= @@ -293,8 +300,8 @@ gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= -gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744 h1:tE44CyJgxEGzoPtHs9GI7ddKdgEGCREQBP54AmaVM+I= -gvisor.dev/gvisor v0.0.0-20230822212503-5bf4e5f98744/go.mod h1:lYEMhXbxgudVhALYsMQrBaUAjM3NMinh8mKL1CJv7rc= +gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259 h1:TbRPT0HtzFP3Cno1zZo7yPzEEnfu8EjLfl6IU9VfqkQ= +gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259/go.mod h1:AVgIgHMwK63XvmAzWG9vLQ41YnVHN0du0tEC46fI7yY= h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo= h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/proxy/wireguard/bind.go b/proxy/wireguard/bind.go index 527f0e74..c224dc56 100644 --- a/proxy/wireguard/bind.go +++ b/proxy/wireguard/bind.go @@ -9,7 +9,8 @@ import ( "strconv" "sync" - "github.com/sagernet/wireguard-go/conn" + "golang.zx2c4.com/wireguard/conn" + xnet "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/features/dns" "github.com/xtls/xray-core/transport/internet" @@ -36,7 +37,7 @@ type netBindClient struct { readQueue chan *netReadInfo } -func (n *netBindClient) ParseEndpoint(s string) (conn.Endpoint, error) { +func (bind *netBindClient) ParseEndpoint(s string) (conn.Endpoint, error) { ipStr, port, _, err := splitAddrPort(s) if err != nil { return nil, err @@ -44,7 +45,7 @@ func (n *netBindClient) ParseEndpoint(s string) (conn.Endpoint, error) { var addr net.IP if IsDomainName(ipStr) { - ips, err := n.dns.LookupIP(ipStr, n.dnsOption) + ips, err := bind.dns.LookupIP(ipStr, bind.dnsOption) if err != nil { return nil, err } else if len(ips) == 0 { @@ -79,22 +80,22 @@ func (n *netBindClient) ParseEndpoint(s string) (conn.Endpoint, error) { func (bind *netBindClient) Open(uport uint16) ([]conn.ReceiveFunc, uint16, error) { bind.readQueue = make(chan *netReadInfo) - fun := func(buff []byte) (cap int, ep conn.Endpoint, err error) { + fun := func(bufs [][]byte, sizes []int, eps []conn.Endpoint) (n int, err error) { defer func() { if r := recover(); r != nil { - cap = 0 - ep = nil + n = 0 err = errors.New("channel closed") } }() r := &netReadInfo{ - buff: buff, + buff: bufs[0], } r.waiter.Add(1) bind.readQueue <- r r.waiter.Wait() // wait read goroutine done, or we will miss the result - return r.bytes, r.endpoint, r.err + sizes[0], eps[0] = r.bytes, r.endpoint + return 1, r.err } workers := bind.workers if workers <= 0 { @@ -150,7 +151,7 @@ func (bind *netBindClient) connectTo(endpoint *netEndpoint) error { return nil } -func (bind *netBindClient) Send(buff []byte, endpoint conn.Endpoint) error { +func (bind *netBindClient) Send(buff [][]byte, endpoint conn.Endpoint) error { var err error nend, ok := endpoint.(*netEndpoint) @@ -165,19 +166,25 @@ func (bind *netBindClient) Send(buff []byte, endpoint conn.Endpoint) error { } } - if len(buff) > 3 && len(bind.reserved) == 3 { - copy(buff[1:], bind.reserved) + for _, buff := range buff { + if len(buff) > 3 && len(bind.reserved) == 3 { + copy(buff[1:], bind.reserved) + } + if _, err = nend.conn.Write(buff); err != nil { + return err + } } - - _, err = nend.conn.Write(buff) - - return err + return nil } func (bind *netBindClient) SetMark(mark uint32) error { return nil } +func (bind *netBindClient) BatchSize() int { + return 1 +} + type netEndpoint struct { dst xnet.Destination conn net.Conn @@ -264,3 +271,44 @@ func splitAddrPort(s string) (ip string, port uint16, v6 bool, err error) { return ip, port, v6, nil } + +func IsDomainName(s string) bool { + l := len(s) + if l == 0 || l > 254 || l == 254 && s[l-1] != '.' { + return false + } + last := byte('.') + nonNumeric := false + partlen := 0 + for i := 0; i < len(s); i++ { + c := s[i] + switch { + default: + return false + case 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_': + nonNumeric = true + partlen++ + case '0' <= c && c <= '9': + partlen++ + case c == '-': + if last == '.' { + return false + } + partlen++ + nonNumeric = true + case c == '.': + if last == '.' || last == '-' { + return false + } + if partlen > 63 || partlen == 0 { + return false + } + partlen = 0 + } + last = c + } + if last == '-' || partlen > 63 { + return false + } + return nonNumeric +} diff --git a/proxy/wireguard/tun.go b/proxy/wireguard/tun.go index ed6e434f..c320d0d0 100644 --- a/proxy/wireguard/tun.go +++ b/proxy/wireguard/tun.go @@ -1,303 +1,105 @@ -/* SPDX-License-Identifier: MIT - * - * Copyright (C) 2017-2022 WireGuard LLC. All Rights Reserved. - */ - package wireguard import ( "context" + "errors" "fmt" "net" "net/netip" - "os" + "runtime" + "strconv" + "strings" + "sync" - "github.com/sagernet/wireguard-go/tun" - "github.com/xtls/xray-core/features/dns" - "gvisor.dev/gvisor/pkg/buffer" - "gvisor.dev/gvisor/pkg/tcpip" - "gvisor.dev/gvisor/pkg/tcpip/adapters/gonet" - "gvisor.dev/gvisor/pkg/tcpip/header" - "gvisor.dev/gvisor/pkg/tcpip/link/channel" - "gvisor.dev/gvisor/pkg/tcpip/network/ipv4" - "gvisor.dev/gvisor/pkg/tcpip/network/ipv6" - "gvisor.dev/gvisor/pkg/tcpip/stack" - "gvisor.dev/gvisor/pkg/tcpip/transport/tcp" - "gvisor.dev/gvisor/pkg/tcpip/transport/udp" + "github.com/xtls/xray-core/common/log" + + "golang.zx2c4.com/wireguard/conn" + "golang.zx2c4.com/wireguard/device" + "golang.zx2c4.com/wireguard/tun" ) -type netTun struct { - ep *channel.Endpoint - stack *stack.Stack - events chan tun.Event - incomingPacket chan *buffer.View - mtu int - dnsClient dns.Client - hasV4, hasV6 bool +type Tunnel interface { + BuildDevice(ipc string, bind conn.Bind) error + DialContextTCPAddrPort(ctx context.Context, addr netip.AddrPort) (net.Conn, error) + DialUDPAddrPort(laddr, raddr netip.AddrPort) (net.Conn, error) + Close() error } -type Net netTun - -func CreateNetTUN(localAddresses []netip.Addr, dnsClient dns.Client, mtu int) (tun.Device, *Net, error) { - opts := stack.Options{ - NetworkProtocols: []stack.NetworkProtocolFactory{ipv4.NewProtocol, ipv6.NewProtocol}, - TransportProtocols: []stack.TransportProtocolFactory{tcp.NewProtocol, udp.NewProtocol}, - HandleLocal: true, - } - dev := &netTun{ - ep: channel.New(1024, uint32(mtu), ""), - stack: stack.New(opts), - events: make(chan tun.Event, 10), - incomingPacket: make(chan *buffer.View), - dnsClient: dnsClient, - mtu: mtu, - } - dev.ep.AddNotify(dev) - tcpipErr := dev.stack.CreateNIC(1, dev.ep) - if tcpipErr != nil { - return nil, nil, fmt.Errorf("CreateNIC: %v", tcpipErr) - } - for _, ip := range localAddresses { - var protoNumber tcpip.NetworkProtocolNumber - if ip.Is4() { - protoNumber = ipv4.ProtocolNumber - } else if ip.Is6() { - protoNumber = ipv6.ProtocolNumber - } - protoAddr := tcpip.ProtocolAddress{ - Protocol: protoNumber, - AddressWithPrefix: tcpip.AddrFromSlice(ip.AsSlice()).WithPrefix(), - } - tcpipErr := dev.stack.AddProtocolAddress(1, protoAddr, stack.AddressProperties{}) - if tcpipErr != nil { - return nil, nil, fmt.Errorf("AddProtocolAddress(%v): %v", ip, tcpipErr) - } - if ip.Is4() { - dev.hasV4 = true - } else if ip.Is6() { - dev.hasV6 = true - } - } - if dev.hasV4 { - dev.stack.AddRoute(tcpip.Route{Destination: header.IPv4EmptySubnet, NIC: 1}) - } - if dev.hasV6 { - dev.stack.AddRoute(tcpip.Route{Destination: header.IPv6EmptySubnet, NIC: 1}) - } - - dev.events <- tun.EventUp - return dev, (*Net)(dev), nil +type tunnel struct { + tun tun.Device + device *device.Device + rw sync.Mutex } -func (tun *netTun) Name() (string, error) { - return "go", nil -} +func (t *tunnel) BuildDevice(ipc string, bind conn.Bind) (err error) { + t.rw.Lock() + defer t.rw.Unlock() -func (tun *netTun) File() *os.File { + if t.device != nil { + return errors.New("device is already initialized") + } + + logger := &device.Logger{ + Verbosef: func(format string, args ...any) { + log.Record(&log.GeneralMessage{ + Severity: log.Severity_Debug, + Content: fmt.Sprintf(format, args...), + }) + }, + Errorf: func(format string, args ...any) { + log.Record(&log.GeneralMessage{ + Severity: log.Severity_Error, + Content: fmt.Sprintf(format, args...), + }) + }, + } + + t.device = device.NewDevice(t.tun, bind, logger) + if err = t.device.IpcSet(ipc); err != nil { + return err + } + if err = t.device.Up(); err != nil { + return err + } return nil } -func (tun *netTun) Events() chan tun.Event { - return tun.events -} +func (t *tunnel) Close() (err error) { + t.rw.Lock() + defer t.rw.Unlock() -func (tun *netTun) Read(buf []byte, offset int) (int, error) { - view, ok := <-tun.incomingPacket - if !ok { - return 0, os.ErrClosed + if t.device == nil { + return nil } - return view.Read(buf[offset:]) + t.device.Close() + t.device = nil + err = t.tun.Close() + t.tun = nil + return nil } -func (tun *netTun) Write(buf []byte, offset int) (int, error) { - packet := buf[offset:] - if len(packet) == 0 { - return 0, nil +func CalculateInterfaceName(name string) (tunName string) { + if runtime.GOOS == "darwin" { + tunName = "utun" + } else if name != "" { + tunName = name + } else { + tunName = "tun" } - - pkb := stack.NewPacketBuffer(stack.PacketBufferOptions{Payload: buffer.MakeWithData(packet)}) - switch packet[0] >> 4 { - case 4: - tun.ep.InjectInbound(header.IPv4ProtocolNumber, pkb) - case 6: - tun.ep.InjectInbound(header.IPv6ProtocolNumber, pkb) - } - - return len(buf), nil -} - -func (tun *netTun) WriteNotify() { - pkt := tun.ep.Read() - if pkt == nil { + interfaces, err := net.Interfaces() + if err != nil { return } - - view := pkt.ToView() - pkt.DecRef() - - tun.incomingPacket <- view -} - -func (tun *netTun) Flush() error { - return nil -} - -func (tun *netTun) Close() error { - tun.stack.RemoveNIC(1) - - if tun.events != nil { - close(tun.events) - } - - tun.ep.Close() - - if tun.incomingPacket != nil { - close(tun.incomingPacket) - } - - return nil -} - -func (tun *netTun) MTU() (int, error) { - return tun.mtu, nil -} - -func convertToFullAddr(endpoint netip.AddrPort) (tcpip.FullAddress, tcpip.NetworkProtocolNumber) { - var protoNumber tcpip.NetworkProtocolNumber - if endpoint.Addr().Is4() { - protoNumber = ipv4.ProtocolNumber - } else { - protoNumber = ipv6.ProtocolNumber - } - return tcpip.FullAddress{ - NIC: 1, - Addr: tcpip.AddrFromSlice(endpoint.Addr().AsSlice()), - Port: endpoint.Port(), - }, protoNumber -} - -func (net *Net) DialContextTCPAddrPort(ctx context.Context, addr netip.AddrPort) (*gonet.TCPConn, error) { - fa, pn := convertToFullAddr(addr) - return gonet.DialContextTCP(ctx, net.stack, fa, pn) -} - -func (net *Net) DialContextTCP(ctx context.Context, addr *net.TCPAddr) (*gonet.TCPConn, error) { - if addr == nil { - return net.DialContextTCPAddrPort(ctx, netip.AddrPort{}) - } - ip, _ := netip.AddrFromSlice(addr.IP) - return net.DialContextTCPAddrPort(ctx, netip.AddrPortFrom(ip, uint16(addr.Port))) -} - -func (net *Net) DialTCPAddrPort(addr netip.AddrPort) (*gonet.TCPConn, error) { - fa, pn := convertToFullAddr(addr) - return gonet.DialTCP(net.stack, fa, pn) -} - -func (net *Net) DialTCP(addr *net.TCPAddr) (*gonet.TCPConn, error) { - if addr == nil { - return net.DialTCPAddrPort(netip.AddrPort{}) - } - ip, _ := netip.AddrFromSlice(addr.IP) - return net.DialTCPAddrPort(netip.AddrPortFrom(ip, uint16(addr.Port))) -} - -func (net *Net) ListenTCPAddrPort(addr netip.AddrPort) (*gonet.TCPListener, error) { - fa, pn := convertToFullAddr(addr) - return gonet.ListenTCP(net.stack, fa, pn) -} - -func (net *Net) ListenTCP(addr *net.TCPAddr) (*gonet.TCPListener, error) { - if addr == nil { - return net.ListenTCPAddrPort(netip.AddrPort{}) - } - ip, _ := netip.AddrFromSlice(addr.IP) - return net.ListenTCPAddrPort(netip.AddrPortFrom(ip, uint16(addr.Port))) -} - -func (net *Net) DialUDPAddrPort(laddr, raddr netip.AddrPort) (*gonet.UDPConn, error) { - var lfa, rfa *tcpip.FullAddress - var pn tcpip.NetworkProtocolNumber - if laddr.IsValid() || laddr.Port() > 0 { - var addr tcpip.FullAddress - addr, pn = convertToFullAddr(laddr) - lfa = &addr - } - if raddr.IsValid() || raddr.Port() > 0 { - var addr tcpip.FullAddress - addr, pn = convertToFullAddr(raddr) - rfa = &addr - } - return gonet.DialUDP(net.stack, lfa, rfa, pn) -} - -func (net *Net) ListenUDPAddrPort(laddr netip.AddrPort) (*gonet.UDPConn, error) { - return net.DialUDPAddrPort(laddr, netip.AddrPort{}) -} - -func (net *Net) DialUDP(laddr, raddr *net.UDPAddr) (*gonet.UDPConn, error) { - var la, ra netip.AddrPort - if laddr != nil { - ip, _ := netip.AddrFromSlice(laddr.IP) - la = netip.AddrPortFrom(ip, uint16(laddr.Port)) - } - if raddr != nil { - ip, _ := netip.AddrFromSlice(raddr.IP) - ra = netip.AddrPortFrom(ip, uint16(raddr.Port)) - } - return net.DialUDPAddrPort(la, ra) -} - -func (net *Net) ListenUDP(laddr *net.UDPAddr) (*gonet.UDPConn, error) { - return net.DialUDP(laddr, nil) -} - -func (n *Net) HasV4() bool { - return n.hasV4 -} - -func (n *Net) HasV6() bool { - return n.hasV6 -} - -func IsDomainName(s string) bool { - l := len(s) - if l == 0 || l > 254 || l == 254 && s[l-1] != '.' { - return false - } - last := byte('.') - nonNumeric := false - partlen := 0 - for i := 0; i < len(s); i++ { - c := s[i] - switch { - default: - return false - case 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_': - nonNumeric = true - partlen++ - case '0' <= c && c <= '9': - partlen++ - case c == '-': - if last == '.' { - return false + var tunIndex int + for _, netInterface := range interfaces { + if strings.HasPrefix(netInterface.Name, tunName) { + index, parseErr := strconv.ParseInt(netInterface.Name[len(tunName):], 10, 16) + if parseErr == nil { + tunIndex = int(index) + 1 } - partlen++ - nonNumeric = true - case c == '.': - if last == '.' || last == '-' { - return false - } - if partlen > 63 || partlen == 0 { - return false - } - partlen = 0 } - last = c } - if last == '-' || partlen > 63 { - return false - } - return nonNumeric + tunName = fmt.Sprintf("%s%d", tunName, tunIndex) + return } diff --git a/proxy/wireguard/tun_default.go b/proxy/wireguard/tun_default.go new file mode 100644 index 00000000..07f21272 --- /dev/null +++ b/proxy/wireguard/tun_default.go @@ -0,0 +1,42 @@ +//go:build !linux + +package wireguard + +import ( + "context" + "net" + "net/netip" + + "golang.zx2c4.com/wireguard/tun/netstack" +) + +var _ Tunnel = (*gvisorNet)(nil) + +type gvisorNet struct { + tunnel + net *netstack.Net +} + +func (g *gvisorNet) Close() error { + return g.tunnel.Close() +} + +func (g *gvisorNet) DialContextTCPAddrPort(ctx context.Context, addr netip.AddrPort) ( + net.Conn, error, +) { + return g.net.DialContextTCPAddrPort(ctx, addr) +} + +func (g *gvisorNet) DialUDPAddrPort(laddr, raddr netip.AddrPort) (net.Conn, error) { + return g.net.DialUDPAddrPort(laddr, raddr) +} + +func CreateTun(localAddresses []netip.Addr, mtu int) (Tunnel, error) { + out := &gvisorNet{} + tun, n, err := netstack.CreateNetTUN(localAddresses, nil, mtu) + if err != nil { + return nil, err + } + out.tun, out.net = tun, n + return out, nil +} diff --git a/proxy/wireguard/tun_linux.go b/proxy/wireguard/tun_linux.go new file mode 100644 index 00000000..ec940c56 --- /dev/null +++ b/proxy/wireguard/tun_linux.go @@ -0,0 +1,223 @@ +package wireguard + +import ( + "context" + "errors" + "fmt" + "net" + "net/netip" + "os" + + "golang.org/x/sys/unix" + + "github.com/sagernet/sing/common/control" + "github.com/vishvananda/netlink" + wgtun "golang.zx2c4.com/wireguard/tun" +) + +type deviceNet struct { + tunnel + dialer net.Dialer + + handle *netlink.Handle + linkAddrs []netlink.Addr + routes []*netlink.Route + rules []*netlink.Rule +} + +func newDeviceNet(interfaceName string) *deviceNet { + var dialer net.Dialer + bindControl := control.BindToInterface(control.DefaultInterfaceFinder(), interfaceName, -1) + dialer.Control = control.Append(dialer.Control, bindControl) + return &deviceNet{dialer: dialer} +} + +func (d *deviceNet) DialContextTCPAddrPort(ctx context.Context, addr netip.AddrPort) ( + net.Conn, error, +) { + return d.dialer.DialContext(ctx, "tcp", addr.String()) +} + +func (d *deviceNet) DialUDPAddrPort(laddr, raddr netip.AddrPort) (net.Conn, error) { + dialer := d.dialer + dialer.LocalAddr = &net.UDPAddr{IP: laddr.Addr().AsSlice(), Port: int(laddr.Port())} + return dialer.DialContext(context.Background(), "udp", raddr.String()) +} + +func (d *deviceNet) Close() (err error) { + var errs []error + for _, rule := range d.rules { + if err = d.handle.RuleDel(rule); err != nil { + errs = append(errs, fmt.Errorf("failed to delete rule: %w", err)) + } + } + for _, route := range d.routes { + if err = d.handle.RouteDel(route); err != nil { + errs = append(errs, fmt.Errorf("failed to delete route: %w", err)) + } + } + if err = d.tunnel.Close(); err != nil { + errs = append(errs, fmt.Errorf("failed to close tunnel: %w", err)) + } + if d.handle != nil { + d.handle.Close() + d.handle = nil + } + if len(errs) == 0 { + return nil + } + return errors.Join(errs...) +} + +func CreateTun(localAddresses []netip.Addr, mtu int) (t Tunnel, err error) { + var v4, v6 *netip.Addr + for _, prefixes := range localAddresses { + if v4 == nil && prefixes.Is4() { + x := prefixes + v4 = &x + } + if v6 == nil && prefixes.Is6() { + x := prefixes + v6 = &x + } + } + + writeSysctlZero := func(path string) error { + _, err := os.Stat(path) + if os.IsNotExist(err) { + return nil + } + if err != nil { + return err + } + return os.WriteFile(path, []byte("0"), 0o644) + } + + // system configs. + if v4 != nil { + if err = writeSysctlZero("/proc/sys/net/ipv4/conf/all/rp_filter"); err != nil { + return nil, fmt.Errorf("failed to disable ipv4 rp_filter for all: %w", err) + } + } + if v6 != nil { + if err = writeSysctlZero("/proc/sys/net/ipv6/conf/all/disable_ipv6"); err != nil { + return nil, fmt.Errorf("failed to enable ipv6: %w", err) + } + if err = writeSysctlZero("/proc/sys/net/ipv6/conf/all/rp_filter"); err != nil { + return nil, fmt.Errorf("failed to disable ipv6 rp_filter for all: %w", err) + } + } + + n := CalculateInterfaceName("wg") + wgt, err := wgtun.CreateTUN(n, mtu) + if err != nil { + return nil, err + } + defer func() { + if err != nil { + _ = wgt.Close() + } + }() + + // disable linux rp_filter for tunnel device to avoid packet drop. + // the operation require root privilege on container require '--privileged' flag. + if v4 != nil { + if err = writeSysctlZero("/proc/sys/net/ipv4/conf/" + n + "/rp_filter"); err != nil { + return nil, fmt.Errorf("failed to disable ipv4 rp_filter for tunnel: %w", err) + } + } + if v6 != nil { + if err = writeSysctlZero("/proc/sys/net/ipv6/conf/" + n + "/rp_filter"); err != nil { + return nil, fmt.Errorf("failed to disable ipv6 rp_filter for tunnel: %w", err) + } + } + + ipv6TableIndex := 1023 + if v6 != nil { + r := &netlink.Route{Table: ipv6TableIndex} + for { + routeList, fErr := netlink.RouteListFiltered(netlink.FAMILY_V6, r, netlink.RT_FILTER_TABLE) + if len(routeList) == 0 || fErr != nil { + break + } + ipv6TableIndex-- + if ipv6TableIndex < 0 { + return nil, fmt.Errorf("failed to find available ipv6 table index") + } + } + } + + out := newDeviceNet(n) + out.handle, err = netlink.NewHandle() + if err != nil { + return nil, err + } + defer func() { + if err != nil { + _ = out.Close() + } + }() + + l, err := netlink.LinkByName(n) + if err != nil { + return nil, err + } + + if v4 != nil { + addr := netlink.Addr{ + IPNet: &net.IPNet{ + IP: v4.AsSlice(), + Mask: net.CIDRMask(v4.BitLen(), v4.BitLen()), + }, + } + out.linkAddrs = append(out.linkAddrs, addr) + } + if v6 != nil { + addr := netlink.Addr{ + IPNet: &net.IPNet{ + IP: v6.AsSlice(), + Mask: net.CIDRMask(v6.BitLen(), v6.BitLen()), + }, + } + out.linkAddrs = append(out.linkAddrs, addr) + + rt := &netlink.Route{ + LinkIndex: l.Attrs().Index, + Dst: &net.IPNet{ + IP: net.IPv6zero, + Mask: net.CIDRMask(0, 128), + }, + Table: ipv6TableIndex, + } + out.routes = append(out.routes, rt) + + r := netlink.NewRule() + r.Table, r.Family, r.Src = ipv6TableIndex, unix.AF_INET6, addr.IPNet + out.rules = append(out.rules, r) + } + + for _, addr := range out.linkAddrs { + if err = out.handle.AddrAdd(l, &addr); err != nil { + return nil, fmt.Errorf("failed to add address %s to %s: %w", addr, n, err) + } + } + if err = out.handle.LinkSetMTU(l, mtu); err != nil { + return nil, err + } + if err = out.handle.LinkSetUp(l); err != nil { + return nil, err + } + + for _, route := range out.routes { + if err = out.handle.RouteAdd(route); err != nil { + return nil, fmt.Errorf("failed to add route %s: %w", route, err) + } + } + for _, rule := range out.rules { + if err = out.handle.RuleAdd(rule); err != nil { + return nil, fmt.Errorf("failed to add rule %s: %w", rule, err) + } + } + out.tun = wgt + return out, nil +} diff --git a/proxy/wireguard/wireguard.go b/proxy/wireguard/wireguard.go index 899dcac5..231776e7 100644 --- a/proxy/wireguard/wireguard.go +++ b/proxy/wireguard/wireguard.go @@ -24,10 +24,11 @@ import ( "bytes" "context" "fmt" + stdnet "net" "net/netip" "strings" + "sync" - "github.com/sagernet/wireguard-go/device" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/log" @@ -46,13 +47,15 @@ import ( // Handler is an outbound connection that silently swallow the entire payload. type Handler struct { conf *DeviceConfig - net *Net + net Tunnel bind *netBindClient policyManager policy.Manager dns dns.Client // cached configuration - ipc string - endpoints []netip.Addr + ipc string + endpoints []netip.Addr + hasIPv4, hasIPv6 bool + wgLock sync.Mutex } // New creates a new wireguard handler. @@ -64,15 +67,71 @@ func New(ctx context.Context, conf *DeviceConfig) (*Handler, error) { return nil, err } + hasIPv4, hasIPv6 := false, false + for _, e := range endpoints { + if e.Is4() { + hasIPv4 = true + } + if e.Is6() { + hasIPv6 = true + } + } + + d := v.GetFeature(dns.ClientType()).(dns.Client) return &Handler{ conf: conf, policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), - dns: v.GetFeature(dns.ClientType()).(dns.Client), - ipc: createIPCRequest(conf), + dns: d, + ipc: createIPCRequest(conf, d, hasIPv6), endpoints: endpoints, + hasIPv4: hasIPv4, + hasIPv6: hasIPv6, }, nil } +func (h *Handler) processWireGuard(dialer internet.Dialer) (err error) { + h.wgLock.Lock() + defer h.wgLock.Unlock() + + if h.bind != nil && h.bind.dialer == dialer && h.net != nil { + return nil + } + + log.Record(&log.GeneralMessage{ + Severity: log.Severity_Info, + Content: "switching dialer", + }) + + if h.net != nil { + _ = h.net.Close() + h.net = nil + } + if h.bind != nil { + _ = h.bind.Close() + h.bind = nil + } + + // bind := conn.NewStdNetBind() // TODO: conn.Bind wrapper for dialer + bind := &netBindClient{ + dialer: dialer, + workers: int(h.conf.NumWorkers), + dns: h.dns, + reserved: h.conf.Reserved, + } + defer func() { + if err != nil { + _ = bind.Close() + } + }() + + h.net, err = h.makeVirtualTun(bind) + if err != nil { + return newError("failed to create virtual tun interface").Base(err) + } + h.bind = bind + return nil +} + // Process implements OutboundHandler.Dispatch(). func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error { outbound := session.OutboundFromContext(ctx) @@ -85,30 +144,8 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte inbound.SetCanSpliceCopy(3) } - if h.bind == nil || h.bind.dialer != dialer || h.net == nil { - log.Record(&log.GeneralMessage{ - Severity: log.Severity_Info, - Content: "switching dialer", - }) - // bind := conn.NewStdNetBind() // TODO: conn.Bind wrapper for dialer - bind := &netBindClient{ - dialer: dialer, - workers: int(h.conf.NumWorkers), - dns: h.dns, - reserved: h.conf.Reserved, - } - - net, err := h.makeVirtualTun(bind) - if err != nil { - bind.Close() - return newError("failed to create virtual tun interface").Base(err) - } - - h.net = net - if h.bind != nil { - h.bind.Close() - } - h.bind = bind + if err := h.processWireGuard(dialer); err != nil { + return err } // Destination of the inner request. @@ -122,8 +159,8 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte addr := destination.Address if addr.Family().IsDomain() { ips, err := h.dns.LookupIP(addr.Domain(), dns.IPOption{ - IPv4Enable: h.net.HasV4(), - IPv6Enable: h.net.HasV6(), + IPv4Enable: h.hasIPv4, + IPv6Enable: h.hasIPv6, }) if err != nil { return newError("failed to lookup DNS").Base(err) @@ -200,14 +237,26 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } // serialize the config into an IPC request -func createIPCRequest(conf *DeviceConfig) string { +func createIPCRequest(conf *DeviceConfig, d dns.Client, resolveEndPointToV4 bool) string { var request bytes.Buffer request.WriteString(fmt.Sprintf("private_key=%s\n", conf.SecretKey)) for _, peer := range conf.Peers { + endpoint := peer.Endpoint + host, port, err := net.SplitHostPort(endpoint) + if resolveEndPointToV4 && err == nil { + _, err = netip.ParseAddr(host) + if err != nil { + ipList, err := d.LookupIP(host, dns.IPOption{IPv4Enable: true, IPv6Enable: false}) + if err == nil && len(ipList) > 0 { + endpoint = stdnet.JoinHostPort(ipList[0].String(), port) + } + } + } + request.WriteString(fmt.Sprintf("public_key=%s\nendpoint=%s\npersistent_keepalive_interval=%d\npreshared_key=%s\n", - peer.PublicKey, peer.Endpoint, peer.KeepAlive, peer.PreSharedKey)) + peer.PublicKey, endpoint, peer.KeepAlive, peer.PreSharedKey)) for _, ip := range peer.AllowedIps { request.WriteString(fmt.Sprintf("allowed_ip=%s\n", ip)) @@ -245,41 +294,20 @@ func parseEndpoints(conf *DeviceConfig) ([]netip.Addr, error) { } // creates a tun interface on netstack given a configuration -func (h *Handler) makeVirtualTun(bind *netBindClient) (*Net, error) { - tun, tnet, err := CreateNetTUN(h.endpoints, h.dns, int(h.conf.Mtu)) +func (h *Handler) makeVirtualTun(bind *netBindClient) (Tunnel, error) { + t, err := CreateTun(h.endpoints, int(h.conf.Mtu)) if err != nil { return nil, err } - bind.dnsOption.IPv4Enable = tnet.HasV4() - bind.dnsOption.IPv6Enable = tnet.HasV6() + bind.dnsOption.IPv4Enable = h.hasIPv4 + bind.dnsOption.IPv6Enable = h.hasIPv6 - // dev := device.NewDevice(tun, conn.NewDefaultBind(), nil /* device.NewLogger(device.LogLevelVerbose, "") */) - dev := device.NewDevice(tun, bind, &device.Logger{ - Verbosef: func(format string, args ...any) { - log.Record(&log.GeneralMessage{ - Severity: log.Severity_Debug, - Content: fmt.Sprintf(format, args...), - }) - }, - Errorf: func(format string, args ...any) { - log.Record(&log.GeneralMessage{ - Severity: log.Severity_Error, - Content: fmt.Sprintf(format, args...), - }) - }, - }, int(h.conf.NumWorkers)) - err = dev.IpcSet(h.ipc) - if err != nil { + if err = t.BuildDevice(h.ipc, bind); err != nil { + _ = t.Close() return nil, err } - - err = dev.Up() - if err != nil { - return nil, err - } - - return tnet, nil + return t, nil } func init() { From cc4b28b15900dc80211fb78fdbeb203b527976a5 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 12 Nov 2023 14:28:36 -0500 Subject: [PATCH 192/867] Remove dragonfly build --- .github/build/friendly-filenames.json | 1 - .github/workflows/release.yml | 6 ++---- transport/internet/sockopt_other.go | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/build/friendly-filenames.json b/.github/build/friendly-filenames.json index f7a3e526..d4001f70 100644 --- a/.github/build/friendly-filenames.json +++ b/.github/build/friendly-filenames.json @@ -2,7 +2,6 @@ "android-arm64": { "friendlyName": "android-arm64-v8a" }, "darwin-amd64": { "friendlyName": "macos-64" }, "darwin-arm64": { "friendlyName": "macos-arm64-v8a" }, - "dragonfly-amd64": { "friendlyName": "dragonfly-64" }, "freebsd-386": { "friendlyName": "freebsd-32" }, "freebsd-amd64": { "friendlyName": "freebsd-64" }, "freebsd-arm64": { "friendlyName": "freebsd-arm64-v8a" }, diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 30b96142..57e14693 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,12 +70,10 @@ jobs: strategy: matrix: # Include amd64 on all platforms. - goos: [windows, freebsd, openbsd, linux, dragonfly, darwin] + goos: [windows, freebsd, openbsd, linux, darwin] goarch: [amd64, 386] exclude: - # Exclude i386 on darwin and dragonfly. - - goarch: 386 - goos: dragonfly + # Exclude i386 on darwin - goarch: 386 goos: darwin include: diff --git a/transport/internet/sockopt_other.go b/transport/internet/sockopt_other.go index ebcf4e26..7e91110e 100644 --- a/transport/internet/sockopt_other.go +++ b/transport/internet/sockopt_other.go @@ -1,5 +1,5 @@ -//go:build js || dragonfly || netbsd || openbsd || solaris -// +build js dragonfly netbsd openbsd solaris +//go:build js || netbsd || openbsd || solaris +// +build js netbsd openbsd solaris package internet From a109389efb17a1fabd7c79872dbfb5b3997799fb Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 12 Nov 2023 15:52:09 -0500 Subject: [PATCH 193/867] Wireguard resolve strategy (#2717) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 增加 wireguard 出站选项 `resolveStrategy`. * They become a part of you. * 移除不必要的选项别名. * aliases NG. * 微调. --------- Co-authored-by: rui0572 <125641819+rui0572@users.noreply.github.com> --- infra/conf/wireguard.go | 29 ++++++-- infra/conf/wireguard_test.go | 8 ++- proxy/wireguard/config.go | 25 +++++++ proxy/wireguard/config.pb.go | 125 ++++++++++++++++++++++++++++------- proxy/wireguard/config.proto | 8 +++ proxy/wireguard/wireguard.go | 15 ++++- 6 files changed, 175 insertions(+), 35 deletions(-) create mode 100644 proxy/wireguard/config.go diff --git a/infra/conf/wireguard.go b/infra/conf/wireguard.go index 0c79297b..7b2b6bbf 100644 --- a/infra/conf/wireguard.go +++ b/infra/conf/wireguard.go @@ -3,6 +3,7 @@ package conf import ( "encoding/base64" "encoding/hex" + "strings" "github.com/xtls/xray-core/proxy/wireguard" "google.golang.org/protobuf/proto" @@ -47,12 +48,13 @@ func (c *WireGuardPeerConfig) Build() (proto.Message, error) { } type WireGuardConfig struct { - SecretKey string `json:"secretKey"` - Address []string `json:"address"` - Peers []*WireGuardPeerConfig `json:"peers"` - MTU int `json:"mtu"` - NumWorkers int `json:"workers"` - Reserved []byte `json:"reserved"` + SecretKey string `json:"secretKey"` + Address []string `json:"address"` + Peers []*WireGuardPeerConfig `json:"peers"` + MTU int `json:"mtu"` + NumWorkers int `json:"workers"` + Reserved []byte `json:"reserved"` + DomainStrategy string `json:"domainStrategy"` } func (c *WireGuardConfig) Build() (proto.Message, error) { @@ -96,6 +98,21 @@ func (c *WireGuardConfig) Build() (proto.Message, error) { } config.Reserved = c.Reserved + switch strings.ToLower(c.DomainStrategy) { + case "forceip", "": + config.DomainStrategy = wireguard.DeviceConfig_FORCE_IP + case "forceipv4": + config.DomainStrategy = wireguard.DeviceConfig_FORCE_IP4 + case "forceipv6": + config.DomainStrategy = wireguard.DeviceConfig_FORCE_IP6 + case "forceipv4v6": + config.DomainStrategy = wireguard.DeviceConfig_FORCE_IP46 + case "forceipv6v4": + config.DomainStrategy = wireguard.DeviceConfig_FORCE_IP64 + default: + return nil, newError("unsupported domain strategy: ", c.DomainStrategy) + } + return config, nil } diff --git a/infra/conf/wireguard_test.go b/infra/conf/wireguard_test.go index f0136bf0..7a4adf36 100644 --- a/infra/conf/wireguard_test.go +++ b/infra/conf/wireguard_test.go @@ -24,7 +24,8 @@ func TestWireGuardOutbound(t *testing.T) { } ], "mtu": 1300, - "workers": 2 + "workers": 2, + "domainStrategy": "ForceIPv6v4" }`, Parser: loadJSON(creator), Output: &wireguard.DeviceConfig{ @@ -41,8 +42,9 @@ func TestWireGuardOutbound(t *testing.T) { AllowedIps: []string{"0.0.0.0/0", "::0/0"}, }, }, - Mtu: 1300, - NumWorkers: 2, + Mtu: 1300, + NumWorkers: 2, + DomainStrategy: wireguard.DeviceConfig_FORCE_IP64, }, }, }) diff --git a/proxy/wireguard/config.go b/proxy/wireguard/config.go new file mode 100644 index 00000000..75622753 --- /dev/null +++ b/proxy/wireguard/config.go @@ -0,0 +1,25 @@ +package wireguard + +func (c *DeviceConfig) preferIP4() bool { + return c.DomainStrategy == DeviceConfig_FORCE_IP || + c.DomainStrategy == DeviceConfig_FORCE_IP4 || + c.DomainStrategy == DeviceConfig_FORCE_IP46 +} + +func (c *DeviceConfig) preferIP6() bool { + return c.DomainStrategy == DeviceConfig_FORCE_IP || + c.DomainStrategy == DeviceConfig_FORCE_IP6 || + c.DomainStrategy == DeviceConfig_FORCE_IP64 +} + +func (c *DeviceConfig) hasFallback() bool { + return c.DomainStrategy == DeviceConfig_FORCE_IP46 || c.DomainStrategy == DeviceConfig_FORCE_IP64 +} + +func (c *DeviceConfig) fallbackIP4() bool { + return c.DomainStrategy == DeviceConfig_FORCE_IP64 +} + +func (c *DeviceConfig) fallbackIP6() bool { + return c.DomainStrategy == DeviceConfig_FORCE_IP46 +} diff --git a/proxy/wireguard/config.pb.go b/proxy/wireguard/config.pb.go index 442d78f0..6af1f41c 100644 --- a/proxy/wireguard/config.pb.go +++ b/proxy/wireguard/config.pb.go @@ -20,6 +20,61 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type DeviceConfig_DomainStrategy int32 + +const ( + DeviceConfig_FORCE_IP DeviceConfig_DomainStrategy = 0 + DeviceConfig_FORCE_IP4 DeviceConfig_DomainStrategy = 1 + DeviceConfig_FORCE_IP6 DeviceConfig_DomainStrategy = 2 + DeviceConfig_FORCE_IP46 DeviceConfig_DomainStrategy = 3 + DeviceConfig_FORCE_IP64 DeviceConfig_DomainStrategy = 4 +) + +// Enum value maps for DeviceConfig_DomainStrategy. +var ( + DeviceConfig_DomainStrategy_name = map[int32]string{ + 0: "FORCE_IP", + 1: "FORCE_IP4", + 2: "FORCE_IP6", + 3: "FORCE_IP46", + 4: "FORCE_IP64", + } + DeviceConfig_DomainStrategy_value = map[string]int32{ + "FORCE_IP": 0, + "FORCE_IP4": 1, + "FORCE_IP6": 2, + "FORCE_IP46": 3, + "FORCE_IP64": 4, + } +) + +func (x DeviceConfig_DomainStrategy) Enum() *DeviceConfig_DomainStrategy { + p := new(DeviceConfig_DomainStrategy) + *p = x + return p +} + +func (x DeviceConfig_DomainStrategy) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (DeviceConfig_DomainStrategy) Descriptor() protoreflect.EnumDescriptor { + return file_proxy_wireguard_config_proto_enumTypes[0].Descriptor() +} + +func (DeviceConfig_DomainStrategy) Type() protoreflect.EnumType { + return &file_proxy_wireguard_config_proto_enumTypes[0] +} + +func (x DeviceConfig_DomainStrategy) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use DeviceConfig_DomainStrategy.Descriptor instead. +func (DeviceConfig_DomainStrategy) EnumDescriptor() ([]byte, []int) { + return file_proxy_wireguard_config_proto_rawDescGZIP(), []int{1, 0} +} + type PeerConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -104,12 +159,13 @@ type DeviceConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - SecretKey string `protobuf:"bytes,1,opt,name=secret_key,json=secretKey,proto3" json:"secret_key,omitempty"` - Endpoint []string `protobuf:"bytes,2,rep,name=endpoint,proto3" json:"endpoint,omitempty"` - Peers []*PeerConfig `protobuf:"bytes,3,rep,name=peers,proto3" json:"peers,omitempty"` - Mtu int32 `protobuf:"varint,4,opt,name=mtu,proto3" json:"mtu,omitempty"` - NumWorkers int32 `protobuf:"varint,5,opt,name=num_workers,json=numWorkers,proto3" json:"num_workers,omitempty"` - Reserved []byte `protobuf:"bytes,6,opt,name=reserved,proto3" json:"reserved,omitempty"` + SecretKey string `protobuf:"bytes,1,opt,name=secret_key,json=secretKey,proto3" json:"secret_key,omitempty"` + Endpoint []string `protobuf:"bytes,2,rep,name=endpoint,proto3" json:"endpoint,omitempty"` + Peers []*PeerConfig `protobuf:"bytes,3,rep,name=peers,proto3" json:"peers,omitempty"` + Mtu int32 `protobuf:"varint,4,opt,name=mtu,proto3" json:"mtu,omitempty"` + NumWorkers int32 `protobuf:"varint,5,opt,name=num_workers,json=numWorkers,proto3" json:"num_workers,omitempty"` + Reserved []byte `protobuf:"bytes,6,opt,name=reserved,proto3" json:"reserved,omitempty"` + DomainStrategy DeviceConfig_DomainStrategy `protobuf:"varint,7,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.proxy.wireguard.DeviceConfig_DomainStrategy" json:"domain_strategy,omitempty"` } func (x *DeviceConfig) Reset() { @@ -186,6 +242,13 @@ func (x *DeviceConfig) GetReserved() []byte { return nil } +func (x *DeviceConfig) GetDomainStrategy() DeviceConfig_DomainStrategy { + if x != nil { + return x.DomainStrategy + } + return DeviceConfig_FORCE_IP +} + var File_proxy_wireguard_config_proto protoreflect.FileDescriptor var file_proxy_wireguard_config_proto_rawDesc = []byte{ @@ -203,7 +266,7 @@ var file_proxy_wireguard_config_proto_rawDesc = []byte{ 0x76, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, - 0x64, 0x49, 0x70, 0x73, 0x22, 0xd0, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x43, + 0x64, 0x49, 0x70, 0x73, 0x22, 0x8a, 0x03, 0x0a, 0x0c, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, @@ -216,13 +279,25 @@ var file_proxy_wireguard_config_proto_rawDesc = []byte{ 0x6d, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x6e, 0x75, 0x6d, 0x57, 0x6f, 0x72, 0x6b, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x72, - 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x42, 0x5e, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x77, 0x69, 0x72, 0x65, 0x67, 0x75, - 0x61, 0x72, 0x64, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x77, 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, - 0xaa, 0x02, 0x14, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x57, 0x69, - 0x72, 0x65, 0x47, 0x75, 0x61, 0x72, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x73, 0x65, 0x72, 0x76, 0x65, 0x64, 0x12, 0x5a, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x31, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x77, 0x69, + 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x22, 0x5c, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, + 0x50, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, + 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, + 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, + 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, + 0x04, 0x42, 0x5e, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x2e, 0x77, 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0x50, 0x01, 0x5a, + 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, + 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2f, 0x77, 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0xaa, 0x02, 0x14, 0x58, 0x72, 0x61, + 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x57, 0x69, 0x72, 0x65, 0x47, 0x75, 0x61, 0x72, + 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -237,18 +312,21 @@ func file_proxy_wireguard_config_proto_rawDescGZIP() []byte { return file_proxy_wireguard_config_proto_rawDescData } +var file_proxy_wireguard_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_proxy_wireguard_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_proxy_wireguard_config_proto_goTypes = []interface{}{ - (*PeerConfig)(nil), // 0: xray.proxy.wireguard.PeerConfig - (*DeviceConfig)(nil), // 1: xray.proxy.wireguard.DeviceConfig + (DeviceConfig_DomainStrategy)(0), // 0: xray.proxy.wireguard.DeviceConfig.DomainStrategy + (*PeerConfig)(nil), // 1: xray.proxy.wireguard.PeerConfig + (*DeviceConfig)(nil), // 2: xray.proxy.wireguard.DeviceConfig } var file_proxy_wireguard_config_proto_depIdxs = []int32{ - 0, // 0: xray.proxy.wireguard.DeviceConfig.peers:type_name -> xray.proxy.wireguard.PeerConfig - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 1, // 0: xray.proxy.wireguard.DeviceConfig.peers:type_name -> xray.proxy.wireguard.PeerConfig + 0, // 1: xray.proxy.wireguard.DeviceConfig.domain_strategy:type_name -> xray.proxy.wireguard.DeviceConfig.DomainStrategy + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_proxy_wireguard_config_proto_init() } @@ -287,13 +365,14 @@ func file_proxy_wireguard_config_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proxy_wireguard_config_proto_rawDesc, - NumEnums: 0, + NumEnums: 1, NumMessages: 2, NumExtensions: 0, NumServices: 0, }, GoTypes: file_proxy_wireguard_config_proto_goTypes, DependencyIndexes: file_proxy_wireguard_config_proto_depIdxs, + EnumInfos: file_proxy_wireguard_config_proto_enumTypes, MessageInfos: file_proxy_wireguard_config_proto_msgTypes, }.Build() File_proxy_wireguard_config_proto = out.File diff --git a/proxy/wireguard/config.proto b/proxy/wireguard/config.proto index 810a1126..0a12c009 100644 --- a/proxy/wireguard/config.proto +++ b/proxy/wireguard/config.proto @@ -15,10 +15,18 @@ message PeerConfig { } message DeviceConfig { + enum DomainStrategy { + FORCE_IP = 0; + FORCE_IP4 = 1; + FORCE_IP6 = 2; + FORCE_IP46 = 3; + FORCE_IP64 = 4; + } string secret_key = 1; repeated string endpoint = 2; repeated PeerConfig peers = 3; int32 mtu = 4; int32 num_workers = 5; bytes reserved = 6; + DomainStrategy domain_strategy = 7; } \ No newline at end of file diff --git a/proxy/wireguard/wireguard.go b/proxy/wireguard/wireguard.go index 231776e7..48e2ace3 100644 --- a/proxy/wireguard/wireguard.go +++ b/proxy/wireguard/wireguard.go @@ -31,6 +31,7 @@ import ( "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/log" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" @@ -159,15 +160,23 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte addr := destination.Address if addr.Family().IsDomain() { ips, err := h.dns.LookupIP(addr.Domain(), dns.IPOption{ - IPv4Enable: h.hasIPv4, - IPv6Enable: h.hasIPv6, + IPv4Enable: h.hasIPv4 && h.conf.preferIP4(), + IPv6Enable: h.hasIPv6 && h.conf.preferIP6(), }) + { // Resolve fallback + if (len(ips) == 0 || err != nil) && h.conf.hasFallback() { + ips, err = h.dns.LookupIP(addr.Domain(), dns.IPOption{ + IPv4Enable: h.hasIPv4 && h.conf.fallbackIP4(), + IPv6Enable: h.hasIPv6 && h.conf.fallbackIP6(), + }) + } + } if err != nil { return newError("failed to lookup DNS").Base(err) } else if len(ips) == 0 { return dns.ErrEmptyResponse } - addr = net.IPAddress(ips[0]) + addr = net.IPAddress(ips[dice.Roll(len(ips))]) } var newCtx context.Context From d9fd3f8eb147e28c16a75419b930c9ce6df67497 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 12 Nov 2023 16:27:39 -0500 Subject: [PATCH 194/867] Freedom xdomain strategy (#2719) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 统一 `domainStrategy` 行为. * aliases NG. * 化简. * 调整. * Let it crash. * Update proto --------- Co-authored-by: rui0572 <125641819+rui0572@users.noreply.github.com> --- app/commander/config.pb.go | 2 +- app/dispatcher/config.pb.go | 2 +- app/dns/config.pb.go | 2 +- app/dns/fakedns/fakedns.pb.go | 2 +- app/log/command/config.pb.go | 2 +- app/log/config.pb.go | 2 +- app/metrics/config.pb.go | 2 +- app/observatory/command/command.pb.go | 2 +- app/observatory/config.pb.go | 2 +- app/policy/config.pb.go | 2 +- app/proxyman/command/command.pb.go | 2 +- app/proxyman/config.pb.go | 2 +- app/reverse/config.pb.go | 2 +- app/router/command/command.pb.go | 2 +- app/router/config.pb.go | 2 +- app/stats/command/command.pb.go | 2 +- app/stats/config.pb.go | 2 +- common/log/log.pb.go | 2 +- common/net/address.pb.go | 2 +- common/net/destination.pb.go | 2 +- common/net/network.pb.go | 2 +- common/net/port.pb.go | 2 +- common/protocol/headers.pb.go | 2 +- common/protocol/server_spec.pb.go | 2 +- common/protocol/user.pb.go | 2 +- common/serial/typed_message.pb.go | 2 +- core/config.pb.go | 2 +- infra/conf/freedom.go | 25 +++++- proxy/blackhole/config.pb.go | 2 +- proxy/dns/config.pb.go | 2 +- proxy/dokodemo/config.pb.go | 2 +- proxy/freedom/config.go | 43 +++++++++- proxy/freedom/config.pb.go | 79 +++++++++++++------ proxy/freedom/config.proto | 7 ++ proxy/freedom/freedom.go | 34 ++++---- proxy/http/config.pb.go | 2 +- proxy/loopback/config.pb.go | 2 +- proxy/shadowsocks/config.pb.go | 2 +- proxy/shadowsocks_2022/config.pb.go | 2 +- proxy/socks/config.pb.go | 2 +- proxy/trojan/config.pb.go | 2 +- proxy/vless/account.pb.go | 2 +- proxy/vless/encoding/addons.pb.go | 2 +- proxy/vless/inbound/config.pb.go | 2 +- proxy/vless/outbound/config.pb.go | 2 +- proxy/vmess/account.pb.go | 2 +- proxy/vmess/inbound/config.pb.go | 2 +- proxy/vmess/outbound/config.pb.go | 2 +- proxy/wireguard/config.pb.go | 2 +- transport/global/config.pb.go | 2 +- transport/internet/config.pb.go | 2 +- transport/internet/domainsocket/config.pb.go | 2 +- transport/internet/grpc/config.pb.go | 2 +- transport/internet/grpc/encoding/stream.pb.go | 2 +- transport/internet/headers/dns/config.pb.go | 2 +- transport/internet/headers/http/config.pb.go | 2 +- transport/internet/headers/noop/config.pb.go | 2 +- transport/internet/headers/srtp/config.pb.go | 2 +- transport/internet/headers/tls/config.pb.go | 2 +- transport/internet/headers/utp/config.pb.go | 2 +- .../internet/headers/wechat/config.pb.go | 2 +- .../internet/headers/wireguard/config.pb.go | 2 +- transport/internet/http/config.pb.go | 2 +- transport/internet/kcp/config.pb.go | 2 +- transport/internet/quic/config.pb.go | 2 +- transport/internet/reality/config.pb.go | 2 +- transport/internet/tcp/config.pb.go | 2 +- transport/internet/tls/config.pb.go | 2 +- transport/internet/udp/config.pb.go | 2 +- transport/internet/websocket/config.pb.go | 2 +- 70 files changed, 201 insertions(+), 117 deletions(-) diff --git a/app/commander/config.pb.go b/app/commander/config.pb.go index 73037653..32dd608a 100644 --- a/app/commander/config.pb.go +++ b/app/commander/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/commander/config.proto diff --git a/app/dispatcher/config.pb.go b/app/dispatcher/config.pb.go index e0a55ab2..1512f186 100644 --- a/app/dispatcher/config.pb.go +++ b/app/dispatcher/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/dispatcher/config.proto diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index 8a066a9e..2d84fe72 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/dns/config.proto diff --git a/app/dns/fakedns/fakedns.pb.go b/app/dns/fakedns/fakedns.pb.go index dc9970f9..dea59f99 100644 --- a/app/dns/fakedns/fakedns.pb.go +++ b/app/dns/fakedns/fakedns.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/dns/fakedns/fakedns.proto diff --git a/app/log/command/config.pb.go b/app/log/command/config.pb.go index 6a3d6602..21637a8b 100644 --- a/app/log/command/config.pb.go +++ b/app/log/command/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/log/command/config.proto diff --git a/app/log/config.pb.go b/app/log/config.pb.go index 0bc09d40..7829713c 100644 --- a/app/log/config.pb.go +++ b/app/log/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/log/config.proto diff --git a/app/metrics/config.pb.go b/app/metrics/config.pb.go index 2cf67618..a93bbb64 100644 --- a/app/metrics/config.pb.go +++ b/app/metrics/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/metrics/config.proto diff --git a/app/observatory/command/command.pb.go b/app/observatory/command/command.pb.go index 9eab1533..df531537 100644 --- a/app/observatory/command/command.pb.go +++ b/app/observatory/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/observatory/command/command.proto diff --git a/app/observatory/config.pb.go b/app/observatory/config.pb.go index 741da506..43eb7196 100644 --- a/app/observatory/config.pb.go +++ b/app/observatory/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/observatory/config.proto diff --git a/app/policy/config.pb.go b/app/policy/config.pb.go index 9841fff0..c8b4311c 100644 --- a/app/policy/config.pb.go +++ b/app/policy/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/policy/config.proto diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index 9add8afb..458179e5 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/proxyman/command/command.proto diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index cabc09dd..db41ad75 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/proxyman/config.proto diff --git a/app/reverse/config.pb.go b/app/reverse/config.pb.go index 0e1bc941..83c0709b 100644 --- a/app/reverse/config.pb.go +++ b/app/reverse/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/reverse/config.proto diff --git a/app/router/command/command.pb.go b/app/router/command/command.pb.go index eb7c8530..18296ff9 100644 --- a/app/router/command/command.pb.go +++ b/app/router/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/router/command/command.proto diff --git a/app/router/config.pb.go b/app/router/config.pb.go index 3fd01cc7..cfe5a8fc 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/router/config.proto diff --git a/app/stats/command/command.pb.go b/app/stats/command/command.pb.go index 6d4d0d38..089dd183 100644 --- a/app/stats/command/command.pb.go +++ b/app/stats/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/stats/command/command.proto diff --git a/app/stats/config.pb.go b/app/stats/config.pb.go index 216da044..7c944e9b 100644 --- a/app/stats/config.pb.go +++ b/app/stats/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: app/stats/config.proto diff --git a/common/log/log.pb.go b/common/log/log.pb.go index 92ea0811..871d019b 100644 --- a/common/log/log.pb.go +++ b/common/log/log.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: common/log/log.proto diff --git a/common/net/address.pb.go b/common/net/address.pb.go index 82240db3..c0ebb72a 100644 --- a/common/net/address.pb.go +++ b/common/net/address.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: common/net/address.proto diff --git a/common/net/destination.pb.go b/common/net/destination.pb.go index ea6339cb..ee775c7b 100644 --- a/common/net/destination.pb.go +++ b/common/net/destination.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: common/net/destination.proto diff --git a/common/net/network.pb.go b/common/net/network.pb.go index 18e0df4b..39a1dcd3 100644 --- a/common/net/network.pb.go +++ b/common/net/network.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: common/net/network.proto diff --git a/common/net/port.pb.go b/common/net/port.pb.go index 255bd940..791e4e7e 100644 --- a/common/net/port.pb.go +++ b/common/net/port.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: common/net/port.proto diff --git a/common/protocol/headers.pb.go b/common/protocol/headers.pb.go index 96c427d4..f733c419 100644 --- a/common/protocol/headers.pb.go +++ b/common/protocol/headers.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: common/protocol/headers.proto diff --git a/common/protocol/server_spec.pb.go b/common/protocol/server_spec.pb.go index da698518..5c8ed7de 100644 --- a/common/protocol/server_spec.pb.go +++ b/common/protocol/server_spec.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: common/protocol/server_spec.proto diff --git a/common/protocol/user.pb.go b/common/protocol/user.pb.go index 6f063e73..77c26e22 100644 --- a/common/protocol/user.pb.go +++ b/common/protocol/user.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: common/protocol/user.proto diff --git a/common/serial/typed_message.pb.go b/common/serial/typed_message.pb.go index b03f2aaa..09c71b0d 100644 --- a/common/serial/typed_message.pb.go +++ b/common/serial/typed_message.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: common/serial/typed_message.proto diff --git a/core/config.pb.go b/core/config.pb.go index c36e7fd0..72ba2379 100644 --- a/core/config.pb.go +++ b/core/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: core/config.proto diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 21f0616a..dd812db6 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -28,14 +28,31 @@ type Fragment struct { // Build implements Buildable func (c *FreedomConfig) Build() (proto.Message, error) { config := new(freedom.Config) - config.DomainStrategy = freedom.Config_AS_IS switch strings.ToLower(c.DomainStrategy) { - case "useip", "use_ip", "use-ip": + case "asis", "": + config.DomainStrategy = freedom.Config_AS_IS + case "useip": config.DomainStrategy = freedom.Config_USE_IP - case "useip4", "useipv4", "use_ip4", "use_ipv4", "use_ip_v4", "use-ip4", "use-ipv4", "use-ip-v4": + case "useipv4": config.DomainStrategy = freedom.Config_USE_IP4 - case "useip6", "useipv6", "use_ip6", "use_ipv6", "use_ip_v6", "use-ip6", "use-ipv6", "use-ip-v6": + case "useipv6": config.DomainStrategy = freedom.Config_USE_IP6 + case "useipv4v6": + config.DomainStrategy = freedom.Config_USE_IP46 + case "useipv6v4": + config.DomainStrategy = freedom.Config_USE_IP64 + case "forceip": + config.DomainStrategy = freedom.Config_FORCE_IP + case "forceipv4": + config.DomainStrategy = freedom.Config_FORCE_IP4 + case "forceipv6": + config.DomainStrategy = freedom.Config_FORCE_IP6 + case "forceipv4v6": + config.DomainStrategy = freedom.Config_FORCE_IP46 + case "forceipv6v4": + config.DomainStrategy = freedom.Config_FORCE_IP64 + default: + return nil, newError("unsupported domain strategy: ", c.DomainStrategy) } if c.Fragment != nil { diff --git a/proxy/blackhole/config.pb.go b/proxy/blackhole/config.pb.go index 2bc838c6..0cdb33a7 100644 --- a/proxy/blackhole/config.pb.go +++ b/proxy/blackhole/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/blackhole/config.proto diff --git a/proxy/dns/config.pb.go b/proxy/dns/config.pb.go index 24016460..767ad2ca 100644 --- a/proxy/dns/config.pb.go +++ b/proxy/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/dns/config.proto diff --git a/proxy/dokodemo/config.pb.go b/proxy/dokodemo/config.pb.go index 6e43def1..c56e74b9 100644 --- a/proxy/dokodemo/config.pb.go +++ b/proxy/dokodemo/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/dokodemo/config.proto diff --git a/proxy/freedom/config.go b/proxy/freedom/config.go index 61cc6ad5..2e67244b 100644 --- a/proxy/freedom/config.go +++ b/proxy/freedom/config.go @@ -1,5 +1,44 @@ package freedom -func (c *Config) useIP() bool { - return c.DomainStrategy == Config_USE_IP || c.DomainStrategy == Config_USE_IP4 || c.DomainStrategy == Config_USE_IP6 +var strategy = [][]byte{ + // name strategy, prefer, fallback + {0, 0, 0}, // AsIs none, /, / + {1, 0, 0}, // UseIP use, both, none + {1, 4, 0}, // UseIPv4 use, 4, none + {1, 6, 0}, // UseIPv6 use, 6, none + {1, 4, 6}, // UseIPv4v6 use, 4, 6 + {1, 6, 4}, // UseIPv6v4 use, 6, 4 + {2, 0, 0}, // ForceIP force, both, none + {2, 4, 0}, // ForceIPv4 force, 4, none + {2, 6, 0}, // ForceIPv6 force, 6, none + {2, 4, 6}, // ForceIPv4v6 force, 4, 6 + {2, 6, 4}, // ForceIPv6v4 force, 6, 4 +} + +func (c *Config) hasStrategy() bool { + return strategy[c.DomainStrategy][0] != 0 +} + +func (c *Config) forceIP() bool { + return strategy[c.DomainStrategy][0] == 2 +} + +func (c *Config) preferIP4() bool { + return strategy[c.DomainStrategy][1] == 4 || strategy[c.DomainStrategy][1] == 0 +} + +func (c *Config) preferIP6() bool { + return strategy[c.DomainStrategy][1] == 6 || strategy[c.DomainStrategy][1] == 0 +} + +func (c *Config) hasFallback() bool { + return strategy[c.DomainStrategy][2] != 0 +} + +func (c *Config) fallbackIP4() bool { + return strategy[c.DomainStrategy][2] == 4 +} + +func (c *Config) fallbackIP6() bool { + return strategy[c.DomainStrategy][2] == 6 } diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 7561f7fd..229630d4 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/freedom/config.proto @@ -24,25 +24,46 @@ const ( type Config_DomainStrategy int32 const ( - Config_AS_IS Config_DomainStrategy = 0 - Config_USE_IP Config_DomainStrategy = 1 - Config_USE_IP4 Config_DomainStrategy = 2 - Config_USE_IP6 Config_DomainStrategy = 3 + Config_AS_IS Config_DomainStrategy = 0 + Config_USE_IP Config_DomainStrategy = 1 + Config_USE_IP4 Config_DomainStrategy = 2 + Config_USE_IP6 Config_DomainStrategy = 3 + Config_USE_IP46 Config_DomainStrategy = 4 + Config_USE_IP64 Config_DomainStrategy = 5 + Config_FORCE_IP Config_DomainStrategy = 6 + Config_FORCE_IP4 Config_DomainStrategy = 7 + Config_FORCE_IP6 Config_DomainStrategy = 8 + Config_FORCE_IP46 Config_DomainStrategy = 9 + Config_FORCE_IP64 Config_DomainStrategy = 10 ) // Enum value maps for Config_DomainStrategy. var ( Config_DomainStrategy_name = map[int32]string{ - 0: "AS_IS", - 1: "USE_IP", - 2: "USE_IP4", - 3: "USE_IP6", + 0: "AS_IS", + 1: "USE_IP", + 2: "USE_IP4", + 3: "USE_IP6", + 4: "USE_IP46", + 5: "USE_IP64", + 6: "FORCE_IP", + 7: "FORCE_IP4", + 8: "FORCE_IP6", + 9: "FORCE_IP46", + 10: "FORCE_IP64", } Config_DomainStrategy_value = map[string]int32{ - "AS_IS": 0, - "USE_IP": 1, - "USE_IP4": 2, - "USE_IP6": 3, + "AS_IS": 0, + "USE_IP": 1, + "USE_IP4": 2, + "USE_IP6": 3, + "USE_IP46": 4, + "USE_IP64": 5, + "FORCE_IP": 6, + "FORCE_IP4": 7, + "FORCE_IP6": 8, + "FORCE_IP46": 9, + "FORCE_IP64": 10, } ) @@ -314,7 +335,7 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x6c, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0xf2, 0x02, 0x0a, 0x06, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0xdb, 0x03, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, @@ -333,18 +354,24 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x76, 0x65, 0x6c, 0x12, 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x41, 0x0a, - 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, - 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, - 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, - 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, - 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, - 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x66, 0x72, - 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, - 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x65, 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0xa9, 0x01, + 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, + 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, + 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, + 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, + 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, + 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, + 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, + 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, + 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, + 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, + 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, + 0x64, 0x6f, 0x6d, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, + 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, + 0x64, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/freedom/config.proto b/proxy/freedom/config.proto index 53524e19..0f328022 100644 --- a/proxy/freedom/config.proto +++ b/proxy/freedom/config.proto @@ -27,6 +27,13 @@ message Config { USE_IP = 1; USE_IP4 = 2; USE_IP6 = 3; + USE_IP46 = 4; + USE_IP64 = 5; + FORCE_IP = 6; + FORCE_IP4 = 7; + FORCE_IP6 = 8; + FORCE_IP46 = 9; + FORCE_IP64 = 10; } DomainStrategy domain_strategy = 1; uint32 timeout = 2 [deprecated = true]; diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 3eb5b8a3..809d4df8 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -73,26 +73,18 @@ func (h *Handler) policy() policy.Session { } func (h *Handler) resolveIP(ctx context.Context, domain string, localAddr net.Address) net.Address { - var option dns.IPOption = dns.IPOption{ - IPv4Enable: true, - IPv6Enable: true, - FakeEnable: false, - } - if h.config.DomainStrategy == Config_USE_IP4 || (localAddr != nil && localAddr.Family().IsIPv4()) { - option = dns.IPOption{ - IPv4Enable: true, - IPv6Enable: false, - FakeEnable: false, - } - } else if h.config.DomainStrategy == Config_USE_IP6 || (localAddr != nil && localAddr.Family().IsIPv6()) { - option = dns.IPOption{ - IPv4Enable: false, - IPv6Enable: true, - FakeEnable: false, + ips, err := h.dns.LookupIP(domain, dns.IPOption{ + IPv4Enable: (localAddr == nil || localAddr.Family().IsIPv4()) && h.config.preferIP4(), + IPv6Enable: (localAddr == nil || localAddr.Family().IsIPv6()) && h.config.preferIP6(), + }) + { // Resolve fallback + if (len(ips) == 0 || err != nil) && h.config.hasFallback() && localAddr == nil { + ips, err = h.dns.LookupIP(domain, dns.IPOption{ + IPv4Enable: h.config.fallbackIP4(), + IPv6Enable: h.config.fallbackIP6(), + }) } } - - ips, err := h.dns.LookupIP(domain, option) if err != nil { newError("failed to get IP address for domain ", domain).Base(err).WriteToLog(session.ExportIDToError(ctx)) } @@ -142,7 +134,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte var conn stat.Connection err := retry.ExponentialBackoff(5, 100).On(func() error { dialDest := destination - if h.config.useIP() && dialDest.Address.Family().IsDomain() { + if h.config.hasStrategy() && dialDest.Address.Family().IsDomain() { ip := h.resolveIP(ctx, dialDest.Address.Domain(), dialer.Address()) if ip != nil { dialDest = net.Destination{ @@ -151,6 +143,8 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte Port: dialDest.Port, } newError("dialing to ", dialDest).WriteToLog(session.ExportIDToError(ctx)) + } else if h.config.forceIP() { + return dns.ErrEmptyResponse } } @@ -325,7 +319,7 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { if w.UDPOverride.Port != 0 { b.UDP.Port = w.UDPOverride.Port } - if w.Handler.config.useIP() && b.UDP.Address.Family().IsDomain() { + if w.Handler.config.hasStrategy() && b.UDP.Address.Family().IsDomain() { ip := w.Handler.resolveIP(w.Context, b.UDP.Address.Domain(), nil) if ip != nil { b.UDP.Address = ip diff --git a/proxy/http/config.pb.go b/proxy/http/config.pb.go index 986a038a..6ae78777 100644 --- a/proxy/http/config.pb.go +++ b/proxy/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/http/config.proto diff --git a/proxy/loopback/config.pb.go b/proxy/loopback/config.pb.go index e25f8425..3902e532 100644 --- a/proxy/loopback/config.pb.go +++ b/proxy/loopback/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/loopback/config.proto diff --git a/proxy/shadowsocks/config.pb.go b/proxy/shadowsocks/config.pb.go index 5fc221da..86351df8 100644 --- a/proxy/shadowsocks/config.pb.go +++ b/proxy/shadowsocks/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/shadowsocks/config.proto diff --git a/proxy/shadowsocks_2022/config.pb.go b/proxy/shadowsocks_2022/config.pb.go index 8ccb848a..633f3cda 100644 --- a/proxy/shadowsocks_2022/config.pb.go +++ b/proxy/shadowsocks_2022/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/shadowsocks_2022/config.proto diff --git a/proxy/socks/config.pb.go b/proxy/socks/config.pb.go index a1daa276..c22af748 100644 --- a/proxy/socks/config.pb.go +++ b/proxy/socks/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/socks/config.proto diff --git a/proxy/trojan/config.pb.go b/proxy/trojan/config.pb.go index 49374001..d90271d9 100644 --- a/proxy/trojan/config.pb.go +++ b/proxy/trojan/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/trojan/config.proto diff --git a/proxy/vless/account.pb.go b/proxy/vless/account.pb.go index 1d055185..405d8811 100644 --- a/proxy/vless/account.pb.go +++ b/proxy/vless/account.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/vless/account.proto diff --git a/proxy/vless/encoding/addons.pb.go b/proxy/vless/encoding/addons.pb.go index b78c878c..8c409cbc 100644 --- a/proxy/vless/encoding/addons.pb.go +++ b/proxy/vless/encoding/addons.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/vless/encoding/addons.proto diff --git a/proxy/vless/inbound/config.pb.go b/proxy/vless/inbound/config.pb.go index f15f9114..c2ddd5e5 100644 --- a/proxy/vless/inbound/config.pb.go +++ b/proxy/vless/inbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/vless/inbound/config.proto diff --git a/proxy/vless/outbound/config.pb.go b/proxy/vless/outbound/config.pb.go index 5bd8912a..3fb9ed75 100644 --- a/proxy/vless/outbound/config.pb.go +++ b/proxy/vless/outbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/vless/outbound/config.proto diff --git a/proxy/vmess/account.pb.go b/proxy/vmess/account.pb.go index 9938cfb1..575ec583 100644 --- a/proxy/vmess/account.pb.go +++ b/proxy/vmess/account.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/vmess/account.proto diff --git a/proxy/vmess/inbound/config.pb.go b/proxy/vmess/inbound/config.pb.go index 663256aa..67fa6461 100644 --- a/proxy/vmess/inbound/config.pb.go +++ b/proxy/vmess/inbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/vmess/inbound/config.proto diff --git a/proxy/vmess/outbound/config.pb.go b/proxy/vmess/outbound/config.pb.go index b68cbffa..80492e05 100644 --- a/proxy/vmess/outbound/config.pb.go +++ b/proxy/vmess/outbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/vmess/outbound/config.proto diff --git a/proxy/wireguard/config.pb.go b/proxy/wireguard/config.pb.go index 6af1f41c..dfe7dab5 100644 --- a/proxy/wireguard/config.pb.go +++ b/proxy/wireguard/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: proxy/wireguard/config.proto diff --git a/transport/global/config.pb.go b/transport/global/config.pb.go index 1d763122..4bd8c84f 100644 --- a/transport/global/config.pb.go +++ b/transport/global/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/global/config.proto diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 33519b63..9a5f78e8 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.31.0 -// protoc v4.24.1 +// protoc v4.23.1 // source: transport/internet/config.proto package internet diff --git a/transport/internet/domainsocket/config.pb.go b/transport/internet/domainsocket/config.pb.go index 6089cf34..9d3eb25c 100644 --- a/transport/internet/domainsocket/config.pb.go +++ b/transport/internet/domainsocket/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/domainsocket/config.proto diff --git a/transport/internet/grpc/config.pb.go b/transport/internet/grpc/config.pb.go index 91289606..4a794bb1 100644 --- a/transport/internet/grpc/config.pb.go +++ b/transport/internet/grpc/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/grpc/config.proto diff --git a/transport/internet/grpc/encoding/stream.pb.go b/transport/internet/grpc/encoding/stream.pb.go index 96cf41bd..f8e7c7fb 100644 --- a/transport/internet/grpc/encoding/stream.pb.go +++ b/transport/internet/grpc/encoding/stream.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/grpc/encoding/stream.proto diff --git a/transport/internet/headers/dns/config.pb.go b/transport/internet/headers/dns/config.pb.go index aeadae6a..34d37c33 100644 --- a/transport/internet/headers/dns/config.pb.go +++ b/transport/internet/headers/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/headers/dns/config.proto diff --git a/transport/internet/headers/http/config.pb.go b/transport/internet/headers/http/config.pb.go index 786bd928..69fefd8c 100644 --- a/transport/internet/headers/http/config.pb.go +++ b/transport/internet/headers/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/headers/http/config.proto diff --git a/transport/internet/headers/noop/config.pb.go b/transport/internet/headers/noop/config.pb.go index cd8880a8..9777e46f 100644 --- a/transport/internet/headers/noop/config.pb.go +++ b/transport/internet/headers/noop/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/headers/noop/config.proto diff --git a/transport/internet/headers/srtp/config.pb.go b/transport/internet/headers/srtp/config.pb.go index 553349e8..2d9c5354 100644 --- a/transport/internet/headers/srtp/config.pb.go +++ b/transport/internet/headers/srtp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/headers/srtp/config.proto diff --git a/transport/internet/headers/tls/config.pb.go b/transport/internet/headers/tls/config.pb.go index 8d940553..c0b77de4 100644 --- a/transport/internet/headers/tls/config.pb.go +++ b/transport/internet/headers/tls/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/headers/tls/config.proto diff --git a/transport/internet/headers/utp/config.pb.go b/transport/internet/headers/utp/config.pb.go index 9dff1aed..b3bd9749 100644 --- a/transport/internet/headers/utp/config.pb.go +++ b/transport/internet/headers/utp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/headers/utp/config.proto diff --git a/transport/internet/headers/wechat/config.pb.go b/transport/internet/headers/wechat/config.pb.go index 02c4f50d..8bec6fe4 100644 --- a/transport/internet/headers/wechat/config.pb.go +++ b/transport/internet/headers/wechat/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/headers/wechat/config.proto diff --git a/transport/internet/headers/wireguard/config.pb.go b/transport/internet/headers/wireguard/config.pb.go index 68c72d96..4274198c 100644 --- a/transport/internet/headers/wireguard/config.pb.go +++ b/transport/internet/headers/wireguard/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/headers/wireguard/config.proto diff --git a/transport/internet/http/config.pb.go b/transport/internet/http/config.pb.go index 6abb97dd..baaa5630 100644 --- a/transport/internet/http/config.pb.go +++ b/transport/internet/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/http/config.proto diff --git a/transport/internet/kcp/config.pb.go b/transport/internet/kcp/config.pb.go index 8b6dbd40..74537db7 100644 --- a/transport/internet/kcp/config.pb.go +++ b/transport/internet/kcp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/kcp/config.proto diff --git a/transport/internet/quic/config.pb.go b/transport/internet/quic/config.pb.go index 0b850900..f10998eb 100644 --- a/transport/internet/quic/config.pb.go +++ b/transport/internet/quic/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/quic/config.proto diff --git a/transport/internet/reality/config.pb.go b/transport/internet/reality/config.pb.go index 799e30d4..2b44d9b7 100644 --- a/transport/internet/reality/config.pb.go +++ b/transport/internet/reality/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/reality/config.proto diff --git a/transport/internet/tcp/config.pb.go b/transport/internet/tcp/config.pb.go index 1ff79f64..e7ecd49b 100644 --- a/transport/internet/tcp/config.pb.go +++ b/transport/internet/tcp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/tcp/config.proto diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index 65c18e6b..9bd5a84d 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/tls/config.proto diff --git a/transport/internet/udp/config.pb.go b/transport/internet/udp/config.pb.go index b3921e46..b56c5fa4 100644 --- a/transport/internet/udp/config.pb.go +++ b/transport/internet/udp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/udp/config.proto diff --git a/transport/internet/websocket/config.pb.go b/transport/internet/websocket/config.pb.go index 7880a1a5..ab0aa373 100644 --- a/transport/internet/websocket/config.pb.go +++ b/transport/internet/websocket/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.30.0 +// protoc-gen-go v1.31.0 // protoc v4.23.1 // source: transport/internet/websocket/config.proto From 7523f7f440a3177977d65a79fba18bf6979182e3 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 12 Nov 2023 16:37:02 -0500 Subject: [PATCH 195/867] =?UTF-8?q?=E7=BB=9F=E4=B8=80=20`domainStrategy`?= =?UTF-8?q?=20=E8=A1=8C=E4=B8=BA.=20(#2720)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 统一 `domainStrategy` 行为. * Update proto --------- Co-authored-by: rui0572 <125641819+rui0572@users.noreply.github.com> --- infra/conf/transport_internet.go | 24 ++++++++-- transport/internet/config.go | 43 ++++++++++++++++++ transport/internet/config.pb.go | 75 ++++++++++++++++++++++---------- transport/internet/config.proto | 7 +++ transport/internet/dialer.go | 36 ++++++--------- 5 files changed, 135 insertions(+), 50 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 9e10feed..e1471bde 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -654,12 +654,30 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { dStrategy := internet.DomainStrategy_AS_IS switch strings.ToLower(c.DomainStrategy) { - case "useip", "use_ip": + case "asis", "": + dStrategy = internet.DomainStrategy_AS_IS + case "useip": dStrategy = internet.DomainStrategy_USE_IP - case "useip4", "useipv4", "use_ipv4", "use_ip_v4", "use_ip4": + case "useipv4": dStrategy = internet.DomainStrategy_USE_IP4 - case "useip6", "useipv6", "use_ipv6", "use_ip_v6", "use_ip6": + case "useipv6": dStrategy = internet.DomainStrategy_USE_IP6 + case "useipv4v6": + dStrategy = internet.DomainStrategy_USE_IP46 + case "useipv6v4": + dStrategy = internet.DomainStrategy_USE_IP64 + case "forceip": + dStrategy = internet.DomainStrategy_FORCE_IP + case "forceipv4": + dStrategy = internet.DomainStrategy_FORCE_IP4 + case "forceipv6": + dStrategy = internet.DomainStrategy_FORCE_IP6 + case "forceipv4v6": + dStrategy = internet.DomainStrategy_FORCE_IP46 + case "forceipv6v4": + dStrategy = internet.DomainStrategy_FORCE_IP64 + default: + return nil, newError("unsupported domain strategy: ", c.DomainStrategy) } return &internet.SocketConfig{ diff --git a/transport/internet/config.go b/transport/internet/config.go index a7ff96c6..6725a995 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -12,6 +12,21 @@ var ( globalTransportSettings []*TransportConfig ) +var strategy = [][]byte{ + // name strategy, prefer, fallback + {0, 0, 0}, // AsIs none, /, / + {1, 0, 0}, // UseIP use, both, none + {1, 4, 0}, // UseIPv4 use, 4, none + {1, 6, 0}, // UseIPv6 use, 6, none + {1, 4, 6}, // UseIPv4v6 use, 4, 6 + {1, 6, 4}, // UseIPv6v4 use, 6, 4 + {2, 0, 0}, // ForceIP force, both, none + {2, 4, 0}, // ForceIPv4 force, 4, none + {2, 6, 0}, // ForceIPv6 force, 6, none + {2, 4, 6}, // ForceIPv4v6 force, 4, 6 + {2, 6, 4}, // ForceIPv6v4 force, 6, 4 +} + const unknownProtocol = "unknown" func transportProtocolToString(protocol TransportProtocol) string { @@ -122,3 +137,31 @@ func (c *ProxyConfig) HasTag() bool { func (m SocketConfig_TProxyMode) IsEnabled() bool { return m != SocketConfig_Off } + +func (s DomainStrategy) hasStrategy() bool { + return strategy[s][0] != 0 +} + +func (s DomainStrategy) forceIP() bool { + return strategy[s][0] == 2 +} + +func (s DomainStrategy) preferIP4() bool { + return strategy[s][1] == 4 || strategy[s][1] == 0 +} + +func (s DomainStrategy) preferIP6() bool { + return strategy[s][1] == 6 || strategy[s][1] == 0 +} + +func (s DomainStrategy) hasFallback() bool { + return strategy[s][2] != 0 +} + +func (s DomainStrategy) fallbackIP4() bool { + return strategy[s][2] == 4 +} + +func (s DomainStrategy) fallbackIP6() bool { + return strategy[s][2] == 6 +} diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 9a5f78e8..9636bfb4 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -82,25 +82,46 @@ func (TransportProtocol) EnumDescriptor() ([]byte, []int) { type DomainStrategy int32 const ( - DomainStrategy_AS_IS DomainStrategy = 0 - DomainStrategy_USE_IP DomainStrategy = 1 - DomainStrategy_USE_IP4 DomainStrategy = 2 - DomainStrategy_USE_IP6 DomainStrategy = 3 + DomainStrategy_AS_IS DomainStrategy = 0 + DomainStrategy_USE_IP DomainStrategy = 1 + DomainStrategy_USE_IP4 DomainStrategy = 2 + DomainStrategy_USE_IP6 DomainStrategy = 3 + DomainStrategy_USE_IP46 DomainStrategy = 4 + DomainStrategy_USE_IP64 DomainStrategy = 5 + DomainStrategy_FORCE_IP DomainStrategy = 6 + DomainStrategy_FORCE_IP4 DomainStrategy = 7 + DomainStrategy_FORCE_IP6 DomainStrategy = 8 + DomainStrategy_FORCE_IP46 DomainStrategy = 9 + DomainStrategy_FORCE_IP64 DomainStrategy = 10 ) // Enum value maps for DomainStrategy. var ( DomainStrategy_name = map[int32]string{ - 0: "AS_IS", - 1: "USE_IP", - 2: "USE_IP4", - 3: "USE_IP6", + 0: "AS_IS", + 1: "USE_IP", + 2: "USE_IP4", + 3: "USE_IP6", + 4: "USE_IP46", + 5: "USE_IP64", + 6: "FORCE_IP", + 7: "FORCE_IP4", + 8: "FORCE_IP6", + 9: "FORCE_IP46", + 10: "FORCE_IP64", } DomainStrategy_value = map[string]int32{ - "AS_IS": 0, - "USE_IP": 1, - "USE_IP4": 2, - "USE_IP6": 3, + "AS_IS": 0, + "USE_IP": 1, + "USE_IP4": 2, + "USE_IP6": 3, + "USE_IP46": 4, + "USE_IP64": 5, + "FORCE_IP": 6, + "FORCE_IP4": 7, + "FORCE_IP6": 8, + "FORCE_IP46": 9, + "FORCE_IP64": 10, } ) @@ -710,18 +731,24 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, - 0x10, 0x05, 0x2a, 0x41, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, - 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, - 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, - 0x49, 0x50, 0x36, 0x10, 0x03, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, - 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x10, 0x05, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, + 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, + 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, + 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, + 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, + 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, + 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, + 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, + 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, + 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, 0x67, + 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, + 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, + 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, + 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/config.proto b/transport/internet/config.proto index 550d00ec..f596d19f 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -22,6 +22,13 @@ enum DomainStrategy { USE_IP = 1; USE_IP4 = 2; USE_IP6 = 3; + USE_IP46 = 4; + USE_IP64 = 5; + FORCE_IP = 6; + FORCE_IP4 = 7; + FORCE_IP6 = 8; + FORCE_IP46 = 9; + FORCE_IP64 = 10; } message TransportConfig { diff --git a/transport/internet/dialer.go b/transport/internet/dialer.go index d178bdcd..deae4df0 100644 --- a/transport/internet/dialer.go +++ b/transport/internet/dialer.go @@ -78,37 +78,27 @@ func lookupIP(domain string, strategy DomainStrategy, localAddr net.Address) ([] return nil, nil } - option := dns.IPOption{ - IPv4Enable: true, - IPv6Enable: true, - FakeEnable: false, + ips, err := dnsClient.LookupIP(domain, dns.IPOption{ + IPv4Enable: (localAddr == nil || localAddr.Family().IsIPv4()) && strategy.preferIP4(), + IPv6Enable: (localAddr == nil || localAddr.Family().IsIPv6()) && strategy.preferIP6(), + }) + { // Resolve fallback + if (len(ips) == 0 || err != nil) && strategy.hasFallback() && localAddr == nil { + ips, err = dnsClient.LookupIP(domain, dns.IPOption{ + IPv4Enable: strategy.fallbackIP4(), + IPv6Enable: strategy.fallbackIP6(), + }) + } } - switch { - case strategy == DomainStrategy_USE_IP4 || (localAddr != nil && localAddr.Family().IsIPv4()): - option = dns.IPOption{ - IPv4Enable: true, - IPv6Enable: false, - FakeEnable: false, - } - case strategy == DomainStrategy_USE_IP6 || (localAddr != nil && localAddr.Family().IsIPv6()): - option = dns.IPOption{ - IPv4Enable: false, - IPv6Enable: true, - FakeEnable: false, - } - case strategy == DomainStrategy_AS_IS: - return nil, nil - } - - return dnsClient.LookupIP(domain, option) + return ips, err } func canLookupIP(ctx context.Context, dst net.Destination, sockopt *SocketConfig) bool { if dst.Address.Family().IsIP() || dnsClient == nil { return false } - return sockopt.DomainStrategy != DomainStrategy_AS_IS + return sockopt.DomainStrategy.hasStrategy() } func redirect(ctx context.Context, dst net.Destination, obt string) net.Conn { From 7205298474ef57821d87e5230430c6ccc1e19c4b Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 12 Nov 2023 16:07:26 -0500 Subject: [PATCH 196/867] Update dependencies --- go.mod | 30 +++++++++++++-------------- go.sum | 64 +++++++++++++++++++++++++++++----------------------------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/go.mod b/go.mod index f3abbad1..f0e15d8f 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/xtls/xray-core -go 1.21 +go 1.21.4 require ( github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 @@ -18,7 +18,7 @@ require ( github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 - github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 + github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20230824141953-6213f710f925 golang.org/x/crypto v0.15.0 golang.org/x/net v0.18.0 @@ -32,8 +32,8 @@ require ( ) require ( - github.com/andybalholm/brotli v1.0.5 // indirect - github.com/cloudflare/circl v1.3.3 // indirect + github.com/andybalholm/brotli v1.0.6 // indirect + github.com/cloudflare/circl v1.3.6 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect github.com/francoispqt/gojay v1.2.13 // indirect @@ -41,23 +41,23 @@ require ( github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect - github.com/klauspost/compress v1.17.0 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect - github.com/onsi/ginkgo/v2 v2.12.1 // indirect + github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a // indirect + github.com/klauspost/compress v1.17.2 // indirect + github.com/klauspost/cpuid/v2 v2.2.6 // indirect + github.com/onsi/ginkgo/v2 v2.13.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/quic-go/qtls-go1-20 v0.4.1 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect - github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect + github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.3.0 // indirect - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/mod v0.12.0 // indirect + golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect + golang.org/x/mod v0.14.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.13.0 // indirect + golang.org/x/time v0.4.0 // indirect + golang.org/x/tools v0.15.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259 // indirect + gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b // indirect ) diff --git a/go.sum b/go.sum index 3195b2b6..36a5e317 100644 --- a/go.sum +++ b/go.sum @@ -8,15 +8,15 @@ dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1 dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI= +github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cloudflare/circl v1.3.6 h1:/xbKIqSHbZXHwkhbrhrt2YOHIwYJlXH94E3tI/gDlUg= +github.com/cloudflare/circl v1.3.6/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -36,8 +36,8 @@ github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3 github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -63,8 +63,8 @@ github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+u github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 h1:pUa4ghanp6q4IJHwE9RwLgmVFfReJN+KbQ8ExNEUUoQ= -github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a h1:fEBsGL/sjAuJrgah5XqmmYsTLzJp/TO9Lhy39gkverk= +github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -78,10 +78,10 @@ github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= -github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= +github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= +github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -98,10 +98,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.12.1 h1:uHNEO1RP2SpuZApSkel9nEh1/Mu+hmQe7Q+Pepg5OYA= -github.com/onsi/ginkgo/v2 v2.12.1/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU= +github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM= +github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= +github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= @@ -169,10 +169,10 @@ github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMI github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 h1:tkMT5pTye+1NlKIXETU78NXw0fyjnaNHmJyyLyzw8+U= github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3/go.mod h1:cAAsePK2e15YDAMJNyOpGYEWNe4sIghTY7gpz4cX/Ik= github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= -github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 h1:gga7acRE695APm9hlsSMoOoE65U4/TcqNj90mc69Rlg= -github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= -github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6 h1:T+YCYGfFdzyaKTDCdZn/hEiKvsw6yUfd+e4hze0rCUw= -github.com/xtls/reality v0.0.0-20230828171259-e426190d57f6/go.mod h1:rkuAY1S9F8eI8gDiPDYvACE8e2uwkyg8qoOTuwWov7Y= +github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= +github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= +github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 h1:capMfFYRgH9BCLd6A3Er/cH3A9Nz3CU2KwxwOQZIePI= +github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= @@ -188,14 +188,14 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= +golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= -golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= +golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -244,8 +244,8 @@ golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.4.0 h1:Z81tqI5ddIoXDPvVQ7/7CC9TnLM7ubaFG2qXYd5BbYY= +golang.org/x/time v0.4.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -253,8 +253,8 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= -golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= +golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -275,8 +275,8 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= @@ -300,8 +300,8 @@ gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= -gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259 h1:TbRPT0HtzFP3Cno1zZo7yPzEEnfu8EjLfl6IU9VfqkQ= -gvisor.dev/gvisor v0.0.0-20230927004350-cbd86285d259/go.mod h1:AVgIgHMwK63XvmAzWG9vLQ41YnVHN0du0tEC46fI7yY= +gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h1:yqkg3pTifuKukuWanp8spDsL4irJkHF5WI0J47hU87o= +gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b/go.mod h1:10sU+Uh5KKNv1+2x2A0Gvzt8FjD3ASIhorV3YsauXhk= h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo= h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From ac52a226d16b77c400535feb5eddc395aa1113bd Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 12 Nov 2023 16:57:15 -0500 Subject: [PATCH 197/867] v1.8.5 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index e1128775..dfcaac6d 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 4 + Version_z byte = 5 ) var ( From f1c81557dcf8251e98f5a474931473dfa630fc1a Mon Sep 17 00:00:00 2001 From: cty123 Date: Tue, 14 Nov 2023 00:00:04 +0100 Subject: [PATCH 198/867] #2605: Add safety check for type casting for QUIC dialer Issue #2605 brought up real problem that QUIC dialer doesn't support sockopt at the moment. Inside `internet.DialSystem(...)` function, one of the branch that involves `redirect(...)` returns `cnc.connection` instance that is currently unhandled by the code logic, and thus caused program panic during runtime. It seems the sockopt support for QUIC protocol requires a couple changes including making `cnc.connection` public, such that we can handle in dialer, along with some thorough tests, this commit simply adds safety check to explicity state the fact that QUIC isn't working with sockopt. And the implementation of the feature can be scheduled later on. --- transport/internet/quic/dialer.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/transport/internet/quic/dialer.go b/transport/internet/quic/dialer.go index 1358dac7..c6bc08aa 100644 --- a/transport/internet/quic/dialer.go +++ b/transport/internet/quic/dialer.go @@ -146,10 +146,19 @@ func (s *clientConnections) openConnection(ctx context.Context, destAddr net.Add return qlog.NewConnectionTracer(&QlogWriter{connID: ci}, p, ci) }, } - udpConn, _ := rawConn.(*net.UDPConn) - if udpConn == nil { - udpConn = rawConn.(*internet.PacketConnWrapper).Conn.(*net.UDPConn) + + var udpConn *net.UDPConn + switch conn := rawConn.(type) { + case *net.UDPConn: + udpConn = conn + case *internet.PacketConnWrapper: + udpConn = conn.Conn.(*net.UDPConn) + default: + // TODO: Support sockopt for QUIC + rawConn.Close() + return nil, newError("QUIC with sockopt is unsupported").AtWarning() } + sysConn, err := wrapSysConn(udpConn, config) if err != nil { rawConn.Close() From 0ac7da2fc8e26017c694c16bd2c2c2f1734c301c Mon Sep 17 00:00:00 2001 From: hax0r31337 <65506006+hax0r31337@users.noreply.github.com> Date: Sat, 18 Nov 2023 11:27:17 +0800 Subject: [PATCH 199/867] WireGuard Inbound (User-space WireGuard server) (#2477) * feat: wireguard inbound * feat(command): generate wireguard compatible keypair * feat(wireguard): connection idle timeout * fix(wireguard): close endpoint after connection closed * fix(wireguard): resolve conflicts * feat(wireguard): set cubic as default cc algorithm in gVisor TUN * chore(wireguard): resolve conflict * chore(wireguard): remove redurant code * chore(wireguard): remove redurant code * feat: rework server for gvisor tun * feat: keep user-space tun as an option * fix: exclude android from native tun build * feat: auto kernel tun * fix: build * fix: regulate function name & fix test --- go.mod | 4 +- go.sum | 3 +- infra/conf/wireguard.go | 71 ++++--- infra/conf/wireguard_test.go | 15 +- infra/conf/xray.go | 3 +- main/commands/all/x25519.go | 15 +- proxy/wireguard/bind.go | 170 ++++++--------- proxy/wireguard/client.go | 255 +++++++++++++++++++++++ proxy/wireguard/config.go | 7 + proxy/wireguard/config.pb.go | 58 ++++-- proxy/wireguard/config.proto | 40 ++-- proxy/wireguard/gvisortun/tun.go | 230 +++++++++++++++++++++ proxy/wireguard/server.go | 181 ++++++++++++++++ proxy/wireguard/tun.go | 100 +++++++++ proxy/wireguard/tun_default.go | 38 +--- proxy/wireguard/tun_linux.go | 16 +- proxy/wireguard/wireguard.go | 343 ++++++------------------------- 17 files changed, 1049 insertions(+), 500 deletions(-) create mode 100644 proxy/wireguard/client.go create mode 100644 proxy/wireguard/gvisortun/tun.go create mode 100644 proxy/wireguard/server.go diff --git a/go.mod b/go.mod index f0e15d8f..d7f43f89 100644 --- a/go.mod +++ b/go.mod @@ -27,6 +27,7 @@ require ( golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 + gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 lukechampine.com/blake3 v1.2.1 ) @@ -48,7 +49,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/quic-go/qtls-go1-20 v0.4.1 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect - github.com/vishvananda/netns v0.0.4 // indirect + github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae // indirect go.uber.org/mock v0.3.0 // indirect golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect golang.org/x/mod v0.14.0 // indirect @@ -59,5 +60,4 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b // indirect ) diff --git a/go.sum b/go.sum index 36a5e317..22473052 100644 --- a/go.sum +++ b/go.sum @@ -168,9 +168,8 @@ github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49u github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 h1:tkMT5pTye+1NlKIXETU78NXw0fyjnaNHmJyyLyzw8+U= github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3/go.mod h1:cAAsePK2e15YDAMJNyOpGYEWNe4sIghTY7gpz4cX/Ik= +github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae h1:4hwBBUfQCFe3Cym0ZtKyq7L16eZUtYKs+BaHDN6mAns= github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= -github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= -github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 h1:capMfFYRgH9BCLd6A3Er/cH3A9Nz3CU2KwxwOQZIePI= github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/infra/conf/wireguard.go b/infra/conf/wireguard.go index 7b2b6bbf..a4f0eda6 100644 --- a/infra/conf/wireguard.go +++ b/infra/conf/wireguard.go @@ -13,7 +13,7 @@ type WireGuardPeerConfig struct { PublicKey string `json:"publicKey"` PreSharedKey string `json:"preSharedKey"` Endpoint string `json:"endpoint"` - KeepAlive int `json:"keepAlive"` + KeepAlive uint32 `json:"keepAlive"` AllowedIPs []string `json:"allowedIPs,omitempty"` } @@ -21,9 +21,11 @@ func (c *WireGuardPeerConfig) Build() (proto.Message, error) { var err error config := new(wireguard.PeerConfig) - config.PublicKey, err = parseWireGuardKey(c.PublicKey) - if err != nil { - return nil, err + if c.PublicKey != "" { + config.PublicKey, err = parseWireGuardKey(c.PublicKey) + if err != nil { + return nil, err + } } if c.PreSharedKey != "" { @@ -31,13 +33,11 @@ func (c *WireGuardPeerConfig) Build() (proto.Message, error) { if err != nil { return nil, err } - } else { - config.PreSharedKey = "0000000000000000000000000000000000000000000000000000000000000000" } config.Endpoint = c.Endpoint // default 0 - config.KeepAlive = int32(c.KeepAlive) + config.KeepAlive = c.KeepAlive if c.AllowedIPs == nil { config.AllowedIps = []string{"0.0.0.0/0", "::0/0"} } else { @@ -48,11 +48,14 @@ func (c *WireGuardPeerConfig) Build() (proto.Message, error) { } type WireGuardConfig struct { + IsClient bool `json:""` + + KernelMode *bool `json:"kernelMode"` SecretKey string `json:"secretKey"` Address []string `json:"address"` Peers []*WireGuardPeerConfig `json:"peers"` - MTU int `json:"mtu"` - NumWorkers int `json:"workers"` + MTU int32 `json:"mtu"` + NumWorkers int32 `json:"workers"` Reserved []byte `json:"reserved"` DomainStrategy string `json:"domainStrategy"` } @@ -87,11 +90,11 @@ func (c *WireGuardConfig) Build() (proto.Message, error) { if c.MTU == 0 { config.Mtu = 1420 } else { - config.Mtu = int32(c.MTU) + config.Mtu = c.MTU } - // these a fallback code exists in github.com/nanoda0523/wireguard-go code, + // these a fallback code exists in wireguard-go code, // we don't need to process fallback manually - config.NumWorkers = int32(c.NumWorkers) + config.NumWorkers = c.NumWorkers if len(c.Reserved) != 0 && len(c.Reserved) != 3 { return nil, newError(`"reserved" should be empty or 3 bytes`) @@ -113,22 +116,42 @@ func (c *WireGuardConfig) Build() (proto.Message, error) { return nil, newError("unsupported domain strategy: ", c.DomainStrategy) } + config.IsClient = c.IsClient + if c.KernelMode != nil { + config.KernelMode = *c.KernelMode + if config.KernelMode && !wireguard.KernelTunSupported() { + newError("kernel mode is not supported on your OS or permission is insufficient").AtWarning().WriteToLog() + } + } else { + config.KernelMode = wireguard.KernelTunSupported() + if config.KernelMode { + newError("kernel mode is enabled as it's supported and permission is sufficient").AtDebug().WriteToLog() + } + } + return config, nil } func parseWireGuardKey(str string) (string, error) { - if len(str) != 64 { - // may in base64 form - dat, err := base64.StdEncoding.DecodeString(str) - if err != nil { - return "", err + var err error + + if len(str)%2 == 0 { + _, err = hex.DecodeString(str) + if err == nil { + return str, nil } - if len(dat) != 32 { - return "", newError("key should be 32 bytes: " + str) - } - return hex.EncodeToString(dat), err - } else { - // already hex form - return str, nil } + + var dat []byte + str = strings.TrimSuffix(str, "=") + if strings.ContainsRune(str, '+') || strings.ContainsRune(str, '/') { + dat, err = base64.RawStdEncoding.DecodeString(str) + } else { + dat, err = base64.RawURLEncoding.DecodeString(str) + } + if err == nil { + return hex.EncodeToString(dat), nil + } + + return "", newError("failed to deserialize key").Base(err) } diff --git a/infra/conf/wireguard_test.go b/infra/conf/wireguard_test.go index 7a4adf36..57951105 100644 --- a/infra/conf/wireguard_test.go +++ b/infra/conf/wireguard_test.go @@ -7,7 +7,7 @@ import ( "github.com/xtls/xray-core/proxy/wireguard" ) -func TestWireGuardOutbound(t *testing.T) { +func TestWireGuardConfig(t *testing.T) { creator := func() Buildable { return new(WireGuardConfig) } @@ -25,7 +25,8 @@ func TestWireGuardOutbound(t *testing.T) { ], "mtu": 1300, "workers": 2, - "domainStrategy": "ForceIPv6v4" + "domainStrategy": "ForceIPv6v4", + "kernelMode": false }`, Parser: loadJSON(creator), Output: &wireguard.DeviceConfig{ @@ -35,16 +36,16 @@ func TestWireGuardOutbound(t *testing.T) { Peers: []*wireguard.PeerConfig{ { // also can read from hex form directly - PublicKey: "6e65ce0be17517110c17d77288ad87e7fd5252dcc7d09b95a39d61db03df832a", - PreSharedKey: "0000000000000000000000000000000000000000000000000000000000000000", - Endpoint: "127.0.0.1:1234", - KeepAlive: 0, - AllowedIps: []string{"0.0.0.0/0", "::0/0"}, + PublicKey: "6e65ce0be17517110c17d77288ad87e7fd5252dcc7d09b95a39d61db03df832a", + Endpoint: "127.0.0.1:1234", + KeepAlive: 0, + AllowedIps: []string{"0.0.0.0/0", "::0/0"}, }, }, Mtu: 1300, NumWorkers: 2, DomainStrategy: wireguard.DeviceConfig_FORCE_IP64, + KernelMode: false, }, }, }) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index dfc34a8c..0935b1b0 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -24,6 +24,7 @@ var ( "vless": func() interface{} { return new(VLessInboundConfig) }, "vmess": func() interface{} { return new(VMessInboundConfig) }, "trojan": func() interface{} { return new(TrojanServerConfig) }, + "wireguard": func() interface{} { return &WireGuardConfig{IsClient: false} }, }, "protocol", "settings") outboundConfigLoader = NewJSONConfigLoader(ConfigCreatorCache{ @@ -37,7 +38,7 @@ var ( "vmess": func() interface{} { return new(VMessOutboundConfig) }, "trojan": func() interface{} { return new(TrojanClientConfig) }, "dns": func() interface{} { return new(DNSOutboundConfig) }, - "wireguard": func() interface{} { return new(WireGuardConfig) }, + "wireguard": func() interface{} { return &WireGuardConfig{IsClient: true} }, }, "protocol", "settings") ctllog = log.New(os.Stderr, "xctl> ", 0) diff --git a/main/commands/all/x25519.go b/main/commands/all/x25519.go index e7909d9b..814cca72 100644 --- a/main/commands/all/x25519.go +++ b/main/commands/all/x25519.go @@ -10,7 +10,7 @@ import ( ) var cmdX25519 = &base.Command{ - UsageLine: `{{.Exec}} x25519 [-i "private key (base64.RawURLEncoding)"]`, + UsageLine: `{{.Exec}} x25519 [-i "private key (base64.RawURLEncoding)"] [--std-encoding]`, Short: `Generate key pair for x25519 key exchange`, Long: ` Generate key pair for x25519 key exchange. @@ -18,6 +18,7 @@ Generate key pair for x25519 key exchange. Random: {{.Exec}} x25519 From private key: {{.Exec}} x25519 -i "private key (base64.RawURLEncoding)" +For Std Encoding: {{.Exec}} x25519 --std-encoding `, } @@ -26,12 +27,14 @@ func init() { } var input_base64 = cmdX25519.Flag.String("i", "", "") +var input_stdEncoding = cmdX25519.Flag.Bool("std-encoding", false, "") func executeX25519(cmd *base.Command, args []string) { var output string var err error var privateKey []byte var publicKey []byte + var encoding *base64.Encoding if len(*input_base64) > 0 { privateKey, err = base64.RawURLEncoding.DecodeString(*input_base64) if err != nil { @@ -63,9 +66,15 @@ func executeX25519(cmd *base.Command, args []string) { goto out } + if *input_stdEncoding { + encoding = base64.StdEncoding + } else { + encoding = base64.RawURLEncoding + } + output = fmt.Sprintf("Private key: %v\nPublic key: %v", - base64.RawURLEncoding.EncodeToString(privateKey), - base64.RawURLEncoding.EncodeToString(publicKey)) + encoding.EncodeToString(privateKey), + encoding.EncodeToString(publicKey)) out: fmt.Println(output) } diff --git a/proxy/wireguard/bind.go b/proxy/wireguard/bind.go index c224dc56..1fbcbc98 100644 --- a/proxy/wireguard/bind.go +++ b/proxy/wireguard/bind.go @@ -27,48 +27,45 @@ type netReadInfo struct { err error } -type netBindClient struct { - workers int - dialer internet.Dialer +// reduce duplicated code +type netBind struct { dns dns.Client dnsOption dns.IPOption - reserved []byte + workers int readQueue chan *netReadInfo } -func (bind *netBindClient) ParseEndpoint(s string) (conn.Endpoint, error) { - ipStr, port, _, err := splitAddrPort(s) +// SetMark implements conn.Bind +func (bind *netBind) SetMark(mark uint32) error { + return nil +} + +// ParseEndpoint implements conn.Bind +func (n *netBind) ParseEndpoint(s string) (conn.Endpoint, error) { + ipStr, port, err := net.SplitHostPort(s) + if err != nil { + return nil, err + } + portNum, err := strconv.Atoi(port) if err != nil { return nil, err } - var addr net.IP - if IsDomainName(ipStr) { - ips, err := bind.dns.LookupIP(ipStr, bind.dnsOption) + addr := xnet.ParseAddress(ipStr) + if addr.Family() == xnet.AddressFamilyDomain { + ips, err := n.dns.LookupIP(addr.Domain(), n.dnsOption) if err != nil { return nil, err } else if len(ips) == 0 { return nil, dns.ErrEmptyResponse } - addr = ips[0] - } else { - addr = net.ParseIP(ipStr) - } - if addr == nil { - return nil, errors.New("failed to parse ip: " + ipStr) - } - - var ip xnet.Address - if p4 := addr.To4(); len(p4) == net.IPv4len { - ip = xnet.IPAddress(p4[:]) - } else { - ip = xnet.IPAddress(addr[:]) + addr = xnet.IPAddress(ips[0]) } dst := xnet.Destination{ - Address: ip, - Port: xnet.Port(port), + Address: addr, + Port: xnet.Port(portNum), Network: xnet.Network_UDP, } @@ -77,7 +74,13 @@ func (bind *netBindClient) ParseEndpoint(s string) (conn.Endpoint, error) { }, nil } -func (bind *netBindClient) Open(uport uint16) ([]conn.ReceiveFunc, uint16, error) { +// BatchSize implements conn.Bind +func (bind *netBind) BatchSize() int { + return 1 +} + +// Open implements conn.Bind +func (bind *netBind) Open(uport uint16) ([]conn.ReceiveFunc, uint16, error) { bind.readQueue = make(chan *netReadInfo) fun := func(bufs [][]byte, sizes []int, eps []conn.Endpoint) (n int, err error) { @@ -109,13 +112,21 @@ func (bind *netBindClient) Open(uport uint16) ([]conn.ReceiveFunc, uint16, error return arr, uint16(uport), nil } -func (bind *netBindClient) Close() error { +// Close implements conn.Bind +func (bind *netBind) Close() error { if bind.readQueue != nil { close(bind.readQueue) } return nil } +type netBindClient struct { + netBind + + dialer internet.Dialer + reserved []byte +} + func (bind *netBindClient) connectTo(endpoint *netEndpoint) error { c, err := bind.dialer.Dial(context.Background(), endpoint.dst) if err != nil { @@ -177,12 +188,29 @@ func (bind *netBindClient) Send(buff [][]byte, endpoint conn.Endpoint) error { return nil } -func (bind *netBindClient) SetMark(mark uint32) error { - return nil +type netBindServer struct { + netBind } -func (bind *netBindClient) BatchSize() int { - return 1 +func (bind *netBindServer) Send(buff [][]byte, endpoint conn.Endpoint) error { + var err error + + nend, ok := endpoint.(*netEndpoint) + if !ok { + return conn.ErrWrongEndpointType + } + + if nend.conn == nil { + return newError("connection not open yet") + } + + for _, buff := range buff { + if _, err = nend.conn.Write(buff); err != nil { + return err + } + } + + return err } type netEndpoint struct { @@ -193,7 +221,7 @@ type netEndpoint struct { func (netEndpoint) ClearSrc() {} func (e netEndpoint) DstIP() netip.Addr { - return toNetIpAddr(e.dst.Address) + return netip.Addr{} } func (e netEndpoint) SrcIP() netip.Addr { @@ -232,83 +260,3 @@ func toNetIpAddr(addr xnet.Address) netip.Addr { return netip.AddrFrom16(arr) } } - -func stringsLastIndexByte(s string, b byte) int { - for i := len(s) - 1; i >= 0; i-- { - if s[i] == b { - return i - } - } - return -1 -} - -func splitAddrPort(s string) (ip string, port uint16, v6 bool, err error) { - i := stringsLastIndexByte(s, ':') - if i == -1 { - return "", 0, false, errors.New("not an ip:port") - } - - ip = s[:i] - portStr := s[i+1:] - if len(ip) == 0 { - return "", 0, false, errors.New("no IP") - } - if len(portStr) == 0 { - return "", 0, false, errors.New("no port") - } - port64, err := strconv.ParseUint(portStr, 10, 16) - if err != nil { - return "", 0, false, errors.New("invalid port " + strconv.Quote(portStr) + " parsing " + strconv.Quote(s)) - } - port = uint16(port64) - if ip[0] == '[' { - if len(ip) < 2 || ip[len(ip)-1] != ']' { - return "", 0, false, errors.New("missing ]") - } - ip = ip[1 : len(ip)-1] - v6 = true - } - - return ip, port, v6, nil -} - -func IsDomainName(s string) bool { - l := len(s) - if l == 0 || l > 254 || l == 254 && s[l-1] != '.' { - return false - } - last := byte('.') - nonNumeric := false - partlen := 0 - for i := 0; i < len(s); i++ { - c := s[i] - switch { - default: - return false - case 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '_': - nonNumeric = true - partlen++ - case '0' <= c && c <= '9': - partlen++ - case c == '-': - if last == '.' { - return false - } - partlen++ - nonNumeric = true - case c == '.': - if last == '.' || last == '-' { - return false - } - if partlen > 63 || partlen == 0 { - return false - } - partlen = 0 - } - last = c - } - if last == '-' || partlen > 63 { - return false - } - return nonNumeric -} diff --git a/proxy/wireguard/client.go b/proxy/wireguard/client.go new file mode 100644 index 00000000..def07878 --- /dev/null +++ b/proxy/wireguard/client.go @@ -0,0 +1,255 @@ +/* + +Some of codes are copied from https://github.com/octeep/wireproxy, license below. + +Copyright (c) 2022 Wind T.F. Wong + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +*/ + +package wireguard + +import ( + "context" + "net/netip" + "sync" + + "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/log" + "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/protocol" + "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/signal" + "github.com/xtls/xray-core/common/task" + "github.com/xtls/xray-core/core" + "github.com/xtls/xray-core/features/dns" + "github.com/xtls/xray-core/features/policy" + "github.com/xtls/xray-core/transport" + "github.com/xtls/xray-core/transport/internet" +) + +// Handler is an outbound connection that silently swallow the entire payload. +type Handler struct { + conf *DeviceConfig + net Tunnel + bind *netBindClient + policyManager policy.Manager + dns dns.Client + // cached configuration + ipc string + endpoints []netip.Addr + hasIPv4, hasIPv6 bool + wgLock sync.Mutex +} + +// New creates a new wireguard handler. +func New(ctx context.Context, conf *DeviceConfig) (*Handler, error) { + v := core.MustFromContext(ctx) + + endpoints, hasIPv4, hasIPv6, err := parseEndpoints(conf) + if err != nil { + return nil, err + } + + d := v.GetFeature(dns.ClientType()).(dns.Client) + return &Handler{ + conf: conf, + policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), + dns: d, + ipc: createIPCRequest(conf), + endpoints: endpoints, + hasIPv4: hasIPv4, + hasIPv6: hasIPv6, + }, nil +} + +func (h *Handler) processWireGuard(dialer internet.Dialer) (err error) { + h.wgLock.Lock() + defer h.wgLock.Unlock() + + if h.bind != nil && h.bind.dialer == dialer && h.net != nil { + return nil + } + + log.Record(&log.GeneralMessage{ + Severity: log.Severity_Info, + Content: "switching dialer", + }) + + if h.net != nil { + _ = h.net.Close() + h.net = nil + } + if h.bind != nil { + _ = h.bind.Close() + h.bind = nil + } + + // bind := conn.NewStdNetBind() // TODO: conn.Bind wrapper for dialer + bind := &netBindClient{ + netBind: netBind{ + dns: h.dns, + dnsOption: dns.IPOption{ + IPv4Enable: h.hasIPv4, + IPv6Enable: h.hasIPv6, + }, + workers: int(h.conf.NumWorkers), + }, + dialer: dialer, + reserved: h.conf.Reserved, + } + defer func() { + if err != nil { + _ = bind.Close() + } + }() + + h.net, err = h.makeVirtualTun(bind) + if err != nil { + return newError("failed to create virtual tun interface").Base(err) + } + h.bind = bind + return nil +} + +// Process implements OutboundHandler.Dispatch(). +func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error { + outbound := session.OutboundFromContext(ctx) + if outbound == nil || !outbound.Target.IsValid() { + return newError("target not specified") + } + outbound.Name = "wireguard" + inbound := session.InboundFromContext(ctx) + if inbound != nil { + inbound.SetCanSpliceCopy(3) + } + + if err := h.processWireGuard(dialer); err != nil { + return err + } + + // Destination of the inner request. + destination := outbound.Target + command := protocol.RequestCommandTCP + if destination.Network == net.Network_UDP { + command = protocol.RequestCommandUDP + } + + // resolve dns + addr := destination.Address + if addr.Family().IsDomain() { + ips, err := h.dns.LookupIP(addr.Domain(), dns.IPOption{ + IPv4Enable: h.hasIPv4 && h.conf.preferIP4(), + IPv6Enable: h.hasIPv6 && h.conf.preferIP6(), + }) + { // Resolve fallback + if (len(ips) == 0 || err != nil) && h.conf.hasFallback() { + ips, err = h.dns.LookupIP(addr.Domain(), dns.IPOption{ + IPv4Enable: h.hasIPv4 && h.conf.fallbackIP4(), + IPv6Enable: h.hasIPv6 && h.conf.fallbackIP6(), + }) + } + } + if err != nil { + return newError("failed to lookup DNS").Base(err) + } else if len(ips) == 0 { + return dns.ErrEmptyResponse + } + addr = net.IPAddress(ips[dice.Roll(len(ips))]) + } + + var newCtx context.Context + var newCancel context.CancelFunc + if session.TimeoutOnlyFromContext(ctx) { + newCtx, newCancel = context.WithCancel(context.Background()) + } + + p := h.policyManager.ForLevel(0) + + ctx, cancel := context.WithCancel(ctx) + timer := signal.CancelAfterInactivity(ctx, func() { + cancel() + if newCancel != nil { + newCancel() + } + }, p.Timeouts.ConnectionIdle) + addrPort := netip.AddrPortFrom(toNetIpAddr(addr), destination.Port.Value()) + + var requestFunc func() error + var responseFunc func() error + + if command == protocol.RequestCommandTCP { + conn, err := h.net.DialContextTCPAddrPort(ctx, addrPort) + if err != nil { + return newError("failed to create TCP connection").Base(err) + } + defer conn.Close() + + requestFunc = func() error { + defer timer.SetTimeout(p.Timeouts.DownlinkOnly) + return buf.Copy(link.Reader, buf.NewWriter(conn), buf.UpdateActivity(timer)) + } + responseFunc = func() error { + defer timer.SetTimeout(p.Timeouts.UplinkOnly) + return buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer)) + } + } else if command == protocol.RequestCommandUDP { + conn, err := h.net.DialUDPAddrPort(netip.AddrPort{}, addrPort) + if err != nil { + return newError("failed to create UDP connection").Base(err) + } + defer conn.Close() + + requestFunc = func() error { + defer timer.SetTimeout(p.Timeouts.DownlinkOnly) + return buf.Copy(link.Reader, buf.NewWriter(conn), buf.UpdateActivity(timer)) + } + responseFunc = func() error { + defer timer.SetTimeout(p.Timeouts.UplinkOnly) + return buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer)) + } + } + + if newCtx != nil { + ctx = newCtx + } + + responseDonePost := task.OnSuccess(responseFunc, task.Close(link.Writer)) + if err := task.Run(ctx, requestFunc, responseDonePost); err != nil { + common.Interrupt(link.Reader) + common.Interrupt(link.Writer) + return newError("connection ends").Base(err) + } + + return nil +} + +// creates a tun interface on netstack given a configuration +func (h *Handler) makeVirtualTun(bind *netBindClient) (Tunnel, error) { + t, err := h.conf.createTun()(h.endpoints, int(h.conf.Mtu), nil) + if err != nil { + return nil, err + } + + bind.dnsOption.IPv4Enable = h.hasIPv4 + bind.dnsOption.IPv6Enable = h.hasIPv6 + + if err = t.BuildDevice(h.ipc, bind); err != nil { + _ = t.Close() + return nil, err + } + return t, nil +} diff --git a/proxy/wireguard/config.go b/proxy/wireguard/config.go index 75622753..2a316cdd 100644 --- a/proxy/wireguard/config.go +++ b/proxy/wireguard/config.go @@ -23,3 +23,10 @@ func (c *DeviceConfig) fallbackIP4() bool { func (c *DeviceConfig) fallbackIP6() bool { return c.DomainStrategy == DeviceConfig_FORCE_IP46 } + +func (c *DeviceConfig) createTun() tunCreator { + if c.KernelMode { + return createKernelTun + } + return createGVisorTun +} diff --git a/proxy/wireguard/config.pb.go b/proxy/wireguard/config.pb.go index dfe7dab5..ed8b135e 100644 --- a/proxy/wireguard/config.pb.go +++ b/proxy/wireguard/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.1 +// protoc-gen-go v1.28.1 +// protoc v4.25.0 // source: proxy/wireguard/config.proto package wireguard @@ -83,7 +83,7 @@ type PeerConfig struct { PublicKey string `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` PreSharedKey string `protobuf:"bytes,2,opt,name=pre_shared_key,json=preSharedKey,proto3" json:"pre_shared_key,omitempty"` Endpoint string `protobuf:"bytes,3,opt,name=endpoint,proto3" json:"endpoint,omitempty"` - KeepAlive int32 `protobuf:"varint,4,opt,name=keep_alive,json=keepAlive,proto3" json:"keep_alive,omitempty"` + KeepAlive uint32 `protobuf:"varint,4,opt,name=keep_alive,json=keepAlive,proto3" json:"keep_alive,omitempty"` AllowedIps []string `protobuf:"bytes,5,rep,name=allowed_ips,json=allowedIps,proto3" json:"allowed_ips,omitempty"` } @@ -140,7 +140,7 @@ func (x *PeerConfig) GetEndpoint() string { return "" } -func (x *PeerConfig) GetKeepAlive() int32 { +func (x *PeerConfig) GetKeepAlive() uint32 { if x != nil { return x.KeepAlive } @@ -166,6 +166,8 @@ type DeviceConfig struct { NumWorkers int32 `protobuf:"varint,5,opt,name=num_workers,json=numWorkers,proto3" json:"num_workers,omitempty"` Reserved []byte `protobuf:"bytes,6,opt,name=reserved,proto3" json:"reserved,omitempty"` DomainStrategy DeviceConfig_DomainStrategy `protobuf:"varint,7,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.proxy.wireguard.DeviceConfig_DomainStrategy" json:"domain_strategy,omitempty"` + IsClient bool `protobuf:"varint,8,opt,name=is_client,json=isClient,proto3" json:"is_client,omitempty"` + KernelMode bool `protobuf:"varint,9,opt,name=kernel_mode,json=kernelMode,proto3" json:"kernel_mode,omitempty"` } func (x *DeviceConfig) Reset() { @@ -249,6 +251,20 @@ func (x *DeviceConfig) GetDomainStrategy() DeviceConfig_DomainStrategy { return DeviceConfig_FORCE_IP } +func (x *DeviceConfig) GetIsClient() bool { + if x != nil { + return x.IsClient + } + return false +} + +func (x *DeviceConfig) GetKernelMode() bool { + if x != nil { + return x.KernelMode + } + return false +} + var File_proxy_wireguard_config_proto protoreflect.FileDescriptor var file_proxy_wireguard_config_proto_rawDesc = []byte{ @@ -263,10 +279,10 @@ var file_proxy_wireguard_config_proto_rawDesc = []byte{ 0x68, 0x61, 0x72, 0x65, 0x64, 0x4b, 0x65, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, - 0x76, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6b, 0x65, 0x65, 0x70, 0x41, 0x6c, + 0x76, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x6b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, - 0x64, 0x49, 0x70, 0x73, 0x22, 0x8a, 0x03, 0x0a, 0x0c, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x43, + 0x64, 0x49, 0x70, 0x73, 0x22, 0xc8, 0x03, 0x0a, 0x0c, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, @@ -285,19 +301,23 @@ var file_proxy_wireguard_config_proto_rawDesc = []byte{ 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2e, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, - 0x65, 0x67, 0x79, 0x22, 0x5c, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, - 0x50, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, - 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, - 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, - 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, - 0x04, 0x42, 0x5e, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2e, 0x77, 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0x50, 0x01, 0x5a, - 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, - 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x2f, 0x77, 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0xaa, 0x02, 0x14, 0x58, 0x72, 0x61, - 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x57, 0x69, 0x72, 0x65, 0x47, 0x75, 0x61, 0x72, - 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x67, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x12, 0x1f, 0x0a, 0x0b, 0x6b, 0x65, 0x72, 0x6e, 0x65, 0x6c, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6b, 0x65, 0x72, 0x6e, 0x65, 0x6c, 0x4d, 0x6f, 0x64, + 0x65, 0x22, 0x5c, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, + 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x01, + 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x12, + 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x03, 0x12, + 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x04, 0x42, + 0x5e, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x2e, 0x77, 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0x50, 0x01, 0x5a, 0x29, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, + 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x77, + 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0xaa, 0x02, 0x14, 0x58, 0x72, 0x61, 0x79, 0x2e, + 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x57, 0x69, 0x72, 0x65, 0x47, 0x75, 0x61, 0x72, 0x64, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/wireguard/config.proto b/proxy/wireguard/config.proto index 0a12c009..e7fd66f4 100644 --- a/proxy/wireguard/config.proto +++ b/proxy/wireguard/config.proto @@ -7,26 +7,28 @@ option java_package = "com.xray.proxy.wireguard"; option java_multiple_files = true; message PeerConfig { - string public_key = 1; - string pre_shared_key = 2; - string endpoint = 3; - int32 keep_alive = 4; - repeated string allowed_ips = 5; + string public_key = 1; + string pre_shared_key = 2; + string endpoint = 3; + uint32 keep_alive = 4; + repeated string allowed_ips = 5; } message DeviceConfig { - enum DomainStrategy { - FORCE_IP = 0; - FORCE_IP4 = 1; - FORCE_IP6 = 2; - FORCE_IP46 = 3; - FORCE_IP64 = 4; - } - string secret_key = 1; - repeated string endpoint = 2; - repeated PeerConfig peers = 3; - int32 mtu = 4; - int32 num_workers = 5; - bytes reserved = 6; - DomainStrategy domain_strategy = 7; + enum DomainStrategy { + FORCE_IP = 0; + FORCE_IP4 = 1; + FORCE_IP6 = 2; + FORCE_IP46 = 3; + FORCE_IP64 = 4; + } + string secret_key = 1; + repeated string endpoint = 2; + repeated PeerConfig peers = 3; + int32 mtu = 4; + int32 num_workers = 5; + bytes reserved = 6; + DomainStrategy domain_strategy = 7; + bool is_client = 8; + bool kernel_mode = 9; } \ No newline at end of file diff --git a/proxy/wireguard/gvisortun/tun.go b/proxy/wireguard/gvisortun/tun.go new file mode 100644 index 00000000..9e9a0b2b --- /dev/null +++ b/proxy/wireguard/gvisortun/tun.go @@ -0,0 +1,230 @@ +/* SPDX-License-Identifier: MIT + * + * Copyright (C) 2017-2022 WireGuard LLC. All Rights Reserved. + */ + +package gvisortun + +import ( + "context" + "fmt" + "net/netip" + "os" + "syscall" + + "golang.zx2c4.com/wireguard/tun" + "gvisor.dev/gvisor/pkg/buffer" + "gvisor.dev/gvisor/pkg/tcpip" + "gvisor.dev/gvisor/pkg/tcpip/adapters/gonet" + "gvisor.dev/gvisor/pkg/tcpip/header" + "gvisor.dev/gvisor/pkg/tcpip/link/channel" + "gvisor.dev/gvisor/pkg/tcpip/network/ipv4" + "gvisor.dev/gvisor/pkg/tcpip/network/ipv6" + "gvisor.dev/gvisor/pkg/tcpip/stack" + "gvisor.dev/gvisor/pkg/tcpip/transport/icmp" + "gvisor.dev/gvisor/pkg/tcpip/transport/tcp" + "gvisor.dev/gvisor/pkg/tcpip/transport/udp" +) + +type netTun struct { + ep *channel.Endpoint + stack *stack.Stack + events chan tun.Event + incomingPacket chan *buffer.View + mtu int + hasV4, hasV6 bool +} + +type Net netTun + +func CreateNetTUN(localAddresses []netip.Addr, mtu int, promiscuousMode bool) (tun.Device, *Net, *stack.Stack, error) { + opts := stack.Options{ + NetworkProtocols: []stack.NetworkProtocolFactory{ipv4.NewProtocol, ipv6.NewProtocol}, + TransportProtocols: []stack.TransportProtocolFactory{tcp.NewProtocol, udp.NewProtocol, icmp.NewProtocol6, icmp.NewProtocol4}, + HandleLocal: !promiscuousMode, + } + dev := &netTun{ + ep: channel.New(1024, uint32(mtu), ""), + stack: stack.New(opts), + events: make(chan tun.Event, 1), + incomingPacket: make(chan *buffer.View), + mtu: mtu, + } + dev.ep.AddNotify(dev) + tcpipErr := dev.stack.CreateNIC(1, dev.ep) + if tcpipErr != nil { + return nil, nil, dev.stack, fmt.Errorf("CreateNIC: %v", tcpipErr) + } + for _, ip := range localAddresses { + var protoNumber tcpip.NetworkProtocolNumber + if ip.Is4() { + protoNumber = ipv4.ProtocolNumber + } else if ip.Is6() { + protoNumber = ipv6.ProtocolNumber + } + protoAddr := tcpip.ProtocolAddress{ + Protocol: protoNumber, + AddressWithPrefix: tcpip.AddrFromSlice(ip.AsSlice()).WithPrefix(), + } + tcpipErr := dev.stack.AddProtocolAddress(1, protoAddr, stack.AddressProperties{}) + if tcpipErr != nil { + return nil, nil, dev.stack, fmt.Errorf("AddProtocolAddress(%v): %v", ip, tcpipErr) + } + if ip.Is4() { + dev.hasV4 = true + } else if ip.Is6() { + dev.hasV6 = true + } + } + if dev.hasV4 { + dev.stack.AddRoute(tcpip.Route{Destination: header.IPv4EmptySubnet, NIC: 1}) + } + if dev.hasV6 { + dev.stack.AddRoute(tcpip.Route{Destination: header.IPv6EmptySubnet, NIC: 1}) + } + if promiscuousMode { + // enable promiscuous mode to handle all packets processed by netstack + dev.stack.SetPromiscuousMode(1, true) + dev.stack.SetSpoofing(1, true) + } + + opt := tcpip.CongestionControlOption("cubic") + if err := dev.stack.SetTransportProtocolOption(tcp.ProtocolNumber, &opt); err != nil { + return nil, nil, dev.stack, fmt.Errorf("SetTransportProtocolOption(%d, &%T(%s)): %s", tcp.ProtocolNumber, opt, opt, err) + } + + dev.events <- tun.EventUp + return dev, (*Net)(dev), dev.stack, nil +} + +// BatchSize implements tun.Device +func (tun *netTun) BatchSize() int { + return 1 +} + +// Name implements tun.Device +func (tun *netTun) Name() (string, error) { + return "go", nil +} + +// File implements tun.Device +func (tun *netTun) File() *os.File { + return nil +} + +// Events implements tun.Device +func (tun *netTun) Events() <-chan tun.Event { + return tun.events +} + +// Read implements tun.Device + +func (tun *netTun) Read(buf [][]byte, sizes []int, offset int) (int, error) { + view, ok := <-tun.incomingPacket + if !ok { + return 0, os.ErrClosed + } + + n, err := view.Read(buf[0][offset:]) + if err != nil { + return 0, err + } + sizes[0] = n + return 1, nil +} + +// Write implements tun.Device +func (tun *netTun) Write(buf [][]byte, offset int) (int, error) { + for _, buf := range buf { + packet := buf[offset:] + if len(packet) == 0 { + continue + } + + pkb := stack.NewPacketBuffer(stack.PacketBufferOptions{Payload: buffer.MakeWithData(packet)}) + switch packet[0] >> 4 { + case 4: + tun.ep.InjectInbound(header.IPv4ProtocolNumber, pkb) + case 6: + tun.ep.InjectInbound(header.IPv6ProtocolNumber, pkb) + default: + return 0, syscall.EAFNOSUPPORT + } + } + return len(buf), nil +} + +// WriteNotify implements channel.Notification +func (tun *netTun) WriteNotify() { + pkt := tun.ep.Read() + if pkt.IsNil() { + return + } + + view := pkt.ToView() + pkt.DecRef() + + tun.incomingPacket <- view +} + +// Flush implements tun.Device +func (tun *netTun) Flush() error { + return nil +} + +// Close implements tun.Device +func (tun *netTun) Close() error { + tun.stack.RemoveNIC(1) + + if tun.events != nil { + close(tun.events) + } + + tun.ep.Close() + + if tun.incomingPacket != nil { + close(tun.incomingPacket) + } + + return nil +} + +// MTU implements tun.Device +func (tun *netTun) MTU() (int, error) { + return tun.mtu, nil +} + +func convertToFullAddr(endpoint netip.AddrPort) (tcpip.FullAddress, tcpip.NetworkProtocolNumber) { + var protoNumber tcpip.NetworkProtocolNumber + if endpoint.Addr().Is4() { + protoNumber = ipv4.ProtocolNumber + } else { + protoNumber = ipv6.ProtocolNumber + } + return tcpip.FullAddress{ + NIC: 1, + Addr: tcpip.AddrFromSlice(endpoint.Addr().AsSlice()), + Port: endpoint.Port(), + }, protoNumber +} + +func (net *Net) DialContextTCPAddrPort(ctx context.Context, addr netip.AddrPort) (*gonet.TCPConn, error) { + fa, pn := convertToFullAddr(addr) + return gonet.DialContextTCP(ctx, net.stack, fa, pn) +} + +func (net *Net) DialUDPAddrPort(laddr, raddr netip.AddrPort) (*gonet.UDPConn, error) { + var lfa, rfa *tcpip.FullAddress + var pn tcpip.NetworkProtocolNumber + if laddr.IsValid() || laddr.Port() > 0 { + var addr tcpip.FullAddress + addr, pn = convertToFullAddr(laddr) + lfa = &addr + } + if raddr.IsValid() || raddr.Port() > 0 { + var addr tcpip.FullAddress + addr, pn = convertToFullAddr(raddr) + rfa = &addr + } + return gonet.DialUDP(net.stack, lfa, rfa, pn) +} diff --git a/proxy/wireguard/server.go b/proxy/wireguard/server.go new file mode 100644 index 00000000..6cd2d7ad --- /dev/null +++ b/proxy/wireguard/server.go @@ -0,0 +1,181 @@ +package wireguard + +import ( + "context" + "errors" + "io" + + "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/log" + "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/signal" + "github.com/xtls/xray-core/common/task" + "github.com/xtls/xray-core/core" + "github.com/xtls/xray-core/features/dns" + "github.com/xtls/xray-core/features/policy" + "github.com/xtls/xray-core/features/routing" + "github.com/xtls/xray-core/transport/internet/stat" +) + +var nullDestination = net.TCPDestination(net.AnyIP, 0) + +type Server struct { + bindServer *netBindServer + + info routingInfo + policyManager policy.Manager +} + +type routingInfo struct { + ctx context.Context + dispatcher routing.Dispatcher + inboundTag *session.Inbound + outboundTag *session.Outbound + contentTag *session.Content +} + +func NewServer(ctx context.Context, conf *DeviceConfig) (*Server, error) { + v := core.MustFromContext(ctx) + + endpoints, hasIPv4, hasIPv6, err := parseEndpoints(conf) + if err != nil { + return nil, err + } + + server := &Server{ + bindServer: &netBindServer{ + netBind: netBind{ + dns: v.GetFeature(dns.ClientType()).(dns.Client), + dnsOption: dns.IPOption{ + IPv4Enable: hasIPv4, + IPv6Enable: hasIPv6, + }, + }, + }, + policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), + } + + tun, err := conf.createTun()(endpoints, int(conf.Mtu), server.forwardConnection) + if err != nil { + return nil, err + } + + if err = tun.BuildDevice(createIPCRequest(conf), server.bindServer); err != nil { + _ = tun.Close() + return nil, err + } + + return server, nil +} + +// Network implements proxy.Inbound. +func (*Server) Network() []net.Network { + return []net.Network{net.Network_UDP} +} + +// Process implements proxy.Inbound. +func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error { + s.info = routingInfo{ + ctx: core.ToBackgroundDetachedContext(ctx), + dispatcher: dispatcher, + inboundTag: session.InboundFromContext(ctx), + outboundTag: session.OutboundFromContext(ctx), + contentTag: session.ContentFromContext(ctx), + } + + ep, err := s.bindServer.ParseEndpoint(conn.RemoteAddr().String()) + if err != nil { + return err + } + + nep := ep.(*netEndpoint) + nep.conn = conn + + reader := buf.NewPacketReader(conn) + for { + mpayload, err := reader.ReadMultiBuffer() + if err != nil { + return err + } + + for _, payload := range mpayload { + v, ok := <-s.bindServer.readQueue + if !ok { + return nil + } + i, err := payload.Read(v.buff) + + v.bytes = i + v.endpoint = nep + v.err = err + v.waiter.Done() + if err != nil && errors.Is(err, io.EOF) { + nep.conn = nil + return nil + } + } + } +} + +func (s *Server) forwardConnection(dest net.Destination, conn net.Conn) { + if s.info.dispatcher == nil { + newError("unexpected: dispatcher == nil").AtError().WriteToLog() + return + } + defer conn.Close() + + ctx, cancel := context.WithCancel(core.ToBackgroundDetachedContext(s.info.ctx)) + plcy := s.policyManager.ForLevel(0) + timer := signal.CancelAfterInactivity(ctx, cancel, plcy.Timeouts.ConnectionIdle) + + ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{ + From: nullDestination, + To: dest, + Status: log.AccessAccepted, + Reason: "", + }) + + if s.info.inboundTag != nil { + ctx = session.ContextWithInbound(ctx, s.info.inboundTag) + } + if s.info.outboundTag != nil { + ctx = session.ContextWithOutbound(ctx, s.info.outboundTag) + } + if s.info.contentTag != nil { + ctx = session.ContextWithContent(ctx, s.info.contentTag) + } + + link, err := s.info.dispatcher.Dispatch(ctx, dest) + if err != nil { + newError("dispatch connection").Base(err).AtError().WriteToLog() + } + defer cancel() + + requestDone := func() error { + defer timer.SetTimeout(plcy.Timeouts.DownlinkOnly) + if err := buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer)); err != nil { + return newError("failed to transport all TCP request").Base(err) + } + + return nil + } + + responseDone := func() error { + defer timer.SetTimeout(plcy.Timeouts.UplinkOnly) + if err := buf.Copy(link.Reader, buf.NewWriter(conn), buf.UpdateActivity(timer)); err != nil { + return newError("failed to transport all TCP response").Base(err) + } + + return nil + } + + requestDonePost := task.OnSuccess(requestDone, task.Close(link.Writer)) + if err := task.Run(ctx, requestDonePost, responseDone); err != nil { + common.Interrupt(link.Reader) + common.Interrupt(link.Writer) + newError("connection ends").Base(err).AtDebug().WriteToLog() + return + } +} diff --git a/proxy/wireguard/tun.go b/proxy/wireguard/tun.go index c320d0d0..c2d30323 100644 --- a/proxy/wireguard/tun.go +++ b/proxy/wireguard/tun.go @@ -10,14 +10,26 @@ import ( "strconv" "strings" "sync" + "time" "github.com/xtls/xray-core/common/log" + xnet "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/proxy/wireguard/gvisortun" + "gvisor.dev/gvisor/pkg/tcpip" + "gvisor.dev/gvisor/pkg/tcpip/adapters/gonet" + "gvisor.dev/gvisor/pkg/tcpip/transport/tcp" + "gvisor.dev/gvisor/pkg/tcpip/transport/udp" + "gvisor.dev/gvisor/pkg/waiter" "golang.zx2c4.com/wireguard/conn" "golang.zx2c4.com/wireguard/device" "golang.zx2c4.com/wireguard/tun" ) +type tunCreator func(localAddresses []netip.Addr, mtu int, handler promiscuousModeHandler) (Tunnel, error) + +type promiscuousModeHandler func(dest xnet.Destination, conn net.Conn) + type Tunnel interface { BuildDevice(ipc string, bind conn.Bind) error DialContextTCPAddrPort(ctx context.Context, addr netip.AddrPort) (net.Conn, error) @@ -103,3 +115,91 @@ func CalculateInterfaceName(name string) (tunName string) { tunName = fmt.Sprintf("%s%d", tunName, tunIndex) return } + +var _ Tunnel = (*gvisorNet)(nil) + +type gvisorNet struct { + tunnel + net *gvisortun.Net +} + +func (g *gvisorNet) Close() error { + return g.tunnel.Close() +} + +func (g *gvisorNet) DialContextTCPAddrPort(ctx context.Context, addr netip.AddrPort) ( + net.Conn, error, +) { + return g.net.DialContextTCPAddrPort(ctx, addr) +} + +func (g *gvisorNet) DialUDPAddrPort(laddr, raddr netip.AddrPort) (net.Conn, error) { + return g.net.DialUDPAddrPort(laddr, raddr) +} + +func createGVisorTun(localAddresses []netip.Addr, mtu int, handler promiscuousModeHandler) (Tunnel, error) { + out := &gvisorNet{} + tun, n, stack, err := gvisortun.CreateNetTUN(localAddresses, mtu, handler != nil) + if err != nil { + return nil, err + } + + if handler != nil { + // handler is only used for promiscuous mode + // capture all packets and send to handler + + tcpForwarder := tcp.NewForwarder(stack, 0, 65535, func(r *tcp.ForwarderRequest) { + go func(r *tcp.ForwarderRequest) { + var ( + wq waiter.Queue + id = r.ID() + ) + + // Perform a TCP three-way handshake. + ep, err := r.CreateEndpoint(&wq) + if err != nil { + newError(err.String()).AtError().WriteToLog() + r.Complete(true) + return + } + r.Complete(false) + defer ep.Close() + + // enable tcp keep-alive to prevent hanging connections + ep.SocketOptions().SetKeepAlive(true) + + // local address is actually destination + handler(xnet.TCPDestination(xnet.IPAddress(id.LocalAddress.AsSlice()), xnet.Port(id.LocalPort)), gonet.NewTCPConn(&wq, ep)) + }(r) + }) + stack.SetTransportProtocolHandler(tcp.ProtocolNumber, tcpForwarder.HandlePacket) + + udpForwarder := udp.NewForwarder(stack, func(r *udp.ForwarderRequest) { + go func(r *udp.ForwarderRequest) { + var ( + wq waiter.Queue + id = r.ID() + ) + + ep, err := r.CreateEndpoint(&wq) + if err != nil { + newError(err.String()).AtError().WriteToLog() + return + } + defer ep.Close() + + // prevents hanging connections and ensure timely release + ep.SocketOptions().SetLinger(tcpip.LingerOption{ + Enabled: true, + Timeout: 15 * time.Second, + }) + + handler(xnet.UDPDestination(xnet.IPAddress(id.LocalAddress.AsSlice()), xnet.Port(id.LocalPort)), gonet.NewUDPConn(stack, &wq, ep)) + }(r) + }) + stack.SetTransportProtocolHandler(udp.ProtocolNumber, udpForwarder.HandlePacket) + } + + out.tun, out.net = tun, n + return out, nil +} diff --git a/proxy/wireguard/tun_default.go b/proxy/wireguard/tun_default.go index 07f21272..4d0567af 100644 --- a/proxy/wireguard/tun_default.go +++ b/proxy/wireguard/tun_default.go @@ -1,42 +1,16 @@ -//go:build !linux +//go:build !linux || android package wireguard import ( - "context" - "net" + "errors" "net/netip" - - "golang.zx2c4.com/wireguard/tun/netstack" ) -var _ Tunnel = (*gvisorNet)(nil) - -type gvisorNet struct { - tunnel - net *netstack.Net +func createKernelTun(localAddresses []netip.Addr, mtu int, handler promiscuousModeHandler) (t Tunnel, err error) { + return nil, errors.New("not implemented") } -func (g *gvisorNet) Close() error { - return g.tunnel.Close() -} - -func (g *gvisorNet) DialContextTCPAddrPort(ctx context.Context, addr netip.AddrPort) ( - net.Conn, error, -) { - return g.net.DialContextTCPAddrPort(ctx, addr) -} - -func (g *gvisorNet) DialUDPAddrPort(laddr, raddr netip.AddrPort) (net.Conn, error) { - return g.net.DialUDPAddrPort(laddr, raddr) -} - -func CreateTun(localAddresses []netip.Addr, mtu int) (Tunnel, error) { - out := &gvisorNet{} - tun, n, err := netstack.CreateNetTUN(localAddresses, nil, mtu) - if err != nil { - return nil, err - } - out.tun, out.net = tun, n - return out, nil +func KernelTunSupported() bool { + return false } diff --git a/proxy/wireguard/tun_linux.go b/proxy/wireguard/tun_linux.go index ec940c56..b85a9d09 100644 --- a/proxy/wireguard/tun_linux.go +++ b/proxy/wireguard/tun_linux.go @@ -1,3 +1,5 @@ +//go:build linux && !android + package wireguard import ( @@ -69,7 +71,11 @@ func (d *deviceNet) Close() (err error) { return errors.Join(errs...) } -func CreateTun(localAddresses []netip.Addr, mtu int) (t Tunnel, err error) { +func createKernelTun(localAddresses []netip.Addr, mtu int, handler promiscuousModeHandler) (t Tunnel, err error) { + if handler != nil { + return nil, newError("TODO: support promiscuous mode") + } + var v4, v6 *netip.Addr for _, prefixes := range localAddresses { if v4 == nil && prefixes.Is4() { @@ -221,3 +227,11 @@ func CreateTun(localAddresses []netip.Addr, mtu int) (t Tunnel, err error) { out.tun = wgt return out, nil } + +func KernelTunSupported() bool { + // run a superuser permission check to check + // if the current user has the sufficient permission + // to create a tun device. + + return unix.Geteuid() == 0 // 0 means root +} diff --git a/proxy/wireguard/wireguard.go b/proxy/wireguard/wireguard.go index 48e2ace3..2b3c3007 100644 --- a/proxy/wireguard/wireguard.go +++ b/proxy/wireguard/wireguard.go @@ -1,326 +1,111 @@ -/* - -Some of codes are copied from https://github.com/octeep/wireproxy, license below. - -Copyright (c) 2022 Wind T.F. Wong - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -*/ - package wireguard import ( - "bytes" "context" "fmt" - stdnet "net" "net/netip" "strings" - "sync" "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/log" - "github.com/xtls/xray-core/common/net" - "github.com/xtls/xray-core/common/protocol" - "github.com/xtls/xray-core/common/session" - "github.com/xtls/xray-core/common/signal" - "github.com/xtls/xray-core/common/task" - "github.com/xtls/xray-core/core" - "github.com/xtls/xray-core/features/dns" - "github.com/xtls/xray-core/features/policy" - "github.com/xtls/xray-core/transport" - "github.com/xtls/xray-core/transport/internet" + "golang.zx2c4.com/wireguard/device" ) -// Handler is an outbound connection that silently swallow the entire payload. -type Handler struct { - conf *DeviceConfig - net Tunnel - bind *netBindClient - policyManager policy.Manager - dns dns.Client - // cached configuration - ipc string - endpoints []netip.Addr - hasIPv4, hasIPv6 bool - wgLock sync.Mutex -} +//go:generate go run github.com/xtls/xray-core/common/errors/errorgen -// New creates a new wireguard handler. -func New(ctx context.Context, conf *DeviceConfig) (*Handler, error) { - v := core.MustFromContext(ctx) - - endpoints, err := parseEndpoints(conf) - if err != nil { - return nil, err - } - - hasIPv4, hasIPv6 := false, false - for _, e := range endpoints { - if e.Is4() { - hasIPv4 = true - } - if e.Is6() { - hasIPv6 = true - } - } - - d := v.GetFeature(dns.ClientType()).(dns.Client) - return &Handler{ - conf: conf, - policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), - dns: d, - ipc: createIPCRequest(conf, d, hasIPv6), - endpoints: endpoints, - hasIPv4: hasIPv4, - hasIPv6: hasIPv6, - }, nil -} - -func (h *Handler) processWireGuard(dialer internet.Dialer) (err error) { - h.wgLock.Lock() - defer h.wgLock.Unlock() - - if h.bind != nil && h.bind.dialer == dialer && h.net != nil { - return nil - } - - log.Record(&log.GeneralMessage{ - Severity: log.Severity_Info, - Content: "switching dialer", - }) - - if h.net != nil { - _ = h.net.Close() - h.net = nil - } - if h.bind != nil { - _ = h.bind.Close() - h.bind = nil - } - - // bind := conn.NewStdNetBind() // TODO: conn.Bind wrapper for dialer - bind := &netBindClient{ - dialer: dialer, - workers: int(h.conf.NumWorkers), - dns: h.dns, - reserved: h.conf.Reserved, - } - defer func() { - if err != nil { - _ = bind.Close() - } - }() - - h.net, err = h.makeVirtualTun(bind) - if err != nil { - return newError("failed to create virtual tun interface").Base(err) - } - h.bind = bind - return nil -} - -// Process implements OutboundHandler.Dispatch(). -func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error { - outbound := session.OutboundFromContext(ctx) - if outbound == nil || !outbound.Target.IsValid() { - return newError("target not specified") - } - outbound.Name = "wireguard" - inbound := session.InboundFromContext(ctx) - if inbound != nil { - inbound.SetCanSpliceCopy(3) - } - - if err := h.processWireGuard(dialer); err != nil { - return err - } - - // Destination of the inner request. - destination := outbound.Target - command := protocol.RequestCommandTCP - if destination.Network == net.Network_UDP { - command = protocol.RequestCommandUDP - } - - // resolve dns - addr := destination.Address - if addr.Family().IsDomain() { - ips, err := h.dns.LookupIP(addr.Domain(), dns.IPOption{ - IPv4Enable: h.hasIPv4 && h.conf.preferIP4(), - IPv6Enable: h.hasIPv6 && h.conf.preferIP6(), +var wgLogger = &device.Logger{ + Verbosef: func(format string, args ...any) { + log.Record(&log.GeneralMessage{ + Severity: log.Severity_Debug, + Content: fmt.Sprintf(format, args...), }) - { // Resolve fallback - if (len(ips) == 0 || err != nil) && h.conf.hasFallback() { - ips, err = h.dns.LookupIP(addr.Domain(), dns.IPOption{ - IPv4Enable: h.hasIPv4 && h.conf.fallbackIP4(), - IPv6Enable: h.hasIPv6 && h.conf.fallbackIP6(), - }) - } - } - if err != nil { - return newError("failed to lookup DNS").Base(err) - } else if len(ips) == 0 { - return dns.ErrEmptyResponse - } - addr = net.IPAddress(ips[dice.Roll(len(ips))]) - } - - var newCtx context.Context - var newCancel context.CancelFunc - if session.TimeoutOnlyFromContext(ctx) { - newCtx, newCancel = context.WithCancel(context.Background()) - } - - p := h.policyManager.ForLevel(0) - - ctx, cancel := context.WithCancel(ctx) - timer := signal.CancelAfterInactivity(ctx, func() { - cancel() - if newCancel != nil { - newCancel() - } - }, p.Timeouts.ConnectionIdle) - addrPort := netip.AddrPortFrom(toNetIpAddr(addr), destination.Port.Value()) - - var requestFunc func() error - var responseFunc func() error - - if command == protocol.RequestCommandTCP { - conn, err := h.net.DialContextTCPAddrPort(ctx, addrPort) - if err != nil { - return newError("failed to create TCP connection").Base(err) - } - defer conn.Close() - - requestFunc = func() error { - defer timer.SetTimeout(p.Timeouts.DownlinkOnly) - return buf.Copy(link.Reader, buf.NewWriter(conn), buf.UpdateActivity(timer)) - } - responseFunc = func() error { - defer timer.SetTimeout(p.Timeouts.UplinkOnly) - return buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer)) - } - } else if command == protocol.RequestCommandUDP { - conn, err := h.net.DialUDPAddrPort(netip.AddrPort{}, addrPort) - if err != nil { - return newError("failed to create UDP connection").Base(err) - } - defer conn.Close() - - requestFunc = func() error { - defer timer.SetTimeout(p.Timeouts.DownlinkOnly) - return buf.Copy(link.Reader, buf.NewWriter(conn), buf.UpdateActivity(timer)) - } - responseFunc = func() error { - defer timer.SetTimeout(p.Timeouts.UplinkOnly) - return buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer)) - } - } - - if newCtx != nil { - ctx = newCtx - } - - responseDonePost := task.OnSuccess(responseFunc, task.Close(link.Writer)) - if err := task.Run(ctx, requestFunc, responseDonePost); err != nil { - common.Interrupt(link.Reader) - common.Interrupt(link.Writer) - return newError("connection ends").Base(err) - } - - return nil + }, + Errorf: func(format string, args ...any) { + log.Record(&log.GeneralMessage{ + Severity: log.Severity_Error, + Content: fmt.Sprintf(format, args...), + }) + }, } -// serialize the config into an IPC request -func createIPCRequest(conf *DeviceConfig, d dns.Client, resolveEndPointToV4 bool) string { - var request bytes.Buffer - - request.WriteString(fmt.Sprintf("private_key=%s\n", conf.SecretKey)) - - for _, peer := range conf.Peers { - endpoint := peer.Endpoint - host, port, err := net.SplitHostPort(endpoint) - if resolveEndPointToV4 && err == nil { - _, err = netip.ParseAddr(host) - if err != nil { - ipList, err := d.LookupIP(host, dns.IPOption{IPv4Enable: true, IPv6Enable: false}) - if err == nil && len(ipList) > 0 { - endpoint = stdnet.JoinHostPort(ipList[0].String(), port) - } - } +func init() { + common.Must(common.RegisterConfig((*DeviceConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { + deviceConfig := config.(*DeviceConfig) + if deviceConfig.IsClient { + return New(ctx, deviceConfig) + } else { + return NewServer(ctx, deviceConfig) } - - request.WriteString(fmt.Sprintf("public_key=%s\nendpoint=%s\npersistent_keepalive_interval=%d\npreshared_key=%s\n", - peer.PublicKey, endpoint, peer.KeepAlive, peer.PreSharedKey)) - - for _, ip := range peer.AllowedIps { - request.WriteString(fmt.Sprintf("allowed_ip=%s\n", ip)) - } - } - - return request.String()[:request.Len()] + })) } // convert endpoint string to netip.Addr -func parseEndpoints(conf *DeviceConfig) ([]netip.Addr, error) { +func parseEndpoints(conf *DeviceConfig) ([]netip.Addr, bool, bool, error) { + var hasIPv4, hasIPv6 bool + endpoints := make([]netip.Addr, len(conf.Endpoint)) for i, str := range conf.Endpoint { var addr netip.Addr if strings.Contains(str, "/") { prefix, err := netip.ParsePrefix(str) if err != nil { - return nil, err + return nil, false, false, err } addr = prefix.Addr() if prefix.Bits() != addr.BitLen() { - return nil, newError("interface address subnet should be /32 for IPv4 and /128 for IPv6") + return nil, false, false, newError("interface address subnet should be /32 for IPv4 and /128 for IPv6") } } else { var err error addr, err = netip.ParseAddr(str) if err != nil { - return nil, err + return nil, false, false, err } } endpoints[i] = addr + + if addr.Is4() { + hasIPv4 = true + } else if addr.Is6() { + hasIPv6 = true + } } - return endpoints, nil + return endpoints, hasIPv4, hasIPv6, nil } -// creates a tun interface on netstack given a configuration -func (h *Handler) makeVirtualTun(bind *netBindClient) (Tunnel, error) { - t, err := CreateTun(h.endpoints, int(h.conf.Mtu)) - if err != nil { - return nil, err +// serialize the config into an IPC request +func createIPCRequest(conf *DeviceConfig) string { + var request strings.Builder + + request.WriteString(fmt.Sprintf("private_key=%s\n", conf.SecretKey)) + + if !conf.IsClient { + // placeholder, we'll handle actual port listening on Xray + request.WriteString("listen_port=1337\n") } - bind.dnsOption.IPv4Enable = h.hasIPv4 - bind.dnsOption.IPv6Enable = h.hasIPv6 + for _, peer := range conf.Peers { + if peer.PublicKey != "" { + request.WriteString(fmt.Sprintf("public_key=%s\n", peer.PublicKey)) + } - if err = t.BuildDevice(h.ipc, bind); err != nil { - _ = t.Close() - return nil, err + if peer.PreSharedKey != "" { + request.WriteString(fmt.Sprintf("preshared_key=%s\n", peer.PreSharedKey)) + } + + if peer.Endpoint != "" { + request.WriteString(fmt.Sprintf("endpoint=%s\n", peer.Endpoint)) + } + + for _, ip := range peer.AllowedIps { + request.WriteString(fmt.Sprintf("allowed_ip=%s\n", ip)) + } + + if peer.KeepAlive != 0 { + request.WriteString(fmt.Sprintf("persistent_keepalive_interval=%d\n", peer.KeepAlive)) + } } - return t, nil -} -func init() { - common.Must(common.RegisterConfig((*DeviceConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { - return New(ctx, config.(*DeviceConfig)) - })) + return request.String()[:request.Len()] } From 84014d7464a2d662c9576c2444a49b5df71bcab6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Nov 2023 00:40:27 +0000 Subject: [PATCH 200/867] Bump github.com/miekg/dns from 1.1.56 to 1.1.57 Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.56 to 1.1.57. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.56...v1.1.57) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d7f43f89..c0e7bfbe 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.6.0 github.com/gorilla/websocket v1.5.1 - github.com/miekg/dns v1.1.56 + github.com/miekg/dns v1.1.57 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.40.0 diff --git a/go.sum b/go.sum index 22473052..1239d8f0 100644 --- a/go.sum +++ b/go.sum @@ -92,8 +92,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= -github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE= -github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY= +github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM= +github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= From 2570855cd780e34893ad31d8d5ff2338a396005a Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 17 Nov 2023 20:10:46 -0500 Subject: [PATCH 201/867] Update v1.8.6 --- core/core.go | 2 +- proxy/wireguard/server.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index dfcaac6d..d11fa273 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 5 + Version_z byte = 6 ) var ( diff --git a/proxy/wireguard/server.go b/proxy/wireguard/server.go index 6cd2d7ad..bdb4e801 100644 --- a/proxy/wireguard/server.go +++ b/proxy/wireguard/server.go @@ -77,6 +77,10 @@ func (*Server) Network() []net.Network { // Process implements proxy.Inbound. func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error { + inbound := session.InboundFromContext(ctx) + inbound.Name = "wireguard" + inbound.SetCanSpliceCopy(3) + s.info = routingInfo{ ctx: core.ToBackgroundDetachedContext(ctx), dispatcher: dispatcher, From 6f092bd21223b654465ccbfa1aaaafa59723f982 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:08:34 -0500 Subject: [PATCH 202/867] Add "masterKeyLog" in TLS config (#2758) * Add "enableMasterKeyLog" in TLS config Turn on the debug option for Wireshark to decrypt traffic * Change to "masterKeyLog" to configure a path --- infra/conf/transport_internet.go | 3 +++ proxy/wireguard/config.pb.go | 4 ++-- transport/internet/tls/config.go | 10 ++++++++++ transport/internet/tls/config.pb.go | 30 +++++++++++++++++++---------- transport/internet/tls/config.proto | 2 ++ 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index e1471bde..318eb336 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -357,6 +357,7 @@ type TLSConfig struct { RejectUnknownSNI bool `json:"rejectUnknownSni"` PinnedPeerCertificateChainSha256 *[]string `json:"pinnedPeerCertificateChainSha256"` PinnedPeerCertificatePublicKeySha256 *[]string `json:"pinnedPeerCertificatePublicKeySha256"` + MasterKeyLog string `json:"masterKeyLog"` } // Build implements Buildable. @@ -412,6 +413,8 @@ func (c *TLSConfig) Build() (proto.Message, error) { } } + config.MasterKeyLog = c.MasterKeyLog + return config, nil } diff --git a/proxy/wireguard/config.pb.go b/proxy/wireguard/config.pb.go index ed8b135e..47bd2b77 100644 --- a/proxy/wireguard/config.pb.go +++ b/proxy/wireguard/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v4.25.0 +// protoc-gen-go v1.31.0 +// protoc v4.23.1 // source: proxy/wireguard/config.proto package wireguard diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 2e2b784a..325909e3 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -5,6 +5,7 @@ import ( "crypto/tls" "crypto/x509" "encoding/base64" + "os" "strings" "sync" "time" @@ -364,6 +365,15 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { config.PreferServerCipherSuites = c.PreferServerCipherSuites + if (len(c.MasterKeyLog) > 0 && c.MasterKeyLog != "none") { + writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644) + if err != nil { + newError("failed to open ", c.MasterKeyLog, " as master key log").AtError().Base(err).WriteToLog() + } else { + config.KeyLogWriter = writer + } + } + return config } diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index 9bd5a84d..7602f3e9 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -208,6 +208,7 @@ type Config struct { // @Document This value replace allow_insecure. // @Critical PinnedPeerCertificatePublicKeySha256 [][]byte `protobuf:"bytes,14,rep,name=pinned_peer_certificate_public_key_sha256,json=pinnedPeerCertificatePublicKeySha256,proto3" json:"pinned_peer_certificate_public_key_sha256,omitempty"` + MasterKeyLog string `protobuf:"bytes,15,opt,name=master_key_log,json=masterKeyLog,proto3" json:"master_key_log,omitempty"` } func (x *Config) Reset() { @@ -340,6 +341,13 @@ func (x *Config) GetPinnedPeerCertificatePublicKeySha256() [][]byte { return nil } +func (x *Config) GetMasterKeyLog() string { + if x != nil { + return x.MasterKeyLog + } + return "" +} + var File_transport_internet_tls_config_proto protoreflect.FileDescriptor var file_transport_internet_tls_config_proto_rawDesc = []byte{ @@ -369,7 +377,7 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x43, 0x49, 0x50, 0x48, 0x45, 0x52, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, - 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xcc, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, + 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xf2, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x49, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x63, 0x65, 0x72, @@ -414,15 +422,17 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x6b, 0x65, 0x79, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, - 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x42, 0x73, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, - 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, + 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, 0x42, 0x73, 0x0a, 0x1f, + 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x50, + 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, + 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, + 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x6c, + 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/tls/config.proto b/transport/internet/tls/config.proto index 227840a2..b1c26a4c 100644 --- a/transport/internet/tls/config.proto +++ b/transport/internet/tls/config.proto @@ -83,4 +83,6 @@ message Config { @Critical */ repeated bytes pinned_peer_certificate_public_key_sha256 = 14; + + string master_key_log = 15; } From 69cbb4c47a2940d9ce08d0c2a3425e112fa3e5fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Tue, 28 Nov 2023 18:25:37 +0800 Subject: [PATCH 203/867] Change WS upgraderBufferSize due to https://github.com/gorilla/websocket/issues/223 --- transport/internet/websocket/hub.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index 7951b1f4..c907e224 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -28,8 +28,8 @@ type requestHandler struct { var replacer = strings.NewReplacer("+", "-", "/", "_", "=", "") var upgrader = &websocket.Upgrader{ - ReadBufferSize: 4 * 1024, - WriteBufferSize: 4 * 1024, + ReadBufferSize: 0, + WriteBufferSize: 0, HandshakeTimeout: time.Second * 4, CheckOrigin: func(r *http.Request) bool { return true From be21b1194b0413c5e864012d0b36716d788929e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Nov 2023 00:54:23 +0000 Subject: [PATCH 204/867] Bump golang.org/x/net from 0.18.0 to 0.19.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.18.0 to 0.19.0. - [Commits](https://github.com/golang/net/compare/v0.18.0...v0.19.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index c0e7bfbe..7ea4e1ce 100644 --- a/go.mod +++ b/go.mod @@ -20,10 +20,10 @@ require ( github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20230824141953-6213f710f925 - golang.org/x/crypto v0.15.0 - golang.org/x/net v0.18.0 + golang.org/x/crypto v0.16.0 + golang.org/x/net v0.19.0 golang.org/x/sync v0.5.0 - golang.org/x/sys v0.14.0 + golang.org/x/sys v0.15.0 golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb google.golang.org/grpc v1.59.0 google.golang.org/protobuf v1.31.0 diff --git a/go.sum b/go.sum index 1239d8f0..0d8aef55 100644 --- a/go.sum +++ b/go.sum @@ -184,8 +184,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= @@ -206,8 +206,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= -golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -233,8 +233,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 2fd765ea4c31ed97d752f525f5f308f12cd04f45 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 12 Nov 2023 12:28:21 -0500 Subject: [PATCH 205/867] Delay XUDP Basekey read --- common/xudp/xudp.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/common/xudp/xudp.go b/common/xudp/xudp.go index af18119f..566ba749 100644 --- a/common/xudp/xudp.go +++ b/common/xudp/xudp.go @@ -6,7 +6,9 @@ import ( "encoding/base64" "fmt" "io" + "strconv" "strings" + "time" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/net" @@ -32,13 +34,16 @@ func init() { if strings.ToLower(platform.NewEnvFlag(platform.XUDPLog).GetValue(func() string { return "" })) == "true" { Show = true } - if raw := platform.NewEnvFlag(platform.XUDPBaseKey).GetValue(func() string { return "" }); raw != "" { - if BaseKey, _ = base64.RawURLEncoding.DecodeString(raw); len(BaseKey) == 32 { - return - } - panic(platform.XUDPBaseKey + ": invalid value: " + raw) - } rand.Read(BaseKey) + go func() { + time.Sleep(100 * time.Millisecond) // this is not nice, but need to give some time for Android to setup ENV + if raw := platform.NewEnvFlag(platform.XUDPBaseKey).GetValue(func() string { return "" }); raw != "" { + if BaseKey, _ = base64.RawURLEncoding.DecodeString(raw); len(BaseKey) == 32 { + return + } + panic(platform.XUDPBaseKey + ": invalid value (BaseKey must be 32 bytes): " + raw + " len " + strconv.Itoa(len(BaseKey))) + } + }() } func GetGlobalID(ctx context.Context) (globalID [8]byte) { From c590163f9ffb34c16a2da0096af07f625e7fb9ce Mon Sep 17 00:00:00 2001 From: Gorilla <147204357+gorilla800@users.noreply.github.com> Date: Thu, 30 Nov 2023 17:16:43 -0800 Subject: [PATCH 206/867] Update README.md Add link to tutorial for "Xray with WireGuard inbound" --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7d84f044..4ad50458 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,7 @@ - [REALITY (English)](https://cscot.pages.dev/2023/03/02/Xray-REALITY-tutorial/) - [XTLS-Iran-Reality (English)](https://github.com/SasukeFreestyle/XTLS-Iran-Reality) - [Xray REALITY with 'steal oneself' (English)](https://computerscot.github.io/vless-xtls-utls-reality-steal-oneself.html) + - [Xray with WireGuard inbound (English)](https://g800.pages.dev/wireguard) ## GUI Clients From 0c3e1d4bd9ca0fb6766322e0199688419e111274 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 00:23:03 +0000 Subject: [PATCH 207/867] Bump github.com/sagernet/sing from 0.2.17 to 0.2.18 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.2.17 to 0.2.18. - [Commits](https://github.com/sagernet/sing/compare/v0.2.17...v0.2.18) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7ea4e1ce..2c3b3f3e 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.40.0 github.com/refraction-networking/utls v1.5.4 - github.com/sagernet/sing v0.2.17 + github.com/sagernet/sing v0.2.18 github.com/sagernet/sing-shadowsocks v0.2.5 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 0d8aef55..a68e1b77 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83Fuavw github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.17 h1:vMPKb3MV0Aa5ws4dCJkRI8XEjrsUcDn810czd0FwmzI= -github.com/sagernet/sing v0.2.17/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= +github.com/sagernet/sing v0.2.18 h1:2Ce4dl0pkWft+4914NGXPb8OiQpgA8UHQ9xFOmgvKuY= +github.com/sagernet/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= github.com/sagernet/sing-shadowsocks v0.2.5 h1:qxIttos4xu6ii7MTVJYA8EFQR7Q3KG6xMqmLJIFtBaY= github.com/sagernet/sing-shadowsocks v0.2.5/go.mod h1:MGWGkcU2xW2G2mfArT9/QqpVLOGU+dBaahZCtPHdt7A= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= From 1444552691b9f64f5152191be1d4c2c45c811cf5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 7 Dec 2023 00:20:06 +0000 Subject: [PATCH 208/867] Bump actions/setup-go from 4 to 5 Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4 to 5. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57e14693..6ef8a74d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -165,7 +165,7 @@ jobs: echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.21' check-latest: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0ab32cd4..cf5d1259 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -28,7 +28,7 @@ jobs: os: [windows-latest, ubuntu-latest, macos-latest] steps: - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: '1.21' check-latest: true From 06734d6f08287387441c42a1da8e97274812e4ab Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Fri, 8 Dec 2023 09:07:51 -0800 Subject: [PATCH 209/867] common/ocsp: fix dropped error --- common/ocsp/ocsp.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/ocsp/ocsp.go b/common/ocsp/ocsp.go index 02140c0d..b2c0bc58 100644 --- a/common/ocsp/ocsp.go +++ b/common/ocsp/ocsp.go @@ -28,6 +28,9 @@ func GetOCSPStapling(cert [][]byte, path string) ([]byte, error) { ocspData, err := GetOCSPForFile(path) if err != nil { ocspData, err = GetOCSPForCert(cert) + if err != nil { + return nil, err + } if !CheckOCSPFileIsNotExist(path) { err = os.Remove(path) if err != nil { From 4e7a57ef8641075e115a1081ab456ff56989a244 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 00:29:38 +0000 Subject: [PATCH 210/867] Bump github.com/sagernet/sing-shadowsocks from 0.2.5 to 0.2.6 Bumps [github.com/sagernet/sing-shadowsocks](https://github.com/sagernet/sing-shadowsocks) from 0.2.5 to 0.2.6. - [Commits](https://github.com/sagernet/sing-shadowsocks/compare/v0.2.5...v0.2.6) --- updated-dependencies: - dependency-name: github.com/sagernet/sing-shadowsocks dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2c3b3f3e..1274e2b5 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/quic-go/quic-go v0.40.0 github.com/refraction-networking/utls v1.5.4 github.com/sagernet/sing v0.2.18 - github.com/sagernet/sing-shadowsocks v0.2.5 + github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e diff --git a/go.sum b/go.sum index a68e1b77..a07f7093 100644 --- a/go.sum +++ b/go.sum @@ -127,8 +127,8 @@ github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstv github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/sagernet/sing v0.2.18 h1:2Ce4dl0pkWft+4914NGXPb8OiQpgA8UHQ9xFOmgvKuY= github.com/sagernet/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= -github.com/sagernet/sing-shadowsocks v0.2.5 h1:qxIttos4xu6ii7MTVJYA8EFQR7Q3KG6xMqmLJIFtBaY= -github.com/sagernet/sing-shadowsocks v0.2.5/go.mod h1:MGWGkcU2xW2G2mfArT9/QqpVLOGU+dBaahZCtPHdt7A= +github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= +github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= From 2c97beae4e0a9da30f912bce52aab8786fb90377 Mon Sep 17 00:00:00 2001 From: Yu FranzKafka <38254177+FranzKafkaYu@users.noreply.github.com> Date: Tue, 12 Dec 2023 00:43:13 +0800 Subject: [PATCH 211/867] delete my repo for unnecessary disputes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 写了半天英文,感觉挺别扭的,还是用中文吧。 因为闭源的缘故,很抱歉给社区带来了负面影响;同时也是由于生活所迫,自己再没有额外的精力维护项目。自此,我提议在README中删除我的项目,并推荐大家使用其他仍在维护的版本。 原本想说的话有很多,千言万语到此都作烟消云散。 相信我不会离开,我们总会以其他的方式再次见面。 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4ad50458..158487bf 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ - [iamybj/docker-xray](https://hub.docker.com/r/iamybj/docker-xray) - [teddysun/xray](https://hub.docker.com/r/teddysun/xray) - Web Panel - - [X-UI](https://github.com/FranzKafkaYu/x-ui), [X-UI-English](https://github.com/NidukaAkalanka/x-ui-english), [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [X-UI](https://github.com/diditra/x-ui) + - [X-UI-English](https://github.com/NidukaAkalanka/x-ui-english), [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [X-UI](https://github.com/diditra/x-ui) - [Xray-UI](https://github.com/qist/xray-ui), [X-UI](https://github.com/sing-web/x-ui) - [Hiddify](https://github.com/hiddify/hiddify-config) - [Marzban](https://github.com/Gozargah/Marzban) From 2da476eef426e7bbb42915aa2178ebb3cc5a553c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=82=BB?= <123655015+chise0713@users.noreply.github.com> Date: Tue, 12 Dec 2023 09:52:10 +0800 Subject: [PATCH 212/867] Command: Add `wg` for wireguard key generation (#2794) * Command: Add `wg` for wireguard key generation * Command: Merge `x25519` and `wg` --- main/commands/all/commands.go | 1 + main/commands/all/curve25519.go | 57 +++++++++++++++++++++++++++++++++ main/commands/all/wg.go | 27 ++++++++++++++++ main/commands/all/x25519.go | 55 ++----------------------------- 4 files changed, 87 insertions(+), 53 deletions(-) create mode 100644 main/commands/all/curve25519.go create mode 100644 main/commands/all/wg.go diff --git a/main/commands/all/commands.go b/main/commands/all/commands.go index 9b8b49e0..41d0e0f1 100644 --- a/main/commands/all/commands.go +++ b/main/commands/all/commands.go @@ -16,5 +16,6 @@ func init() { tls.CmdTLS, cmdUUID, cmdX25519, + cmdWG, ) } diff --git a/main/commands/all/curve25519.go b/main/commands/all/curve25519.go new file mode 100644 index 00000000..25cc812e --- /dev/null +++ b/main/commands/all/curve25519.go @@ -0,0 +1,57 @@ +package all + +import ( + "crypto/rand" + "encoding/base64" + "fmt" + + "golang.org/x/crypto/curve25519" +) + +func Curve25519Genkey(StdEncoding bool, input_base64 string) { + var output string + var err error + var privateKey, publicKey []byte + var encoding *base64.Encoding + if *input_stdEncoding || StdEncoding { + encoding = base64.StdEncoding + } else { + encoding = base64.RawURLEncoding + } + + if len(input_base64) > 0 { + privateKey, err = encoding.DecodeString(input_base64) + if err != nil { + output = err.Error() + goto out + } + if len(privateKey) != curve25519.ScalarSize { + output = "Invalid length of private key." + goto out + } + } + + if privateKey == nil { + privateKey = make([]byte, curve25519.ScalarSize) + if _, err = rand.Read(privateKey); err != nil { + output = err.Error() + goto out + } + } + + // Modify random bytes using algorithm described at: + // https://cr.yp.to/ecdh.html. + privateKey[0] &= 248 + privateKey[31] &= 127 | 64 + + if publicKey, err = curve25519.X25519(privateKey, curve25519.Basepoint); err != nil { + output = err.Error() + goto out + } + + output = fmt.Sprintf("Private key: %v\nPublic key: %v", + encoding.EncodeToString(privateKey), + encoding.EncodeToString(publicKey)) +out: + fmt.Println(output) +} diff --git a/main/commands/all/wg.go b/main/commands/all/wg.go new file mode 100644 index 00000000..70da4668 --- /dev/null +++ b/main/commands/all/wg.go @@ -0,0 +1,27 @@ +package all + +import ( + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdWG = &base.Command{ + UsageLine: `{{.Exec}} wg [-i "private key (base64.StdEncoding)"]`, + Short: `Generate key pair for wireguard key exchange`, + Long: ` +Generate key pair for wireguard key exchange. + +Random: {{.Exec}} wg + +From private key: {{.Exec}} wg -i "private key (base64.StdEncoding)" +`, +} + +func init() { + cmdWG.Run = executeWG // break init loop +} + +var input_wireguard = cmdWG.Flag.String("i", "", "") + +func executeWG(cmd *base.Command, args []string) { + Curve25519Genkey(true, *input_wireguard) +} diff --git a/main/commands/all/x25519.go b/main/commands/all/x25519.go index 814cca72..73f669b2 100644 --- a/main/commands/all/x25519.go +++ b/main/commands/all/x25519.go @@ -1,12 +1,7 @@ package all import ( - "crypto/rand" - "encoding/base64" - "fmt" - "github.com/xtls/xray-core/main/commands/base" - "golang.org/x/crypto/curve25519" ) var cmdX25519 = &base.Command{ @@ -26,55 +21,9 @@ func init() { cmdX25519.Run = executeX25519 // break init loop } -var input_base64 = cmdX25519.Flag.String("i", "", "") var input_stdEncoding = cmdX25519.Flag.Bool("std-encoding", false, "") +var input_x25519 = cmdX25519.Flag.String("i", "", "") func executeX25519(cmd *base.Command, args []string) { - var output string - var err error - var privateKey []byte - var publicKey []byte - var encoding *base64.Encoding - if len(*input_base64) > 0 { - privateKey, err = base64.RawURLEncoding.DecodeString(*input_base64) - if err != nil { - output = err.Error() - goto out - } - if len(privateKey) != curve25519.ScalarSize { - output = "Invalid length of private key." - goto out - } - } - - if privateKey == nil { - privateKey = make([]byte, curve25519.ScalarSize) - if _, err = rand.Read(privateKey); err != nil { - output = err.Error() - goto out - } - } - - // Modify random bytes using algorithm described at: - // https://cr.yp.to/ecdh.html. - privateKey[0] &= 248 - privateKey[31] &= 127 - privateKey[31] |= 64 - - if publicKey, err = curve25519.X25519(privateKey, curve25519.Basepoint); err != nil { - output = err.Error() - goto out - } - - if *input_stdEncoding { - encoding = base64.StdEncoding - } else { - encoding = base64.RawURLEncoding - } - - output = fmt.Sprintf("Private key: %v\nPublic key: %v", - encoding.EncodeToString(privateKey), - encoding.EncodeToString(publicKey)) -out: - fmt.Println(output) + Curve25519Genkey(false, *input_x25519) } From 921be3ac40dffb2404b8d28cc5a7861184e5894f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Dec 2023 00:12:39 +0000 Subject: [PATCH 213/867] Bump google.golang.org/grpc from 1.59.0 to 1.60.0 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.59.0 to 1.60.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.59.0...v1.60.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1274e2b5..a2cbf726 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/sync v0.5.0 golang.org/x/sys v0.15.0 golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb - google.golang.org/grpc v1.59.0 + google.golang.org/grpc v1.60.0 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index a07f7093..aedbe25b 100644 --- a/go.sum +++ b/go.sum @@ -280,8 +280,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= +google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k= +google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From 46d6b9f57a2c43934681d63d40f2527f48acb218 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Dec 2023 00:12:42 +0000 Subject: [PATCH 214/867] Bump github.com/sagernet/sing from 0.2.18 to 0.2.19 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.2.18 to 0.2.19. - [Commits](https://github.com/sagernet/sing/compare/v0.2.18...v0.2.19) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a2cbf726..6d5ab543 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.40.0 github.com/refraction-networking/utls v1.5.4 - github.com/sagernet/sing v0.2.18 + github.com/sagernet/sing v0.2.19 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index aedbe25b..e00d5540 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83Fuavw github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.18 h1:2Ce4dl0pkWft+4914NGXPb8OiQpgA8UHQ9xFOmgvKuY= -github.com/sagernet/sing v0.2.18/go.mod h1:OL6k2F0vHmEzXz2KW19qQzu172FDgSbUSODylighuVo= +github.com/sagernet/sing v0.2.19 h1:Mdj/YJ5TtEyG+eIZaAlvX8j2cHxMN6eW4RF6Xh9iWyg= +github.com/sagernet/sing v0.2.19/go.mod h1:Ce5LNojQOgOiWhiD8pPD6E9H7e2KgtOe3Zxx4Ou5u80= github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= From 31a8fae76406eb4cbd9ec406947fd9f495b81bc5 Mon Sep 17 00:00:00 2001 From: wyx2685 Date: Tue, 12 Dec 2023 19:05:03 +0800 Subject: [PATCH 215/867] Fix deprecated StackNew() function --- proxy/shadowsocks_2022/outbound.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proxy/shadowsocks_2022/outbound.go b/proxy/shadowsocks_2022/outbound.go index a06daac7..031e7fc5 100644 --- a/proxy/shadowsocks_2022/outbound.go +++ b/proxy/shadowsocks_2022/outbound.go @@ -102,7 +102,7 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int if err != nil && err != buf.ErrNotTimeoutReader && err != buf.ErrReadTimeout { return newError("read payload").Base(err) } - _payload := B.StackNew() + _payload := B.New() payload := C.Dup(_payload) defer payload.Release() for { From 53ac4c031d7a42130bdb1c163a88f1b75ba36e05 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 14 Dec 2023 00:42:41 +0000 Subject: [PATCH 216/867] Bump github.com/quic-go/quic-go from 0.40.0 to 0.40.1 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.40.0 to 0.40.1. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.40.0...v0.40.1) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6d5ab543..466bd673 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/miekg/dns v1.1.57 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.40.0 + github.com/quic-go/quic-go v0.40.1 github.com/refraction-networking/utls v1.5.4 github.com/sagernet/sing v0.2.19 github.com/sagernet/sing-shadowsocks v0.2.6 diff --git a/go.sum b/go.sum index e00d5540..39a3041c 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs= github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.40.0 h1:GYd1iznlKm7dpHD7pOVpUvItgMPo/jrMgDWZhMCecqw= -github.com/quic-go/quic-go v0.40.0/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c= +github.com/quic-go/quic-go v0.40.1 h1:X3AGzUNFs0jVuO3esAGnTfvdgvL4fq655WaOi1snv1Q= +github.com/quic-go/quic-go v0.40.1/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c= github.com/refraction-networking/utls v1.5.4 h1:9k6EO2b8TaOGsQ7Pl7p9w6PUhx18/ZCeT0WNTZ7Uw4o= github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From 38b175d53e9043aa4fcda8fef9263d9ec313fbc1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Dec 2023 00:58:43 +0000 Subject: [PATCH 217/867] Bump actions/upload-artifact from 3 to 4 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6ef8a74d..e33b18b7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -235,7 +235,7 @@ jobs: mv build_assets Xray-${{ env.ASSET_NAME }} - name: Upload files to Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: Xray-${{ env.ASSET_NAME }} path: | From c01a30e8f42ee67b31f6737ad5d05c3c2c721056 Mon Sep 17 00:00:00 2001 From: H1JK Date: Fri, 15 Dec 2023 23:45:41 +0800 Subject: [PATCH 218/867] Cleanup sing buffer usage --- go.mod | 2 +- go.sum | 4 ++-- proxy/shadowsocks_2022/inbound.go | 2 +- proxy/shadowsocks_2022/inbound_multi.go | 2 +- proxy/shadowsocks_2022/inbound_relay.go | 2 +- proxy/shadowsocks_2022/outbound.go | 13 +++++-------- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 466bd673..3a8f1649 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.40.1 github.com/refraction-networking/utls v1.5.4 - github.com/sagernet/sing v0.2.19 + github.com/sagernet/sing v0.3.0-beta.2 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 39a3041c..a4920441 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83Fuavw github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.2.19 h1:Mdj/YJ5TtEyG+eIZaAlvX8j2cHxMN6eW4RF6Xh9iWyg= -github.com/sagernet/sing v0.2.19/go.mod h1:Ce5LNojQOgOiWhiD8pPD6E9H7e2KgtOe3Zxx4Ou5u80= +github.com/sagernet/sing v0.3.0-beta.2 h1:7wqgP+cMQeHS3M/64WWvJLeX07fLctBkE4+lguAFWeU= +github.com/sagernet/sing v0.3.0-beta.2/go.mod h1:9pfuAH6mZfgnz/YjP6xu5sxx882rfyjpcrTdUpd6w3g= github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= diff --git a/proxy/shadowsocks_2022/inbound.go b/proxy/shadowsocks_2022/inbound.go index 246fc7f1..00314c90 100644 --- a/proxy/shadowsocks_2022/inbound.go +++ b/proxy/shadowsocks_2022/inbound.go @@ -88,13 +88,13 @@ func (i *Inbound) Process(ctx context.Context, network net.Network, connection s } for _, buffer := range mb { packet := B.As(buffer.Bytes()).ToOwned() + buffer.Release() err = i.service.NewPacket(ctx, pc, packet, metadata) if err != nil { packet.Release() buf.ReleaseMulti(mb) return err } - buffer.Release() } } } diff --git a/proxy/shadowsocks_2022/inbound_multi.go b/proxy/shadowsocks_2022/inbound_multi.go index c3832a91..df837894 100644 --- a/proxy/shadowsocks_2022/inbound_multi.go +++ b/proxy/shadowsocks_2022/inbound_multi.go @@ -177,13 +177,13 @@ func (i *MultiUserInbound) Process(ctx context.Context, network net.Network, con } for _, buffer := range mb { packet := B.As(buffer.Bytes()).ToOwned() + buffer.Release() err = i.service.NewPacket(ctx, pc, packet, metadata) if err != nil { packet.Release() buf.ReleaseMulti(mb) return err } - buffer.Release() } } } diff --git a/proxy/shadowsocks_2022/inbound_relay.go b/proxy/shadowsocks_2022/inbound_relay.go index e2cb7d50..7317f8dd 100644 --- a/proxy/shadowsocks_2022/inbound_relay.go +++ b/proxy/shadowsocks_2022/inbound_relay.go @@ -109,13 +109,13 @@ func (i *RelayInbound) Process(ctx context.Context, network net.Network, connect } for _, buffer := range mb { packet := B.As(buffer.Bytes()).ToOwned() + buffer.Release() err = i.service.NewPacket(ctx, pc, packet, metadata) if err != nil { packet.Release() buf.ReleaseMulti(mb) return err } - buffer.Release() } } } diff --git a/proxy/shadowsocks_2022/outbound.go b/proxy/shadowsocks_2022/outbound.go index 031e7fc5..bc1eb556 100644 --- a/proxy/shadowsocks_2022/outbound.go +++ b/proxy/shadowsocks_2022/outbound.go @@ -2,7 +2,6 @@ package shadowsocks_2022 import ( "context" - "runtime" "time" shadowsocks "github.com/sagernet/sing-shadowsocks" @@ -102,27 +101,25 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int if err != nil && err != buf.ErrNotTimeoutReader && err != buf.ErrReadTimeout { return newError("read payload").Base(err) } - _payload := B.New() - payload := C.Dup(_payload) - defer payload.Release() + payload := B.New() for { - payload.FullReset() + payload.Reset() nb, n := buf.SplitBytes(mb, payload.FreeBytes()) if n > 0 { payload.Truncate(n) _, err = serverConn.Write(payload.Bytes()) if err != nil { + payload.Release() return newError("write payload").Base(err) } handshake = true } if nb.IsEmpty() { break - } else { - mb = nb } + mb = nb } - runtime.KeepAlive(_payload) + payload.Release() } if !handshake { _, err = serverConn.Write(nil) From 5a5e615b46369579240dac1fdfe2b5e122c4c4ce Mon Sep 17 00:00:00 2001 From: Zhang San <52621825+zhangsan946@users.noreply.github.com> Date: Mon, 18 Dec 2023 06:56:15 +0800 Subject: [PATCH 219/867] Enable interface setting for socketopt under Windows (#2819) * allow set interface under windows Signed-off-by: San Zhang * polish code Signed-off-by: San Zhang --------- Signed-off-by: San Zhang Co-authored-by: San Zhang --- transport/internet/sockopt_windows.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/transport/internet/sockopt_windows.go b/transport/internet/sockopt_windows.go index 703a53c2..e2f1f796 100644 --- a/transport/internet/sockopt_windows.go +++ b/transport/internet/sockopt_windows.go @@ -1,11 +1,16 @@ package internet import ( + "encoding/binary" + "net" "syscall" + "unsafe" ) const ( - TCP_FASTOPEN = 15 + TCP_FASTOPEN = 15 + IP_UNICAST_IF = 31 + IPV6_UNICAST_IF = 31 ) func setTFO(fd syscall.Handle, tfo int) error { @@ -21,6 +26,26 @@ func setTFO(fd syscall.Handle, tfo int) error { } func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error { + if config.Interface != "" { + inf, err := net.InterfaceByName(config.Interface) + if err != nil { + return newError("failed to find the interface").Base(err) + } + isV4 := (network == "tcp4") + if isV4 { + var bytes [4]byte + binary.BigEndian.PutUint32(bytes[:], uint32(inf.Index)) + idx := *(*uint32)(unsafe.Pointer(&bytes[0])) + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, IP_UNICAST_IF, int(idx)); err != nil { + return newError("failed to set IP_UNICAST_IF").Base(err) + } + } else { + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_UNICAST_IF, inf.Index); err != nil { + return newError("failed to set IPV6_UNICAST_IF").Base(err) + } + } + } + if isTCPSocket(network) { if err := setTFO(syscall.Handle(fd), config.ParseTFOValue()); err != nil { return err From d60281d0a58643fb024cdb566b8b01c031a13a0a Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 17 Dec 2023 13:09:04 -0500 Subject: [PATCH 220/867] Add DestIpAddress() in Dialer interface Android client prepares an IP before proxy connection is established. It is useful when connecting to wireguard (or quic) outbound with domain address. E.g. engage.cloudflareclient.com:2408 --- app/proxyman/outbound/handler.go | 4 ++ proxy/wireguard/client.go | 73 +++++++++++++++++++++++++++-- transport/internet/dialer.go | 8 ++++ transport/internet/system_dialer.go | 9 ++++ 4 files changed, 91 insertions(+), 3 deletions(-) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index d290b016..2df2b2c3 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -229,6 +229,10 @@ func (h *Handler) Address() net.Address { return h.senderSettings.Via.AsAddress() } +func (h *Handler) DestIpAddress() net.IP { + return internet.DestIpAddress() +} + // Dial implements internet.Dialer. func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connection, error) { if h.senderSettings != nil { diff --git a/proxy/wireguard/client.go b/proxy/wireguard/client.go index def07878..2560c538 100644 --- a/proxy/wireguard/client.go +++ b/proxy/wireguard/client.go @@ -22,7 +22,9 @@ package wireguard import ( "context" + "fmt" "net/netip" + "strings" "sync" "github.com/xtls/xray-core/common" @@ -49,7 +51,6 @@ type Handler struct { policyManager policy.Manager dns dns.Client // cached configuration - ipc string endpoints []netip.Addr hasIPv4, hasIPv6 bool wgLock sync.Mutex @@ -69,7 +70,6 @@ func New(ctx context.Context, conf *DeviceConfig) (*Handler, error) { conf: conf, policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), dns: d, - ipc: createIPCRequest(conf), endpoints: endpoints, hasIPv4: hasIPv4, hasIPv6: hasIPv6, @@ -247,9 +247,76 @@ func (h *Handler) makeVirtualTun(bind *netBindClient) (Tunnel, error) { bind.dnsOption.IPv4Enable = h.hasIPv4 bind.dnsOption.IPv6Enable = h.hasIPv6 - if err = t.BuildDevice(h.ipc, bind); err != nil { + if err = t.BuildDevice(h.createIPCRequest(bind, h.conf), bind); err != nil { _ = t.Close() return nil, err } return t, nil } + + +// serialize the config into an IPC request +func (h *Handler) createIPCRequest(bind *netBindClient, conf *DeviceConfig) string { + var request strings.Builder + + request.WriteString(fmt.Sprintf("private_key=%s\n", conf.SecretKey)) + + if !conf.IsClient { + // placeholder, we'll handle actual port listening on Xray + request.WriteString("listen_port=1337\n") + } + + for _, peer := range conf.Peers { + if peer.PublicKey != "" { + request.WriteString(fmt.Sprintf("public_key=%s\n", peer.PublicKey)) + } + + if peer.PreSharedKey != "" { + request.WriteString(fmt.Sprintf("preshared_key=%s\n", peer.PreSharedKey)) + } + + split := strings.Split(peer.Endpoint, ":") + addr := net.ParseAddress(split[0]) + if addr.Family().IsDomain() { + dialerIp := bind.dialer.DestIpAddress() + if dialerIp != nil { + addr = net.ParseAddress(dialerIp.String()) + newError("createIPCRequest use dialer dest ip: ", addr).WriteToLog() + } else { + ips, err := h.dns.LookupIP(addr.Domain(), dns.IPOption{ + IPv4Enable: h.hasIPv4 && h.conf.preferIP4(), + IPv6Enable: h.hasIPv6 && h.conf.preferIP6(), + }) + { // Resolve fallback + if (len(ips) == 0 || err != nil) && h.conf.hasFallback() { + ips, err = h.dns.LookupIP(addr.Domain(), dns.IPOption{ + IPv4Enable: h.hasIPv4 && h.conf.fallbackIP4(), + IPv6Enable: h.hasIPv6 && h.conf.fallbackIP6(), + }) + } + } + if err != nil { + newError("createIPCRequest failed to lookup DNS").Base(err).WriteToLog() + } else if len(ips) == 0 { + newError("createIPCRequest empty lookup DNS").WriteToLog() + } else { + addr = net.IPAddress(ips[dice.Roll(len(ips))]) + } + } + } + + if peer.Endpoint != "" { + request.WriteString(fmt.Sprintf("endpoint=%s:%s\n", addr, split[1])) + } + + for _, ip := range peer.AllowedIps { + request.WriteString(fmt.Sprintf("allowed_ip=%s\n", ip)) + } + + if peer.KeepAlive != 0 { + request.WriteString(fmt.Sprintf("persistent_keepalive_interval=%d\n", peer.KeepAlive)) + } + } + + return request.String()[:request.Len()] +} diff --git a/transport/internet/dialer.go b/transport/internet/dialer.go index deae4df0..3d5d046f 100644 --- a/transport/internet/dialer.go +++ b/transport/internet/dialer.go @@ -22,6 +22,9 @@ type Dialer interface { // Address returns the address used by this Dialer. Maybe nil if not known. Address() net.Address + + // DestIpAddress returns the ip of proxy server. It is useful in case of Android client, which prepare an IP before proxy connection is established + DestIpAddress() net.IP } // dialFunc is an interface to dial network connection to a specific destination. @@ -68,6 +71,11 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *MemoryStrea return nil, newError("unknown network ", dest.Network) } +// DestIpAddress returns the ip of proxy server. It is useful in case of Android client, which prepare an IP before proxy connection is established +func DestIpAddress() net.IP { + return effectiveSystemDialer.DestIpAddress() +} + var ( dnsClient dns.Client obm outbound.Manager diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index 5304595f..cdb6cb9c 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -16,6 +16,7 @@ var effectiveSystemDialer SystemDialer = &DefaultSystemDialer{} type SystemDialer interface { Dial(ctx context.Context, source net.Address, destination net.Destination, sockopt *SocketConfig) (net.Conn, error) + DestIpAddress() net.IP } type DefaultSystemDialer struct { @@ -108,6 +109,10 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne return dialer.DialContext(ctx, dest.Network.SystemString(), dest.NetAddr()) } +func (d *DefaultSystemDialer) DestIpAddress() net.IP { + return nil +} + type PacketConnWrapper struct { Conn net.PacketConn Dest net.Addr @@ -172,6 +177,10 @@ func (v *SimpleSystemDialer) Dial(ctx context.Context, src net.Address, dest net return v.adapter.Dial(dest.Network.SystemString(), dest.NetAddr()) } +func (d *SimpleSystemDialer) DestIpAddress() net.IP { + return nil +} + // UseAlternativeSystemDialer replaces the current system dialer with a given one. // Caller must ensure there is no race condition. // From e03b78dcec4468ea7b559b2084f857d22f8daca2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 00:23:05 +0000 Subject: [PATCH 221/867] Bump github.com/refraction-networking/utls from 1.5.4 to 1.6.0 Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.5.4 to 1.6.0. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.5.4...v1.6.0) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 3 +-- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 3a8f1649..fff59a1b 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.40.1 - github.com/refraction-networking/utls v1.5.4 + github.com/refraction-networking/utls v1.6.0 github.com/sagernet/sing v0.3.0-beta.2 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb @@ -38,7 +38,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect github.com/francoispqt/gojay v1.2.13 // indirect - github.com/gaukas/godicttls v0.0.4 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/btree v1.1.2 // indirect diff --git a/go.sum b/go.sum index a4920441..710ab59c 100644 --- a/go.sum +++ b/go.sum @@ -29,8 +29,6 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/gaukas/godicttls v0.0.4 h1:NlRaXb3J6hAnTmWdsEKb9bcSBD6BvcIjdGdeb0zfXbk= -github.com/gaukas/godicttls v0.0.4/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3A65HN+7CMjSDP/gofXL4CZt1V4= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= @@ -120,8 +118,8 @@ github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5 github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.40.1 h1:X3AGzUNFs0jVuO3esAGnTfvdgvL4fq655WaOi1snv1Q= github.com/quic-go/quic-go v0.40.1/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c= -github.com/refraction-networking/utls v1.5.4 h1:9k6EO2b8TaOGsQ7Pl7p9w6PUhx18/ZCeT0WNTZ7Uw4o= -github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw= +github.com/refraction-networking/utls v1.6.0 h1:X5vQMqVx7dY7ehxxqkFER/W6DSjy8TMqSItXm8hRDYQ= +github.com/refraction-networking/utls v1.6.0/go.mod h1:kHJ6R9DFFA0WsRgBM35iiDku4O7AqPR6y79iuzW7b10= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= From 5e19c1a77842130c8efd46781301e19f0e2fecfc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Dec 2023 00:17:49 +0000 Subject: [PATCH 222/867] Bump google.golang.org/grpc from 1.60.0 to 1.60.1 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.60.0 to 1.60.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.60.0...v1.60.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fff59a1b..214aacf7 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/sync v0.5.0 golang.org/x/sys v0.15.0 golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb - google.golang.org/grpc v1.60.0 + google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.31.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 710ab59c..42268bc5 100644 --- a/go.sum +++ b/go.sum @@ -278,8 +278,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k= -google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= +google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= From f51bf98714724cad273f853c8102f6bce64fd20f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Dec 2023 00:17:38 +0000 Subject: [PATCH 223/867] Bump golang.org/x/crypto from 0.16.0 to 0.17.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.16.0 to 0.17.0. - [Commits](https://github.com/golang/crypto/compare/v0.16.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 214aacf7..b2d787af 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20230824141953-6213f710f925 - golang.org/x/crypto v0.16.0 + golang.org/x/crypto v0.17.0 golang.org/x/net v0.19.0 golang.org/x/sync v0.5.0 golang.org/x/sys v0.15.0 diff --git a/go.sum b/go.sum index 42268bc5..b1fa4a9c 100644 --- a/go.sum +++ b/go.sum @@ -182,8 +182,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= From 9becf02316472a186d99e507ce65345f19c8d71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 22 Dec 2023 18:27:03 +0800 Subject: [PATCH 224/867] allow empty route type default field --- infra/conf/router.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infra/conf/router.go b/infra/conf/router.go index a9f57cd6..79176fa5 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -636,7 +636,7 @@ func ParseRule(msg json.RawMessage) (*router.RoutingRule, error) { if err != nil { return nil, newError("invalid router rule").Base(err) } - if strings.EqualFold(rawRule.Type, "field") { + if rawRule.Type == "" || strings.EqualFold(rawRule.Type, "field") { fieldrule, err := parseFieldRule(msg) if err != nil { return nil, newError("invalid field rule").Base(err) From 01c14a599450ffd576cced599098c895d5790c2d Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Sun, 24 Dec 2023 23:29:10 +0300 Subject: [PATCH 225/867] add Round-Robin Strategy to balancer (#2844) * add Round-Robin Strategy * clean up --- app/router/balancing.go | 34 ++++++++++++++++++++++++++++++++++ app/router/config.go | 6 ++++++ infra/conf/router.go | 2 ++ infra/conf/router_strategy.go | 5 +++-- 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/app/router/balancing.go b/app/router/balancing.go index 50b84388..ad0a3b36 100644 --- a/app/router/balancing.go +++ b/app/router/balancing.go @@ -2,6 +2,7 @@ package router import ( "context" + sync "sync" "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/features/extension" @@ -23,6 +24,39 @@ func (s *RandomStrategy) PickOutbound(tags []string) string { return tags[dice.Roll(n)] } +type RoundRobinStrategy struct { + mu sync.Mutex + tags []string + index int + roundRobin *RoundRobinStrategy +} + +func NewRoundRobin(tags []string) *RoundRobinStrategy { + return &RoundRobinStrategy{ + tags: tags, + } +} +func (r *RoundRobinStrategy) NextTag() string { + r.mu.Lock() + defer r.mu.Unlock() + + tags := r.tags[r.index] + r.index = (r.index + 1) % len(r.tags) + return tags +} + +func (s *RoundRobinStrategy) PickOutbound(tags []string) string { + if len(tags) == 0 { + panic("0 tags") + } + if s.roundRobin == nil { + s.roundRobin = NewRoundRobin(tags) + } + tag := s.roundRobin.NextTag() + + return tag +} + type Balancer struct { selectors []string strategy BalancingStrategy diff --git a/app/router/config.go b/app/router/config.go index f50f02a1..5dc32fa8 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -129,6 +129,12 @@ func (br *BalancingRule) Build(ohm outbound.Manager) (*Balancer, error) { strategy: &LeastPingStrategy{}, ohm: ohm, }, nil + case "roundRobin": + return &Balancer{ + selectors: br.OutboundSelector, + strategy: &RoundRobinStrategy{}, + ohm: ohm, + }, nil case "random": fallthrough default: diff --git a/infra/conf/router.go b/infra/conf/router.go index 79176fa5..a3285e85 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -43,6 +43,8 @@ func (r *BalancingRule) Build() (*router.BalancingRule, error) { strategy = strategyRandom case strategyLeastPing: strategy = "leastPing" + case strategyRoundRobin: + strategy = "roundRobin" default: return nil, newError("unknown balancing strategy: " + r.Strategy.Type) } diff --git a/infra/conf/router_strategy.go b/infra/conf/router_strategy.go index b8536330..ef2abc26 100644 --- a/infra/conf/router_strategy.go +++ b/infra/conf/router_strategy.go @@ -1,6 +1,7 @@ package conf const ( - strategyRandom string = "random" - strategyLeastPing string = "leastping" + strategyRandom string = "random" + strategyLeastPing string = "leastping" + strategyRoundRobin string = "roundrobin" ) From b7f21be8bcaaeb1d608f7b96d4ae62182896c094 Mon Sep 17 00:00:00 2001 From: hossinasaadi Date: Sat, 23 Dec 2023 11:38:43 +0400 Subject: [PATCH 226/867] fix ecdh crash in reality --- transport/internet/reality/reality.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index de8a6ac6..75a668c9 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -136,7 +136,10 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati if config.Show { newError(fmt.Sprintf("REALITY localAddr: %v\thello.SessionId[:16]: %v\n", localAddr, hello.SessionId[:16])).WriteToLog(session.ExportIDToError(ctx)) } - publicKey, _ := ecdh.X25519().NewPublicKey(config.PublicKey) + publicKey, err := ecdh.X25519().NewPublicKey(config.PublicKey) + if err != nil { + return nil, errors.New("REALITY: publicKey == nil") + } uConn.AuthKey, _ = uConn.HandshakeState.State13.EcdheKey.ECDH(publicKey) if uConn.AuthKey == nil { return nil, errors.New("REALITY: SharedKey == nil") From b0bf0d7fd5e4942b063fd8f9d2080944189c803f Mon Sep 17 00:00:00 2001 From: Allo Date: Fri, 22 Dec 2023 17:42:04 +0800 Subject: [PATCH 227/867] fix(conf): add Windows support for Unix Domain Socket --- infra/conf/xray.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 0935b1b0..10944826 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "os" + "path/filepath" "strings" "github.com/xtls/xray-core/app/dispatcher" @@ -188,7 +189,7 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) { } else { // Listen on specific IP or Unix Domain Socket receiverSettings.Listen = c.ListenOn.Build() - listenDS := c.ListenOn.Family().IsDomain() && (c.ListenOn.Domain()[0] == '/' || c.ListenOn.Domain()[0] == '@') + listenDS := c.ListenOn.Family().IsDomain() && (filepath.IsAbs(c.ListenOn.Domain()) || c.ListenOn.Domain()[0] == '@') listenIP := c.ListenOn.Family().IsIP() || (c.ListenOn.Family().IsDomain() && c.ListenOn.Domain() == "localhost") if listenIP { // Listen on specific IP, must set PortList From eacdda3c93184043a98aa1841947ad4d4f6f7c61 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 24 Dec 2023 21:07:56 -0500 Subject: [PATCH 228/867] Fix connecting to quic outbound with domain address --- transport/internet/quic/dialer.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/transport/internet/quic/dialer.go b/transport/internet/quic/dialer.go index c6bc08aa..7c8122b6 100644 --- a/transport/internet/quic/dialer.go +++ b/transport/internet/quic/dialer.go @@ -208,12 +208,21 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me IP: dest.Address.IP(), Port: int(dest.Port), } - } else { - addr, err := net.ResolveUDPAddr("udp", dest.NetAddr()) - if err != nil { - return nil, err + } else { + dialerIp := internet.DestIpAddress() + if dialerIp != nil { + destAddr = &net.UDPAddr{ + IP: dialerIp, + Port: int(dest.Port), + } + newError("quic Dial use dialer dest addr: ", destAddr).WriteToLog() + } else { + addr, err := net.ResolveUDPAddr("udp", dest.NetAddr()) + if err != nil { + return nil, err + } + destAddr = addr } - destAddr = addr } config := streamSettings.ProtocolSettings.(*Config) From 1dc9a720689f5748ef944a6004d52770c76b2034 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Dec 2023 00:49:24 +0000 Subject: [PATCH 229/867] Bump google.golang.org/protobuf from 1.31.0 to 1.32.0 Bumps google.golang.org/protobuf from 1.31.0 to 1.32.0. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b2d787af..09a5a803 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( golang.org/x/sys v0.15.0 golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb google.golang.org/grpc v1.60.1 - google.golang.org/protobuf v1.31.0 + google.golang.org/protobuf v1.32.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 lukechampine.com/blake3 v1.2.1 diff --git a/go.sum b/go.sum index b1fa4a9c..d02298e3 100644 --- a/go.sum +++ b/go.sum @@ -282,8 +282,8 @@ google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 1dba70004fcea75fc3cf057d81081219e362a775 Mon Sep 17 00:00:00 2001 From: R8s6 <44877866+R8s6@users.noreply.github.com> Date: Wed, 27 Dec 2023 17:15:53 -0800 Subject: [PATCH 230/867] Update README.md Adding official docker repo. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 158487bf..001654dc 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ - Linux Script - [XTLS/Xray-install](https://github.com/XTLS/Xray-install) - Docker + - Official: [ghcr.io/xtls/xray-core](https://ghcr.io/xtls/xray-core) - [iamybj/docker-xray](https://hub.docker.com/r/iamybj/docker-xray) - [teddysun/xray](https://hub.docker.com/r/teddysun/xray) - Web Panel From 006cf491e57c0e66bee1814251ecd293aaf9033f Mon Sep 17 00:00:00 2001 From: Allo Date: Wed, 27 Dec 2023 12:19:52 +0800 Subject: [PATCH 231/867] fix(conf): add Windows support for Unix Domain Socket in the fallback settings --- infra/conf/trojan.go | 29 ++++++++++++++--------------- infra/conf/vless.go | 29 ++++++++++++++--------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/infra/conf/trojan.go b/infra/conf/trojan.go index 2cd1e520..6bc2385f 100644 --- a/infra/conf/trojan.go +++ b/infra/conf/trojan.go @@ -2,8 +2,10 @@ package conf import ( "encoding/json" + "path/filepath" "runtime" "strconv" + "strings" "syscall" "github.com/xtls/xray-core/common/net" @@ -147,22 +149,19 @@ func (c *TrojanServerConfig) Build() (proto.Message, error) { if fb.Type == "" && fb.Dest != "" { if fb.Dest == "serve-ws-none" { fb.Type = "serve" + } else if filepath.IsAbs(fb.Dest) || fb.Dest[0] == '@' { + fb.Type = "unix" + if strings.HasPrefix(fb.Dest, "@@") && (runtime.GOOS == "linux" || runtime.GOOS == "android") { + fullAddr := make([]byte, len(syscall.RawSockaddrUnix{}.Path)) // may need padding to work with haproxy + copy(fullAddr, fb.Dest[1:]) + fb.Dest = string(fullAddr) + } } else { - switch fb.Dest[0] { - case '@', '/': - fb.Type = "unix" - if fb.Dest[0] == '@' && len(fb.Dest) > 1 && fb.Dest[1] == '@' && (runtime.GOOS == "linux" || runtime.GOOS == "android") { - fullAddr := make([]byte, len(syscall.RawSockaddrUnix{}.Path)) // may need padding to work with haproxy - copy(fullAddr, fb.Dest[1:]) - fb.Dest = string(fullAddr) - } - default: - if _, err := strconv.Atoi(fb.Dest); err == nil { - fb.Dest = "127.0.0.1:" + fb.Dest - } - if _, _, err := net.SplitHostPort(fb.Dest); err == nil { - fb.Type = "tcp" - } + if _, err := strconv.Atoi(fb.Dest); err == nil { + fb.Dest = "127.0.0.1:" + fb.Dest + } + if _, _, err := net.SplitHostPort(fb.Dest); err == nil { + fb.Type = "tcp" } } } diff --git a/infra/conf/vless.go b/infra/conf/vless.go index 2e5c5d64..9d293555 100644 --- a/infra/conf/vless.go +++ b/infra/conf/vless.go @@ -2,8 +2,10 @@ package conf import ( "encoding/json" + "path/filepath" "runtime" "strconv" + "strings" "syscall" "github.com/xtls/xray-core/common/net" @@ -103,22 +105,19 @@ func (c *VLessInboundConfig) Build() (proto.Message, error) { if fb.Type == "" && fb.Dest != "" { if fb.Dest == "serve-ws-none" { fb.Type = "serve" + } else if filepath.IsAbs(fb.Dest) || fb.Dest[0] == '@' { + fb.Type = "unix" + if strings.HasPrefix(fb.Dest, "@@") && (runtime.GOOS == "linux" || runtime.GOOS == "android") { + fullAddr := make([]byte, len(syscall.RawSockaddrUnix{}.Path)) // may need padding to work with haproxy + copy(fullAddr, fb.Dest[1:]) + fb.Dest = string(fullAddr) + } } else { - switch fb.Dest[0] { - case '@', '/': - fb.Type = "unix" - if fb.Dest[0] == '@' && len(fb.Dest) > 1 && fb.Dest[1] == '@' && (runtime.GOOS == "linux" || runtime.GOOS == "android") { - fullAddr := make([]byte, len(syscall.RawSockaddrUnix{}.Path)) // may need padding to work with haproxy - copy(fullAddr, fb.Dest[1:]) - fb.Dest = string(fullAddr) - } - default: - if _, err := strconv.Atoi(fb.Dest); err == nil { - fb.Dest = "127.0.0.1:" + fb.Dest - } - if _, _, err := net.SplitHostPort(fb.Dest); err == nil { - fb.Type = "tcp" - } + if _, err := strconv.Atoi(fb.Dest); err == nil { + fb.Dest = "127.0.0.1:" + fb.Dest + } + if _, _, err := net.SplitHostPort(fb.Dest); err == nil { + fb.Type = "tcp" } } } From 44bb83033f238675b2e94024edf001e3720ae53f Mon Sep 17 00:00:00 2001 From: nobody <59990325+vrnobody@users.noreply.github.com> Date: Sat, 30 Dec 2023 00:16:48 +0800 Subject: [PATCH 232/867] Add sub-command "-dump" to "run". (#2854) * Add MarshalToJson(). * Add cmd arg -dump for printing out merged multiple json configs. --------- Co-authored-by: nobody --- common/log/logger.go | 32 ++++++ common/reflect/marshal.go | 173 ++++++++++++++++++++++++++++++ common/reflect/marshal_test.go | 187 +++++++++++++++++++++++++++++++++ core/config.go | 19 ++++ infra/conf/serial/builder.go | 26 ++++- main/run.go | 49 +++++++-- 6 files changed, 476 insertions(+), 10 deletions(-) create mode 100644 common/reflect/marshal.go create mode 100644 common/reflect/marshal_test.go diff --git a/common/log/logger.go b/common/log/logger.go index 79507964..d964a212 100644 --- a/common/log/logger.go +++ b/common/log/logger.go @@ -27,6 +27,11 @@ type generalLogger struct { done *done.Instance } +type serverityLogger struct { + inner *generalLogger + logLevel Severity +} + // NewLogger returns a generic log handler that can handle all type of messages. func NewLogger(logWriterCreator WriterCreator) Handler { return &generalLogger{ @@ -37,6 +42,32 @@ func NewLogger(logWriterCreator WriterCreator) Handler { } } +func ReplaceWithSeverityLogger(serverity Severity) { + w := CreateStdoutLogWriter() + g := &generalLogger{ + creator: w, + buffer: make(chan Message, 16), + access: semaphore.New(1), + done: done.New(), + } + s := &serverityLogger{ + inner: g, + logLevel: serverity, + } + RegisterHandler(s) +} + +func (l *serverityLogger) Handle(msg Message) { + switch msg := msg.(type) { + case *GeneralMessage: + if msg.Severity <= l.logLevel { + l.inner.Handle(msg) + } + default: + l.inner.Handle(msg) + } +} + func (l *generalLogger) run() { defer l.access.Signal() @@ -67,6 +98,7 @@ func (l *generalLogger) run() { } func (l *generalLogger) Handle(msg Message) { + select { case l.buffer <- msg: default: diff --git a/common/reflect/marshal.go b/common/reflect/marshal.go new file mode 100644 index 00000000..96e83351 --- /dev/null +++ b/common/reflect/marshal.go @@ -0,0 +1,173 @@ +package reflect + +import ( + "encoding/json" + "reflect" + "slices" + + cserial "github.com/xtls/xray-core/common/serial" +) + +func MarshalToJson(v interface{}) (string, bool) { + if itf := marshalInterface(v, true); itf != nil { + if b, err := json.MarshalIndent(itf, "", " "); err == nil { + return string(b[:]), true + } + } + return "", false +} + +func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool) interface{} { + tmsg, err := v.GetInstance() + if err != nil { + return nil + } + r := marshalInterface(tmsg, ignoreNullValue) + if msg, ok := r.(map[string]interface{}); ok { + msg["_TypedMessage_"] = v.Type + } + return r +} + +func marshalSlice(v reflect.Value, ignoreNullValue bool) interface{} { + r := make([]interface{}, 0) + for i := 0; i < v.Len(); i++ { + rv := v.Index(i) + if rv.CanInterface() { + value := rv.Interface() + r = append(r, marshalInterface(value, ignoreNullValue)) + } + } + return r +} + +func marshalStruct(v reflect.Value, ignoreNullValue bool) interface{} { + r := make(map[string]interface{}) + t := v.Type() + for i := 0; i < v.NumField(); i++ { + rv := v.Field(i) + if rv.CanInterface() { + ft := t.Field(i) + name := ft.Name + value := rv.Interface() + tv := marshalInterface(value, ignoreNullValue) + if tv != nil || !ignoreNullValue { + r[name] = tv + } + } + } + return r +} + +func marshalMap(v reflect.Value, ignoreNullValue bool) interface{} { + // policy.level is map[uint32] *struct + kt := v.Type().Key() + vt := reflect.TypeOf((*interface{})(nil)) + mt := reflect.MapOf(kt, vt) + r := reflect.MakeMap(mt) + for _, key := range v.MapKeys() { + rv := v.MapIndex(key) + if rv.CanInterface() { + iv := rv.Interface() + tv := marshalInterface(iv, ignoreNullValue) + if tv != nil || !ignoreNullValue { + r.SetMapIndex(key, reflect.ValueOf(&tv)) + } + } + } + return r.Interface() +} + +func marshalIString(v interface{}) (r string, ok bool) { + defer func() { + if err := recover(); err != nil { + r = "" + ok = false + } + }() + + if iStringFn, ok := v.(interface{ String() string }); ok { + return iStringFn.String(), true + } + return "", false +} + +func marshalKnownType(v interface{}, ignoreNullValue bool) (interface{}, bool) { + switch ty := v.(type) { + case cserial.TypedMessage: + return marshalTypedMessage(&ty, ignoreNullValue), true + case *cserial.TypedMessage: + return marshalTypedMessage(ty, ignoreNullValue), true + case map[string]json.RawMessage: + return ty, true + case []json.RawMessage: + return ty, true + case *json.RawMessage: + return ty, true + case json.RawMessage: + return ty, true + default: + return nil, false + } +} + +var valueKinds = []reflect.Kind{ + reflect.Bool, + reflect.Int, + reflect.Int8, + reflect.Int16, + reflect.Int32, + reflect.Int64, + reflect.Uint, + reflect.Uint8, + reflect.Uint16, + reflect.Uint32, + reflect.Uint64, + reflect.Uintptr, + reflect.Float32, + reflect.Float64, + reflect.Complex64, + reflect.Complex128, + reflect.String, +} + +func isValueKind(kind reflect.Kind) bool { + return slices.Contains(valueKinds, kind) +} + +func marshalInterface(v interface{}, ignoreNullValue bool) interface{} { + + if r, ok := marshalKnownType(v, ignoreNullValue); ok { + return r + } + + rv := reflect.ValueOf(v) + if rv.Kind() == reflect.Ptr { + rv = rv.Elem() + } + k := rv.Kind() + if k == reflect.Invalid { + return nil + } + if isValueKind(k) { + return v + } + + switch k { + case reflect.Struct: + return marshalStruct(rv, ignoreNullValue) + case reflect.Slice: + return marshalSlice(rv, ignoreNullValue) + case reflect.Array: + return marshalSlice(rv, ignoreNullValue) + case reflect.Map: + return marshalMap(rv, ignoreNullValue) + default: + break + } + + if str, ok := marshalIString(v); ok { + return str + } + return nil +} diff --git a/common/reflect/marshal_test.go b/common/reflect/marshal_test.go new file mode 100644 index 00000000..377ad4e9 --- /dev/null +++ b/common/reflect/marshal_test.go @@ -0,0 +1,187 @@ +package reflect_test + +import ( + "bytes" + "encoding/json" + "strings" + "testing" + + . "github.com/xtls/xray-core/common/reflect" + cserial "github.com/xtls/xray-core/common/serial" + iserial "github.com/xtls/xray-core/infra/conf/serial" +) + +func TestMashalStruct(t *testing.T) { + type Foo = struct { + N int `json:"n"` + Np *int `json:"np"` + S string `json:"s"` + Arr *[]map[string]map[string]string `json:"arr"` + } + + n := 1 + np := &n + arr := make([]map[string]map[string]string, 0) + m1 := make(map[string]map[string]string, 0) + m2 := make(map[string]string, 0) + m2["hello"] = "world" + m1["foo"] = m2 + + arr = append(arr, m1) + + f1 := Foo{ + N: n, + Np: np, + S: "hello", + Arr: &arr, + } + + s, ok1 := MarshalToJson(f1) + sp, ok2 := MarshalToJson(&f1) + + if !ok1 || !ok2 || s != sp { + t.Error("marshal failed") + } + + f2 := Foo{} + if json.Unmarshal([]byte(s), &f2) != nil { + t.Error("json unmarshal failed") + } + + v := (*f2.Arr)[0]["foo"]["hello"] + + if f1.N != f2.N || *(f1.Np) != *(f2.Np) || f1.S != f2.S || v != "world" { + t.Error("f1 not equal to f2") + } +} + +func TestMarshalConfigJson(t *testing.T) { + + buf := bytes.NewBufferString(getConfig()) + config, err := iserial.DecodeJSONConfig(buf) + if err != nil { + t.Error("decode JSON config failed") + } + + bc, err := config.Build() + if err != nil { + t.Error("build core config failed") + } + + tmsg := cserial.ToTypedMessage(bc) + tc, ok := MarshalToJson(tmsg) + if !ok { + t.Error("marshal config failed") + } + + // t.Log(tc) + + keywords := []string{ + "4784f9b8-a879-4fec-9718-ebddefa47750", + "bing.com", + "DomainStrategy", + "InboundTag", + "Level", + "Stats", + "UserDownlink", + "UserUplink", + "System", + "InboundDownlink", + "OutboundUplink", + } + for _, kw := range keywords { + if !strings.Contains(tc, kw) { + t.Error("marshaled config error") + } + } +} + +func getConfig() string { + return `{ + "log": { + "loglevel": "debug" + }, + "stats": {}, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true, + "statsOutboundUplink": true, + "statsOutboundDownlink": true + } + }, + "inbounds": [ + { + "tag": "agentin", + "protocol": "http", + "port": 8080, + "listen": "127.0.0.1", + "settings": {} + }, + { + "listen": "127.0.0.1", + "port": 10085, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api-in" + } + ], + "api": { + "tag": "api", + "services": [ + "HandlerService", + "StatsService" + ] + }, + "routing": { + "rules": [ + { + "inboundTag": [ + "api-in" + ], + "outboundTag": "api", + "type": "field" + } + ], + "domainStrategy": "AsIs" + }, + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "1.2.3.4", + "port": 1234, + "users": [ + { + "id": "4784f9b8-a879-4fec-9718-ebddefa47750", + "encryption": "none" + } + ] + } + ] + }, + "tag": "agentout", + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/?ed=2048", + "headers": { + "Host": "bing.com" + } + } + } + } + ] + }` +} diff --git a/core/config.go b/core/config.go index f4077449..ec5ad6a4 100644 --- a/core/config.go +++ b/core/config.go @@ -2,6 +2,7 @@ package core import ( "io" + "slices" "strings" "github.com/xtls/xray-core/common" @@ -24,10 +25,14 @@ type ConfigLoader func(input interface{}) (*Config, error) // ConfigBuilder is a builder to build core.Config from filenames and formats type ConfigBuilder func(files []string, formats []string) (*Config, error) +// ConfigMerger merge multiple json configs into on config +type ConfigsMerger func(files []string, formats []string) (string, error) + var ( configLoaderByName = make(map[string]*ConfigFormat) configLoaderByExt = make(map[string]*ConfigFormat) ConfigBuilderForFiles ConfigBuilder + ConfigMergedFormFiles ConfigsMerger ) // RegisterConfigLoader add a new ConfigLoader. @@ -49,6 +54,20 @@ func RegisterConfigLoader(format *ConfigFormat) error { return nil } +func GetMergedConfig(args cmdarg.Arg) (string, error) { + files := make([]string, 0) + formats := make([]string, 0) + supported := []string{"json", "yaml", "toml"} + for _, file := range args { + format := getFormat(file) + if slices.Contains(supported, format) { + files = append(files, file) + formats = append(formats, format) + } + } + return ConfigMergedFormFiles(files, formats) +} + func GetFormatByExtension(ext string) string { switch strings.ToLower(ext) { case "pb", "protobuf": diff --git a/infra/conf/serial/builder.go b/infra/conf/serial/builder.go index 443dbdb0..88ea9e65 100644 --- a/infra/conf/serial/builder.go +++ b/infra/conf/serial/builder.go @@ -3,12 +3,25 @@ package serial import ( "io" + creflect "github.com/xtls/xray-core/common/reflect" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/infra/conf" "github.com/xtls/xray-core/main/confloader" ) -func BuildConfig(files []string, formats []string) (*core.Config, error) { +func MergeConfigFromFiles(files []string, formats []string) (string, error) { + c, err := mergeConfigs(files, formats) + if err != nil { + return "", err + } + + if j, ok := creflect.MarshalToJson(c); ok { + return j, nil + } + return "", newError("marshal to json failed.").AtError() +} + +func mergeConfigs(files []string, formats []string) (*conf.Config, error) { cf := &conf.Config{} for i, file := range files { newError("Reading config: ", file).AtInfo().WriteToLog() @@ -26,7 +39,15 @@ func BuildConfig(files []string, formats []string) (*core.Config, error) { } cf.Override(c, file) } - return cf.Build() + return cf, nil +} + +func BuildConfig(files []string, formats []string) (*core.Config, error) { + config, err := mergeConfigs(files, formats) + if err != nil { + return nil, err + } + return config.Build() } type readerDecoder func(io.Reader) (*conf.Config, error) @@ -39,4 +60,5 @@ func init() { ReaderDecoderByFormat["toml"] = DecodeTOMLConfig core.ConfigBuilderForFiles = BuildConfig + core.ConfigMergedFormFiles = MergeConfigFromFiles } diff --git a/main/run.go b/main/run.go index 1f8a4b88..f54d7480 100644 --- a/main/run.go +++ b/main/run.go @@ -12,8 +12,10 @@ import ( "runtime/debug" "strings" "syscall" + "time" "github.com/xtls/xray-core/common/cmdarg" + clog "github.com/xtls/xray-core/common/log" "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/main/commands/base" @@ -34,7 +36,9 @@ The -format=json flag sets the format of config files. Default "auto". The -test flag tells Xray to test config files only, -without launching the server +without launching the server. + +The -dump flag tells Xray to print the merged config. `, } @@ -45,6 +49,7 @@ func init() { var ( configFiles cmdarg.Arg // "Config file for Xray.", the option is customed type, parse in main configDir string + dump = cmdRun.Flag.Bool("dump", false, "Dump merged config only, without launching Xray server.") test = cmdRun.Flag.Bool("test", false, "Test config file only, without launching Xray server.") format = cmdRun.Flag.String("format", "auto", "Format of input file.") @@ -61,6 +66,12 @@ var ( ) func executeRun(cmd *base.Command, args []string) { + if *dump { + clog.ReplaceWithSeverityLogger(clog.Severity_Warning) + errCode := dumpConfig() + os.Exit(errCode) + } + printVersion() server, err := startXray() if err != nil { @@ -97,6 +108,18 @@ func executeRun(cmd *base.Command, args []string) { } } +func dumpConfig() int { + files := getConfigFilePath(false) + if config, err := core.GetMergedConfig(files); err != nil { + fmt.Println(err) + time.Sleep(1 * time.Second) + return 23 + } else { + fmt.Print(config) + } + return 0 +} + func fileExists(file string) bool { info, err := os.Stat(file) return err == nil && !info.IsDir() @@ -139,12 +162,16 @@ func readConfDir(dirPath string) { } } -func getConfigFilePath() cmdarg.Arg { +func getConfigFilePath(verbose bool) cmdarg.Arg { if dirExists(configDir) { - log.Println("Using confdir from arg:", configDir) + if verbose { + log.Println("Using confdir from arg:", configDir) + } readConfDir(configDir) } else if envConfDir := platform.GetConfDirPath(); dirExists(envConfDir) { - log.Println("Using confdir from env:", envConfDir) + if verbose { + log.Println("Using confdir from env:", envConfDir) + } readConfDir(envConfDir) } @@ -155,17 +182,23 @@ func getConfigFilePath() cmdarg.Arg { if workingDir, err := os.Getwd(); err == nil { configFile := filepath.Join(workingDir, "config.json") if fileExists(configFile) { - log.Println("Using default config: ", configFile) + if verbose { + log.Println("Using default config: ", configFile) + } return cmdarg.Arg{configFile} } } if configFile := platform.GetConfigurationPath(); fileExists(configFile) { - log.Println("Using config from env: ", configFile) + if verbose { + log.Println("Using config from env: ", configFile) + } return cmdarg.Arg{configFile} } - log.Println("Using config from STDIN") + if verbose { + log.Println("Using config from STDIN") + } return cmdarg.Arg{"stdin:"} } @@ -178,7 +211,7 @@ func getConfigFormat() string { } func startXray() (core.Server, error) { - configFiles := getConfigFilePath() + configFiles := getConfigFilePath(true) // config, err := core.LoadConfig(getConfigFormat(), configFiles[0], configFiles) From 60f7a03e1b5e952f9d15f1a136bfabd24e80d9bd Mon Sep 17 00:00:00 2001 From: dop-bot <95738113+dop-bot@users.noreply.github.com> Date: Tue, 2 Jan 2024 12:03:36 +0800 Subject: [PATCH 233/867] fix(dns): avoid early return when dns query refused (#2878) * avoid early return when dns query refused * address reviews --- app/dns/dns.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/dns/dns.go b/app/dns/dns.go index 6efcb825..3b173677 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -215,7 +215,8 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, error) { newError("failed to lookup ip for domain ", domain, " at server ", client.Name()).Base(err).WriteToLog() errs = append(errs, err) } - if err != context.Canceled && err != context.DeadlineExceeded && err != errExpectedIPNonMatch && err != dns.ErrEmptyResponse { + // 5 for RcodeRefused in miekg/dns, hardcode to reduce binary size + if err != context.Canceled && err != context.DeadlineExceeded && err != errExpectedIPNonMatch && err != dns.ErrEmptyResponse && dns.RCodeFromError(err) != 5 { return nil, err } } From 7b4db50c9ddcb8bcfc41c1260ff97c47a4748451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=82=BB?= <123655015+chise0713@users.noreply.github.com> Date: Tue, 2 Jan 2024 23:13:38 +0800 Subject: [PATCH 234/867] Feat: Using `Makefile` to build xray (#2882) * Feat: Using `Makefile` to build xray * Typo --- .github/workflows/release.yml | 29 ++--------------------------- .gitignore | 2 ++ Makefile | 29 +++++++++++++++++++++++++++++ README.md | 10 +--------- 4 files changed, 34 insertions(+), 36 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e33b18b7..86335113 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -173,36 +173,11 @@ jobs: - name: Get project dependencies run: go mod download - - name: Replace Custom to Commit ID - if: github.event_name != 'release' - run: | - ID=$(git rev-parse --short ${{ github.sha }}) - if [ "${{ github.event_name }}" == 'pull_request' ] - then - ID=$(git rev-parse --short ${{ github.event.pull_request.head.sha }}) - fi - sed -i '/build/ s/Custom/'$ID'/' ./core/core.go - - name: Build Xray run: | mkdir -p build_assets - go build -v -o build_assets/xray -trimpath -ldflags "-s -w -buildid=" ./main - - - name: Build background Xray on Windows - if: matrix.goos == 'windows' - run: | - go build -v -o build_assets/wxray.exe -trimpath -ldflags "-s -w -H windowsgui -buildid=" ./main - - - name: Build Mips softfloat Xray - if: matrix.goarch == 'mips' || matrix.goarch == 'mipsle' - run: | - GOMIPS=softfloat go build -v -o build_assets/xray_softfloat -trimpath -ldflags "-s -w -buildid=" ./main - - - name: Rename Windows Xray - if: matrix.goos == 'windows' - run: | - cd ./build_assets || exit 1 - mv xray xray.exe + make + find . -maxdepth 1 -type f -regex '.*\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; - name: Restore Cache uses: actions/cache/restore@v3 diff --git a/.gitignore b/.gitignore index 9242f587..c77bc579 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ *.zip *.tar.gz xray +xray_softfloat mockgen vprotogen !infra/vprotogen/ @@ -26,3 +27,4 @@ errorgen !common/errors/errorgen/ *.dat .vscode +/build_assets diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..f69a9b2b --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +NAME = xray + +VERSION=$(shell git describe --always --dirty) + +LDFLAGS = -X github.com/xtls/xray-core/core.build=$(VERSION) -s -w -buildid= +PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v +MAIN = ./main +PREFIX ?= $(shell go env GOPATH) +ifeq ($(GOOS),windows) +OUTPUT = $(NAME).exe +ADDITION = go build -o w$(NAME).exe -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) +else +OUTPUT = $(NAME) +endif +ifeq ($(shell echo "$(GOARCH)" | grep -Pq "(mips|mipsle)" && echo true),true) # +ADDITION = GOMIPS=softfloat go build -o $(NAME)_softfloat -trimpath -ldflags "$(LDFLAGS)" -v $(MAIN) +endif +.PHONY: clean + +build: + go build -o $(OUTPUT) $(PARAMS) $(MAIN) + $(ADDITION) + +install: + go build -o $(PREFIX)/bin/$(OUTPUT) $(PARAMS) $(MAIN) + +clean: + go clean -v -i $(PWD) + rm -f xray xray.exe wxray.exe xray_softfloat \ No newline at end of file diff --git a/README.md b/README.md index 001654dc..df1537d8 100644 --- a/README.md +++ b/README.md @@ -125,16 +125,8 @@ ## Compilation -### Windows - ```bash -go build -o xray.exe -trimpath -ldflags "-s -w -buildid=" ./main -``` - -### Linux / macOS - -```bash -go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main +make ``` ## Stargazers over time From 2fc4b31fcf5fac9a1b1774d3605d218a18e91ce8 Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Tue, 2 Jan 2024 10:23:11 -0800 Subject: [PATCH 235/867] common/singbridge: fix dropped context --- common/singbridge/dialer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/singbridge/dialer.go b/common/singbridge/dialer.go index dfc128d8..896c97fe 100644 --- a/common/singbridge/dialer.go +++ b/common/singbridge/dialer.go @@ -43,7 +43,7 @@ func NewOutboundDialer(outbound proxy.Outbound, dialer internet.Dialer) *XrayOut } func (d *XrayOutboundDialer) DialContext(ctx context.Context, network string, destination M.Socksaddr) (net.Conn, error) { - ctx = session.ContextWithOutbound(context.Background(), &session.Outbound{ + ctx = session.ContextWithOutbound(ctx, &session.Outbound{ Target: ToDestination(destination, ToNetwork(network)), }) opts := []pipe.Option{pipe.WithSizeLimit(64 * 1024)} From 9a2ab9b6a3331de03d1ca0cd15c9a77d2b9f4c58 Mon Sep 17 00:00:00 2001 From: hossinasaadi Date: Sun, 7 Jan 2024 20:07:39 +0400 Subject: [PATCH 236/867] fix roundRobin --- app/router/balancing.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/router/balancing.go b/app/router/balancing.go index ad0a3b36..e6f29a67 100644 --- a/app/router/balancing.go +++ b/app/router/balancing.go @@ -2,6 +2,7 @@ package router import ( "context" + reflect "reflect" sync "sync" "github.com/xtls/xray-core/common/dice" @@ -49,7 +50,7 @@ func (s *RoundRobinStrategy) PickOutbound(tags []string) string { if len(tags) == 0 { panic("0 tags") } - if s.roundRobin == nil { + if s.roundRobin == nil || !reflect.DeepEqual(s.roundRobin.tags, tags) { s.roundRobin = NewRoundRobin(tags) } tag := s.roundRobin.NextTag() From 3f0bc134298cf512bd29660221a030db91594faf Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Tue, 2 Jan 2024 20:14:42 -0500 Subject: [PATCH 237/867] Update 1.8.7 and dependencies --- core/core.go | 2 +- go.mod | 30 +++++++++++++------------- go.sum | 59 ++++++++++++++++++++++++++-------------------------- 3 files changed, 46 insertions(+), 45 deletions(-) diff --git a/core/core.go b/core/core.go index d11fa273..09a591f2 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 6 + Version_z byte = 7 ) var ( diff --git a/go.mod b/go.mod index 09a5a803..e004d90b 100644 --- a/go.mod +++ b/go.mod @@ -12,19 +12,19 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.40.1 github.com/refraction-networking/utls v1.6.0 - github.com/sagernet/sing v0.3.0-beta.2 + github.com/sagernet/sing v0.3.0 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 - go4.org/netipx v0.0.0-20230824141953-6213f710f925 + go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.17.0 golang.org/x/net v0.19.0 - golang.org/x/sync v0.5.0 - golang.org/x/sys v0.15.0 - golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb + golang.org/x/sync v0.6.0 + golang.org/x/sys v0.16.0 + golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.32.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b @@ -34,29 +34,29 @@ require ( require ( github.com/andybalholm/brotli v1.0.6 // indirect - github.com/cloudflare/circl v1.3.6 // indirect + github.com/cloudflare/circl v1.3.7 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect github.com/francoispqt/gojay v1.2.13 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a // indirect - github.com/klauspost/compress v1.17.2 // indirect + github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 // indirect + github.com/klauspost/compress v1.17.4 // indirect github.com/klauspost/cpuid/v2 v2.2.6 // indirect - github.com/onsi/ginkgo/v2 v2.13.1 // indirect + github.com/onsi/ginkgo/v2 v2.13.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/quic-go/qtls-go1-20 v0.4.1 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect - github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae // indirect - go.uber.org/mock v0.3.0 // indirect - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect + github.com/vishvananda/netns v0.0.4 // indirect + go.uber.org/mock v0.4.0 // indirect + golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/time v0.4.0 // indirect - golang.org/x/tools v0.15.0 // indirect + golang.org/x/time v0.5.0 // indirect + golang.org/x/tools v0.16.1 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index d02298e3..3b1016bb 100644 --- a/go.sum +++ b/go.sum @@ -15,8 +15,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/circl v1.3.6 h1:/xbKIqSHbZXHwkhbrhrt2YOHIwYJlXH94E3tI/gDlUg= -github.com/cloudflare/circl v1.3.6/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -61,8 +61,8 @@ github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+u github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a h1:fEBsGL/sjAuJrgah5XqmmYsTLzJp/TO9Lhy39gkverk= -github.com/google/pprof v0.0.0-20231101202521-4ca4178f5c7a/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 h1:dHLYa5D8/Ta0aLR2XcPsrkpAgGeFs6thhMcQK0oQ0n8= +github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -76,8 +76,8 @@ github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= -github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= +github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -96,8 +96,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU= -github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM= +github.com/onsi/ginkgo/v2 v2.13.2 h1:Bi2gGVkfn6gQcjNjZJVO8Gf0FHzMPf2phUei9tejVMs= +github.com/onsi/ginkgo/v2 v2.13.2/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM= github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= @@ -123,8 +123,8 @@ github.com/refraction-networking/utls v1.6.0/go.mod h1:kHJ6R9DFFA0WsRgBM35iiDku4 github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.3.0-beta.2 h1:7wqgP+cMQeHS3M/64WWvJLeX07fLctBkE4+lguAFWeU= -github.com/sagernet/sing v0.3.0-beta.2/go.mod h1:9pfuAH6mZfgnz/YjP6xu5sxx882rfyjpcrTdUpd6w3g= +github.com/sagernet/sing v0.3.0 h1:PIDVFZHnQAAYRL1UYqNM+0k5s8f/tb1lUW6UDcQiOc8= +github.com/sagernet/sing v0.3.0/go.mod h1:9pfuAH6mZfgnz/YjP6xu5sxx882rfyjpcrTdUpd6w3g= github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= @@ -166,17 +166,18 @@ github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49u github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 h1:tkMT5pTye+1NlKIXETU78NXw0fyjnaNHmJyyLyzw8+U= github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3/go.mod h1:cAAsePK2e15YDAMJNyOpGYEWNe4sIghTY7gpz4cX/Ik= -github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae h1:4hwBBUfQCFe3Cym0ZtKyq7L16eZUtYKs+BaHDN6mAns= github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= +github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= +github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 h1:capMfFYRgH9BCLd6A3Er/cH3A9Nz3CU2KwxwOQZIePI= github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= -go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= -go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= +go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= +go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= -go4.org/netipx v0.0.0-20230824141953-6213f710f925 h1:eeQDDVKFkx0g4Hyy8pHgmZaK0EqB4SD6rvKbUdN3ziQ= -go4.org/netipx v0.0.0-20230824141953-6213f710f925/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= +go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= +go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -185,8 +186,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= +golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -217,8 +218,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -231,8 +232,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -241,8 +242,8 @@ golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.4.0 h1:Z81tqI5ddIoXDPvVQ7/7CC9TnLM7ubaFG2qXYd5BbYY= -golang.org/x/time v0.4.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -250,16 +251,16 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.15.0 h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8= -golang.org/x/tools v0.15.0/go.mod h1:hpksKq4dtpQWS1uQ61JkdqWM3LscIS6Slf+VVkm+wQk= +golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= +golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg= golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= -golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb h1:c5tyN8sSp8jSDxdCCDXVOpJwYXXhmTkNMt+g0zTSOic= -golang.zx2c4.com/wireguard v0.0.0-20231022001213-2e0774f246fb/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= +golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4= +golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= @@ -272,8 +273,8 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= From 8a6b9e742060792aa27bd759f777482505d01111 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jan 2024 00:05:54 +0000 Subject: [PATCH 238/867] Bump golang.org/x/net from 0.19.0 to 0.20.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.19.0 to 0.20.0. - [Commits](https://github.com/golang/net/compare/v0.19.0...v0.20.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index e004d90b..757ef883 100644 --- a/go.mod +++ b/go.mod @@ -20,8 +20,8 @@ require ( github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.17.0 - golang.org/x/net v0.19.0 + golang.org/x/crypto v0.18.0 + golang.org/x/net v0.20.0 golang.org/x/sync v0.6.0 golang.org/x/sys v0.16.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index 3b1016bb..48fc84f8 100644 --- a/go.sum +++ b/go.sum @@ -183,8 +183,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= @@ -205,8 +205,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= -golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From 2fa5c299ac14829ed7ea0819443355f88fbe676d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jan 2024 00:06:00 +0000 Subject: [PATCH 239/867] Bump github.com/refraction-networking/utls from 1.6.0 to 1.6.1 Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.6.0 to 1.6.1. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.6.0...v1.6.1) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 757ef883..a021afff 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.40.1 - github.com/refraction-networking/utls v1.6.0 + github.com/refraction-networking/utls v1.6.1 github.com/sagernet/sing v0.3.0 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index 48fc84f8..81583ebb 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5 github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= github.com/quic-go/quic-go v0.40.1 h1:X3AGzUNFs0jVuO3esAGnTfvdgvL4fq655WaOi1snv1Q= github.com/quic-go/quic-go v0.40.1/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c= -github.com/refraction-networking/utls v1.6.0 h1:X5vQMqVx7dY7ehxxqkFER/W6DSjy8TMqSItXm8hRDYQ= -github.com/refraction-networking/utls v1.6.0/go.mod h1:kHJ6R9DFFA0WsRgBM35iiDku4O7AqPR6y79iuzW7b10= +github.com/refraction-networking/utls v1.6.1 h1:n1JG5karzdGWsI6iZmGrOv3SNzR4c+4M8J6KWGsk3lA= +github.com/refraction-networking/utls v1.6.1/go.mod h1:+EbcQOvQvXoFV9AEKbuGlljt1doLRKAVY1jJHe9EtDo= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= From 81f9f567ffa9dfc987dff2724369c3884d065bcb Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Wed, 10 Jan 2024 19:26:27 +0300 Subject: [PATCH 240/867] sort Outbound selector output (#2914) * clean code * sort oubound selector output * clean up * fix duplicate outbound --- app/proxyman/outbound/outbound.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/proxyman/outbound/outbound.go b/app/proxyman/outbound/outbound.go index 8ebcde17..1bc4c403 100644 --- a/app/proxyman/outbound/outbound.go +++ b/app/proxyman/outbound/outbound.go @@ -4,6 +4,7 @@ package outbound import ( "context" + "sort" "strings" "sync" @@ -148,18 +149,14 @@ func (m *Manager) Select(selectors []string) []string { tags := make([]string, 0, len(selectors)) for tag := range m.taggedHandler { - match := false for _, selector := range selectors { if strings.HasPrefix(tag, selector) { - match = true + tags = append(tags, tag) break } } - if match { - tags = append(tags, tag) - } } - + sort.Strings(tags) return tags } From 2b08d8638ef63d63de85a334fc8d35fa8221c00c Mon Sep 17 00:00:00 2001 From: Qi Lin <141757486+QiL1n@users.noreply.github.com> Date: Mon, 8 Jan 2024 18:14:08 +0800 Subject: [PATCH 241/867] Let `tlsSettings.masterKeyLog` and `tlsSettings.fingerprint` work together --- transport/internet/tls/tls.go | 1 + 1 file changed, 1 insertion(+) diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index 2fd9a017..e73a495b 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -118,6 +118,7 @@ func copyConfig(c *tls.Config) *utls.Config { ServerName: c.ServerName, InsecureSkipVerify: c.InsecureSkipVerify, VerifyPeerCertificate: c.VerifyPeerCertificate, + KeyLogWriter: c.KeyLogWriter, } } From 961cf9d3b17f975db7013b8410d541f6fdfcf249 Mon Sep 17 00:00:00 2001 From: nobody <59990325+vrnobody@users.noreply.github.com> Date: Thu, 11 Jan 2024 23:34:26 +0800 Subject: [PATCH 242/867] Remove slices dependency. (#2930) * Remove slices dependency. * Fix nil pointer dereference bug. --------- Co-authored-by: nobody --- common/reflect/marshal.go | 47 +++++++++++++++++++++------------------ core/config.go | 10 +++++---- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/common/reflect/marshal.go b/common/reflect/marshal.go index 96e83351..736afc01 100644 --- a/common/reflect/marshal.go +++ b/common/reflect/marshal.go @@ -3,7 +3,6 @@ package reflect import ( "encoding/json" "reflect" - "slices" cserial "github.com/xtls/xray-core/common/serial" ) @@ -18,6 +17,9 @@ func MarshalToJson(v interface{}) (string, bool) { } func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool) interface{} { + if v == nil { + return nil + } tmsg, err := v.GetInstance() if err != nil { return nil @@ -111,28 +113,29 @@ func marshalKnownType(v interface{}, ignoreNullValue bool) (interface{}, bool) { } } -var valueKinds = []reflect.Kind{ - reflect.Bool, - reflect.Int, - reflect.Int8, - reflect.Int16, - reflect.Int32, - reflect.Int64, - reflect.Uint, - reflect.Uint8, - reflect.Uint16, - reflect.Uint32, - reflect.Uint64, - reflect.Uintptr, - reflect.Float32, - reflect.Float64, - reflect.Complex64, - reflect.Complex128, - reflect.String, -} - func isValueKind(kind reflect.Kind) bool { - return slices.Contains(valueKinds, kind) + switch kind { + case reflect.Bool, + reflect.Int, + reflect.Int8, + reflect.Int16, + reflect.Int32, + reflect.Int64, + reflect.Uint, + reflect.Uint8, + reflect.Uint16, + reflect.Uint32, + reflect.Uint64, + reflect.Uintptr, + reflect.Float32, + reflect.Float64, + reflect.Complex64, + reflect.Complex128, + reflect.String: + return true + default: + return false + } } func marshalInterface(v interface{}, ignoreNullValue bool) interface{} { diff --git a/core/config.go b/core/config.go index ec5ad6a4..1aa21f5f 100644 --- a/core/config.go +++ b/core/config.go @@ -2,7 +2,6 @@ package core import ( "io" - "slices" "strings" "github.com/xtls/xray-core/common" @@ -60,9 +59,12 @@ func GetMergedConfig(args cmdarg.Arg) (string, error) { supported := []string{"json", "yaml", "toml"} for _, file := range args { format := getFormat(file) - if slices.Contains(supported, format) { - files = append(files, file) - formats = append(formats, format) + for _, s := range supported { + if s == format { + files = append(files, file) + formats = append(formats, format) + break + } } } return ConfigMergedFormFiles(files, formats) From 0ea2a50264c4eab43ac1a67cf4ddde62c9214a6d Mon Sep 17 00:00:00 2001 From: Qi Lin <141757486+QiL1n@users.noreply.github.com> Date: Thu, 11 Jan 2024 14:36:13 +0800 Subject: [PATCH 243/867] Add option `realitySettings.masterKeyLog` --- infra/conf/transport_internet.go | 2 ++ transport/internet/reality/config.go | 17 ++++++++++++ transport/internet/reality/config.pb.go | 36 ++++++++++++++++--------- transport/internet/reality/config.proto | 1 + transport/internet/reality/reality.go | 1 + 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 318eb336..8c113e92 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -420,6 +420,7 @@ func (c *TLSConfig) Build() (proto.Message, error) { type REALITYConfig struct { Show bool `json:"show"` + MasterKeyLog string `json:"masterKeyLog"` Dest json.RawMessage `json:"dest"` Type string `json:"type"` Xver uint64 `json:"xver"` @@ -440,6 +441,7 @@ type REALITYConfig struct { func (c *REALITYConfig) Build() (proto.Message, error) { config := new(reality.Config) config.Show = c.Show + config.MasterKeyLog = c.MasterKeyLog var err error if c.Dest != nil { var i uint16 diff --git a/transport/internet/reality/config.go b/transport/internet/reality/config.go index 58608720..be3611e5 100644 --- a/transport/internet/reality/config.go +++ b/transport/internet/reality/config.go @@ -1,7 +1,9 @@ package reality import ( + "io" "net" + "os" "time" "github.com/xtls/reality" @@ -25,6 +27,8 @@ func (c *Config) GetREALITYConfig() *reality.Config { NextProtos: nil, // should be nil SessionTicketsDisabled: true, + + KeyLogWriter: KeyLogWriterFromConfig(c), } config.ServerNames = make(map[string]bool) for _, serverName := range c.ServerNames { @@ -37,6 +41,19 @@ func (c *Config) GetREALITYConfig() *reality.Config { return config } +func KeyLogWriterFromConfig(c *Config) io.Writer { + if len(c.MasterKeyLog) <= 0 || c.MasterKeyLog == "none" { + return nil + } + + writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644) + if err != nil { + newError("failed to open ", c.MasterKeyLog, " as master key log").AtError().Base(err).WriteToLog() + } + + return writer +} + func ConfigFromStreamSettings(settings *internet.MemoryStreamConfig) *Config { if settings == nil { return nil diff --git a/transport/internet/reality/config.pb.go b/transport/internet/reality/config.pb.go index 2b44d9b7..6631d0af 100644 --- a/transport/internet/reality/config.pb.go +++ b/transport/internet/reality/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.1 +// protoc-gen-go v1.32.0 +// protoc v4.25.1 // source: transport/internet/reality/config.proto package reality @@ -41,6 +41,7 @@ type Config struct { ShortId []byte `protobuf:"bytes,24,opt,name=short_id,json=shortId,proto3" json:"short_id,omitempty"` SpiderX string `protobuf:"bytes,25,opt,name=spider_x,json=spiderX,proto3" json:"spider_x,omitempty"` SpiderY []int64 `protobuf:"varint,26,rep,packed,name=spider_y,json=spiderY,proto3" json:"spider_y,omitempty"` + MasterKeyLog string `protobuf:"bytes,27,opt,name=master_key_log,json=masterKeyLog,proto3" json:"master_key_log,omitempty"` } func (x *Config) Reset() { @@ -187,6 +188,13 @@ func (x *Config) GetSpiderY() []int64 { return nil } +func (x *Config) GetMasterKeyLog() string { + if x != nil { + return x.MasterKeyLog + } + return "" +} + var File_transport_internet_reality_config_proto protoreflect.FileDescriptor var file_transport_internet_reality_config_proto_rawDesc = []byte{ @@ -194,7 +202,7 @@ var file_transport_internet_reality_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1f, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x22, 0xdc, 0x03, 0x0a, 0x06, 0x43, + 0x65, 0x74, 0x2e, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x22, 0x82, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x68, 0x6f, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x73, 0x68, 0x6f, 0x77, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, @@ -224,16 +232,18 @@ var file_transport_internet_reality_config_proto_rawDesc = []byte{ 0x74, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x70, 0x69, 0x64, 0x65, 0x72, 0x5f, 0x78, 0x18, 0x19, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x70, 0x69, 0x64, 0x65, 0x72, 0x58, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x70, 0x69, 0x64, 0x65, 0x72, 0x5f, 0x79, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x03, - 0x52, 0x07, 0x73, 0x70, 0x69, 0x64, 0x65, 0x72, 0x59, 0x42, 0x7f, 0x0a, 0x23, 0x63, 0x6f, 0x6d, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, - 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, - 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0xaa, 0x02, 0x1f, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x52, 0x07, 0x73, 0x70, 0x69, 0x64, 0x65, 0x72, 0x59, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x61, 0x73, + 0x74, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x1b, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, 0x42, + 0x7f, 0x0a, 0x23, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x72, + 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0xaa, 0x02, + 0x1f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/reality/config.proto b/transport/internet/reality/config.proto index f9ae3a4f..233f6e05 100644 --- a/transport/internet/reality/config.proto +++ b/transport/internet/reality/config.proto @@ -24,4 +24,5 @@ message Config { bytes short_id = 24; string spider_x = 25; repeated int64 spider_y = 26; + string master_key_log = 27; } diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 75a668c9..136a075d 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -112,6 +112,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati ServerName: config.ServerName, InsecureSkipVerify: true, SessionTicketsDisabled: true, + KeyLogWriter: KeyLogWriterFromConfig(config), } if utlsConfig.ServerName == "" { utlsConfig.ServerName = dest.Address.String() From 7f7f57d3b6a3fbce3cd2ab3d34abe27e6f6a3829 Mon Sep 17 00:00:00 2001 From: nobody <59990325+vrnobody@users.noreply.github.com> Date: Fri, 12 Jan 2024 23:36:48 +0800 Subject: [PATCH 244/867] Add tags cache to app.proxyman.ohm.Select() (#2927) * Add tags cache to ohm.Select(). * Refactor round-robin. * Fix a bug. --------- Co-authored-by: nobody --- app/proxyman/outbound/outbound.go | 14 ++++++++++++++ app/router/balancing.go | 32 ++++++++----------------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/app/proxyman/outbound/outbound.go b/app/proxyman/outbound/outbound.go index 1bc4c403..3bd0d85c 100644 --- a/app/proxyman/outbound/outbound.go +++ b/app/proxyman/outbound/outbound.go @@ -22,12 +22,14 @@ type Manager struct { taggedHandler map[string]outbound.Handler untaggedHandlers []outbound.Handler running bool + tagsCache map[string][]string } // New creates a new Manager. func New(ctx context.Context, config *proxyman.OutboundConfig) (*Manager, error) { m := &Manager{ taggedHandler: make(map[string]outbound.Handler), + tagsCache: make(map[string][]string), } return m, nil } @@ -104,6 +106,8 @@ func (m *Manager) AddHandler(ctx context.Context, handler outbound.Handler) erro m.access.Lock() defer m.access.Unlock() + m.tagsCache = make(map[string][]string) + if m.defaultHandler == nil { m.defaultHandler = handler } @@ -133,6 +137,8 @@ func (m *Manager) RemoveHandler(ctx context.Context, tag string) error { m.access.Lock() defer m.access.Unlock() + m.tagsCache = make(map[string][]string) + delete(m.taggedHandler, tag) if m.defaultHandler != nil && m.defaultHandler.Tag() == tag { m.defaultHandler = nil @@ -146,6 +152,11 @@ func (m *Manager) Select(selectors []string) []string { m.access.RLock() defer m.access.RUnlock() + key := strings.Join(selectors, ",") + if cache, ok := m.tagsCache[key]; ok { + return cache + } + tags := make([]string, 0, len(selectors)) for tag := range m.taggedHandler { @@ -156,7 +167,10 @@ func (m *Manager) Select(selectors []string) []string { } } } + sort.Strings(tags) + m.tagsCache[key] = tags + return tags } diff --git a/app/router/balancing.go b/app/router/balancing.go index e6f29a67..458e6838 100644 --- a/app/router/balancing.go +++ b/app/router/balancing.go @@ -2,7 +2,6 @@ package router import ( "context" - reflect "reflect" sync "sync" "github.com/xtls/xray-core/common/dice" @@ -26,35 +25,20 @@ func (s *RandomStrategy) PickOutbound(tags []string) string { } type RoundRobinStrategy struct { - mu sync.Mutex - tags []string - index int - roundRobin *RoundRobinStrategy -} - -func NewRoundRobin(tags []string) *RoundRobinStrategy { - return &RoundRobinStrategy{ - tags: tags, - } -} -func (r *RoundRobinStrategy) NextTag() string { - r.mu.Lock() - defer r.mu.Unlock() - - tags := r.tags[r.index] - r.index = (r.index + 1) % len(r.tags) - return tags + mu sync.Mutex + index int } func (s *RoundRobinStrategy) PickOutbound(tags []string) string { - if len(tags) == 0 { + n := len(tags) + if n == 0 { panic("0 tags") } - if s.roundRobin == nil || !reflect.DeepEqual(s.roundRobin.tags, tags) { - s.roundRobin = NewRoundRobin(tags) - } - tag := s.roundRobin.NextTag() + s.mu.Lock() + defer s.mu.Unlock() + tag := tags[s.index%n] + s.index = (s.index + 1) % n return tag } From 77376ed94f3ac8e3002c84dd43ceadabe9ab41e4 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 12 Jan 2024 21:56:22 -0500 Subject: [PATCH 245/867] Reduce size and time of UDP test In the past, the UDP test in mass parallel proved to be the source of instability. This change try to improve pass rate. --- testing/scenarios/dokodemo_test.go | 2 +- testing/scenarios/shadowsocks_2022_test.go | 26 ++++++++++++++-------- testing/scenarios/shadowsocks_test.go | 4 ++-- testing/scenarios/vmess_test.go | 4 ++-- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/testing/scenarios/dokodemo_test.go b/testing/scenarios/dokodemo_test.go index 69032b6e..0744cac9 100644 --- a/testing/scenarios/dokodemo_test.go +++ b/testing/scenarios/dokodemo_test.go @@ -171,7 +171,7 @@ func TestDokodemoUDP(t *testing.T) { common.Must(err) defer CloseServer(server) - clientPortRange := uint32(5) + clientPortRange := uint32(3) retry := 1 clientPort := uint32(udp.PickPort()) for { diff --git a/testing/scenarios/shadowsocks_2022_test.go b/testing/scenarios/shadowsocks_2022_test.go index aa595844..f06c38dc 100644 --- a/testing/scenarios/shadowsocks_2022_test.go +++ b/testing/scenarios/shadowsocks_2022_test.go @@ -32,14 +32,22 @@ func TestShadowsocks2022Tcp(t *testing.T) { } } -func TestShadowsocks2022Udp(t *testing.T) { - for _, method := range shadowaead_2022.List { - password := make([]byte, 32) - rand.Read(password) - t.Run(method, func(t *testing.T) { - testShadowsocks2022Udp(t, method, base64.StdEncoding.EncodeToString(password)) - }) - } +func TestShadowsocks2022UdpAES128(t *testing.T) { + password := make([]byte, 32) + rand.Read(password) + testShadowsocks2022Udp(t, shadowaead_2022.List[0], base64.StdEncoding.EncodeToString(password)) +} + +func TestShadowsocks2022UdpAES256(t *testing.T) { + password := make([]byte, 32) + rand.Read(password) + testShadowsocks2022Udp(t, shadowaead_2022.List[1], base64.StdEncoding.EncodeToString(password)) +} + +func TestShadowsocks2022UdpChacha(t *testing.T) { + password := make([]byte, 32) + rand.Read(password) + testShadowsocks2022Udp(t, shadowaead_2022.List[2], base64.StdEncoding.EncodeToString(password)) } func testShadowsocks2022Tcp(t *testing.T, method string, password string) { @@ -199,7 +207,7 @@ func testShadowsocks2022Udp(t *testing.T, method string, password string) { defer CloseAllServers(servers) var errGroup errgroup.Group - for i := 0; i < 10; i++ { + for i := 0; i < 2; i++ { errGroup.Go(testUDPConn(udpClientPort, 1024, time.Second*5)) } diff --git a/testing/scenarios/shadowsocks_test.go b/testing/scenarios/shadowsocks_test.go index d6b8ee82..e7620429 100644 --- a/testing/scenarios/shadowsocks_test.go +++ b/testing/scenarios/shadowsocks_test.go @@ -289,7 +289,7 @@ func TestShadowsocksAES128GCMUDP(t *testing.T) { defer CloseAllServers(servers) var errGroup errgroup.Group - for i := 0; i < 10; i++ { + for i := 0; i < 2; i++ { errGroup.Go(testUDPConn(clientPort, 1024, time.Second*5)) } if err := errGroup.Wait(); err != nil { @@ -391,7 +391,7 @@ func TestShadowsocksAES128GCMUDPMux(t *testing.T) { defer CloseAllServers(servers) var errGroup errgroup.Group - for i := 0; i < 10; i++ { + for i := 0; i < 2; i++ { errGroup.Go(testUDPConn(clientPort, 1024, time.Second*5)) } if err := errGroup.Wait(); err != nil { diff --git a/testing/scenarios/vmess_test.go b/testing/scenarios/vmess_test.go index 2239b13c..c11f830f 100644 --- a/testing/scenarios/vmess_test.go +++ b/testing/scenarios/vmess_test.go @@ -475,7 +475,7 @@ func TestVMessGCMUDP(t *testing.T) { defer CloseAllServers(servers) var errg errgroup.Group - for i := 0; i < 10; i++ { + for i := 0; i < 2; i++ { errg.Go(testUDPConn(clientPort, 1024, time.Second*5)) } if err := errg.Wait(); err != nil { @@ -1176,7 +1176,7 @@ func TestVMessGCMMuxUDP(t *testing.T) { for range "ab" { var errg errgroup.Group - for i := 0; i < 16; i++ { + for i := 0; i < 2; i++ { errg.Go(testTCPConn(clientPort, 1024, time.Second*10)) errg.Go(testUDPConn(clientUDPPort, 1024, time.Second*10)) } From da5a28a088091b86ac5b70ca732fc11cdb4c43fe Mon Sep 17 00:00:00 2001 From: dyhkwong <50692134+dyhkwong@users.noreply.github.com> Date: Mon, 15 Jan 2024 23:33:15 +0800 Subject: [PATCH 246/867] Fix #2654 (#2941) * fix udp dispatcher * fix test --- transport/internet/udp/dispatcher.go | 29 +++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/transport/internet/udp/dispatcher.go b/transport/internet/udp/dispatcher.go index 32c8c8ac..c29d4b13 100644 --- a/transport/internet/udp/dispatcher.go +++ b/transport/internet/udp/dispatcher.go @@ -28,7 +28,7 @@ type connEntry struct { type Dispatcher struct { sync.RWMutex - conns map[net.Destination]*connEntry + conn *connEntry dispatcher routing.Dispatcher callback ResponseCallback callClose func() error @@ -36,19 +36,18 @@ type Dispatcher struct { func NewDispatcher(dispatcher routing.Dispatcher, callback ResponseCallback) *Dispatcher { return &Dispatcher{ - conns: make(map[net.Destination]*connEntry), dispatcher: dispatcher, callback: callback, } } -func (v *Dispatcher) RemoveRay(dest net.Destination) { +func (v *Dispatcher) RemoveRay() { v.Lock() defer v.Unlock() - if conn, found := v.conns[dest]; found { - common.Close(conn.link.Reader) - common.Close(conn.link.Writer) - delete(v.conns, dest) + if v.conn != nil { + common.Close(v.conn.link.Reader) + common.Close(v.conn.link.Writer) + v.conn = nil } } @@ -56,8 +55,8 @@ func (v *Dispatcher) getInboundRay(ctx context.Context, dest net.Destination) (* v.Lock() defer v.Unlock() - if entry, found := v.conns[dest]; found { - return entry, nil + if v.conn != nil { + return v.conn, nil } newError("establishing new connection for ", dest).WriteToLog() @@ -65,7 +64,7 @@ func (v *Dispatcher) getInboundRay(ctx context.Context, dest net.Destination) (* ctx, cancel := context.WithCancel(ctx) removeRay := func() { cancel() - v.RemoveRay(dest) + v.RemoveRay() } timer := signal.CancelAfterInactivity(ctx, removeRay, time.Minute) @@ -79,7 +78,7 @@ func (v *Dispatcher) getInboundRay(ctx context.Context, dest net.Destination) (* timer: timer, cancel: removeRay, } - v.conns[dest] = entry + v.conn = entry go handleInput(ctx, entry, dest, v.callback, v.callClose) return entry, nil } @@ -130,6 +129,9 @@ func handleInput(ctx context.Context, conn *connEntry, dest net.Destination, cal } timer.Update() for _, b := range mb { + if b.UDP != nil { + dest = *b.UDP + } callback(ctx, &udp.Packet{ Payload: b, Source: dest, @@ -153,7 +155,6 @@ func DialDispatcher(ctx context.Context, dispatcher routing.Dispatcher) (net.Pac } d := &Dispatcher{ - conns: make(map[net.Destination]*connEntry), dispatcher: dispatcher, callback: c.callback, callClose: c.Close, @@ -199,7 +200,9 @@ func (c *dispatcherConn) WriteTo(p []byte, addr net.Addr) (int, error) { n := copy(raw, p) buffer.Resize(0, int32(n)) - c.dispatcher.Dispatch(c.ctx, net.DestinationFromAddr(addr), buffer) + destination := net.DestinationFromAddr(addr) + buffer.UDP = &destination + c.dispatcher.Dispatch(c.ctx, destination, buffer) return n, nil } From 10255bca835488fdf0126360d65bdcdcfb5076fc Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Mon, 15 Jan 2024 10:37:56 -0500 Subject: [PATCH 247/867] Reduce size and time of KCP test --- testing/scenarios/vmess_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/testing/scenarios/vmess_test.go b/testing/scenarios/vmess_test.go index c11f830f..8b7e646f 100644 --- a/testing/scenarios/vmess_test.go +++ b/testing/scenarios/vmess_test.go @@ -787,8 +787,8 @@ func TestVMessKCP(t *testing.T) { defer CloseAllServers(servers) var errg errgroup.Group - for i := 0; i < 10; i++ { - errg.Go(testTCPConn(clientPort, 10240*1024, time.Minute*2)) + for i := 0; i < 2; i++ { + errg.Go(testTCPConn(clientPort, 1024, time.Minute*2)) } if err := errg.Wait(); err != nil { t.Error(err) @@ -934,7 +934,7 @@ func TestVMessKCPLarge(t *testing.T) { var errg errgroup.Group for i := 0; i < 2; i++ { - errg.Go(testTCPConn(clientPort, 10240*1024, time.Minute*5)) + errg.Go(testTCPConn(clientPort, 513*1024, time.Minute*5)) } if err := errg.Wait(); err != nil { t.Error(err) From d20a835016b9c0a22b8a698a22a5669d1c5edae6 Mon Sep 17 00:00:00 2001 From: nobody <59990325+vrnobody@users.noreply.github.com> Date: Tue, 16 Jan 2024 23:52:01 +0800 Subject: [PATCH 248/867] Fix concurrent map writes error in ohm.Select(). (#2943) * Add unit test for ohm.tagsCache. * Fix concurrent map writes in ohm.Select(). --------- Co-authored-by: nobody --- app/proxyman/outbound/handler_test.go | 93 +++++++++++++++++++++++++++ app/proxyman/outbound/outbound.go | 19 +++--- 2 files changed, 103 insertions(+), 9 deletions(-) diff --git a/app/proxyman/outbound/handler_test.go b/app/proxyman/outbound/handler_test.go index c5afea70..e5b67308 100644 --- a/app/proxyman/outbound/handler_test.go +++ b/app/proxyman/outbound/handler_test.go @@ -2,9 +2,14 @@ package outbound_test import ( "context" + "fmt" + "sync" + "sync/atomic" "testing" + "time" "github.com/xtls/xray-core/app/policy" + "github.com/xtls/xray-core/app/proxyman" . "github.com/xtls/xray-core/app/proxyman/outbound" "github.com/xtls/xray-core/app/stats" "github.com/xtls/xray-core/common/net" @@ -78,3 +83,91 @@ func TestOutboundWithStatCounter(t *testing.T) { t.Errorf("Expected conn to be CounterConnection") } } + +func TestTagsCache(t *testing.T) { + + test_duration := 10 * time.Second + threads_num := 50 + delay := 10 * time.Millisecond + tags_prefix := "node" + + tags := sync.Map{} + counter := atomic.Uint64{} + + ohm, err := New(context.Background(), &proxyman.OutboundConfig{}) + if err != nil { + t.Error("failed to create outbound handler manager") + } + config := &core.Config{ + App: []*serial.TypedMessage{}, + } + v, _ := core.New(config) + v.AddFeature(ohm) + ctx := context.WithValue(context.Background(), xrayKey, v) + + stop_add_rm := false + wg_add_rm := sync.WaitGroup{} + addHandlers := func() { + defer wg_add_rm.Done() + for !stop_add_rm { + time.Sleep(delay) + idx := counter.Add(1) + tag := fmt.Sprintf("%s%d", tags_prefix, idx) + cfg := &core.OutboundHandlerConfig{ + Tag: tag, + ProxySettings: serial.ToTypedMessage(&freedom.Config{}), + } + if h, err := NewHandler(ctx, cfg); err == nil { + if err := ohm.AddHandler(ctx, h); err == nil { + // t.Log("add handler:", tag) + tags.Store(tag, nil) + } else { + t.Error("failed to add handler:", tag) + } + } else { + t.Error("failed to create handler:", tag) + } + } + } + + rmHandlers := func() { + defer wg_add_rm.Done() + for !stop_add_rm { + time.Sleep(delay) + tags.Range(func(key interface{}, value interface{}) bool { + if _, ok := tags.LoadAndDelete(key); ok { + // t.Log("remove handler:", key) + ohm.RemoveHandler(ctx, key.(string)) + return false + } + return true + }) + } + } + + selectors := []string{tags_prefix} + wg_get := sync.WaitGroup{} + stop_get := false + getTags := func() { + defer wg_get.Done() + for !stop_get { + time.Sleep(delay) + _ = ohm.Select(selectors) + // t.Logf("get tags: %v", tag) + } + } + + for i := 0; i < threads_num; i++ { + wg_add_rm.Add(2) + go rmHandlers() + go addHandlers() + wg_get.Add(1) + go getTags() + } + + time.Sleep(test_duration) + stop_add_rm = true + wg_add_rm.Wait() + stop_get = true + wg_get.Wait() +} diff --git a/app/proxyman/outbound/outbound.go b/app/proxyman/outbound/outbound.go index 3bd0d85c..40f32965 100644 --- a/app/proxyman/outbound/outbound.go +++ b/app/proxyman/outbound/outbound.go @@ -22,14 +22,14 @@ type Manager struct { taggedHandler map[string]outbound.Handler untaggedHandlers []outbound.Handler running bool - tagsCache map[string][]string + tagsCache *sync.Map } // New creates a new Manager. func New(ctx context.Context, config *proxyman.OutboundConfig) (*Manager, error) { m := &Manager{ taggedHandler: make(map[string]outbound.Handler), - tagsCache: make(map[string][]string), + tagsCache: &sync.Map{}, } return m, nil } @@ -106,7 +106,7 @@ func (m *Manager) AddHandler(ctx context.Context, handler outbound.Handler) erro m.access.Lock() defer m.access.Unlock() - m.tagsCache = make(map[string][]string) + m.tagsCache = &sync.Map{} if m.defaultHandler == nil { m.defaultHandler = handler @@ -137,7 +137,7 @@ func (m *Manager) RemoveHandler(ctx context.Context, tag string) error { m.access.Lock() defer m.access.Unlock() - m.tagsCache = make(map[string][]string) + m.tagsCache = &sync.Map{} delete(m.taggedHandler, tag) if m.defaultHandler != nil && m.defaultHandler.Tag() == tag { @@ -149,14 +149,15 @@ func (m *Manager) RemoveHandler(ctx context.Context, tag string) error { // Select implements outbound.HandlerSelector. func (m *Manager) Select(selectors []string) []string { - m.access.RLock() - defer m.access.RUnlock() key := strings.Join(selectors, ",") - if cache, ok := m.tagsCache[key]; ok { - return cache + if cache, ok := m.tagsCache.Load(key); ok { + return cache.([]string) } + m.access.RLock() + defer m.access.RUnlock() + tags := make([]string, 0, len(selectors)) for tag := range m.taggedHandler { @@ -169,7 +170,7 @@ func (m *Manager) Select(selectors []string) []string { } sort.Strings(tags) - m.tagsCache[key] = tags + m.tagsCache.Store(key, tags) return tags } From 360272a77d2c7df76ec4929f743bdca815da62a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 00:15:36 +0000 Subject: [PATCH 249/867] Bump actions/cache from 3 to 4 Bumps [actions/cache](https://github.com/actions/cache) from 3 to 4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 6 +++--- .github/workflows/test.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86335113..436aeacb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Restore Cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: resources key: xray-geodat- @@ -57,7 +57,7 @@ jobs: done - name: Save Cache - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 if: ${{ steps.update.outputs.unhit }} with: path: resources @@ -180,7 +180,7 @@ jobs: find . -maxdepth 1 -type f -regex '.*\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; - name: Restore Cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: resources key: xray-geodat- diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cf5d1259..59ee22c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,7 +35,7 @@ jobs: - name: Checkout codebase uses: actions/checkout@v4 - name: Restore Cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: path: resources key: xray-geodat- From 4bffd5114dbaa43949aa38d9fea2cefd37af632b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Jan 2024 00:55:39 +0000 Subject: [PATCH 250/867] Bump github.com/quic-go/quic-go from 0.40.1 to 0.41.0 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.40.1 to 0.41.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.40.1...v0.41.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 3 +-- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index a021afff..566b3885 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/miekg/dns v1.1.57 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.40.1 + github.com/quic-go/quic-go v0.41.0 github.com/refraction-networking/utls v1.6.1 github.com/sagernet/sing v0.3.0 github.com/sagernet/sing-shadowsocks v0.2.6 @@ -46,7 +46,6 @@ require ( github.com/klauspost/cpuid/v2 v2.2.6 // indirect github.com/onsi/ginkgo/v2 v2.13.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/quic-go/qtls-go1-20 v0.4.1 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.4.0 // indirect diff --git a/go.sum b/go.sum index 81583ebb..ea8b516e 100644 --- a/go.sum +++ b/go.sum @@ -114,10 +114,8 @@ github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/quic-go/qtls-go1-20 v0.4.1 h1:D33340mCNDAIKBqXuAvexTNMUByrYmFYVfKfDN5nfFs= -github.com/quic-go/qtls-go1-20 v0.4.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.40.1 h1:X3AGzUNFs0jVuO3esAGnTfvdgvL4fq655WaOi1snv1Q= -github.com/quic-go/quic-go v0.40.1/go.mod h1:PeN7kuVJ4xZbxSv/4OX6S1USOX8MJvydwpTx31vx60c= +github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k= +github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= github.com/refraction-networking/utls v1.6.1 h1:n1JG5karzdGWsI6iZmGrOv3SNzR4c+4M8J6KWGsk3lA= github.com/refraction-networking/utls v1.6.1/go.mod h1:+EbcQOvQvXoFV9AEKbuGlljt1doLRKAVY1jJHe9EtDo= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From 53de58fad3a0b715f91d39a492de2a33faf42023 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Jan 2024 00:26:56 +0000 Subject: [PATCH 251/867] Bump github.com/miekg/dns from 1.1.57 to 1.1.58 Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.57 to 1.1.58. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.57...v1.1.58) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 566b3885..ea467490 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.6.0 github.com/gorilla/websocket v1.5.1 - github.com/miekg/dns v1.1.57 + github.com/miekg/dns v1.1.58 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.41.0 @@ -53,7 +53,7 @@ require ( golang.org/x/mod v0.14.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.16.1 // indirect + golang.org/x/tools v0.17.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index ea8b516e..ea4dfac0 100644 --- a/go.sum +++ b/go.sum @@ -90,8 +90,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= -github.com/miekg/dns v1.1.57 h1:Jzi7ApEIzwEPLHWRcafCN9LZSBbqQpxjt/wpgvg7wcM= -github.com/miekg/dns v1.1.57/go.mod h1:uqRjCRUuEAA6qsOiJvDd+CFo/vW+y5WR6SNmHE55hZk= +github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= +github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= @@ -249,8 +249,8 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= -golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From d97a29f55bc82ff878a786c5d53de808658caa4d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Jan 2024 01:00:09 +0000 Subject: [PATCH 252/867] Bump google.golang.org/grpc from 1.60.1 to 1.61.0 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.60.1 to 1.61.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.60.1...v1.61.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ea467490..12f713a8 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/sync v0.6.0 golang.org/x/sys v0.16.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.60.1 + google.golang.org/grpc v1.61.0 google.golang.org/protobuf v1.32.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index ea4dfac0..49d18605 100644 --- a/go.sum +++ b/go.sum @@ -277,8 +277,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= +google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= From 25c531c6c35890d447d56c465578622821ebfec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=82=BB?= <123655015+chise0713@users.noreply.github.com> Date: Thu, 25 Jan 2024 21:21:10 +0800 Subject: [PATCH 253/867] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df1537d8..3b1226d2 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ - [Libertea](https://github.com/VZiChoushaDui/Libertea) - One Click - [Xray-REALITY](https://github.com/zxcvos/Xray-script), [xray-reality](https://github.com/sajjaddg/xray-reality), [reality-ezpz](https://github.com/aleskxyz/reality-ezpz) - - [Xray-script](https://github.com/kirin10000/Xray-script), [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [XTool](https://github.com/LordPenguin666/XTool) + - [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [XTool](https://github.com/LordPenguin666/XTool) - [v2ray-agent](https://github.com/mack-a/v2ray-agent), [Xray_onekey](https://github.com/wulabing/Xray_onekey), [ProxySU](https://github.com/proxysu/ProxySU) - Magisk - [Xray4Magisk](https://github.com/Asterisk4Magisk/Xray4Magisk) From 3167a70ff8f0ac7e2b6c4f8ffc57a0a2ada0be9c Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 26 Jan 2024 02:14:26 -0500 Subject: [PATCH 254/867] Try to fix rare ssl error with freedom splice --- proxy/proxy.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/proxy/proxy.go b/proxy/proxy.go index 4dcb6bf9..ee131315 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -13,6 +13,7 @@ import ( "math/big" "runtime" "strconv" + "time" "github.com/pires/go-proxyproto" "github.com/xtls/xray-core/common/buf" @@ -478,6 +479,7 @@ func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net if inbound.CanSpliceCopy == 1 { newError("CopyRawConn splice").WriteToLog(session.ExportIDToError(ctx)) runtime.Gosched() // necessary + time.Sleep(time.Millisecond) // without this, there will be a rare ssl error for freedom splice w, err := tc.ReadFrom(readerConn) if readCounter != nil { readCounter.Add(w) From d21e9b0abd3a3472c07fafd7f407f3a08d99e07a Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 26 Jan 2024 04:42:45 -0500 Subject: [PATCH 255/867] Try a better fix for rare ssl error with freedom splice It seems the root cause is if the flag set at the inbound pipe reader, it is a race condition and freedom outbound can possibly do splice at the same time with inbound xtls writer. Now we set the flag at the earliest and always do splice at the next buffer cycle. --- proxy/proxy.go | 2 -- proxy/vless/encoding/encoding.go | 18 +++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index ee131315..4dcb6bf9 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -13,7 +13,6 @@ import ( "math/big" "runtime" "strconv" - "time" "github.com/pires/go-proxyproto" "github.com/xtls/xray-core/common/buf" @@ -479,7 +478,6 @@ func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net if inbound.CanSpliceCopy == 1 { newError("CopyRawConn splice").WriteToLog(session.ExportIDToError(ctx)) runtime.Gosched() // necessary - time.Sleep(time.Millisecond) // without this, there will be a rare ssl error for freedom splice w, err := tc.ReadFrom(readerConn) if readCounter != nil { readCounter.Add(w) diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index b7fb66f5..5fe79c08 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -225,15 +225,6 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate var ct stats.Counter for { buffer, err := reader.ReadMultiBuffer() - if trafficState.WriterSwitchToDirectCopy { - if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.CanSpliceCopy == 2 { - inbound.CanSpliceCopy = 1 // force the value to 1, don't use setter - } - rawConn, _, writerCounter := proxy.UnwrapRawConn(conn) - writer = buf.NewWriter(rawConn) - ct = writerCounter - trafficState.WriterSwitchToDirectCopy = false - } if !buffer.IsEmpty() { if ct != nil { ct.Add(int64(buffer.Len())) @@ -242,6 +233,15 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate if werr := writer.WriteMultiBuffer(buffer); werr != nil { return werr } + if trafficState.WriterSwitchToDirectCopy { + rawConn, _, writerCounter := proxy.UnwrapRawConn(conn) + writer = buf.NewWriter(rawConn) + ct = writerCounter + trafficState.WriterSwitchToDirectCopy = false + if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.CanSpliceCopy == 2 { + inbound.CanSpliceCopy = 1 // force the value to 1, don't use setter + } + } } if err != nil { return err From 813f9a33b7c7f27c3a9fd1765809395c59a763e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 30 Jan 2024 00:55:50 +0000 Subject: [PATCH 256/867] Bump github.com/refraction-networking/utls from 1.6.1 to 1.6.2 Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.6.1 to 1.6.2. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.6.1...v1.6.2) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 12f713a8..9dc7a917 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.41.0 - github.com/refraction-networking/utls v1.6.1 + github.com/refraction-networking/utls v1.6.2 github.com/sagernet/sing v0.3.0 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index 49d18605..31542da8 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k= github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= -github.com/refraction-networking/utls v1.6.1 h1:n1JG5karzdGWsI6iZmGrOv3SNzR4c+4M8J6KWGsk3lA= -github.com/refraction-networking/utls v1.6.1/go.mod h1:+EbcQOvQvXoFV9AEKbuGlljt1doLRKAVY1jJHe9EtDo= +github.com/refraction-networking/utls v1.6.2 h1:iTeeGY0o6nMNcGyirxkD5bFIsVctP5InGZ3E0HrzS7k= +github.com/refraction-networking/utls v1.6.2/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr3h62pQoY1lXiNR/FPs= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= From dd635c7c8d3bf2b4c2717709fca3d5bd8fba6de6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 00:31:18 +0000 Subject: [PATCH 257/867] Bump nick-fields/retry from 2 to 3 Bumps [nick-fields/retry](https://github.com/nick-fields/retry) from 2 to 3. - [Release notes](https://github.com/nick-fields/retry/releases) - [Changelog](https://github.com/nick-fields/retry/blob/master/.releaserc.js) - [Commits](https://github.com/nick-fields/retry/compare/v2...v3) --- updated-dependencies: - dependency-name: nick-fields/retry dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 436aeacb..678831c6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: - name: Update Geodat id: update - uses: nick-fields/retry@v2 + uses: nick-fields/retry@v3 with: timeout_minutes: 60 retry_wait_seconds: 60 From ad3d347cfc1fada5e951ebcd3de9696f69a1f927 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 2 Feb 2024 20:32:46 +0000 Subject: [PATCH 258/867] XTLS Vision: Apply padding to single XUDP by default at client side Requires Xray-core v1.8.1+ at server side: https://github.com/XTLS/Xray-core/commit/242f3b0e0b635699db26a991aa6c0cd47927e8b6 --- proxy/vless/encoding/addons.go | 6 +----- proxy/vless/encoding/encoding.go | 3 +-- proxy/vless/inbound/inbound.go | 1 + proxy/vless/outbound/outbound.go | 12 +++++++++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/proxy/vless/encoding/addons.go b/proxy/vless/encoding/addons.go index e3e5071b..9426f6a0 100644 --- a/proxy/vless/encoding/addons.go +++ b/proxy/vless/encoding/addons.go @@ -62,11 +62,7 @@ func DecodeHeaderAddons(buffer *buf.Buffer, reader io.Reader) (*Addons, error) { // EncodeBodyAddons returns a Writer that auto-encrypt content written by caller. func EncodeBodyAddons(writer io.Writer, request *protocol.RequestHeader, requestAddons *Addons, state *proxy.TrafficState, context context.Context) buf.Writer { if request.Command == protocol.RequestCommandUDP { - w := writer.(buf.Writer) - if requestAddons.Flow == vless.XRV { - w = proxy.NewVisionWriter(w, state, context) - } - return NewMultiLengthPacketWriter(w) + return NewMultiLengthPacketWriter(writer.(buf.Writer)) } w := buf.NewWriter(writer) if requestAddons.Flow == vless.XRV { diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index 5fe79c08..455f896b 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -176,7 +176,6 @@ func DecodeResponseHeader(reader io.Reader, request *protocol.RequestHeader) (*A // XtlsRead filter and read xtls protocol func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, input *bytes.Reader, rawInput *bytes.Buffer, trafficState *proxy.TrafficState, ctx context.Context) error { err := func() error { - visionReader := proxy.NewVisionReader(reader, trafficState, ctx) for { if trafficState.ReaderSwitchToDirectCopy { var writerConn net.Conn @@ -188,7 +187,7 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater } return proxy.CopyRawConnIfExist(ctx, conn, writerConn, writer, timer) } - buffer, err := visionReader.ReadMultiBuffer() + buffer, err := reader.ReadMultiBuffer() if !buffer.IsEmpty() { timer.Update() if trafficState.ReaderSwitchToDirectCopy { diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index 4cd3fcb1..0ffa61d2 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -522,6 +522,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s if requestAddons.Flow == vless.XRV { ctx1 := session.ContextWithInbound(ctx, nil) // TODO enable splice + clientReader = proxy.NewVisionReader(clientReader, trafficState, ctx1) err = encoding.XtlsRead(clientReader, serverWriter, timer, connection, input, rawInput, trafficState, ctx1) } else { // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index cd30617c..a9368813 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -138,7 +138,6 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte if !allowUDP443 && request.Port == 443 { return newError("XTLS rejected UDP/443 traffic").AtInfo() } - requestAddons.Flow = "" case protocol.RequestCommandMux: fallthrough // let server break Mux connections that contain TCP requests case protocol.RequestCommandTCP: @@ -185,7 +184,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte clientReader := link.Reader // .(*pipe.Reader) clientWriter := link.Writer // .(*pipe.Writer) trafficState := proxy.NewTrafficState(account.ID.Bytes()) - if request.Command == protocol.RequestCommandUDP && h.cone && request.Port != 53 && request.Port != 443 { + if request.Command == protocol.RequestCommandUDP && (requestAddons.Flow == vless.XRV || (h.cone && request.Port != 53 && request.Port != 443)) { request.Command = protocol.RequestCommandMux request.Address = net.DomainAddress("v1.mux.cool") request.Port = net.Port(666) @@ -266,8 +265,15 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte // default: serverReader := buf.NewReader(conn) serverReader := encoding.DecodeBodyAddons(conn, request, responseAddons) + if requestAddons.Flow == vless.XRV { + serverReader = proxy.NewVisionReader(serverReader, trafficState, ctx) + } if request.Command == protocol.RequestCommandMux && request.Port == 666 { - serverReader = xudp.NewPacketReader(conn) + if requestAddons.Flow == vless.XRV { + serverReader = xudp.NewPacketReader(&buf.BufferedReader{Reader: serverReader}) + } else { + serverReader = xudp.NewPacketReader(conn) + } } if requestAddons.Flow == vless.XRV { From b56917fde5be2cc912677fafa7c51bb70779110f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 4 Feb 2024 09:36:41 +0000 Subject: [PATCH 259/867] README: Re-add Compilation --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 3b1226d2..467a83e9 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,21 @@ ## Compilation +### Windows (PowerShell) + +```powershell +$env:CGO_ENABLED=0 +go build -o xray.exe -trimpath -ldflags "-s -w -buildid=" ./main +``` + +### Linux / macOS + +```bash +CGO_ENABLED=0 go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main +``` + +### Reproducible Releases + ```bash make ``` From 3a99520370f41dde572fd6c7f499e694006341a2 Mon Sep 17 00:00:00 2001 From: Iain Lau Date: Sat, 3 Feb 2024 09:10:23 +0800 Subject: [PATCH 260/867] Add PROXY Protocol support for freedom outbound --- common/net/destination.go | 29 +++++++++++++++++++++ infra/conf/freedom.go | 4 +++ proxy/freedom/config.pb.go | 53 +++++++++++++++++++++++--------------- proxy/freedom/config.proto | 3 ++- proxy/freedom/freedom.go | 13 ++++++++++ 5 files changed, 80 insertions(+), 22 deletions(-) diff --git a/common/net/destination.go b/common/net/destination.go index 055395e9..90f8298b 100644 --- a/common/net/destination.go +++ b/common/net/destination.go @@ -97,6 +97,35 @@ func (d Destination) NetAddr() string { return addr } +// RawNetAddr converts a net.Addr from its Destination presentation. +func (d Destination) RawNetAddr() net.Addr { + var addr net.Addr + switch d.Network { + case Network_TCP: + if d.Address.Family().IsIP() { + addr = &net.TCPAddr{ + IP: d.Address.IP(), + Port: int(d.Port), + } + } + case Network_UDP: + if d.Address.Family().IsIP() { + addr = &net.UDPAddr{ + IP: d.Address.IP(), + Port: int(d.Port), + } + } + case Network_UNIX: + if d.Address.Family().IsDomain() { + addr = &net.UnixAddr{ + Name: d.Address.String(), + Net: d.Network.SystemString(), + } + } + } + return addr +} + // String returns the strings form of this Destination. func (d Destination) String() string { prefix := "unknown:" diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index dd812db6..90c99b37 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -17,6 +17,7 @@ type FreedomConfig struct { Redirect string `json:"redirect"` UserLevel uint32 `json:"userLevel"` Fragment *Fragment `json:"fragment"` + ProxyProtocol uint32 `json:"proxyProtocol"` } type Fragment struct { @@ -165,5 +166,8 @@ func (c *FreedomConfig) Build() (proto.Message, error) { config.DestinationOverride.Server.Address = v2net.NewIPOrDomain(v2net.ParseAddress(host)) } } + if c.ProxyProtocol > 0 && c.ProxyProtocol <= 2 { + config.ProxyProtocol = c.ProxyProtocol + } return config, nil } diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 229630d4..81ce18e5 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 -// protoc v4.23.1 +// protoc-gen-go v1.32.0 +// protoc v4.25.2 // source: proxy/freedom/config.proto package freedom @@ -239,6 +239,7 @@ type Config struct { DestinationOverride *DestinationOverride `protobuf:"bytes,3,opt,name=destination_override,json=destinationOverride,proto3" json:"destination_override,omitempty"` UserLevel uint32 `protobuf:"varint,4,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` Fragment *Fragment `protobuf:"bytes,5,opt,name=fragment,proto3" json:"fragment,omitempty"` + ProxyProtocol uint32 `protobuf:"varint,6,opt,name=proxy_protocol,json=proxyProtocol,proto3" json:"proxy_protocol,omitempty"` } func (x *Config) Reset() { @@ -309,6 +310,13 @@ func (x *Config) GetFragment() *Fragment { return nil } +func (x *Config) GetProxyProtocol() uint32 { + if x != nil { + return x.ProxyProtocol + } + return 0 +} + var File_proxy_freedom_config_proto protoreflect.FileDescriptor var file_proxy_freedom_config_proto_rawDesc = []byte{ @@ -335,7 +343,7 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x6c, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0xdb, 0x03, 0x0a, 0x06, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0x82, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, @@ -354,24 +362,27 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x76, 0x65, 0x6c, 0x12, 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0xa9, 0x01, - 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, - 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, - 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, - 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, - 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, - 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, - 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, - 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, - 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, - 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, - 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, - 0x64, 0x6f, 0x6d, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, - 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, - 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, - 0x64, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, + 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, + 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, + 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, + 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, + 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, + 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, + 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, + 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, + 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, + 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, + 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, + 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x66, 0x72, + 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/proxy/freedom/config.proto b/proxy/freedom/config.proto index 0f328022..1eabedb7 100644 --- a/proxy/freedom/config.proto +++ b/proxy/freedom/config.proto @@ -39,5 +39,6 @@ message Config { uint32 timeout = 2 [deprecated = true]; DestinationOverride destination_override = 3; uint32 user_level = 4; - Fragment fragment = 5; + Fragment fragment = 5; + uint32 proxy_protocol = 6; } diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 809d4df8..55853646 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -9,6 +9,7 @@ import ( "math/big" "time" + "github.com/pires/go-proxyproto" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/dice" @@ -152,6 +153,18 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte if err != nil { return err } + + if h.config.ProxyProtocol > 0 && h.config.ProxyProtocol <= 2 { + version := byte(h.config.ProxyProtocol) + srcAddr := inbound.Source.RawNetAddr() + dstAddr := rawConn.RemoteAddr() + header := proxyproto.HeaderProxyFromAddrs(version, srcAddr, dstAddr) + if _, err = header.WriteTo(rawConn); err != nil { + rawConn.Close() + return err + } + } + conn = rawConn return nil }) From 303beff5dd1aa42f9be45313a4381aa1ce45fb7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Tue, 6 Feb 2024 18:56:55 +0800 Subject: [PATCH 261/867] Fix SockOpt does not work in UDP --- transport/internet/system_dialer.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index cdb6cb9c..2c2fdf85 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -66,6 +66,18 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne if err != nil { return nil, err } + if sockopt != nil || len(d.controllers) > 0 { + file, err := packetConn.(*net.UDPConn).File() + if err != nil { + return nil, err + } + fd := file.Fd() + if sockopt != nil { + if err := applyOutboundSocketOptions("udp", dest.NetAddr(), fd, sockopt); err != nil { + newError("failed to apply socket options").Base(err).WriteToLog(session.ExportIDToError(ctx)) + } + } + } return &PacketConnWrapper{ Conn: packetConn, Dest: destAddr, From d83ccaeea97f2ee0e7eb3135d5d7f8e16d43442e Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Tue, 6 Feb 2024 21:16:27 -0500 Subject: [PATCH 262/867] Clean up legacy compile directive --- app/observatory/command/command.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/observatory/command/command.go b/app/observatory/command/command.go index 0c1fac51..aab85e80 100644 --- a/app/observatory/command/command.go +++ b/app/observatory/command/command.go @@ -1,6 +1,3 @@ -//go:build !confonly -// +build !confonly - package command import ( From 7c8bec85964f0da8334802132d960fec18e3b54d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 00:23:54 +0000 Subject: [PATCH 263/867] Bump golang.org/x/sys from 0.16.0 to 0.17.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.16.0 to 0.17.0. - [Commits](https://github.com/golang/sys/compare/v0.16.0...v0.17.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9dc7a917..689d33f9 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( golang.org/x/crypto v0.18.0 golang.org/x/net v0.20.0 golang.org/x/sync v0.6.0 - golang.org/x/sys v0.16.0 + golang.org/x/sys v0.17.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.61.0 google.golang.org/protobuf v1.32.0 diff --git a/go.sum b/go.sum index 31542da8..7ff8a9d2 100644 --- a/go.sum +++ b/go.sum @@ -230,8 +230,8 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From c5713eb9524c719ebc51771a099d19fa509a4b4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 00:23:59 +0000 Subject: [PATCH 264/867] Bump golang.org/x/crypto from 0.18.0 to 0.19.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.18.0 to 0.19.0. - [Commits](https://github.com/golang/crypto/compare/v0.18.0...v0.19.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 689d33f9..b6b3f064 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.18.0 + golang.org/x/crypto v0.19.0 golang.org/x/net v0.20.0 golang.org/x/sync v0.6.0 golang.org/x/sys v0.17.0 diff --git a/go.sum b/go.sum index 7ff8a9d2..bf7fd5ca 100644 --- a/go.sum +++ b/go.sum @@ -181,8 +181,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= +golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= From 7c9e3f97f1c9dd794dd2230a1b6be3019675fced Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Feb 2024 02:06:55 +0000 Subject: [PATCH 265/867] Bump golang.org/x/net from 0.20.0 to 0.21.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.20.0 to 0.21.0. - [Commits](https://github.com/golang/net/compare/v0.20.0...v0.21.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b6b3f064..d2833fd8 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.19.0 - golang.org/x/net v0.20.0 + golang.org/x/net v0.21.0 golang.org/x/sync v0.6.0 golang.org/x/sys v0.17.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index bf7fd5ca..a09c6734 100644 --- a/go.sum +++ b/go.sum @@ -203,8 +203,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From b091076bae457743fa4358ff0e149b25c3f3c43a Mon Sep 17 00:00:00 2001 From: lunafe <45958598+lunafe@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:03:29 +0800 Subject: [PATCH 266/867] fix #2970 parsing IPv6 address in wireguard peers configure --- proxy/wireguard/client.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/proxy/wireguard/client.go b/proxy/wireguard/client.go index 2560c538..4136525e 100644 --- a/proxy/wireguard/client.go +++ b/proxy/wireguard/client.go @@ -254,7 +254,6 @@ func (h *Handler) makeVirtualTun(bind *netBindClient) (Tunnel, error) { return t, nil } - // serialize the config into an IPC request func (h *Handler) createIPCRequest(bind *netBindClient, conf *DeviceConfig) string { var request strings.Builder @@ -275,8 +274,11 @@ func (h *Handler) createIPCRequest(bind *netBindClient, conf *DeviceConfig) stri request.WriteString(fmt.Sprintf("preshared_key=%s\n", peer.PreSharedKey)) } - split := strings.Split(peer.Endpoint, ":") - addr := net.ParseAddress(split[0]) + address, port, err := net.SplitHostPort(peer.Endpoint) + if err != nil { + newError("failed to split endpoint ", peer.Endpoint, " into address and port").AtError().WriteToLog() + } + addr := net.ParseAddress(address) if addr.Family().IsDomain() { dialerIp := bind.dialer.DestIpAddress() if dialerIp != nil { @@ -306,7 +308,7 @@ func (h *Handler) createIPCRequest(bind *netBindClient, conf *DeviceConfig) stri } if peer.Endpoint != "" { - request.WriteString(fmt.Sprintf("endpoint=%s:%s\n", addr, split[1])) + request.WriteString(fmt.Sprintf("endpoint=%s:%s\n", addr, port)) } for _, ip := range peer.AllowedIps { From 40e41d8b6b51b3fa78117cb644684eb531ea34ca Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Feb 2024 00:43:55 +0000 Subject: [PATCH 267/867] Bump google.golang.org/grpc from 1.61.0 to 1.61.1 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.61.0 to 1.61.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.61.0...v1.61.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d2833fd8..91b31d4c 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/sync v0.6.0 golang.org/x/sys v0.17.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.61.0 + google.golang.org/grpc v1.61.1 google.golang.org/protobuf v1.32.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index a09c6734..cf6dd63c 100644 --- a/go.sum +++ b/go.sum @@ -277,8 +277,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= -google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= +google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY= +google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= From 09656bd5d1a52d8aed119bcd75a2ffea238a4672 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:14:42 -0500 Subject: [PATCH 268/867] Add back sleep for freedom splice --- proxy/proxy.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 4dcb6bf9..e8adb7e2 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -13,6 +13,7 @@ import ( "math/big" "runtime" "strconv" + "time" "github.com/pires/go-proxyproto" "github.com/xtls/xray-core/common/buf" @@ -477,7 +478,8 @@ func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net for inbound.CanSpliceCopy != 3 { if inbound.CanSpliceCopy == 1 { newError("CopyRawConn splice").WriteToLog(session.ExportIDToError(ctx)) - runtime.Gosched() // necessary + //runtime.Gosched() // necessary + time.Sleep(time.Millisecond) // without this, there will be a rare ssl error for freedom splice w, err := tc.ReadFrom(readerConn) if readCounter != nil { readCounter.Add(w) From a15334b39555cf5810b87414aeba360d85b9b786 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 17 Feb 2024 11:16:37 -0500 Subject: [PATCH 269/867] Go back to first fix (revet d21e9b0abd3a3472c07fafd7f407f3a08d99e07a) Xtls is magic, don't play with it ;) A knowledged guess is the timing to switch to splice is very sensitive. Now both Xtls and Freedom outound do the switching when pipe just finished one buffer --- proxy/vless/encoding/encoding.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index 455f896b..5956389a 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -224,6 +224,15 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate var ct stats.Counter for { buffer, err := reader.ReadMultiBuffer() + if trafficState.WriterSwitchToDirectCopy { + if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.CanSpliceCopy == 2 { + inbound.CanSpliceCopy = 1 // force the value to 1, don't use setter + } + rawConn, _, writerCounter := proxy.UnwrapRawConn(conn) + writer = buf.NewWriter(rawConn) + ct = writerCounter + trafficState.WriterSwitchToDirectCopy = false + } if !buffer.IsEmpty() { if ct != nil { ct.Add(int64(buffer.Len())) @@ -232,15 +241,6 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate if werr := writer.WriteMultiBuffer(buffer); werr != nil { return werr } - if trafficState.WriterSwitchToDirectCopy { - rawConn, _, writerCounter := proxy.UnwrapRawConn(conn) - writer = buf.NewWriter(rawConn) - ct = writerCounter - trafficState.WriterSwitchToDirectCopy = false - if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.CanSpliceCopy == 2 { - inbound.CanSpliceCopy = 1 // force the value to 1, don't use setter - } - } } if err != nil { return err From bf02392969076e1a5422f95ee1993764cbcd0d74 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 17 Feb 2024 13:22:39 -0500 Subject: [PATCH 270/867] Temporarily turn off sockopt for UDP on windows --- transport/internet/system_dialer.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index 2c2fdf85..924f364c 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -2,6 +2,7 @@ package internet import ( "context" + "runtime" "syscall" "time" @@ -66,7 +67,7 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne if err != nil { return nil, err } - if sockopt != nil || len(d.controllers) > 0 { + if runtime.GOOS != "windows" && (sockopt != nil || len(d.controllers) > 0) { file, err := packetConn.(*net.UDPConn).File() if err != nil { return nil, err From fa5d7a255b95215916d93bf371aaea55ea758381 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 17 Feb 2024 22:51:37 -0500 Subject: [PATCH 271/867] Least load balancer (#2999) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * v5: Health Check & LeastLoad Strategy (rebased from 2c5a71490368500a982018a74a6d519c7e121816) Some changes will be necessary to integrate it into V2Ray * Update proto * parse duration conf with time.Parse() * moving health ping to observatory as a standalone component * moving health ping to observatory as a standalone component: auto generated file * add initialization for health ping * incorporate changes in router implementation * support principle target output * add v4 json support for BurstObservatory & fix balancer reference * update API command * remove cancelled API * return zero length value when observer is not found * remove duplicated targeted dispatch * adjust test with updated structure * bug fix for observer * fix strategy selector * fix strategy least load * Fix ticker usage ticker.Close does not close ticker.C * feat: Replace default Health Ping URL to HTTPS (#1991) * fix selectLeastLoad() returns wrong number of nodes (#2083) * Test: fix leastload strategy unit test * fix(router): panic caused by concurrent map read and write (#2678) * Clean up code --------- Co-authored-by: Jebbs Co-authored-by: Shelikhoo Co-authored-by: 世界 Co-authored-by: Bernd Eichelberger <46166740+4-FLOSS-Free-Libre-Open-Source-Software@users.noreply.github.com> Co-authored-by: 秋のかえで Co-authored-by: Rinka --- app/commander/config.pb.go | 2 +- app/dispatcher/config.pb.go | 2 +- app/dispatcher/default.go | 2 +- app/dns/config.pb.go | 2 +- app/dns/fakedns/fakedns.pb.go | 2 +- app/log/command/config.pb.go | 2 +- app/log/config.pb.go | 2 +- app/metrics/config.pb.go | 2 +- app/observatory/burst/burst.go | 14 + app/observatory/burst/burstobserver.go | 108 ++++ app/observatory/burst/config.pb.go | 276 +++++++++ app/observatory/burst/config.proto | 29 + app/observatory/burst/errors.generated.go | 9 + app/observatory/burst/healthping.go | 244 ++++++++ app/observatory/burst/healthping_result.go | 143 +++++ .../burst/healthping_result_test.go | 106 ++++ app/observatory/burst/ping.go | 69 +++ app/observatory/command/command.pb.go | 2 +- app/observatory/config.pb.go | 266 +++++--- app/observatory/config.proto | 11 + app/policy/config.pb.go | 2 +- app/proxyman/command/command.pb.go | 2 +- app/proxyman/config.pb.go | 2 +- app/reverse/config.pb.go | 2 +- app/router/balancing.go | 88 ++- app/router/balancing_override.go | 50 ++ app/router/command/command.go | 35 ++ app/router/command/command.pb.go | 575 +++++++++++++++-- app/router/command/command.proto | 31 + app/router/command/command_grpc.pb.go | 78 ++- app/router/command/command_test.go | 2 +- app/router/config.go | 37 +- app/router/config.pb.go | 582 ++++++++++++------ app/router/config.proto | 22 + app/router/router.go | 12 +- app/router/router_test.go | 59 +- app/router/strategy_leastload.go | 200 ++++++ app/router/strategy_leastload_test.go | 179 ++++++ app/router/strategy_leastping.go | 4 + app/router/strategy_random.go | 21 + app/router/weight.go | 89 +++ app/router/weight_test.go | 60 ++ app/stats/command/command.pb.go | 2 +- app/stats/config.pb.go | 2 +- common/log/log.pb.go | 2 +- common/net/address.pb.go | 2 +- common/net/destination.pb.go | 2 +- common/net/network.pb.go | 2 +- common/net/port.pb.go | 2 +- common/protocol/headers.pb.go | 2 +- common/protocol/server_spec.pb.go | 2 +- common/protocol/user.pb.go | 2 +- common/serial/typed_message.pb.go | 2 +- common/session/context.go | 1 + core/config.pb.go | 2 +- features/routing/balancer.go | 10 + infra/conf/api.go | 3 + infra/conf/observatory.go | 20 +- infra/conf/router.go | 44 +- infra/conf/router_strategy.go | 86 +++ infra/conf/router_test.go | 52 ++ infra/conf/xray.go | 9 + main/commands/all/api/api.go | 2 + main/commands/all/api/balancer_info.go | 108 ++++ main/commands/all/api/balancer_override.go | 77 +++ main/commands/all/api/shared.go | 13 +- proxy/blackhole/config.pb.go | 2 +- proxy/dns/config.pb.go | 2 +- proxy/dokodemo/config.pb.go | 2 +- proxy/freedom/config.pb.go | 2 +- proxy/http/config.pb.go | 2 +- proxy/loopback/config.pb.go | 2 +- proxy/shadowsocks/config.pb.go | 2 +- proxy/shadowsocks_2022/config.pb.go | 2 +- proxy/socks/config.pb.go | 2 +- proxy/trojan/config.pb.go | 2 +- proxy/vless/account.pb.go | 2 +- proxy/vless/encoding/addons.pb.go | 2 +- proxy/vless/inbound/config.pb.go | 2 +- proxy/vless/outbound/config.pb.go | 2 +- proxy/vmess/account.pb.go | 2 +- proxy/vmess/inbound/config.pb.go | 2 +- proxy/vmess/outbound/config.pb.go | 2 +- proxy/wireguard/config.pb.go | 2 +- transport/global/config.pb.go | 2 +- transport/internet/config.pb.go | 2 +- transport/internet/domainsocket/config.pb.go | 2 +- transport/internet/grpc/config.pb.go | 2 +- transport/internet/grpc/encoding/stream.pb.go | 2 +- transport/internet/headers/dns/config.pb.go | 2 +- transport/internet/headers/http/config.pb.go | 2 +- transport/internet/headers/noop/config.pb.go | 2 +- transport/internet/headers/srtp/config.pb.go | 2 +- transport/internet/headers/tls/config.pb.go | 2 +- transport/internet/headers/utp/config.pb.go | 2 +- .../internet/headers/wechat/config.pb.go | 2 +- .../internet/headers/wireguard/config.pb.go | 2 +- transport/internet/http/config.pb.go | 2 +- transport/internet/kcp/config.pb.go | 2 +- transport/internet/quic/config.pb.go | 2 +- transport/internet/reality/config.pb.go | 2 +- transport/internet/tcp/config.pb.go | 2 +- transport/internet/tls/config.pb.go | 2 +- transport/internet/udp/config.pb.go | 2 +- transport/internet/websocket/config.pb.go | 2 +- 105 files changed, 3523 insertions(+), 429 deletions(-) create mode 100644 app/observatory/burst/burst.go create mode 100644 app/observatory/burst/burstobserver.go create mode 100644 app/observatory/burst/config.pb.go create mode 100644 app/observatory/burst/config.proto create mode 100644 app/observatory/burst/errors.generated.go create mode 100644 app/observatory/burst/healthping.go create mode 100644 app/observatory/burst/healthping_result.go create mode 100644 app/observatory/burst/healthping_result_test.go create mode 100644 app/observatory/burst/ping.go create mode 100644 app/router/balancing_override.go create mode 100644 app/router/strategy_leastload.go create mode 100644 app/router/strategy_leastload_test.go create mode 100644 app/router/strategy_random.go create mode 100644 app/router/weight.go create mode 100644 app/router/weight_test.go create mode 100644 features/routing/balancer.go create mode 100644 main/commands/all/api/balancer_info.go create mode 100644 main/commands/all/api/balancer_override.go diff --git a/app/commander/config.pb.go b/app/commander/config.pb.go index 32dd608a..2c7b954e 100644 --- a/app/commander/config.pb.go +++ b/app/commander/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/commander/config.proto diff --git a/app/dispatcher/config.pb.go b/app/dispatcher/config.pb.go index 1512f186..cd55bd69 100644 --- a/app/dispatcher/config.pb.go +++ b/app/dispatcher/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/dispatcher/config.proto diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index bfc43608..effa2198 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -230,6 +230,7 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin content = new(session.Content) ctx = session.ContextWithContent(ctx, content) } + sniffingRequest := content.SniffingRequest inbound, outbound := d.getLink(ctx) if !sniffingRequest.Enabled { @@ -366,7 +367,6 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw } return contentResult, contentErr } - func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.Link, destination net.Destination) { ob := session.OutboundFromContext(ctx) if hosts, ok := d.dns.(dns.HostsLookup); ok && destination.Address.Family().IsDomain() { diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index 2d84fe72..51638688 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/dns/config.proto diff --git a/app/dns/fakedns/fakedns.pb.go b/app/dns/fakedns/fakedns.pb.go index dea59f99..c9a09a2c 100644 --- a/app/dns/fakedns/fakedns.pb.go +++ b/app/dns/fakedns/fakedns.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/dns/fakedns/fakedns.proto diff --git a/app/log/command/config.pb.go b/app/log/command/config.pb.go index 21637a8b..258f8cb1 100644 --- a/app/log/command/config.pb.go +++ b/app/log/command/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/log/command/config.proto diff --git a/app/log/config.pb.go b/app/log/config.pb.go index 7829713c..3e981674 100644 --- a/app/log/config.pb.go +++ b/app/log/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/log/config.proto diff --git a/app/metrics/config.pb.go b/app/metrics/config.pb.go index a93bbb64..9bab8d20 100644 --- a/app/metrics/config.pb.go +++ b/app/metrics/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/metrics/config.proto diff --git a/app/observatory/burst/burst.go b/app/observatory/burst/burst.go new file mode 100644 index 00000000..13eb0fd6 --- /dev/null +++ b/app/observatory/burst/burst.go @@ -0,0 +1,14 @@ +package burst + +import ( + "math" + "time" +) + +//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen + +const ( + rttFailed = time.Duration(math.MaxInt64 - iota) + rttUntested + rttUnqualified +) diff --git a/app/observatory/burst/burstobserver.go b/app/observatory/burst/burstobserver.go new file mode 100644 index 00000000..6b7dbc7c --- /dev/null +++ b/app/observatory/burst/burstobserver.go @@ -0,0 +1,108 @@ +package burst + +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/common/signal/done" + "github.com/xtls/xray-core/features/extension" + "github.com/xtls/xray-core/features/outbound" + "google.golang.org/protobuf/proto" + "sync" +) + +type Observer struct { + config *Config + ctx context.Context + + statusLock sync.Mutex + hp *HealthPing + + finished *done.Instance + + ohm outbound.Manager +} + +func (o *Observer) GetObservation(ctx context.Context) (proto.Message, error) { + return &observatory.ObservationResult{Status: o.createResult()}, nil +} + +func (o *Observer) createResult() []*observatory.OutboundStatus { + var result []*observatory.OutboundStatus + o.hp.access.Lock() + defer o.hp.access.Unlock() + for name, value := range o.hp.Results { + status := observatory.OutboundStatus{ + Alive: value.getStatistics().All != value.getStatistics().Fail, + Delay: value.getStatistics().Average.Milliseconds(), + LastErrorReason: "", + OutboundTag: name, + LastSeenTime: 0, + LastTryTime: 0, + HealthPing: &observatory.HealthPingMeasurementResult{ + All: int64(value.getStatistics().All), + Fail: int64(value.getStatistics().Fail), + Deviation: int64(value.getStatistics().Deviation), + Average: int64(value.getStatistics().Average), + Max: int64(value.getStatistics().Max), + Min: int64(value.getStatistics().Min), + }, + } + result = append(result, &status) + } + return result +} + +func (o *Observer) Type() interface{} { + return extension.ObservatoryType() +} + +func (o *Observer) Start() error { + if o.config != nil && len(o.config.SubjectSelector) != 0 { + o.finished = done.New() + o.hp.StartScheduler(func() ([]string, error) { + hs, ok := o.ohm.(outbound.HandlerSelector) + if !ok { + + return nil, newError("outbound.Manager is not a HandlerSelector") + } + + outbounds := hs.Select(o.config.SubjectSelector) + return outbounds, nil + }) + } + return nil +} + +func (o *Observer) Close() error { + if o.finished != nil { + o.hp.StopScheduler() + return o.finished.Close() + } + return nil +} + +func New(ctx context.Context, config *Config) (*Observer, error) { + var outboundManager outbound.Manager + err := core.RequireFeatures(ctx, func(om outbound.Manager) { + outboundManager = om + }) + if err != nil { + return nil, newError("Cannot get depended features").Base(err) + } + hp := NewHealthPing(ctx, config.PingConfig) + return &Observer{ + config: config, + ctx: ctx, + ohm: outboundManager, + hp: hp, + }, nil +} + +func init() { + common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { + return New(ctx, config.(*Config)) + })) +} diff --git a/app/observatory/burst/config.pb.go b/app/observatory/burst/config.pb.go new file mode 100644 index 00000000..ce371583 --- /dev/null +++ b/app/observatory/burst/config.pb.go @@ -0,0 +1,276 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.32.0 +// protoc v4.23.1 +// source: app/observatory/burst/config.proto + +package burst + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Config struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // @Document The selectors for outbound under observation + SubjectSelector []string `protobuf:"bytes,2,rep,name=subject_selector,json=subjectSelector,proto3" json:"subject_selector,omitempty"` + PingConfig *HealthPingConfig `protobuf:"bytes,3,opt,name=ping_config,json=pingConfig,proto3" json:"ping_config,omitempty"` +} + +func (x *Config) Reset() { + *x = Config{} + if protoimpl.UnsafeEnabled { + mi := &file_app_observatory_burst_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Config) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Config) ProtoMessage() {} + +func (x *Config) ProtoReflect() protoreflect.Message { + mi := &file_app_observatory_burst_config_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Config.ProtoReflect.Descriptor instead. +func (*Config) Descriptor() ([]byte, []int) { + return file_app_observatory_burst_config_proto_rawDescGZIP(), []int{0} +} + +func (x *Config) GetSubjectSelector() []string { + if x != nil { + return x.SubjectSelector + } + return nil +} + +func (x *Config) GetPingConfig() *HealthPingConfig { + if x != nil { + return x.PingConfig + } + return nil +} + +type HealthPingConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // destination url, need 204 for success return + // default https://connectivitycheck.gstatic.com/generate_204 + Destination string `protobuf:"bytes,1,opt,name=destination,proto3" json:"destination,omitempty"` + // connectivity check url + Connectivity string `protobuf:"bytes,2,opt,name=connectivity,proto3" json:"connectivity,omitempty"` + // health check interval, int64 values of time.Duration + Interval int64 `protobuf:"varint,3,opt,name=interval,proto3" json:"interval,omitempty"` + // sampling count is the amount of recent ping results which are kept for calculation + SamplingCount int32 `protobuf:"varint,4,opt,name=samplingCount,proto3" json:"samplingCount,omitempty"` + // ping timeout, int64 values of time.Duration + Timeout int64 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` +} + +func (x *HealthPingConfig) Reset() { + *x = HealthPingConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_app_observatory_burst_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HealthPingConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HealthPingConfig) ProtoMessage() {} + +func (x *HealthPingConfig) ProtoReflect() protoreflect.Message { + mi := &file_app_observatory_burst_config_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HealthPingConfig.ProtoReflect.Descriptor instead. +func (*HealthPingConfig) Descriptor() ([]byte, []int) { + return file_app_observatory_burst_config_proto_rawDescGZIP(), []int{1} +} + +func (x *HealthPingConfig) GetDestination() string { + if x != nil { + return x.Destination + } + return "" +} + +func (x *HealthPingConfig) GetConnectivity() string { + if x != nil { + return x.Connectivity + } + return "" +} + +func (x *HealthPingConfig) GetInterval() int64 { + if x != nil { + return x.Interval + } + return 0 +} + +func (x *HealthPingConfig) GetSamplingCount() int32 { + if x != nil { + return x.SamplingCount + } + return 0 +} + +func (x *HealthPingConfig) GetTimeout() int64 { + if x != nil { + return x.Timeout + } + return 0 +} + +var File_app_observatory_burst_config_proto protoreflect.FileDescriptor + +var file_app_observatory_burst_config_proto_rawDesc = []byte{ + 0x0a, 0x22, 0x61, 0x70, 0x70, 0x2f, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, + 0x79, 0x2f, 0x62, 0x75, 0x72, 0x73, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1f, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, + 0x62, 0x75, 0x72, 0x73, 0x74, 0x22, 0x87, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x12, 0x29, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x73, 0x65, 0x6c, 0x65, + 0x63, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x52, 0x0a, 0x0b, 0x70, + 0x69, 0x6e, 0x67, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x31, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x62, 0x75, 0x72, + 0x73, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x52, 0x0a, 0x70, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, + 0xb4, 0x01, 0x0a, 0x10, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, + 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x6f, + 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x24, 0x0a, 0x0d, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x69, + 0x6e, 0x67, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x73, + 0x61, 0x6d, 0x70, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x42, 0x70, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, + 0x72, 0x79, 0x2e, 0x62, 0x75, 0x72, 0x73, 0x74, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, + 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2f, 0x62, 0x75, 0x72, 0x73, 0x74, 0xaa, 0x02, 0x1a, 0x58, 0x72, + 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, + 0x72, 0x79, 0x2e, 0x42, 0x75, 0x72, 0x73, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_app_observatory_burst_config_proto_rawDescOnce sync.Once + file_app_observatory_burst_config_proto_rawDescData = file_app_observatory_burst_config_proto_rawDesc +) + +func file_app_observatory_burst_config_proto_rawDescGZIP() []byte { + file_app_observatory_burst_config_proto_rawDescOnce.Do(func() { + file_app_observatory_burst_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_observatory_burst_config_proto_rawDescData) + }) + return file_app_observatory_burst_config_proto_rawDescData +} + +var file_app_observatory_burst_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_app_observatory_burst_config_proto_goTypes = []interface{}{ + (*Config)(nil), // 0: xray.core.app.observatory.burst.Config + (*HealthPingConfig)(nil), // 1: xray.core.app.observatory.burst.HealthPingConfig +} +var file_app_observatory_burst_config_proto_depIdxs = []int32{ + 1, // 0: xray.core.app.observatory.burst.Config.ping_config:type_name -> xray.core.app.observatory.burst.HealthPingConfig + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_app_observatory_burst_config_proto_init() } +func file_app_observatory_burst_config_proto_init() { + if File_app_observatory_burst_config_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_app_observatory_burst_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Config); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_observatory_burst_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HealthPingConfig); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_app_observatory_burst_config_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_app_observatory_burst_config_proto_goTypes, + DependencyIndexes: file_app_observatory_burst_config_proto_depIdxs, + MessageInfos: file_app_observatory_burst_config_proto_msgTypes, + }.Build() + File_app_observatory_burst_config_proto = out.File + file_app_observatory_burst_config_proto_rawDesc = nil + file_app_observatory_burst_config_proto_goTypes = nil + file_app_observatory_burst_config_proto_depIdxs = nil +} diff --git a/app/observatory/burst/config.proto b/app/observatory/burst/config.proto new file mode 100644 index 00000000..ead75478 --- /dev/null +++ b/app/observatory/burst/config.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; + +package xray.core.app.observatory.burst; +option csharp_namespace = "Xray.App.Observatory.Burst"; +option go_package = "github.com/xtls/xray-core/app/observatory/burst"; +option java_package = "com.xray.app.observatory.burst"; +option java_multiple_files = true; + +message Config { + /* @Document The selectors for outbound under observation + */ + repeated string subject_selector = 2; + + HealthPingConfig ping_config = 3; +} + +message HealthPingConfig { + // destination url, need 204 for success return + // default https://connectivitycheck.gstatic.com/generate_204 + string destination = 1; + // connectivity check url + string connectivity = 2; + // health check interval, int64 values of time.Duration + int64 interval = 3; + // sampling count is the amount of recent ping results which are kept for calculation + int32 samplingCount = 4; + // ping timeout, int64 values of time.Duration + int64 timeout = 5; +} diff --git a/app/observatory/burst/errors.generated.go b/app/observatory/burst/errors.generated.go new file mode 100644 index 00000000..35638eec --- /dev/null +++ b/app/observatory/burst/errors.generated.go @@ -0,0 +1,9 @@ +package burst + +import "github.com/xtls/xray-core/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/app/observatory/burst/healthping.go b/app/observatory/burst/healthping.go new file mode 100644 index 00000000..cde9fbc1 --- /dev/null +++ b/app/observatory/burst/healthping.go @@ -0,0 +1,244 @@ +package burst + +import ( + "context" + "fmt" + "strings" + "sync" + "time" + + "github.com/xtls/xray-core/common/dice" +) + +// HealthPingSettings holds settings for health Checker +type HealthPingSettings struct { + Destination string `json:"destination"` + Connectivity string `json:"connectivity"` + Interval time.Duration `json:"interval"` + SamplingCount int `json:"sampling"` + Timeout time.Duration `json:"timeout"` +} + +// HealthPing is the health checker for balancers +type HealthPing struct { + ctx context.Context + access sync.Mutex + ticker *time.Ticker + tickerClose chan struct{} + + Settings *HealthPingSettings + Results map[string]*HealthPingRTTS +} + +// NewHealthPing creates a new HealthPing with settings +func NewHealthPing(ctx context.Context, config *HealthPingConfig) *HealthPing { + settings := &HealthPingSettings{} + if config != nil { + settings = &HealthPingSettings{ + Connectivity: strings.TrimSpace(config.Connectivity), + Destination: strings.TrimSpace(config.Destination), + Interval: time.Duration(config.Interval), + SamplingCount: int(config.SamplingCount), + Timeout: time.Duration(config.Timeout), + } + } + if settings.Destination == "" { + // Destination URL, need 204 for success return default to chromium + // https://github.com/chromium/chromium/blob/main/components/safety_check/url_constants.cc#L10 + // https://chromium.googlesource.com/chromium/src/+/refs/heads/main/components/safety_check/url_constants.cc#10 + settings.Destination = "https://connectivitycheck.gstatic.com/generate_204" + } + if settings.Interval == 0 { + settings.Interval = time.Duration(1) * time.Minute + } else if settings.Interval < 10 { + newError("health check interval is too small, 10s is applied").AtWarning().WriteToLog() + settings.Interval = time.Duration(10) * time.Second + } + if settings.SamplingCount <= 0 { + settings.SamplingCount = 10 + } + if settings.Timeout <= 0 { + // results are saved after all health pings finish, + // a larger timeout could possibly makes checks run longer + settings.Timeout = time.Duration(5) * time.Second + } + return &HealthPing{ + ctx: ctx, + Settings: settings, + Results: nil, + } +} + +// StartScheduler implements the HealthChecker +func (h *HealthPing) StartScheduler(selector func() ([]string, error)) { + if h.ticker != nil { + return + } + interval := h.Settings.Interval * time.Duration(h.Settings.SamplingCount) + ticker := time.NewTicker(interval) + tickerClose := make(chan struct{}) + h.ticker = ticker + h.tickerClose = tickerClose + go func() { + for { + go func() { + tags, err := selector() + if err != nil { + newError("error select outbounds for scheduled health check: ", err).AtWarning().WriteToLog() + return + } + h.doCheck(tags, interval, h.Settings.SamplingCount) + h.Cleanup(tags) + }() + select { + case <-ticker.C: + continue + case <-tickerClose: + return + } + } + }() +} + +// StopScheduler implements the HealthChecker +func (h *HealthPing) StopScheduler() { + if h.ticker == nil { + return + } + h.ticker.Stop() + h.ticker = nil + close(h.tickerClose) + h.tickerClose = nil +} + +// Check implements the HealthChecker +func (h *HealthPing) Check(tags []string) error { + if len(tags) == 0 { + return nil + } + newError("perform one-time health check for tags ", tags).AtInfo().WriteToLog() + h.doCheck(tags, 0, 1) + return nil +} + +type rtt struct { + handler string + value time.Duration +} + +// doCheck performs the 'rounds' amount checks in given 'duration'. You should make +// sure all tags are valid for current balancer +func (h *HealthPing) doCheck(tags []string, duration time.Duration, rounds int) { + count := len(tags) * rounds + if count == 0 { + return + } + ch := make(chan *rtt, count) + + for _, tag := range tags { + handler := tag + client := newPingClient( + h.ctx, + h.Settings.Destination, + h.Settings.Timeout, + handler, + ) + for i := 0; i < rounds; i++ { + delay := time.Duration(0) + if duration > 0 { + delay = time.Duration(dice.Roll(int(duration))) + } + time.AfterFunc(delay, func() { + newError("checking ", handler).AtDebug().WriteToLog() + delay, err := client.MeasureDelay() + if err == nil { + ch <- &rtt{ + handler: handler, + value: delay, + } + return + } + if !h.checkConnectivity() { + newError("network is down").AtWarning().WriteToLog() + ch <- &rtt{ + handler: handler, + value: 0, + } + return + } + newError(fmt.Sprintf( + "error ping %s with %s: %s", + h.Settings.Destination, + handler, + err, + )).AtWarning().WriteToLog() + ch <- &rtt{ + handler: handler, + value: rttFailed, + } + }) + } + } + for i := 0; i < count; i++ { + rtt := <-ch + if rtt.value > 0 { + // should not put results when network is down + h.PutResult(rtt.handler, rtt.value) + } + } +} + +// PutResult put a ping rtt to results +func (h *HealthPing) PutResult(tag string, rtt time.Duration) { + h.access.Lock() + defer h.access.Unlock() + if h.Results == nil { + h.Results = make(map[string]*HealthPingRTTS) + } + r, ok := h.Results[tag] + if !ok { + // validity is 2 times to sampling period, since the check are + // distributed in the time line randomly, in extreme cases, + // previous checks are distributed on the left, and latters + // on the right + validity := h.Settings.Interval * time.Duration(h.Settings.SamplingCount) * 2 + r = NewHealthPingResult(h.Settings.SamplingCount, validity) + h.Results[tag] = r + } + r.Put(rtt) +} + +// Cleanup removes results of removed handlers, +// tags should be all valid tags of the Balancer now +func (h *HealthPing) Cleanup(tags []string) { + h.access.Lock() + defer h.access.Unlock() + for tag := range h.Results { + found := false + for _, v := range tags { + if tag == v { + found = true + break + } + } + if !found { + delete(h.Results, tag) + } + } +} + +// checkConnectivity checks the network connectivity, it returns +// true if network is good or "connectivity check url" not set +func (h *HealthPing) checkConnectivity() bool { + if h.Settings.Connectivity == "" { + return true + } + tester := newDirectPingClient( + h.Settings.Connectivity, + h.Settings.Timeout, + ) + if _, err := tester.MeasureDelay(); err != nil { + return false + } + return true +} diff --git a/app/observatory/burst/healthping_result.go b/app/observatory/burst/healthping_result.go new file mode 100644 index 00000000..f48d37b6 --- /dev/null +++ b/app/observatory/burst/healthping_result.go @@ -0,0 +1,143 @@ +package burst + +import ( + "math" + "time" +) + +// HealthPingStats is the statistics of HealthPingRTTS +type HealthPingStats struct { + All int + Fail int + Deviation time.Duration + Average time.Duration + Max time.Duration + Min time.Duration +} + +// HealthPingRTTS holds ping rtts for health Checker +type HealthPingRTTS struct { + idx int + cap int + validity time.Duration + rtts []*pingRTT + + lastUpdateAt time.Time + stats *HealthPingStats +} + +type pingRTT struct { + time time.Time + value time.Duration +} + +// NewHealthPingResult returns a *HealthPingResult with specified capacity +func NewHealthPingResult(cap int, validity time.Duration) *HealthPingRTTS { + return &HealthPingRTTS{cap: cap, validity: validity} +} + +// Get gets statistics of the HealthPingRTTS +func (h *HealthPingRTTS) Get() *HealthPingStats { + return h.getStatistics() +} + +// GetWithCache get statistics and write cache for next call +// Make sure use Mutex.Lock() before calling it, RWMutex.RLock() +// is not an option since it writes cache +func (h *HealthPingRTTS) GetWithCache() *HealthPingStats { + lastPutAt := h.rtts[h.idx].time + now := time.Now() + if h.stats == nil || h.lastUpdateAt.Before(lastPutAt) || h.findOutdated(now) >= 0 { + h.stats = h.getStatistics() + h.lastUpdateAt = now + } + return h.stats +} + +// Put puts a new rtt to the HealthPingResult +func (h *HealthPingRTTS) Put(d time.Duration) { + if h.rtts == nil { + h.rtts = make([]*pingRTT, h.cap) + for i := 0; i < h.cap; i++ { + h.rtts[i] = &pingRTT{} + } + h.idx = -1 + } + h.idx = h.calcIndex(1) + now := time.Now() + h.rtts[h.idx].time = now + h.rtts[h.idx].value = d +} + +func (h *HealthPingRTTS) calcIndex(step int) int { + idx := h.idx + idx += step + if idx >= h.cap { + idx %= h.cap + } + return idx +} + +func (h *HealthPingRTTS) getStatistics() *HealthPingStats { + stats := &HealthPingStats{} + stats.Fail = 0 + stats.Max = 0 + stats.Min = rttFailed + sum := time.Duration(0) + cnt := 0 + validRTTs := make([]time.Duration, 0) + for _, rtt := range h.rtts { + switch { + case rtt.value == 0 || time.Since(rtt.time) > h.validity: + continue + case rtt.value == rttFailed: + stats.Fail++ + continue + } + cnt++ + sum += rtt.value + validRTTs = append(validRTTs, rtt.value) + if stats.Max < rtt.value { + stats.Max = rtt.value + } + if stats.Min > rtt.value { + stats.Min = rtt.value + } + } + stats.All = cnt + stats.Fail + if cnt == 0 { + stats.Min = 0 + return stats + } + stats.Average = time.Duration(int(sum) / cnt) + var std float64 + if cnt < 2 { + // no enough data for standard deviation, we assume it's half of the average rtt + // if we don't do this, standard deviation of 1 round tested nodes is 0, will always + // selected before 2 or more rounds tested nodes + std = float64(stats.Average / 2) + } else { + variance := float64(0) + for _, rtt := range validRTTs { + variance += math.Pow(float64(rtt-stats.Average), 2) + } + std = math.Sqrt(variance / float64(cnt)) + } + stats.Deviation = time.Duration(std) + return stats +} + +func (h *HealthPingRTTS) findOutdated(now time.Time) int { + for i := h.cap - 1; i < 2*h.cap; i++ { + // from oldest to latest + idx := h.calcIndex(i) + validity := h.rtts[idx].time.Add(h.validity) + if h.lastUpdateAt.After(validity) { + return idx + } + if validity.Before(now) { + return idx + } + } + return -1 +} diff --git a/app/observatory/burst/healthping_result_test.go b/app/observatory/burst/healthping_result_test.go new file mode 100644 index 00000000..a93e22dd --- /dev/null +++ b/app/observatory/burst/healthping_result_test.go @@ -0,0 +1,106 @@ +package burst_test + +import ( + "math" + reflect "reflect" + "testing" + "time" + + "github.com/xtls/xray-core/app/observatory/burst" +) + +func TestHealthPingResults(t *testing.T) { + rtts := []int64{60, 140, 60, 140, 60, 60, 140, 60, 140} + hr := burst.NewHealthPingResult(4, time.Hour) + for _, rtt := range rtts { + hr.Put(time.Duration(rtt)) + } + rttFailed := time.Duration(math.MaxInt64) + expected := &burst.HealthPingStats{ + All: 4, + Fail: 0, + Deviation: 40, + Average: 100, + Max: 140, + Min: 60, + } + actual := hr.Get() + if !reflect.DeepEqual(expected, actual) { + t.Errorf("expected: %v, actual: %v", expected, actual) + } + hr.Put(rttFailed) + hr.Put(rttFailed) + expected.Fail = 2 + actual = hr.Get() + if !reflect.DeepEqual(expected, actual) { + t.Errorf("failed half-failures test, expected: %v, actual: %v", expected, actual) + } + hr.Put(rttFailed) + hr.Put(rttFailed) + expected = &burst.HealthPingStats{ + All: 4, + Fail: 4, + Deviation: 0, + Average: 0, + Max: 0, + Min: 0, + } + actual = hr.Get() + if !reflect.DeepEqual(expected, actual) { + t.Errorf("failed all-failures test, expected: %v, actual: %v", expected, actual) + } +} + +func TestHealthPingResultsIgnoreOutdated(t *testing.T) { + rtts := []int64{60, 140, 60, 140} + hr := burst.NewHealthPingResult(4, time.Duration(10)*time.Millisecond) + for i, rtt := range rtts { + if i == 2 { + // wait for previous 2 outdated + time.Sleep(time.Duration(10) * time.Millisecond) + } + hr.Put(time.Duration(rtt)) + } + hr.Get() + expected := &burst.HealthPingStats{ + All: 2, + Fail: 0, + Deviation: 40, + Average: 100, + Max: 140, + Min: 60, + } + actual := hr.Get() + if !reflect.DeepEqual(expected, actual) { + t.Errorf("failed 'half-outdated' test, expected: %v, actual: %v", expected, actual) + } + // wait for all outdated + time.Sleep(time.Duration(10) * time.Millisecond) + expected = &burst.HealthPingStats{ + All: 0, + Fail: 0, + Deviation: 0, + Average: 0, + Max: 0, + Min: 0, + } + actual = hr.Get() + if !reflect.DeepEqual(expected, actual) { + t.Errorf("failed 'outdated / not-tested' test, expected: %v, actual: %v", expected, actual) + } + + hr.Put(time.Duration(60)) + expected = &burst.HealthPingStats{ + All: 1, + Fail: 0, + // 1 sample, std=0.5rtt + Deviation: 30, + Average: 60, + Max: 60, + Min: 60, + } + actual = hr.Get() + if !reflect.DeepEqual(expected, actual) { + t.Errorf("expected: %v, actual: %v", expected, actual) + } +} diff --git a/app/observatory/burst/ping.go b/app/observatory/burst/ping.go new file mode 100644 index 00000000..ccc0af68 --- /dev/null +++ b/app/observatory/burst/ping.go @@ -0,0 +1,69 @@ +package burst + +import ( + "context" + "net/http" + "time" + + "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/transport/internet/tagged" +) + +type pingClient struct { + destination string + httpClient *http.Client +} + +func newPingClient(ctx context.Context, destination string, timeout time.Duration, handler string) *pingClient { + return &pingClient{ + destination: destination, + httpClient: newHTTPClient(ctx, handler, timeout), + } +} + +func newDirectPingClient(destination string, timeout time.Duration) *pingClient { + return &pingClient{ + destination: destination, + httpClient: &http.Client{Timeout: timeout}, + } +} + +func newHTTPClient(ctxv context.Context, handler string, timeout time.Duration) *http.Client { + tr := &http.Transport{ + DisableKeepAlives: true, + DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { + dest, err := net.ParseDestination(network + ":" + addr) + if err != nil { + return nil, err + } + return tagged.Dialer(ctxv, dest, handler) + }, + } + return &http.Client{ + Transport: tr, + Timeout: timeout, + // don't follow redirect + CheckRedirect: func(req *http.Request, via []*http.Request) error { + return http.ErrUseLastResponse + }, + } +} + +// MeasureDelay returns the delay time of the request to dest +func (s *pingClient) MeasureDelay() (time.Duration, error) { + if s.httpClient == nil { + panic("pingClient no initialized") + } + req, err := http.NewRequest(http.MethodHead, s.destination, nil) + if err != nil { + return rttFailed, err + } + start := time.Now() + resp, err := s.httpClient.Do(req) + if err != nil { + return rttFailed, err + } + // don't wait for body + resp.Body.Close() + return time.Since(start), nil +} diff --git a/app/observatory/command/command.pb.go b/app/observatory/command/command.pb.go index df531537..abf170c8 100644 --- a/app/observatory/command/command.pb.go +++ b/app/observatory/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/observatory/command/command.proto diff --git a/app/observatory/config.pb.go b/app/observatory/config.pb.go index 43eb7196..708fcf76 100644 --- a/app/observatory/config.pb.go +++ b/app/observatory/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/observatory/config.proto @@ -67,6 +67,93 @@ func (x *ObservationResult) GetStatus() []*OutboundStatus { return nil } +type HealthPingMeasurementResult struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + All int64 `protobuf:"varint,1,opt,name=all,proto3" json:"all,omitempty"` + Fail int64 `protobuf:"varint,2,opt,name=fail,proto3" json:"fail,omitempty"` + Deviation int64 `protobuf:"varint,3,opt,name=deviation,proto3" json:"deviation,omitempty"` + Average int64 `protobuf:"varint,4,opt,name=average,proto3" json:"average,omitempty"` + Max int64 `protobuf:"varint,5,opt,name=max,proto3" json:"max,omitempty"` + Min int64 `protobuf:"varint,6,opt,name=min,proto3" json:"min,omitempty"` +} + +func (x *HealthPingMeasurementResult) Reset() { + *x = HealthPingMeasurementResult{} + if protoimpl.UnsafeEnabled { + mi := &file_app_observatory_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HealthPingMeasurementResult) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HealthPingMeasurementResult) ProtoMessage() {} + +func (x *HealthPingMeasurementResult) ProtoReflect() protoreflect.Message { + mi := &file_app_observatory_config_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HealthPingMeasurementResult.ProtoReflect.Descriptor instead. +func (*HealthPingMeasurementResult) Descriptor() ([]byte, []int) { + return file_app_observatory_config_proto_rawDescGZIP(), []int{1} +} + +func (x *HealthPingMeasurementResult) GetAll() int64 { + if x != nil { + return x.All + } + return 0 +} + +func (x *HealthPingMeasurementResult) GetFail() int64 { + if x != nil { + return x.Fail + } + return 0 +} + +func (x *HealthPingMeasurementResult) GetDeviation() int64 { + if x != nil { + return x.Deviation + } + return 0 +} + +func (x *HealthPingMeasurementResult) GetAverage() int64 { + if x != nil { + return x.Average + } + return 0 +} + +func (x *HealthPingMeasurementResult) GetMax() int64 { + if x != nil { + return x.Max + } + return 0 +} + +func (x *HealthPingMeasurementResult) GetMin() int64 { + if x != nil { + return x.Min + } + return 0 +} + type OutboundStatus struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -90,13 +177,14 @@ type OutboundStatus struct { LastSeenTime int64 `protobuf:"varint,5,opt,name=last_seen_time,json=lastSeenTime,proto3" json:"last_seen_time,omitempty"` // @Document The time this outbound is tried // @Type id.outboundTag - LastTryTime int64 `protobuf:"varint,6,opt,name=last_try_time,json=lastTryTime,proto3" json:"last_try_time,omitempty"` + LastTryTime int64 `protobuf:"varint,6,opt,name=last_try_time,json=lastTryTime,proto3" json:"last_try_time,omitempty"` + HealthPing *HealthPingMeasurementResult `protobuf:"bytes,7,opt,name=health_ping,json=healthPing,proto3" json:"health_ping,omitempty"` } func (x *OutboundStatus) Reset() { *x = OutboundStatus{} if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_config_proto_msgTypes[1] + mi := &file_app_observatory_config_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -109,7 +197,7 @@ func (x *OutboundStatus) String() string { func (*OutboundStatus) ProtoMessage() {} func (x *OutboundStatus) ProtoReflect() protoreflect.Message { - mi := &file_app_observatory_config_proto_msgTypes[1] + mi := &file_app_observatory_config_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -122,7 +210,7 @@ func (x *OutboundStatus) ProtoReflect() protoreflect.Message { // Deprecated: Use OutboundStatus.ProtoReflect.Descriptor instead. func (*OutboundStatus) Descriptor() ([]byte, []int) { - return file_app_observatory_config_proto_rawDescGZIP(), []int{1} + return file_app_observatory_config_proto_rawDescGZIP(), []int{2} } func (x *OutboundStatus) GetAlive() bool { @@ -167,6 +255,13 @@ func (x *OutboundStatus) GetLastTryTime() int64 { return 0 } +func (x *OutboundStatus) GetHealthPing() *HealthPingMeasurementResult { + if x != nil { + return x.HealthPing + } + return nil +} + type ProbeResult struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -187,7 +282,7 @@ type ProbeResult struct { func (x *ProbeResult) Reset() { *x = ProbeResult{} if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_config_proto_msgTypes[2] + mi := &file_app_observatory_config_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -200,7 +295,7 @@ func (x *ProbeResult) String() string { func (*ProbeResult) ProtoMessage() {} func (x *ProbeResult) ProtoReflect() protoreflect.Message { - mi := &file_app_observatory_config_proto_msgTypes[2] + mi := &file_app_observatory_config_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -213,7 +308,7 @@ func (x *ProbeResult) ProtoReflect() protoreflect.Message { // Deprecated: Use ProbeResult.ProtoReflect.Descriptor instead. func (*ProbeResult) Descriptor() ([]byte, []int) { - return file_app_observatory_config_proto_rawDescGZIP(), []int{2} + return file_app_observatory_config_proto_rawDescGZIP(), []int{3} } func (x *ProbeResult) GetAlive() bool { @@ -250,7 +345,7 @@ type Intensity struct { func (x *Intensity) Reset() { *x = Intensity{} if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_config_proto_msgTypes[3] + mi := &file_app_observatory_config_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -263,7 +358,7 @@ func (x *Intensity) String() string { func (*Intensity) ProtoMessage() {} func (x *Intensity) ProtoReflect() protoreflect.Message { - mi := &file_app_observatory_config_proto_msgTypes[3] + mi := &file_app_observatory_config_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -276,7 +371,7 @@ func (x *Intensity) ProtoReflect() protoreflect.Message { // Deprecated: Use Intensity.ProtoReflect.Descriptor instead. func (*Intensity) Descriptor() ([]byte, []int) { - return file_app_observatory_config_proto_rawDescGZIP(), []int{3} + return file_app_observatory_config_proto_rawDescGZIP(), []int{4} } func (x *Intensity) GetProbeInterval() uint32 { @@ -301,7 +396,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_config_proto_msgTypes[4] + mi := &file_app_observatory_config_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -314,7 +409,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_app_observatory_config_proto_msgTypes[4] + mi := &file_app_observatory_config_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -327,7 +422,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_app_observatory_config_proto_rawDescGZIP(), []int{4} + return file_app_observatory_config_proto_rawDescGZIP(), []int{5} } func (x *Config) GetSubjectSelector() []string { @@ -370,47 +465,62 @@ var file_app_observatory_config_proto_rawDesc = []byte{ 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x22, 0xd5, 0x01, 0x0a, 0x0e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x05, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, - 0x6c, 0x61, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, - 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x72, - 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x61, 0x73, - 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, - 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x12, - 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x65, 0x6e, 0x5f, 0x74, 0x69, 0x6d, - 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, 0x65, 0x65, - 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x74, 0x72, - 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x6c, 0x61, - 0x73, 0x74, 0x54, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x65, 0x0a, 0x0b, 0x50, 0x72, 0x6f, - 0x62, 0x65, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x76, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x64, - 0x65, 0x6c, 0x61, 0x79, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x65, 0x72, 0x72, - 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0f, 0x6c, 0x61, 0x73, 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, - 0x22, 0x32, 0x0a, 0x09, 0x49, 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x12, 0x25, 0x0a, - 0x0e, 0x70, 0x72, 0x6f, 0x62, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x62, 0x65, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x76, 0x61, 0x6c, 0x22, 0xa6, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, - 0x29, 0x0a, 0x10, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, - 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, - 0x63, 0x74, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x72, - 0x6f, 0x62, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, - 0x72, 0x6f, 0x62, 0x65, 0x55, 0x72, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x62, 0x65, - 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x0d, 0x70, 0x72, 0x6f, 0x62, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x2d, - 0x0a, 0x12, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x63, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x65, 0x6e, 0x61, 0x62, - 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x42, 0x5e, 0x0a, - 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, - 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6f, 0x62, 0x73, 0x65, 0x72, - 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0xaa, 0x02, 0x14, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, - 0x70, 0x2e, 0x4f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x22, 0x9f, 0x01, 0x0a, 0x1b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x50, 0x69, 0x6e, 0x67, + 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x6c, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, + 0x61, 0x6c, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x04, 0x66, 0x61, 0x69, 0x6c, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x65, 0x76, 0x69, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x64, 0x65, 0x76, 0x69, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x61, 0x76, 0x65, 0x72, 0x61, 0x67, 0x65, 0x12, + 0x10, 0x0a, 0x03, 0x6d, 0x61, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6d, 0x61, + 0x78, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x69, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, + 0x6d, 0x69, 0x6e, 0x22, 0xae, 0x02, 0x0a, 0x0e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x64, 0x65, 0x6c, + 0x61, 0x79, 0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, + 0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, + 0x61, 0x73, 0x74, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x21, + 0x0a, 0x0c, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, + 0x67, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x65, 0x6e, 0x5f, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6c, 0x61, 0x73, 0x74, 0x53, + 0x65, 0x65, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x6c, 0x61, 0x73, 0x74, 0x5f, + 0x74, 0x72, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, + 0x6c, 0x61, 0x73, 0x74, 0x54, 0x72, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x57, 0x0a, 0x0b, 0x68, + 0x65, 0x61, 0x6c, 0x74, 0x68, 0x5f, 0x70, 0x69, 0x6e, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x36, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x48, 0x65, 0x61, + 0x6c, 0x74, 0x68, 0x50, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x6d, 0x65, + 0x6e, 0x74, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x0a, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, + 0x50, 0x69, 0x6e, 0x67, 0x22, 0x65, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x62, 0x65, 0x52, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x05, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, 0x6c, + 0x61, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x12, + 0x2a, 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x72, 0x65, + 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x61, 0x73, 0x74, + 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x22, 0x32, 0x0a, 0x09, 0x49, + 0x6e, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x74, 0x79, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x62, + 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x62, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x22, + 0xa6, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x29, 0x0a, 0x10, 0x73, 0x75, + 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x75, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x53, 0x65, 0x6c, + 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x62, 0x65, 0x5f, 0x75, + 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x62, 0x65, 0x55, + 0x72, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x62, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x76, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x62, + 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x2d, 0x0a, 0x12, 0x65, 0x6e, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x6f, 0x6e, + 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x42, 0x5e, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, + 0x74, 0x6f, 0x72, 0x79, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, + 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, + 0x79, 0xaa, 0x02, 0x14, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4f, 0x62, 0x73, + 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -425,21 +535,23 @@ func file_app_observatory_config_proto_rawDescGZIP() []byte { return file_app_observatory_config_proto_rawDescData } -var file_app_observatory_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_app_observatory_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_app_observatory_config_proto_goTypes = []interface{}{ - (*ObservationResult)(nil), // 0: xray.core.app.observatory.ObservationResult - (*OutboundStatus)(nil), // 1: xray.core.app.observatory.OutboundStatus - (*ProbeResult)(nil), // 2: xray.core.app.observatory.ProbeResult - (*Intensity)(nil), // 3: xray.core.app.observatory.Intensity - (*Config)(nil), // 4: xray.core.app.observatory.Config + (*ObservationResult)(nil), // 0: xray.core.app.observatory.ObservationResult + (*HealthPingMeasurementResult)(nil), // 1: xray.core.app.observatory.HealthPingMeasurementResult + (*OutboundStatus)(nil), // 2: xray.core.app.observatory.OutboundStatus + (*ProbeResult)(nil), // 3: xray.core.app.observatory.ProbeResult + (*Intensity)(nil), // 4: xray.core.app.observatory.Intensity + (*Config)(nil), // 5: xray.core.app.observatory.Config } var file_app_observatory_config_proto_depIdxs = []int32{ - 1, // 0: xray.core.app.observatory.ObservationResult.status:type_name -> xray.core.app.observatory.OutboundStatus - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 2, // 0: xray.core.app.observatory.ObservationResult.status:type_name -> xray.core.app.observatory.OutboundStatus + 1, // 1: xray.core.app.observatory.OutboundStatus.health_ping:type_name -> xray.core.app.observatory.HealthPingMeasurementResult + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_app_observatory_config_proto_init() } @@ -461,7 +573,7 @@ func file_app_observatory_config_proto_init() { } } file_app_observatory_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*OutboundStatus); i { + switch v := v.(*HealthPingMeasurementResult); i { case 0: return &v.state case 1: @@ -473,7 +585,7 @@ func file_app_observatory_config_proto_init() { } } file_app_observatory_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*ProbeResult); i { + switch v := v.(*OutboundStatus); i { case 0: return &v.state case 1: @@ -485,7 +597,7 @@ func file_app_observatory_config_proto_init() { } } file_app_observatory_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Intensity); i { + switch v := v.(*ProbeResult); i { case 0: return &v.state case 1: @@ -497,6 +609,18 @@ func file_app_observatory_config_proto_init() { } } file_app_observatory_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Intensity); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_observatory_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Config); i { case 0: return &v.state @@ -515,7 +639,7 @@ func file_app_observatory_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_observatory_config_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/app/observatory/config.proto b/app/observatory/config.proto index 9ac9c549..fbfabad6 100644 --- a/app/observatory/config.proto +++ b/app/observatory/config.proto @@ -10,6 +10,15 @@ message ObservationResult { repeated OutboundStatus status = 1; } +message HealthPingMeasurementResult { + int64 all = 1; + int64 fail = 2; + int64 deviation = 3; + int64 average = 4; + int64 max = 5; + int64 min = 6; +} + message OutboundStatus{ /* @Document Whether this outbound is usable @Restriction ReadOnlyForUser @@ -36,6 +45,8 @@ message OutboundStatus{ @Type id.outboundTag */ int64 last_try_time = 6; + + HealthPingMeasurementResult health_ping = 7; } message ProbeResult{ diff --git a/app/policy/config.pb.go b/app/policy/config.pb.go index c8b4311c..0bfef971 100644 --- a/app/policy/config.pb.go +++ b/app/policy/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/policy/config.proto diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index 458179e5..a689a808 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/proxyman/command/command.proto diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index db41ad75..541679ac 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/proxyman/config.proto diff --git a/app/reverse/config.pb.go b/app/reverse/config.pb.go index 83c0709b..c262f47a 100644 --- a/app/reverse/config.pb.go +++ b/app/reverse/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/reverse/config.proto diff --git a/app/router/balancing.go b/app/router/balancing.go index 458e6838..7eb8c5a8 100644 --- a/app/router/balancing.go +++ b/app/router/balancing.go @@ -4,7 +4,6 @@ import ( "context" sync "sync" - "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/features/extension" "github.com/xtls/xray-core/features/outbound" ) @@ -13,15 +12,8 @@ type BalancingStrategy interface { PickOutbound([]string) string } -type RandomStrategy struct{} - -func (s *RandomStrategy) PickOutbound(tags []string) string { - n := len(tags) - if n == 0 { - panic("0 tags") - } - - return tags[dice.Roll(n)] +type BalancingPrincipleTarget interface { + GetPrincipleTarget([]string) []string } type RoundRobinStrategy struct { @@ -43,22 +35,36 @@ func (s *RoundRobinStrategy) PickOutbound(tags []string) string { } type Balancer struct { - selectors []string - strategy BalancingStrategy - ohm outbound.Manager + selectors []string + strategy BalancingStrategy + ohm outbound.Manager + fallbackTag string + + override override } +// PickOutbound picks the tag of a outbound func (b *Balancer) PickOutbound() (string, error) { - hs, ok := b.ohm.(outbound.HandlerSelector) - if !ok { - return "", newError("outbound.Manager is not a HandlerSelector") + candidates, err := b.SelectOutbounds() + if err != nil { + if b.fallbackTag != "" { + newError("fallback to [", b.fallbackTag, "], due to error: ", err).AtInfo().WriteToLog() + return b.fallbackTag, nil + } + return "", err } - tags := hs.Select(b.selectors) - if len(tags) == 0 { - return "", newError("no available outbounds selected") + var tag string + if o := b.override.Get(); o != "" { + tag = o + } else { + tag = b.strategy.PickOutbound(candidates) } - tag := b.strategy.PickOutbound(tags) if tag == "" { + if b.fallbackTag != "" { + newError("fallback to [", b.fallbackTag, "], due to empty tag returned").AtInfo().WriteToLog() + return b.fallbackTag, nil + } + // will use default handler return "", newError("balancing strategy returns empty tag") } return tag, nil @@ -69,3 +75,45 @@ func (b *Balancer) InjectContext(ctx context.Context) { contextReceiver.InjectContext(ctx) } } + +// SelectOutbounds select outbounds with selectors of the Balancer +func (b *Balancer) SelectOutbounds() ([]string, error) { + hs, ok := b.ohm.(outbound.HandlerSelector) + if !ok { + return nil, newError("outbound.Manager is not a HandlerSelector") + } + tags := hs.Select(b.selectors) + return tags, nil +} + +// GetPrincipleTarget implements routing.BalancerPrincipleTarget +func (r *Router) GetPrincipleTarget(tag string) ([]string, error) { + if b, ok := r.balancers[tag]; ok { + if s, ok := b.strategy.(BalancingPrincipleTarget); ok { + candidates, err := b.SelectOutbounds() + if err != nil { + return nil, newError("unable to select outbounds").Base(err) + } + return s.GetPrincipleTarget(candidates), nil + } + return nil, newError("unsupported GetPrincipleTarget") + } + return nil, newError("cannot find tag") +} + +// SetOverrideTarget implements routing.BalancerOverrider +func (r *Router) SetOverrideTarget(tag, target string) error { + if b, ok := r.balancers[tag]; ok { + b.override.Put(target) + return nil + } + return newError("cannot find tag") +} + +// GetOverrideTarget implements routing.BalancerOverrider +func (r *Router) GetOverrideTarget(tag string) (string, error) { + if b, ok := r.balancers[tag]; ok { + return b.override.Get(), nil + } + return "", newError("cannot find tag") +} diff --git a/app/router/balancing_override.go b/app/router/balancing_override.go new file mode 100644 index 00000000..30769f6b --- /dev/null +++ b/app/router/balancing_override.go @@ -0,0 +1,50 @@ +package router + +import ( + sync "sync" +) + +func (r *Router) OverrideBalancer(balancer string, target string) error { + var b *Balancer + for tag, bl := range r.balancers { + if tag == balancer { + b = bl + break + } + } + if b == nil { + return newError("balancer '", balancer, "' not found") + } + b.override.Put(target) + return nil +} + +type overrideSettings struct { + target string +} + +type override struct { + access sync.RWMutex + settings overrideSettings +} + +// Get gets the override settings +func (o *override) Get() string { + o.access.RLock() + defer o.access.RUnlock() + return o.settings.target +} + +// Put updates the override settings +func (o *override) Put(target string) { + o.access.Lock() + defer o.access.Unlock() + o.settings.target = target +} + +// Clear clears the override settings +func (o *override) Clear() { + o.access.Lock() + defer o.access.Unlock() + o.settings.target = "" +} diff --git a/app/router/command/command.go b/app/router/command/command.go index 58981056..60458f14 100644 --- a/app/router/command/command.go +++ b/app/router/command/command.go @@ -19,6 +19,41 @@ type routingServer struct { routingStats stats.Channel } +func (s *routingServer) GetBalancerInfo(ctx context.Context, request *GetBalancerInfoRequest) (*GetBalancerInfoResponse, error) { + var ret GetBalancerInfoResponse + ret.Balancer = &BalancerMsg{} + if bo, ok := s.router.(routing.BalancerOverrider); ok { + { + res, err := bo.GetOverrideTarget(request.GetTag()) + if err != nil { + return nil, err + } + ret.Balancer.Override = &OverrideInfo{ + Target: res, + } + } + } + + if pt, ok := s.router.(routing.BalancerPrincipleTarget); ok { + { + res, err := pt.GetPrincipleTarget(request.GetTag()) + if err != nil { + newError("unable to obtain principle target").Base(err).AtInfo().WriteToLog() + } else { + ret.Balancer.PrincipleTarget = &PrincipleTargetInfo{Tag: res} + } + } + } + return &ret, nil +} + +func (s *routingServer) OverrideBalancerTarget(ctx context.Context, request *OverrideBalancerTargetRequest) (*OverrideBalancerTargetResponse, error) { + if bo, ok := s.router.(routing.BalancerOverrider); ok { + return &OverrideBalancerTargetResponse{}, bo.SetOverrideTarget(request.BalancerTag, request.Target) + } + return nil, newError("unsupported router implementation") +} + // NewRoutingServer creates a statistics service with statistics manager. func NewRoutingServer(router routing.Router, routingStats stats.Channel) RoutingServiceServer { return &routingServer{ diff --git a/app/router/command/command.pb.go b/app/router/command/command.pb.go index 18296ff9..5cdf5332 100644 --- a/app/router/command/command.pb.go +++ b/app/router/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/router/command/command.proto @@ -294,6 +294,342 @@ func (x *TestRouteRequest) GetPublishResult() bool { return false } +type PrincipleTargetInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tag []string `protobuf:"bytes,1,rep,name=tag,proto3" json:"tag,omitempty"` +} + +func (x *PrincipleTargetInfo) Reset() { + *x = PrincipleTargetInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PrincipleTargetInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PrincipleTargetInfo) ProtoMessage() {} + +func (x *PrincipleTargetInfo) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PrincipleTargetInfo.ProtoReflect.Descriptor instead. +func (*PrincipleTargetInfo) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{3} +} + +func (x *PrincipleTargetInfo) GetTag() []string { + if x != nil { + return x.Tag + } + return nil +} + +type OverrideInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Target string `protobuf:"bytes,2,opt,name=target,proto3" json:"target,omitempty"` +} + +func (x *OverrideInfo) Reset() { + *x = OverrideInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OverrideInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OverrideInfo) ProtoMessage() {} + +func (x *OverrideInfo) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OverrideInfo.ProtoReflect.Descriptor instead. +func (*OverrideInfo) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{4} +} + +func (x *OverrideInfo) GetTarget() string { + if x != nil { + return x.Target + } + return "" +} + +type BalancerMsg struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Override *OverrideInfo `protobuf:"bytes,5,opt,name=override,proto3" json:"override,omitempty"` + PrincipleTarget *PrincipleTargetInfo `protobuf:"bytes,6,opt,name=principle_target,json=principleTarget,proto3" json:"principle_target,omitempty"` +} + +func (x *BalancerMsg) Reset() { + *x = BalancerMsg{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BalancerMsg) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BalancerMsg) ProtoMessage() {} + +func (x *BalancerMsg) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BalancerMsg.ProtoReflect.Descriptor instead. +func (*BalancerMsg) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{5} +} + +func (x *BalancerMsg) GetOverride() *OverrideInfo { + if x != nil { + return x.Override + } + return nil +} + +func (x *BalancerMsg) GetPrincipleTarget() *PrincipleTargetInfo { + if x != nil { + return x.PrincipleTarget + } + return nil +} + +type GetBalancerInfoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` +} + +func (x *GetBalancerInfoRequest) Reset() { + *x = GetBalancerInfoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBalancerInfoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBalancerInfoRequest) ProtoMessage() {} + +func (x *GetBalancerInfoRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBalancerInfoRequest.ProtoReflect.Descriptor instead. +func (*GetBalancerInfoRequest) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{6} +} + +func (x *GetBalancerInfoRequest) GetTag() string { + if x != nil { + return x.Tag + } + return "" +} + +type GetBalancerInfoResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Balancer *BalancerMsg `protobuf:"bytes,1,opt,name=balancer,proto3" json:"balancer,omitempty"` +} + +func (x *GetBalancerInfoResponse) Reset() { + *x = GetBalancerInfoResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetBalancerInfoResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetBalancerInfoResponse) ProtoMessage() {} + +func (x *GetBalancerInfoResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetBalancerInfoResponse.ProtoReflect.Descriptor instead. +func (*GetBalancerInfoResponse) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{7} +} + +func (x *GetBalancerInfoResponse) GetBalancer() *BalancerMsg { + if x != nil { + return x.Balancer + } + return nil +} + +type OverrideBalancerTargetRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BalancerTag string `protobuf:"bytes,1,opt,name=balancerTag,proto3" json:"balancerTag,omitempty"` + Target string `protobuf:"bytes,2,opt,name=target,proto3" json:"target,omitempty"` +} + +func (x *OverrideBalancerTargetRequest) Reset() { + *x = OverrideBalancerTargetRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OverrideBalancerTargetRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OverrideBalancerTargetRequest) ProtoMessage() {} + +func (x *OverrideBalancerTargetRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OverrideBalancerTargetRequest.ProtoReflect.Descriptor instead. +func (*OverrideBalancerTargetRequest) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{8} +} + +func (x *OverrideBalancerTargetRequest) GetBalancerTag() string { + if x != nil { + return x.BalancerTag + } + return "" +} + +func (x *OverrideBalancerTargetRequest) GetTarget() string { + if x != nil { + return x.Target + } + return "" +} + +type OverrideBalancerTargetResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *OverrideBalancerTargetResponse) Reset() { + *x = OverrideBalancerTargetResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OverrideBalancerTargetResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OverrideBalancerTargetResponse) ProtoMessage() {} + +func (x *OverrideBalancerTargetResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OverrideBalancerTargetResponse.ProtoReflect.Descriptor instead. +func (*OverrideBalancerTargetResponse) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{9} +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -303,7 +639,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[3] + mi := &file_app_router_command_command_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -316,7 +652,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_app_router_command_command_proto_msgTypes[3] + mi := &file_app_router_command_command_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -329,7 +665,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_app_router_command_command_proto_rawDescGZIP(), []int{3} + return file_app_router_command_command_proto_rawDescGZIP(), []int{10} } var File_app_router_command_command_proto protoreflect.FileDescriptor @@ -390,29 +726,78 @@ var file_app_router_command_command_proto_rawDesc = []byte{ 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xf0, 0x01, 0x0a, 0x0e, 0x52, - 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7b, 0x0a, - 0x15, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, - 0x67, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x35, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x22, 0x27, 0x0a, 0x13, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x6c, 0x65, 0x54, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x26, 0x0a, 0x0c, 0x4f, 0x76, 0x65, + 0x72, 0x72, 0x69, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x22, 0xa9, 0x01, 0x0a, 0x0b, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x4d, 0x73, + 0x67, 0x12, 0x41, 0x0a, 0x08, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, + 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4f, 0x76, + 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6f, 0x76, 0x65, 0x72, + 0x72, 0x69, 0x64, 0x65, 0x12, 0x57, 0x0a, 0x10, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x6c, + 0x65, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, + 0x6c, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0f, 0x70, 0x72, + 0x69, 0x6e, 0x63, 0x69, 0x70, 0x6c, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0x2a, 0x0a, + 0x16, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x5b, 0x0a, 0x17, 0x47, 0x65, 0x74, + 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, - 0x67, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, - 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x00, 0x30, 0x01, 0x12, 0x61, 0x0a, 0x09, 0x54, 0x65, - 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, - 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, - 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75, - 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x00, 0x42, 0x67, 0x0a, - 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, - 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2c, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, - 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, - 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x17, 0x58, - 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x4d, 0x73, 0x67, 0x52, 0x08, 0x62, 0x61, + 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x22, 0x59, 0x0a, 0x1d, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, + 0x64, 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x61, 0x6c, 0x61, 0x6e, + 0x63, 0x65, 0x72, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x62, 0x61, + 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x22, 0x20, 0x0a, 0x1e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x42, 0x61, 0x6c, + 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xf6, 0x03, + 0x0a, 0x0e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x7b, 0x0a, 0x15, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, + 0x74, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x35, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, + 0x74, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, + 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, + 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x00, 0x30, 0x01, 0x12, 0x61, 0x0a, + 0x09, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x29, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, + 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x00, + 0x12, 0x76, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, + 0x6e, 0x66, 0x6f, 0x12, 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, + 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, + 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, + 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x8b, 0x01, 0x0a, 0x16, 0x4f, 0x76, 0x65, + 0x72, 0x72, 0x69, 0x64, 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x12, 0x36, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, + 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4f, 0x76, + 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x42, 0x61, + 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, + 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, + 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -427,28 +812,42 @@ func file_app_router_command_command_proto_rawDescGZIP() []byte { return file_app_router_command_command_proto_rawDescData } -var file_app_router_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_app_router_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 12) var file_app_router_command_command_proto_goTypes = []interface{}{ - (*RoutingContext)(nil), // 0: xray.app.router.command.RoutingContext - (*SubscribeRoutingStatsRequest)(nil), // 1: xray.app.router.command.SubscribeRoutingStatsRequest - (*TestRouteRequest)(nil), // 2: xray.app.router.command.TestRouteRequest - (*Config)(nil), // 3: xray.app.router.command.Config - nil, // 4: xray.app.router.command.RoutingContext.AttributesEntry - (net.Network)(0), // 5: xray.common.net.Network + (*RoutingContext)(nil), // 0: xray.app.router.command.RoutingContext + (*SubscribeRoutingStatsRequest)(nil), // 1: xray.app.router.command.SubscribeRoutingStatsRequest + (*TestRouteRequest)(nil), // 2: xray.app.router.command.TestRouteRequest + (*PrincipleTargetInfo)(nil), // 3: xray.app.router.command.PrincipleTargetInfo + (*OverrideInfo)(nil), // 4: xray.app.router.command.OverrideInfo + (*BalancerMsg)(nil), // 5: xray.app.router.command.BalancerMsg + (*GetBalancerInfoRequest)(nil), // 6: xray.app.router.command.GetBalancerInfoRequest + (*GetBalancerInfoResponse)(nil), // 7: xray.app.router.command.GetBalancerInfoResponse + (*OverrideBalancerTargetRequest)(nil), // 8: xray.app.router.command.OverrideBalancerTargetRequest + (*OverrideBalancerTargetResponse)(nil), // 9: xray.app.router.command.OverrideBalancerTargetResponse + (*Config)(nil), // 10: xray.app.router.command.Config + nil, // 11: xray.app.router.command.RoutingContext.AttributesEntry + (net.Network)(0), // 12: xray.common.net.Network } var file_app_router_command_command_proto_depIdxs = []int32{ - 5, // 0: xray.app.router.command.RoutingContext.Network:type_name -> xray.common.net.Network - 4, // 1: xray.app.router.command.RoutingContext.Attributes:type_name -> xray.app.router.command.RoutingContext.AttributesEntry - 0, // 2: xray.app.router.command.TestRouteRequest.RoutingContext:type_name -> xray.app.router.command.RoutingContext - 1, // 3: xray.app.router.command.RoutingService.SubscribeRoutingStats:input_type -> xray.app.router.command.SubscribeRoutingStatsRequest - 2, // 4: xray.app.router.command.RoutingService.TestRoute:input_type -> xray.app.router.command.TestRouteRequest - 0, // 5: xray.app.router.command.RoutingService.SubscribeRoutingStats:output_type -> xray.app.router.command.RoutingContext - 0, // 6: xray.app.router.command.RoutingService.TestRoute:output_type -> xray.app.router.command.RoutingContext - 5, // [5:7] is the sub-list for method output_type - 3, // [3:5] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 12, // 0: xray.app.router.command.RoutingContext.Network:type_name -> xray.common.net.Network + 11, // 1: xray.app.router.command.RoutingContext.Attributes:type_name -> xray.app.router.command.RoutingContext.AttributesEntry + 0, // 2: xray.app.router.command.TestRouteRequest.RoutingContext:type_name -> xray.app.router.command.RoutingContext + 4, // 3: xray.app.router.command.BalancerMsg.override:type_name -> xray.app.router.command.OverrideInfo + 3, // 4: xray.app.router.command.BalancerMsg.principle_target:type_name -> xray.app.router.command.PrincipleTargetInfo + 5, // 5: xray.app.router.command.GetBalancerInfoResponse.balancer:type_name -> xray.app.router.command.BalancerMsg + 1, // 6: xray.app.router.command.RoutingService.SubscribeRoutingStats:input_type -> xray.app.router.command.SubscribeRoutingStatsRequest + 2, // 7: xray.app.router.command.RoutingService.TestRoute:input_type -> xray.app.router.command.TestRouteRequest + 6, // 8: xray.app.router.command.RoutingService.GetBalancerInfo:input_type -> xray.app.router.command.GetBalancerInfoRequest + 8, // 9: xray.app.router.command.RoutingService.OverrideBalancerTarget:input_type -> xray.app.router.command.OverrideBalancerTargetRequest + 0, // 10: xray.app.router.command.RoutingService.SubscribeRoutingStats:output_type -> xray.app.router.command.RoutingContext + 0, // 11: xray.app.router.command.RoutingService.TestRoute:output_type -> xray.app.router.command.RoutingContext + 7, // 12: xray.app.router.command.RoutingService.GetBalancerInfo:output_type -> xray.app.router.command.GetBalancerInfoResponse + 9, // 13: xray.app.router.command.RoutingService.OverrideBalancerTarget:output_type -> xray.app.router.command.OverrideBalancerTargetResponse + 10, // [10:14] is the sub-list for method output_type + 6, // [6:10] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_app_router_command_command_proto_init() } @@ -494,6 +893,90 @@ func file_app_router_command_command_proto_init() { } } file_app_router_command_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PrincipleTargetInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OverrideInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*BalancerMsg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBalancerInfoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetBalancerInfoResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OverrideBalancerTargetRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OverrideBalancerTargetResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Config); i { case 0: return &v.state @@ -512,7 +995,7 @@ func file_app_router_command_command_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_router_command_command_proto_rawDesc, NumEnums: 0, - NumMessages: 5, + NumMessages: 12, NumExtensions: 0, NumServices: 1, }, diff --git a/app/router/command/command.proto b/app/router/command/command.proto index 5f777044..ebf8610e 100644 --- a/app/router/command/command.proto +++ b/app/router/command/command.proto @@ -60,10 +60,41 @@ message TestRouteRequest { bool PublishResult = 3; } +message PrincipleTargetInfo { + repeated string tag = 1; +} + +message OverrideInfo { + string target = 2; +} + +message BalancerMsg { + OverrideInfo override = 5; + PrincipleTargetInfo principle_target = 6; +} + +message GetBalancerInfoRequest { + string tag = 1; +} + +message GetBalancerInfoResponse { + BalancerMsg balancer = 1; +} + +message OverrideBalancerTargetRequest { + string balancerTag = 1; + string target = 2; +} + +message OverrideBalancerTargetResponse {} + service RoutingService { rpc SubscribeRoutingStats(SubscribeRoutingStatsRequest) returns (stream RoutingContext) {} rpc TestRoute(TestRouteRequest) returns (RoutingContext) {} + + rpc GetBalancerInfo(GetBalancerInfoRequest) returns (GetBalancerInfoResponse){} + rpc OverrideBalancerTarget(OverrideBalancerTargetRequest) returns (OverrideBalancerTargetResponse) {} } message Config {} diff --git a/app/router/command/command_grpc.pb.go b/app/router/command/command_grpc.pb.go index 4d3b4ab4..5710ec2b 100644 --- a/app/router/command/command_grpc.pb.go +++ b/app/router/command/command_grpc.pb.go @@ -19,8 +19,10 @@ import ( const _ = grpc.SupportPackageIsVersion7 const ( - RoutingService_SubscribeRoutingStats_FullMethodName = "/xray.app.router.command.RoutingService/SubscribeRoutingStats" - RoutingService_TestRoute_FullMethodName = "/xray.app.router.command.RoutingService/TestRoute" + RoutingService_SubscribeRoutingStats_FullMethodName = "/xray.app.router.command.RoutingService/SubscribeRoutingStats" + RoutingService_TestRoute_FullMethodName = "/xray.app.router.command.RoutingService/TestRoute" + RoutingService_GetBalancerInfo_FullMethodName = "/xray.app.router.command.RoutingService/GetBalancerInfo" + RoutingService_OverrideBalancerTarget_FullMethodName = "/xray.app.router.command.RoutingService/OverrideBalancerTarget" ) // RoutingServiceClient is the client API for RoutingService service. @@ -29,6 +31,8 @@ const ( type RoutingServiceClient interface { SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error) TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error) + GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error) + OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error) } type routingServiceClient struct { @@ -80,12 +84,32 @@ func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteReque return out, nil } +func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error) { + out := new(GetBalancerInfoResponse) + err := c.cc.Invoke(ctx, RoutingService_GetBalancerInfo_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *routingServiceClient) OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error) { + out := new(OverrideBalancerTargetResponse) + err := c.cc.Invoke(ctx, RoutingService_OverrideBalancerTarget_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // RoutingServiceServer is the server API for RoutingService service. // All implementations must embed UnimplementedRoutingServiceServer // for forward compatibility type RoutingServiceServer interface { SubscribeRoutingStats(*SubscribeRoutingStatsRequest, RoutingService_SubscribeRoutingStatsServer) error TestRoute(context.Context, *TestRouteRequest) (*RoutingContext, error) + GetBalancerInfo(context.Context, *GetBalancerInfoRequest) (*GetBalancerInfoResponse, error) + OverrideBalancerTarget(context.Context, *OverrideBalancerTargetRequest) (*OverrideBalancerTargetResponse, error) mustEmbedUnimplementedRoutingServiceServer() } @@ -99,6 +123,12 @@ func (UnimplementedRoutingServiceServer) SubscribeRoutingStats(*SubscribeRouting func (UnimplementedRoutingServiceServer) TestRoute(context.Context, *TestRouteRequest) (*RoutingContext, error) { return nil, status.Errorf(codes.Unimplemented, "method TestRoute not implemented") } +func (UnimplementedRoutingServiceServer) GetBalancerInfo(context.Context, *GetBalancerInfoRequest) (*GetBalancerInfoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBalancerInfo not implemented") +} +func (UnimplementedRoutingServiceServer) OverrideBalancerTarget(context.Context, *OverrideBalancerTargetRequest) (*OverrideBalancerTargetResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method OverrideBalancerTarget not implemented") +} func (UnimplementedRoutingServiceServer) mustEmbedUnimplementedRoutingServiceServer() {} // UnsafeRoutingServiceServer may be embedded to opt out of forward compatibility for this service. @@ -151,6 +181,42 @@ func _RoutingService_TestRoute_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _RoutingService_GetBalancerInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetBalancerInfoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoutingServiceServer).GetBalancerInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RoutingService_GetBalancerInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoutingServiceServer).GetBalancerInfo(ctx, req.(*GetBalancerInfoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RoutingService_OverrideBalancerTarget_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(OverrideBalancerTargetRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoutingServiceServer).OverrideBalancerTarget(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: RoutingService_OverrideBalancerTarget_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoutingServiceServer).OverrideBalancerTarget(ctx, req.(*OverrideBalancerTargetRequest)) + } + return interceptor(ctx, in, info, handler) +} + // RoutingService_ServiceDesc is the grpc.ServiceDesc for RoutingService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -162,6 +228,14 @@ var RoutingService_ServiceDesc = grpc.ServiceDesc{ MethodName: "TestRoute", Handler: _RoutingService_TestRoute_Handler, }, + { + MethodName: "GetBalancerInfo", + Handler: _RoutingService_GetBalancerInfo_Handler, + }, + { + MethodName: "OverrideBalancerTarget", + Handler: _RoutingService_OverrideBalancerTarget_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/app/router/command/command_test.go b/app/router/command/command_test.go index b9d252a6..fa8d48b3 100644 --- a/app/router/command/command_test.go +++ b/app/router/command/command_test.go @@ -318,7 +318,7 @@ func TestSerivceTestRoute(t *testing.T) { TargetTag: &router.RoutingRule_Tag{Tag: "out"}, }, }, - }, mocks.NewDNSClient(mockCtl), mocks.NewOutboundManager(mockCtl))) + }, mocks.NewDNSClient(mockCtl), mocks.NewOutboundManager(mockCtl), nil)) lis := bufconn.Listen(1024 * 1024) bufDialer := func(context.Context, string) (net.Conn, error) { diff --git a/app/router/config.go b/app/router/config.go index 5dc32fa8..28ba7e31 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -121,28 +121,45 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) { return conds, nil } -func (br *BalancingRule) Build(ohm outbound.Manager) (*Balancer, error) { - switch br.Strategy { - case "leastPing": +// Build builds the balancing rule +func (br *BalancingRule) Build(ohm outbound.Manager, dispatcher routing.Dispatcher) (*Balancer, error) { + switch strings.ToLower(br.Strategy) { + case "leastping": return &Balancer{ selectors: br.OutboundSelector, strategy: &LeastPingStrategy{}, ohm: ohm, }, nil - case "roundRobin": + case "roundrobin": return &Balancer{ selectors: br.OutboundSelector, strategy: &RoundRobinStrategy{}, ohm: ohm, }, nil - case "random": - fallthrough - default: + case "leastload": + i, err := br.StrategySettings.GetInstance() + if err != nil { + return nil, err + } + s, ok := i.(*StrategyLeastLoadConfig) + if !ok { + return nil, newError("not a StrategyLeastLoadConfig").AtError() + } + leastLoadStrategy := NewLeastLoadStrategy(s) return &Balancer{ selectors: br.OutboundSelector, - strategy: &RandomStrategy{}, - ohm: ohm, + ohm: ohm, fallbackTag: br.FallbackTag, + strategy: leastLoadStrategy, }, nil - + case "random": + fallthrough + case "": + return &Balancer{ + selectors: br.OutboundSelector, + ohm: ohm, fallbackTag: br.FallbackTag, + strategy: &RandomStrategy{}, + }, nil + default: + return nil, newError("unrecognized balancer type") } } diff --git a/app/router/config.pb.go b/app/router/config.pb.go index cfe5a8fc..59a86a2e 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/router/config.proto @@ -8,6 +8,7 @@ package router import ( net "github.com/xtls/xray-core/common/net" + serial "github.com/xtls/xray-core/common/serial" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -131,7 +132,7 @@ func (x Config_DomainStrategy) Number() protoreflect.EnumNumber { // Deprecated: Use Config_DomainStrategy.Descriptor instead. func (Config_DomainStrategy) EnumDescriptor() ([]byte, []int) { - return file_app_router_config_proto_rawDescGZIP(), []int{8, 0} + return file_app_router_config_proto_rawDescGZIP(), []int{10, 0} } // Domain for routing decision. @@ -707,9 +708,11 @@ type BalancingRule struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` - OutboundSelector []string `protobuf:"bytes,2,rep,name=outbound_selector,json=outboundSelector,proto3" json:"outbound_selector,omitempty"` - Strategy string `protobuf:"bytes,3,opt,name=strategy,proto3" json:"strategy,omitempty"` + Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` + OutboundSelector []string `protobuf:"bytes,2,rep,name=outbound_selector,json=outboundSelector,proto3" json:"outbound_selector,omitempty"` + Strategy string `protobuf:"bytes,3,opt,name=strategy,proto3" json:"strategy,omitempty"` + StrategySettings *serial.TypedMessage `protobuf:"bytes,4,opt,name=strategy_settings,json=strategySettings,proto3" json:"strategy_settings,omitempty"` + FallbackTag string `protobuf:"bytes,5,opt,name=fallback_tag,json=fallbackTag,proto3" json:"fallback_tag,omitempty"` } func (x *BalancingRule) Reset() { @@ -765,6 +768,167 @@ func (x *BalancingRule) GetStrategy() string { return "" } +func (x *BalancingRule) GetStrategySettings() *serial.TypedMessage { + if x != nil { + return x.StrategySettings + } + return nil +} + +func (x *BalancingRule) GetFallbackTag() string { + if x != nil { + return x.FallbackTag + } + return "" +} + +type StrategyWeight struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Regexp bool `protobuf:"varint,1,opt,name=regexp,proto3" json:"regexp,omitempty"` + Match string `protobuf:"bytes,2,opt,name=match,proto3" json:"match,omitempty"` + Value float32 `protobuf:"fixed32,3,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *StrategyWeight) Reset() { + *x = StrategyWeight{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_config_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StrategyWeight) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StrategyWeight) ProtoMessage() {} + +func (x *StrategyWeight) ProtoReflect() protoreflect.Message { + mi := &file_app_router_config_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StrategyWeight.ProtoReflect.Descriptor instead. +func (*StrategyWeight) Descriptor() ([]byte, []int) { + return file_app_router_config_proto_rawDescGZIP(), []int{8} +} + +func (x *StrategyWeight) GetRegexp() bool { + if x != nil { + return x.Regexp + } + return false +} + +func (x *StrategyWeight) GetMatch() string { + if x != nil { + return x.Match + } + return "" +} + +func (x *StrategyWeight) GetValue() float32 { + if x != nil { + return x.Value + } + return 0 +} + +type StrategyLeastLoadConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // weight settings + Costs []*StrategyWeight `protobuf:"bytes,2,rep,name=costs,proto3" json:"costs,omitempty"` + // RTT baselines for selecting, int64 values of time.Duration + Baselines []int64 `protobuf:"varint,3,rep,packed,name=baselines,proto3" json:"baselines,omitempty"` + // expected nodes count to select + Expected int32 `protobuf:"varint,4,opt,name=expected,proto3" json:"expected,omitempty"` + // max acceptable rtt, filter away high delay nodes. defalut 0 + MaxRTT int64 `protobuf:"varint,5,opt,name=maxRTT,proto3" json:"maxRTT,omitempty"` + // acceptable failure rate + Tolerance float32 `protobuf:"fixed32,6,opt,name=tolerance,proto3" json:"tolerance,omitempty"` +} + +func (x *StrategyLeastLoadConfig) Reset() { + *x = StrategyLeastLoadConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_config_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *StrategyLeastLoadConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*StrategyLeastLoadConfig) ProtoMessage() {} + +func (x *StrategyLeastLoadConfig) ProtoReflect() protoreflect.Message { + mi := &file_app_router_config_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use StrategyLeastLoadConfig.ProtoReflect.Descriptor instead. +func (*StrategyLeastLoadConfig) Descriptor() ([]byte, []int) { + return file_app_router_config_proto_rawDescGZIP(), []int{9} +} + +func (x *StrategyLeastLoadConfig) GetCosts() []*StrategyWeight { + if x != nil { + return x.Costs + } + return nil +} + +func (x *StrategyLeastLoadConfig) GetBaselines() []int64 { + if x != nil { + return x.Baselines + } + return nil +} + +func (x *StrategyLeastLoadConfig) GetExpected() int32 { + if x != nil { + return x.Expected + } + return 0 +} + +func (x *StrategyLeastLoadConfig) GetMaxRTT() int64 { + if x != nil { + return x.MaxRTT + } + return 0 +} + +func (x *StrategyLeastLoadConfig) GetTolerance() float32 { + if x != nil { + return x.Tolerance + } + return 0 +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -778,7 +942,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[8] + mi := &file_app_router_config_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -791,7 +955,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_app_router_config_proto_msgTypes[8] + mi := &file_app_router_config_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -804,7 +968,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_app_router_config_proto_rawDescGZIP(), []int{8} + return file_app_router_config_proto_rawDescGZIP(), []int{10} } func (x *Config) GetDomainStrategy() Config_DomainStrategy { @@ -844,7 +1008,7 @@ type Domain_Attribute struct { func (x *Domain_Attribute) Reset() { *x = Domain_Attribute{} if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[9] + mi := &file_app_router_config_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -857,7 +1021,7 @@ func (x *Domain_Attribute) String() string { func (*Domain_Attribute) ProtoMessage() {} func (x *Domain_Attribute) ProtoReflect() protoreflect.Message { - mi := &file_app_router_config_proto_msgTypes[9] + mi := &file_app_router_config_proto_msgTypes[11] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -922,142 +1086,169 @@ var File_app_router_config_proto protoreflect.FileDescriptor var file_app_router_config_proto_rawDesc = []byte{ 0x0a, 0x17, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x1a, 0x15, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x6e, 0x65, - 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, 0x02, 0x0a, 0x06, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x54, 0x79, - 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x3f, - 0x0a, 0x09, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x21, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, - 0x74, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x41, 0x74, 0x74, 0x72, 0x69, - 0x62, 0x75, 0x74, 0x65, 0x52, 0x09, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x1a, - 0x6c, 0x0a, 0x09, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x1f, - 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, - 0x1d, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x03, 0x48, 0x00, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x0d, - 0x0a, 0x0b, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x32, 0x0a, - 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x6c, 0x61, 0x69, 0x6e, 0x10, 0x00, - 0x12, 0x09, 0x0a, 0x05, 0x52, 0x65, 0x67, 0x65, 0x78, 0x10, 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, - 0x03, 0x22, 0x2e, 0x0a, 0x04, 0x43, 0x49, 0x44, 0x52, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x72, 0x65, - 0x66, 0x69, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x70, 0x72, 0x65, 0x66, 0x69, - 0x78, 0x22, 0x7a, 0x0a, 0x05, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x29, 0x0a, - 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x49, - 0x44, 0x52, 0x52, 0x04, 0x63, 0x69, 0x64, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x72, 0x65, 0x76, 0x65, - 0x72, 0x73, 0x65, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0c, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x22, 0x39, 0x0a, - 0x09, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2c, 0x0a, 0x05, 0x65, 0x6e, - 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, - 0x50, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x5d, 0x0a, 0x07, 0x47, 0x65, 0x6f, 0x53, - 0x69, 0x74, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x5f, 0x63, - 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x72, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x2f, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, - 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x3d, 0x0a, 0x0b, 0x47, 0x65, 0x6f, 0x53, 0x69, - 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x52, - 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0xa2, 0x07, 0x0a, 0x0b, 0x52, 0x6f, 0x75, 0x74, 0x69, - 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x25, 0x0a, 0x0d, 0x62, 0x61, - 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, - 0x09, 0x48, 0x00, 0x52, 0x0c, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x54, 0x61, - 0x67, 0x12, 0x2f, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, - 0x74, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x12, 0x2d, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x15, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, - 0x65, 0x72, 0x2e, 0x43, 0x49, 0x44, 0x52, 0x42, 0x02, 0x18, 0x01, 0x52, 0x04, 0x63, 0x69, 0x64, - 0x72, 0x12, 0x2c, 0x0a, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, - 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x12, - 0x3d, 0x0a, 0x0a, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, - 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x42, - 0x02, 0x18, 0x01, 0x52, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x36, - 0x0a, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, - 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x08, 0x70, 0x6f, - 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, - 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0b, - 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x6e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, - 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x73, 0x12, 0x3a, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x69, 0x64, 0x72, - 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x49, 0x44, 0x52, 0x42, 0x02, 0x18, - 0x01, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x69, 0x64, 0x72, 0x12, 0x39, 0x0a, - 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0b, 0x20, + 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x1a, 0x21, 0x63, 0x6f, 0x6d, 0x6d, + 0x6f, 0x6e, 0x2f, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x15, 0x63, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, + 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, + 0x02, 0x0a, 0x06, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x12, 0x3f, 0x0a, 0x09, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x41, 0x74, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x52, 0x09, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, + 0x74, 0x65, 0x1a, 0x6c, 0x0a, 0x09, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x1f, 0x0a, 0x0a, 0x62, 0x6f, 0x6f, 0x6c, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x09, 0x62, 0x6f, 0x6f, 0x6c, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x12, 0x1d, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x08, 0x69, 0x6e, 0x74, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x42, 0x0d, 0x0a, 0x0b, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x22, 0x32, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x09, 0x0a, 0x05, 0x50, 0x6c, 0x61, 0x69, + 0x6e, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x65, 0x67, 0x65, 0x78, 0x10, 0x01, 0x12, 0x0a, + 0x0a, 0x06, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x02, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, + 0x6c, 0x6c, 0x10, 0x03, 0x22, 0x2e, 0x0a, 0x04, 0x43, 0x49, 0x44, 0x52, 0x12, 0x0e, 0x0a, 0x02, + 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x70, 0x12, 0x16, 0x0a, 0x06, + 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x70, 0x72, + 0x65, 0x66, 0x69, 0x78, 0x22, 0x7a, 0x0a, 0x05, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x12, 0x21, 0x0a, + 0x0c, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79, 0x43, 0x6f, 0x64, 0x65, + 0x12, 0x29, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x2e, 0x43, 0x49, 0x44, 0x52, 0x52, 0x04, 0x63, 0x69, 0x64, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x72, + 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0c, 0x72, 0x65, 0x76, 0x65, 0x72, 0x73, 0x65, 0x4d, 0x61, 0x74, 0x63, 0x68, + 0x22, 0x39, 0x0a, 0x09, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2c, 0x0a, + 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, + 0x65, 0x6f, 0x49, 0x50, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0x5d, 0x0a, 0x07, 0x47, + 0x65, 0x6f, 0x53, 0x69, 0x74, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x72, + 0x79, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, + 0x75, 0x6e, 0x74, 0x72, 0x79, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x2f, 0x0a, 0x06, 0x64, 0x6f, 0x6d, + 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, + 0x69, 0x6e, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x22, 0x3d, 0x0a, 0x0b, 0x47, 0x65, + 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x6e, 0x74, + 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x53, 0x69, + 0x74, 0x65, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0xa2, 0x07, 0x0a, 0x0b, 0x52, 0x6f, + 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x03, 0x74, 0x61, 0x67, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x25, 0x0a, + 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x0c, + 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, + 0x67, 0x54, 0x61, 0x67, 0x12, 0x2f, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x06, 0x64, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x2d, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x03, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, + 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x49, 0x44, 0x52, 0x42, 0x02, 0x18, 0x01, 0x52, 0x04, + 0x63, 0x69, 0x64, 0x72, 0x12, 0x2c, 0x0a, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, - 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x0b, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x47, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x43, 0x0a, 0x10, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x10, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, - 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x0e, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1d, 0x0a, - 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, - 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x08, 0x20, 0x03, 0x28, - 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x12, 0x1a, 0x0a, - 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x4c, 0x0a, 0x0a, 0x61, 0x74, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, - 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x2e, 0x41, 0x74, 0x74, 0x72, - 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x61, 0x74, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x0d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x1a, 0x3d, - 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0c, 0x0a, - 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x61, 0x67, 0x22, 0x6a, 0x0a, 0x0d, 0x42, - 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, - 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x2b, - 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, - 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, - 0x75, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x22, 0x9b, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x12, 0x4f, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, - 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, - 0x65, 0x67, 0x79, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, - 0x74, 0x65, 0x72, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, - 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x0e, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, - 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, - 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x62, - 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x47, 0x0a, 0x0e, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, - 0x0a, 0x04, 0x41, 0x73, 0x49, 0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x49, - 0x70, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x70, 0x49, 0x66, 0x4e, 0x6f, 0x6e, 0x4d, 0x61, - 0x74, 0x63, 0x68, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x70, 0x4f, 0x6e, 0x44, 0x65, 0x6d, - 0x61, 0x6e, 0x64, 0x10, 0x03, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x24, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, - 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, - 0x75, 0x74, 0x65, 0x72, 0xaa, 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, - 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x05, 0x67, 0x65, 0x6f, + 0x69, 0x70, 0x12, 0x3d, 0x0a, 0x0a, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x72, 0x61, 0x6e, 0x67, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, + 0x67, 0x65, 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, 0x67, + 0x65, 0x12, 0x36, 0x0a, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x0e, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, + 0x08, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x6e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, + 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x02, 0x18, + 0x01, 0x52, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x34, + 0x0a, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0e, + 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, + 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x08, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x73, 0x12, 0x3a, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, + 0x69, 0x64, 0x72, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x49, 0x44, 0x52, + 0x42, 0x02, 0x18, 0x01, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x69, 0x64, 0x72, + 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x67, 0x65, 0x6f, 0x69, 0x70, + 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x0b, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x47, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x43, 0x0a, 0x10, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, + 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, + 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, + 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x08, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, + 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x4c, 0x0a, 0x0a, + 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x2c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, + 0x65, 0x72, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x2e, 0x41, + 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, + 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x6f, + 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, 0x11, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, + 0x72, 0x1a, 0x3d, 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x42, 0x0c, 0x0a, 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x61, 0x67, 0x22, 0xdc, + 0x01, 0x0a, 0x0d, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, + 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, + 0x61, 0x67, 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, + 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x6f, + 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, + 0x1a, 0x0a, 0x08, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x4d, 0x0a, 0x11, 0x73, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, + 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x10, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x67, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x61, + 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x66, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x54, 0x0a, + 0x0e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, + 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x06, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x22, 0xc0, 0x01, 0x0a, 0x17, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, + 0x4c, 0x65, 0x61, 0x73, 0x74, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, + 0x35, 0x0a, 0x05, 0x63, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x2e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, + 0x05, 0x63, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x61, 0x73, 0x65, 0x6c, 0x69, + 0x6e, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x09, 0x62, 0x61, 0x73, 0x65, 0x6c, + 0x69, 0x6e, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, + 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x78, 0x52, 0x54, 0x54, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x06, 0x6d, 0x61, 0x78, 0x52, 0x54, 0x54, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x6f, 0x6c, 0x65, + 0x72, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x74, 0x6f, 0x6c, + 0x65, 0x72, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x9b, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x4f, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x67, 0x79, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, + 0x65, 0x72, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, + 0x72, 0x75, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x0e, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, + 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x42, + 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x62, 0x61, + 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x47, 0x0a, 0x0e, 0x44, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, + 0x04, 0x41, 0x73, 0x49, 0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x49, 0x70, + 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x70, 0x49, 0x66, 0x4e, 0x6f, 0x6e, 0x4d, 0x61, 0x74, + 0x63, 0x68, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x70, 0x4f, 0x6e, 0x44, 0x65, 0x6d, 0x61, + 0x6e, 0x64, 0x10, 0x03, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x24, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, + 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, + 0x74, 0x65, 0x72, 0xaa, 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, + 0x6f, 0x75, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1073,29 +1264,32 @@ func file_app_router_config_proto_rawDescGZIP() []byte { } var file_app_router_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_app_router_config_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_app_router_config_proto_msgTypes = make([]protoimpl.MessageInfo, 13) var file_app_router_config_proto_goTypes = []interface{}{ - (Domain_Type)(0), // 0: xray.app.router.Domain.Type - (Config_DomainStrategy)(0), // 1: xray.app.router.Config.DomainStrategy - (*Domain)(nil), // 2: xray.app.router.Domain - (*CIDR)(nil), // 3: xray.app.router.CIDR - (*GeoIP)(nil), // 4: xray.app.router.GeoIP - (*GeoIPList)(nil), // 5: xray.app.router.GeoIPList - (*GeoSite)(nil), // 6: xray.app.router.GeoSite - (*GeoSiteList)(nil), // 7: xray.app.router.GeoSiteList - (*RoutingRule)(nil), // 8: xray.app.router.RoutingRule - (*BalancingRule)(nil), // 9: xray.app.router.BalancingRule - (*Config)(nil), // 10: xray.app.router.Config - (*Domain_Attribute)(nil), // 11: xray.app.router.Domain.Attribute - nil, // 12: xray.app.router.RoutingRule.AttributesEntry - (*net.PortRange)(nil), // 13: xray.common.net.PortRange - (*net.PortList)(nil), // 14: xray.common.net.PortList - (*net.NetworkList)(nil), // 15: xray.common.net.NetworkList - (net.Network)(0), // 16: xray.common.net.Network + (Domain_Type)(0), // 0: xray.app.router.Domain.Type + (Config_DomainStrategy)(0), // 1: xray.app.router.Config.DomainStrategy + (*Domain)(nil), // 2: xray.app.router.Domain + (*CIDR)(nil), // 3: xray.app.router.CIDR + (*GeoIP)(nil), // 4: xray.app.router.GeoIP + (*GeoIPList)(nil), // 5: xray.app.router.GeoIPList + (*GeoSite)(nil), // 6: xray.app.router.GeoSite + (*GeoSiteList)(nil), // 7: xray.app.router.GeoSiteList + (*RoutingRule)(nil), // 8: xray.app.router.RoutingRule + (*BalancingRule)(nil), // 9: xray.app.router.BalancingRule + (*StrategyWeight)(nil), // 10: xray.app.router.StrategyWeight + (*StrategyLeastLoadConfig)(nil), // 11: xray.app.router.StrategyLeastLoadConfig + (*Config)(nil), // 12: xray.app.router.Config + (*Domain_Attribute)(nil), // 13: xray.app.router.Domain.Attribute + nil, // 14: xray.app.router.RoutingRule.AttributesEntry + (*net.PortRange)(nil), // 15: xray.common.net.PortRange + (*net.PortList)(nil), // 16: xray.common.net.PortList + (*net.NetworkList)(nil), // 17: xray.common.net.NetworkList + (net.Network)(0), // 18: xray.common.net.Network + (*serial.TypedMessage)(nil), // 19: xray.common.serial.TypedMessage } var file_app_router_config_proto_depIdxs = []int32{ 0, // 0: xray.app.router.Domain.type:type_name -> xray.app.router.Domain.Type - 11, // 1: xray.app.router.Domain.attribute:type_name -> xray.app.router.Domain.Attribute + 13, // 1: xray.app.router.Domain.attribute:type_name -> xray.app.router.Domain.Attribute 3, // 2: xray.app.router.GeoIP.cidr:type_name -> xray.app.router.CIDR 4, // 3: xray.app.router.GeoIPList.entry:type_name -> xray.app.router.GeoIP 2, // 4: xray.app.router.GeoSite.domain:type_name -> xray.app.router.Domain @@ -1103,22 +1297,24 @@ var file_app_router_config_proto_depIdxs = []int32{ 2, // 6: xray.app.router.RoutingRule.domain:type_name -> xray.app.router.Domain 3, // 7: xray.app.router.RoutingRule.cidr:type_name -> xray.app.router.CIDR 4, // 8: xray.app.router.RoutingRule.geoip:type_name -> xray.app.router.GeoIP - 13, // 9: xray.app.router.RoutingRule.port_range:type_name -> xray.common.net.PortRange - 14, // 10: xray.app.router.RoutingRule.port_list:type_name -> xray.common.net.PortList - 15, // 11: xray.app.router.RoutingRule.network_list:type_name -> xray.common.net.NetworkList - 16, // 12: xray.app.router.RoutingRule.networks:type_name -> xray.common.net.Network + 15, // 9: xray.app.router.RoutingRule.port_range:type_name -> xray.common.net.PortRange + 16, // 10: xray.app.router.RoutingRule.port_list:type_name -> xray.common.net.PortList + 17, // 11: xray.app.router.RoutingRule.network_list:type_name -> xray.common.net.NetworkList + 18, // 12: xray.app.router.RoutingRule.networks:type_name -> xray.common.net.Network 3, // 13: xray.app.router.RoutingRule.source_cidr:type_name -> xray.app.router.CIDR 4, // 14: xray.app.router.RoutingRule.source_geoip:type_name -> xray.app.router.GeoIP - 14, // 15: xray.app.router.RoutingRule.source_port_list:type_name -> xray.common.net.PortList - 12, // 16: xray.app.router.RoutingRule.attributes:type_name -> xray.app.router.RoutingRule.AttributesEntry - 1, // 17: xray.app.router.Config.domain_strategy:type_name -> xray.app.router.Config.DomainStrategy - 8, // 18: xray.app.router.Config.rule:type_name -> xray.app.router.RoutingRule - 9, // 19: xray.app.router.Config.balancing_rule:type_name -> xray.app.router.BalancingRule - 20, // [20:20] is the sub-list for method output_type - 20, // [20:20] is the sub-list for method input_type - 20, // [20:20] is the sub-list for extension type_name - 20, // [20:20] is the sub-list for extension extendee - 0, // [0:20] is the sub-list for field type_name + 16, // 15: xray.app.router.RoutingRule.source_port_list:type_name -> xray.common.net.PortList + 14, // 16: xray.app.router.RoutingRule.attributes:type_name -> xray.app.router.RoutingRule.AttributesEntry + 19, // 17: xray.app.router.BalancingRule.strategy_settings:type_name -> xray.common.serial.TypedMessage + 10, // 18: xray.app.router.StrategyLeastLoadConfig.costs:type_name -> xray.app.router.StrategyWeight + 1, // 19: xray.app.router.Config.domain_strategy:type_name -> xray.app.router.Config.DomainStrategy + 8, // 20: xray.app.router.Config.rule:type_name -> xray.app.router.RoutingRule + 9, // 21: xray.app.router.Config.balancing_rule:type_name -> xray.app.router.BalancingRule + 22, // [22:22] is the sub-list for method output_type + 22, // [22:22] is the sub-list for method input_type + 22, // [22:22] is the sub-list for extension type_name + 22, // [22:22] is the sub-list for extension extendee + 0, // [0:22] is the sub-list for field type_name } func init() { file_app_router_config_proto_init() } @@ -1224,7 +1420,7 @@ func file_app_router_config_proto_init() { } } file_app_router_config_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Config); i { + switch v := v.(*StrategyWeight); i { case 0: return &v.state case 1: @@ -1236,6 +1432,30 @@ func file_app_router_config_proto_init() { } } file_app_router_config_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*StrategyLeastLoadConfig); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_config_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Config); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_config_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Domain_Attribute); i { case 0: return &v.state @@ -1252,7 +1472,7 @@ func file_app_router_config_proto_init() { (*RoutingRule_Tag)(nil), (*RoutingRule_BalancingTag)(nil), } - file_app_router_config_proto_msgTypes[9].OneofWrappers = []interface{}{ + file_app_router_config_proto_msgTypes[11].OneofWrappers = []interface{}{ (*Domain_Attribute_BoolValue)(nil), (*Domain_Attribute_IntValue)(nil), } @@ -1262,7 +1482,7 @@ func file_app_router_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_router_config_proto_rawDesc, NumEnums: 2, - NumMessages: 11, + NumMessages: 13, NumExtensions: 0, NumServices: 0, }, diff --git a/app/router/config.proto b/app/router/config.proto index ab9957f3..1cedb9e9 100644 --- a/app/router/config.proto +++ b/app/router/config.proto @@ -6,6 +6,7 @@ option go_package = "github.com/xtls/xray-core/app/router"; option java_package = "com.xray.app.router"; option java_multiple_files = true; +import "common/serial/typed_message.proto"; import "common/net/port.proto"; import "common/net/network.proto"; @@ -128,6 +129,27 @@ message BalancingRule { string tag = 1; repeated string outbound_selector = 2; string strategy = 3; + xray.common.serial.TypedMessage strategy_settings = 4; + string fallback_tag = 5; +} + +message StrategyWeight { + bool regexp = 1; + string match = 2; + float value =3; +} + +message StrategyLeastLoadConfig { + // weight settings + repeated StrategyWeight costs = 2; + // RTT baselines for selecting, int64 values of time.Duration + repeated int64 baselines = 3; + // expected nodes count to select + int32 expected = 4; + // max acceptable rtt, filter away high delay nodes. defalut 0 + int64 maxRTT = 5; + // acceptable failure rate + float tolerance = 6; } message Config { diff --git a/app/router/router.go b/app/router/router.go index 010f8d0a..88197710 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -29,13 +29,13 @@ type Route struct { } // Init initializes the Router. -func (r *Router) Init(ctx context.Context, config *Config, d dns.Client, ohm outbound.Manager) error { +func (r *Router) Init(ctx context.Context, config *Config, d dns.Client, ohm outbound.Manager, dispatcher routing.Dispatcher) error { r.domainStrategy = config.DomainStrategy r.dns = d r.balancers = make(map[string]*Balancer, len(config.BalancingRule)) for _, rule := range config.BalancingRule { - balancer, err := rule.Build(ohm) + balancer, err := rule.Build(ohm, dispatcher) if err != nil { return err } @@ -113,12 +113,12 @@ func (r *Router) pickRouteInternal(ctx routing.Context) (*Rule, routing.Context, } // Start implements common.Runnable. -func (*Router) Start() error { +func (r *Router) Start() error { return nil } // Close implements common.Closable. -func (*Router) Close() error { +func (r *Router) Close() error { return nil } @@ -140,8 +140,8 @@ func (r *Route) GetOutboundTag() string { func init() { common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { r := new(Router) - if err := core.RequireFeatures(ctx, func(d dns.Client, ohm outbound.Manager) error { - return r.Init(ctx, config.(*Config), d, ohm) + if err := core.RequireFeatures(ctx, func(d dns.Client, ohm outbound.Manager, dispatcher routing.Dispatcher) error { + return r.Init(ctx, config.(*Config), d, ohm, dispatcher) }); err != nil { return nil, err } diff --git a/app/router/router_test.go b/app/router/router_test.go index 1b71e99b..4c6bfc63 100644 --- a/app/router/router_test.go +++ b/app/router/router_test.go @@ -43,7 +43,7 @@ func TestSimpleRouter(t *testing.T) { common.Must(r.Init(context.TODO(), config, mockDNS, &mockOutboundManager{ Manager: mockOhm, HandlerSelector: mockHs, - })) + }, nil)) ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("example.com"), 80)}) route, err := r.PickRoute(routing_session.AsRoutingContext(ctx)) @@ -84,7 +84,7 @@ func TestSimpleBalancer(t *testing.T) { common.Must(r.Init(context.TODO(), config, mockDNS, &mockOutboundManager{ Manager: mockOhm, HandlerSelector: mockHs, - })) + }, nil)) ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("example.com"), 80)}) route, err := r.PickRoute(routing_session.AsRoutingContext(ctx)) @@ -94,6 +94,55 @@ func TestSimpleBalancer(t *testing.T) { } } +/* + +Do not work right now: need a full client setup + +func TestLeastLoadBalancer(t *testing.T) { + config := &Config{ + Rule: []*RoutingRule{ + { + TargetTag: &RoutingRule_BalancingTag{ + BalancingTag: "balance", + }, + Networks: []net.Network{net.Network_TCP}, + }, + }, + BalancingRule: []*BalancingRule{ + { + Tag: "balance", + OutboundSelector: []string{"test-"}, + Strategy: "leastLoad", + StrategySettings: serial.ToTypedMessage(&StrategyLeastLoadConfig{ + Baselines: nil, + Expected: 1, + }), + }, + }, + } + + mockCtl := gomock.NewController(t) + defer mockCtl.Finish() + + mockDNS := mocks.NewDNSClient(mockCtl) + mockOhm := mocks.NewOutboundManager(mockCtl) + mockHs := mocks.NewOutboundHandlerSelector(mockCtl) + + mockHs.EXPECT().Select(gomock.Eq([]string{"test-"})).Return([]string{"test1"}) + + r := new(Router) + common.Must(r.Init(context.TODO(), config, mockDNS, &mockOutboundManager{ + Manager: mockOhm, + HandlerSelector: mockHs, + }, nil)) + ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("v2ray.com"), 80)}) + route, err := r.PickRoute(routing_session.AsRoutingContext(ctx)) + common.Must(err) + if tag := route.GetOutboundTag(); tag != "test1" { + t.Error("expect tag 'test1', bug actually ", tag) + } +}*/ + func TestIPOnDemand(t *testing.T) { config := &Config{ DomainStrategy: Config_IpOnDemand, @@ -123,7 +172,7 @@ func TestIPOnDemand(t *testing.T) { }).Return([]net.IP{{192, 168, 0, 1}}, nil).AnyTimes() r := new(Router) - common.Must(r.Init(context.TODO(), config, mockDNS, nil)) + common.Must(r.Init(context.TODO(), config, mockDNS, nil, nil)) ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("example.com"), 80)}) route, err := r.PickRoute(routing_session.AsRoutingContext(ctx)) @@ -162,7 +211,7 @@ func TestIPIfNonMatchDomain(t *testing.T) { }).Return([]net.IP{{192, 168, 0, 1}}, nil).AnyTimes() r := new(Router) - common.Must(r.Init(context.TODO(), config, mockDNS, nil)) + common.Must(r.Init(context.TODO(), config, mockDNS, nil, nil)) ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.DomainAddress("example.com"), 80)}) route, err := r.PickRoute(routing_session.AsRoutingContext(ctx)) @@ -196,7 +245,7 @@ func TestIPIfNonMatchIP(t *testing.T) { mockDNS := mocks.NewDNSClient(mockCtl) r := new(Router) - common.Must(r.Init(context.TODO(), config, mockDNS, nil)) + common.Must(r.Init(context.TODO(), config, mockDNS, nil, nil)) ctx := session.ContextWithOutbound(context.Background(), &session.Outbound{Target: net.TCPDestination(net.LocalHostIP, 80)}) route, err := r.PickRoute(routing_session.AsRoutingContext(ctx)) diff --git a/app/router/strategy_leastload.go b/app/router/strategy_leastload.go new file mode 100644 index 00000000..e8eb5567 --- /dev/null +++ b/app/router/strategy_leastload.go @@ -0,0 +1,200 @@ +package router + +import ( + "context" + "math" + "sort" + "time" + + "github.com/xtls/xray-core/app/observatory" + "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/dice" + "github.com/xtls/xray-core/core" + "github.com/xtls/xray-core/features/extension" +) + +// LeastLoadStrategy represents a least load balancing strategy +type LeastLoadStrategy struct { + settings *StrategyLeastLoadConfig + costs *WeightManager + + observer extension.Observatory + + ctx context.Context +} + +func (l *LeastLoadStrategy) GetPrincipleTarget(strings []string) []string { + var ret []string + nodes := l.pickOutbounds(strings) + for _, v := range nodes { + ret = append(ret, v.Tag) + } + return ret +} + +// NewLeastLoadStrategy creates a new LeastLoadStrategy with settings +func NewLeastLoadStrategy(settings *StrategyLeastLoadConfig) *LeastLoadStrategy { + return &LeastLoadStrategy{ + settings: settings, + costs: NewWeightManager( + settings.Costs, 1, + func(value, cost float64) float64 { + return value * math.Pow(cost, 0.5) + }, + ), + } +} + +// node is a minimal copy of HealthCheckResult +// we don't use HealthCheckResult directly because +// it may change by health checker during routing +type node struct { + Tag string + CountAll int + CountFail int + RTTAverage time.Duration + RTTDeviation time.Duration + RTTDeviationCost time.Duration +} + +func (l *LeastLoadStrategy) InjectContext(ctx context.Context) { + l.ctx = ctx +} + +func (s *LeastLoadStrategy) PickOutbound(candidates []string) string { + selects := s.pickOutbounds(candidates) + count := len(selects) + if count == 0 { + // goes to fallbackTag + return "" + } + return selects[dice.Roll(count)].Tag +} + +func (s *LeastLoadStrategy) pickOutbounds(candidates []string) []*node { + qualified := s.getNodes(candidates, time.Duration(s.settings.MaxRTT)) + selects := s.selectLeastLoad(qualified) + return selects +} + +// selectLeastLoad selects nodes according to Baselines and Expected Count. +// +// The strategy always improves network response speed, not matter which mode below is configured. +// But they can still have different priorities. +// +// 1. Bandwidth priority: no Baseline + Expected Count > 0.: selects `Expected Count` of nodes. +// (one if Expected Count <= 0) +// +// 2. Bandwidth priority advanced: Baselines + Expected Count > 0. +// Select `Expected Count` amount of nodes, and also those near them according to baselines. +// In other words, it selects according to different Baselines, until one of them matches +// the Expected Count, if no Baseline matches, Expected Count applied. +// +// 3. Speed priority: Baselines + `Expected Count <= 0`. +// go through all baselines until find selects, if not, select none. Used in combination +// with 'balancer.fallbackTag', it means: selects qualified nodes or use the fallback. +func (s *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node { + if len(nodes) == 0 { + newError("least load: no qualified outbound").AtInfo().WriteToLog() + return nil + } + expected := int(s.settings.Expected) + availableCount := len(nodes) + if expected > availableCount { + return nodes + } + + if expected <= 0 { + expected = 1 + } + if len(s.settings.Baselines) == 0 { + return nodes[:expected] + } + + count := 0 + // go through all base line until find expected selects + for _, b := range s.settings.Baselines { + baseline := time.Duration(b) + for i := count; i < availableCount; i++ { + if nodes[i].RTTDeviationCost >= baseline { + break + } + count = i + 1 + } + // don't continue if find expected selects + if count >= expected { + newError("applied baseline: ", baseline).AtDebug().WriteToLog() + break + } + } + if s.settings.Expected > 0 && count < expected { + count = expected + } + return nodes[:count] +} + +func (s *LeastLoadStrategy) getNodes(candidates []string, maxRTT time.Duration) []*node { + if s.observer == nil { + common.Must(core.RequireFeatures(s.ctx, func(observatory extension.Observatory) error { + s.observer = observatory + return nil + })) + } + observeResult, err := s.observer.GetObservation(s.ctx) + if err != nil { + newError("cannot get observation").Base(err).WriteToLog() + return make([]*node, 0) + } + + results := observeResult.(*observatory.ObservationResult) + + outboundlist := outboundList(candidates) + + var ret []*node + + for _, v := range results.Status { + if v.Alive && (v.Delay < maxRTT.Milliseconds() || maxRTT == 0) && outboundlist.contains(v.OutboundTag) { + record := &node{ + Tag: v.OutboundTag, + CountAll: 1, + CountFail: 1, + RTTAverage: time.Duration(v.Delay) * time.Millisecond, + RTTDeviation: time.Duration(v.Delay) * time.Millisecond, + RTTDeviationCost: time.Duration(s.costs.Apply(v.OutboundTag, float64(time.Duration(v.Delay)*time.Millisecond))), + } + + if v.HealthPing != nil { + record.RTTAverage = time.Duration(v.HealthPing.Average) + record.RTTDeviation = time.Duration(v.HealthPing.Deviation) + record.RTTDeviationCost = time.Duration(s.costs.Apply(v.OutboundTag, float64(v.HealthPing.Deviation))) + record.CountAll = int(v.HealthPing.All) + record.CountFail = int(v.HealthPing.Fail) + + } + ret = append(ret, record) + } + } + + leastloadSort(ret) + return ret +} + +func leastloadSort(nodes []*node) { + sort.Slice(nodes, func(i, j int) bool { + left := nodes[i] + right := nodes[j] + if left.RTTDeviationCost != right.RTTDeviationCost { + return left.RTTDeviationCost < right.RTTDeviationCost + } + if left.RTTAverage != right.RTTAverage { + return left.RTTAverage < right.RTTAverage + } + if left.CountFail != right.CountFail { + return left.CountFail < right.CountFail + } + if left.CountAll != right.CountAll { + return left.CountAll > right.CountAll + } + return left.Tag < right.Tag + }) +} diff --git a/app/router/strategy_leastload_test.go b/app/router/strategy_leastload_test.go new file mode 100644 index 00000000..be95140d --- /dev/null +++ b/app/router/strategy_leastload_test.go @@ -0,0 +1,179 @@ +package router + +import ( + "testing" +) + +/* +Split into multiple package, need to be tested separately + +func TestSelectLeastLoad(t *testing.T) { + settings := &StrategyLeastLoadConfig{ + HealthCheck: &HealthPingConfig{ + SamplingCount: 10, + }, + Expected: 1, + MaxRTT: int64(time.Millisecond * time.Duration(800)), + } + strategy := NewLeastLoadStrategy(settings) + // std 40 + strategy.PutResult("a", time.Millisecond*time.Duration(60)) + strategy.PutResult("a", time.Millisecond*time.Duration(140)) + strategy.PutResult("a", time.Millisecond*time.Duration(60)) + strategy.PutResult("a", time.Millisecond*time.Duration(140)) + // std 60 + strategy.PutResult("b", time.Millisecond*time.Duration(40)) + strategy.PutResult("b", time.Millisecond*time.Duration(160)) + strategy.PutResult("b", time.Millisecond*time.Duration(40)) + strategy.PutResult("b", time.Millisecond*time.Duration(160)) + // std 0, but >MaxRTT + strategy.PutResult("c", time.Millisecond*time.Duration(1000)) + strategy.PutResult("c", time.Millisecond*time.Duration(1000)) + strategy.PutResult("c", time.Millisecond*time.Duration(1000)) + strategy.PutResult("c", time.Millisecond*time.Duration(1000)) + expected := "a" + actual := strategy.SelectAndPick([]string{"a", "b", "c", "untested"}) + if actual != expected { + t.Errorf("expected: %v, actual: %v", expected, actual) + } +} + +func TestSelectLeastLoadWithCost(t *testing.T) { + settings := &StrategyLeastLoadConfig{ + HealthCheck: &HealthPingConfig{ + SamplingCount: 10, + }, + Costs: []*StrategyWeight{ + {Match: "a", Value: 9}, + }, + Expected: 1, + } + strategy := NewLeastLoadStrategy(settings, nil) + // std 40, std+c 120 + strategy.PutResult("a", time.Millisecond*time.Duration(60)) + strategy.PutResult("a", time.Millisecond*time.Duration(140)) + strategy.PutResult("a", time.Millisecond*time.Duration(60)) + strategy.PutResult("a", time.Millisecond*time.Duration(140)) + // std 60 + strategy.PutResult("b", time.Millisecond*time.Duration(40)) + strategy.PutResult("b", time.Millisecond*time.Duration(160)) + strategy.PutResult("b", time.Millisecond*time.Duration(40)) + strategy.PutResult("b", time.Millisecond*time.Duration(160)) + expected := "b" + actual := strategy.SelectAndPick([]string{"a", "b", "untested"}) + if actual != expected { + t.Errorf("expected: %v, actual: %v", expected, actual) + } +} +*/ +func TestSelectLeastExpected(t *testing.T) { + strategy := &LeastLoadStrategy{ + settings: &StrategyLeastLoadConfig{ + Baselines: nil, + Expected: 3, + }, + } + nodes := []*node{ + {Tag: "a", RTTDeviationCost: 100}, + {Tag: "b", RTTDeviationCost: 200}, + {Tag: "c", RTTDeviationCost: 300}, + {Tag: "d", RTTDeviationCost: 350}, + } + expected := 3 + ns := strategy.selectLeastLoad(nodes) + if len(ns) != expected { + t.Errorf("expected: %v, actual: %v", expected, len(ns)) + } +} +func TestSelectLeastExpected2(t *testing.T) { + strategy := &LeastLoadStrategy{ + settings: &StrategyLeastLoadConfig{ + Baselines: nil, + Expected: 3, + }, + } + nodes := []*node{ + {Tag: "a", RTTDeviationCost: 100}, + {Tag: "b", RTTDeviationCost: 200}, + } + expected := 2 + ns := strategy.selectLeastLoad(nodes) + if len(ns) != expected { + t.Errorf("expected: %v, actual: %v", expected, len(ns)) + } +} +func TestSelectLeastExpectedAndBaselines(t *testing.T) { + strategy := &LeastLoadStrategy{ + settings: &StrategyLeastLoadConfig{ + Baselines: []int64{200, 300, 400}, + Expected: 3, + }, + } + nodes := []*node{ + {Tag: "a", RTTDeviationCost: 100}, + {Tag: "b", RTTDeviationCost: 200}, + {Tag: "c", RTTDeviationCost: 250}, + {Tag: "d", RTTDeviationCost: 300}, + {Tag: "e", RTTDeviationCost: 310}, + } + expected := 3 + ns := strategy.selectLeastLoad(nodes) + if len(ns) != expected { + t.Errorf("expected: %v, actual: %v", expected, len(ns)) + } +} +func TestSelectLeastExpectedAndBaselines2(t *testing.T) { + strategy := &LeastLoadStrategy{ + settings: &StrategyLeastLoadConfig{ + Baselines: []int64{200, 300, 400}, + Expected: 3, + }, + } + nodes := []*node{ + {Tag: "a", RTTDeviationCost: 500}, + {Tag: "b", RTTDeviationCost: 600}, + {Tag: "c", RTTDeviationCost: 700}, + {Tag: "d", RTTDeviationCost: 800}, + {Tag: "e", RTTDeviationCost: 900}, + } + expected := 3 + ns := strategy.selectLeastLoad(nodes) + if len(ns) != expected { + t.Errorf("expected: %v, actual: %v", expected, len(ns)) + } +} +func TestSelectLeastLoadBaselines(t *testing.T) { + strategy := &LeastLoadStrategy{ + settings: &StrategyLeastLoadConfig{ + Baselines: []int64{200, 400, 600}, + Expected: 0, + }, + } + nodes := []*node{ + {Tag: "a", RTTDeviationCost: 100}, + {Tag: "b", RTTDeviationCost: 200}, + {Tag: "c", RTTDeviationCost: 300}, + } + expected := 1 + ns := strategy.selectLeastLoad(nodes) + if len(ns) != expected { + t.Errorf("expected: %v, actual: %v", expected, len(ns)) + } +} +func TestSelectLeastLoadBaselinesNoQualified(t *testing.T) { + strategy := &LeastLoadStrategy{ + settings: &StrategyLeastLoadConfig{ + Baselines: []int64{200, 400, 600}, + Expected: 0, + }, + } + nodes := []*node{ + {Tag: "a", RTTDeviationCost: 800}, + {Tag: "b", RTTDeviationCost: 1000}, + } + expected := 0 + ns := strategy.selectLeastLoad(nodes) + if len(ns) != expected { + t.Errorf("expected: %v, actual: %v", expected, len(ns)) + } +} diff --git a/app/router/strategy_leastping.go b/app/router/strategy_leastping.go index e8c40aea..09ff845f 100644 --- a/app/router/strategy_leastping.go +++ b/app/router/strategy_leastping.go @@ -14,6 +14,10 @@ type LeastPingStrategy struct { observatory extension.Observatory } +func (l *LeastPingStrategy) GetPrincipleTarget(strings []string) []string { + return []string{l.PickOutbound(strings)} +} + func (l *LeastPingStrategy) InjectContext(ctx context.Context) { l.ctx = ctx } diff --git a/app/router/strategy_random.go b/app/router/strategy_random.go new file mode 100644 index 00000000..0bfe3ab6 --- /dev/null +++ b/app/router/strategy_random.go @@ -0,0 +1,21 @@ +package router + +import ( + "github.com/xtls/xray-core/common/dice" +) + +// RandomStrategy represents a random balancing strategy +type RandomStrategy struct{} + +func (s *RandomStrategy) GetPrincipleTarget(strings []string) []string { + return strings +} + +func (s *RandomStrategy) PickOutbound(candidates []string) string { + count := len(candidates) + if count == 0 { + // goes to fallbackTag + return "" + } + return candidates[dice.Roll(count)] +} diff --git a/app/router/weight.go b/app/router/weight.go new file mode 100644 index 00000000..c235740d --- /dev/null +++ b/app/router/weight.go @@ -0,0 +1,89 @@ +package router + +import ( + "regexp" + "strconv" + "strings" + "sync" +) + +type weightScaler func(value, weight float64) float64 + +var numberFinder = regexp.MustCompile(`\d+(\.\d+)?`) + +// NewWeightManager creates a new WeightManager with settings +func NewWeightManager(s []*StrategyWeight, defaultWeight float64, scaler weightScaler) *WeightManager { + return &WeightManager{ + settings: s, + cache: make(map[string]float64), + scaler: scaler, + defaultWeight: defaultWeight, + } +} + +// WeightManager manages weights for specific settings +type WeightManager struct { + settings []*StrategyWeight + cache map[string]float64 + scaler weightScaler + defaultWeight float64 + mu sync.Mutex +} + +// Get get the weight of specified tag +func (s *WeightManager) Get(tag string) float64 { + s.mu.Lock() + defer s.mu.Unlock() + weight, ok := s.cache[tag] + if ok { + return weight + } + weight = s.findValue(tag) + s.cache[tag] = weight + return weight +} + +// Apply applies weight to the value +func (s *WeightManager) Apply(tag string, value float64) float64 { + return s.scaler(value, s.Get(tag)) +} + +func (s *WeightManager) findValue(tag string) float64 { + for _, w := range s.settings { + matched := s.getMatch(tag, w.Match, w.Regexp) + if matched == "" { + continue + } + if w.Value > 0 { + return float64(w.Value) + } + // auto weight from matched + numStr := numberFinder.FindString(matched) + if numStr == "" { + return s.defaultWeight + } + weight, err := strconv.ParseFloat(numStr, 64) + if err != nil { + newError("unexpected error from ParseFloat: ", err).AtError().WriteToLog() + return s.defaultWeight + } + return weight + } + return s.defaultWeight +} + +func (s *WeightManager) getMatch(tag, find string, isRegexp bool) string { + if !isRegexp { + idx := strings.Index(tag, find) + if idx < 0 { + return "" + } + return find + } + r, err := regexp.Compile(find) + if err != nil { + newError("invalid regexp: ", find, "err: ", err).AtError().WriteToLog() + return "" + } + return r.FindString(tag) +} diff --git a/app/router/weight_test.go b/app/router/weight_test.go new file mode 100644 index 00000000..2e6a91e5 --- /dev/null +++ b/app/router/weight_test.go @@ -0,0 +1,60 @@ +package router_test + +import ( + "reflect" + "testing" + + "github.com/xtls/xray-core/app/router" +) + +func TestWeight(t *testing.T) { + manager := router.NewWeightManager( + []*router.StrategyWeight{ + { + Match: "x5", + Value: 100, + }, + { + Match: "x8", + }, + { + Regexp: true, + Match: `\bx0+(\.\d+)?\b`, + Value: 1, + }, + { + Regexp: true, + Match: `\bx\d+(\.\d+)?\b`, + }, + }, + 1, func(v, w float64) float64 { + return v * w + }, + ) + tags := []string{ + "node name, x5, and more", + "node name, x8", + "node name, x15", + "node name, x0100, and more", + "node name, x10.1", + "node name, x00.1, and more", + } + // test weight + expected := []float64{100, 8, 15, 100, 10.1, 1} + actual := make([]float64, 0) + for _, tag := range tags { + actual = append(actual, manager.Get(tag)) + } + if !reflect.DeepEqual(expected, actual) { + t.Errorf("expected: %v, actual: %v", expected, actual) + } + // test scale + expected2 := []float64{1000, 80, 150, 1000, 101, 10} + actual2 := make([]float64, 0) + for _, tag := range tags { + actual2 = append(actual2, manager.Apply(tag, 10)) + } + if !reflect.DeepEqual(expected2, actual2) { + t.Errorf("expected2: %v, actual2: %v", expected2, actual2) + } +} diff --git a/app/stats/command/command.pb.go b/app/stats/command/command.pb.go index 089dd183..1de78b96 100644 --- a/app/stats/command/command.pb.go +++ b/app/stats/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/stats/command/command.proto diff --git a/app/stats/config.pb.go b/app/stats/config.pb.go index 7c944e9b..24730161 100644 --- a/app/stats/config.pb.go +++ b/app/stats/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: app/stats/config.proto diff --git a/common/log/log.pb.go b/common/log/log.pb.go index 871d019b..3b0f89b0 100644 --- a/common/log/log.pb.go +++ b/common/log/log.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: common/log/log.proto diff --git a/common/net/address.pb.go b/common/net/address.pb.go index c0ebb72a..169ced8d 100644 --- a/common/net/address.pb.go +++ b/common/net/address.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: common/net/address.proto diff --git a/common/net/destination.pb.go b/common/net/destination.pb.go index ee775c7b..ac9fae9b 100644 --- a/common/net/destination.pb.go +++ b/common/net/destination.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: common/net/destination.proto diff --git a/common/net/network.pb.go b/common/net/network.pb.go index 39a1dcd3..867e3cd6 100644 --- a/common/net/network.pb.go +++ b/common/net/network.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: common/net/network.proto diff --git a/common/net/port.pb.go b/common/net/port.pb.go index 791e4e7e..1b80a81a 100644 --- a/common/net/port.pb.go +++ b/common/net/port.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: common/net/port.proto diff --git a/common/protocol/headers.pb.go b/common/protocol/headers.pb.go index f733c419..39e2f16d 100644 --- a/common/protocol/headers.pb.go +++ b/common/protocol/headers.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: common/protocol/headers.proto diff --git a/common/protocol/server_spec.pb.go b/common/protocol/server_spec.pb.go index 5c8ed7de..34642373 100644 --- a/common/protocol/server_spec.pb.go +++ b/common/protocol/server_spec.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: common/protocol/server_spec.proto diff --git a/common/protocol/user.pb.go b/common/protocol/user.pb.go index 77c26e22..972cca84 100644 --- a/common/protocol/user.pb.go +++ b/common/protocol/user.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: common/protocol/user.proto diff --git a/common/serial/typed_message.pb.go b/common/serial/typed_message.pb.go index 09c71b0d..a5846dc8 100644 --- a/common/serial/typed_message.pb.go +++ b/common/serial/typed_message.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: common/serial/typed_message.proto diff --git a/common/session/context.go b/common/session/context.go index 329a5a65..87586169 100644 --- a/common/session/context.go +++ b/common/session/context.go @@ -24,6 +24,7 @@ const ( dispatcherKey timeoutOnlyKey allowedNetworkKey + handlerSessionKey ) // ContextWithID returns a new context with the given ID. diff --git a/core/config.pb.go b/core/config.pb.go index 72ba2379..de21cc56 100644 --- a/core/config.pb.go +++ b/core/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: core/config.proto diff --git a/features/routing/balancer.go b/features/routing/balancer.go new file mode 100644 index 00000000..b1a2339f --- /dev/null +++ b/features/routing/balancer.go @@ -0,0 +1,10 @@ +package routing + +type BalancerOverrider interface { + SetOverrideTarget(tag, target string) error + GetOverrideTarget(tag string) (string, error) +} + +type BalancerPrincipleTarget interface { + GetPrincipleTarget(tag string) ([]string, error) +} diff --git a/infra/conf/api.go b/infra/conf/api.go index 879fc328..d1ec0391 100644 --- a/infra/conf/api.go +++ b/infra/conf/api.go @@ -7,6 +7,7 @@ import ( loggerservice "github.com/xtls/xray-core/app/log/command" observatoryservice "github.com/xtls/xray-core/app/observatory/command" handlerservice "github.com/xtls/xray-core/app/proxyman/command" + routerservice "github.com/xtls/xray-core/app/router/command" statsservice "github.com/xtls/xray-core/app/stats/command" "github.com/xtls/xray-core/common/serial" ) @@ -34,6 +35,8 @@ func (c *APIConfig) Build() (*commander.Config, error) { services = append(services, serial.ToTypedMessage(&statsservice.Config{})) case "observatoryservice": services = append(services, serial.ToTypedMessage(&observatoryservice.Config{})) + case "routingservice": + services = append(services, serial.ToTypedMessage(&routerservice.Config{})) } } diff --git a/infra/conf/observatory.go b/infra/conf/observatory.go index f51787a4..24c37a69 100644 --- a/infra/conf/observatory.go +++ b/infra/conf/observatory.go @@ -1,9 +1,11 @@ package conf import ( - "github.com/xtls/xray-core/app/observatory" - "github.com/xtls/xray-core/infra/conf/cfgcommon/duration" "google.golang.org/protobuf/proto" + + "github.com/xtls/xray-core/app/observatory" + "github.com/xtls/xray-core/app/observatory/burst" + "github.com/xtls/xray-core/infra/conf/cfgcommon/duration" ) type ObservatoryConfig struct { @@ -16,3 +18,17 @@ type ObservatoryConfig struct { func (o *ObservatoryConfig) Build() (proto.Message, error) { return &observatory.Config{SubjectSelector: o.SubjectSelector, ProbeUrl: o.ProbeURL, ProbeInterval: int64(o.ProbeInterval), EnableConcurrency: o.EnableConcurrency}, nil } + +type BurstObservatoryConfig struct { + SubjectSelector []string `json:"subjectSelector"` + // health check settings + HealthCheck *healthCheckSettings `json:"pingConfig,omitempty"` +} + +func (b BurstObservatoryConfig) Build() (proto.Message, error) { + if result, err := b.HealthCheck.Build(); err == nil { + return &burst.Config{SubjectSelector: b.SubjectSelector, PingConfig: result.(*burst.HealthPingConfig)}, nil + } else { + return nil, err + } +} diff --git a/infra/conf/router.go b/infra/conf/router.go index a3285e85..9c7ce789 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -8,6 +8,7 @@ import ( "github.com/xtls/xray-core/app/router" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/platform/filesystem" "google.golang.org/protobuf/proto" ) @@ -24,11 +25,13 @@ type StrategyConfig struct { } type BalancingRule struct { - Tag string `json:"tag"` - Selectors StringList `json:"selector"` - Strategy StrategyConfig `json:"strategy"` + Tag string `json:"tag"` + Selectors StringList `json:"selector"` + Strategy StrategyConfig `json:"strategy"` + FallbackTag string `json:"fallbackTag"` } +// Build builds the balancing rule func (r *BalancingRule) Build() (*router.BalancingRule, error) { if r.Tag == "" { return nil, newError("empty balancer tag") @@ -37,22 +40,37 @@ func (r *BalancingRule) Build() (*router.BalancingRule, error) { return nil, newError("empty selector list") } - var strategy string - switch strings.ToLower(r.Strategy.Type) { - case strategyRandom, "": - strategy = strategyRandom - case strategyLeastPing: - strategy = "leastPing" - case strategyRoundRobin: - strategy = "roundRobin" + r.Strategy.Type = strings.ToLower(r.Strategy.Type) + switch r.Strategy.Type { + case "": + r.Strategy.Type = strategyRandom + case strategyRandom, strategyLeastLoad, strategyLeastPing, strategyRoundRobin: default: return nil, newError("unknown balancing strategy: " + r.Strategy.Type) } + settings := []byte("{}") + if r.Strategy.Settings != nil { + settings = ([]byte)(*r.Strategy.Settings) + } + rawConfig, err := strategyConfigLoader.LoadWithID(settings, r.Strategy.Type) + if err != nil { + return nil, newError("failed to parse to strategy config.").Base(err) + } + var ts proto.Message + if builder, ok := rawConfig.(Buildable); ok { + ts, err = builder.Build() + if err != nil { + return nil, err + } + } + return &router.BalancingRule{ + Strategy: r.Strategy.Type, + StrategySettings: serial.ToTypedMessage(ts), + FallbackTag: r.FallbackTag, + OutboundSelector: r.Selectors, Tag: r.Tag, - OutboundSelector: []string(r.Selectors), - Strategy: strategy, }, nil } diff --git a/infra/conf/router_strategy.go b/infra/conf/router_strategy.go index ef2abc26..58367b4a 100644 --- a/infra/conf/router_strategy.go +++ b/infra/conf/router_strategy.go @@ -1,7 +1,93 @@ package conf +import ( + "google.golang.org/protobuf/proto" + + "github.com/xtls/xray-core/app/router" + "github.com/xtls/xray-core/app/observatory/burst" + "github.com/xtls/xray-core/infra/conf/cfgcommon/duration" +) + const ( strategyRandom string = "random" strategyLeastPing string = "leastping" strategyRoundRobin string = "roundrobin" + strategyLeastLoad string = "leastload" ) + +var ( + strategyConfigLoader = NewJSONConfigLoader(ConfigCreatorCache{ + strategyRandom: func() interface{} { return new(strategyEmptyConfig) }, + strategyLeastPing: func() interface{} { return new(strategyEmptyConfig) }, + strategyRoundRobin: func() interface{} { return new(strategyEmptyConfig) }, + strategyLeastLoad: func() interface{} { return new(strategyLeastLoadConfig) }, + }, "type", "settings") +) + +type strategyEmptyConfig struct { +} + +func (v *strategyEmptyConfig) Build() (proto.Message, error) { + return nil, nil +} + +type strategyLeastLoadConfig struct { + // weight settings + Costs []*router.StrategyWeight `json:"costs,omitempty"` + // ping rtt baselines + Baselines []duration.Duration `json:"baselines,omitempty"` + // expected nodes count to select + Expected int32 `json:"expected,omitempty"` + // max acceptable rtt, filter away high delay nodes. defalut 0 + MaxRTT duration.Duration `json:"maxRTT,omitempty"` + // acceptable failure rate + Tolerance float64 `json:"tolerance,omitempty"` +} + +// healthCheckSettings holds settings for health Checker +type healthCheckSettings struct { + Destination string `json:"destination"` + Connectivity string `json:"connectivity"` + Interval duration.Duration `json:"interval"` + SamplingCount int `json:"sampling"` + Timeout duration.Duration `json:"timeout"` +} + +func (h healthCheckSettings) Build() (proto.Message, error) { + return &burst.HealthPingConfig{ + Destination: h.Destination, + Connectivity: h.Connectivity, + Interval: int64(h.Interval), + Timeout: int64(h.Timeout), + SamplingCount: int32(h.SamplingCount), + }, nil +} + +// Build implements Buildable. +func (v *strategyLeastLoadConfig) Build() (proto.Message, error) { + config := &router.StrategyLeastLoadConfig{} + config.Costs = v.Costs + config.Tolerance = float32(v.Tolerance) + if config.Tolerance < 0 { + config.Tolerance = 0 + } + if config.Tolerance > 1 { + config.Tolerance = 1 + } + config.Expected = v.Expected + if config.Expected < 0 { + config.Expected = 0 + } + config.MaxRTT = int64(v.MaxRTT) + if config.MaxRTT < 0 { + config.MaxRTT = 0 + } + config.Baselines = make([]int64, 0) + for _, b := range v.Baselines { + if b <= 0 { + continue + } + config.Baselines = append(config.Baselines, int64(b)) + } + return config, nil +} diff --git a/infra/conf/router_test.go b/infra/conf/router_test.go index 63dc8e8d..0af1b3e3 100644 --- a/infra/conf/router_test.go +++ b/infra/conf/router_test.go @@ -5,6 +5,7 @@ import ( "os" "path/filepath" "testing" + "time" _ "unsafe" "github.com/xtls/xray-core/app/router" @@ -12,6 +13,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/common/platform/filesystem" + "github.com/xtls/xray-core/common/serial" . "github.com/xtls/xray-core/infra/conf" "google.golang.org/protobuf/proto" ) @@ -96,6 +98,34 @@ func TestRouterConfig(t *testing.T) { { "tag": "b1", "selector": ["test"] + }, + { + "tag": "b2", + "selector": ["test"], + "strategy": { + "type": "leastload", + "settings": { + "healthCheck": { + "interval": "5m0s", + "sampling": 2, + "timeout": "5s", + "destination": "dest", + "connectivity": "conn" + }, + "costs": [ + { + "regexp": true, + "match": "\\d+(\\.\\d+)", + "value": 5 + } + ], + "baselines": ["400ms", "600ms"], + "expected": 6, + "maxRTT": "1000ms", + "tolerance": 0.5 + } + }, + "fallbackTag": "fall" } ] }`, @@ -108,6 +138,28 @@ func TestRouterConfig(t *testing.T) { OutboundSelector: []string{"test"}, Strategy: "random", }, + { + Tag: "b2", + OutboundSelector: []string{"test"}, + Strategy: "leastload", + StrategySettings: serial.ToTypedMessage(&router.StrategyLeastLoadConfig{ + Costs: []*router.StrategyWeight{ + { + Regexp: true, + Match: "\\d+(\\.\\d+)", + Value: 5, + }, + }, + Baselines: []int64{ + int64(time.Duration(400) * time.Millisecond), + int64(time.Duration(600) * time.Millisecond), + }, + Expected: 6, + MaxRTT: int64(time.Duration(1000) * time.Millisecond), + Tolerance: 0.5, + }), + FallbackTag: "fall", + }, }, Rule: []*router.RoutingRule{ { diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 10944826..2144815a 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -410,6 +410,7 @@ type Config struct { Reverse *ReverseConfig `json:"reverse"` FakeDNS *FakeDNSConfig `json:"fakeDns"` Observatory *ObservatoryConfig `json:"observatory"` + BurstObservatory *BurstObservatoryConfig `json:"burstObservatory"` } func (c *Config) findInboundTag(tag string) int { @@ -639,6 +640,14 @@ func (c *Config) Build() (*core.Config, error) { config.App = append(config.App, serial.ToTypedMessage(r)) } + if c.BurstObservatory != nil { + r, err := c.BurstObservatory.Build() + if err != nil { + return nil, err + } + config.App = append(config.App, serial.ToTypedMessage(r)) + } + var inbounds []InboundDetourConfig if c.InboundConfig != nil { diff --git a/main/commands/all/api/api.go b/main/commands/all/api/api.go index 9986329b..0ff446b7 100644 --- a/main/commands/all/api/api.go +++ b/main/commands/all/api/api.go @@ -15,6 +15,8 @@ var CmdAPI = &base.Command{ cmdGetStats, cmdQueryStats, cmdSysStats, + cmdBalancerInfo, + cmdBalancerOverride, cmdAddInbounds, cmdAddOutbounds, cmdRemoveInbounds, diff --git a/main/commands/all/api/balancer_info.go b/main/commands/all/api/balancer_info.go new file mode 100644 index 00000000..4ba33236 --- /dev/null +++ b/main/commands/all/api/balancer_info.go @@ -0,0 +1,108 @@ +package api + +import ( + "fmt" + "os" + "strings" + + routerService "github.com/xtls/xray-core/app/router/command" + "github.com/xtls/xray-core/main/commands/base" +) + +// TODO: support "-json" flag for json output +var cmdBalancerInfo = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api bi [--server=127.0.0.1:8080] [balancer]...", + Short: "balancer information", + Long: ` +Get information of specified balancers, including health, strategy +and selecting. If no balancer tag specified, get information of +all balancers. + +> Make sure you have "RoutingService" set in "config.api.services" +of server config. + +Arguments: + + -json + Use json output. + + -s, -server + The API server address. Default 127.0.0.1:8080 + + -t, -timeout + Timeout seconds to call API. Default 3 + +Example: + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 balancer1 balancer2 +`, + Run: executeBalancerInfo, +} + +func executeBalancerInfo(cmd *base.Command, args []string) { + setSharedFlags(cmd) + cmd.Flag.Parse(args) + + conn, ctx, close := dialAPIServer() + defer close() + + client := routerService.NewRoutingServiceClient(conn) + r := &routerService.GetBalancerInfoRequest{Tag: args[0]} + resp, err := client.GetBalancerInfo(ctx, r) + if err != nil { + base.Fatalf("failed to get health information: %s", err) + } + + if apiJSON { + showJSONResponse(resp) + return + } + + showBalancerInfo(resp.Balancer) + +} + +func showBalancerInfo(b *routerService.BalancerMsg) { + const tableIndent = 4 + sb := new(strings.Builder) + // Override + if b.Override != nil { + sb.WriteString(" - Selecting Override:\n") + for i, s := range []string{b.Override.Target} { + writeRow(sb, tableIndent, i+1, []string{s}, nil) + } + } + // Selects + sb.WriteString(" - Selects:\n") + + for i, o := range b.PrincipleTarget.Tag { + writeRow(sb, tableIndent, i+1, []string{o}, nil) + } + os.Stdout.WriteString(sb.String()) +} + +func getColumnFormats(titles []string) []string { + w := make([]string, len(titles)) + for i, t := range titles { + w[i] = fmt.Sprintf("%%-%ds ", len(t)) + } + return w +} + +func writeRow(sb *strings.Builder, indent, index int, values, formats []string) { + if index == 0 { + // title line + sb.WriteString(strings.Repeat(" ", indent+4)) + } else { + sb.WriteString(fmt.Sprintf("%s%-4d", strings.Repeat(" ", indent), index)) + } + for i, v := range values { + format := "%-14s" + if i < len(formats) { + format = formats[i] + } + sb.WriteString(fmt.Sprintf(format, v)) + } + sb.WriteByte('\n') +} diff --git a/main/commands/all/api/balancer_override.go b/main/commands/all/api/balancer_override.go new file mode 100644 index 00000000..3ac013e9 --- /dev/null +++ b/main/commands/all/api/balancer_override.go @@ -0,0 +1,77 @@ +package api + +import ( + routerService "github.com/xtls/xray-core/app/router/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdBalancerOverride = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api bo [--server=127.0.0.1:8080] <-b balancer> outboundTag", + Short: "balancer override", + Long: ` +Override a balancer's selection. + +> Make sure you have "RoutingService" set in "config.api.services" +of server config. + +Once a balancer's selecting is overridden: + +- The balancer's selection result will always be outboundTag + +Arguments: + + -r, -remove + Remove the overridden + + -r, -remove + Remove the override + + -s, -server + The API server address. Default 127.0.0.1:8080 + + -t, -timeout + Timeout seconds to call API. Default 3 + +Example: + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -b balancer tag + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -b balancer -r +`, + Run: executeBalancerOverride, +} + +func executeBalancerOverride(cmd *base.Command, args []string) { + var ( + balancer string + remove bool + ) + cmd.Flag.StringVar(&balancer, "b", "", "") + cmd.Flag.StringVar(&balancer, "balancer", "", "") + cmd.Flag.BoolVar(&remove, "r", false, "") + cmd.Flag.BoolVar(&remove, "remove", false, "") + setSharedFlags(cmd) + cmd.Flag.Parse(args) + + if balancer == "" { + base.Fatalf("balancer tag not specified") + } + + conn, ctx, close := dialAPIServer() + defer close() + + client := routerService.NewRoutingServiceClient(conn) + target := "" + if !remove { + target = cmd.Flag.Args()[0] + } + r := &routerService.OverrideBalancerTargetRequest{ + BalancerTag: balancer, + Target: target, + } + + _, err := client.OverrideBalancerTarget(ctx, r) + if err != nil { + base.Fatalf("failed to perform balancer health checks: %s", err) + } +} diff --git a/main/commands/all/api/shared.go b/main/commands/all/api/shared.go index d3aaf0e1..4d98359f 100644 --- a/main/commands/all/api/shared.go +++ b/main/commands/all/api/shared.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "google.golang.org/protobuf/encoding/protojson" "io" "net/http" "net/url" @@ -15,7 +16,6 @@ import ( "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/main/commands/base" "google.golang.org/grpc" - "google.golang.org/protobuf/encoding/protojson" "google.golang.org/protobuf/proto" ) @@ -24,6 +24,7 @@ type serviceHandler func(ctx context.Context, conn *grpc.ClientConn, cmd *base.C var ( apiServerAddrPtr string apiTimeout int + apiJSON bool ) func setSharedFlags(cmd *base.Command) { @@ -31,6 +32,7 @@ func setSharedFlags(cmd *base.Command) { cmd.Flag.StringVar(&apiServerAddrPtr, "server", "127.0.0.1:8080", "") cmd.Flag.IntVar(&apiTimeout, "t", 3, "") cmd.Flag.IntVar(&apiTimeout, "timeout", 3, "") + cmd.Flag.BoolVar(&apiJSON, "json", false, "") } func dialAPIServer() (conn *grpc.ClientConn, ctx context.Context, close func()) { @@ -103,13 +105,8 @@ func fetchHTTPContent(target string) ([]byte, error) { return content, nil } -func protoToJSONString(m proto.Message, _, indent string) (string, error) { - ops := protojson.MarshalOptions{ - Indent: indent, - EmitUnpopulated: true, - } - b, err := ops.Marshal(m) - return string(b), err +func protoToJSONString(m proto.Message, prefix, indent string) (string, error) { + return strings.TrimSpace(protojson.MarshalOptions{Indent: indent}.Format(m)), nil } func showJSONResponse(m proto.Message) { diff --git a/proxy/blackhole/config.pb.go b/proxy/blackhole/config.pb.go index 0cdb33a7..6b047974 100644 --- a/proxy/blackhole/config.pb.go +++ b/proxy/blackhole/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/blackhole/config.proto diff --git a/proxy/dns/config.pb.go b/proxy/dns/config.pb.go index 767ad2ca..6b1f062a 100644 --- a/proxy/dns/config.pb.go +++ b/proxy/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/dns/config.proto diff --git a/proxy/dokodemo/config.pb.go b/proxy/dokodemo/config.pb.go index c56e74b9..206089e8 100644 --- a/proxy/dokodemo/config.pb.go +++ b/proxy/dokodemo/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/dokodemo/config.proto diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 81ce18e5..447c9cde 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.32.0 -// protoc v4.25.2 +// protoc v4.23.1 // source: proxy/freedom/config.proto package freedom diff --git a/proxy/http/config.pb.go b/proxy/http/config.pb.go index 6ae78777..4c5776e6 100644 --- a/proxy/http/config.pb.go +++ b/proxy/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/http/config.proto diff --git a/proxy/loopback/config.pb.go b/proxy/loopback/config.pb.go index 3902e532..f9a89d55 100644 --- a/proxy/loopback/config.pb.go +++ b/proxy/loopback/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/loopback/config.proto diff --git a/proxy/shadowsocks/config.pb.go b/proxy/shadowsocks/config.pb.go index 86351df8..33d96f5c 100644 --- a/proxy/shadowsocks/config.pb.go +++ b/proxy/shadowsocks/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/shadowsocks/config.proto diff --git a/proxy/shadowsocks_2022/config.pb.go b/proxy/shadowsocks_2022/config.pb.go index 633f3cda..12d03625 100644 --- a/proxy/shadowsocks_2022/config.pb.go +++ b/proxy/shadowsocks_2022/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/shadowsocks_2022/config.proto diff --git a/proxy/socks/config.pb.go b/proxy/socks/config.pb.go index c22af748..991b467e 100644 --- a/proxy/socks/config.pb.go +++ b/proxy/socks/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/socks/config.proto diff --git a/proxy/trojan/config.pb.go b/proxy/trojan/config.pb.go index d90271d9..63003b50 100644 --- a/proxy/trojan/config.pb.go +++ b/proxy/trojan/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/trojan/config.proto diff --git a/proxy/vless/account.pb.go b/proxy/vless/account.pb.go index 405d8811..21f1a729 100644 --- a/proxy/vless/account.pb.go +++ b/proxy/vless/account.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/vless/account.proto diff --git a/proxy/vless/encoding/addons.pb.go b/proxy/vless/encoding/addons.pb.go index 8c409cbc..02dcc713 100644 --- a/proxy/vless/encoding/addons.pb.go +++ b/proxy/vless/encoding/addons.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/vless/encoding/addons.proto diff --git a/proxy/vless/inbound/config.pb.go b/proxy/vless/inbound/config.pb.go index c2ddd5e5..952b3b51 100644 --- a/proxy/vless/inbound/config.pb.go +++ b/proxy/vless/inbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/vless/inbound/config.proto diff --git a/proxy/vless/outbound/config.pb.go b/proxy/vless/outbound/config.pb.go index 3fb9ed75..428110d8 100644 --- a/proxy/vless/outbound/config.pb.go +++ b/proxy/vless/outbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/vless/outbound/config.proto diff --git a/proxy/vmess/account.pb.go b/proxy/vmess/account.pb.go index 575ec583..0d41c368 100644 --- a/proxy/vmess/account.pb.go +++ b/proxy/vmess/account.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/vmess/account.proto diff --git a/proxy/vmess/inbound/config.pb.go b/proxy/vmess/inbound/config.pb.go index 67fa6461..e7d50c6a 100644 --- a/proxy/vmess/inbound/config.pb.go +++ b/proxy/vmess/inbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/vmess/inbound/config.proto diff --git a/proxy/vmess/outbound/config.pb.go b/proxy/vmess/outbound/config.pb.go index 80492e05..c08479f7 100644 --- a/proxy/vmess/outbound/config.pb.go +++ b/proxy/vmess/outbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/vmess/outbound/config.proto diff --git a/proxy/wireguard/config.pb.go b/proxy/wireguard/config.pb.go index 47bd2b77..c620471e 100644 --- a/proxy/wireguard/config.pb.go +++ b/proxy/wireguard/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: proxy/wireguard/config.proto diff --git a/transport/global/config.pb.go b/transport/global/config.pb.go index 4bd8c84f..046c39e8 100644 --- a/transport/global/config.pb.go +++ b/transport/global/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/global/config.proto diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 9636bfb4..3c8e36f5 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/config.proto diff --git a/transport/internet/domainsocket/config.pb.go b/transport/internet/domainsocket/config.pb.go index 9d3eb25c..276293f1 100644 --- a/transport/internet/domainsocket/config.pb.go +++ b/transport/internet/domainsocket/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/domainsocket/config.proto diff --git a/transport/internet/grpc/config.pb.go b/transport/internet/grpc/config.pb.go index 4a794bb1..43da0199 100644 --- a/transport/internet/grpc/config.pb.go +++ b/transport/internet/grpc/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/grpc/config.proto diff --git a/transport/internet/grpc/encoding/stream.pb.go b/transport/internet/grpc/encoding/stream.pb.go index f8e7c7fb..6450c7d1 100644 --- a/transport/internet/grpc/encoding/stream.pb.go +++ b/transport/internet/grpc/encoding/stream.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/grpc/encoding/stream.proto diff --git a/transport/internet/headers/dns/config.pb.go b/transport/internet/headers/dns/config.pb.go index 34d37c33..1dc5783e 100644 --- a/transport/internet/headers/dns/config.pb.go +++ b/transport/internet/headers/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/headers/dns/config.proto diff --git a/transport/internet/headers/http/config.pb.go b/transport/internet/headers/http/config.pb.go index 69fefd8c..b18e4228 100644 --- a/transport/internet/headers/http/config.pb.go +++ b/transport/internet/headers/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/headers/http/config.proto diff --git a/transport/internet/headers/noop/config.pb.go b/transport/internet/headers/noop/config.pb.go index 9777e46f..fdccb47e 100644 --- a/transport/internet/headers/noop/config.pb.go +++ b/transport/internet/headers/noop/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/headers/noop/config.proto diff --git a/transport/internet/headers/srtp/config.pb.go b/transport/internet/headers/srtp/config.pb.go index 2d9c5354..ed841c38 100644 --- a/transport/internet/headers/srtp/config.pb.go +++ b/transport/internet/headers/srtp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/headers/srtp/config.proto diff --git a/transport/internet/headers/tls/config.pb.go b/transport/internet/headers/tls/config.pb.go index c0b77de4..aa026e8a 100644 --- a/transport/internet/headers/tls/config.pb.go +++ b/transport/internet/headers/tls/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/headers/tls/config.proto diff --git a/transport/internet/headers/utp/config.pb.go b/transport/internet/headers/utp/config.pb.go index b3bd9749..a6e1dd1e 100644 --- a/transport/internet/headers/utp/config.pb.go +++ b/transport/internet/headers/utp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/headers/utp/config.proto diff --git a/transport/internet/headers/wechat/config.pb.go b/transport/internet/headers/wechat/config.pb.go index 8bec6fe4..edb45f28 100644 --- a/transport/internet/headers/wechat/config.pb.go +++ b/transport/internet/headers/wechat/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/headers/wechat/config.proto diff --git a/transport/internet/headers/wireguard/config.pb.go b/transport/internet/headers/wireguard/config.pb.go index 4274198c..f46ba626 100644 --- a/transport/internet/headers/wireguard/config.pb.go +++ b/transport/internet/headers/wireguard/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/headers/wireguard/config.proto diff --git a/transport/internet/http/config.pb.go b/transport/internet/http/config.pb.go index baaa5630..12624f02 100644 --- a/transport/internet/http/config.pb.go +++ b/transport/internet/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/http/config.proto diff --git a/transport/internet/kcp/config.pb.go b/transport/internet/kcp/config.pb.go index 74537db7..2369dc50 100644 --- a/transport/internet/kcp/config.pb.go +++ b/transport/internet/kcp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/kcp/config.proto diff --git a/transport/internet/quic/config.pb.go b/transport/internet/quic/config.pb.go index f10998eb..b5b9b8a3 100644 --- a/transport/internet/quic/config.pb.go +++ b/transport/internet/quic/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/quic/config.proto diff --git a/transport/internet/reality/config.pb.go b/transport/internet/reality/config.pb.go index 6631d0af..220d871d 100644 --- a/transport/internet/reality/config.pb.go +++ b/transport/internet/reality/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.32.0 -// protoc v4.25.1 +// protoc v4.23.1 // source: transport/internet/reality/config.proto package reality diff --git a/transport/internet/tcp/config.pb.go b/transport/internet/tcp/config.pb.go index e7ecd49b..1ee10034 100644 --- a/transport/internet/tcp/config.pb.go +++ b/transport/internet/tcp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/tcp/config.proto diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index 7602f3e9..daa02fd9 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/tls/config.proto diff --git a/transport/internet/udp/config.pb.go b/transport/internet/udp/config.pb.go index b56c5fa4..82df7a75 100644 --- a/transport/internet/udp/config.pb.go +++ b/transport/internet/udp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/udp/config.proto diff --git a/transport/internet/websocket/config.pb.go b/transport/internet/websocket/config.pb.go index ab0aa373..490dcfa0 100644 --- a/transport/internet/websocket/config.pb.go +++ b/transport/internet/websocket/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.32.0 // protoc v4.23.1 // source: transport/internet/websocket/config.proto From 5ea1315b85c3b448e7f8b27c9c1e20fc61acac49 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 18 Feb 2024 06:55:47 +0000 Subject: [PATCH 272/867] Update workflows to use Go 1.22 --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 678831c6..ef320e95 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -167,7 +167,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.22' check-latest: true - name: Get project dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59ee22c1..dab4f822 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.21' + go-version: '1.22' check-latest: true - name: Checkout codebase uses: actions/checkout@v4 From cae94570df467d6073f791a80bafc5f3f36773f9 Mon Sep 17 00:00:00 2001 From: deorth-kku Date: Sat, 3 Feb 2024 19:45:37 +0800 Subject: [PATCH 273/867] Fixing tcp connestions leak - always use HandshakeContext instead of Handshake - pickup dailer dropped ctx - rename HandshakeContextAddress to HandshakeAddressContext --- proxy/dokodemo/dokodemo.go | 8 +++--- proxy/http/client.go | 2 +- transport/internet/http/dialer.go | 2 +- transport/internet/tcp/dialer.go | 2 +- transport/internet/tls/grpc.go | 2 +- transport/internet/tls/tls.go | 36 ++++++++++++++++++++------ transport/internet/websocket/dialer.go | 4 +-- 7 files changed, 38 insertions(+), 18 deletions(-) diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 4a4735e8..1c59fe62 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -71,8 +71,8 @@ func (d *DokodemoDoor) policy() policy.Session { return p } -type hasHandshakeAddress interface { - HandshakeAddress() net.Address +type hasHandshakeAddressContext interface { + HandshakeAddressContext(ctx context.Context) net.Address } // Process implements proxy.Inbound. @@ -89,8 +89,8 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st if outbound := session.OutboundFromContext(ctx); outbound != nil && outbound.Target.IsValid() { dest = outbound.Target destinationOverridden = true - } else if handshake, ok := conn.(hasHandshakeAddress); ok { - addr := handshake.HandshakeAddress() + } else if handshake, ok := conn.(hasHandshakeAddressContext); ok { + addr := handshake.HandshakeAddressContext(ctx) if addr != nil { dest.Address = addr destinationOverridden = true diff --git a/proxy/http/client.go b/proxy/http/client.go index 302e521d..72060c4d 100644 --- a/proxy/http/client.go +++ b/proxy/http/client.go @@ -308,7 +308,7 @@ func setUpHTTPTunnel(ctx context.Context, dest net.Destination, target string, u nextProto := "" if tlsConn, ok := iConn.(*tls.Conn); ok { - if err := tlsConn.Handshake(); err != nil { + if err := tlsConn.HandshakeContext(ctx); err != nil { rawConn.Close() return nil, err } diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index 1ea3a738..513962d3 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -87,7 +87,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in } else { cn = tls.Client(pconn, tlsConfig).(*tls.Conn) } - if err := cn.Handshake(); err != nil { + if err := cn.HandshakeContext(ctx); err != nil { newError("failed to dial to " + addr).Base(err).AtError().WriteToLog() return nil, err } diff --git a/transport/internet/tcp/dialer.go b/transport/internet/tcp/dialer.go index 840062b1..06ee3ecf 100644 --- a/transport/internet/tcp/dialer.go +++ b/transport/internet/tcp/dialer.go @@ -24,7 +24,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me tlsConfig := config.GetTLSConfig(tls.WithDestination(dest)) if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil { conn = tls.UClient(conn, tlsConfig, fingerprint) - if err := conn.(*tls.UConn).Handshake(); err != nil { + if err := conn.(*tls.UConn).HandshakeContext(ctx); err != nil { return nil, err } } else { diff --git a/transport/internet/tls/grpc.go b/transport/internet/tls/grpc.go index a698196b..6e5dc578 100644 --- a/transport/internet/tls/grpc.go +++ b/transport/internet/tls/grpc.go @@ -65,7 +65,7 @@ func (c *grpcUtls) ClientHandshake(ctx context.Context, authority string, rawCon conn := UClient(rawConn, cfg, c.fingerprint).(*UConn) errChannel := make(chan error, 1) go func() { - errChannel <- conn.Handshake() + errChannel <- conn.HandshakeContext(ctx) close(errChannel) }() select { diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index e73a495b..73631ef9 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -1,9 +1,11 @@ package tls import ( + "context" "crypto/rand" "crypto/tls" "math/big" + "time" utls "github.com/refraction-networking/utls" "github.com/xtls/xray-core/common/buf" @@ -14,7 +16,7 @@ import ( type Interface interface { net.Conn - Handshake() error + HandshakeContext(ctx context.Context) error VerifyHostname(host string) error NegotiatedProtocol() (name string, mutual bool) } @@ -25,6 +27,16 @@ type Conn struct { *tls.Conn } +const tlsCloseTimeout = 250 * time.Millisecond + +func (c *Conn) Close() error { + timer := time.AfterFunc(tlsCloseTimeout, func() { + c.Conn.NetConn().Close() + }) + defer timer.Stop() + return c.Conn.Close() +} + func (c *Conn) WriteMultiBuffer(mb buf.MultiBuffer) error { mb = buf.Compact(mb) mb, err := buf.WriteMultiBuffer(c, mb) @@ -32,8 +44,8 @@ func (c *Conn) WriteMultiBuffer(mb buf.MultiBuffer) error { return err } -func (c *Conn) HandshakeAddress() net.Address { - if err := c.Handshake(); err != nil { +func (c *Conn) HandshakeAddressContext(ctx context.Context) net.Address { + if err := c.HandshakeContext(ctx); err != nil { return nil } state := c.ConnectionState() @@ -64,8 +76,16 @@ type UConn struct { *utls.UConn } -func (c *UConn) HandshakeAddress() net.Address { - if err := c.Handshake(); err != nil { +func (c *UConn) Close() error { + timer := time.AfterFunc(tlsCloseTimeout, func() { + c.Conn.NetConn().Close() + }) + defer timer.Stop() + return c.Conn.Close() +} + +func (c *UConn) HandshakeAddressContext(ctx context.Context) net.Address { + if err := c.HandshakeContext(ctx); err != nil { return nil } state := c.ConnectionState() @@ -77,7 +97,7 @@ func (c *UConn) HandshakeAddress() net.Address { // WebsocketHandshake basically calls UConn.Handshake inside it but it will only send // http/1.1 in its ALPN. -func (c *UConn) WebsocketHandshake() error { +func (c *UConn) WebsocketHandshakeContext(ctx context.Context) error { // Build the handshake state. This will apply every variable of the TLS of the // fingerprint in the UConn if err := c.BuildHandshakeState(); err != nil { @@ -99,7 +119,7 @@ func (c *UConn) WebsocketHandshake() error { if err := c.BuildHandshakeState(); err != nil { return err } - return c.Handshake() + return c.HandshakeContext(ctx) } func (c *UConn) NegotiatedProtocol() (name string, mutual bool) { @@ -118,7 +138,7 @@ func copyConfig(c *tls.Config) *utls.Config { ServerName: c.ServerName, InsecureSkipVerify: c.InsecureSkipVerify, VerifyPeerCertificate: c.VerifyPeerCertificate, - KeyLogWriter: c.KeyLogWriter, + KeyLogWriter: c.KeyLogWriter, } } diff --git a/transport/internet/websocket/dialer.go b/transport/internet/websocket/dialer.go index 02b73a66..4ef27831 100644 --- a/transport/internet/websocket/dialer.go +++ b/transport/internet/websocket/dialer.go @@ -96,7 +96,7 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in } // TLS and apply the handshake cn := tls.UClient(pconn, tlsConfig, fingerprint).(*tls.UConn) - if err := cn.WebsocketHandshake(); err != nil { + if err := cn.WebsocketHandshakeContext(ctx); err != nil { newError("failed to dial to " + addr).Base(err).AtError().WriteToLog() return nil, err } @@ -147,7 +147,7 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in header.Set("Sec-WebSocket-Protocol", base64.RawURLEncoding.EncodeToString(ed)) } - conn, resp, err := dialer.Dial(uri, header) + conn, resp, err := dialer.DialContext(ctx, uri, header) if err != nil { var reason string if resp != nil { From ad3dd3df56b9e4486d7b1116a6496359c7c44153 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 19 Feb 2024 15:16:43 +0000 Subject: [PATCH 274/867] Update go.mod to specify Go 1.22 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 91b31d4c..85bf5bc1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/xtls/xray-core -go 1.21.4 +go 1.22 require ( github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 From f9653d0d888bad1f403f2a14624351aae07a762c Mon Sep 17 00:00:00 2001 From: Allo Date: Tue, 20 Feb 2024 09:25:22 +0800 Subject: [PATCH 275/867] chore(ci): use go version file to specify the go version --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ef320e95..8d6476aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -167,7 +167,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.22' + go-version-file: go.mod check-latest: true - name: Get project dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dab4f822..da178740 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,13 +27,13 @@ jobs: matrix: os: [windows-latest, ubuntu-latest, macos-latest] steps: + - name: Checkout codebase + uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.22' + go-version-file: go.mod check-latest: true - - name: Checkout codebase - uses: actions/checkout@v4 - name: Restore Cache uses: actions/cache/restore@v4 with: From c100d35b8808bf1029e8a1c243d7e5663763ed3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= <45535409+Fangliding@users.noreply.github.com> Date: Wed, 21 Feb 2024 14:22:24 +0800 Subject: [PATCH 276/867] Fix a little version issue --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 85bf5bc1..7e89e6ce 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/xtls/xray-core -go 1.22 +go 1.22.0 require ( github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 From a0f1e1f37762bc456d06034b788d0a2b7ac6ff09 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Tue, 20 Feb 2024 20:24:31 -0500 Subject: [PATCH 277/867] FakeDNS return TTL=1 and drop HTTPS QType 65 request Co-authored-by: qwerr0 --- app/dispatcher/default.go | 6 +++--- proxy/dns/dns.go | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index effa2198..b8131b8f 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -199,7 +199,7 @@ func (d *DefaultDispatcher) shouldOverride(ctx context.Context, result SniffResu return true } if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && protocolString != "bittorrent" && p == "fakedns" && - destination.Address.Family().IsIP() && fkr0.IsIPInIPPool(destination.Address) { + fkr0.IsIPInIPPool(destination.Address) { newError("Using sniffer ", protocolString, " since the fake DNS missed").WriteToLog(session.ExportIDToError(ctx)) return true } @@ -254,7 +254,7 @@ func (d *DefaultDispatcher) Dispatch(ctx context.Context, destination net.Destin protocol = resComp.ProtocolForDomainResult() } isFakeIP := false - if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && ob.Target.Address.Family().IsIP() && fkr0.IsIPInIPPool(ob.Target.Address) { + if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && fkr0.IsIPInIPPool(ob.Target.Address) { isFakeIP = true } if sniffingRequest.RouteOnly && protocol != "fakedns" && protocol != "fakedns+others" && !isFakeIP { @@ -307,7 +307,7 @@ func (d *DefaultDispatcher) DispatchLink(ctx context.Context, destination net.De protocol = resComp.ProtocolForDomainResult() } isFakeIP := false - if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && ob.Target.Address.Family().IsIP() && fkr0.IsIPInIPPool(ob.Target.Address) { + if fkr0, ok := d.fdns.(dns.FakeDNSEngineRev0); ok && fkr0.IsIPInIPPool(ob.Target.Address) { isFakeIP = true } if sniffingRequest.RouteOnly && protocol != "fakedns" && protocol != "fakedns+others" && !isFakeIP { diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index 415fe991..2cf21a42 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -27,6 +27,9 @@ func init() { common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { h := new(Handler) if err := core.RequireFeatures(ctx, func(dnsClient dns.Client, policyManager policy.Manager) error { + core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { + h.fdns = fdns + }) return h.Init(config.(*Config), dnsClient, policyManager) }); err != nil { return nil, err @@ -41,6 +44,7 @@ type ownLinkVerifier interface { type Handler struct { client dns.Client + fdns dns.FakeDNSEngine ownLinkVerifier ownLinkVerifier server net.Destination timeout time.Duration @@ -179,7 +183,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet. if isIPQuery { go h.handleIPQuery(id, qType, domain, writer) } - if isIPQuery || h.nonIPQuery == "drop" { + if isIPQuery || h.nonIPQuery == "drop" || qType == 65 { b.Release() continue } @@ -244,6 +248,10 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string, return } + if fkr0, ok := h.fdns.(dns.FakeDNSEngineRev0); ok && len(ips) > 0 && fkr0.IsIPInIPPool(net.IPAddress(ips[0])) { + ttl = 1 + } + switch qType { case dnsmessage.TypeA: for i, ip := range ips { From 3778a367c8aa5c07162b4003c672945a6296c169 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 21 Feb 2024 13:58:50 -0500 Subject: [PATCH 278/867] Fix and simplify SockOpt in UDP https://github.com/golang/go/issues/29277 --- transport/internet/system_dialer.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index 924f364c..3c9239e8 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -2,7 +2,6 @@ package internet import ( "context" - "runtime" "syscall" "time" @@ -67,17 +66,16 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne if err != nil { return nil, err } - if runtime.GOOS != "windows" && (sockopt != nil || len(d.controllers) > 0) { - file, err := packetConn.(*net.UDPConn).File() + if sockopt != nil { + sys, err := packetConn.(*net.UDPConn).SyscallConn() if err != nil { return nil, err } - fd := file.Fd() - if sockopt != nil { + sys.Control(func(fd uintptr) { if err := applyOutboundSocketOptions("udp", dest.NetAddr(), fd, sockopt); err != nil { newError("failed to apply socket options").Base(err).WriteToLog(session.ExportIDToError(ctx)) } - } + }) } return &PacketConnWrapper{ Conn: packetConn, From 51bacf7722ed6c707af6d8f5c00101cc26dd716f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 00:25:04 +0000 Subject: [PATCH 279/867] Bump github.com/refraction-networking/utls from 1.6.2 to 1.6.3 Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.6.2 to 1.6.3. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.6.2...v1.6.3) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7e89e6ce..4770f016 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.41.0 - github.com/refraction-networking/utls v1.6.2 + github.com/refraction-networking/utls v1.6.3 github.com/sagernet/sing v0.3.0 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index cf6dd63c..02d4b688 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k= github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= -github.com/refraction-networking/utls v1.6.2 h1:iTeeGY0o6nMNcGyirxkD5bFIsVctP5InGZ3E0HrzS7k= -github.com/refraction-networking/utls v1.6.2/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr3h62pQoY1lXiNR/FPs= +github.com/refraction-networking/utls v1.6.3 h1:MFOfRN35sSx6K5AZNIoESsBuBxS2LCgRilRIdHb6fDc= +github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr3h62pQoY1lXiNR/FPs= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= From 84d9c63bdbb2fe43ea47828ce7aee66a5eddfcdb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 00:25:09 +0000 Subject: [PATCH 280/867] Bump google.golang.org/grpc from 1.61.1 to 1.62.0 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.61.1 to 1.62.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.61.1...v1.62.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 4770f016..4cc79202 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/sync v0.6.0 golang.org/x/sys v0.17.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.61.1 + google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 @@ -55,7 +55,7 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.17.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 02d4b688..d5fd10bc 100644 --- a/go.sum +++ b/go.sum @@ -271,14 +271,14 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY= -google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= +google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= +google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= From d5e94deea6373319c4fe8bad2a67e1751dc05184 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:12:55 +0000 Subject: [PATCH 281/867] Bump github.com/sagernet/sing from 0.3.0 to 0.3.2 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.3.0 to 0.3.2. - [Commits](https://github.com/sagernet/sing/compare/v0.3.0...v0.3.2) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4cc79202..e0d34c2b 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.41.0 github.com/refraction-networking/utls v1.6.3 - github.com/sagernet/sing v0.3.0 + github.com/sagernet/sing v0.3.2 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index d5fd10bc..ee022ada 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.3.0 h1:PIDVFZHnQAAYRL1UYqNM+0k5s8f/tb1lUW6UDcQiOc8= -github.com/sagernet/sing v0.3.0/go.mod h1:9pfuAH6mZfgnz/YjP6xu5sxx882rfyjpcrTdUpd6w3g= +github.com/sagernet/sing v0.3.2 h1:CwWcxUBPkMvwgfe2/zUgY5oHG9qOL8Aob/evIFYK9jo= +github.com/sagernet/sing v0.3.2/go.mod h1:qHySJ7u8po9DABtMYEkNBcOumx7ZZJf/fbv2sfTkNHE= github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= From 57f0a6712f4ccda375cb08dcd7989f0c8ba9074a Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 21 Feb 2024 17:40:27 -0500 Subject: [PATCH 282/867] Revert "Fix a little version issue" This reverts commit c100d35b8808bf1029e8a1c243d7e5663763ed3f. --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index e0d34c2b..910c1074 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/xtls/xray-core -go 1.22.0 +go 1.22 require ( github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 From 1c8375997d627d6ae40df4f4c242293d01659974 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 25 Feb 2024 09:31:59 -0500 Subject: [PATCH 283/867] Update 1.8.8 and dependencies --- core/core.go | 2 +- go.mod | 20 +++++++++--------- go.sum | 59 ++++++++++++++++++++++++++-------------------------- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/core/core.go b/core/core.go index 09a591f2..b7cd1d9b 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 7 + Version_z byte = 8 ) var ( diff --git a/go.mod b/go.mod index 910c1074..5445c267 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 - github.com/golang/mock v1.6.0 + github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.6.0 github.com/gorilla/websocket v1.5.1 github.com/miekg/dns v1.1.58 @@ -33,7 +33,7 @@ require ( ) require ( - github.com/andybalholm/brotli v1.0.6 // indirect + github.com/andybalholm/brotli v1.1.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect @@ -41,21 +41,21 @@ require ( github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 // indirect - github.com/klauspost/compress v1.17.4 // indirect - github.com/klauspost/cpuid/v2 v2.2.6 // indirect - github.com/onsi/ginkgo/v2 v2.13.2 // indirect + github.com/google/pprof v0.0.0-20240225044709-fd706174c886 // indirect + github.com/klauspost/compress v1.17.7 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/onsi/ginkgo/v2 v2.15.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.4.0 // indirect - golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect - golang.org/x/mod v0.14.0 // indirect + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect + golang.org/x/mod v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/tools v0.18.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index ee022ada..ed2a6ba4 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,8 @@ dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1 dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/andybalholm/brotli v1.0.6 h1:Yf9fFpf49Zrxb9NlQaluyE92/+X7UVHlhMNJN2sxfOI= -github.com/andybalholm/brotli v1.0.6/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= +github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= @@ -43,8 +43,8 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U= +github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= @@ -61,8 +61,8 @@ github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+u github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42 h1:dHLYa5D8/Ta0aLR2XcPsrkpAgGeFs6thhMcQK0oQ0n8= -github.com/google/pprof v0.0.0-20231229205709-960ae82b1e42/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20240225044709-fd706174c886 h1:JSJUTZTQT1Gzb2ROdAKOY3HwzBYcclS2GgumhMfHqjw= +github.com/google/pprof v0.0.0-20240225044709-fd706174c886/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -76,10 +76,10 @@ github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= -github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= -github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= -github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= +github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -96,10 +96,10 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.13.2 h1:Bi2gGVkfn6gQcjNjZJVO8Gf0FHzMPf2phUei9tejVMs= -github.com/onsi/ginkgo/v2 v2.13.2/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM= -github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= -github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= +github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= +github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= @@ -169,7 +169,7 @@ github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1Y github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 h1:capMfFYRgH9BCLd6A3Er/cH3A9Nz3CU2KwxwOQZIePI= github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= @@ -184,14 +184,14 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= -golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -202,7 +202,7 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -226,8 +226,8 @@ golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= @@ -235,7 +235,8 @@ golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -248,9 +249,9 @@ golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -271,8 +272,8 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c h1:NUsgEN92SQQqzfA+YtqYNqYmB3DMMYLlIwUZAQFVFbo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= From c83c0bb21dfc70cdcfa33ebb403c6d36cafb7e3b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 27 Feb 2024 00:05:27 +0000 Subject: [PATCH 284/867] Bump golang.org/x/crypto from 0.19.0 to 0.20.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.19.0 to 0.20.0. - [Commits](https://github.com/golang/crypto/compare/v0.19.0...v0.20.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5445c267..0c681395 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.19.0 + golang.org/x/crypto v0.20.0 golang.org/x/net v0.21.0 golang.org/x/sync v0.6.0 golang.org/x/sys v0.17.0 diff --git a/go.sum b/go.sum index ed2a6ba4..edc2c4e7 100644 --- a/go.sum +++ b/go.sum @@ -181,8 +181,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= +golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= From aa101d9dc2149781f134f30ed4e636a824b1a60a Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 28 Feb 2024 21:35:35 -0500 Subject: [PATCH 285/867] Doq (#3073) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: change ALPN of DNS over QUIC * Fix: length of DNS over QUIC (#1888) --------- Co-authored-by: 秋のかえで --- app/dns/nameserver_quic.go | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 9e702564..89bb4aaa 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -1,7 +1,9 @@ package dns import ( + "bytes" "context" + "encoding/binary" "net/url" "sync" "sync/atomic" @@ -24,7 +26,7 @@ import ( // NextProtoDQ - During connection establishment, DNS/QUIC support is indicated // by selecting the ALPN token "dq" in the crypto handshake. -const NextProtoDQ = "doq-i00" +const NextProtoDQ = "doq" const handshakeTimeout = time.Second * 8 @@ -194,13 +196,18 @@ func (s *QUICNameServer) sendQuery(ctx context.Context, domain string, clientIP return } + dnsReqBuf := buf.New() + binary.Write(dnsReqBuf, binary.BigEndian, uint16(b.Len())) + dnsReqBuf.Write(b.Bytes()) + b.Release() + conn, err := s.openStream(dnsCtx) if err != nil { newError("failed to open quic connection").Base(err).AtError().WriteToLog() return } - _, err = conn.Write(b.Bytes()) + _, err = conn.Write(dnsReqBuf.Bytes()) if err != nil { newError("failed to send query").Base(err).AtError().WriteToLog() return @@ -210,9 +217,21 @@ func (s *QUICNameServer) sendQuery(ctx context.Context, domain string, clientIP respBuf := buf.New() defer respBuf.Release() - n, err := respBuf.ReadFrom(conn) + n, err := respBuf.ReadFullFrom(conn, 2) if err != nil && n == 0 { - newError("failed to read response").Base(err).AtError().WriteToLog() + newError("failed to read response length").Base(err).AtError().WriteToLog() + return + } + var length int16 + err = binary.Read(bytes.NewReader(respBuf.Bytes()), binary.BigEndian, &length) + if err != nil { + newError("failed to parse response length").Base(err).AtError().WriteToLog() + return + } + respBuf.Clear() + n, err = respBuf.ReadFullFrom(conn, int32(length)) + if err != nil && n == 0 { + newError("failed to read response length").Base(err).AtError().WriteToLog() return } From 7184a8165f474e29ecc1d3de9e60c1aaac790c91 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 29 Feb 2024 14:22:14 +0000 Subject: [PATCH 286/867] Add Authority to gRPC Transport (#3076) Why couldn't you have Host, for the last three years? --- infra/conf/grpc.go | 4 +- transport/internet/grpc/config.pb.go | 56 ++++++++++++++-------------- transport/internet/grpc/config.proto | 2 +- transport/internet/grpc/dial.go | 38 ++++++++++++------- 4 files changed, 57 insertions(+), 43 deletions(-) diff --git a/infra/conf/grpc.go b/infra/conf/grpc.go index 18447512..429186b0 100644 --- a/infra/conf/grpc.go +++ b/infra/conf/grpc.go @@ -6,7 +6,8 @@ import ( ) type GRPCConfig struct { - ServiceName string `json:"serviceName" ` + Authority string `json:"authority"` + ServiceName string `json:"serviceName"` MultiMode bool `json:"multiMode"` IdleTimeout int32 `json:"idle_timeout"` HealthCheckTimeout int32 `json:"health_check_timeout"` @@ -28,6 +29,7 @@ func (g *GRPCConfig) Build() (proto.Message, error) { } return &grpc.Config{ + Authority: g.Authority, ServiceName: g.ServiceName, MultiMode: g.MultiMode, IdleTimeout: g.IdleTimeout, diff --git a/transport/internet/grpc/config.pb.go b/transport/internet/grpc/config.pb.go index 43da0199..a9059ad4 100644 --- a/transport/internet/grpc/config.pb.go +++ b/transport/internet/grpc/config.pb.go @@ -25,7 +25,7 @@ type Config struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` ServiceName string `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"` MultiMode bool `protobuf:"varint,3,opt,name=multi_mode,json=multiMode,proto3" json:"multi_mode,omitempty"` IdleTimeout int32 `protobuf:"varint,4,opt,name=idle_timeout,json=idleTimeout,proto3" json:"idle_timeout,omitempty"` @@ -67,9 +67,9 @@ func (*Config) Descriptor() ([]byte, []int) { return file_transport_internet_grpc_config_proto_rawDescGZIP(), []int{0} } -func (x *Config) GetHost() string { +func (x *Config) GetAuthority() string { if x != nil { - return x.Host + return x.Authority } return "" } @@ -130,31 +130,31 @@ var file_transport_internet_grpc_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x25, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, - 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x22, 0xb8, 0x02, - 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, - 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, - 0x1d, 0x0a, 0x0a, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x09, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x21, - 0x0a, 0x0c, 0x69, 0x64, 0x6c, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x69, 0x64, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, - 0x74, 0x12, 0x30, 0x0a, 0x14, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x5f, 0x63, 0x68, 0x65, 0x63, - 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x12, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, - 0x6f, 0x75, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x74, 0x5f, 0x77, 0x69, - 0x74, 0x68, 0x6f, 0x75, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x13, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x74, 0x57, 0x69, 0x74, 0x68, 0x6f, 0x75, - 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x30, 0x0a, 0x14, 0x69, 0x6e, 0x69, 0x74, 0x69, - 0x61, 0x6c, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x57, 0x69, - 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x61, 0x67, 0x65, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, - 0x73, 0x65, 0x72, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, - 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x22, 0xc2, 0x02, + 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, + 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x61, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x75, 0x6c, + 0x74, 0x69, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6d, + 0x75, 0x6c, 0x74, 0x69, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x64, 0x6c, 0x65, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, + 0x69, 0x64, 0x6c, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x30, 0x0a, 0x14, 0x68, + 0x65, 0x61, 0x6c, 0x74, 0x68, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x68, 0x65, 0x61, 0x6c, 0x74, + 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x32, 0x0a, + 0x15, 0x70, 0x65, 0x72, 0x6d, 0x69, 0x74, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x5f, + 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x70, 0x65, + 0x72, 0x6d, 0x69, 0x74, 0x57, 0x69, 0x74, 0x68, 0x6f, 0x75, 0x74, 0x53, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x12, 0x30, 0x0a, 0x14, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x77, 0x69, 0x6e, + 0x64, 0x6f, 0x77, 0x73, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x12, 0x69, 0x6e, 0x69, 0x74, 0x69, 0x61, 0x6c, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x53, + 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x61, 0x67, 0x65, 0x6e, + 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x41, 0x67, 0x65, + 0x6e, 0x74, 0x42, 0x33, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/grpc/config.proto b/transport/internet/grpc/config.proto index 56c507ae..fcaa2ed9 100644 --- a/transport/internet/grpc/config.proto +++ b/transport/internet/grpc/config.proto @@ -4,7 +4,7 @@ package xray.transport.internet.grpc.encoding; option go_package = "github.com/xtls/xray-core/transport/internet/grpc"; message Config { - string host = 1; + string authority = 1; string service_name = 2; bool multi_mode = 3; int32 idle_timeout = 4; diff --git a/transport/internet/grpc/dial.go b/transport/internet/grpc/dial.go index 16af63cd..2355b231 100644 --- a/transport/internet/grpc/dial.go +++ b/transport/internet/grpc/dial.go @@ -17,7 +17,6 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/backoff" "google.golang.org/grpc/connectivity" - "google.golang.org/grpc/credentials" "google.golang.org/grpc/keepalive" ) @@ -122,24 +121,37 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in gctx = session.ContextWithTimeoutOnly(gctx, true) c, err := internet.DialSystem(gctx, net.TCPDestination(address, port), sockopt) - if err == nil && realityConfig != nil { - return reality.UClient(c, realityConfig, gctx, dest) + if err == nil { + if tlsConfig != nil { + config := tlsConfig.GetTLSConfig() + if config.ServerName == "" && address.Family().IsDomain() { + config.ServerName = address.Domain() + } + if fingerprint := tls.GetFingerprint(tlsConfig.Fingerprint); fingerprint != nil { + return tls.UClient(c, config, fingerprint), nil + } else { // Fallback to normal gRPC TLS + return tls.Client(c, config), nil + } + } + if realityConfig != nil { + return reality.UClient(c, realityConfig, gctx, dest) + } } return c, err }), } - if tlsConfig != nil { - var transportCredential credentials.TransportCredentials - if fingerprint := tls.GetFingerprint(tlsConfig.Fingerprint); fingerprint != nil { - transportCredential = tls.NewGrpcUtls(tlsConfig.GetTLSConfig(), fingerprint) - } else { // Fallback to normal gRPC TLS - transportCredential = credentials.NewTLS(tlsConfig.GetTLSConfig()) - } - dialOptions = append(dialOptions, grpc.WithTransportCredentials(transportCredential)) - } else { - dialOptions = append(dialOptions, grpc.WithInsecure()) + dialOptions = append(dialOptions, grpc.WithInsecure()) + + authority := "" + if grpcSettings.Authority != "" { + authority = grpcSettings.Authority + } else if tlsConfig != nil && tlsConfig.ServerName != "" { + authority = tlsConfig.ServerName + } else if realityConfig == nil && dest.Address.Family().IsDomain() { + authority = dest.Address.Domain() } + dialOptions = append(dialOptions, grpc.WithAuthority(authority)) if grpcSettings.IdleTimeout > 0 || grpcSettings.HealthCheckTimeout > 0 || grpcSettings.PermitWithoutStream { dialOptions = append(dialOptions, grpc.WithKeepaliveParams(keepalive.ClientParameters{ From 8fe8aa5432d6f14f62aaecd57d7f35fda04d5c0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 1 Mar 2024 00:50:32 +0000 Subject: [PATCH 287/867] Bump github.com/sagernet/sing from 0.3.2 to 0.3.3 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.3.2 to 0.3.3. - [Commits](https://github.com/sagernet/sing/compare/v0.3.2...v0.3.3) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0c681395..8d4d2387 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.41.0 github.com/refraction-networking/utls v1.6.3 - github.com/sagernet/sing v0.3.2 + github.com/sagernet/sing v0.3.3 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index edc2c4e7..2fa1899f 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.3.2 h1:CwWcxUBPkMvwgfe2/zUgY5oHG9qOL8Aob/evIFYK9jo= -github.com/sagernet/sing v0.3.2/go.mod h1:qHySJ7u8po9DABtMYEkNBcOumx7ZZJf/fbv2sfTkNHE= +github.com/sagernet/sing v0.3.3 h1:gJWe0YrAqRlJqkQ5o9vZ9kMBerABm9q4j8MK78DuZuA= +github.com/sagernet/sing v0.3.3/go.mod h1:qHySJ7u8po9DABtMYEkNBcOumx7ZZJf/fbv2sfTkNHE= github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= From a3f50d0f5d3c35a852846384d0be7fea17241a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= <45535409+Fangliding@users.noreply.github.com> Date: Sat, 2 Mar 2024 03:51:13 +0800 Subject: [PATCH 288/867] Add a linux script --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 467a83e9..97c3215f 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ - Linux Script - [XTLS/Xray-install](https://github.com/XTLS/Xray-install) + - [team-cloudchaser/tempest](https://github.com/team-cloudchaser/tempest) (For Linux without systemd) - Docker - Official: [ghcr.io/xtls/xray-core](https://ghcr.io/xtls/xray-core) - [iamybj/docker-xray](https://hub.docker.com/r/iamybj/docker-xray) From 173b03448fe647bd7a938ebc5ba715e9322467fc Mon Sep 17 00:00:00 2001 From: Eken Chan Date: Sun, 3 Mar 2024 13:12:38 +0800 Subject: [PATCH 289/867] transport: add httpupgrade --- infra/conf/transport.go | 28 ++- infra/conf/transport_internet.go | 58 ++++-- infra/conf/xray.go | 3 + main/distro/all/all.go | 1 + transport/internet/httpupgrade/config.go | 12 ++ transport/internet/httpupgrade/config.pb.go | 174 ++++++++++++++++++ transport/internet/httpupgrade/config.proto | 16 ++ transport/internet/httpupgrade/dialer.go | 87 +++++++++ .../internet/httpupgrade/errors.generated.go | 9 + transport/internet/httpupgrade/httpupgrade.go | 17 ++ transport/internet/httpupgrade/hub.go | 140 ++++++++++++++ 11 files changed, 524 insertions(+), 21 deletions(-) create mode 100644 transport/internet/httpupgrade/config.go create mode 100644 transport/internet/httpupgrade/config.pb.go create mode 100644 transport/internet/httpupgrade/config.proto create mode 100644 transport/internet/httpupgrade/dialer.go create mode 100644 transport/internet/httpupgrade/errors.generated.go create mode 100644 transport/internet/httpupgrade/httpupgrade.go create mode 100644 transport/internet/httpupgrade/hub.go diff --git a/infra/conf/transport.go b/infra/conf/transport.go index fa8a3886..b7969e47 100644 --- a/infra/conf/transport.go +++ b/infra/conf/transport.go @@ -7,14 +7,15 @@ import ( ) type TransportConfig struct { - TCPConfig *TCPConfig `json:"tcpSettings"` - KCPConfig *KCPConfig `json:"kcpSettings"` - WSConfig *WebSocketConfig `json:"wsSettings"` - HTTPConfig *HTTPConfig `json:"httpSettings"` - DSConfig *DomainSocketConfig `json:"dsSettings"` - QUICConfig *QUICConfig `json:"quicSettings"` - GRPCConfig *GRPCConfig `json:"grpcSettings"` - GUNConfig *GRPCConfig `json:"gunSettings"` + TCPConfig *TCPConfig `json:"tcpSettings"` + KCPConfig *KCPConfig `json:"kcpSettings"` + WSConfig *WebSocketConfig `json:"wsSettings"` + HTTPConfig *HTTPConfig `json:"httpSettings"` + DSConfig *DomainSocketConfig `json:"dsSettings"` + QUICConfig *QUICConfig `json:"quicSettings"` + GRPCConfig *GRPCConfig `json:"grpcSettings"` + GUNConfig *GRPCConfig `json:"gunSettings"` + HTTPUPGRADEConfig *HttpUpgradeConfig `json:"httpupgradeSettings"` } // Build implements Buildable. @@ -101,5 +102,16 @@ func (c *TransportConfig) Build() (*global.Config, error) { }) } + if c.HTTPUPGRADEConfig != nil { + hs, err := c.HTTPUPGRADEConfig.Build() + if err != nil { + return nil, newError("failed to build HttpUpgrade config").Base(err) + } + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ + ProtocolName: "httpupgrade", + Settings: serial.ToTypedMessage(hs), + }) + } + return config, nil } diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 8c113e92..9ab34cf5 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -19,6 +19,7 @@ import ( "github.com/xtls/xray-core/transport/internet/domainsocket" httpheader "github.com/xtls/xray-core/transport/internet/headers/http" "github.com/xtls/xray-core/transport/internet/http" + "github.com/xtls/xray-core/transport/internet/httpupgrade" "github.com/xtls/xray-core/transport/internet/kcp" "github.com/xtls/xray-core/transport/internet/quic" "github.com/xtls/xray-core/transport/internet/reality" @@ -181,6 +182,24 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { return config, nil } +type HttpUpgradeConfig struct { + Path string `json:"path"` + Host string `json:"host"` + AcceptProxyProtocol bool `json:"acceptProxyProtocol"` +} + +// Build implements Buildable. +func (c *HttpUpgradeConfig) Build() (proto.Message, error) { + config := &httpupgrade.Config{ + Path: c.Path, + Host: c.Host, + } + if c.AcceptProxyProtocol { + config.AcceptProxyProtocol = c.AcceptProxyProtocol + } + return config, nil +} + type HTTPConfig struct { Host *StringList `json:"host"` Path string `json:"path"` @@ -606,6 +625,8 @@ func (p TransportProtocol) Build() (string, error) { return "quic", nil case "grpc", "gun": return "grpc", nil + case "httpupgrade": + return "httpupgrade", nil default: return "", newError("Config: unknown transport protocol: ", p) } @@ -706,19 +727,20 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { } type StreamConfig struct { - Network *TransportProtocol `json:"network"` - Security string `json:"security"` - TLSSettings *TLSConfig `json:"tlsSettings"` - REALITYSettings *REALITYConfig `json:"realitySettings"` - TCPSettings *TCPConfig `json:"tcpSettings"` - KCPSettings *KCPConfig `json:"kcpSettings"` - WSSettings *WebSocketConfig `json:"wsSettings"` - HTTPSettings *HTTPConfig `json:"httpSettings"` - DSSettings *DomainSocketConfig `json:"dsSettings"` - QUICSettings *QUICConfig `json:"quicSettings"` - SocketSettings *SocketConfig `json:"sockopt"` - GRPCConfig *GRPCConfig `json:"grpcSettings"` - GUNConfig *GRPCConfig `json:"gunSettings"` + Network *TransportProtocol `json:"network"` + Security string `json:"security"` + TLSSettings *TLSConfig `json:"tlsSettings"` + REALITYSettings *REALITYConfig `json:"realitySettings"` + TCPSettings *TCPConfig `json:"tcpSettings"` + KCPSettings *KCPConfig `json:"kcpSettings"` + WSSettings *WebSocketConfig `json:"wsSettings"` + HTTPSettings *HTTPConfig `json:"httpSettings"` + DSSettings *DomainSocketConfig `json:"dsSettings"` + QUICSettings *QUICConfig `json:"quicSettings"` + SocketSettings *SocketConfig `json:"sockopt"` + GRPCConfig *GRPCConfig `json:"grpcSettings"` + GUNConfig *GRPCConfig `json:"gunSettings"` + HTTPUPGRADESettings *HttpUpgradeConfig `json:"httpupgradeSettings"` } // Build implements Buildable. @@ -839,6 +861,16 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { Settings: serial.ToTypedMessage(gs), }) } + if c.HTTPUPGRADESettings != nil { + hs, err := c.HTTPUPGRADESettings.Build() + if err != nil { + return nil, newError("Failed to build HttpUpgrade config.").Base(err) + } + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ + ProtocolName: "httpupgrade", + Settings: serial.ToTypedMessage(hs), + }) + } if c.SocketSettings != nil { ss, err := c.SocketSettings.Build() if err != nil { diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 2144815a..c99dca59 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -544,6 +544,9 @@ func applyTransportConfig(s *StreamConfig, t *TransportConfig) { if s.DSSettings == nil { s.DSSettings = t.DSConfig } + if s.HTTPUPGRADESettings == nil { + s.HTTPUPGRADESettings = t.HTTPUPGRADEConfig + } } // Build implements Buildable. diff --git a/main/distro/all/all.go b/main/distro/all/all.go index d383e043..0f0397f5 100644 --- a/main/distro/all/all.go +++ b/main/distro/all/all.go @@ -53,6 +53,7 @@ import ( _ "github.com/xtls/xray-core/transport/internet/domainsocket" _ "github.com/xtls/xray-core/transport/internet/grpc" _ "github.com/xtls/xray-core/transport/internet/http" + _ "github.com/xtls/xray-core/transport/internet/httpupgrade" _ "github.com/xtls/xray-core/transport/internet/kcp" _ "github.com/xtls/xray-core/transport/internet/quic" _ "github.com/xtls/xray-core/transport/internet/reality" diff --git a/transport/internet/httpupgrade/config.go b/transport/internet/httpupgrade/config.go new file mode 100644 index 00000000..21841bfd --- /dev/null +++ b/transport/internet/httpupgrade/config.go @@ -0,0 +1,12 @@ +package httpupgrade + +func (c *Config) GetNormalizedPath() string { + path := c.Path + if path == "" { + return "/" + } + if path[0] != '/' { + return "/" + path + } + return path +} diff --git a/transport/internet/httpupgrade/config.pb.go b/transport/internet/httpupgrade/config.pb.go new file mode 100644 index 00000000..f097f63f --- /dev/null +++ b/transport/internet/httpupgrade/config.pb.go @@ -0,0 +1,174 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.32.0 +// protoc v4.25.1 +// source: transport/internet/httpupgrade/config.proto + +package httpupgrade + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Config struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` + Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` + AcceptProxyProtocol bool `protobuf:"varint,4,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` +} + +func (x *Config) Reset() { + *x = Config{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_internet_httpupgrade_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Config) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Config) ProtoMessage() {} + +func (x *Config) ProtoReflect() protoreflect.Message { + mi := &file_transport_internet_httpupgrade_config_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Config.ProtoReflect.Descriptor instead. +func (*Config) Descriptor() ([]byte, []int) { + return file_transport_internet_httpupgrade_config_proto_rawDescGZIP(), []int{0} +} + +func (x *Config) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *Config) GetHost() string { + if x != nil { + return x.Host + } + return "" +} + +func (x *Config) GetAcceptProxyProtocol() bool { + if x != nil { + return x.AcceptProxyProtocol + } + return false +} + +var File_transport_internet_httpupgrade_config_proto protoreflect.FileDescriptor + +var file_transport_internet_httpupgrade_config_proto_rawDesc = []byte{ + 0x0a, 0x2b, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, + 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x23, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, + 0x64, 0x65, 0x22, 0x6a, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, + 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x68, 0x6f, 0x73, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x42, 0x8b, + 0x01, 0x0a, 0x27, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, + 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, + 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x75, + 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0xaa, 0x02, 0x23, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2e, 0x48, 0x74, 0x74, 0x70, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_transport_internet_httpupgrade_config_proto_rawDescOnce sync.Once + file_transport_internet_httpupgrade_config_proto_rawDescData = file_transport_internet_httpupgrade_config_proto_rawDesc +) + +func file_transport_internet_httpupgrade_config_proto_rawDescGZIP() []byte { + file_transport_internet_httpupgrade_config_proto_rawDescOnce.Do(func() { + file_transport_internet_httpupgrade_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_internet_httpupgrade_config_proto_rawDescData) + }) + return file_transport_internet_httpupgrade_config_proto_rawDescData +} + +var file_transport_internet_httpupgrade_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_transport_internet_httpupgrade_config_proto_goTypes = []interface{}{ + (*Config)(nil), // 0: xray.transport.internet.httpupgrade.Config +} +var file_transport_internet_httpupgrade_config_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_transport_internet_httpupgrade_config_proto_init() } +func file_transport_internet_httpupgrade_config_proto_init() { + if File_transport_internet_httpupgrade_config_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_transport_internet_httpupgrade_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Config); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_transport_internet_httpupgrade_config_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_transport_internet_httpupgrade_config_proto_goTypes, + DependencyIndexes: file_transport_internet_httpupgrade_config_proto_depIdxs, + MessageInfos: file_transport_internet_httpupgrade_config_proto_msgTypes, + }.Build() + File_transport_internet_httpupgrade_config_proto = out.File + file_transport_internet_httpupgrade_config_proto_rawDesc = nil + file_transport_internet_httpupgrade_config_proto_goTypes = nil + file_transport_internet_httpupgrade_config_proto_depIdxs = nil +} diff --git a/transport/internet/httpupgrade/config.proto b/transport/internet/httpupgrade/config.proto new file mode 100644 index 00000000..2be7cc22 --- /dev/null +++ b/transport/internet/httpupgrade/config.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package xray.transport.internet.httpupgrade; +option csharp_namespace = "Xray.Transport.Internet.HttpUpgrade"; +option go_package = "github.com/xtls/xray-core/transport/internet/httpupgrade"; +option java_package = "com.xray.transport.internet.httpupgrade"; +option java_multiple_files = true; + +message Config { + reserved 1; + + string path = 2; + string host = 3; + + bool accept_proxy_protocol = 4; +} \ No newline at end of file diff --git a/transport/internet/httpupgrade/dialer.go b/transport/internet/httpupgrade/dialer.go new file mode 100644 index 00000000..2ed43ed7 --- /dev/null +++ b/transport/internet/httpupgrade/dialer.go @@ -0,0 +1,87 @@ +package httpupgrade + +import ( + "bufio" + "context" + "net/http" + "net/url" + "strings" + + "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" +) + +func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (net.Conn, error) { + transportConfiguration := streamSettings.ProtocolSettings.(*Config) + + pconn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) + if err != nil { + newError("failed to dial to ", dest).Base(err).AtError().WriteToLog() + return nil, err + } + + var conn net.Conn + var requestURL url.URL + if config := tls.ConfigFromStreamSettings(streamSettings); config != nil { + tlsConfig := config.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("http/1.1")) + if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil { + conn = tls.UClient(pconn, tlsConfig, fingerprint) + if err := conn.(*tls.UConn).WebsocketHandshakeContext(ctx); err != nil { + return nil, err + } + } else { + conn = tls.Client(pconn, tlsConfig) + } + + requestURL.Scheme = "https" + } else { + requestURL.Scheme = "http" + } + + requestURL.Host = dest.NetAddr() + requestURL.Path = transportConfiguration.GetNormalizedPath() + req := &http.Request{ + Method: http.MethodGet, + URL: &requestURL, + Host: transportConfiguration.Host, + Header: make(http.Header), + } + req.Header.Set("Connection", "upgrade") + req.Header.Set("Upgrade", "websocket") + + err = req.Write(conn) + if err != nil { + return nil, err + } + + // TODO The bufio usage here is unreliable + resp, err := http.ReadResponse(bufio.NewReader(conn), req) // nolint:bodyclose + if err != nil { + return nil, err + } + + if resp.Status == "101 Switching Protocols" && + strings.ToLower(resp.Header.Get("Upgrade")) == "websocket" && + strings.ToLower(resp.Header.Get("Connection")) == "upgrade" { + return conn, nil + } + return nil, newError("unrecognized reply") +} + +func dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) { + newError("creating connection to ", dest).WriteToLog(session.ExportIDToError(ctx)) + + conn, err := dialhttpUpgrade(ctx, dest, streamSettings) + if err != nil { + return nil, newError("failed to dial request to ", dest).Base(err) + } + return stat.Connection(conn), nil +} + +func init() { + common.Must(internet.RegisterTransportDialer(protocolName, dial)) +} diff --git a/transport/internet/httpupgrade/errors.generated.go b/transport/internet/httpupgrade/errors.generated.go new file mode 100644 index 00000000..9a3440c0 --- /dev/null +++ b/transport/internet/httpupgrade/errors.generated.go @@ -0,0 +1,9 @@ +package httpupgrade + +import "github.com/xtls/xray-core/common/errors" + +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/transport/internet/httpupgrade/httpupgrade.go b/transport/internet/httpupgrade/httpupgrade.go new file mode 100644 index 00000000..c1410c61 --- /dev/null +++ b/transport/internet/httpupgrade/httpupgrade.go @@ -0,0 +1,17 @@ +package httpupgrade + +import ( + "context" + + "github.com/xtls/xray-core/common" +) + +//go:generate go run github.com/xtls/xray-core/common/errors/errorgen + +const protocolName = "httpupgrade" + +func init() { + common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { + return nil, newError("httpupgrade is a transport protocol.") + })) +} diff --git a/transport/internet/httpupgrade/hub.go b/transport/internet/httpupgrade/hub.go new file mode 100644 index 00000000..f87d020f --- /dev/null +++ b/transport/internet/httpupgrade/hub.go @@ -0,0 +1,140 @@ +package httpupgrade + +import ( + "bufio" + "context" + "crypto/tls" + "net/http" + "strings" + + "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" + v2tls "github.com/xtls/xray-core/transport/internet/tls" +) + +type server struct { + config *Config + addConn internet.ConnHandler + innnerListener net.Listener +} + +func (s *server) Close() error { + return s.innnerListener.Close() +} + +func (s *server) Addr() net.Addr { + return nil +} + +func (s *server) Handle(conn net.Conn) (stat.Connection, error) { + connReader := bufio.NewReader(conn) + req, err := http.ReadRequest(connReader) + if err != nil { + return nil, err + } + + if s.config != nil { + host := req.Host + if len(s.config.Host) > 0 && host != s.config.Host { + return nil, newError("bad host: ", host) + } + path := s.config.GetNormalizedPath() + if req.URL.Path != path { + return nil, newError("bad path: ", req.URL.Path) + } + } + + connection := strings.ToLower(req.Header.Get("Connection")) + upgrade := strings.ToLower(req.Header.Get("Upgrade")) + if connection != "upgrade" || upgrade != "websocket" { + _ = conn.Close() + return nil, newError("unrecognized request") + } + resp := &http.Response{ + Status: "101 Switching Protocols", + StatusCode: 101, + Proto: "HTTP/1.1", + ProtoMajor: 1, + ProtoMinor: 1, + Header: http.Header{}, + } + resp.Header.Set("Connection", "upgrade") + resp.Header.Set("Upgrade", "websocket") + err = resp.Write(conn) + if err != nil { + _ = conn.Close() + return nil, err + } + return stat.Connection(conn), nil +} + +func (s *server) keepAccepting() { + for { + conn, err := s.innnerListener.Accept() + if err != nil { + return + } + handledConn, err := s.Handle(conn) + if err != nil { + newError("failed to handle request").Base(err).WriteToLog() + continue + } + s.addConn(handledConn) + } +} + +func listenHTTPUpgrade(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (internet.Listener, error) { + transportConfiguration := streamSettings.ProtocolSettings.(*Config) + if transportConfiguration != nil { + if streamSettings.SocketSettings == nil { + streamSettings.SocketSettings = &internet.SocketConfig{} + } + streamSettings.SocketSettings.AcceptProxyProtocol = transportConfiguration.AcceptProxyProtocol || streamSettings.SocketSettings.AcceptProxyProtocol + } + var listener net.Listener + var err error + if port == net.Port(0) { // unix + listener, err = internet.ListenSystem(ctx, &net.UnixAddr{ + Name: address.Domain(), + Net: "unix", + }, streamSettings.SocketSettings) + if err != nil { + return nil, newError("failed to listen unix domain socket(for HttpUpgrade) on ", address).Base(err) + } + newError("listening unix domain socket(for HttpUpgrade) on ", address).WriteToLog(session.ExportIDToError(ctx)) + } else { // tcp + listener, err = internet.ListenSystem(ctx, &net.TCPAddr{ + IP: address.IP(), + Port: int(port), + }, streamSettings.SocketSettings) + if err != nil { + return nil, newError("failed to listen TCP(for HttpUpgrade) on ", address, ":", port).Base(err) + } + newError("listening TCP(for HttpUpgrade) on ", address, ":", port).WriteToLog(session.ExportIDToError(ctx)) + } + + if streamSettings.SocketSettings != nil && streamSettings.SocketSettings.AcceptProxyProtocol { + newError("accepting PROXY protocol").AtWarning().WriteToLog(session.ExportIDToError(ctx)) + } + + if config := v2tls.ConfigFromStreamSettings(streamSettings); config != nil { + if tlsConfig := config.GetTLSConfig(); tlsConfig != nil { + listener = tls.NewListener(listener, tlsConfig) + } + } + + serverInstance := &server{ + config: transportConfiguration, + addConn: addConn, + innnerListener: listener, + } + go serverInstance.keepAccepting() + return serverInstance, nil +} + +func init() { + common.Must(internet.RegisterTransportListener(protocolName, listenHTTPUpgrade)) +} From a994bf8b04c842cb9e2352cd969061ada7501854 Mon Sep 17 00:00:00 2001 From: A1lo Date: Sun, 3 Mar 2024 23:52:22 +0800 Subject: [PATCH 290/867] chore: fix some errors detected by staticcheck (#3089) * chore: fix some errors detected by staticcheck * feat: remove `rand.Seed()` usage for possibly using "fastrand64" runtime to avoid locking ref: https://pkg.go.dev/math/rand#Seed --- app/dns/dns.go | 4 +--- app/router/command/command_test.go | 7 ++++--- common/dice/dice.go | 5 ----- common/drain/drainer.go | 3 +-- main/commands/all/api/shared.go | 6 ++++-- main/commands/all/tls/certchainhash.go | 5 ++--- proxy/socks/server.go | 4 ++-- testing/scenarios/command_test.go | 7 ++++--- testing/scenarios/metrics_test.go | 6 +++--- transport/internet/grpc/dial.go | 3 ++- 10 files changed, 23 insertions(+), 27 deletions(-) diff --git a/app/dns/dns.go b/app/dns/dns.go index 3b173677..fbdf74ee 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -181,9 +181,7 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, error) { } // Normalize the FQDN form query - if strings.HasSuffix(domain, ".") { - domain = domain[:len(domain)-1] - } + domain = strings.TrimSuffix(domain, ".") // Static host lookup switch addrs := s.hosts.Lookup(domain, option); { diff --git a/app/router/command/command_test.go b/app/router/command/command_test.go index fa8d48b3..096e90ee 100644 --- a/app/router/command/command_test.go +++ b/app/router/command/command_test.go @@ -16,6 +16,7 @@ import ( "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/testing/mocks" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/test/bufconn" ) @@ -80,7 +81,7 @@ func TestServiceSubscribeRoutingStats(t *testing.T) { // Client goroutine go func() { defer lis.Close() - conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(bufDialer), grpc.WithInsecure()) + conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(bufDialer), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { errCh <- err return @@ -214,7 +215,7 @@ func TestServiceSubscribeSubsetOfFields(t *testing.T) { // Client goroutine go func() { defer lis.Close() - conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(bufDialer), grpc.WithInsecure()) + conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(bufDialer), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { errCh <- err return @@ -337,7 +338,7 @@ func TestSerivceTestRoute(t *testing.T) { // Client goroutine go func() { defer lis.Close() - conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(bufDialer), grpc.WithInsecure()) + conn, err := grpc.DialContext(context.Background(), "bufnet", grpc.WithContextDialer(bufDialer), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { errCh <- err } diff --git a/common/dice/dice.go b/common/dice/dice.go index 896c1e8e..2ff925b8 100644 --- a/common/dice/dice.go +++ b/common/dice/dice.go @@ -4,7 +4,6 @@ package dice // import "github.com/xtls/xray-core/common/dice" import ( "math/rand" - "time" ) // Roll returns a non-negative number between 0 (inclusive) and n (exclusive). @@ -46,7 +45,3 @@ func (dd *DeterministicDice) Roll(n int) int { } return dd.Intn(n) } - -func init() { - rand.Seed(time.Now().Unix()) -} diff --git a/common/drain/drainer.go b/common/drain/drainer.go index bdb12d4f..bb1ae68a 100644 --- a/common/drain/drainer.go +++ b/common/drain/drainer.go @@ -2,7 +2,6 @@ package drain import ( "io" - "io/ioutil" "github.com/xtls/xray-core/common/dice" ) @@ -36,7 +35,7 @@ func (d *BehaviorSeedLimitedDrainer) Drain(reader io.Reader) error { } func drainReadN(reader io.Reader, n int) error { - _, err := io.CopyN(ioutil.Discard, reader, int64(n)) + _, err := io.CopyN(io.Discard, reader, int64(n)) return err } diff --git a/main/commands/all/api/shared.go b/main/commands/all/api/shared.go index 4d98359f..751b8615 100644 --- a/main/commands/all/api/shared.go +++ b/main/commands/all/api/shared.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "fmt" - "google.golang.org/protobuf/encoding/protojson" "io" "net/http" "net/url" @@ -13,6 +12,9 @@ import ( "strings" "time" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/protobuf/encoding/protojson" + "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/main/commands/base" "google.golang.org/grpc" @@ -37,7 +39,7 @@ func setSharedFlags(cmd *base.Command) { func dialAPIServer() (conn *grpc.ClientConn, ctx context.Context, close func()) { ctx, cancel := context.WithTimeout(context.Background(), time.Duration(apiTimeout)*time.Second) - conn, err := grpc.DialContext(ctx, apiServerAddrPtr, grpc.WithInsecure(), grpc.WithBlock()) + conn, err := grpc.DialContext(ctx, apiServerAddrPtr, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) if err != nil { base.Fatalf("failed to dial %s", apiServerAddrPtr) } diff --git a/main/commands/all/tls/certchainhash.go b/main/commands/all/tls/certchainhash.go index 3fbdb4c4..304f668d 100644 --- a/main/commands/all/tls/certchainhash.go +++ b/main/commands/all/tls/certchainhash.go @@ -3,7 +3,7 @@ package tls import ( "flag" "fmt" - "io/ioutil" + "os" "github.com/xtls/xray-core/main/commands/base" "github.com/xtls/xray-core/transport/internet/tls" @@ -30,12 +30,11 @@ func executeCertChainHash(cmd *base.Command, args []string) { fmt.Println(err) return } - certContent, err := ioutil.ReadFile(*input) + certContent, err := os.ReadFile(*input) if err != nil { fmt.Println(err) return } certChainHashB64 := tls.CalculatePEMCertChainSHA256Hash(certContent) fmt.Println(certChainHashB64) - return } diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 6964fdf2..2f789757 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -101,7 +101,7 @@ func (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatche reader := &buf.BufferedReader{Reader: buf.NewReader(conn)} request, err := svrSession.Handshake(reader, conn) if err != nil { - if inbound != nil && inbound.Source.IsValid() { + if inbound.Source.IsValid() { log.Record(&log.AccessMessage{ From: inbound.Source, To: "", @@ -122,7 +122,7 @@ func (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatche if request.Command == protocol.RequestCommandTCP { dest := request.Destination() newError("TCP Connect request to ", dest).WriteToLog(session.ExportIDToError(ctx)) - if inbound != nil && inbound.Source.IsValid() { + if inbound.Source.IsValid() { ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{ From: inbound.Source, To: dest, diff --git a/testing/scenarios/command_test.go b/testing/scenarios/command_test.go index d82e6a37..44513b77 100644 --- a/testing/scenarios/command_test.go +++ b/testing/scenarios/command_test.go @@ -30,6 +30,7 @@ import ( "github.com/xtls/xray-core/proxy/vmess/outbound" "github.com/xtls/xray-core/testing/servers/tcp" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) func TestCommanderRemoveHandler(t *testing.T) { @@ -103,7 +104,7 @@ func TestCommanderRemoveHandler(t *testing.T) { t.Fatal(err) } - cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithInsecure(), grpc.WithBlock()) + cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) common.Must(err) defer cmdConn.Close() @@ -270,7 +271,7 @@ func TestCommanderAddRemoveUser(t *testing.T) { t.Fatal("expected error: ", err) } - cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithInsecure(), grpc.WithBlock()) + cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) common.Must(err) defer cmdConn.Close() @@ -451,7 +452,7 @@ func TestCommanderStats(t *testing.T) { t.Fatal(err) } - cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithInsecure(), grpc.WithBlock()) + cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) common.Must(err) defer cmdConn.Close() diff --git a/testing/scenarios/metrics_test.go b/testing/scenarios/metrics_test.go index 914e46c4..eee2d942 100644 --- a/testing/scenarios/metrics_test.go +++ b/testing/scenarios/metrics_test.go @@ -3,7 +3,7 @@ package scenarios import ( "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "testing" @@ -80,7 +80,7 @@ func TestMetrics(t *testing.T) { if resp.StatusCode != http.StatusOK { t.Error("unexpected pprof status code") } - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { t.Fatal(err) } @@ -96,7 +96,7 @@ func TestMetrics(t *testing.T) { if resp2.StatusCode != http.StatusOK { t.Error("unexpected expvars status code") } - body2, err2 := ioutil.ReadAll(resp2.Body) + body2, err2 := io.ReadAll(resp2.Body) if err2 != nil { t.Fatal(err2) } diff --git a/transport/internet/grpc/dial.go b/transport/internet/grpc/dial.go index 2355b231..5d5789b4 100644 --- a/transport/internet/grpc/dial.go +++ b/transport/internet/grpc/dial.go @@ -17,6 +17,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/backoff" "google.golang.org/grpc/connectivity" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/keepalive" ) @@ -141,7 +142,7 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in }), } - dialOptions = append(dialOptions, grpc.WithInsecure()) + dialOptions = append(dialOptions, grpc.WithTransportCredentials(insecure.NewCredentials())) authority := "" if grpcSettings.Authority != "" { From 87ef07d5f4dd92b018b58662ab15a426328d1990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Tue, 5 Mar 2024 03:43:14 +0800 Subject: [PATCH 291/867] Correctly propagate error in AuthenticationReader readBuffer --- common/crypto/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/crypto/auth.go b/common/crypto/auth.go index 88de851e..0bc8e71d 100644 --- a/common/crypto/auth.go +++ b/common/crypto/auth.go @@ -178,7 +178,7 @@ func (r *AuthenticationReader) readInternal(soft bool, mb *buf.MultiBuffer) erro if size <= buf.Size { b, err := r.readBuffer(int32(size), int32(padding)) if err != nil { - return nil + return err } *mb = append(*mb, b) return nil From b0fa7b6b85bba5582c676093abd614adb7a486b2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 01:07:16 +0000 Subject: [PATCH 292/867] Bump github.com/stretchr/testify from 1.8.4 to 1.9.0 Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.8.4 to 1.9.0. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.8.4...v1.9.0) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8d4d2387..a6445147 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/sagernet/sing v0.3.3 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 diff --git a/go.sum b/go.sum index 2fa1899f..39d4f08e 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF8gHIiADmOVOV5LS43gt3ONnlEl3xkwI= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= From eefdcb27f39180296267f361b6280d58cc8298d7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 01:07:07 +0000 Subject: [PATCH 293/867] Bump github.com/sagernet/sing from 0.3.3 to 0.3.4 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.3.3 to 0.3.4. - [Commits](https://github.com/sagernet/sing/compare/v0.3.3...v0.3.4) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a6445147..5260a710 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.41.0 github.com/refraction-networking/utls v1.6.3 - github.com/sagernet/sing v0.3.3 + github.com/sagernet/sing v0.3.4 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index 39d4f08e..30a7705c 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.3.3 h1:gJWe0YrAqRlJqkQ5o9vZ9kMBerABm9q4j8MK78DuZuA= -github.com/sagernet/sing v0.3.3/go.mod h1:qHySJ7u8po9DABtMYEkNBcOumx7ZZJf/fbv2sfTkNHE= +github.com/sagernet/sing v0.3.4 h1:mFGTVGFz/RxIDT9BMyJ67PanLxVh6fagB27eaUlO0aw= +github.com/sagernet/sing v0.3.4/go.mod h1:qHySJ7u8po9DABtMYEkNBcOumx7ZZJf/fbv2sfTkNHE= github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= From da9c0ea07f6cd17d4e486f05fc77acd4f1dd6c59 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 00:30:40 +0000 Subject: [PATCH 294/867] Bump golang.org/x/crypto from 0.20.0 to 0.21.0 Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.20.0 to 0.21.0. - [Commits](https://github.com/golang/crypto/compare/v0.20.0...v0.21.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 5260a710..b7330f52 100644 --- a/go.mod +++ b/go.mod @@ -20,10 +20,10 @@ require ( github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.20.0 + golang.org/x/crypto v0.21.0 golang.org/x/net v0.21.0 golang.org/x/sync v0.6.0 - golang.org/x/sys v0.17.0 + golang.org/x/sys v0.18.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 diff --git a/go.sum b/go.sum index 30a7705c..341370b3 100644 --- a/go.sum +++ b/go.sum @@ -181,8 +181,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= @@ -230,8 +230,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 6991c119e7551b3b19935fc3169da2dfb7be439b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 01:17:53 +0000 Subject: [PATCH 295/867] Bump golang.org/x/net from 0.21.0 to 0.22.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.21.0 to 0.22.0. - [Commits](https://github.com/golang/net/compare/v0.21.0...v0.22.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b7330f52..c85f421d 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.21.0 - golang.org/x/net v0.21.0 + golang.org/x/net v0.22.0 golang.org/x/sync v0.6.0 golang.org/x/sys v0.18.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index 341370b3..b87ad8e3 100644 --- a/go.sum +++ b/go.sum @@ -203,8 +203,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From 601246468af0c9e5307d9d30aa04890570f4825f Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Tue, 5 Mar 2024 23:10:33 -0500 Subject: [PATCH 296/867] Add initial check for burstObserver --- app/observatory/burst/healthping.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/observatory/burst/healthping.go b/app/observatory/burst/healthping.go index cde9fbc1..2f0bbcc6 100644 --- a/app/observatory/burst/healthping.go +++ b/app/observatory/burst/healthping.go @@ -79,6 +79,15 @@ func (h *HealthPing) StartScheduler(selector func() ([]string, error)) { tickerClose := make(chan struct{}) h.ticker = ticker h.tickerClose = tickerClose + go func() { + tags, err := selector() + if err != nil { + newError("error select outbounds for initial health check: ", err).AtWarning().WriteToLog() + return + } + h.Check(tags) + }() + go func() { for { go func() { From baf5de5cd3ab853bbf5236f6435faf343b9f7f78 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 01:01:38 +0000 Subject: [PATCH 297/867] Bump github.com/sagernet/sing from 0.3.4 to 0.3.5 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.3.4 to 0.3.5. - [Commits](https://github.com/sagernet/sing/compare/v0.3.4...v0.3.5) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c85f421d..4844287e 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.41.0 github.com/refraction-networking/utls v1.6.3 - github.com/sagernet/sing v0.3.4 + github.com/sagernet/sing v0.3.5 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index b87ad8e3..2d9fe893 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.3.4 h1:mFGTVGFz/RxIDT9BMyJ67PanLxVh6fagB27eaUlO0aw= -github.com/sagernet/sing v0.3.4/go.mod h1:qHySJ7u8po9DABtMYEkNBcOumx7ZZJf/fbv2sfTkNHE= +github.com/sagernet/sing v0.3.5 h1:f87Y5tU8RiWhA/zzZy7rht3SbWU8t15YZEuj/UNi/gY= +github.com/sagernet/sing v0.3.5/go.mod h1:+60H3Cm91RnL9dpVGWDPHt0zTQImO9Vfqt9a4rSambI= github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= From cee776c3b77669ad019b0a22c575f65d01a28c58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 01:01:32 +0000 Subject: [PATCH 298/867] Bump google.golang.org/protobuf from 1.32.0 to 1.33.0 Bumps google.golang.org/protobuf from 1.32.0 to 1.33.0. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4844287e..493f9bdf 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( golang.org/x/sys v0.18.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.62.0 - google.golang.org/protobuf v1.32.0 + google.golang.org/protobuf v1.33.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 lukechampine.com/blake3 v1.2.1 diff --git a/go.sum b/go.sum index 2d9fe893..a27d6684 100644 --- a/go.sum +++ b/go.sum @@ -282,8 +282,8 @@ google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From e7c5059a6f7990f43fd49a67717cb0b9e813e51d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Mar 2024 04:22:05 +0000 Subject: [PATCH 299/867] Bump google.golang.org/grpc from 1.62.0 to 1.62.1 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.62.0 to 1.62.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.62.0...v1.62.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 493f9bdf..6856cff9 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/sync v0.6.0 golang.org/x/sys v0.18.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.62.0 + google.golang.org/grpc v1.62.1 google.golang.org/protobuf v1.33.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index a27d6684..a893f648 100644 --- a/go.sum +++ b/go.sum @@ -278,8 +278,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= -google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= +google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= From d7434e8e36e761854e4600c67045e7f3dbb5bfc1 Mon Sep 17 00:00:00 2001 From: Omid The Great <143901555+omid-the-great@users.noreply.github.com> Date: Fri, 8 Mar 2024 22:57:56 +0330 Subject: [PATCH 300/867] add: Add a new xray wrapper --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 97c3215f..95481eed 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ - [AndroidLibXrayLite](https://github.com/2dust/AndroidLibXrayLite) - [XrayKit](https://github.com/arror/XrayKit) - [Xray-core-python](https://github.com/LorenEteval/Xray-core-python) + - [xray-api](https://github.com/XVGuardian/xray-api) - [XrayR](https://github.com/XrayR-project/XrayR) - [XrayR-release](https://github.com/XrayR-project/XrayR-release) - [XrayR-V2Board](https://github.com/missuo/XrayR-V2Board) From 9b5c3f417eefbad79b9f761a0682498f3d03155f Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 8 Mar 2024 08:45:50 -0500 Subject: [PATCH 301/867] Fix user download stats with splice --- proxy/proxy.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index e8adb7e2..6a5a1798 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -16,6 +16,7 @@ import ( "time" "github.com/pires/go-proxyproto" + "github.com/xtls/xray-core/app/dispatcher" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" @@ -478,14 +479,18 @@ func CopyRawConnIfExist(ctx context.Context, readerConn net.Conn, writerConn net for inbound.CanSpliceCopy != 3 { if inbound.CanSpliceCopy == 1 { newError("CopyRawConn splice").WriteToLog(session.ExportIDToError(ctx)) + statWriter, _ := writer.(*dispatcher.SizeStatWriter) //runtime.Gosched() // necessary time.Sleep(time.Millisecond) // without this, there will be a rare ssl error for freedom splice w, err := tc.ReadFrom(readerConn) if readCounter != nil { - readCounter.Add(w) + readCounter.Add(w) // outbound stats } if writeCounter != nil { - writeCounter.Add(w) + writeCounter.Add(w) // inbound stats + } + if statWriter != nil { + statWriter.Counter.Add(w) // user stats } if err != nil && errors.Cause(err) != io.EOF { return err From 93cfbd6a9211828914dbb18c095deb2c3f028ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lumi=C3=A8re=20=C3=89lev=C3=A9?= <88174309+PoneyClairDeLune@users.noreply.github.com> Date: Sun, 10 Mar 2024 17:13:48 +0000 Subject: [PATCH 302/867] Tempest isn't only for OpenRC --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 95481eed..32bc0722 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ - Linux Script - [XTLS/Xray-install](https://github.com/XTLS/Xray-install) - - [team-cloudchaser/tempest](https://github.com/team-cloudchaser/tempest) (For Linux without systemd) + - [team-cloudchaser/tempest](https://github.com/team-cloudchaser/tempest) (supports [`systemd`](https://systemd.io) and [OpenRC](https://github.com/OpenRC/openrc); Linux-only) - Docker - Official: [ghcr.io/xtls/xray-core](https://ghcr.io/xtls/xray-core) - [iamybj/docker-xray](https://hub.docker.com/r/iamybj/docker-xray) From 96ca298b2a2e07bf72d8b3e0b7201faa77714eea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Mar 2024 00:28:58 +0000 Subject: [PATCH 303/867] Bump github.com/sagernet/sing from 0.3.5 to 0.3.6 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.3.5 to 0.3.6. - [Commits](https://github.com/sagernet/sing/compare/v0.3.5...v0.3.6) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6856cff9..36cad2fb 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.41.0 github.com/refraction-networking/utls v1.6.3 - github.com/sagernet/sing v0.3.5 + github.com/sagernet/sing v0.3.6 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index a893f648..ccb4f498 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.3.5 h1:f87Y5tU8RiWhA/zzZy7rht3SbWU8t15YZEuj/UNi/gY= -github.com/sagernet/sing v0.3.5/go.mod h1:+60H3Cm91RnL9dpVGWDPHt0zTQImO9Vfqt9a4rSambI= +github.com/sagernet/sing v0.3.6 h1:dsEdYLKBQlrxUfw1a92x0VdPvR1/BOxQ+HIMyaoEJsQ= +github.com/sagernet/sing v0.3.6/go.mod h1:+60H3Cm91RnL9dpVGWDPHt0zTQImO9Vfqt9a4rSambI= github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= From 37f8654957f8a20233223a5eb5235061ad91af1f Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 10 Mar 2024 15:48:50 -0400 Subject: [PATCH 304/867] Update 1.8.9 and dependencies --- core/core.go | 2 +- go.mod | 12 ++++++------ go.sum | 33 ++++++++++++++------------------- 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/core/core.go b/core/core.go index b7cd1d9b..374d5fba 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 8 + Version_z byte = 9 ) var ( diff --git a/go.mod b/go.mod index 36cad2fb..048a5dcc 100644 --- a/go.mod +++ b/go.mod @@ -39,23 +39,23 @@ require ( github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect github.com/francoispqt/gojay v1.2.13 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/pprof v0.0.0-20240225044709-fd706174c886 // indirect + github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect github.com/klauspost/compress v1.17.7 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect - github.com/onsi/ginkgo/v2 v2.15.0 // indirect + github.com/onsi/ginkgo/v2 v2.16.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.4.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect - golang.org/x/mod v0.15.0 // indirect + golang.org/x/mod v0.16.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.18.0 // indirect + golang.org/x/tools v0.19.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240308144416-29370a3891b7 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index ccb4f498..7ebfd178 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,8 @@ github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3 github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -47,22 +47,20 @@ github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/ github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20240225044709-fd706174c886 h1:JSJUTZTQT1Gzb2ROdAKOY3HwzBYcclS2GgumhMfHqjw= -github.com/google/pprof v0.0.0-20240225044709-fd706174c886/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 h1:y3N7Bm7Y9/CtpiVkw/ZWj6lSlDF3F74SfKwfTCer72Q= +github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -96,8 +94,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= -github.com/onsi/ginkgo/v2 v2.15.0 h1:79HwNRBAZHOEwrczrgSOPy+eFTTlIGELKy5as+ClttY= -github.com/onsi/ginkgo/v2 v2.15.0/go.mod h1:HlxMHtYF57y6Dpf+mc5529KKmSq9h2FpCF+/ZkwUxKM= +github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM= +github.com/onsi/ginkgo/v2 v2.16.0/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs= github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= @@ -190,8 +188,8 @@ golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTk golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -250,11 +248,10 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= -golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeunTOisW56dUokqW/FOteYJJ/yg= golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= @@ -272,16 +269,14 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c h1:NUsgEN92SQQqzfA+YtqYNqYmB3DMMYLlIwUZAQFVFbo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240308144416-29370a3891b7 h1:em/y72n4XlYRtayY/cVj6pnVzHa//BDA1BdoO+z9mdE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240308144416-29370a3891b7/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 950a64e9a410acc6b0c9ceb24d66ec3b24ba5727 Mon Sep 17 00:00:00 2001 From: simpleandstupid <61134763+simpleandstupid@users.noreply.github.com> Date: Thu, 16 Jun 2022 17:28:48 +0800 Subject: [PATCH 305/867] Change the default port of Dns over Quic --- app/dns/nameserver_quic.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 89bb4aaa..817402f9 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -48,7 +48,7 @@ func NewQUICNameServer(url *url.URL, queryStrategy QueryStrategy) (*QUICNameServ newError("DNS: created Local DNS-over-QUIC client for ", url.String()).AtInfo().WriteToLog() var err error - port := net.Port(784) + port := net.Port(853) if url.Port() != "" { port, err = net.PortFromString(url.Port()) if err != nil { From d3a218f896b5db0208f83535b8f8a30b4dae3e53 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 12 Mar 2024 11:58:29 +0000 Subject: [PATCH 306/867] Fix https://github.com/XTLS/Xray-core/issues/3128 --- transport/internet/httpupgrade/dialer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transport/internet/httpupgrade/dialer.go b/transport/internet/httpupgrade/dialer.go index 2ed43ed7..6b5435b5 100644 --- a/transport/internet/httpupgrade/dialer.go +++ b/transport/internet/httpupgrade/dialer.go @@ -36,9 +36,9 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings * } else { conn = tls.Client(pconn, tlsConfig) } - requestURL.Scheme = "https" } else { + conn = pconn requestURL.Scheme = "http" } From 5c41292836a94721427b56e512939895d5f7718c Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 13 Mar 2024 22:39:24 +0000 Subject: [PATCH 307/867] Add ConnRF to make HTTPUpgrade 0-RTT https://github.com/XTLS/Xray-core/issues/3128#issuecomment-1991809113 --- transport/internet/httpupgrade/dialer.go | 36 ++++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/transport/internet/httpupgrade/dialer.go b/transport/internet/httpupgrade/dialer.go index 6b5435b5..159dcb98 100644 --- a/transport/internet/httpupgrade/dialer.go +++ b/transport/internet/httpupgrade/dialer.go @@ -15,6 +15,29 @@ import ( "github.com/xtls/xray-core/transport/internet/tls" ) +type ConnRF struct { + net.Conn + Req *http.Request + First bool +} + +func (c *ConnRF) Read(b []byte) (int, error) { + if c.First { + c.First = false + // TODO The bufio usage here is unreliable + resp, err := http.ReadResponse(bufio.NewReader(c.Conn), c.Req) // nolint:bodyclose + if err != nil { + return 0, err + } + if resp.Status != "101 Switching Protocols" || + strings.ToLower(resp.Header.Get("Upgrade")) != "websocket" || + strings.ToLower(resp.Header.Get("Connection")) != "upgrade" { + return 0, newError("unrecognized reply") + } + } + return c.Conn.Read(b) +} + func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (net.Conn, error) { transportConfiguration := streamSettings.ProtocolSettings.(*Config) @@ -58,18 +81,7 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings * return nil, err } - // TODO The bufio usage here is unreliable - resp, err := http.ReadResponse(bufio.NewReader(conn), req) // nolint:bodyclose - if err != nil { - return nil, err - } - - if resp.Status == "101 Switching Protocols" && - strings.ToLower(resp.Header.Get("Upgrade")) == "websocket" && - strings.ToLower(resp.Header.Get("Connection")) == "upgrade" { - return conn, nil - } - return nil, newError("unrecognized reply") + return &ConnRF{Conn: conn, Req: req, First: true}, nil } func dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) { From 69e1734e3a129414db1ca12147cf51c05ffa25ba Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:49:11 -0400 Subject: [PATCH 308/867] Apply FallbackTag to leastping and roundrobin --- app/router/config.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/app/router/config.go b/app/router/config.go index 28ba7e31..ce4ed270 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -126,15 +126,17 @@ func (br *BalancingRule) Build(ohm outbound.Manager, dispatcher routing.Dispatch switch strings.ToLower(br.Strategy) { case "leastping": return &Balancer{ - selectors: br.OutboundSelector, - strategy: &LeastPingStrategy{}, - ohm: ohm, + selectors: br.OutboundSelector, + strategy: &LeastPingStrategy{}, + fallbackTag: br.FallbackTag, + ohm: ohm, }, nil case "roundrobin": return &Balancer{ - selectors: br.OutboundSelector, - strategy: &RoundRobinStrategy{}, - ohm: ohm, + selectors: br.OutboundSelector, + strategy: &RoundRobinStrategy{}, + fallbackTag: br.FallbackTag, + ohm: ohm, }, nil case "leastload": i, err := br.StrategySettings.GetInstance() @@ -147,17 +149,19 @@ func (br *BalancingRule) Build(ohm outbound.Manager, dispatcher routing.Dispatch } leastLoadStrategy := NewLeastLoadStrategy(s) return &Balancer{ - selectors: br.OutboundSelector, - ohm: ohm, fallbackTag: br.FallbackTag, - strategy: leastLoadStrategy, + selectors: br.OutboundSelector, + ohm: ohm, + fallbackTag: br.FallbackTag, + strategy: leastLoadStrategy, }, nil case "random": fallthrough case "": return &Balancer{ - selectors: br.OutboundSelector, - ohm: ohm, fallbackTag: br.FallbackTag, - strategy: &RandomStrategy{}, + selectors: br.OutboundSelector, + ohm: ohm, + fallbackTag: br.FallbackTag, + strategy: &RandomStrategy{}, }, nil default: return nil, newError("unrecognized balancer type") From 18b823b4a611fe102fdef320f0481f4b342a565a Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 17 Mar 2024 20:43:19 +0000 Subject: [PATCH 309/867] HTTPUpgrade 0-RTT (#3152) * Add ed to enable HTTPUpgrade 0-RTT https://github.com/XTLS/Xray-core/issues/3128#issuecomment-2002563369 * WebSocket hub.go MaxHeaderBytes: 4096 -> 8192 --- infra/conf/transport_internet.go | 30 +++++++++++++-------- transport/internet/httpupgrade/config.pb.go | 15 ++++++++--- transport/internet/httpupgrade/config.proto | 4 ++- transport/internet/httpupgrade/dialer.go | 15 ++++++++++- transport/internet/websocket/hub.go | 2 +- 5 files changed, 49 insertions(+), 17 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 9ab34cf5..96b458ed 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -172,12 +172,10 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { } } config := &websocket.Config{ - Path: path, - Header: header, - Ed: ed, - } - if c.AcceptProxyProtocol { - config.AcceptProxyProtocol = c.AcceptProxyProtocol + Path: path, + Header: header, + AcceptProxyProtocol: c.AcceptProxyProtocol, + Ed: ed, } return config, nil } @@ -190,12 +188,22 @@ type HttpUpgradeConfig struct { // Build implements Buildable. func (c *HttpUpgradeConfig) Build() (proto.Message, error) { - config := &httpupgrade.Config{ - Path: c.Path, - Host: c.Host, + path := c.Path + var ed uint32 + if u, err := url.Parse(path); err == nil { + if q := u.Query(); q.Get("ed") != "" { + Ed, _ := strconv.Atoi(q.Get("ed")) + ed = uint32(Ed) + q.Del("ed") + u.RawQuery = q.Encode() + path = u.String() + } } - if c.AcceptProxyProtocol { - config.AcceptProxyProtocol = c.AcceptProxyProtocol + config := &httpupgrade.Config{ + Path: path, + Host: c.Host, + AcceptProxyProtocol: c.AcceptProxyProtocol, + Ed: ed, } return config, nil } diff --git a/transport/internet/httpupgrade/config.pb.go b/transport/internet/httpupgrade/config.pb.go index f097f63f..5b9fb7bc 100644 --- a/transport/internet/httpupgrade/config.pb.go +++ b/transport/internet/httpupgrade/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.32.0 -// protoc v4.25.1 +// protoc v4.23.1 // source: transport/internet/httpupgrade/config.proto package httpupgrade @@ -28,6 +28,7 @@ type Config struct { Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` AcceptProxyProtocol bool `protobuf:"varint,4,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` + Ed uint32 `protobuf:"varint,5,opt,name=ed,proto3" json:"ed,omitempty"` } func (x *Config) Reset() { @@ -83,6 +84,13 @@ func (x *Config) GetAcceptProxyProtocol() bool { return false } +func (x *Config) GetEd() uint32 { + if x != nil { + return x.Ed + } + return 0 +} + var File_transport_internet_httpupgrade_config_proto protoreflect.FileDescriptor var file_transport_internet_httpupgrade_config_proto_rawDesc = []byte{ @@ -91,13 +99,14 @@ var file_transport_internet_httpupgrade_config_proto_rawDesc = []byte{ 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x23, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, - 0x64, 0x65, 0x22, 0x6a, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, + 0x64, 0x65, 0x22, 0x7a, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x42, 0x8b, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x65, 0x64, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x65, 0x64, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x42, 0x8b, 0x01, 0x0a, 0x27, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, diff --git a/transport/internet/httpupgrade/config.proto b/transport/internet/httpupgrade/config.proto index 2be7cc22..c1874c9e 100644 --- a/transport/internet/httpupgrade/config.proto +++ b/transport/internet/httpupgrade/config.proto @@ -13,4 +13,6 @@ message Config { string host = 3; bool accept_proxy_protocol = 4; -} \ No newline at end of file + + uint32 ed = 5; +} diff --git a/transport/internet/httpupgrade/dialer.go b/transport/internet/httpupgrade/dialer.go index 159dcb98..691f85a8 100644 --- a/transport/internet/httpupgrade/dialer.go +++ b/transport/internet/httpupgrade/dialer.go @@ -81,7 +81,20 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings * return nil, err } - return &ConnRF{Conn: conn, Req: req, First: true}, nil + connRF := &ConnRF{ + Conn: conn, + Req: req, + First: true, + } + + if transportConfiguration.Ed == 0 { + _, err = connRF.Read([]byte{}) + if err != nil { + return nil, err + } + } + + return connRF, nil } func dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) { diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index c907e224..b3fe9ff4 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -129,7 +129,7 @@ func ListenWS(ctx context.Context, address net.Address, port net.Port, streamSet ln: l, }, ReadHeaderTimeout: time.Second * 4, - MaxHeaderBytes: 4096, + MaxHeaderBytes: 8192, } go func() { From bb48a2043dcf5ab52867ce9e315aa8ce0c7d307a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Mon, 18 Mar 2024 13:16:46 +0800 Subject: [PATCH 310/867] Fix HTTPUpgrade transport register --- transport/internet/config.go | 2 ++ transport/internet/config.pb.go | 46 ++++++++++++++++++--------------- transport/internet/config.proto | 1 + 3 files changed, 28 insertions(+), 21 deletions(-) diff --git a/transport/internet/config.go b/transport/internet/config.go index 6725a995..0dc617e7 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -43,6 +43,8 @@ func transportProtocolToString(protocol TransportProtocol) string { return "websocket" case TransportProtocol_DomainSocket: return "domainsocket" + case TransportProtocol_HttpUpgrade: + return "httpupgrade" default: return unknownProtocol } diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 3c8e36f5..fd527548 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 -// protoc v4.23.1 +// protoc-gen-go v1.33.0 +// protoc v3.6.1 // source: transport/internet/config.proto package internet @@ -30,6 +30,7 @@ const ( TransportProtocol_WebSocket TransportProtocol = 3 TransportProtocol_HTTP TransportProtocol = 4 TransportProtocol_DomainSocket TransportProtocol = 5 + TransportProtocol_HttpUpgrade TransportProtocol = 6 ) // Enum value maps for TransportProtocol. @@ -41,6 +42,7 @@ var ( 3: "WebSocket", 4: "HTTP", 5: "DomainSocket", + 6: "HttpUpgrade", } TransportProtocol_value = map[string]int32{ "TCP": 0, @@ -49,6 +51,7 @@ var ( "WebSocket": 3, "HTTP": 4, "DomainSocket": 5, + "HttpUpgrade": 6, } ) @@ -725,30 +728,31 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x4d, 0x70, 0x74, 0x63, 0x70, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, - 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x5a, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x6b, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, - 0x10, 0x05, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, - 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, - 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, - 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, - 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, - 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, - 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, - 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, - 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, - 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, 0x67, - 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, - 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, - 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, - 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x10, 0x05, 0x12, 0x0f, 0x0a, 0x0b, 0x48, 0x74, 0x74, 0x70, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, + 0x65, 0x10, 0x06, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, + 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, + 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, + 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, + 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, + 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, + 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, + 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, + 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, + 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, + 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, + 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, + 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/config.proto b/transport/internet/config.proto index f596d19f..38bab4a1 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -15,6 +15,7 @@ enum TransportProtocol { WebSocket = 3; HTTP = 4; DomainSocket = 5; + HttpUpgrade = 6; } enum DomainStrategy { From f848a364e368a1a0d477c4b2b0bab4d5c580a49f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Mar 2024 00:47:06 +0000 Subject: [PATCH 311/867] Bump github.com/quic-go/quic-go from 0.41.0 to 0.42.0 Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.41.0 to 0.42.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.41.0...v0.42.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 048a5dcc..ac01776e 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/miekg/dns v1.1.58 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.41.0 + github.com/quic-go/quic-go v0.42.0 github.com/refraction-networking/utls v1.6.3 github.com/sagernet/sing v0.3.6 github.com/sagernet/sing-shadowsocks v0.2.6 diff --git a/go.sum b/go.sum index 7ebfd178..59753582 100644 --- a/go.sum +++ b/go.sum @@ -112,8 +112,8 @@ github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k= -github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA= +github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= +github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= github.com/refraction-networking/utls v1.6.3 h1:MFOfRN35sSx6K5AZNIoESsBuBxS2LCgRilRIdHb6fDc= github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr3h62pQoY1lXiNR/FPs= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From c05fd2f8c2143f64da6713bd824c86c3201cfc3e Mon Sep 17 00:00:00 2001 From: debian-go <438092+upbeat-backbone-bose@users.noreply.github.com> Date: Wed, 20 Mar 2024 10:35:21 +0800 Subject: [PATCH 312/867] Update README.md Remove invalid client addresses --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 32bc0722..dce3383c 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,6 @@ - [HiddifyNG](https://github.com/hiddify/HiddifyNG) - [X-flutter](https://github.com/XTLS/X-flutter) - iOS & macOS arm64 - - [Mango](https://github.com/arror/Mango) - [FoXray](https://apps.apple.com/app/foxray/id6448898396) - [Streisand](https://apps.apple.com/app/streisand/id6450534064) - macOS arm64 & x64 From fe3a0cf95436e1ebbd45fc590bee998fb9d3868a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=82=BB?= <123655015+chise0713@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:22:56 +0800 Subject: [PATCH 313/867] Chore: Clean up legacy `field` usage --- infra/conf/router.go | 52 +------------------------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/infra/conf/router.go b/infra/conf/router.go index 9c7ce789..5a6ca8fe 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -8,8 +8,8 @@ import ( "github.com/xtls/xray-core/app/router" "github.com/xtls/xray-core/common/net" - "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/platform/filesystem" + "github.com/xtls/xray-core/common/serial" "google.golang.org/protobuf/proto" ) @@ -663,55 +663,5 @@ func ParseRule(msg json.RawMessage) (*router.RoutingRule, error) { } return fieldrule, nil } - if strings.EqualFold(rawRule.Type, "chinaip") { - chinaiprule, err := parseChinaIPRule(msg) - if err != nil { - return nil, newError("invalid chinaip rule").Base(err) - } - return chinaiprule, nil - } - if strings.EqualFold(rawRule.Type, "chinasites") { - chinasitesrule, err := parseChinaSitesRule(msg) - if err != nil { - return nil, newError("invalid chinasites rule").Base(err) - } - return chinasitesrule, nil - } return nil, newError("unknown router rule type: ", rawRule.Type) } - -func parseChinaIPRule(data []byte) (*router.RoutingRule, error) { - rawRule := new(RouterRule) - err := json.Unmarshal(data, rawRule) - if err != nil { - return nil, newError("invalid router rule").Base(err) - } - chinaIPs, err := loadGeoIP("CN") - if err != nil { - return nil, newError("failed to load geoip:cn").Base(err) - } - return &router.RoutingRule{ - TargetTag: &router.RoutingRule_Tag{ - Tag: rawRule.OutboundTag, - }, - Cidr: chinaIPs, - }, nil -} - -func parseChinaSitesRule(data []byte) (*router.RoutingRule, error) { - rawRule := new(RouterRule) - err := json.Unmarshal(data, rawRule) - if err != nil { - return nil, newError("invalid router rule").Base(err).AtError() - } - domains, err := loadGeositeWithAttr("geosite.dat", "CN") - if err != nil { - return nil, newError("failed to load geosite:cn.").Base(err) - } - return &router.RoutingRule{ - TargetTag: &router.RoutingRule_Tag{ - Tag: rawRule.OutboundTag, - }, - Domain: domains, - }, nil -} From 657c5c857080e4b5a00b7456ab96c47c2aa7d40f Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:08:43 -0400 Subject: [PATCH 314/867] Update HTTPUpgrade spelling and proto --- app/commander/config.pb.go | 2 +- app/dispatcher/config.pb.go | 2 +- app/dns/config.pb.go | 2 +- app/dns/fakedns/fakedns.pb.go | 2 +- app/log/command/config.pb.go | 2 +- app/log/config.pb.go | 2 +- app/metrics/config.pb.go | 2 +- app/observatory/burst/config.pb.go | 2 +- app/observatory/command/command.pb.go | 2 +- app/observatory/config.pb.go | 2 +- app/policy/config.pb.go | 2 +- app/proxyman/command/command.pb.go | 2 +- app/proxyman/config.pb.go | 2 +- app/reverse/config.pb.go | 2 +- app/router/command/command.pb.go | 2 +- app/router/config.pb.go | 2 +- app/stats/command/command.pb.go | 2 +- app/stats/config.pb.go | 2 +- common/log/log.pb.go | 2 +- common/net/address.pb.go | 2 +- common/net/destination.pb.go | 2 +- common/net/network.pb.go | 2 +- common/net/port.pb.go | 2 +- common/protocol/headers.pb.go | 2 +- common/protocol/server_spec.pb.go | 2 +- common/protocol/user.pb.go | 2 +- common/serial/typed_message.pb.go | 2 +- core/config.pb.go | 2 +- proxy/blackhole/config.pb.go | 2 +- proxy/dns/config.pb.go | 2 +- proxy/dokodemo/config.pb.go | 2 +- proxy/freedom/config.pb.go | 2 +- proxy/http/config.pb.go | 2 +- proxy/loopback/config.pb.go | 2 +- proxy/shadowsocks/config.pb.go | 2 +- proxy/shadowsocks_2022/config.pb.go | 2 +- proxy/socks/config.pb.go | 2 +- proxy/trojan/config.pb.go | 2 +- proxy/vless/account.pb.go | 2 +- proxy/vless/encoding/addons.pb.go | 2 +- proxy/vless/inbound/config.pb.go | 2 +- proxy/vless/outbound/config.pb.go | 2 +- proxy/vmess/account.pb.go | 2 +- proxy/vmess/inbound/config.pb.go | 2 +- proxy/vmess/outbound/config.pb.go | 2 +- proxy/wireguard/config.pb.go | 2 +- transport/global/config.pb.go | 2 +- transport/internet/config.go | 2 +- transport/internet/config.pb.go | 10 +++++----- transport/internet/config.proto | 2 +- transport/internet/domainsocket/config.pb.go | 2 +- transport/internet/grpc/config.pb.go | 2 +- transport/internet/grpc/encoding/stream.pb.go | 2 +- transport/internet/headers/dns/config.pb.go | 2 +- transport/internet/headers/http/config.pb.go | 2 +- transport/internet/headers/noop/config.pb.go | 2 +- transport/internet/headers/srtp/config.pb.go | 2 +- transport/internet/headers/tls/config.pb.go | 2 +- transport/internet/headers/utp/config.pb.go | 2 +- transport/internet/headers/wechat/config.pb.go | 2 +- transport/internet/headers/wireguard/config.pb.go | 2 +- transport/internet/http/config.pb.go | 2 +- transport/internet/httpupgrade/config.pb.go | 2 +- transport/internet/kcp/config.pb.go | 2 +- transport/internet/quic/config.pb.go | 2 +- transport/internet/reality/config.pb.go | 2 +- transport/internet/tcp/config.pb.go | 2 +- transport/internet/tls/config.pb.go | 2 +- transport/internet/udp/config.pb.go | 2 +- transport/internet/websocket/config.pb.go | 2 +- 70 files changed, 74 insertions(+), 74 deletions(-) diff --git a/app/commander/config.pb.go b/app/commander/config.pb.go index 2c7b954e..cf46b1b6 100644 --- a/app/commander/config.pb.go +++ b/app/commander/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/commander/config.proto diff --git a/app/dispatcher/config.pb.go b/app/dispatcher/config.pb.go index cd55bd69..92936a7f 100644 --- a/app/dispatcher/config.pb.go +++ b/app/dispatcher/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/dispatcher/config.proto diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index 51638688..1c072443 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/dns/config.proto diff --git a/app/dns/fakedns/fakedns.pb.go b/app/dns/fakedns/fakedns.pb.go index c9a09a2c..906cb446 100644 --- a/app/dns/fakedns/fakedns.pb.go +++ b/app/dns/fakedns/fakedns.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/dns/fakedns/fakedns.proto diff --git a/app/log/command/config.pb.go b/app/log/command/config.pb.go index 258f8cb1..68f418f9 100644 --- a/app/log/command/config.pb.go +++ b/app/log/command/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/log/command/config.proto diff --git a/app/log/config.pb.go b/app/log/config.pb.go index 3e981674..093dd04f 100644 --- a/app/log/config.pb.go +++ b/app/log/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/log/config.proto diff --git a/app/metrics/config.pb.go b/app/metrics/config.pb.go index 9bab8d20..218a0284 100644 --- a/app/metrics/config.pb.go +++ b/app/metrics/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/metrics/config.proto diff --git a/app/observatory/burst/config.pb.go b/app/observatory/burst/config.pb.go index ce371583..15a29a51 100644 --- a/app/observatory/burst/config.pb.go +++ b/app/observatory/burst/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/observatory/burst/config.proto diff --git a/app/observatory/command/command.pb.go b/app/observatory/command/command.pb.go index abf170c8..6f50c245 100644 --- a/app/observatory/command/command.pb.go +++ b/app/observatory/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/observatory/command/command.proto diff --git a/app/observatory/config.pb.go b/app/observatory/config.pb.go index 708fcf76..40253497 100644 --- a/app/observatory/config.pb.go +++ b/app/observatory/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/observatory/config.proto diff --git a/app/policy/config.pb.go b/app/policy/config.pb.go index 0bfef971..fefeb4f1 100644 --- a/app/policy/config.pb.go +++ b/app/policy/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/policy/config.proto diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index a689a808..bc2fb781 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/proxyman/command/command.proto diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index 541679ac..7e142bfd 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/proxyman/config.proto diff --git a/app/reverse/config.pb.go b/app/reverse/config.pb.go index c262f47a..b7899948 100644 --- a/app/reverse/config.pb.go +++ b/app/reverse/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/reverse/config.proto diff --git a/app/router/command/command.pb.go b/app/router/command/command.pb.go index 5cdf5332..0c0be90b 100644 --- a/app/router/command/command.pb.go +++ b/app/router/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/router/command/command.proto diff --git a/app/router/config.pb.go b/app/router/config.pb.go index 59a86a2e..36459c1c 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/router/config.proto diff --git a/app/stats/command/command.pb.go b/app/stats/command/command.pb.go index 1de78b96..cb6a1183 100644 --- a/app/stats/command/command.pb.go +++ b/app/stats/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/stats/command/command.proto diff --git a/app/stats/config.pb.go b/app/stats/config.pb.go index 24730161..1ca8a4db 100644 --- a/app/stats/config.pb.go +++ b/app/stats/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: app/stats/config.proto diff --git a/common/log/log.pb.go b/common/log/log.pb.go index 3b0f89b0..7d3c45bd 100644 --- a/common/log/log.pb.go +++ b/common/log/log.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: common/log/log.proto diff --git a/common/net/address.pb.go b/common/net/address.pb.go index 169ced8d..feb9f606 100644 --- a/common/net/address.pb.go +++ b/common/net/address.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: common/net/address.proto diff --git a/common/net/destination.pb.go b/common/net/destination.pb.go index ac9fae9b..06afca47 100644 --- a/common/net/destination.pb.go +++ b/common/net/destination.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: common/net/destination.proto diff --git a/common/net/network.pb.go b/common/net/network.pb.go index 867e3cd6..29f487e4 100644 --- a/common/net/network.pb.go +++ b/common/net/network.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: common/net/network.proto diff --git a/common/net/port.pb.go b/common/net/port.pb.go index 1b80a81a..245e5131 100644 --- a/common/net/port.pb.go +++ b/common/net/port.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: common/net/port.proto diff --git a/common/protocol/headers.pb.go b/common/protocol/headers.pb.go index 39e2f16d..2aaddcef 100644 --- a/common/protocol/headers.pb.go +++ b/common/protocol/headers.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: common/protocol/headers.proto diff --git a/common/protocol/server_spec.pb.go b/common/protocol/server_spec.pb.go index 34642373..cbb083df 100644 --- a/common/protocol/server_spec.pb.go +++ b/common/protocol/server_spec.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: common/protocol/server_spec.proto diff --git a/common/protocol/user.pb.go b/common/protocol/user.pb.go index 972cca84..cb1c340f 100644 --- a/common/protocol/user.pb.go +++ b/common/protocol/user.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: common/protocol/user.proto diff --git a/common/serial/typed_message.pb.go b/common/serial/typed_message.pb.go index a5846dc8..bb344328 100644 --- a/common/serial/typed_message.pb.go +++ b/common/serial/typed_message.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: common/serial/typed_message.proto diff --git a/core/config.pb.go b/core/config.pb.go index de21cc56..0d5b1ea8 100644 --- a/core/config.pb.go +++ b/core/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: core/config.proto diff --git a/proxy/blackhole/config.pb.go b/proxy/blackhole/config.pb.go index 6b047974..38a0f76d 100644 --- a/proxy/blackhole/config.pb.go +++ b/proxy/blackhole/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/blackhole/config.proto diff --git a/proxy/dns/config.pb.go b/proxy/dns/config.pb.go index 6b1f062a..af9d7913 100644 --- a/proxy/dns/config.pb.go +++ b/proxy/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/dns/config.proto diff --git a/proxy/dokodemo/config.pb.go b/proxy/dokodemo/config.pb.go index 206089e8..7dfd6568 100644 --- a/proxy/dokodemo/config.pb.go +++ b/proxy/dokodemo/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/dokodemo/config.proto diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 447c9cde..5db2148d 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/freedom/config.proto diff --git a/proxy/http/config.pb.go b/proxy/http/config.pb.go index 4c5776e6..023c1b1b 100644 --- a/proxy/http/config.pb.go +++ b/proxy/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/http/config.proto diff --git a/proxy/loopback/config.pb.go b/proxy/loopback/config.pb.go index f9a89d55..53123ca1 100644 --- a/proxy/loopback/config.pb.go +++ b/proxy/loopback/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/loopback/config.proto diff --git a/proxy/shadowsocks/config.pb.go b/proxy/shadowsocks/config.pb.go index 33d96f5c..6c2d0ddb 100644 --- a/proxy/shadowsocks/config.pb.go +++ b/proxy/shadowsocks/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/shadowsocks/config.proto diff --git a/proxy/shadowsocks_2022/config.pb.go b/proxy/shadowsocks_2022/config.pb.go index 12d03625..07f459a0 100644 --- a/proxy/shadowsocks_2022/config.pb.go +++ b/proxy/shadowsocks_2022/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/shadowsocks_2022/config.proto diff --git a/proxy/socks/config.pb.go b/proxy/socks/config.pb.go index 991b467e..b10affd3 100644 --- a/proxy/socks/config.pb.go +++ b/proxy/socks/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/socks/config.proto diff --git a/proxy/trojan/config.pb.go b/proxy/trojan/config.pb.go index 63003b50..29a307ea 100644 --- a/proxy/trojan/config.pb.go +++ b/proxy/trojan/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/trojan/config.proto diff --git a/proxy/vless/account.pb.go b/proxy/vless/account.pb.go index 21f1a729..203e3376 100644 --- a/proxy/vless/account.pb.go +++ b/proxy/vless/account.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/vless/account.proto diff --git a/proxy/vless/encoding/addons.pb.go b/proxy/vless/encoding/addons.pb.go index 02dcc713..b6a2925d 100644 --- a/proxy/vless/encoding/addons.pb.go +++ b/proxy/vless/encoding/addons.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/vless/encoding/addons.proto diff --git a/proxy/vless/inbound/config.pb.go b/proxy/vless/inbound/config.pb.go index 952b3b51..9a763b1d 100644 --- a/proxy/vless/inbound/config.pb.go +++ b/proxy/vless/inbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/vless/inbound/config.proto diff --git a/proxy/vless/outbound/config.pb.go b/proxy/vless/outbound/config.pb.go index 428110d8..95955b1e 100644 --- a/proxy/vless/outbound/config.pb.go +++ b/proxy/vless/outbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/vless/outbound/config.proto diff --git a/proxy/vmess/account.pb.go b/proxy/vmess/account.pb.go index 0d41c368..ef212c38 100644 --- a/proxy/vmess/account.pb.go +++ b/proxy/vmess/account.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/vmess/account.proto diff --git a/proxy/vmess/inbound/config.pb.go b/proxy/vmess/inbound/config.pb.go index e7d50c6a..0db3fdc1 100644 --- a/proxy/vmess/inbound/config.pb.go +++ b/proxy/vmess/inbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/vmess/inbound/config.proto diff --git a/proxy/vmess/outbound/config.pb.go b/proxy/vmess/outbound/config.pb.go index c08479f7..7894241e 100644 --- a/proxy/vmess/outbound/config.pb.go +++ b/proxy/vmess/outbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/vmess/outbound/config.proto diff --git a/proxy/wireguard/config.pb.go b/proxy/wireguard/config.pb.go index c620471e..3563685e 100644 --- a/proxy/wireguard/config.pb.go +++ b/proxy/wireguard/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: proxy/wireguard/config.proto diff --git a/transport/global/config.pb.go b/transport/global/config.pb.go index 046c39e8..f77b1da3 100644 --- a/transport/global/config.pb.go +++ b/transport/global/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/global/config.proto diff --git a/transport/internet/config.go b/transport/internet/config.go index 0dc617e7..a2091f5c 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -43,7 +43,7 @@ func transportProtocolToString(protocol TransportProtocol) string { return "websocket" case TransportProtocol_DomainSocket: return "domainsocket" - case TransportProtocol_HttpUpgrade: + case TransportProtocol_HTTPUpgrade: return "httpupgrade" default: return unknownProtocol diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index fd527548..629b0315 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 -// protoc v3.6.1 +// protoc v4.23.1 // source: transport/internet/config.proto package internet @@ -30,7 +30,7 @@ const ( TransportProtocol_WebSocket TransportProtocol = 3 TransportProtocol_HTTP TransportProtocol = 4 TransportProtocol_DomainSocket TransportProtocol = 5 - TransportProtocol_HttpUpgrade TransportProtocol = 6 + TransportProtocol_HTTPUpgrade TransportProtocol = 6 ) // Enum value maps for TransportProtocol. @@ -42,7 +42,7 @@ var ( 3: "WebSocket", 4: "HTTP", 5: "DomainSocket", - 6: "HttpUpgrade", + 6: "HTTPUpgrade", } TransportProtocol_value = map[string]int32{ "TCP": 0, @@ -51,7 +51,7 @@ var ( "WebSocket": 3, "HTTP": 4, "DomainSocket": 5, - "HttpUpgrade": 6, + "HTTPUpgrade": 6, } ) @@ -734,7 +734,7 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, - 0x10, 0x05, 0x12, 0x0f, 0x0a, 0x0b, 0x48, 0x74, 0x74, 0x70, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, + 0x10, 0x05, 0x12, 0x0f, 0x0a, 0x0b, 0x48, 0x54, 0x54, 0x50, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x10, 0x06, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, diff --git a/transport/internet/config.proto b/transport/internet/config.proto index 38bab4a1..22277b42 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -15,7 +15,7 @@ enum TransportProtocol { WebSocket = 3; HTTP = 4; DomainSocket = 5; - HttpUpgrade = 6; + HTTPUpgrade = 6; } enum DomainStrategy { diff --git a/transport/internet/domainsocket/config.pb.go b/transport/internet/domainsocket/config.pb.go index 276293f1..50bf0984 100644 --- a/transport/internet/domainsocket/config.pb.go +++ b/transport/internet/domainsocket/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/domainsocket/config.proto diff --git a/transport/internet/grpc/config.pb.go b/transport/internet/grpc/config.pb.go index a9059ad4..6c441171 100644 --- a/transport/internet/grpc/config.pb.go +++ b/transport/internet/grpc/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/grpc/config.proto diff --git a/transport/internet/grpc/encoding/stream.pb.go b/transport/internet/grpc/encoding/stream.pb.go index 6450c7d1..cdab47cd 100644 --- a/transport/internet/grpc/encoding/stream.pb.go +++ b/transport/internet/grpc/encoding/stream.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/grpc/encoding/stream.proto diff --git a/transport/internet/headers/dns/config.pb.go b/transport/internet/headers/dns/config.pb.go index 1dc5783e..418bedad 100644 --- a/transport/internet/headers/dns/config.pb.go +++ b/transport/internet/headers/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/headers/dns/config.proto diff --git a/transport/internet/headers/http/config.pb.go b/transport/internet/headers/http/config.pb.go index b18e4228..f7c7109d 100644 --- a/transport/internet/headers/http/config.pb.go +++ b/transport/internet/headers/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/headers/http/config.proto diff --git a/transport/internet/headers/noop/config.pb.go b/transport/internet/headers/noop/config.pb.go index fdccb47e..8a40604c 100644 --- a/transport/internet/headers/noop/config.pb.go +++ b/transport/internet/headers/noop/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/headers/noop/config.proto diff --git a/transport/internet/headers/srtp/config.pb.go b/transport/internet/headers/srtp/config.pb.go index ed841c38..7dd2d15d 100644 --- a/transport/internet/headers/srtp/config.pb.go +++ b/transport/internet/headers/srtp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/headers/srtp/config.proto diff --git a/transport/internet/headers/tls/config.pb.go b/transport/internet/headers/tls/config.pb.go index aa026e8a..864b2042 100644 --- a/transport/internet/headers/tls/config.pb.go +++ b/transport/internet/headers/tls/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/headers/tls/config.proto diff --git a/transport/internet/headers/utp/config.pb.go b/transport/internet/headers/utp/config.pb.go index a6e1dd1e..057a8bfd 100644 --- a/transport/internet/headers/utp/config.pb.go +++ b/transport/internet/headers/utp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/headers/utp/config.proto diff --git a/transport/internet/headers/wechat/config.pb.go b/transport/internet/headers/wechat/config.pb.go index edb45f28..38d00a0c 100644 --- a/transport/internet/headers/wechat/config.pb.go +++ b/transport/internet/headers/wechat/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/headers/wechat/config.proto diff --git a/transport/internet/headers/wireguard/config.pb.go b/transport/internet/headers/wireguard/config.pb.go index f46ba626..efe7f27c 100644 --- a/transport/internet/headers/wireguard/config.pb.go +++ b/transport/internet/headers/wireguard/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/headers/wireguard/config.proto diff --git a/transport/internet/http/config.pb.go b/transport/internet/http/config.pb.go index 12624f02..cbf1a3b7 100644 --- a/transport/internet/http/config.pb.go +++ b/transport/internet/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/http/config.proto diff --git a/transport/internet/httpupgrade/config.pb.go b/transport/internet/httpupgrade/config.pb.go index 5b9fb7bc..edd4e753 100644 --- a/transport/internet/httpupgrade/config.pb.go +++ b/transport/internet/httpupgrade/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/httpupgrade/config.proto diff --git a/transport/internet/kcp/config.pb.go b/transport/internet/kcp/config.pb.go index 2369dc50..213b9042 100644 --- a/transport/internet/kcp/config.pb.go +++ b/transport/internet/kcp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/kcp/config.proto diff --git a/transport/internet/quic/config.pb.go b/transport/internet/quic/config.pb.go index b5b9b8a3..76a0752b 100644 --- a/transport/internet/quic/config.pb.go +++ b/transport/internet/quic/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/quic/config.proto diff --git a/transport/internet/reality/config.pb.go b/transport/internet/reality/config.pb.go index 220d871d..5c6a5d3f 100644 --- a/transport/internet/reality/config.pb.go +++ b/transport/internet/reality/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/reality/config.proto diff --git a/transport/internet/tcp/config.pb.go b/transport/internet/tcp/config.pb.go index 1ee10034..2d1eb352 100644 --- a/transport/internet/tcp/config.pb.go +++ b/transport/internet/tcp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/tcp/config.proto diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index daa02fd9..0e616ae8 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/tls/config.proto diff --git a/transport/internet/udp/config.pb.go b/transport/internet/udp/config.pb.go index 82df7a75..6b0c2079 100644 --- a/transport/internet/udp/config.pb.go +++ b/transport/internet/udp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/udp/config.proto diff --git a/transport/internet/websocket/config.pb.go b/transport/internet/websocket/config.pb.go index 490dcfa0..aecd530c 100644 --- a/transport/internet/websocket/config.pb.go +++ b/transport/internet/websocket/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.33.0 // protoc v4.23.1 // source: transport/internet/websocket/config.proto From 70a5fe9a250c5863ba675deaa9749e81f6539e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= <45535409+Fangliding@users.noreply.github.com> Date: Thu, 21 Mar 2024 10:15:07 +0000 Subject: [PATCH 315/867] Allow to send through random IPv6 --- app/proxyman/config.pb.go | 54 +++++++++++++++++++------------- app/proxyman/config.proto | 1 + app/proxyman/outbound/handler.go | 22 ++++++++++++- infra/conf/xray.go | 47 +++++++++++++++++---------- 4 files changed, 84 insertions(+), 40 deletions(-) diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index 7e142bfd..501908d0 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 -// protoc v4.23.1 +// protoc v5.26.0 // source: app/proxyman/config.proto package proxyman @@ -524,6 +524,7 @@ type SenderConfig struct { StreamSettings *internet.StreamConfig `protobuf:"bytes,2,opt,name=stream_settings,json=streamSettings,proto3" json:"stream_settings,omitempty"` ProxySettings *internet.ProxyConfig `protobuf:"bytes,3,opt,name=proxy_settings,json=proxySettings,proto3" json:"proxy_settings,omitempty"` MultiplexSettings *MultiplexingConfig `protobuf:"bytes,4,opt,name=multiplex_settings,json=multiplexSettings,proto3" json:"multiplex_settings,omitempty"` + ViaCidr string `protobuf:"bytes,5,opt,name=via_cidr,json=viaCidr,proto3" json:"via_cidr,omitempty"` } func (x *SenderConfig) Reset() { @@ -586,6 +587,13 @@ func (x *SenderConfig) GetMultiplexSettings() *MultiplexingConfig { return nil } +func (x *SenderConfig) GetViaCidr() string { + if x != nil { + return x.ViaCidr + } + return "" +} + type MultiplexingConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -855,7 +863,7 @@ var file_app_proxyman_config_proto_rawDesc = []byte{ 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x10, 0x0a, 0x0e, 0x4f, 0x75, 0x74, 0x62, 0x6f, - 0x75, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0xb0, 0x02, 0x0a, 0x0c, 0x53, 0x65, + 0x75, 0x6e, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0xcb, 0x02, 0x0a, 0x0c, 0x53, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x2d, 0x0a, 0x03, 0x76, 0x69, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, @@ -874,26 +882,28 @@ var file_app_proxyman_config_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x6d, 0x75, 0x6c, 0x74, 0x69, - 0x70, 0x6c, 0x65, 0x78, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0xa4, 0x01, 0x0a, - 0x12, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x20, 0x0a, - 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, - 0x28, 0x0a, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x63, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x43, 0x6f, - 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x78, 0x75, 0x64, - 0x70, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x55, 0x44, 0x50, 0x34, 0x34, 0x33, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x55, 0x44, 0x50, - 0x34, 0x34, 0x33, 0x2a, 0x23, 0x0a, 0x0e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x00, 0x12, - 0x07, 0x0a, 0x03, 0x54, 0x4c, 0x53, 0x10, 0x01, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, - 0x6e, 0x50, 0x01, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, - 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, - 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x6c, 0x65, 0x78, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x19, 0x0a, 0x08, + 0x76, 0x69, 0x61, 0x5f, 0x63, 0x69, 0x64, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x76, 0x69, 0x61, 0x43, 0x69, 0x64, 0x72, 0x22, 0xa4, 0x01, 0x0a, 0x12, 0x4d, 0x75, 0x6c, 0x74, + 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x18, + 0x0a, 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x07, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x63, + 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x78, 0x75, + 0x64, 0x70, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x63, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x50, 0x72, 0x6f, 0x78, + 0x79, 0x55, 0x44, 0x50, 0x34, 0x34, 0x33, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x78, + 0x75, 0x64, 0x70, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x55, 0x44, 0x50, 0x34, 0x34, 0x33, 0x2a, 0x23, + 0x0a, 0x0e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, + 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x4c, + 0x53, 0x10, 0x01, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x50, 0x01, 0x5a, 0x26, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, + 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, + 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/app/proxyman/config.proto b/app/proxyman/config.proto index 5d063eba..fe18c378 100644 --- a/app/proxyman/config.proto +++ b/app/proxyman/config.proto @@ -91,6 +91,7 @@ message SenderConfig { xray.transport.internet.StreamConfig stream_settings = 2; xray.transport.internet.ProxyConfig proxy_settings = 3; MultiplexingConfig multiplex_settings = 4; + string via_cidr = 5; } message MultiplexingConfig { diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 2df2b2c3..41713d0b 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -4,6 +4,8 @@ import ( "context" "errors" "io" + "math/rand" + gonet "net" "os" "github.com/xtls/xray-core/app/proxyman" @@ -269,7 +271,11 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connecti outbound = new(session.Outbound) ctx = session.ContextWithOutbound(ctx, outbound) } - outbound.Gateway = h.senderSettings.Via.AsAddress() + if h.senderSettings.ViaCidr == "" { + outbound.Gateway = h.senderSettings.Via.AsAddress() + } else { //Get a random address. + outbound.Gateway = ParseRandomIPv6(h.senderSettings.Via.AsAddress(), h.senderSettings.ViaCidr) + } } } @@ -312,3 +318,17 @@ func (h *Handler) Close() error { common.Close(h.mux) return nil } + +// Return random IPv6 in a CIDR block +func ParseRandomIPv6(address net.Address, prefix string) net.Address { + addr := address.IP().String() + _, network, _ := gonet.ParseCIDR(addr + "/" + prefix) + + ipv6 := network.IP.To16() + prefixLen, _ := network.Mask.Size() + for i := prefixLen / 8; i < 16; i++ { + ipv6[i] = byte(rand.Intn(256)) + } + + return net.ParseAddress(gonet.IP(ipv6).String()) +} diff --git a/infra/conf/xray.go b/infra/conf/xray.go index c99dca59..645da473 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -11,6 +11,7 @@ import ( "github.com/xtls/xray-core/app/dispatcher" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/app/stats" + "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/serial" core "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/transport/internet" @@ -279,7 +280,7 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) { type OutboundDetourConfig struct { Protocol string `json:"protocol"` - SendThrough *Address `json:"sendThrough"` + SendThrough *string `json:"sendThrough"` Tag string `json:"tag"` Settings *json.RawMessage `json:"settings"` StreamSetting *StreamConfig `json:"streamSettings"` @@ -305,9 +306,14 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) { } if c.SendThrough != nil { - address := c.SendThrough - if address.Family().IsDomain() { - return nil, newError("unable to send through: " + address.String()) + address := ParseSendThough(c.SendThrough) + //Check if CIDR exists + if strings.Contains(*c.SendThrough, "/") { + senderSettings.ViaCidr = strings.Split(*c.SendThrough, "/")[1] + } else { + if address.Family().IsDomain() { + return nil, newError("unable to send through: " + address.String()) + } } senderSettings.Via = address.Build() } @@ -397,19 +403,19 @@ type Config struct { // and should not be used. OutboundDetours []OutboundDetourConfig `json:"outboundDetour"` - LogConfig *LogConfig `json:"log"` - RouterConfig *RouterConfig `json:"routing"` - DNSConfig *DNSConfig `json:"dns"` - InboundConfigs []InboundDetourConfig `json:"inbounds"` - OutboundConfigs []OutboundDetourConfig `json:"outbounds"` - Transport *TransportConfig `json:"transport"` - Policy *PolicyConfig `json:"policy"` - API *APIConfig `json:"api"` - Metrics *MetricsConfig `json:"metrics"` - Stats *StatsConfig `json:"stats"` - Reverse *ReverseConfig `json:"reverse"` - FakeDNS *FakeDNSConfig `json:"fakeDns"` - Observatory *ObservatoryConfig `json:"observatory"` + LogConfig *LogConfig `json:"log"` + RouterConfig *RouterConfig `json:"routing"` + DNSConfig *DNSConfig `json:"dns"` + InboundConfigs []InboundDetourConfig `json:"inbounds"` + OutboundConfigs []OutboundDetourConfig `json:"outbounds"` + Transport *TransportConfig `json:"transport"` + Policy *PolicyConfig `json:"policy"` + API *APIConfig `json:"api"` + Metrics *MetricsConfig `json:"metrics"` + Stats *StatsConfig `json:"stats"` + Reverse *ReverseConfig `json:"reverse"` + FakeDNS *FakeDNSConfig `json:"fakeDns"` + Observatory *ObservatoryConfig `json:"observatory"` BurstObservatory *BurstObservatoryConfig `json:"burstObservatory"` } @@ -717,3 +723,10 @@ func (c *Config) Build() (*core.Config, error) { return config, nil } + +// Convert string to Address. +func ParseSendThough(Addr *string) *Address { + var addr Address + addr.Address = net.ParseAddress(strings.Split(*Addr, "/")[0]) + return &addr +} From 2cafb3ef89990e3b1088d6b0a3ce16d7c924a78c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=82=BB?= <123655015+chise0713@users.noreply.github.com> Date: Sun, 24 Mar 2024 01:34:51 +0800 Subject: [PATCH 316/867] Fix(httpupgrade): `X-Forwarded-For` header not read. (#3172) --- transport/internet/httpupgrade/connection.go | 19 +++++++++++++++++++ transport/internet/httpupgrade/hub.go | 15 +++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 transport/internet/httpupgrade/connection.go diff --git a/transport/internet/httpupgrade/connection.go b/transport/internet/httpupgrade/connection.go new file mode 100644 index 00000000..c7a33af9 --- /dev/null +++ b/transport/internet/httpupgrade/connection.go @@ -0,0 +1,19 @@ +package httpupgrade + +import "net" + +type connnection struct { + net.Conn + remoteAddr net.Addr +} + +func newConnection(conn net.Conn, remoteAddr net.Addr) *connnection { + return &connnection{ + Conn: conn, + remoteAddr: remoteAddr, + } +} + +func (c *connnection) RemoteAddr() net.Addr { + return c.remoteAddr +} diff --git a/transport/internet/httpupgrade/hub.go b/transport/internet/httpupgrade/hub.go index f87d020f..f78f8442 100644 --- a/transport/internet/httpupgrade/hub.go +++ b/transport/internet/httpupgrade/hub.go @@ -9,6 +9,7 @@ import ( "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" + http_proto "github.com/xtls/xray-core/common/protocol/http" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/stat" @@ -68,6 +69,20 @@ func (s *server) Handle(conn net.Conn) (stat.Connection, error) { _ = conn.Close() return nil, err } + + forwardedAddrs := http_proto.ParseXForwardedFor(req.Header) + remoteAddr := conn.RemoteAddr() + if len(forwardedAddrs) > 0 && forwardedAddrs[0].Family().IsIP() { + remoteAddr = &net.TCPAddr{ + IP: forwardedAddrs[0].IP(), + Port: int(0), + } + } + if remoteAddr == nil { + return nil, newError("remoteAddr is nil") + } + + conn = newConnection(conn, remoteAddr) return stat.Connection(conn), nil } From bd385789784f3fa1dff5fbac6c221bb7cf14a86e Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Fri, 22 Mar 2024 16:11:14 +0400 Subject: [PATCH 317/867] improve balancer_info.go fix balancer args --- main/commands/all/api/balancer_info.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/main/commands/all/api/balancer_info.go b/main/commands/all/api/balancer_info.go index 4ba33236..0d376d63 100644 --- a/main/commands/all/api/balancer_info.go +++ b/main/commands/all/api/balancer_info.go @@ -43,12 +43,16 @@ Example: func executeBalancerInfo(cmd *base.Command, args []string) { setSharedFlags(cmd) cmd.Flag.Parse(args) + unnamedArgs := cmd.Flag.Args() + if len(unnamedArgs) == 0 { + fmt.Println("set balancer tag") + unnamedArgs = []string{""} + } conn, ctx, close := dialAPIServer() defer close() - client := routerService.NewRoutingServiceClient(conn) - r := &routerService.GetBalancerInfoRequest{Tag: args[0]} + r := &routerService.GetBalancerInfoRequest{Tag: unnamedArgs[0]} resp, err := client.GetBalancerInfo(ctx, r) if err != nil { base.Fatalf("failed to get health information: %s", err) @@ -75,9 +79,10 @@ func showBalancerInfo(b *routerService.BalancerMsg) { } // Selects sb.WriteString(" - Selects:\n") - - for i, o := range b.PrincipleTarget.Tag { - writeRow(sb, tableIndent, i+1, []string{o}, nil) + if b.PrincipleTarget != nil { + for i, o := range b.PrincipleTarget.Tag { + writeRow(sb, tableIndent, i+1, []string{o}, nil) + } } os.Stdout.WriteString(sb.String()) } From 9a619f9e7c5d92867b248f6bba55c35cbff7dfdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= <45535409+Fangliding@users.noreply.github.com> Date: Sat, 23 Mar 2024 17:43:07 +0000 Subject: [PATCH 318/867] Add support for HTTPupgrade custom headers --- infra/conf/transport_internet.go | 2 + transport/internet/httpupgrade/config.pb.go | 79 +++++++++++++-------- transport/internet/httpupgrade/config.proto | 1 + transport/internet/httpupgrade/dialer.go | 3 + 4 files changed, 55 insertions(+), 30 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 96b458ed..3feb7347 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -183,6 +183,7 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { type HttpUpgradeConfig struct { Path string `json:"path"` Host string `json:"host"` + Headers map[string]string `json:"headers"` AcceptProxyProtocol bool `json:"acceptProxyProtocol"` } @@ -202,6 +203,7 @@ func (c *HttpUpgradeConfig) Build() (proto.Message, error) { config := &httpupgrade.Config{ Path: path, Host: c.Host, + Header: c.Headers, AcceptProxyProtocol: c.AcceptProxyProtocol, Ed: ed, } diff --git a/transport/internet/httpupgrade/config.pb.go b/transport/internet/httpupgrade/config.pb.go index edd4e753..e265b092 100644 --- a/transport/internet/httpupgrade/config.pb.go +++ b/transport/internet/httpupgrade/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 -// protoc v4.23.1 +// protoc v5.26.0 // source: transport/internet/httpupgrade/config.proto package httpupgrade @@ -25,10 +25,11 @@ type Config struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` - AcceptProxyProtocol bool `protobuf:"varint,4,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` - Ed uint32 `protobuf:"varint,5,opt,name=ed,proto3" json:"ed,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` + Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` + AcceptProxyProtocol bool `protobuf:"varint,4,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` + Ed uint32 `protobuf:"varint,5,opt,name=ed,proto3" json:"ed,omitempty"` + Header map[string]string `protobuf:"bytes,6,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (x *Config) Reset() { @@ -91,6 +92,13 @@ func (x *Config) GetEd() uint32 { return 0 } +func (x *Config) GetHeader() map[string]string { + if x != nil { + return x.Header + } + return nil +} + var File_transport_internet_httpupgrade_config_proto protoreflect.FileDescriptor var file_transport_internet_httpupgrade_config_proto_rawDesc = []byte{ @@ -99,24 +107,33 @@ var file_transport_internet_httpupgrade_config_proto_rawDesc = []byte{ 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x23, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, - 0x64, 0x65, 0x22, 0x7a, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, - 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, - 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x68, 0x6f, 0x73, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, - 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x65, 0x64, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x65, 0x64, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x42, 0x8b, - 0x01, 0x0a, 0x27, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, - 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, - 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x75, - 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0xaa, 0x02, 0x23, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x48, 0x74, 0x74, 0x70, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x65, 0x22, 0x86, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, + 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, + 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x65, 0x64, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x65, 0x64, 0x12, 0x4f, 0x0a, 0x06, 0x68, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, + 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x42, 0x8b, 0x01, 0x0a, 0x27, + 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, + 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, + 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, + 0x61, 0x64, 0x65, 0xaa, 0x02, 0x23, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x48, 0x74, + 0x74, 0x70, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -131,16 +148,18 @@ func file_transport_internet_httpupgrade_config_proto_rawDescGZIP() []byte { return file_transport_internet_httpupgrade_config_proto_rawDescData } -var file_transport_internet_httpupgrade_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_transport_internet_httpupgrade_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_transport_internet_httpupgrade_config_proto_goTypes = []interface{}{ (*Config)(nil), // 0: xray.transport.internet.httpupgrade.Config + nil, // 1: xray.transport.internet.httpupgrade.Config.HeaderEntry } var file_transport_internet_httpupgrade_config_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: xray.transport.internet.httpupgrade.Config.header:type_name -> xray.transport.internet.httpupgrade.Config.HeaderEntry + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_transport_internet_httpupgrade_config_proto_init() } @@ -168,7 +187,7 @@ func file_transport_internet_httpupgrade_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_transport_internet_httpupgrade_config_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/transport/internet/httpupgrade/config.proto b/transport/internet/httpupgrade/config.proto index c1874c9e..33d8c054 100644 --- a/transport/internet/httpupgrade/config.proto +++ b/transport/internet/httpupgrade/config.proto @@ -15,4 +15,5 @@ message Config { bool accept_proxy_protocol = 4; uint32 ed = 5; + map header = 6; } diff --git a/transport/internet/httpupgrade/dialer.go b/transport/internet/httpupgrade/dialer.go index 691f85a8..b54af9a6 100644 --- a/transport/internet/httpupgrade/dialer.go +++ b/transport/internet/httpupgrade/dialer.go @@ -73,6 +73,9 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings * Host: transportConfiguration.Host, Header: make(http.Header), } + for key, value := range transportConfiguration.Header { + req.Header.Add(key, value) + } req.Header.Set("Connection", "upgrade") req.Header.Set("Upgrade", "websocket") From fac383672c5dc68fd6067ef30cfa036ffe6cc71e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 00:22:43 +0000 Subject: [PATCH 319/867] Bump github.com/sagernet/sing from 0.3.6 to 0.3.8 Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.3.6 to 0.3.8. - [Commits](https://github.com/sagernet/sing/compare/v0.3.6...v0.3.8) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ac01776e..1e13ef54 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.42.0 github.com/refraction-networking/utls v1.6.3 - github.com/sagernet/sing v0.3.6 + github.com/sagernet/sing v0.3.8 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index 59753582..9da6b4ae 100644 --- a/go.sum +++ b/go.sum @@ -119,8 +119,8 @@ github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/sagernet/sing v0.3.6 h1:dsEdYLKBQlrxUfw1a92x0VdPvR1/BOxQ+HIMyaoEJsQ= -github.com/sagernet/sing v0.3.6/go.mod h1:+60H3Cm91RnL9dpVGWDPHt0zTQImO9Vfqt9a4rSambI= +github.com/sagernet/sing v0.3.8 h1:gm4JKalPhydMYX2zFOTnnd4TXtM/16WFRqSjMepYQQk= +github.com/sagernet/sing v0.3.8/go.mod h1:+60H3Cm91RnL9dpVGWDPHt0zTQImO9Vfqt9a4rSambI= github.com/sagernet/sing-shadowsocks v0.2.6 h1:xr7ylAS/q1cQYS8oxKKajhuQcchd5VJJ4K4UZrrpp0s= github.com/sagernet/sing-shadowsocks v0.2.6/go.mod h1:j2YZBIpWIuElPFL/5sJAj470bcn/3QQ5lxZUNKLDNAM= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= From e2439c04834f19269a1daa8feb849dc358ae65e2 Mon Sep 17 00:00:00 2001 From: lelemka0 <20322043+lelemka0@users.noreply.github.com> Date: Sat, 23 Mar 2024 21:25:18 +0800 Subject: [PATCH 320/867] fix: config `burstObservatory` override --- infra/conf/xray.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 645da473..e48e04b2 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -481,6 +481,10 @@ func (c *Config) Override(o *Config, fn string) { c.Observatory = o.Observatory } + if o.BurstObservatory != nil { + c.BurstObservatory = o.BurstObservatory + } + // deprecated attrs... keep them for now if o.InboundConfig != nil { c.InboundConfig = o.InboundConfig From 8a439bf3f2ed8a6898dc3dbb1ab03fa99ce38809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Wed, 27 Mar 2024 21:06:56 +0800 Subject: [PATCH 321/867] Fix host in headers field does not work XTLS#3191 --- infra/conf/transport_internet.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 3feb7347..22e749d7 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -181,10 +181,10 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { } type HttpUpgradeConfig struct { - Path string `json:"path"` - Host string `json:"host"` + Path string `json:"path"` + Host string `json:"host"` Headers map[string]string `json:"headers"` - AcceptProxyProtocol bool `json:"acceptProxyProtocol"` + AcceptProxyProtocol bool `json:"acceptProxyProtocol"` } // Build implements Buildable. @@ -200,6 +200,14 @@ func (c *HttpUpgradeConfig) Build() (proto.Message, error) { path = u.String() } } + // If http host is not set in the Host field, but in headers field, we add it to Host Field here. + // If we don't do that, http host will be overwritten as address. + // Host priority: Host field > headers field > address. + if c.Host == "" && c.Headers["host"] != "" { + c.Host = c.Headers["host"] + } else if c.Host == "" && c.Headers["Host"] != "" { + c.Host = c.Headers["Host"] + } config := &httpupgrade.Config{ Path: path, Host: c.Host, From 53e5814d19fb2e331c4cd8658558a476395d312c Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Fri, 29 Mar 2024 19:17:36 +0400 Subject: [PATCH 322/867] API - Add | Remove Routing Rules (#3189) * add RuleTag to routing rules * add router pb commands * add and remove routing rules api * cleanup * fix * improve error msg * add append flag apply balancer config --- app/router/command/command.go | 14 + app/router/command/command.pb.go | 546 +++++++++++++++++++------- app/router/command/command.proto | 16 + app/router/command/command_grpc.pb.go | 97 ++++- app/router/config.go | 5 +- app/router/config.pb.go | 230 +++++------ app/router/config.proto | 1 + app/router/router.go | 101 +++++ features/routing/router.go | 13 + infra/conf/router.go | 2 + main/commands/all/api/api.go | 2 + main/commands/all/api/rules_add.go | 88 +++++ main/commands/all/api/rules_remove.go | 55 +++ 13 files changed, 901 insertions(+), 269 deletions(-) create mode 100644 main/commands/all/api/rules_add.go create mode 100644 main/commands/all/api/rules_remove.go diff --git a/app/router/command/command.go b/app/router/command/command.go index 60458f14..520b9a30 100644 --- a/app/router/command/command.go +++ b/app/router/command/command.go @@ -54,6 +54,20 @@ func (s *routingServer) OverrideBalancerTarget(ctx context.Context, request *Ove return nil, newError("unsupported router implementation") } +func (s *routingServer) AddRule(ctx context.Context, request *AddRuleRequest) (*AddRuleResponse, error) { + if bo, ok := s.router.(routing.Router); ok { + return &AddRuleResponse{}, bo.AddRule(request.Config, request.ShouldAppend) + } + return nil, newError("unsupported router implementation") + +} +func (s *routingServer) RemoveRule(ctx context.Context, request *RemoveRuleRequest) (*RemoveRuleResponse, error) { + if bo, ok := s.router.(routing.Router); ok { + return &RemoveRuleResponse{}, bo.RemoveRule(request.RuleTag) + } + return nil, newError("unsupported router implementation") +} + // NewRoutingServer creates a statistics service with statistics manager. func NewRoutingServer(router routing.Router, routingStats stats.Channel) RoutingServiceServer { return &routingServer{ diff --git a/app/router/command/command.pb.go b/app/router/command/command.pb.go index 0c0be90b..f6728990 100644 --- a/app/router/command/command.pb.go +++ b/app/router/command/command.pb.go @@ -1,13 +1,14 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 -// protoc v4.23.1 +// protoc-gen-go v1.28.1 +// protoc v4.25.3 // source: app/router/command/command.proto package command import ( net "github.com/xtls/xray-core/common/net" + serial "github.com/xtls/xray-core/common/serial" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -630,6 +631,184 @@ func (*OverrideBalancerTargetResponse) Descriptor() ([]byte, []int) { return file_app_router_command_command_proto_rawDescGZIP(), []int{9} } +type AddRuleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Config *serial.TypedMessage `protobuf:"bytes,1,opt,name=config,proto3" json:"config,omitempty"` + ShouldAppend bool `protobuf:"varint,2,opt,name=shouldAppend,proto3" json:"shouldAppend,omitempty"` +} + +func (x *AddRuleRequest) Reset() { + *x = AddRuleRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddRuleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddRuleRequest) ProtoMessage() {} + +func (x *AddRuleRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddRuleRequest.ProtoReflect.Descriptor instead. +func (*AddRuleRequest) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{10} +} + +func (x *AddRuleRequest) GetConfig() *serial.TypedMessage { + if x != nil { + return x.Config + } + return nil +} + +func (x *AddRuleRequest) GetShouldAppend() bool { + if x != nil { + return x.ShouldAppend + } + return false +} + +type AddRuleResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *AddRuleResponse) Reset() { + *x = AddRuleResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddRuleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddRuleResponse) ProtoMessage() {} + +func (x *AddRuleResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddRuleResponse.ProtoReflect.Descriptor instead. +func (*AddRuleResponse) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{11} +} + +type RemoveRuleRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + RuleTag string `protobuf:"bytes,1,opt,name=ruleTag,proto3" json:"ruleTag,omitempty"` +} + +func (x *RemoveRuleRequest) Reset() { + *x = RemoveRuleRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RemoveRuleRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveRuleRequest) ProtoMessage() {} + +func (x *RemoveRuleRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveRuleRequest.ProtoReflect.Descriptor instead. +func (*RemoveRuleRequest) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{12} +} + +func (x *RemoveRuleRequest) GetRuleTag() string { + if x != nil { + return x.RuleTag + } + return "" +} + +type RemoveRuleResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *RemoveRuleResponse) Reset() { + *x = RemoveRuleResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_app_router_command_command_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RemoveRuleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RemoveRuleResponse) ProtoMessage() {} + +func (x *RemoveRuleResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_router_command_command_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RemoveRuleResponse.ProtoReflect.Descriptor instead. +func (*RemoveRuleResponse) Descriptor() ([]byte, []int) { + return file_app_router_command_command_proto_rawDescGZIP(), []int{13} +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -639,7 +818,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[10] + mi := &file_app_router_command_command_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -652,7 +831,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_app_router_command_command_proto_msgTypes[10] + mi := &file_app_router_command_command_proto_msgTypes[14] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -665,7 +844,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_app_router_command_command_proto_rawDescGZIP(), []int{10} + return file_app_router_command_command_proto_rawDescGZIP(), []int{14} } var File_app_router_command_command_proto protoreflect.FileDescriptor @@ -676,128 +855,155 @@ var file_app_router_command_command_proto_rawDesc = []byte{ 0x74, 0x6f, 0x12, 0x17, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9c, 0x04, 0x0a, 0x0e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, - 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x49, 0x6e, 0x62, 0x6f, - 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x49, 0x6e, - 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x12, 0x32, 0x0a, 0x07, 0x4e, 0x65, 0x74, 0x77, - 0x6f, 0x72, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, - 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x1c, 0x0a, 0x09, - 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x50, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, - 0x09, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x50, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x54, 0x61, - 0x72, 0x67, 0x65, 0x74, 0x49, 0x50, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x09, 0x54, - 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x50, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x53, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x53, 0x6f, - 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x61, 0x72, 0x67, - 0x65, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x54, 0x61, - 0x72, 0x67, 0x65, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x54, 0x61, 0x72, 0x67, - 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x1a, 0x0a, 0x08, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x57, 0x0a, 0x0a, - 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x37, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, - 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, - 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x41, 0x74, 0x74, 0x72, 0x69, - 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, - 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x54, 0x61, 0x67, 0x73, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x11, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x54, - 0x61, 0x67, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, - 0x61, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, - 0x6e, 0x64, 0x54, 0x61, 0x67, 0x1a, 0x3d, 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x22, 0x46, 0x0a, 0x1c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, - 0x65, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x53, 0x65, 0x6c, - 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x46, 0x69, - 0x65, 0x6c, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x22, 0xb1, 0x01, 0x0a, - 0x10, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x4f, 0x0a, 0x0e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, - 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x78, 0x74, 0x52, 0x0e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x78, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, - 0x74, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x46, 0x69, 0x65, 0x6c, - 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x50, 0x75, - 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x22, 0x27, 0x0a, 0x13, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x6c, 0x65, 0x54, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x26, 0x0a, 0x0c, 0x4f, 0x76, 0x65, - 0x72, 0x72, 0x69, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, - 0x74, 0x22, 0xa9, 0x01, 0x0a, 0x0b, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x4d, 0x73, - 0x67, 0x12, 0x41, 0x0a, 0x08, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, - 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4f, 0x76, - 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6f, 0x76, 0x65, 0x72, - 0x72, 0x69, 0x64, 0x65, 0x12, 0x57, 0x0a, 0x10, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x6c, - 0x65, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, - 0x6c, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0f, 0x70, 0x72, - 0x69, 0x6e, 0x63, 0x69, 0x70, 0x6c, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0x2a, 0x0a, - 0x16, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x5b, 0x0a, 0x17, 0x47, 0x65, 0x74, - 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x21, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x73, 0x65, + 0x72, 0x69, 0x61, 0x6c, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9c, 0x04, 0x0a, 0x0e, 0x52, 0x6f, 0x75, + 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x49, + 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x12, 0x32, 0x0a, 0x07, 0x4e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, + 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, + 0x1c, 0x0a, 0x09, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x50, 0x73, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0c, 0x52, 0x09, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x49, 0x50, 0x73, 0x12, 0x1c, 0x0a, + 0x09, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x50, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0c, + 0x52, 0x09, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x50, 0x73, 0x12, 0x1e, 0x0a, 0x0a, 0x53, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x0a, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x0a, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x54, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, + 0x1a, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x08, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x55, + 0x73, 0x65, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, + 0x57, 0x0a, 0x0a, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0a, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, + 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, + 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x2e, 0x41, 0x74, 0x74, + 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x41, 0x74, + 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x2c, 0x0a, 0x11, 0x4f, 0x75, 0x74, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x54, 0x61, 0x67, 0x73, 0x18, 0x0b, 0x20, + 0x03, 0x28, 0x09, 0x52, 0x11, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x54, 0x61, 0x67, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x54, 0x61, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x4f, 0x75, 0x74, + 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x1a, 0x3d, 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x72, + 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x46, 0x0a, 0x1c, 0x53, 0x75, 0x62, 0x73, 0x63, + 0x72, 0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x73, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x46, 0x69, 0x65, 0x6c, 0x64, + 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x0e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x22, + 0xb1, 0x01, 0x0a, 0x10, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x4f, 0x0a, 0x0e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x74, 0x52, 0x0e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x74, 0x12, 0x26, 0x0a, 0x0e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x53, 0x65, + 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x46, + 0x69, 0x65, 0x6c, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x24, 0x0a, + 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x52, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x22, 0x27, 0x0a, 0x13, 0x50, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x6c, 0x65, + 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, + 0x67, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x26, 0x0a, 0x0c, + 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x16, 0x0a, 0x06, + 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x22, 0xa9, 0x01, 0x0a, 0x0b, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, + 0x72, 0x4d, 0x73, 0x67, 0x12, 0x41, 0x0a, 0x08, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x4d, 0x73, 0x67, 0x52, 0x08, 0x62, 0x61, - 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x22, 0x59, 0x0a, 0x1d, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, - 0x64, 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x61, 0x6c, 0x61, 0x6e, - 0x63, 0x65, 0x72, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x62, 0x61, - 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, - 0x74, 0x22, 0x20, 0x0a, 0x1e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x42, 0x61, 0x6c, - 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xf6, 0x03, - 0x0a, 0x0e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x12, 0x7b, 0x0a, 0x15, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, - 0x74, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x35, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6f, + 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x12, 0x57, 0x0a, 0x10, 0x70, 0x72, 0x69, 0x6e, 0x63, + 0x69, 0x70, 0x6c, 0x65, 0x5f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, + 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x50, 0x72, 0x69, 0x6e, + 0x63, 0x69, 0x70, 0x6c, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x0f, 0x70, 0x72, 0x69, 0x6e, 0x63, 0x69, 0x70, 0x6c, 0x65, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x22, 0x2a, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, + 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x5b, 0x0a, 0x17, + 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x40, 0x0a, 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, + 0x63, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, - 0x74, 0x69, 0x6e, 0x67, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x61, 0x6e, 0x64, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x4d, 0x73, 0x67, 0x52, + 0x08, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x22, 0x59, 0x0a, 0x1d, 0x4f, 0x76, 0x65, + 0x72, 0x72, 0x69, 0x64, 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0b, 0x62, 0x61, + 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0b, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x67, 0x12, 0x16, 0x0a, 0x06, + 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x22, 0x20, 0x0a, 0x1e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, + 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x6e, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x52, 0x75, 0x6c, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x38, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, + 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, 0x41, 0x70, 0x70, 0x65, + 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x68, 0x6f, 0x75, 0x6c, 0x64, + 0x41, 0x70, 0x70, 0x65, 0x6e, 0x64, 0x22, 0x11, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x52, 0x75, 0x6c, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x0a, 0x11, 0x52, 0x65, 0x6d, + 0x6f, 0x76, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, + 0x0a, 0x07, 0x72, 0x75, 0x6c, 0x65, 0x54, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x72, 0x75, 0x6c, 0x65, 0x54, 0x61, 0x67, 0x22, 0x14, 0x0a, 0x12, 0x52, 0x65, 0x6d, 0x6f, + 0x76, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x08, + 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xbf, 0x05, 0x0a, 0x0e, 0x52, 0x6f, 0x75, + 0x74, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x7b, 0x0a, 0x15, 0x53, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x53, + 0x74, 0x61, 0x74, 0x73, 0x12, 0x35, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x53, + 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x78, 0x74, 0x22, 0x00, 0x30, 0x01, 0x12, 0x61, 0x0a, 0x09, 0x54, 0x65, 0x73, 0x74, + 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, + 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, - 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x00, 0x30, 0x01, 0x12, 0x61, 0x0a, - 0x09, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x12, 0x29, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x54, 0x65, 0x73, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x00, 0x12, 0x76, 0x0a, 0x0f, 0x47, + 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x2f, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, + 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, + 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, + 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x00, 0x12, 0x8b, 0x01, 0x0a, 0x16, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, + 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x36, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, + 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, + 0x72, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x5e, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x27, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, - 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, 0x22, 0x00, - 0x12, 0x76, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, - 0x6e, 0x66, 0x6f, 0x12, 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, - 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, - 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, - 0x65, 0x74, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x8b, 0x01, 0x0a, 0x16, 0x4f, 0x76, 0x65, - 0x72, 0x72, 0x69, 0x64, 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x12, 0x36, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, - 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4f, 0x76, - 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, - 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x78, 0x72, + 0x41, 0x64, 0x64, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x67, 0x0a, 0x0a, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x75, 0x6c, 0x65, 0x12, + 0x2a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, + 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x52, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x42, 0x61, - 0x6c, 0x61, 0x6e, 0x63, 0x65, 0x72, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, - 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, - 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x52, 0x75, 0x6c, 0x65, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, + 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, + 0x72, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, + 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, + 0x72, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, + 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -812,7 +1018,7 @@ func file_app_router_command_command_proto_rawDescGZIP() []byte { return file_app_router_command_command_proto_rawDescData } -var file_app_router_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_app_router_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_app_router_command_command_proto_goTypes = []interface{}{ (*RoutingContext)(nil), // 0: xray.app.router.command.RoutingContext (*SubscribeRoutingStatsRequest)(nil), // 1: xray.app.router.command.SubscribeRoutingStatsRequest @@ -824,30 +1030,40 @@ var file_app_router_command_command_proto_goTypes = []interface{}{ (*GetBalancerInfoResponse)(nil), // 7: xray.app.router.command.GetBalancerInfoResponse (*OverrideBalancerTargetRequest)(nil), // 8: xray.app.router.command.OverrideBalancerTargetRequest (*OverrideBalancerTargetResponse)(nil), // 9: xray.app.router.command.OverrideBalancerTargetResponse - (*Config)(nil), // 10: xray.app.router.command.Config - nil, // 11: xray.app.router.command.RoutingContext.AttributesEntry - (net.Network)(0), // 12: xray.common.net.Network + (*AddRuleRequest)(nil), // 10: xray.app.router.command.AddRuleRequest + (*AddRuleResponse)(nil), // 11: xray.app.router.command.AddRuleResponse + (*RemoveRuleRequest)(nil), // 12: xray.app.router.command.RemoveRuleRequest + (*RemoveRuleResponse)(nil), // 13: xray.app.router.command.RemoveRuleResponse + (*Config)(nil), // 14: xray.app.router.command.Config + nil, // 15: xray.app.router.command.RoutingContext.AttributesEntry + (net.Network)(0), // 16: xray.common.net.Network + (*serial.TypedMessage)(nil), // 17: xray.common.serial.TypedMessage } var file_app_router_command_command_proto_depIdxs = []int32{ - 12, // 0: xray.app.router.command.RoutingContext.Network:type_name -> xray.common.net.Network - 11, // 1: xray.app.router.command.RoutingContext.Attributes:type_name -> xray.app.router.command.RoutingContext.AttributesEntry + 16, // 0: xray.app.router.command.RoutingContext.Network:type_name -> xray.common.net.Network + 15, // 1: xray.app.router.command.RoutingContext.Attributes:type_name -> xray.app.router.command.RoutingContext.AttributesEntry 0, // 2: xray.app.router.command.TestRouteRequest.RoutingContext:type_name -> xray.app.router.command.RoutingContext 4, // 3: xray.app.router.command.BalancerMsg.override:type_name -> xray.app.router.command.OverrideInfo 3, // 4: xray.app.router.command.BalancerMsg.principle_target:type_name -> xray.app.router.command.PrincipleTargetInfo 5, // 5: xray.app.router.command.GetBalancerInfoResponse.balancer:type_name -> xray.app.router.command.BalancerMsg - 1, // 6: xray.app.router.command.RoutingService.SubscribeRoutingStats:input_type -> xray.app.router.command.SubscribeRoutingStatsRequest - 2, // 7: xray.app.router.command.RoutingService.TestRoute:input_type -> xray.app.router.command.TestRouteRequest - 6, // 8: xray.app.router.command.RoutingService.GetBalancerInfo:input_type -> xray.app.router.command.GetBalancerInfoRequest - 8, // 9: xray.app.router.command.RoutingService.OverrideBalancerTarget:input_type -> xray.app.router.command.OverrideBalancerTargetRequest - 0, // 10: xray.app.router.command.RoutingService.SubscribeRoutingStats:output_type -> xray.app.router.command.RoutingContext - 0, // 11: xray.app.router.command.RoutingService.TestRoute:output_type -> xray.app.router.command.RoutingContext - 7, // 12: xray.app.router.command.RoutingService.GetBalancerInfo:output_type -> xray.app.router.command.GetBalancerInfoResponse - 9, // 13: xray.app.router.command.RoutingService.OverrideBalancerTarget:output_type -> xray.app.router.command.OverrideBalancerTargetResponse - 10, // [10:14] is the sub-list for method output_type - 6, // [6:10] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 17, // 6: xray.app.router.command.AddRuleRequest.config:type_name -> xray.common.serial.TypedMessage + 1, // 7: xray.app.router.command.RoutingService.SubscribeRoutingStats:input_type -> xray.app.router.command.SubscribeRoutingStatsRequest + 2, // 8: xray.app.router.command.RoutingService.TestRoute:input_type -> xray.app.router.command.TestRouteRequest + 6, // 9: xray.app.router.command.RoutingService.GetBalancerInfo:input_type -> xray.app.router.command.GetBalancerInfoRequest + 8, // 10: xray.app.router.command.RoutingService.OverrideBalancerTarget:input_type -> xray.app.router.command.OverrideBalancerTargetRequest + 10, // 11: xray.app.router.command.RoutingService.AddRule:input_type -> xray.app.router.command.AddRuleRequest + 12, // 12: xray.app.router.command.RoutingService.RemoveRule:input_type -> xray.app.router.command.RemoveRuleRequest + 0, // 13: xray.app.router.command.RoutingService.SubscribeRoutingStats:output_type -> xray.app.router.command.RoutingContext + 0, // 14: xray.app.router.command.RoutingService.TestRoute:output_type -> xray.app.router.command.RoutingContext + 7, // 15: xray.app.router.command.RoutingService.GetBalancerInfo:output_type -> xray.app.router.command.GetBalancerInfoResponse + 9, // 16: xray.app.router.command.RoutingService.OverrideBalancerTarget:output_type -> xray.app.router.command.OverrideBalancerTargetResponse + 11, // 17: xray.app.router.command.RoutingService.AddRule:output_type -> xray.app.router.command.AddRuleResponse + 13, // 18: xray.app.router.command.RoutingService.RemoveRule:output_type -> xray.app.router.command.RemoveRuleResponse + 13, // [13:19] is the sub-list for method output_type + 7, // [7:13] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_app_router_command_command_proto_init() } @@ -977,6 +1193,54 @@ func file_app_router_command_command_proto_init() { } } file_app_router_command_command_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddRuleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddRuleResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RemoveRuleRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RemoveRuleResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_router_command_command_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Config); i { case 0: return &v.state @@ -995,7 +1259,7 @@ func file_app_router_command_command_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_router_command_command_proto_rawDesc, NumEnums: 0, - NumMessages: 12, + NumMessages: 16, NumExtensions: 0, NumServices: 1, }, diff --git a/app/router/command/command.proto b/app/router/command/command.proto index ebf8610e..756f8226 100644 --- a/app/router/command/command.proto +++ b/app/router/command/command.proto @@ -7,6 +7,7 @@ option java_package = "com.xray.app.router.command"; option java_multiple_files = true; import "common/net/network.proto"; +import "common/serial/typed_message.proto"; // RoutingContext is the context with information relative to routing process. // It conforms to the structure of xray.features.routing.Context and @@ -88,6 +89,18 @@ message OverrideBalancerTargetRequest { message OverrideBalancerTargetResponse {} +message AddRuleRequest { + xray.common.serial.TypedMessage config = 1; + bool shouldAppend = 2; +} +message AddRuleResponse {} + +message RemoveRuleRequest { + string ruleTag = 1; +} + +message RemoveRuleResponse {} + service RoutingService { rpc SubscribeRoutingStats(SubscribeRoutingStatsRequest) returns (stream RoutingContext) {} @@ -95,6 +108,9 @@ service RoutingService { rpc GetBalancerInfo(GetBalancerInfoRequest) returns (GetBalancerInfoResponse){} rpc OverrideBalancerTarget(OverrideBalancerTargetRequest) returns (OverrideBalancerTargetResponse) {} + + rpc AddRule(AddRuleRequest) returns (AddRuleResponse) {} + rpc RemoveRule(RemoveRuleRequest) returns (RemoveRuleResponse) {} } message Config {} diff --git a/app/router/command/command_grpc.pb.go b/app/router/command/command_grpc.pb.go index 5710ec2b..716edec4 100644 --- a/app/router/command/command_grpc.pb.go +++ b/app/router/command/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v4.23.1 +// - protoc-gen-go-grpc v1.2.0 +// - protoc v4.25.3 // source: app/router/command/command.proto package command @@ -18,13 +18,6 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -const ( - RoutingService_SubscribeRoutingStats_FullMethodName = "/xray.app.router.command.RoutingService/SubscribeRoutingStats" - RoutingService_TestRoute_FullMethodName = "/xray.app.router.command.RoutingService/TestRoute" - RoutingService_GetBalancerInfo_FullMethodName = "/xray.app.router.command.RoutingService/GetBalancerInfo" - RoutingService_OverrideBalancerTarget_FullMethodName = "/xray.app.router.command.RoutingService/OverrideBalancerTarget" -) - // RoutingServiceClient is the client API for RoutingService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -33,6 +26,8 @@ type RoutingServiceClient interface { TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error) GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error) OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error) + AddRule(ctx context.Context, in *AddRuleRequest, opts ...grpc.CallOption) (*AddRuleResponse, error) + RemoveRule(ctx context.Context, in *RemoveRuleRequest, opts ...grpc.CallOption) (*RemoveRuleResponse, error) } type routingServiceClient struct { @@ -44,7 +39,7 @@ func NewRoutingServiceClient(cc grpc.ClientConnInterface) RoutingServiceClient { } func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error) { - stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], RoutingService_SubscribeRoutingStats_FullMethodName, opts...) + stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], "/xray.app.router.command.RoutingService/SubscribeRoutingStats", opts...) if err != nil { return nil, err } @@ -77,7 +72,7 @@ func (x *routingServiceSubscribeRoutingStatsClient) Recv() (*RoutingContext, err func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error) { out := new(RoutingContext) - err := c.cc.Invoke(ctx, RoutingService_TestRoute_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/TestRoute", in, out, opts...) if err != nil { return nil, err } @@ -86,7 +81,7 @@ func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteReque func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error) { out := new(GetBalancerInfoResponse) - err := c.cc.Invoke(ctx, RoutingService_GetBalancerInfo_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/GetBalancerInfo", in, out, opts...) if err != nil { return nil, err } @@ -95,7 +90,25 @@ func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalan func (c *routingServiceClient) OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error) { out := new(OverrideBalancerTargetResponse) - err := c.cc.Invoke(ctx, RoutingService_OverrideBalancerTarget_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/OverrideBalancerTarget", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *routingServiceClient) AddRule(ctx context.Context, in *AddRuleRequest, opts ...grpc.CallOption) (*AddRuleResponse, error) { + out := new(AddRuleResponse) + err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/AddRule", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *routingServiceClient) RemoveRule(ctx context.Context, in *RemoveRuleRequest, opts ...grpc.CallOption) (*RemoveRuleResponse, error) { + out := new(RemoveRuleResponse) + err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/RemoveRule", in, out, opts...) if err != nil { return nil, err } @@ -110,6 +123,8 @@ type RoutingServiceServer interface { TestRoute(context.Context, *TestRouteRequest) (*RoutingContext, error) GetBalancerInfo(context.Context, *GetBalancerInfoRequest) (*GetBalancerInfoResponse, error) OverrideBalancerTarget(context.Context, *OverrideBalancerTargetRequest) (*OverrideBalancerTargetResponse, error) + AddRule(context.Context, *AddRuleRequest) (*AddRuleResponse, error) + RemoveRule(context.Context, *RemoveRuleRequest) (*RemoveRuleResponse, error) mustEmbedUnimplementedRoutingServiceServer() } @@ -129,6 +144,12 @@ func (UnimplementedRoutingServiceServer) GetBalancerInfo(context.Context, *GetBa func (UnimplementedRoutingServiceServer) OverrideBalancerTarget(context.Context, *OverrideBalancerTargetRequest) (*OverrideBalancerTargetResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method OverrideBalancerTarget not implemented") } +func (UnimplementedRoutingServiceServer) AddRule(context.Context, *AddRuleRequest) (*AddRuleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddRule not implemented") +} +func (UnimplementedRoutingServiceServer) RemoveRule(context.Context, *RemoveRuleRequest) (*RemoveRuleResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveRule not implemented") +} func (UnimplementedRoutingServiceServer) mustEmbedUnimplementedRoutingServiceServer() {} // UnsafeRoutingServiceServer may be embedded to opt out of forward compatibility for this service. @@ -173,7 +194,7 @@ func _RoutingService_TestRoute_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: RoutingService_TestRoute_FullMethodName, + FullMethod: "/xray.app.router.command.RoutingService/TestRoute", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoutingServiceServer).TestRoute(ctx, req.(*TestRouteRequest)) @@ -191,7 +212,7 @@ func _RoutingService_GetBalancerInfo_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: RoutingService_GetBalancerInfo_FullMethodName, + FullMethod: "/xray.app.router.command.RoutingService/GetBalancerInfo", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoutingServiceServer).GetBalancerInfo(ctx, req.(*GetBalancerInfoRequest)) @@ -209,7 +230,7 @@ func _RoutingService_OverrideBalancerTarget_Handler(srv interface{}, ctx context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: RoutingService_OverrideBalancerTarget_FullMethodName, + FullMethod: "/xray.app.router.command.RoutingService/OverrideBalancerTarget", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoutingServiceServer).OverrideBalancerTarget(ctx, req.(*OverrideBalancerTargetRequest)) @@ -217,6 +238,42 @@ func _RoutingService_OverrideBalancerTarget_Handler(srv interface{}, ctx context return interceptor(ctx, in, info, handler) } +func _RoutingService_AddRule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddRuleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoutingServiceServer).AddRule(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/xray.app.router.command.RoutingService/AddRule", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoutingServiceServer).AddRule(ctx, req.(*AddRuleRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _RoutingService_RemoveRule_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RemoveRuleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(RoutingServiceServer).RemoveRule(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/xray.app.router.command.RoutingService/RemoveRule", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(RoutingServiceServer).RemoveRule(ctx, req.(*RemoveRuleRequest)) + } + return interceptor(ctx, in, info, handler) +} + // RoutingService_ServiceDesc is the grpc.ServiceDesc for RoutingService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -236,6 +293,14 @@ var RoutingService_ServiceDesc = grpc.ServiceDesc{ MethodName: "OverrideBalancerTarget", Handler: _RoutingService_OverrideBalancerTarget_Handler, }, + { + MethodName: "AddRule", + Handler: _RoutingService_AddRule_Handler, + }, + { + MethodName: "RemoveRule", + Handler: _RoutingService_RemoveRule_Handler, + }, }, Streams: []grpc.StreamDesc{ { diff --git a/app/router/config.go b/app/router/config.go index ce4ed270..690064bd 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -11,6 +11,7 @@ import ( type Rule struct { Tag string + RuleTag string Balancer *Balancer Condition Condition } @@ -150,7 +151,7 @@ func (br *BalancingRule) Build(ohm outbound.Manager, dispatcher routing.Dispatch leastLoadStrategy := NewLeastLoadStrategy(s) return &Balancer{ selectors: br.OutboundSelector, - ohm: ohm, + ohm: ohm, fallbackTag: br.FallbackTag, strategy: leastLoadStrategy, }, nil @@ -159,7 +160,7 @@ func (br *BalancingRule) Build(ohm outbound.Manager, dispatcher routing.Dispatch case "": return &Balancer{ selectors: br.OutboundSelector, - ohm: ohm, + ohm: ohm, fallbackTag: br.FallbackTag, strategy: &RandomStrategy{}, }, nil diff --git a/app/router/config.pb.go b/app/router/config.pb.go index 36459c1c..3ce4b7c1 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 -// protoc v4.23.1 +// protoc v3.21.12 // source: app/router/config.proto package router @@ -482,6 +482,7 @@ type RoutingRule struct { // *RoutingRule_Tag // *RoutingRule_BalancingTag TargetTag isRoutingRule_TargetTag `protobuf_oneof:"target_tag"` + RuleTag string `protobuf:"bytes,18,opt,name=rule_tag,json=ruleTag,proto3" json:"rule_tag,omitempty"` // List of domains for target domain matching. Domain []*Domain `protobuf:"bytes,2,rep,name=domain,proto3" json:"domain,omitempty"` // List of CIDRs for target IP address matching. @@ -576,6 +577,13 @@ func (x *RoutingRule) GetBalancingTag() string { return "" } +func (x *RoutingRule) GetRuleTag() string { + if x != nil { + return x.RuleTag + } + return "" +} + func (x *RoutingRule) GetDomain() []*Domain { if x != nil { return x.Domain @@ -1135,120 +1143,122 @@ var file_app_router_config_proto_rawDesc = []byte{ 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x53, 0x69, - 0x74, 0x65, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0xa2, 0x07, 0x0a, 0x0b, 0x52, 0x6f, + 0x74, 0x65, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0xbd, 0x07, 0x0a, 0x0b, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x25, 0x0a, 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x0c, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, - 0x67, 0x54, 0x61, 0x67, 0x12, 0x2f, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x06, 0x64, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x2d, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, - 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x49, 0x44, 0x52, 0x42, 0x02, 0x18, 0x01, 0x52, 0x04, - 0x63, 0x69, 0x64, 0x72, 0x12, 0x2c, 0x0a, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0a, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, - 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x05, 0x67, 0x65, 0x6f, - 0x69, 0x70, 0x12, 0x3d, 0x0a, 0x0a, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x72, 0x61, 0x6e, 0x67, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, - 0x67, 0x65, 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, 0x67, - 0x65, 0x12, 0x36, 0x0a, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x0e, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, - 0x08, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x6e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, - 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x02, 0x18, - 0x01, 0x52, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x34, - 0x0a, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0e, - 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, - 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x08, 0x6e, 0x65, 0x74, 0x77, - 0x6f, 0x72, 0x6b, 0x73, 0x12, 0x3a, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, - 0x69, 0x64, 0x72, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x49, 0x44, 0x52, - 0x42, 0x02, 0x18, 0x01, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x69, 0x64, 0x72, - 0x12, 0x39, 0x0a, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x67, 0x65, 0x6f, 0x69, 0x70, - 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x0b, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x47, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x43, 0x0a, 0x10, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, - 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, - 0x52, 0x0e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, - 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, - 0x1f, 0x0a, 0x0b, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x08, - 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, - 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x4c, 0x0a, 0x0a, - 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x2c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, - 0x65, 0x72, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x2e, 0x41, - 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, - 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, 0x11, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0d, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, - 0x72, 0x1a, 0x3d, 0x0a, 0x0f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x42, 0x0c, 0x0a, 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x61, 0x67, 0x22, 0xdc, - 0x01, 0x0a, 0x0d, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, - 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, - 0x61, 0x67, 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, - 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x6f, - 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, - 0x1a, 0x0a, 0x08, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x4d, 0x0a, 0x11, 0x73, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, - 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x10, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x61, - 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x66, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x54, 0x0a, - 0x0e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, - 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x06, 0x72, 0x65, 0x67, 0x65, 0x78, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x22, 0xc0, 0x01, 0x0a, 0x17, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, - 0x4c, 0x65, 0x61, 0x73, 0x74, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, - 0x35, 0x0a, 0x05, 0x63, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, + 0x67, 0x54, 0x61, 0x67, 0x12, 0x19, 0x0a, 0x08, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x74, 0x61, 0x67, + 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x75, 0x6c, 0x65, 0x54, 0x61, 0x67, 0x12, + 0x2f, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, + 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x12, 0x2d, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x2e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, - 0x05, 0x63, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x61, 0x73, 0x65, 0x6c, 0x69, - 0x6e, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x09, 0x62, 0x61, 0x73, 0x65, 0x6c, - 0x69, 0x6e, 0x65, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, - 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x61, 0x78, 0x52, 0x54, 0x54, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x06, 0x6d, 0x61, 0x78, 0x52, 0x54, 0x54, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x6f, 0x6c, 0x65, - 0x72, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x74, 0x6f, 0x6c, - 0x65, 0x72, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x9b, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x4f, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x12, 0x30, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, - 0x65, 0x72, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, - 0x72, 0x75, 0x6c, 0x65, 0x12, 0x45, 0x0a, 0x0e, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, - 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x42, - 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x62, 0x61, - 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x47, 0x0a, 0x0e, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, - 0x04, 0x41, 0x73, 0x49, 0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x49, 0x70, - 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x49, 0x70, 0x49, 0x66, 0x4e, 0x6f, 0x6e, 0x4d, 0x61, 0x74, - 0x63, 0x68, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x70, 0x4f, 0x6e, 0x44, 0x65, 0x6d, 0x61, - 0x6e, 0x64, 0x10, 0x03, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x24, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, - 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, - 0x74, 0x65, 0x72, 0xaa, 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, - 0x6f, 0x75, 0x74, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x43, 0x49, 0x44, 0x52, 0x42, 0x02, 0x18, 0x01, 0x52, 0x04, 0x63, 0x69, 0x64, 0x72, 0x12, + 0x2c, 0x0a, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x3d, 0x0a, + 0x0a, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x42, 0x02, 0x18, + 0x01, 0x52, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x09, + 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, + 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x08, 0x70, 0x6f, 0x72, 0x74, + 0x4c, 0x69, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, + 0x6c, 0x69, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0b, 0x6e, 0x65, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x6e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x12, + 0x3a, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x69, 0x64, 0x72, 0x18, 0x06, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x49, 0x44, 0x52, 0x42, 0x02, 0x18, 0x01, 0x52, + 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x69, 0x64, 0x72, 0x12, 0x39, 0x0a, 0x0c, 0x73, + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0b, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, + 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x47, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x43, 0x0a, 0x10, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, + 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x0e, 0x73, 0x6f, 0x75, + 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x09, 0x75, 0x73, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, + 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x0a, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x4c, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, + 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x6f, + 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x2e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, + 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, + 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, + 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x1a, 0x3d, 0x0a, 0x0f, + 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0c, 0x0a, 0x0a, 0x74, + 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x61, 0x67, 0x22, 0xdc, 0x01, 0x0a, 0x0d, 0x42, 0x61, + 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x74, + 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x2b, 0x0a, + 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, + 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x4d, 0x0a, 0x11, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x67, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x52, 0x10, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x53, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x61, 0x6c, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x54, 0x0a, 0x0e, 0x53, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, + 0x67, 0x65, 0x78, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, 0x65, 0x67, 0x65, + 0x78, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xc0, + 0x01, 0x0a, 0x17, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x4c, 0x65, 0x61, 0x73, 0x74, + 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, 0x0a, 0x05, 0x63, 0x6f, + 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x05, 0x63, 0x6f, 0x73, 0x74, + 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x61, 0x73, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x03, 0x52, 0x09, 0x62, 0x61, 0x73, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x12, + 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x08, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6d, + 0x61, 0x78, 0x52, 0x54, 0x54, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6d, 0x61, 0x78, + 0x52, 0x54, 0x54, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x6f, 0x6c, 0x65, 0x72, 0x61, 0x6e, 0x63, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x74, 0x6f, 0x6c, 0x65, 0x72, 0x61, 0x6e, 0x63, + 0x65, 0x22, 0x9b, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4f, 0x0a, 0x0f, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x30, 0x0a, + 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x6f, + 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, + 0x45, 0x0a, 0x0e, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, + 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, + 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, + 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x47, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x73, 0x49, 0x73, + 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x49, 0x70, 0x10, 0x01, 0x12, 0x10, 0x0a, + 0x0c, 0x49, 0x70, 0x49, 0x66, 0x4e, 0x6f, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x02, 0x12, + 0x0e, 0x0a, 0x0a, 0x49, 0x70, 0x4f, 0x6e, 0x44, 0x65, 0x6d, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x42, + 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0xaa, 0x02, + 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/app/router/config.proto b/app/router/config.proto index 1cedb9e9..cff00fad 100644 --- a/app/router/config.proto +++ b/app/router/config.proto @@ -79,6 +79,7 @@ message RoutingRule { // Tag of routing balancer. string balancing_tag = 12; } + string rule_tag = 18; // List of domains for target domain matching. repeated Domain domain = 2; diff --git a/app/router/router.go b/app/router/router.go index 88197710..a45a6016 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -4,8 +4,10 @@ package router import ( "context" + sync "sync" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/dns" "github.com/xtls/xray-core/features/outbound" @@ -19,6 +21,11 @@ type Router struct { rules []*Rule balancers map[string]*Balancer dns dns.Client + + ctx context.Context + ohm outbound.Manager + dispatcher routing.Dispatcher + mu sync.Mutex } // Route is an implementation of routing.Route. @@ -32,6 +39,9 @@ type Route struct { func (r *Router) Init(ctx context.Context, config *Config, d dns.Client, ohm outbound.Manager, dispatcher routing.Dispatcher) error { r.domainStrategy = config.DomainStrategy r.dns = d + r.ctx = ctx + r.ohm = ohm + r.dispatcher = dispatcher r.balancers = make(map[string]*Balancer, len(config.BalancingRule)) for _, rule := range config.BalancingRule { @@ -52,6 +62,7 @@ func (r *Router) Init(ctx context.Context, config *Config, d dns.Client, ohm out rr := &Rule{ Condition: cond, Tag: rule.GetTag(), + RuleTag: rule.GetRuleTag(), } btag := rule.GetBalancingTag() if len(btag) > 0 { @@ -80,6 +91,96 @@ func (r *Router) PickRoute(ctx routing.Context) (routing.Route, error) { return &Route{Context: ctx, outboundTag: tag}, nil } +// AddRule implements routing.Router. +func (r *Router) AddRule(config *serial.TypedMessage, shouldAppend bool) error { + + inst, err := config.GetInstance() + if err != nil { + return err + } + if c, ok := inst.(*Config); ok { + return r.ReloadRules(c, shouldAppend) + } + return newError("AddRule: config type error") +} + +func (r *Router) ReloadRules(config *Config, shouldAppend bool) error { + r.mu.Lock() + defer r.mu.Unlock() + + if !shouldAppend { + r.balancers = make(map[string]*Balancer, len(config.BalancingRule)) + r.rules = make([]*Rule, 0, len(config.Rule)) + } + for _, rule := range config.BalancingRule { + _, found := r.balancers[rule.Tag] + if found { + return newError("duplicate balancer tag") + } + balancer, err := rule.Build(r.ohm, r.dispatcher) + if err != nil { + return err + } + balancer.InjectContext(r.ctx) + r.balancers[rule.Tag] = balancer + } + + for _, rule := range config.Rule { + if r.RuleExists(rule.GetRuleTag()) { + return newError("duplicate ruleTag ", rule.GetRuleTag()) + } + cond, err := rule.BuildCondition() + if err != nil { + return err + } + rr := &Rule{ + Condition: cond, + Tag: rule.GetTag(), + RuleTag: rule.GetRuleTag(), + } + btag := rule.GetBalancingTag() + if len(btag) > 0 { + brule, found := r.balancers[btag] + if !found { + return newError("balancer ", btag, " not found") + } + rr.Balancer = brule + } + r.rules = append(r.rules, rr) + } + + return nil +} + +func (r *Router) RuleExists(tag string) bool { + if tag != "" { + for _, rule := range r.rules { + if rule.RuleTag == tag { + return true + } + } + } + return false +} + +// RemoveRule implements routing.Router. +func (r *Router) RemoveRule(tag string) error { + r.mu.Lock() + defer r.mu.Unlock() + + newRules := []*Rule{} + if tag != "" { + for _, rule := range r.rules { + if rule.RuleTag != tag { + newRules = append(newRules, rule) + } + } + r.rules = newRules + return nil + } + return newError("empty tag name!") + +} func (r *Router) pickRouteInternal(ctx routing.Context) (*Rule, routing.Context, error) { // SkipDNSResolve is set from DNS module. // the DOH remote server maybe a domain name, diff --git a/features/routing/router.go b/features/routing/router.go index 3d6f150a..97246cdb 100644 --- a/features/routing/router.go +++ b/features/routing/router.go @@ -2,6 +2,7 @@ package routing import ( "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/features" ) @@ -13,6 +14,8 @@ type Router interface { // PickRoute returns a route decision based on the given routing context. PickRoute(ctx Context) (Route, error) + AddRule(config *serial.TypedMessage, shouldAppend bool) error + RemoveRule(tag string) error } // Route is the routing result of Router feature. @@ -49,6 +52,16 @@ func (DefaultRouter) PickRoute(ctx Context) (Route, error) { return nil, common.ErrNoClue } +// AddRule implements Router. +func (DefaultRouter) AddRule(config *serial.TypedMessage, shouldAppend bool) error { + return common.ErrNoClue +} + +// RemoveRule implements Router. +func (DefaultRouter) RemoveRule(tag string) error { + return common.ErrNoClue +} + // Start implements common.Runnable. func (DefaultRouter) Start() error { return nil diff --git a/infra/conf/router.go b/infra/conf/router.go index 5a6ca8fe..6ae39d45 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -139,6 +139,7 @@ func (c *RouterConfig) Build() (*router.Config, error) { } type RouterRule struct { + RuleTag string `json:"ruleTag"` Type string `json:"type"` OutboundTag string `json:"outboundTag"` BalancerTag string `json:"balancerTag"` @@ -560,6 +561,7 @@ func parseFieldRule(msg json.RawMessage) (*router.RoutingRule, error) { } rule := new(router.RoutingRule) + rule.RuleTag = rawFieldRule.RuleTag switch { case len(rawFieldRule.OutboundTag) > 0: rule.TargetTag = &router.RoutingRule_Tag{ diff --git a/main/commands/all/api/api.go b/main/commands/all/api/api.go index 0ff446b7..f408fd90 100644 --- a/main/commands/all/api/api.go +++ b/main/commands/all/api/api.go @@ -21,5 +21,7 @@ var CmdAPI = &base.Command{ cmdAddOutbounds, cmdRemoveInbounds, cmdRemoveOutbounds, + cmdAddRules, + cmdRemoveRules, }, } diff --git a/main/commands/all/api/rules_add.go b/main/commands/all/api/rules_add.go new file mode 100644 index 00000000..11ec1e01 --- /dev/null +++ b/main/commands/all/api/rules_add.go @@ -0,0 +1,88 @@ +package api + +import ( + "fmt" + + routerService "github.com/xtls/xray-core/app/router/command" + cserial "github.com/xtls/xray-core/common/serial" + "github.com/xtls/xray-core/infra/conf" + "github.com/xtls/xray-core/infra/conf/serial" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdAddRules = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api adrules [--server=127.0.0.1:8080] [c2.json]...", + Short: "Add routing rules", + Long: ` +Add routing rules to Xray. +Arguments: + -s, -server + The API server address. Default 127.0.0.1:8080 + -t, -timeout + Timeout seconds to call API. Default 3 + -append + append or replace config. Default false + +Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json c2.json +`, + Run: executeAddRules, +} + +func executeAddRules(cmd *base.Command, args []string) { + var ( + shouldAppend bool + ) + setSharedFlags(cmd) + cmd.Flag.BoolVar(&shouldAppend, "append", false, "") + cmd.Flag.Parse(args) + + unnamedArgs := cmd.Flag.Args() + if len(unnamedArgs) == 0 { + fmt.Println("reading from stdin:") + unnamedArgs = []string{"stdin:"} + } + conn, ctx, close := dialAPIServer() + defer close() + + client := routerService.NewRoutingServiceClient(conn) + + rcs := make([]conf.RouterConfig, 0) + for _, arg := range unnamedArgs { + r, err := loadArg(arg) + if err != nil { + base.Fatalf("failed to load %s: %s", arg, err) + } + conf, err := serial.DecodeJSONConfig(r) + if err != nil { + base.Fatalf("failed to decode %s: %s", arg, err) + } + rcs = append(rcs, *conf.RouterConfig) + } + if len(rcs) == 0 { + base.Fatalf("no valid rule found in config") + } + for _, in := range rcs { + + config, err := in.Build() + if err != nil { + base.Fatalf("failed to build conf: %s", err) + } + tmsg := cserial.ToTypedMessage(config) + if tmsg == nil { + base.Fatalf("failed to format config to TypedMessage.") + } + + ra := &routerService.AddRuleRequest{ + Config: tmsg, + ShouldAppend: shouldAppend, + } + resp, err := client.AddRule(ctx, ra) + if err != nil { + base.Fatalf("failed to perform AddRule: %s", err) + } + showJSONResponse(resp) + } + +} diff --git a/main/commands/all/api/rules_remove.go b/main/commands/all/api/rules_remove.go new file mode 100644 index 00000000..4904022a --- /dev/null +++ b/main/commands/all/api/rules_remove.go @@ -0,0 +1,55 @@ +package api + +import ( + "fmt" + + routerService "github.com/xtls/xray-core/app/router/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdRemoveRules = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api rmrules [--server=127.0.0.1:8080] ruleTag1 ruleTag2...", + Short: "Remove routing rules by ruleTag", + Long: ` +Remove routing rules by ruleTag from Xray. +Arguments: + -s, -server + The API server address. Default 127.0.0.1:8080 + -t, -timeout + Timeout seconds to call API. Default 3 +Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 ruleTag1 ruleTag2 +`, + Run: executeRemoveRules, +} + +func executeRemoveRules(cmd *base.Command, args []string) { + setSharedFlags(cmd) + cmd.Flag.Parse(args) + ruleTags := cmd.Flag.Args() + if len(ruleTags) == 0 { + fmt.Println("reading from stdin:") + ruleTags = []string{"stdin:"} + } + conn, ctx, close := dialAPIServer() + defer close() + + client := routerService.NewRoutingServiceClient(conn) + + if len(ruleTags) == 0 { + base.Fatalf("no valid ruleTag input") + } + for _, tag := range ruleTags { + + rr := &routerService.RemoveRuleRequest{ + RuleTag: tag, + } + resp, err := client.RemoveRule(ctx, rr) + if err != nil { + base.Fatalf("failed to perform RemoveRule: %s", err) + } + showJSONResponse(resp) + } + +} From e2302b421c89195ea7b7a1f5389bae2e74623314 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 29 Mar 2024 01:39:59 -0400 Subject: [PATCH 323/867] Update proto file for websocket and httpupgrade (breaking) --- app/proxyman/config.pb.go | 2 +- app/router/command/command.pb.go | 4 +- app/router/command/command_grpc.pb.go | 35 +++-- app/router/config.pb.go | 2 +- infra/conf/transport_internet.go | 7 +- infra/conf/xray_test.go | 14 +- transport/internet/httpupgrade/config.pb.go | 73 +++++----- transport/internet/httpupgrade/config.proto | 8 +- transport/internet/websocket/config.go | 4 +- transport/internet/websocket/config.pb.go | 148 ++++++-------------- transport/internet/websocket/config.proto | 16 +-- transport/internet/websocket/ws_test.go | 2 +- 12 files changed, 121 insertions(+), 194 deletions(-) diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index 501908d0..ab08bbea 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 -// protoc v5.26.0 +// protoc v4.23.1 // source: app/proxyman/config.proto package proxyman diff --git a/app/router/command/command.pb.go b/app/router/command/command.pb.go index f6728990..3fc58b2f 100644 --- a/app/router/command/command.pb.go +++ b/app/router/command/command.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v4.25.3 +// protoc-gen-go v1.33.0 +// protoc v4.23.1 // source: app/router/command/command.proto package command diff --git a/app/router/command/command_grpc.pb.go b/app/router/command/command_grpc.pb.go index 716edec4..c64a4423 100644 --- a/app/router/command/command_grpc.pb.go +++ b/app/router/command/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v4.25.3 +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.23.1 // source: app/router/command/command.proto package command @@ -18,6 +18,15 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 +const ( + RoutingService_SubscribeRoutingStats_FullMethodName = "/xray.app.router.command.RoutingService/SubscribeRoutingStats" + RoutingService_TestRoute_FullMethodName = "/xray.app.router.command.RoutingService/TestRoute" + RoutingService_GetBalancerInfo_FullMethodName = "/xray.app.router.command.RoutingService/GetBalancerInfo" + RoutingService_OverrideBalancerTarget_FullMethodName = "/xray.app.router.command.RoutingService/OverrideBalancerTarget" + RoutingService_AddRule_FullMethodName = "/xray.app.router.command.RoutingService/AddRule" + RoutingService_RemoveRule_FullMethodName = "/xray.app.router.command.RoutingService/RemoveRule" +) + // RoutingServiceClient is the client API for RoutingService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. @@ -39,7 +48,7 @@ func NewRoutingServiceClient(cc grpc.ClientConnInterface) RoutingServiceClient { } func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error) { - stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], "/xray.app.router.command.RoutingService/SubscribeRoutingStats", opts...) + stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], RoutingService_SubscribeRoutingStats_FullMethodName, opts...) if err != nil { return nil, err } @@ -72,7 +81,7 @@ func (x *routingServiceSubscribeRoutingStatsClient) Recv() (*RoutingContext, err func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error) { out := new(RoutingContext) - err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/TestRoute", in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_TestRoute_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -81,7 +90,7 @@ func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteReque func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error) { out := new(GetBalancerInfoResponse) - err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/GetBalancerInfo", in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_GetBalancerInfo_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -90,7 +99,7 @@ func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalan func (c *routingServiceClient) OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error) { out := new(OverrideBalancerTargetResponse) - err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/OverrideBalancerTarget", in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_OverrideBalancerTarget_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -99,7 +108,7 @@ func (c *routingServiceClient) OverrideBalancerTarget(ctx context.Context, in *O func (c *routingServiceClient) AddRule(ctx context.Context, in *AddRuleRequest, opts ...grpc.CallOption) (*AddRuleResponse, error) { out := new(AddRuleResponse) - err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/AddRule", in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_AddRule_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -108,7 +117,7 @@ func (c *routingServiceClient) AddRule(ctx context.Context, in *AddRuleRequest, func (c *routingServiceClient) RemoveRule(ctx context.Context, in *RemoveRuleRequest, opts ...grpc.CallOption) (*RemoveRuleResponse, error) { out := new(RemoveRuleResponse) - err := c.cc.Invoke(ctx, "/xray.app.router.command.RoutingService/RemoveRule", in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_RemoveRule_FullMethodName, in, out, opts...) if err != nil { return nil, err } @@ -194,7 +203,7 @@ func _RoutingService_TestRoute_Handler(srv interface{}, ctx context.Context, dec } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.router.command.RoutingService/TestRoute", + FullMethod: RoutingService_TestRoute_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoutingServiceServer).TestRoute(ctx, req.(*TestRouteRequest)) @@ -212,7 +221,7 @@ func _RoutingService_GetBalancerInfo_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.router.command.RoutingService/GetBalancerInfo", + FullMethod: RoutingService_GetBalancerInfo_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoutingServiceServer).GetBalancerInfo(ctx, req.(*GetBalancerInfoRequest)) @@ -230,7 +239,7 @@ func _RoutingService_OverrideBalancerTarget_Handler(srv interface{}, ctx context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.router.command.RoutingService/OverrideBalancerTarget", + FullMethod: RoutingService_OverrideBalancerTarget_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoutingServiceServer).OverrideBalancerTarget(ctx, req.(*OverrideBalancerTargetRequest)) @@ -248,7 +257,7 @@ func _RoutingService_AddRule_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.router.command.RoutingService/AddRule", + FullMethod: RoutingService_AddRule_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoutingServiceServer).AddRule(ctx, req.(*AddRuleRequest)) @@ -266,7 +275,7 @@ func _RoutingService_RemoveRule_Handler(srv interface{}, ctx context.Context, de } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/xray.app.router.command.RoutingService/RemoveRule", + FullMethod: RoutingService_RemoveRule_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RoutingServiceServer).RemoveRule(ctx, req.(*RemoveRuleRequest)) diff --git a/app/router/config.pb.go b/app/router/config.pb.go index 3ce4b7c1..23aba911 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 -// protoc v3.21.12 +// protoc v4.23.1 // source: app/router/config.proto package router diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 22e749d7..bcb33937 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -154,12 +154,9 @@ type WebSocketConfig struct { // Build implements Buildable. func (c *WebSocketConfig) Build() (proto.Message, error) { path := c.Path - header := make([]*websocket.Header, 0, 32) + header := make(map[string]string); for key, value := range c.Headers { - header = append(header, &websocket.Header{ - Key: key, - Value: value, - }) + header[key] = value; } var ed uint32 if u, err := url.Parse(path); err == nil { diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index a53cd216..b4bb2f6d 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -236,11 +236,8 @@ func TestXrayConfig(t *testing.T) { { ProtocolName: "websocket", Settings: serial.ToTypedMessage(&websocket.Config{ - Header: []*websocket.Header{ - { - Key: "host", - Value: "example.domain", - }, + Header: map[string]string{ + "host": "example.domain", }, }), }, @@ -291,11 +288,8 @@ func TestXrayConfig(t *testing.T) { { ProtocolName: "websocket", Settings: serial.ToTypedMessage(&websocket.Config{ - Header: []*websocket.Header{ - { - Key: "host", - Value: "example.domain", - }, + Header: map[string]string{ + "host": "example.domain", }, }), }, diff --git a/transport/internet/httpupgrade/config.pb.go b/transport/internet/httpupgrade/config.pb.go index e265b092..a4441fde 100644 --- a/transport/internet/httpupgrade/config.pb.go +++ b/transport/internet/httpupgrade/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 -// protoc v5.26.0 +// protoc v4.23.1 // source: transport/internet/httpupgrade/config.proto package httpupgrade @@ -25,11 +25,11 @@ type Config struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` + Header map[string]string `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` AcceptProxyProtocol bool `protobuf:"varint,4,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` Ed uint32 `protobuf:"varint,5,opt,name=ed,proto3" json:"ed,omitempty"` - Header map[string]string `protobuf:"bytes,6,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } func (x *Config) Reset() { @@ -64,6 +64,13 @@ func (*Config) Descriptor() ([]byte, []int) { return file_transport_internet_httpupgrade_config_proto_rawDescGZIP(), []int{0} } +func (x *Config) GetHost() string { + if x != nil { + return x.Host + } + return "" +} + func (x *Config) GetPath() string { if x != nil { return x.Path @@ -71,11 +78,11 @@ func (x *Config) GetPath() string { return "" } -func (x *Config) GetHost() string { +func (x *Config) GetHeader() map[string]string { if x != nil { - return x.Host + return x.Header } - return "" + return nil } func (x *Config) GetAcceptProxyProtocol() bool { @@ -92,13 +99,6 @@ func (x *Config) GetEd() uint32 { return 0 } -func (x *Config) GetHeader() map[string]string { - if x != nil { - return x.Header - } - return nil -} - var File_transport_internet_httpupgrade_config_proto protoreflect.FileDescriptor var file_transport_internet_httpupgrade_config_proto_rawDesc = []byte{ @@ -107,33 +107,32 @@ var file_transport_internet_httpupgrade_config_proto_rawDesc = []byte{ 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x23, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, - 0x64, 0x65, 0x22, 0x86, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, - 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x65, 0x64, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x65, 0x64, 0x12, 0x4f, 0x0a, 0x06, 0x68, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, + 0x64, 0x65, 0x22, 0x80, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, + 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x4f, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, + 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, + 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, + 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, + 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x65, 0x64, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x02, 0x65, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x42, 0x8b, 0x01, 0x0a, 0x27, - 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, - 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, - 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, - 0x61, 0x64, 0x65, 0xaa, 0x02, 0x23, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x48, 0x74, - 0x74, 0x70, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x8b, 0x01, 0x0a, 0x27, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, + 0x65, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0xaa, 0x02, 0x23, + 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x48, 0x74, 0x74, 0x70, 0x55, 0x70, 0x67, 0x72, + 0x61, 0x64, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/httpupgrade/config.proto b/transport/internet/httpupgrade/config.proto index 33d8c054..98206f51 100644 --- a/transport/internet/httpupgrade/config.proto +++ b/transport/internet/httpupgrade/config.proto @@ -7,13 +7,9 @@ option java_package = "com.xray.transport.internet.httpupgrade"; option java_multiple_files = true; message Config { - reserved 1; - + string host = 1; string path = 2; - string host = 3; - + map header = 3; bool accept_proxy_protocol = 4; - uint32 ed = 5; - map header = 6; } diff --git a/transport/internet/websocket/config.go b/transport/internet/websocket/config.go index 948d32c4..2e3cfea5 100644 --- a/transport/internet/websocket/config.go +++ b/transport/internet/websocket/config.go @@ -22,8 +22,8 @@ func (c *Config) GetNormalizedPath() string { func (c *Config) GetRequestHeader() http.Header { header := http.Header{} - for _, h := range c.Header { - header.Add(h.Key, h.Value) + for k, v := range c.Header { + header.Add(k, v) } return header } diff --git a/transport/internet/websocket/config.pb.go b/transport/internet/websocket/config.pb.go index aecd530c..9fdbcbaf 100644 --- a/transport/internet/websocket/config.pb.go +++ b/transport/internet/websocket/config.pb.go @@ -20,77 +20,22 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type Header struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` -} - -func (x *Header) Reset() { - *x = Header{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_websocket_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Header) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Header) ProtoMessage() {} - -func (x *Header) ProtoReflect() protoreflect.Message { - mi := &file_transport_internet_websocket_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Header.ProtoReflect.Descriptor instead. -func (*Header) Descriptor() ([]byte, []int) { - return file_transport_internet_websocket_config_proto_rawDescGZIP(), []int{0} -} - -func (x *Header) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *Header) GetValue() string { - if x != nil { - return x.Value - } - return "" -} - type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // URL path to the WebSocket service. Empty value means root(/). - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - Header []*Header `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty"` - AcceptProxyProtocol bool `protobuf:"varint,4,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` - Ed uint32 `protobuf:"varint,5,opt,name=ed,proto3" json:"ed,omitempty"` + Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` // URL path to the WebSocket service. Empty value means root(/). + Header map[string]string `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + AcceptProxyProtocol bool `protobuf:"varint,4,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` + Ed uint32 `protobuf:"varint,5,opt,name=ed,proto3" json:"ed,omitempty"` } func (x *Config) Reset() { *x = Config{} if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_websocket_config_proto_msgTypes[1] + mi := &file_transport_internet_websocket_config_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -103,7 +48,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_transport_internet_websocket_config_proto_msgTypes[1] + mi := &file_transport_internet_websocket_config_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -116,7 +61,14 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_transport_internet_websocket_config_proto_rawDescGZIP(), []int{1} + return file_transport_internet_websocket_config_proto_rawDescGZIP(), []int{0} +} + +func (x *Config) GetHost() string { + if x != nil { + return x.Host + } + return "" } func (x *Config) GetPath() string { @@ -126,7 +78,7 @@ func (x *Config) GetPath() string { return "" } -func (x *Config) GetHeader() []*Header { +func (x *Config) GetHeader() map[string]string { if x != nil { return x.Header } @@ -154,30 +106,32 @@ var file_transport_internet_websocket_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x22, 0x30, - 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x22, 0xa9, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x70, - 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, - 0x41, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, - 0x6b, 0x65, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x02, 0x65, 0x64, 0x4a, 0x04, 0x08, 0x01, 0x10, 0x02, 0x42, 0x85, 0x01, 0x0a, - 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x77, 0x65, 0x62, - 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, - 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, - 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x57, 0x65, 0x62, 0x73, 0x6f, - 0x63, 0x6b, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x22, 0xfe, + 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x35, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x77, 0x65, 0x62, 0x73, + 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, + 0x52, 0x02, 0x65, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, + 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, + 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, + 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, + 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, + 0x6b, 0x65, 0x74, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x57, 0x65, + 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -194,11 +148,11 @@ func file_transport_internet_websocket_config_proto_rawDescGZIP() []byte { var file_transport_internet_websocket_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_transport_internet_websocket_config_proto_goTypes = []interface{}{ - (*Header)(nil), // 0: xray.transport.internet.websocket.Header - (*Config)(nil), // 1: xray.transport.internet.websocket.Config + (*Config)(nil), // 0: xray.transport.internet.websocket.Config + nil, // 1: xray.transport.internet.websocket.Config.HeaderEntry } var file_transport_internet_websocket_config_proto_depIdxs = []int32{ - 0, // 0: xray.transport.internet.websocket.Config.header:type_name -> xray.transport.internet.websocket.Header + 1, // 0: xray.transport.internet.websocket.Config.header:type_name -> xray.transport.internet.websocket.Config.HeaderEntry 1, // [1:1] is the sub-list for method output_type 1, // [1:1] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name @@ -213,18 +167,6 @@ func file_transport_internet_websocket_config_proto_init() { } if !protoimpl.UnsafeEnabled { file_transport_internet_websocket_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Header); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_websocket_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/websocket/config.proto b/transport/internet/websocket/config.proto index 85365c33..6c6ce7dd 100644 --- a/transport/internet/websocket/config.proto +++ b/transport/internet/websocket/config.proto @@ -6,20 +6,10 @@ option go_package = "github.com/xtls/xray-core/transport/internet/websocket"; option java_package = "com.xray.transport.internet.websocket"; option java_multiple_files = true; -message Header { - string key = 1; - string value = 2; -} - message Config { - reserved 1; - - // URL path to the WebSocket service. Empty value means root(/). - string path = 2; - - repeated Header header = 3; - + string host = 1; + string path = 2; // URL path to the WebSocket service. Empty value means root(/). + map header = 3; bool accept_proxy_protocol = 4; - uint32 ed = 5; } diff --git a/transport/internet/websocket/ws_test.go b/transport/internet/websocket/ws_test.go index f3ae38fb..12223353 100644 --- a/transport/internet/websocket/ws_test.go +++ b/transport/internet/websocket/ws_test.go @@ -95,7 +95,7 @@ func TestDialWithRemoteAddr(t *testing.T) { conn, err := Dial(context.Background(), net.TCPDestination(net.DomainAddress("localhost"), 13148), &internet.MemoryStreamConfig{ ProtocolName: "websocket", - ProtocolSettings: &Config{Path: "ws", Header: []*Header{{Key: "X-Forwarded-For", Value: "1.1.1.1"}}}, + ProtocolSettings: &Config{Path: "ws", Header: map[string]string{"X-Forwarded-For": "1.1.1.1"}}, }) common.Must(err) From 7e3a8d3a04fe94de544184353a2545b2f269c34e Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Fri, 29 Mar 2024 02:27:02 -0400 Subject: [PATCH 324/867] Add separate host config for websocket --- infra/conf/transport_internet.go | 18 ++++++++++++------ transport/internet/websocket/config.go | 1 + transport/internet/websocket/hub.go | 6 ++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index bcb33937..805a674e 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -146,6 +146,7 @@ func (c *TCPConfig) Build() (proto.Message, error) { } type WebSocketConfig struct { + Host string `json:"host"` Path string `json:"path"` Headers map[string]string `json:"headers"` AcceptProxyProtocol bool `json:"acceptProxyProtocol"` @@ -154,10 +155,6 @@ type WebSocketConfig struct { // Build implements Buildable. func (c *WebSocketConfig) Build() (proto.Message, error) { path := c.Path - header := make(map[string]string); - for key, value := range c.Headers { - header[key] = value; - } var ed uint32 if u, err := url.Parse(path); err == nil { if q := u.Query(); q.Get("ed") != "" { @@ -168,9 +165,18 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { path = u.String() } } + // If http host is not set in the Host field, but in headers field, we add it to Host Field here. + // If we don't do that, http host will be overwritten as address. + // Host priority: Host field > headers field > address. + if c.Host == "" && c.Headers["host"] != "" { + c.Host = c.Headers["host"] + } else if c.Host == "" && c.Headers["Host"] != "" { + c.Host = c.Headers["Host"] + } config := &websocket.Config{ Path: path, - Header: header, + Host: c.Host, + Header: c.Headers, AcceptProxyProtocol: c.AcceptProxyProtocol, Ed: ed, } @@ -178,8 +184,8 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { } type HttpUpgradeConfig struct { - Path string `json:"path"` Host string `json:"host"` + Path string `json:"path"` Headers map[string]string `json:"headers"` AcceptProxyProtocol bool `json:"acceptProxyProtocol"` } diff --git a/transport/internet/websocket/config.go b/transport/internet/websocket/config.go index 2e3cfea5..8cb4a855 100644 --- a/transport/internet/websocket/config.go +++ b/transport/internet/websocket/config.go @@ -25,6 +25,7 @@ func (c *Config) GetRequestHeader() http.Header { for k, v := range c.Header { header.Add(k, v) } + header.Set("Host", c.Host) return header } diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index b3fe9ff4..8a860c30 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -21,6 +21,7 @@ import ( ) type requestHandler struct { + host string path string ln *Listener } @@ -37,6 +38,10 @@ var upgrader = &websocket.Upgrader{ } func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) { + if len(h.host) > 0 && request.Host != h.host { + writer.WriteHeader(http.StatusNotFound) + return + } if request.URL.Path != h.path { writer.WriteHeader(http.StatusNotFound) return @@ -125,6 +130,7 @@ func ListenWS(ctx context.Context, address net.Address, port net.Port, streamSet l.server = http.Server{ Handler: &requestHandler{ + host: wsSettings.Host, path: wsSettings.GetNormalizedPath(), ln: l, }, From 685e66e96b0fa2475dfbe76a46aab855f668470a Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 30 Mar 2024 08:10:16 +0000 Subject: [PATCH 325/867] Fix TestXrayConfig in xray_test.go --- infra/conf/xray_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index b4bb2f6d..03e27142 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -236,6 +236,7 @@ func TestXrayConfig(t *testing.T) { { ProtocolName: "websocket", Settings: serial.ToTypedMessage(&websocket.Config{ + Host: "example.domain", Header: map[string]string{ "host": "example.domain", }, @@ -288,6 +289,7 @@ func TestXrayConfig(t *testing.T) { { ProtocolName: "websocket", Settings: serial.ToTypedMessage(&websocket.Config{ + Host: "example.domain", Header: map[string]string{ "host": "example.domain", }, From 07ed0946b502fb00661925e60a449886ec14e95d Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 30 Mar 2024 08:40:20 +0000 Subject: [PATCH 326/867] v1.8.10 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 374d5fba..c331d347 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 9 + Version_z byte = 10 ) var ( From ba57ccdd4531c69bf347e177aebd270fa1cd5672 Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Sun, 31 Mar 2024 08:29:15 +0400 Subject: [PATCH 327/867] API: add Source IP Block command (#3211) * add SourceIpBlock to API * improve inboundTag --- main/commands/all/api/api.go | 1 + main/commands/all/api/source_ip_block.go | 132 +++++++++++++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 main/commands/all/api/source_ip_block.go diff --git a/main/commands/all/api/api.go b/main/commands/all/api/api.go index f408fd90..ea43d107 100644 --- a/main/commands/all/api/api.go +++ b/main/commands/all/api/api.go @@ -23,5 +23,6 @@ var CmdAPI = &base.Command{ cmdRemoveOutbounds, cmdAddRules, cmdRemoveRules, + cmdSourceIpBlock, }, } diff --git a/main/commands/all/api/source_ip_block.go b/main/commands/all/api/source_ip_block.go new file mode 100644 index 00000000..1f773187 --- /dev/null +++ b/main/commands/all/api/source_ip_block.go @@ -0,0 +1,132 @@ +package api + +import ( + "encoding/json" + "fmt" + "strings" + + routerService "github.com/xtls/xray-core/app/router/command" + cserial "github.com/xtls/xray-core/common/serial" + "github.com/xtls/xray-core/infra/conf/serial" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdSourceIpBlock = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api sib [--server=127.0.0.1:8080] -outbound=blocked -inbound=socks 1.2.3.4", + Short: "Drop connections by source ip", + Long: ` +Drop connections by source ip. +Arguments: + -s, -server + The API server address. Default 127.0.0.1:8080 + -t, -timeout + Timeout seconds to call API. Default 3 + -outbound + route traffic to specific outbound. + -inbound + target traffig from specific inbound. + -ruletag + set ruleTag. Default sourceIpBlock + -reset + remove ruletag and apply new source IPs. Default false + + Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json c2.json +`, + Run: executeSourceIpBlock, +} + +func executeSourceIpBlock(cmd *base.Command, args []string) { + var ( + inbound string + outbound string + ruletag string + reset bool + ) + setSharedFlags(cmd) + cmd.Flag.StringVar(&inbound, "inbound", "", "") + cmd.Flag.StringVar(&outbound, "outbound", "", "") + cmd.Flag.StringVar(&ruletag, "ruletag", "sourceIpBlock", "") + cmd.Flag.BoolVar(&reset, "reset", false, "") + + cmd.Flag.Parse(args) + + unnamedArgs := cmd.Flag.Args() + if len(unnamedArgs) == 0 { + fmt.Println("reading from stdin:") + unnamedArgs = []string{"stdin:"} + } + conn, ctx, close := dialAPIServer() + defer close() + + client := routerService.NewRoutingServiceClient(conn) + + jsonIps, err := json.Marshal(unnamedArgs) + if err != nil { + fmt.Println("Error marshaling JSON:", err) + return + } + + jsonInbound, err := json.Marshal([]string{inbound}) + if inbound == "" { + jsonInbound, err = json.Marshal([]string{}) + } + if err != nil { + fmt.Println("Error marshaling JSON:", err) + return + } + stringConfig := fmt.Sprintf(` + { + "routing": { + "rules": [ + { + "ruleTag" : "%s", + "inboundTag": %s, + "outboundTag": "%s", + "type": "field", + "source": %s + } + ] + } + } + + `, ruletag, string(jsonInbound), outbound, string(jsonIps)) + + conf, err := serial.DecodeJSONConfig(strings.NewReader(stringConfig)) + if err != nil { + base.Fatalf("failed to decode : %s", err) + } + rc := *conf.RouterConfig + + config, err := rc.Build() + if err != nil { + base.Fatalf("failed to build conf: %s", err) + } + tmsg := cserial.ToTypedMessage(config) + if tmsg == nil { + base.Fatalf("failed to format config to TypedMessage.") + } + + if reset { + rr := &routerService.RemoveRuleRequest{ + RuleTag: ruletag, + } + resp, err := client.RemoveRule(ctx, rr) + if err != nil { + base.Fatalf("failed to perform RemoveRule: %s", err) + } + showJSONResponse(resp) + + } + ra := &routerService.AddRuleRequest{ + Config: tmsg, + ShouldAppend: true, + } + resp, err := client.AddRule(ctx, ra) + if err != nil { + base.Fatalf("failed to perform AddRule: %s", err) + } + showJSONResponse(resp) + +} From ec2224974de80545b13acd407559e7038fa49262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= <45535409+Fangliding@users.noreply.github.com> Date: Mon, 1 Apr 2024 23:02:19 +0800 Subject: [PATCH 328/867] Add "nosni" option to send empty SNI (#3214) * Allow not to send SNI * Allow reality not to send SNI --- transport/internet/reality/reality.go | 2 ++ transport/internet/tls/config.go | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 136a075d..b8bb881f 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -116,6 +116,8 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati } if utlsConfig.ServerName == "" { utlsConfig.ServerName = dest.Address.String() + } else if strings.ToLower(utlsConfig.ServerName) == "nosni" { // If ServerName is set to "nosni", we set it empty. + utlsConfig.ServerName = "" } uConn.ServerName = utlsConfig.ServerName fingerprint := tls.GetFingerprint(config.Fingerprint) diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 325909e3..03c43a9e 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -325,6 +325,11 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { config.ServerName = sn } + // If ServerName is set to "nosni", we set it empty. + if strings.ToLower(c.parseServerName()) == "nosni" { + config.ServerName = "" + } + if len(config.NextProtos) == 0 { config.NextProtos = []string{"h2", "http/1.1"} } @@ -365,7 +370,7 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { config.PreferServerCipherSuites = c.PreferServerCipherSuites - if (len(c.MasterKeyLog) > 0 && c.MasterKeyLog != "none") { + if len(c.MasterKeyLog) > 0 && c.MasterKeyLog != "none" { writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644) if err != nil { newError("failed to open ", c.MasterKeyLog, " as master key log").AtError().Base(err).WriteToLog() @@ -381,6 +386,9 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { type Option func(*tls.Config) // WithDestination sets the server name in TLS config. +// Due to the incorrect structure of GetTLSConfig(), the config.ServerName will always be empty. +// So the real logic for SNI is: +// set it to dest -> overwrite it with servername(if it's len>0). func WithDestination(dest net.Destination) Option { return func(config *tls.Config) { if config.ServerName == "" { From 4b893fdd22f180ecc5a9680839015f2d2ccdcfb1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 00:34:04 +0000 Subject: [PATCH 329/867] Bump google.golang.org/grpc from 1.62.1 to 1.63.0 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.62.1 to 1.63.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.62.1...v1.63.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 3 +-- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 1e13ef54..6e1c3556 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/sync v0.6.0 golang.org/x/sys v0.18.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.62.1 + google.golang.org/grpc v1.63.0 google.golang.org/protobuf v1.33.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 @@ -39,7 +39,6 @@ require ( github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect github.com/francoispqt/gojay v1.2.13 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect - github.com/golang/protobuf v1.5.4 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7 // indirect github.com/klauspost/compress v1.17.7 // indirect diff --git a/go.sum b/go.sum index 9da6b4ae..5ae5bf35 100644 --- a/go.sum +++ b/go.sum @@ -275,8 +275,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= -google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= +google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From ec3b2b0907fffe65f1d509235592d3d91255c258 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 4 Apr 2024 00:34:11 +0000 Subject: [PATCH 330/867] Bump golang.org/x/net from 0.22.0 to 0.23.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.22.0 to 0.23.0. - [Commits](https://github.com/golang/net/compare/v0.22.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6e1c3556..92fad3c3 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.21.0 - golang.org/x/net v0.22.0 + golang.org/x/net v0.23.0 golang.org/x/sync v0.6.0 golang.org/x/sys v0.18.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index 5ae5bf35..b9a4797b 100644 --- a/go.sum +++ b/go.sum @@ -201,8 +201,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From 8374d59ce693582599e05d5e897ec065a67d3967 Mon Sep 17 00:00:00 2001 From: Aubrey Yang Date: Sun, 7 Apr 2024 06:01:07 +0800 Subject: [PATCH 331/867] Fix IPv6 random IP logic error (#3232) * Update handler.go fix CIDR6 * Update handler.go --- app/proxyman/outbound/handler.go | 33 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 41713d0b..792ac249 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -2,12 +2,8 @@ package outbound import ( "context" + "crypto/rand" "errors" - "io" - "math/rand" - gonet "net" - "os" - "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" @@ -25,6 +21,10 @@ import ( "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/pipe" + "io" + "math/big" + gonet "net" + "os" ) func getStatCounter(v *core.Instance, tag string) (stats.Counter, stats.Counter) { @@ -319,16 +319,21 @@ func (h *Handler) Close() error { return nil } -// Return random IPv6 in a CIDR block + func ParseRandomIPv6(address net.Address, prefix string) net.Address { - addr := address.IP().String() - _, network, _ := gonet.ParseCIDR(addr + "/" + prefix) + _, network, _ := gonet.ParseCIDR(address.IP().String() + "/" + prefix) - ipv6 := network.IP.To16() - prefixLen, _ := network.Mask.Size() - for i := prefixLen / 8; i < 16; i++ { - ipv6[i] = byte(rand.Intn(256)) - } + maskSize, totalBits := network.Mask.Size() + subnetSize := big.NewInt(1).Lsh(big.NewInt(1), uint(totalBits-maskSize)) - return net.ParseAddress(gonet.IP(ipv6).String()) + // random + randomBigInt, _ := rand.Int(rand.Reader, subnetSize) + + startIPBigInt := big.NewInt(0).SetBytes(network.IP.To16()) + randomIPBigInt := big.NewInt(0).Add(startIPBigInt, randomBigInt) + + randomIPBytes := randomIPBigInt.Bytes() + randomIPBytes = append(make([]byte, 16-len(randomIPBytes)), randomIPBytes...) + + return net.ParseAddress(gonet.IP(randomIPBytes).String()) } From 592157bb00a47fe7cdea78bc1ae6f683234bda5d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 00:19:54 +0000 Subject: [PATCH 332/867] Bump golang.org/x/sys from 0.18.0 to 0.19.0 Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.18.0 to 0.19.0. - [Commits](https://github.com/golang/sys/compare/v0.18.0...v0.19.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 92fad3c3..833542b2 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( golang.org/x/crypto v0.21.0 golang.org/x/net v0.23.0 golang.org/x/sync v0.6.0 - golang.org/x/sys v0.18.0 + golang.org/x/sys v0.19.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.63.0 google.golang.org/protobuf v1.33.0 diff --git a/go.sum b/go.sum index b9a4797b..88b6c843 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 457c1f65e0d501326d17abb734d02b36d0761a28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 00:20:01 +0000 Subject: [PATCH 333/867] Bump golang.org/x/net from 0.23.0 to 0.24.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.23.0 to 0.24.0. - [Commits](https://github.com/golang/net/compare/v0.23.0...v0.24.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 833542b2..6746643a 100644 --- a/go.mod +++ b/go.mod @@ -20,8 +20,8 @@ require ( github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20231112171332-de1173cf2b19 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.21.0 - golang.org/x/net v0.23.0 + golang.org/x/crypto v0.22.0 + golang.org/x/net v0.24.0 golang.org/x/sync v0.6.0 golang.org/x/sys v0.19.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index 88b6c843..cd8cecd2 100644 --- a/go.sum +++ b/go.sum @@ -179,8 +179,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= @@ -201,8 +201,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From 09db7e1ccad06fbf8407c2bb7189303249938883 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 00:20:16 +0000 Subject: [PATCH 334/867] Bump lukechampine.com/blake3 from 1.2.1 to 1.2.2 Bumps [lukechampine.com/blake3](https://github.com/lukechampine/blake3) from 1.2.1 to 1.2.2. - [Commits](https://github.com/lukechampine/blake3/compare/v1.2.1...v1.2.2) --- updated-dependencies: - dependency-name: lukechampine.com/blake3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6746643a..25ea942c 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( google.golang.org/protobuf v1.33.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 - lukechampine.com/blake3 v1.2.1 + lukechampine.com/blake3 v1.2.2 ) require ( diff --git a/go.sum b/go.sum index cd8cecd2..462920fb 100644 --- a/go.sum +++ b/go.sum @@ -299,7 +299,7 @@ h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= -lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= +lukechampine.com/blake3 v1.2.2 h1:wEAbSg0IVU4ih44CVlpMqMZMpzr5hf/6aqodLlevd/w= +lukechampine.com/blake3 v1.2.2/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= From e64fb3ca9b56c1535980ce4de9b962e0350d8c95 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 Apr 2024 22:02:08 +0000 Subject: [PATCH 335/867] Bump golang.org/x/sync from 0.6.0 to 0.7.0 Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.6.0 to 0.7.0. - [Commits](https://github.com/golang/sync/compare/v0.6.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/sync dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 25ea942c..bb3a6beb 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.22.0 golang.org/x/net v0.24.0 - golang.org/x/sync v0.6.0 + golang.org/x/sync v0.7.0 golang.org/x/sys v0.19.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.63.0 diff --git a/go.sum b/go.sum index 462920fb..f0450753 100644 --- a/go.sum +++ b/go.sum @@ -214,8 +214,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= From 548646fb06489cc05559cfa47bd6455ac9b5ae87 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 4 Apr 2024 02:50:15 -0400 Subject: [PATCH 336/867] Fix an edge case with tls hello fragment --- proxy/freedom/freedom.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 55853646..0176929c 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -373,6 +373,9 @@ func (f *FragmentWriter) Write(b []byte) (int, error) { return f.writer.Write(b) } recordLen := 5 + ((int(b[3]) << 8) | int(b[4])) + if len(b) < recordLen { // maybe already fragmented somehow + return f.writer.Write(b) + } data := b[5:recordLen] buf := make([]byte, 1024) for from := 0; ; { From 021868afcaa93ea94fed323782807ce4232fef57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= <45535409+Fangliding@users.noreply.github.com> Date: Sun, 7 Apr 2024 15:53:34 +0000 Subject: [PATCH 337/867] Fix HTTPUpgrade init --- transport/internet/config.go | 2 ++ transport/internet/httpupgrade/config.go | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/transport/internet/config.go b/transport/internet/config.go index a2091f5c..dc0b95e5 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -58,6 +58,8 @@ func RegisterProtocolConfigCreator(name string, creator ConfigCreator) error { return nil } +// Note: Each new transport needs to add init() func in transport/internet/xxx/config.go +// Otherwise, it will cause #3244 func CreateTransportConfig(name string) (interface{}, error) { creator, ok := globalTransportConfigCreatorCache[name] if !ok { diff --git a/transport/internet/httpupgrade/config.go b/transport/internet/httpupgrade/config.go index 21841bfd..3404930e 100644 --- a/transport/internet/httpupgrade/config.go +++ b/transport/internet/httpupgrade/config.go @@ -1,5 +1,10 @@ package httpupgrade +import ( + "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/transport/internet" +) + func (c *Config) GetNormalizedPath() string { path := c.Path if path == "" { @@ -10,3 +15,9 @@ func (c *Config) GetNormalizedPath() string { } return path } + +func init() { + common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { + return new(Config) + })) +} From 284316776148c5442fb25975d05cbbfd25b8c88d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Apr 2024 00:21:21 +0000 Subject: [PATCH 338/867] Bump google.golang.org/grpc from 1.63.0 to 1.63.2 Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.63.0 to 1.63.2. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.63.0...v1.63.2) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index bb3a6beb..cf63cbfd 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/sync v0.7.0 golang.org/x/sys v0.19.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.63.0 + google.golang.org/grpc v1.63.2 google.golang.org/protobuf v1.33.0 gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index f0450753..43183848 100644 --- a/go.sum +++ b/go.sum @@ -275,8 +275,8 @@ google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmE google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= -google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 03c20bf3b448ba935312d97e20fd7474809e15c4 Mon Sep 17 00:00:00 2001 From: oftenoccur <166520808+oftenoccur@users.noreply.github.com> Date: Thu, 11 Apr 2024 17:51:12 +0800 Subject: [PATCH 339/867] comments typo Signed-off-by: oftenoccur --- common/session/session.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/session/session.go b/common/session/session.go index 4af61015..38ffa7bd 100644 --- a/common/session/session.go +++ b/common/session/session.go @@ -44,7 +44,7 @@ type Inbound struct { Tag string // Name of the inbound proxy that handles the connection. Name string - // User is the user that authencates for the inbound. May be nil if the protocol allows anounymous traffic. + // User is the user that authenticates for the inbound. May be nil if the protocol allows anonymous traffic. User *protocol.MemoryUser // Conn is actually internet.Connection. May be nil. Conn net.Conn From fc4187450880566ec757bf6bbd68699e70483540 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Apr 2024 00:40:05 +0000 Subject: [PATCH 340/867] Bump github.com/refraction-networking/utls from 1.6.3 to 1.6.4 Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.6.3 to 1.6.4. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.6.3...v1.6.4) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cf63cbfd..807dec1f 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.42.0 - github.com/refraction-networking/utls v1.6.3 + github.com/refraction-networking/utls v1.6.4 github.com/sagernet/sing v0.3.8 github.com/sagernet/sing-shadowsocks v0.2.6 github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb diff --git a/go.sum b/go.sum index 43183848..64362f4e 100644 --- a/go.sum +++ b/go.sum @@ -114,8 +114,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/quic-go v0.42.0 h1:uSfdap0eveIl8KXnipv9K7nlwZ5IqLlYOpJ58u5utpM= github.com/quic-go/quic-go v0.42.0/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M= -github.com/refraction-networking/utls v1.6.3 h1:MFOfRN35sSx6K5AZNIoESsBuBxS2LCgRilRIdHb6fDc= -github.com/refraction-networking/utls v1.6.3/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr3h62pQoY1lXiNR/FPs= +github.com/refraction-networking/utls v1.6.4 h1:aeynTroaYn7y+mFtqv8D0bQ4bw0y9nJHneGxJ7lvRDM= +github.com/refraction-networking/utls v1.6.4/go.mod h1:2VL2xfiqgFAZtJKeUTlf+PSYFs3Eu7km0gCtXJ3m8zs= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= From fbc56b88da2808e3181add4935c143e319772c93 Mon Sep 17 00:00:00 2001 From: Allo Date: Sat, 13 Apr 2024 13:29:34 +0800 Subject: [PATCH 341/867] chore: remove the usage of some deprecated tls properties --- infra/conf/transport_internet.go | 2 - transport/internet/http/dialer.go | 5 +-- transport/internet/tls/config.go | 2 - transport/internet/tls/config.pb.go | 64 +++++++++++++++-------------- transport/internet/tls/config.proto | 3 +- transport/internet/tls/tls.go | 13 +++--- 6 files changed, 45 insertions(+), 44 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 805a674e..908a95d3 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -392,7 +392,6 @@ type TLSConfig struct { MinVersion string `json:"minVersion"` MaxVersion string `json:"maxVersion"` CipherSuites string `json:"cipherSuites"` - PreferServerCipherSuites bool `json:"preferServerCipherSuites"` Fingerprint string `json:"fingerprint"` RejectUnknownSNI bool `json:"rejectUnknownSni"` PinnedPeerCertificateChainSha256 *[]string `json:"pinnedPeerCertificateChainSha256"` @@ -424,7 +423,6 @@ func (c *TLSConfig) Build() (proto.Message, error) { config.MinVersion = c.MinVersion config.MaxVersion = c.MaxVersion config.CipherSuites = c.CipherSuites - config.PreferServerCipherSuites = c.PreferServerCipherSuites config.Fingerprint = strings.ToLower(c.Fingerprint) if config.Fingerprint != "" && tls.GetFingerprint(config.Fingerprint) == nil { return nil, newError(`unknown fingerprint: `, config.Fingerprint) diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index 513962d3..acccd0b7 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -97,13 +97,10 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return nil, err } } - negotiatedProtocol, negotiatedProtocolIsMutual := cn.NegotiatedProtocol() + negotiatedProtocol := cn.NegotiatedProtocol() if negotiatedProtocol != http2.NextProtoTLS { return nil, newError("http2: unexpected ALPN protocol " + negotiatedProtocol + "; want q" + http2.NextProtoTLS).AtError() } - if !negotiatedProtocolIsMutual { - return nil, newError("http2: could not negotiate protocol mutually").AtError() - } return cn, nil }, } diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 03c43a9e..36aca803 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -368,8 +368,6 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { } } - config.PreferServerCipherSuites = c.PreferServerCipherSuites - if len(c.MasterKeyLog) > 0 && c.MasterKeyLog != "none" { writer, err := os.OpenFile(c.MasterKeyLog, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0644) if err != nil { diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index 0e616ae8..d8c9a423 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -194,6 +194,9 @@ type Config struct { // Specify cipher suites, except for TLS 1.3. CipherSuites string `protobuf:"bytes,9,opt,name=cipher_suites,json=cipherSuites,proto3" json:"cipher_suites,omitempty"` // Whether the server selects its most preferred ciphersuite. + // Deprecated: crypto/tls has ignored this field. + // + // Deprecated: Marked as deprecated in transport/internet/tls/config.proto. PreferServerCipherSuites bool `protobuf:"varint,10,opt,name=prefer_server_cipher_suites,json=preferServerCipherSuites,proto3" json:"prefer_server_cipher_suites,omitempty"` // TLS Client Hello fingerprint (uTLS). Fingerprint string `protobuf:"bytes,11,opt,name=fingerprint,proto3" json:"fingerprint,omitempty"` @@ -306,6 +309,7 @@ func (x *Config) GetCipherSuites() string { return "" } +// Deprecated: Marked as deprecated in transport/internet/tls/config.proto. func (x *Config) GetPreferServerCipherSuites() bool { if x != nil { return x.PreferServerCipherSuites @@ -377,7 +381,7 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x43, 0x49, 0x50, 0x48, 0x45, 0x52, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, - 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xf2, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, + 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xf6, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x49, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x63, 0x65, 0x72, @@ -402,37 +406,37 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x61, 0x78, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x5f, 0x73, 0x75, 0x69, 0x74, 0x65, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0c, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x53, 0x75, 0x69, 0x74, 0x65, 0x73, 0x12, 0x3d, + 0x52, 0x0c, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x53, 0x75, 0x69, 0x74, 0x65, 0x73, 0x12, 0x41, 0x0a, 0x1b, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x5f, 0x73, 0x75, 0x69, 0x74, 0x65, 0x73, 0x18, 0x0a, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x18, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x53, 0x75, 0x69, 0x74, 0x65, 0x73, 0x12, 0x20, 0x0a, - 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x12, - 0x2c, 0x0a, 0x12, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x75, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, - 0x6e, 0x5f, 0x73, 0x6e, 0x69, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x72, 0x65, 0x6a, - 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x6e, 0x69, 0x12, 0x4e, 0x0a, - 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x63, 0x65, 0x72, - 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x73, - 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x20, 0x70, 0x69, 0x6e, - 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, - 0x74, 0x65, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x57, 0x0a, - 0x29, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x63, 0x65, 0x72, - 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, - 0x6b, 0x65, 0x79, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0e, 0x20, 0x03, 0x28, 0x0c, - 0x52, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, - 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, - 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, - 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, 0x42, 0x73, 0x0a, 0x1f, - 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x50, - 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, - 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, - 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x6c, - 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x28, 0x08, 0x42, 0x02, 0x18, 0x01, 0x52, 0x18, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x53, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x53, 0x75, 0x69, 0x74, 0x65, + 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, + 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, + 0x69, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x75, 0x6e, + 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x73, 0x6e, 0x69, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x10, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x6e, + 0x69, 0x12, 0x4e, 0x0a, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, 0x72, + 0x5f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x68, 0x61, + 0x69, 0x6e, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0c, 0x52, + 0x20, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x68, 0x61, 0x32, 0x35, + 0x36, 0x12, 0x57, 0x0a, 0x29, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, 0x72, + 0x5f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x75, 0x62, + 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0e, + 0x20, 0x03, 0x28, 0x0c, 0x52, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, + 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x4b, 0x65, 0x79, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x61, + 0x73, 0x74, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x0f, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, + 0x42, 0x73, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, + 0x74, 0x6c, 0x73, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, + 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x2e, 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/tls/config.proto b/transport/internet/tls/config.proto index b1c26a4c..12c7b7cb 100644 --- a/transport/internet/tls/config.proto +++ b/transport/internet/tls/config.proto @@ -63,7 +63,8 @@ message Config { string cipher_suites = 9; // Whether the server selects its most preferred ciphersuite. - bool prefer_server_cipher_suites = 10; + // Deprecated: crypto/tls has ignored this field. + bool prefer_server_cipher_suites = 10 [deprecated = true]; // TLS Client Hello fingerprint (uTLS). string fingerprint = 11; diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index 73631ef9..25889cb1 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -18,10 +18,11 @@ type Interface interface { net.Conn HandshakeContext(ctx context.Context) error VerifyHostname(host string) error - NegotiatedProtocol() (name string, mutual bool) + NegotiatedProtocol() string } var _ buf.Writer = (*Conn)(nil) +var _ Interface = (*Conn)(nil) type Conn struct { *tls.Conn @@ -55,9 +56,9 @@ func (c *Conn) HandshakeAddressContext(ctx context.Context) net.Address { return net.ParseAddress(state.ServerName) } -func (c *Conn) NegotiatedProtocol() (name string, mutual bool) { +func (c *Conn) NegotiatedProtocol() string { state := c.ConnectionState() - return state.NegotiatedProtocol, state.NegotiatedProtocolIsMutual + return state.NegotiatedProtocol } // Client initiates a TLS client handshake on the given connection. @@ -76,6 +77,8 @@ type UConn struct { *utls.UConn } +var _ Interface = (*UConn)(nil) + func (c *UConn) Close() error { timer := time.AfterFunc(tlsCloseTimeout, func() { c.Conn.NetConn().Close() @@ -122,9 +125,9 @@ func (c *UConn) WebsocketHandshakeContext(ctx context.Context) error { return c.HandshakeContext(ctx) } -func (c *UConn) NegotiatedProtocol() (name string, mutual bool) { +func (c *UConn) NegotiatedProtocol() string { state := c.ConnectionState() - return state.NegotiatedProtocol, state.NegotiatedProtocolIsMutual + return state.NegotiatedProtocol } func UClient(c net.Conn, config *tls.Config, fingerprint *utls.ClientHelloID) net.Conn { From cabc4c6013b955412c0998b986e6a029007f8750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=82=BB?= <123655015+chise0713@users.noreply.github.com> Date: Tue, 16 Apr 2024 06:35:20 +0800 Subject: [PATCH 342/867] Command: Add `tls ech` for ech config generation --- go.mod | 1 + go.sum | 2 ++ main/commands/all/tls/ech.go | 69 ++++++++++++++++++++++++++++++++++++ main/commands/all/tls/tls.go | 1 + 4 files changed, 73 insertions(+) create mode 100644 main/commands/all/tls/ech.go diff --git a/go.mod b/go.mod index 807dec1f..7f6b58fb 100644 --- a/go.mod +++ b/go.mod @@ -30,6 +30,7 @@ require ( gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 lukechampine.com/blake3 v1.2.2 + github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 ) require ( diff --git a/go.sum b/go.sum index 64362f4e..e3560abd 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1 dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 h1:Wo41lDOevRJSGpevP+8Pk5bANX7fJacO2w04aqLiC5I= +github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0/go.mod h1:FVGavL/QEBQDcBpr3fAojoK17xX5k9bicBphrOpP7uM= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= diff --git a/main/commands/all/tls/ech.go b/main/commands/all/tls/ech.go new file mode 100644 index 00000000..d4e17f9b --- /dev/null +++ b/main/commands/all/tls/ech.go @@ -0,0 +1,69 @@ +package tls + +import ( + "encoding/json" + "encoding/pem" + "os" + "strings" + + "github.com/OmarTariq612/goech" + "github.com/cloudflare/circl/hpke" + "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdECH = &base.Command{ + UsageLine: `{{.Exec}} tls ech [--serverName (string)] [--json]`, + Short: `Generate TLS-ECH certificates`, + Long: ` +Generate TLS-ECH certificates. + +Set serverName to your custom string: {{.Exec}} tls ech --serverName (string) +Generate into json format: {{.Exec}} tls ech --json +`, // Enable PQ signature schemes: {{.Exec}} tls ech --pq-signature-schemes-enabled +} + +func init() { + cmdECH.Run = executeECH +} + +var input_pqSignatureSchemesEnabled = cmdECH.Flag.Bool("pqSignatureSchemesEnabled", false, "") +var input_serverName = cmdECH.Flag.String("serverName", "cloudflare-ech.com", "") +var input_json = cmdECH.Flag.Bool("json", false, "True == turn on json output") + +func executeECH(cmd *base.Command, args []string) { + var kem hpke.KEM + + if *input_pqSignatureSchemesEnabled { + kem = hpke.KEM_X25519_KYBER768_DRAFT00 + } else { + kem = hpke.KEM_X25519_HKDF_SHA256 + } + + echKeySet, err := goech.GenerateECHKeySet(0, *input_serverName, kem) + common.Must(err) + + configBuffer, _ := echKeySet.ECHConfig.MarshalBinary() + keyBuffer, _ := echKeySet.MarshalBinary() + + configPEM := string(pem.EncodeToMemory(&pem.Block{Type: "ECH CONFIGS", Bytes: configBuffer})) + keyPEM := string(pem.EncodeToMemory(&pem.Block{Type: "ECH KEYS", Bytes: keyBuffer})) + if *input_json { + jECHConfigs := map[string]interface{}{ + "configs": strings.Split(strings.TrimSpace(string(configPEM)), "\n"), + } + jECHKey := map[string]interface{}{ + "key": strings.Split(strings.TrimSpace(string(keyPEM)), "\n"), + } + + for _, i := range []map[string]interface{}{jECHConfigs, jECHKey} { + content, err := json.MarshalIndent(i, "", " ") + common.Must(err) + os.Stdout.Write(content) + os.Stdout.WriteString("\n") + } + } else { + os.Stdout.WriteString(configPEM) + os.Stdout.WriteString(keyPEM) + } +} diff --git a/main/commands/all/tls/tls.go b/main/commands/all/tls/tls.go index bf653301..a93da1c3 100644 --- a/main/commands/all/tls/tls.go +++ b/main/commands/all/tls/tls.go @@ -14,5 +14,6 @@ var CmdTLS = &base.Command{ cmdCert, cmdPing, cmdCertChainHash, + cmdECH, }, } From 0c617528296dbfb64609bfde0395165114179549 Mon Sep 17 00:00:00 2001 From: coderwander <770732124@qq.com> Date: Tue, 16 Apr 2024 11:03:09 +0800 Subject: [PATCH 343/867] chore: fix struct name Signed-off-by: coderwander <770732124@qq.com> --- core/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/config.go b/core/config.go index 1aa21f5f..1a5fa33f 100644 --- a/core/config.go +++ b/core/config.go @@ -24,7 +24,7 @@ type ConfigLoader func(input interface{}) (*Config, error) // ConfigBuilder is a builder to build core.Config from filenames and formats type ConfigBuilder func(files []string, formats []string) (*Config, error) -// ConfigMerger merge multiple json configs into on config +// ConfigsMerger merge multiple json configs into on config type ConfigsMerger func(files []string, formats []string) (string, error) var ( From befa7b8138b7ce8019ab400646a64454a8ba1268 Mon Sep 17 00:00:00 2001 From: Andrej Mihajlov Date: Tue, 16 Apr 2024 11:32:26 +0200 Subject: [PATCH 344/867] Makefile: export GOARCH, GOOS --- Makefile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f69a9b2b..0578fe67 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,15 @@ NAME = xray VERSION=$(shell git describe --always --dirty) +export GOARCH ?= +export GOOS ?= + +ifdef GOARCH + ifeq ($(GOOS),darwin) + NAME:=$(NAME)-$(GOARCH) + endif +endif + LDFLAGS = -X github.com/xtls/xray-core/core.build=$(VERSION) -s -w -buildid= PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v MAIN = ./main @@ -26,4 +35,4 @@ install: clean: go clean -v -i $(PWD) - rm -f xray xray.exe wxray.exe xray_softfloat \ No newline at end of file + rm -f xray xray.exe wxray.exe xray_softfloat From 12f5b05aca8c51524d79ca3d1f6e580395de98d5 Mon Sep 17 00:00:00 2001 From: guangwu Date: Wed, 17 Apr 2024 17:47:47 +0800 Subject: [PATCH 345/867] fix: close resp body --- transport/internet/reality/reality.go | 1 + 1 file changed, 1 insertion(+) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index b8bb881f..5548580c 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -222,6 +222,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati if resp, err = client.Do(req); err != nil { break } + defer resp.Body.Close() req.Header.Set("Referer", req.URL.String()) if body, err = io.ReadAll(resp.Body); err != nil { break From 32f001744905c679c018fb02eb700e280aa58b32 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 17 Apr 2024 21:31:57 -0400 Subject: [PATCH 346/867] Add error log for ws host and path check --- transport/internet/websocket/hub.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index 8a860c30..7889a77f 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -39,10 +39,12 @@ var upgrader = &websocket.Upgrader{ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) { if len(h.host) > 0 && request.Host != h.host { + newError("failed to validate host, request:", request.Host, "config:", h.host).WriteToLog() writer.WriteHeader(http.StatusNotFound) return } if request.URL.Path != h.path { + newError("failed to validate path, request:", request.URL.Path, "config:", h.path).WriteToLog() writer.WriteHeader(http.StatusNotFound) return } From e9eec57b463907528a52b9d1ce3064845c6e0cf8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Apr 2024 00:46:16 +0000 Subject: [PATCH 347/867] Bump github.com/miekg/dns from 1.1.58 to 1.1.59 Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.58 to 1.1.59. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.58...v1.1.59) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 7f6b58fb..e400e8f3 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,13 @@ module github.com/xtls/xray-core go 1.22 require ( + github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 + github.com/cloudflare/circl v1.3.7 github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.6.0 github.com/gorilla/websocket v1.5.1 - github.com/miekg/dns v1.1.58 + github.com/miekg/dns v1.1.59 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.42.0 @@ -30,12 +32,10 @@ require ( gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h12.io/socks v1.0.3 lukechampine.com/blake3 v1.2.2 - github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 ) require ( github.com/andybalholm/brotli v1.1.0 // indirect - github.com/cloudflare/circl v1.3.7 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect github.com/francoispqt/gojay v1.2.13 // indirect diff --git a/go.sum b/go.sum index e3560abd..dc99982a 100644 --- a/go.sum +++ b/go.sum @@ -90,8 +90,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= -github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= -github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= +github.com/miekg/dns v1.1.59 h1:C9EXc/UToRwKLhK5wKU/I4QVsBUc8kE6MkHBkeypWZs= +github.com/miekg/dns v1.1.59/go.mod h1:nZpewl5p6IvctfgrckopVx2OlSEHPRO/U4SYkRklrEk= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= From dd16dcec031d7afd769aee7cb3da1e72e624a2c0 Mon Sep 17 00:00:00 2001 From: writegr Date: Thu, 18 Apr 2024 12:20:07 +0800 Subject: [PATCH 348/867] chore: fix some typos in comments Signed-off-by: writegr --- app/router/config.pb.go | 2 +- app/router/config.proto | 2 +- infra/conf/router_strategy.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/router/config.pb.go b/app/router/config.pb.go index 23aba911..d0da6d14 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -864,7 +864,7 @@ type StrategyLeastLoadConfig struct { Baselines []int64 `protobuf:"varint,3,rep,packed,name=baselines,proto3" json:"baselines,omitempty"` // expected nodes count to select Expected int32 `protobuf:"varint,4,opt,name=expected,proto3" json:"expected,omitempty"` - // max acceptable rtt, filter away high delay nodes. defalut 0 + // max acceptable rtt, filter away high delay nodes. default 0 MaxRTT int64 `protobuf:"varint,5,opt,name=maxRTT,proto3" json:"maxRTT,omitempty"` // acceptable failure rate Tolerance float32 `protobuf:"fixed32,6,opt,name=tolerance,proto3" json:"tolerance,omitempty"` diff --git a/app/router/config.proto b/app/router/config.proto index cff00fad..fdd2e61d 100644 --- a/app/router/config.proto +++ b/app/router/config.proto @@ -147,7 +147,7 @@ message StrategyLeastLoadConfig { repeated int64 baselines = 3; // expected nodes count to select int32 expected = 4; - // max acceptable rtt, filter away high delay nodes. defalut 0 + // max acceptable rtt, filter away high delay nodes. default 0 int64 maxRTT = 5; // acceptable failure rate float tolerance = 6; diff --git a/infra/conf/router_strategy.go b/infra/conf/router_strategy.go index 58367b4a..4d0f647a 100644 --- a/infra/conf/router_strategy.go +++ b/infra/conf/router_strategy.go @@ -38,7 +38,7 @@ type strategyLeastLoadConfig struct { Baselines []duration.Duration `json:"baselines,omitempty"` // expected nodes count to select Expected int32 `json:"expected,omitempty"` - // max acceptable rtt, filter away high delay nodes. defalut 0 + // max acceptable rtt, filter away high delay nodes. default 0 MaxRTT duration.Duration `json:"maxRTT,omitempty"` // acceptable failure rate Tolerance float64 `json:"tolerance,omitempty"` From c85a91bc2991fa98cca345b2f35a92a113effd39 Mon Sep 17 00:00:00 2001 From: X-Oracle <129892464+X-Oracle@users.noreply.github.com> Date: Thu, 18 Apr 2024 11:21:26 +0330 Subject: [PATCH 349/867] fix [ log ]: small fix for better readability. --- transport/internet/websocket/hub.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index 7889a77f..60f07390 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -39,12 +39,12 @@ var upgrader = &websocket.Upgrader{ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request) { if len(h.host) > 0 && request.Host != h.host { - newError("failed to validate host, request:", request.Host, "config:", h.host).WriteToLog() + newError("failed to validate host, request:", request.Host, ", config:", h.host).WriteToLog() writer.WriteHeader(http.StatusNotFound) return } if request.URL.Path != h.path { - newError("failed to validate path, request:", request.URL.Path, "config:", h.path).WriteToLog() + newError("failed to validate path, request:", request.URL.Path, ", config:", h.path).WriteToLog() writer.WriteHeader(http.StatusNotFound) return } From 1593677b090e7e5684d075b43e5cac106621402e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= <45535409+Fangliding@users.noreply.github.com> Date: Sat, 20 Apr 2024 00:07:54 +0800 Subject: [PATCH 350/867] Add issue template. * Add issue template * Do some refine * Add checkbox Refine issue template Refind re --- .github/ISSUE_TEMPLATE/bug_report.yml | 44 ++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/bug_report_zh.yml | 44 ++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/bug_report_zh.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..c8e04a31 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,44 @@ +name: Bug report +description: "Submit Xray-core bug" +body: + - type: checkboxes + attributes: + label: Integrity requirements + description: |- + Please check all of the following options to prove that you have read and understood the requirements, otherwise this issue will be closed. + options: + - label: I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values. + required: true + - label: I searched issues and did not find any similar issues. + required: true + - type: textarea + attributes: + label: Version + description: Xray-core version + render: shell + - type: textarea + attributes: + label: Description + description: Please provide a detailed description of the bug. And information that you consider valuable. + validations: + required: true + - type: textarea + attributes: + label: Reproduction + description: |- + Provide method to reproduce the bug. + Please provide config that can reproduce the problem, including both the server and client. + Do not paste a large exported config here. Removing unnecessary inbounds, outbounds, route rules, and options. This cloud help us locate the problem if you really want to get help. + Even if you are using a GUI/script/panel, please follow the above requirements. + DO NOT just write "I'm using xxx GUI/ xxx panel" instead of providing config. We do not have the energy or obligation to find the software and spend time reproducing according to the description. + validations: + required: true + - type: textarea + attributes: + label: log + description: |- + Set the log level to debug. + Please Restart Xray-core, and then follow the reproduction method to reduce irrelevant parts in log. + Remember to remove personal information such as UUID, IP. + Provid complete log, DO NOT just paste the the parts that you think necessary based on your own judgment. + render: shell \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report_zh.yml b/.github/ISSUE_TEMPLATE/bug_report_zh.yml new file mode 100644 index 00000000..81e262ec --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report_zh.yml @@ -0,0 +1,44 @@ +name: bug反馈 +description: "提交 Xray-core bug" +body: + - type: checkboxes + attributes: + label: 完整性要求 + description: |- + 请勾选以下所有选项以证明您已经阅读并理解了以下要求,否则该 issue 将被关闭。 + options: + - label: 我保证阅读了文档,了解所有我编写的配置文件项的含义,而不是大量堆砌看似有用的选项或默认值。 + required: true + - label: 我搜索了issues,没有发现已提出的类似问题。 + required: true + - type: textarea + attributes: + label: 版本 + description: 使用的Xray-core版本 + render: shell + - type: textarea + attributes: + label: 描述 + description: 请提供错误的详细描述。以及你认为有价值的信息。 + validations: + required: true + - type: textarea + attributes: + label: 重现方式 + description: |- + 提供重现BUG方法。 + 请提供可以重现问题的配置文件,包括服务端和客户端 + 不要直接在这里黏贴一大段导出的 config 文件。去掉无用的出入站、规则、选项,这可以帮助确定问题,如果你真的想得到帮助。 + 即使你在使用图形客户端/脚本/面板,也请遵照上述要求。 + 不要直接用“我使用xxx客户端/xxx面板”替代config,我们没有精力也没有义务去找到项目再花时间按描述重新问题。 + validations: + required: true + - type: textarea + attributes: + label: 日志 + description: |- + 请先将日志等级设置为 debug. + 重启 Xray-core ,再按复现方式操作,尽量减少日志中的无关部分。 + 记得删除有关个人信息(如UUID与IP)的部分。 + 提供完整的日志,不要仅提供你自己觉得有用的部分。 + render: shell \ No newline at end of file From b356b353126f114c0c4e8f989db26b67316b43a3 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 21 Apr 2024 11:46:56 -0400 Subject: [PATCH 351/867] Update latest compatible gvisor https://deps.dev/go/gvisor.dev%2Fgvisor/ --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e400e8f3..794ef9c9 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.63.2 google.golang.org/protobuf v1.33.0 - gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b + gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.2.2 ) diff --git a/go.sum b/go.sum index dc99982a..c36fd3ea 100644 --- a/go.sum +++ b/go.sum @@ -294,8 +294,8 @@ gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= -gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b h1:yqkg3pTifuKukuWanp8spDsL4irJkHF5WI0J47hU87o= -gvisor.dev/gvisor v0.0.0-20231104011432-48a6d7d5bd0b/go.mod h1:10sU+Uh5KKNv1+2x2A0Gvzt8FjD3ASIhorV3YsauXhk= +gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h1:ze1vwAdliUAr68RQ5NtufWaXaOg8WUO2OACzEV+TNdE= +gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489/go.mod h1:10sU+Uh5KKNv1+2x2A0Gvzt8FjD3ASIhorV3YsauXhk= h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo= h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= From 080bd8241c4046dc6c8fb59fc92ccea33c482768 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 21 Apr 2024 19:43:27 +0000 Subject: [PATCH 352/867] Fix https://github.com/XTLS/Xray-core/issues/3288 --- transport/internet/reality/reality.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 5548580c..0cc6950d 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -206,6 +206,9 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati req, _ = http.NewRequest("GET", string(prefix)+getPathLocked(paths), nil) maps.Unlock() } + if req == nil { + return + } req.Header.Set("User-Agent", fingerprint.Client) // TODO: User-Agent map if first && config.Show { newError(fmt.Sprintf("REALITY localAddr: %v\treq.UserAgent(): %v\n", localAddr, req.UserAgent())).WriteToLog(session.ExportIDToError(ctx)) From ae0eec41d8ddc805b38e159bec7eefdd54c96d8a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Apr 2024 00:22:54 +0000 Subject: [PATCH 353/867] Bump github.com/cloudflare/circl from 1.3.7 to 1.3.8 Bumps [github.com/cloudflare/circl](https://github.com/cloudflare/circl) from 1.3.7 to 1.3.8. - [Release notes](https://github.com/cloudflare/circl/releases) - [Commits](https://github.com/cloudflare/circl/compare/v1.3.7...v1.3.8) --- updated-dependencies: - dependency-name: github.com/cloudflare/circl dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 794ef9c9..91c1ef00 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 - github.com/cloudflare/circl v1.3.7 + github.com/cloudflare/circl v1.3.8 github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.6.0 diff --git a/go.sum b/go.sum index c36fd3ea..6d793b16 100644 --- a/go.sum +++ b/go.sum @@ -17,8 +17,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= -github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= +github.com/cloudflare/circl v1.3.8 h1:j+V8jJt09PoeMFIu2uh5JUyEaIHTXVOHslFoLNAKqwI= +github.com/cloudflare/circl v1.3.8/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From 61800fcc66fbff0c9bd80fc564aa6cf14a3585d7 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 26 Apr 2024 02:27:22 +0000 Subject: [PATCH 354/867] Revert "nosni" https://github.com/XTLS/Xray-core/pull/3214#issuecomment-2078502477 --- transport/internet/reality/reality.go | 2 -- transport/internet/tls/config.go | 5 ----- 2 files changed, 7 deletions(-) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 0cc6950d..011bb907 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -116,8 +116,6 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati } if utlsConfig.ServerName == "" { utlsConfig.ServerName = dest.Address.String() - } else if strings.ToLower(utlsConfig.ServerName) == "nosni" { // If ServerName is set to "nosni", we set it empty. - utlsConfig.ServerName = "" } uConn.ServerName = utlsConfig.ServerName fingerprint := tls.GetFingerprint(config.Fingerprint) diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 36aca803..9d9289c3 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -325,11 +325,6 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { config.ServerName = sn } - // If ServerName is set to "nosni", we set it empty. - if strings.ToLower(c.parseServerName()) == "nosni" { - config.ServerName = "" - } - if len(config.NextProtos) == 0 { config.NextProtos = []string{"h2", "http/1.1"} } From 8ce2a0e245cbcde9aed41b4a4436f37a0052e53b Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Fri, 26 Apr 2024 05:19:25 +0200 Subject: [PATCH 355/867] Validate /websocket requests from browser dialer page (#3295) Fixes https://github.com/XTLS/Xray-core/issues/3236 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- transport/internet/websocket/dialer.go | 15 +++++++++++---- transport/internet/websocket/dialer.html | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/transport/internet/websocket/dialer.go b/transport/internet/websocket/dialer.go index 4ef27831..20161688 100644 --- a/transport/internet/websocket/dialer.go +++ b/transport/internet/websocket/dialer.go @@ -1,6 +1,7 @@ package websocket import ( + "bytes" "context" _ "embed" "encoding/base64" @@ -14,6 +15,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/platform" "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" @@ -27,13 +29,18 @@ var conns chan *websocket.Conn func init() { addr := platform.NewEnvFlag(platform.BrowserDialerAddress).GetValue(func() string { return "" }) if addr != "" { + token := uuid.New() + csrfToken := token.String() + webpage = bytes.ReplaceAll(webpage, []byte("csrfToken"), []byte(csrfToken)) conns = make(chan *websocket.Conn, 256) go http.ListenAndServe(addr, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if r.URL.Path == "/websocket" { - if conn, err := upgrader.Upgrade(w, r, nil); err == nil { - conns <- conn - } else { - newError("Browser dialer http upgrade unexpected error").AtError().WriteToLog() + if r.URL.Query().Get("token") == csrfToken { + if conn, err := upgrader.Upgrade(w, r, nil); err == nil { + conns <- conn + } else { + newError("Browser dialer http upgrade unexpected error").AtError().WriteToLog() + } } } else { w.Write(webpage) diff --git a/transport/internet/websocket/dialer.html b/transport/internet/websocket/dialer.html index c141379d..7831225c 100644 --- a/transport/internet/websocket/dialer.html +++ b/transport/internet/websocket/dialer.html @@ -6,7 +6,7 @@ + + diff --git a/transport/internet/splithttp/browser_client.go b/transport/internet/splithttp/browser_client.go new file mode 100644 index 00000000..8a23682e --- /dev/null +++ b/transport/internet/splithttp/browser_client.go @@ -0,0 +1,39 @@ +package splithttp + +import ( + "context" + "io" + "io/ioutil" + gonet "net" + + "github.com/xtls/xray-core/transport/internet/browser_dialer" + "github.com/xtls/xray-core/transport/internet/websocket" +) + +// implements splithttp.DialerClient in terms of browser dialer +// has no fields because everything is global state :O) +type BrowserDialerClient struct{} + +func (c *BrowserDialerClient) OpenDownload(ctx context.Context, baseURL string) (io.ReadCloser, gonet.Addr, gonet.Addr, error) { + conn, err := browser_dialer.DialGet(baseURL) + dummyAddr := &gonet.IPAddr{} + if err != nil { + return nil, dummyAddr, dummyAddr, err + } + + return websocket.NewConnection(conn, dummyAddr, nil), conn.RemoteAddr(), conn.LocalAddr(), nil +} + +func (c *BrowserDialerClient) SendUploadRequest(ctx context.Context, url string, payload io.ReadWriteCloser, contentLength int64) error { + bytes, err := ioutil.ReadAll(payload) + if err != nil { + return err + } + + err = browser_dialer.DialPost(url, bytes) + if err != nil { + return err + } + + return nil +} diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go new file mode 100644 index 00000000..dd48ee6d --- /dev/null +++ b/transport/internet/splithttp/client.go @@ -0,0 +1,169 @@ +package splithttp + +import ( + "bytes" + "context" + "io" + gonet "net" + "net/http" + "net/http/httptrace" + "sync" + + "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/common/signal/done" +) + +// interface to abstract between use of browser dialer, vs net/http +type DialerClient interface { + // (ctx, baseURL, payload) -> err + // baseURL already contains sessionId and seq + SendUploadRequest(context.Context, string, io.ReadWriteCloser, int64) error + + // (ctx, baseURL) -> (downloadReader, remoteAddr, localAddr) + // baseURL already contains sessionId + OpenDownload(context.Context, string) (io.ReadCloser, net.Addr, net.Addr, error) +} + +// implements splithttp.DialerClient in terms of direct network connections +type DefaultDialerClient struct { + transportConfig *Config + download *http.Client + upload *http.Client + isH2 bool + // pool of net.Conn, created using dialUploadConn + uploadRawPool *sync.Pool + dialUploadConn func(ctxInner context.Context) (net.Conn, error) +} + +func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) (io.ReadCloser, gonet.Addr, gonet.Addr, error) { + var remoteAddr gonet.Addr + var localAddr gonet.Addr + // this is done when the TCP/UDP connection to the server was established, + // and we can unblock the Dial function and print correct net addresses in + // logs + gotConn := done.New() + + var downResponse io.ReadCloser + gotDownResponse := done.New() + + go func() { + trace := &httptrace.ClientTrace{ + GotConn: func(connInfo httptrace.GotConnInfo) { + remoteAddr = connInfo.Conn.RemoteAddr() + localAddr = connInfo.Conn.LocalAddr() + gotConn.Close() + }, + } + + // in case we hit an error, we want to unblock this part + defer gotConn.Close() + + req, err := http.NewRequestWithContext( + httptrace.WithClientTrace(ctx, trace), + "GET", + baseURL, + nil, + ) + if err != nil { + errors.LogInfoInner(ctx, err, "failed to construct download http request") + gotDownResponse.Close() + return + } + + req.Header = c.transportConfig.GetRequestHeader() + + response, err := c.download.Do(req) + gotConn.Close() + if err != nil { + errors.LogInfoInner(ctx, err, "failed to send download http request") + gotDownResponse.Close() + return + } + + if response.StatusCode != 200 { + response.Body.Close() + errors.LogInfo(ctx, "invalid status code on download:", response.Status) + gotDownResponse.Close() + return + } + + downResponse = response.Body + gotDownResponse.Close() + }() + + // we want to block Dial until we know the remote address of the server, + // for logging purposes + <-gotConn.Wait() + + lazyDownload := &LazyReader{ + CreateReader: func() (io.ReadCloser, error) { + <-gotDownResponse.Wait() + if downResponse == nil { + return nil, errors.New("downResponse failed") + } + return downResponse, nil + }, + } + + return lazyDownload, remoteAddr, localAddr, nil +} + +func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, payload io.ReadWriteCloser, contentLength int64) error { + req, err := http.NewRequest("POST", url, payload) + req.ContentLength = contentLength + if err != nil { + return err + } + req.Header = c.transportConfig.GetRequestHeader() + + if c.isH2 { + resp, err := c.upload.Do(req) + if err != nil { + return err + } + + defer resp.Body.Close() + + if resp.StatusCode != 200 { + return errors.New("bad status code:", resp.Status) + } + } else { + // stringify the entire HTTP/1.1 request so it can be + // safely retried. if instead req.Write is called multiple + // times, the body is already drained after the first + // request + requestBytes := new(bytes.Buffer) + common.Must(req.Write(requestBytes)) + + var uploadConn any + + for { + uploadConn = c.uploadRawPool.Get() + newConnection := uploadConn == nil + if newConnection { + uploadConn, err = c.dialUploadConn(context.WithoutCancel(ctx)) + if err != nil { + return err + } + } + + _, err = uploadConn.(net.Conn).Write(requestBytes.Bytes()) + + // if the write failed, we try another connection from + // the pool, until the write on a new connection fails. + // failed writes to a pooled connection are normal when + // the connection has been closed in the meantime. + if err == nil { + break + } else if newConnection { + return err + } + } + + c.uploadRawPool.Put(uploadConn) + } + + return nil +} diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 1a927a49..3a7ce641 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -1,13 +1,10 @@ package splithttp import ( - "bytes" "context" gotls "crypto/tls" "io" - gonet "net" "net/http" - "net/http/httptrace" "net/url" "strconv" "sync" @@ -17,10 +14,10 @@ import ( "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" - "github.com/xtls/xray-core/common/signal/done" "github.com/xtls/xray-core/common/signal/semaphore" "github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/browser_dialer" "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/pipe" @@ -32,32 +29,31 @@ type dialerConf struct { *internet.MemoryStreamConfig } -type reusedClient struct { - download *http.Client - upload *http.Client - isH2 bool - // pool of net.Conn, created using dialUploadConn - uploadRawPool *sync.Pool - dialUploadConn func(ctxInner context.Context) (net.Conn, error) -} - var ( - globalDialerMap map[dialerConf]reusedClient + globalDialerMap map[dialerConf]DialerClient globalDialerAccess sync.Mutex ) -func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) reusedClient { +func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) DialerClient { + if browser_dialer.HasBrowserDialer() { + return &BrowserDialerClient{} + } + globalDialerAccess.Lock() defer globalDialerAccess.Unlock() if globalDialerMap == nil { - globalDialerMap = make(map[dialerConf]reusedClient) + globalDialerMap = make(map[dialerConf]DialerClient) } if client, found := globalDialerMap[dialerConf{dest, streamSettings}]; found { return client } + if browser_dialer.HasBrowserDialer() { + return &BrowserDialerClient{} + } + tlsConfig := tls.ConfigFromStreamSettings(streamSettings) isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") @@ -116,7 +112,8 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in uploadTransport = nil } - client := reusedClient{ + client := &DefaultDialerClient{ + transportConfig: streamSettings.ProtocolSettings.(*Config), download: &http.Client{ Transport: downloadTransport, }, @@ -160,80 +157,9 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me httpClient := getHTTPClient(ctx, dest, streamSettings) - var remoteAddr gonet.Addr - var localAddr gonet.Addr - // this is done when the TCP/UDP connection to the server was established, - // and we can unblock the Dial function and print correct net addresses in - // logs - gotConn := done.New() - - var downResponse io.ReadCloser - gotDownResponse := done.New() - sessionIdUuid := uuid.New() sessionId := sessionIdUuid.String() - - go func() { - trace := &httptrace.ClientTrace{ - GotConn: func(connInfo httptrace.GotConnInfo) { - remoteAddr = connInfo.Conn.RemoteAddr() - localAddr = connInfo.Conn.LocalAddr() - gotConn.Close() - }, - } - - // in case we hit an error, we want to unblock this part - defer gotConn.Close() - - req, err := http.NewRequestWithContext( - httptrace.WithClientTrace(context.WithoutCancel(ctx), trace), - "GET", - requestURL.String()+sessionId, - nil, - ) - if err != nil { - errors.LogInfoInner(ctx, err, "failed to construct download http request") - gotDownResponse.Close() - return - } - - req.Header = transportConfiguration.GetRequestHeader() - - response, err := httpClient.download.Do(req) - gotConn.Close() - if err != nil { - errors.LogInfoInner(ctx, err, "failed to send download http request") - gotDownResponse.Close() - return - } - - if response.StatusCode != 200 { - response.Body.Close() - errors.LogInfo(ctx, "invalid status code on download:", response.Status) - gotDownResponse.Close() - return - } - - // skip "ooooooooook" response - trashHeader := []byte{0} - for { - _, err = io.ReadFull(response.Body, trashHeader) - if err != nil { - response.Body.Close() - errors.LogInfoInner(ctx, err, "failed to read initial response") - gotDownResponse.Close() - return - } - if trashHeader[0] == 'k' { - break - } - } - - downResponse = response.Body - gotDownResponse.Close() - }() - - uploadUrl := requestURL.String() + sessionId + "/" + baseURL := requestURL.String() + sessionId uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize)) @@ -252,97 +178,55 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me <-requestsLimiter.Wait() - url := uploadUrl + strconv.FormatInt(requestCounter, 10) + seq := requestCounter requestCounter += 1 go func() { defer requestsLimiter.Signal() - req, err := http.NewRequest("POST", url, &buf.MultiBufferContainer{MultiBuffer: chunk}) + + err := httpClient.SendUploadRequest( + context.WithoutCancel(ctx), + baseURL+"/"+strconv.FormatInt(seq, 10), + &buf.MultiBufferContainer{MultiBuffer: chunk}, + int64(chunk.Len()), + ) + if err != nil { errors.LogInfoInner(ctx, err, "failed to send upload") uploadPipeReader.Interrupt() - return - } - - req.ContentLength = int64(chunk.Len()) - req.Header = transportConfiguration.GetRequestHeader() - - if httpClient.isH2 { - resp, err := httpClient.upload.Do(req) - if err != nil { - errors.LogInfoInner(ctx, err, "failed to send upload") - uploadPipeReader.Interrupt() - return - } - defer resp.Body.Close() - - if resp.StatusCode != 200 { - errors.LogInfo(ctx, "failed to send upload, bad status code:", resp.Status) - uploadPipeReader.Interrupt() - return - } - } else { - var uploadConn any - - // stringify the entire HTTP/1.1 request so it can be - // safely retried. if instead req.Write is called multiple - // times, the body is already drained after the first - // request - requestBytes := new(bytes.Buffer) - common.Must(req.Write(requestBytes)) - - for { - uploadConn = httpClient.uploadRawPool.Get() - newConnection := uploadConn == nil - if newConnection { - uploadConn, err = httpClient.dialUploadConn(context.WithoutCancel(ctx)) - if err != nil { - errors.LogInfoInner(ctx, err, "failed to connect upload") - uploadPipeReader.Interrupt() - return - } - } - - _, err = uploadConn.(net.Conn).Write(requestBytes.Bytes()) - - // if the write failed, we try another connection from - // the pool, until the write on a new connection fails. - // failed writes to a pooled connection are normal when - // the connection has been closed in the meantime. - if err == nil { - break - } else if newConnection { - errors.LogInfoInner(ctx, err, "failed to send upload") - uploadPipeReader.Interrupt() - return - } - } - - httpClient.uploadRawPool.Put(uploadConn) } }() } }() - // we want to block Dial until we know the remote address of the server, - // for logging purposes - <-gotConn.Wait() + lazyRawDownload, remoteAddr, localAddr, err := httpClient.OpenDownload(context.WithoutCancel(ctx), baseURL) + if err != nil { + return nil, err + } + + lazyDownload := &LazyReader{ + CreateReader: func() (io.ReadCloser, error) { + // skip "ooooooooook" response + trashHeader := []byte{0} + for { + _, err := io.ReadFull(lazyRawDownload, trashHeader) + if err != nil { + return nil, errors.New("failed to read initial response").Base(err) + } + if trashHeader[0] == 'k' { + break + } + } + + return lazyRawDownload, nil + }, + } // necessary in order to send larger chunks in upload bufferedUploadPipeWriter := buf.NewBufferedWriter(uploadPipeWriter) bufferedUploadPipeWriter.SetBuffered(false) - lazyDownload := &LazyReader{ - CreateReader: func() (io.ReadCloser, error) { - <-gotDownResponse.Wait() - if downResponse == nil { - return nil, errors.New("downResponse failed") - } - return downResponse, nil - }, - } - conn := splitConn{ writer: bufferedUploadPipeWriter, reader: lazyDownload, diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index f71709ed..27fab68d 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -32,7 +32,7 @@ type requestHandler struct { } type httpSession struct { - uploadQueue *UploadQueue + uploadQueue *uploadQueue // for as long as the GET request is not opened by the client, this will be // open ("undone"), and the session may be expired within a certain TTL. // after the client connects, this becomes "done" and the session lives as @@ -163,7 +163,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req writer.Header().Set("X-Accel-Buffering", "no") // magic header to make the HTTP middle box consider this as SSE to disable buffer writer.Header().Set("Content-Type", "text/event-stream") - + writer.WriteHeader(http.StatusOK) // send a chunk immediately to enable CDN streaming. // many CDN buffer the response headers until the origin starts sending diff --git a/transport/internet/splithttp/upload_queue.go b/transport/internet/splithttp/upload_queue.go index 4737b811..2d1fb5f4 100644 --- a/transport/internet/splithttp/upload_queue.go +++ b/transport/internet/splithttp/upload_queue.go @@ -15,7 +15,7 @@ type Packet struct { Seq uint64 } -type UploadQueue struct { +type uploadQueue struct { pushedPackets chan Packet heap uploadHeap nextSeq uint64 @@ -23,8 +23,8 @@ type UploadQueue struct { maxPackets int } -func NewUploadQueue(maxPackets int) *UploadQueue { - return &UploadQueue{ +func NewUploadQueue(maxPackets int) *uploadQueue { + return &uploadQueue{ pushedPackets: make(chan Packet, maxPackets), heap: uploadHeap{}, nextSeq: 0, @@ -33,7 +33,7 @@ func NewUploadQueue(maxPackets int) *UploadQueue { } } -func (h *UploadQueue) Push(p Packet) error { +func (h *uploadQueue) Push(p Packet) error { if h.closed { return errors.New("splithttp packet queue closed") } @@ -42,13 +42,13 @@ func (h *UploadQueue) Push(p Packet) error { return nil } -func (h *UploadQueue) Close() error { +func (h *uploadQueue) Close() error { h.closed = true close(h.pushedPackets) return nil } -func (h *UploadQueue) Read(b []byte) (int, error) { +func (h *uploadQueue) Read(b []byte) (int, error) { if h.closed { return 0, io.EOF } diff --git a/transport/internet/websocket/connection.go b/transport/internet/websocket/connection.go index 395c2f01..0bb5dd7b 100644 --- a/transport/internet/websocket/connection.go +++ b/transport/internet/websocket/connection.go @@ -15,16 +15,14 @@ var _ buf.Writer = (*connection)(nil) // connection is a wrapper for net.Conn over WebSocket connection. type connection struct { - conn *websocket.Conn - reader io.Reader - remoteAddr net.Addr + conn *websocket.Conn + reader io.Reader } -func newConnection(conn *websocket.Conn, remoteAddr net.Addr, extraReader io.Reader) *connection { +func NewConnection(conn *websocket.Conn, remoteAddr net.Addr, extraReader io.Reader) *connection { return &connection{ - conn: conn, - remoteAddr: remoteAddr, - reader: extraReader, + conn: conn, + reader: extraReader, } } @@ -92,7 +90,7 @@ func (c *connection) LocalAddr() net.Addr { } func (c *connection) RemoteAddr() net.Addr { - return c.remoteAddr + return c.conn.RemoteAddr() } func (c *connection) SetDeadline(t time.Time) error { diff --git a/transport/internet/websocket/dialer.go b/transport/internet/websocket/dialer.go index 7003928b..aa15c1a6 100644 --- a/transport/internet/websocket/dialer.go +++ b/transport/internet/websocket/dialer.go @@ -1,54 +1,23 @@ package websocket import ( - "bytes" "context" _ "embed" "encoding/base64" "io" gonet "net" - "net/http" "time" "github.com/gorilla/websocket" "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/common/platform" - "github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/browser_dialer" "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" ) -//go:embed dialer.html -var webpage []byte - -var conns chan *websocket.Conn - -func init() { - addr := platform.NewEnvFlag(platform.BrowserDialerAddress).GetValue(func() string { return "" }) - if addr != "" { - token := uuid.New() - csrfToken := token.String() - webpage = bytes.ReplaceAll(webpage, []byte("csrfToken"), []byte(csrfToken)) - conns = make(chan *websocket.Conn, 256) - go http.ListenAndServe(addr, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.URL.Path == "/websocket" { - if r.URL.Query().Get("token") == csrfToken { - if conn, err := upgrader.Upgrade(w, r, nil); err == nil { - conns <- conn - } else { - errors.LogError(context.Background(), "Browser dialer http upgrade unexpected error") - } - } - } else { - w.Write(webpage) - } - })) - } -} - // Dial dials a WebSocket connection to the given destination. func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) { errors.LogInfo(ctx, "creating connection to ", dest) @@ -98,18 +67,18 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in // Like the NetDial in the dialer pconn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) if err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to " + addr) + errors.LogErrorInner(ctx, err, "failed to dial to "+addr) return nil, err } // TLS and apply the handshake cn := tls.UClient(pconn, tlsConfig, fingerprint).(*tls.UConn) if err := cn.WebsocketHandshakeContext(ctx); err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to " + addr) + errors.LogErrorInner(ctx, err, "failed to dial to "+addr) return nil, err } if !tlsConfig.InsecureSkipVerify { if err := cn.VerifyHostname(tlsConfig.ServerName); err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to " + addr) + errors.LogErrorInner(ctx, err, "failed to dial to "+addr) return nil, err } } @@ -124,28 +93,13 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in } uri := protocol + "://" + host + wsSettings.GetNormalizedPath() - if conns != nil { - data := []byte(uri) - if ed != nil { - data = append(data, " "+base64.RawURLEncoding.EncodeToString(ed)...) - } - var conn *websocket.Conn - for { - conn = <-conns - if conn.WriteMessage(websocket.TextMessage, data) != nil { - conn.Close() - } else { - break - } - } - if _, p, err := conn.ReadMessage(); err != nil { - conn.Close() + if browser_dialer.HasBrowserDialer() { + conn, err := browser_dialer.DialWS(uri, ed) + if err != nil { return nil, err - } else if s := string(p); s != "ok" { - conn.Close() - return nil, errors.New(s) } - return newConnection(conn, conn.RemoteAddr(), nil), nil + + return NewConnection(conn, conn.RemoteAddr(), nil), nil } header := wsSettings.GetRequestHeader() @@ -163,7 +117,7 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in return nil, errors.New("failed to dial to (", uri, "): ", reason).Base(err) } - return newConnection(conn, conn.RemoteAddr(), nil), nil + return NewConnection(conn, conn.RemoteAddr(), nil), nil } type delayDialConn struct { diff --git a/transport/internet/websocket/dialer.html b/transport/internet/websocket/dialer.html deleted file mode 100644 index 39b14441..00000000 --- a/transport/internet/websocket/dialer.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - Browser Dialer - - - - - diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index 6d363a68..6e07d9a0 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -73,7 +73,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } } - h.ln.addConn(newConnection(conn, remoteAddr, extraReader)) + h.ln.addConn(NewConnection(conn, remoteAddr, extraReader)) } type Listener struct { From 73a001dd7a07e51e1a46d3948a6488c16e6f5c54 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 11 Jul 2024 12:02:49 +0000 Subject: [PATCH 433/867] Upgrade github.com/xtls/reality to 20240711105359 Fixes https://github.com/XTLS/Xray-core/issues/3502 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4cb95d9a..14f57eb6 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 - github.com/xtls/reality v0.0.0-20240429224917-ecc4401070cc + github.com/xtls/reality v0.0.0-20240711105359-4dbe0df83874 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.25.0 golang.org/x/net v0.27.0 diff --git a/go.sum b/go.sum index 39be0ddc..b08f8b71 100644 --- a/go.sum +++ b/go.sum @@ -163,8 +163,8 @@ github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3/go.mo github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/reality v0.0.0-20240429224917-ecc4401070cc h1:0Nj8T1n7F7+v4vRVroaJIvY6R0vNABLfPH+lzPHRJvI= -github.com/xtls/reality v0.0.0-20240429224917-ecc4401070cc/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= +github.com/xtls/reality v0.0.0-20240711105359-4dbe0df83874 h1:Y6YuIN3XH/x+klNP7C/BfY2EUJzqXyNkQNfqGa+OCS4= +github.com/xtls/reality v0.0.0-20240711105359-4dbe0df83874/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= From c69d38ae825520a345392b3b29ff5b736f94c497 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Thu, 11 Jul 2024 13:31:26 -0500 Subject: [PATCH 434/867] add link to discussions --- .github/ISSUE_TEMPLATE/config.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..8fe9cb8e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,4 @@ +contact_links: + - name: Community Support and Questions + url: https://github.com/XTLS/Xray-core/discussions + about: Please ask and answer questions there. The issue tracker is for issues with core. From 16de0937a82b936e267c8c7437ba192c2b31f2f3 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Fri, 12 Jul 2024 00:20:06 +0200 Subject: [PATCH 435/867] Fix typos (#3527) --- .github/workflows/release.yml | 2 +- Makefile | 4 +-- app/dns/nameserver.go | 2 +- app/dns/nameserver_doh.go | 2 +- app/log/log.go | 4 +-- app/observatory/burst/healthping.go | 2 +- app/router/command/command_test.go | 2 +- app/stats/channel_test.go | 2 +- app/stats/counter_test.go | 2 +- common/buf/multi_buffer_test.go | 4 +-- common/buf/reader.go | 6 ++-- common/net/cnc/connection.go | 4 +-- common/platform/windows.go | 2 +- common/protocol/tls/cert/cert.go | 2 +- common/protocol/tls/sniff_test.go | 2 +- common/protocol/user.pb.go | 2 +- common/protocol/user.proto | 2 +- common/session/context.go | 30 ++++++++++---------- common/signal/timer_test.go | 2 +- core/config.go | 2 +- main/commands/base/env.go | 2 +- main/json/json.go | 2 +- main/toml/toml.go | 2 +- main/yaml/yaml.go | 2 +- proxy/proxy.go | 4 +-- proxy/socks/config.pb.go | 2 +- proxy/socks/config.proto | 2 +- proxy/socks/protocol_test.go | 2 +- proxy/socks/udpfilter.go | 2 +- proxy/trojan/client.go | 2 +- proxy/vless/inbound/inbound.go | 16 +++++------ proxy/vless/outbound/outbound.go | 6 ++-- transport/internet/domainsocket/config.pb.go | 2 +- transport/internet/domainsocket/config.proto | 2 +- transport/internet/headers/http/config.pb.go | 2 +- transport/internet/headers/http/config.proto | 2 +- transport/internet/httpupgrade/connection.go | 8 +++--- transport/internet/memory_settings.go | 2 +- transport/internet/tcp_hub.go | 2 +- 39 files changed, 72 insertions(+), 72 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9a9a30c5..a2b9da73 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -83,7 +83,7 @@ jobs: - goarch: 386 goos: darwin include: - # BEIGIN MacOS ARM64 + # BEGIN MacOS ARM64 - goos: darwin goarch: arm64 # END MacOS ARM64 diff --git a/Makefile b/Makefile index e6c13953..7653e306 100644 --- a/Makefile +++ b/Makefile @@ -3,13 +3,13 @@ NAME = xray VERSION=$(shell git describe --always --dirty) # NOTE: This MAKEFILE can be used to build Xray-core locally and in Automatic workflows. It is \ - provided for convinience in automatic building and functions as a part of it. + provided for convenience in automatic building and functions as a part of it. # NOTE: If you need to modify this file, please be aware that:\ - This file is not the main Makefile; it only accepts environment variables and builds the \ binary.\ - Automatic building expects the correct binaries to be built by this Makefile. If you \ intend to propose a change to this Makefile, carefully review the file below and ensure \ - that the change will not accidently break the automatic building:\ + that the change will not accidentally break the automatic building:\ .github/workflows/release.yml \ Otherwise it is recommended to contact the project maintainers. diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index 52ab7a91..c7ff8a84 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -85,7 +85,7 @@ func NewClient( return errors.New("failed to create nameserver").Base(err).AtWarning() } - // Priotize local domains with specific TLDs or without any dot to local DNS + // Prioritize local domains with specific TLDs or those without any dot for the local DNS if _, isLocalDNS := server.(*LocalNameServer); isLocalDNS { ns.PrioritizedDomain = append(ns.PrioritizedDomain, localTLDsAndDotlessDomains...) ns.OriginalRules = append(ns.OriginalRules, localTLDsAndDotlessDomainsRule) diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index 01e7ede1..d34709e9 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -259,7 +259,7 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, clientIP n }) // forced to use mux for DOH - // dnsCtx = session.ContextWithMuxPrefered(dnsCtx, true) + // dnsCtx = session.ContextWithMuxPreferred(dnsCtx, true) var cancel context.CancelFunc dnsCtx, cancel = context.WithDeadline(dnsCtx, deadline) diff --git a/app/log/log.go b/app/log/log.go index 88bac44f..098fe631 100644 --- a/app/log/log.go +++ b/app/log/log.go @@ -30,8 +30,8 @@ func New(ctx context.Context, config *Config) (*Instance, error) { } log.RegisterHandler(g) - // start logger instantly on inited - // other modules would log during init + // Start logger instantly on initialization + // Other modules would log during initialization if err := g.startInternal(); err != nil { return nil, err } diff --git a/app/observatory/burst/healthping.go b/app/observatory/burst/healthping.go index 34690f58..41d5e754 100644 --- a/app/observatory/burst/healthping.go +++ b/app/observatory/burst/healthping.go @@ -209,7 +209,7 @@ func (h *HealthPing) PutResult(tag string, rtt time.Duration) { if !ok { // validity is 2 times to sampling period, since the check are // distributed in the time line randomly, in extreme cases, - // previous checks are distributed on the left, and latters + // Previous checks are distributed on the left, and later ones // on the right validity := h.Settings.Interval * time.Duration(h.Settings.SamplingCount) * 2 r = NewHealthPingResult(h.Settings.SamplingCount, validity) diff --git a/app/router/command/command_test.go b/app/router/command/command_test.go index 096e90ee..e8329695 100644 --- a/app/router/command/command_test.go +++ b/app/router/command/command_test.go @@ -272,7 +272,7 @@ func TestServiceSubscribeSubsetOfFields(t *testing.T) { } } -func TestSerivceTestRoute(t *testing.T) { +func TestServiceTestRoute(t *testing.T) { c := stats.NewChannel(&stats.ChannelConfig{ SubscriberLimit: 1, BufferSize: 16, diff --git a/app/stats/channel_test.go b/app/stats/channel_test.go index 75764f0b..ccae8269 100644 --- a/app/stats/channel_test.go +++ b/app/stats/channel_test.go @@ -95,7 +95,7 @@ func TestStatsChannel(t *testing.T) { } } -func TestStatsChannelUnsubcribe(t *testing.T) { +func TestStatsChannelUnsubscribe(t *testing.T) { c := NewChannel(&ChannelConfig{Blocking: true}) common.Must(c.Start()) defer c.Close() diff --git a/app/stats/counter_test.go b/app/stats/counter_test.go index 81106468..d7086540 100644 --- a/app/stats/counter_test.go +++ b/app/stats/counter_test.go @@ -18,7 +18,7 @@ func TestStatsCounter(t *testing.T) { common.Must(err) if v := c.Add(1); v != 1 { - t.Fatal("unpexcted Add(1) return: ", v, ", wanted ", 1) + t.Fatal("unexpected Add(1) return: ", v, ", wanted ", 1) } if v := c.Set(0); v != 1 { diff --git a/common/buf/multi_buffer_test.go b/common/buf/multi_buffer_test.go index 4f9499af..2b83a548 100644 --- a/common/buf/multi_buffer_test.go +++ b/common/buf/multi_buffer_test.go @@ -106,7 +106,7 @@ func TestMultiBufferReadAllToByte(t *testing.T) { common.Must(err) if l := len(b); l != 8*1024 { - t.Error("unexpceted length from ReadAllToBytes", l) + t.Error("unexpected length from ReadAllToBytes", l) } } { @@ -139,7 +139,7 @@ func TestMultiBufferCopy(t *testing.T) { mb.Copy(lbdst) if d := cmp.Diff(lb, lbdst); d != "" { - t.Error("unexpceted different from MultiBufferCopy ", d) + t.Error("unexpected different from MultiBufferCopy ", d) } } diff --git a/common/buf/reader.go b/common/buf/reader.go index c6c50274..33d362d4 100644 --- a/common/buf/reader.go +++ b/common/buf/reader.go @@ -41,8 +41,8 @@ type BufferedReader struct { Reader Reader // Buffer is the internal buffer to be read from first Buffer MultiBuffer - // Spliter is a function to read bytes from MultiBuffer - Spliter func(MultiBuffer, []byte) (MultiBuffer, int) + // Splitter is a function to read bytes from MultiBuffer + Splitter func(MultiBuffer, []byte) (MultiBuffer, int) } // BufferedBytes returns the number of bytes that is cached in this reader. @@ -59,7 +59,7 @@ func (r *BufferedReader) ReadByte() (byte, error) { // Read implements io.Reader. It reads from internal buffer first (if available) and then reads from the underlying reader. func (r *BufferedReader) Read(b []byte) (int, error) { - spliter := r.Spliter + spliter := r.Splitter if spliter == nil { spliter = SplitBytes } diff --git a/common/net/cnc/connection.go b/common/net/cnc/connection.go index 42b632e7..bdae5409 100644 --- a/common/net/cnc/connection.go +++ b/common/net/cnc/connection.go @@ -51,8 +51,8 @@ func ConnectionOutputMulti(reader buf.Reader) ConnectionOption { func ConnectionOutputMultiUDP(reader buf.Reader) ConnectionOption { return func(c *connection) { c.reader = &buf.BufferedReader{ - Reader: reader, - Spliter: buf.SplitFirstBytes, + Reader: reader, + Splitter: buf.SplitFirstBytes, } } } diff --git a/common/platform/windows.go b/common/platform/windows.go index 2aeca80c..872e8461 100644 --- a/common/platform/windows.go +++ b/common/platform/windows.go @@ -19,7 +19,7 @@ func GetToolLocation(file string) string { return filepath.Join(toolPath, file+".exe") } -// GetAssetLocation searches for `file` in the excutable dir +// GetAssetLocation searches for `file` in the executable dir func GetAssetLocation(file string) string { assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir) return filepath.Join(assetPath, file) diff --git a/common/protocol/tls/cert/cert.go b/common/protocol/tls/cert/cert.go index 5bd92a5c..f7629327 100644 --- a/common/protocol/tls/cert/cert.go +++ b/common/protocol/tls/cert/cert.go @@ -19,7 +19,7 @@ import ( //go:generate go run github.com/xtls/xray-core/common/errors/errorgen type Certificate struct { - // Cerificate in ASN.1 DER format + // certificate in ASN.1 DER format Certificate []byte // Private key in ASN.1 DER format PrivateKey []byte diff --git a/common/protocol/tls/sniff_test.go b/common/protocol/tls/sniff_test.go index d334089c..59f3a35f 100644 --- a/common/protocol/tls/sniff_test.go +++ b/common/protocol/tls/sniff_test.go @@ -147,7 +147,7 @@ func TestTLSHeaders(t *testing.T) { header, err := SniffTLS(test.input) if test.err { if err == nil { - t.Errorf("Exepct error but nil in test %v", test) + t.Errorf("Expect error but nil in test %v", test) } } else { if err != nil { diff --git a/common/protocol/user.pb.go b/common/protocol/user.pb.go index 0230b37c..dfa89b33 100644 --- a/common/protocol/user.pb.go +++ b/common/protocol/user.pb.go @@ -21,7 +21,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// User is a generic user for all procotols. +// User is a generic user for all protocols. type User struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/common/protocol/user.proto b/common/protocol/user.proto index 44770edf..14cf995b 100644 --- a/common/protocol/user.proto +++ b/common/protocol/user.proto @@ -8,7 +8,7 @@ option java_multiple_files = true; import "common/serial/typed_message.proto"; -// User is a generic user for all procotols. +// User is a generic user for all protocols. message User { uint32 level = 1; string email = 2; diff --git a/common/session/context.go b/common/session/context.go index da3ad4a8..3fed0151 100644 --- a/common/session/context.go +++ b/common/session/context.go @@ -13,16 +13,16 @@ import ( func IndependentCancelCtx(parent context.Context) context.Context const ( - inboundSessionKey ctx.SessionKey = 1 - outboundSessionKey ctx.SessionKey = 2 - contentSessionKey ctx.SessionKey = 3 - muxPreferedSessionKey ctx.SessionKey = 4 - sockoptSessionKey ctx.SessionKey = 5 + inboundSessionKey ctx.SessionKey = 1 + outboundSessionKey ctx.SessionKey = 2 + contentSessionKey ctx.SessionKey = 3 + muxPreferredSessionKey ctx.SessionKey = 4 + sockoptSessionKey ctx.SessionKey = 5 trackedConnectionErrorKey ctx.SessionKey = 6 - dispatcherKey ctx.SessionKey = 7 - timeoutOnlyKey ctx.SessionKey = 8 - allowedNetworkKey ctx.SessionKey = 9 - handlerSessionKey ctx.SessionKey = 10 + dispatcherKey ctx.SessionKey = 7 + timeoutOnlyKey ctx.SessionKey = 8 + allowedNetworkKey ctx.SessionKey = 9 + handlerSessionKey ctx.SessionKey = 10 ) func ContextWithInbound(ctx context.Context, inbound *Inbound) context.Context { @@ -58,14 +58,14 @@ func ContentFromContext(ctx context.Context) *Content { return nil } -// ContextWithMuxPrefered returns a new context with the given bool -func ContextWithMuxPrefered(ctx context.Context, forced bool) context.Context { - return context.WithValue(ctx, muxPreferedSessionKey, forced) +// ContextWithMuxPreferred returns a new context with the given bool +func ContextWithMuxPreferred(ctx context.Context, forced bool) context.Context { + return context.WithValue(ctx, muxPreferredSessionKey, forced) } -// MuxPreferedFromContext returns value in this context, or false if not contained. -func MuxPreferedFromContext(ctx context.Context) bool { - if val, ok := ctx.Value(muxPreferedSessionKey).(bool); ok { +// MuxPreferredFromContext returns value in this context, or false if not contained. +func MuxPreferredFromContext(ctx context.Context) bool { + if val, ok := ctx.Value(muxPreferredSessionKey).(bool); ok { return val } return false diff --git a/common/signal/timer_test.go b/common/signal/timer_test.go index d56eed2b..263bec9e 100644 --- a/common/signal/timer_test.go +++ b/common/signal/timer_test.go @@ -29,7 +29,7 @@ func TestActivityTimerUpdate(t *testing.T) { timer.SetTimeout(time.Second * 1) time.Sleep(time.Second * 2) if ctx.Err() == nil { - t.Error("expcted some error, but got nil") + t.Error("expected some error, but got nil") } runtime.KeepAlive(timer) } diff --git a/core/config.go b/core/config.go index 32fea49e..aa9b63c9 100644 --- a/core/config.go +++ b/core/config.go @@ -174,7 +174,7 @@ func init() { common.Must(err) return loadProtobufConfig(data) default: - return nil, errors.New("unknow type") + return nil, errors.New("unknown type") } }, })) diff --git a/main/commands/base/env.go b/main/commands/base/env.go index 476ed133..75d141e9 100644 --- a/main/commands/base/env.go +++ b/main/commands/base/env.go @@ -7,7 +7,7 @@ import ( // CommandEnvHolder is a struct holds the environment info of commands type CommandEnvHolder struct { - // Excutable name of current binary + // Executable name of current binary Exec string // commands column width of current command CommandsWidth int diff --git a/main/json/json.go b/main/json/json.go index f14b0eec..aad2dc6b 100644 --- a/main/json/json.go +++ b/main/json/json.go @@ -43,7 +43,7 @@ func init() { case io.Reader: return serial.LoadJSONConfig(v) default: - return nil, errors.New("unknow type") + return nil, errors.New("unknown type") } }, })) diff --git a/main/toml/toml.go b/main/toml/toml.go index 22e1c3dc..b17526ec 100644 --- a/main/toml/toml.go +++ b/main/toml/toml.go @@ -43,7 +43,7 @@ func init() { case io.Reader: return serial.LoadTOMLConfig(v) default: - return nil, errors.New("unknow type") + return nil, errors.New("unknown type") } }, })) diff --git a/main/yaml/yaml.go b/main/yaml/yaml.go index 59bab8fa..a2ead8a7 100644 --- a/main/yaml/yaml.go +++ b/main/yaml/yaml.go @@ -43,7 +43,7 @@ func init() { case io.Reader: return serial.LoadYAMLConfig(v) default: - return nil, errors.New("unknow type") + return nil, errors.New("unknown type") } }, })) diff --git a/proxy/proxy.go b/proxy/proxy.go index 87abd1a2..926bf164 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -243,7 +243,7 @@ func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { return w.Writer.WriteMultiBuffer(mb) } -// ReshapeMultiBuffer prepare multi buffer for padding stucture (max 21 bytes) +// ReshapeMultiBuffer prepare multi buffer for padding structure (max 21 bytes) func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBuffer { needReshape := 0 for _, b := range buffer { @@ -278,7 +278,7 @@ func ReshapeMultiBuffer(ctx context.Context, buffer buf.MultiBuffer) buf.MultiBu return mb2 } -// XtlsPadding add padding to eliminate length siganature during tls handshake +// XtlsPadding add padding to eliminate length signature during tls handshake func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool, ctx context.Context) *buf.Buffer { var contentLen int32 = 0 var paddingLen int32 = 0 diff --git a/proxy/socks/config.pb.go b/proxy/socks/config.pb.go index 6471babf..d13ebd10 100644 --- a/proxy/socks/config.pb.go +++ b/proxy/socks/config.pb.go @@ -26,7 +26,7 @@ const ( type AuthType int32 const ( - // NO_AUTH is for anounymous authentication. + // NO_AUTH is for anonymous authentication. AuthType_NO_AUTH AuthType = 0 // PASSWORD is for username/password authentication. AuthType_PASSWORD AuthType = 1 diff --git a/proxy/socks/config.proto b/proxy/socks/config.proto index 7e7dc09f..85dded0d 100644 --- a/proxy/socks/config.proto +++ b/proxy/socks/config.proto @@ -17,7 +17,7 @@ message Account { // AuthType is the authentication type of Socks proxy. enum AuthType { - // NO_AUTH is for anounymous authentication. + // NO_AUTH is for anonymous authentication. NO_AUTH = 0; // PASSWORD is for username/password authentication. PASSWORD = 1; diff --git a/proxy/socks/protocol_test.go b/proxy/socks/protocol_test.go index 99e07389..b8c84f68 100644 --- a/proxy/socks/protocol_test.go +++ b/proxy/socks/protocol_test.go @@ -68,7 +68,7 @@ func TestReadUsernamePassword(t *testing.T) { t.Error("for input: ", testCase.Input, " expect username ", testCase.Username, " but actually ", username) } if testCase.Password != password { - t.Error("for input: ", testCase.Input, " expect passowrd ", testCase.Password, " but actually ", password) + t.Error("for input: ", testCase.Input, " expect password ", testCase.Password, " but actually ", password) } } } diff --git a/proxy/socks/udpfilter.go b/proxy/socks/udpfilter.go index 25f8a416..9ae3e697 100644 --- a/proxy/socks/udpfilter.go +++ b/proxy/socks/udpfilter.go @@ -9,7 +9,7 @@ import ( In the sock implementation of * ray, UDP authentication is flawed and can be bypassed. Tracking a UDP connection may be a bit troublesome. Here is a simple solution. -We creat a filter, add remote IP to the pool when it try to establish a UDP connection with auth. +We create a filter, add remote IP to the pool when it try to establish a UDP connection with auth. And drop UDP packets from unauthorized IP. After discussion, we believe it is not necessary to add a timeout mechanism to this filter. */ diff --git a/proxy/trojan/client.go b/proxy/trojan/client.go index 21b7d73e..a667d352 100644 --- a/proxy/trojan/client.go +++ b/proxy/trojan/client.go @@ -124,7 +124,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter return errors.New("failed to write A request payload").Base(err).AtWarning() } - // Flush; bufferWriter.WriteMultiBufer now is bufferWriter.writer.WriteMultiBuffer + // Flush; bufferWriter.WriteMultiBuffer now is bufferWriter.writer.WriteMultiBuffer if err = bufferWriter.SetBuffered(false); err != nil { return errors.New("failed to flush payload").Base(err).AtWarning() } diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index 891f725d..3bb2c09c 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -223,14 +223,14 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s cs := tlsConn.ConnectionState() name = cs.ServerName alpn = cs.NegotiatedProtocol - errors.LogInfo(ctx, "realName = " + name) - errors.LogInfo(ctx, "realAlpn = " + alpn) + errors.LogInfo(ctx, "realName = "+name) + errors.LogInfo(ctx, "realAlpn = "+alpn) } else if realityConn, ok := iConn.(*reality.Conn); ok { cs := realityConn.ConnectionState() name = cs.ServerName alpn = cs.NegotiatedProtocol - errors.LogInfo(ctx, "realName = " + name) - errors.LogInfo(ctx, "realAlpn = " + alpn) + errors.LogInfo(ctx, "realName = "+name) + errors.LogInfo(ctx, "realAlpn = "+alpn) } name = strings.ToLower(name) alpn = strings.ToLower(alpn) @@ -295,7 +295,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s } if k == '?' || k == ' ' { path = string(firstBytes[i:j]) - errors.LogInfo(ctx, "realPath = " + path) + errors.LogInfo(ctx, "realPath = "+path) if pfb[path] == nil { path = "" } @@ -524,7 +524,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s clientReader = proxy.NewVisionReader(clientReader, trafficState, ctx1) err = encoding.XtlsRead(clientReader, serverWriter, timer, connection, input, rawInput, trafficState, nil, ctx1) } else { - // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer + // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBuffer err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer)) } @@ -552,7 +552,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s if err := clientWriter.WriteMultiBuffer(multiBuffer); err != nil { return err // ... } - // Flush; bufferWriter.WriteMultiBufer now is bufferWriter.writer.WriteMultiBuffer + // Flush; bufferWriter.WriteMultiBuffer now is bufferWriter.writer.WriteMultiBuffer if err := bufferWriter.SetBuffered(false); err != nil { return errors.New("failed to write A response payload").Base(err).AtWarning() } @@ -561,7 +561,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s if requestAddons.Flow == vless.XRV { err = encoding.XtlsWrite(serverReader, clientWriter, timer, connection, trafficState, nil, ctx) } else { - // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer + // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBuffer err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer)) } if err != nil { diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index 0c9e4721..027a241f 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -219,7 +219,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } else { errors.LogDebug(ctx, "Reader is not timeout reader, will send out vless header separately from first payload") } - // Flush; bufferWriter.WriteMultiBufer now is bufferWriter.writer.WriteMultiBuffer + // Flush; bufferWriter.WriteMultiBuffer now is bufferWriter.writer.WriteMultiBuffer if err := bufferWriter.SetBuffered(false); err != nil { return errors.New("failed to write A request payload").Base(err).AtWarning() } @@ -238,7 +238,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte ctx1 := session.ContextWithInbound(ctx, nil) // TODO enable splice err = encoding.XtlsWrite(clientReader, serverWriter, timer, conn, trafficState, ob, ctx1) } else { - // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBufer + // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBuffer err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer)) } if err != nil { @@ -276,7 +276,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte if requestAddons.Flow == vless.XRV { err = encoding.XtlsRead(serverReader, clientWriter, timer, conn, input, rawInput, trafficState, ob, ctx) } else { - // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBufer + // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBuffer err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer)) } diff --git a/transport/internet/domainsocket/config.pb.go b/transport/internet/domainsocket/config.pb.go index 3ab1adc6..cc33be07 100644 --- a/transport/internet/domainsocket/config.pb.go +++ b/transport/internet/domainsocket/config.pb.go @@ -28,7 +28,7 @@ type Config struct { // Path of the domain socket. This overrides the IP/Port parameter from // upstream caller. Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` - // Abstract speicifies whether to use abstract namespace or not. + // Abstract specifies whether to use abstract namespace or not. // Traditionally Unix domain socket is file system based. Abstract domain // socket can be used without acquiring file lock. Abstract bool `protobuf:"varint,2,opt,name=abstract,proto3" json:"abstract,omitempty"` diff --git a/transport/internet/domainsocket/config.proto b/transport/internet/domainsocket/config.proto index 900dbbe3..dafb9bc6 100644 --- a/transport/internet/domainsocket/config.proto +++ b/transport/internet/domainsocket/config.proto @@ -10,7 +10,7 @@ message Config { // Path of the domain socket. This overrides the IP/Port parameter from // upstream caller. string path = 1; - // Abstract speicifies whether to use abstract namespace or not. + // Abstract specifies whether to use abstract namespace or not. // Traditionally Unix domain socket is file system based. Abstract domain // socket can be used without acquiring file lock. bool abstract = 2; diff --git a/transport/internet/headers/http/config.pb.go b/transport/internet/headers/http/config.pb.go index 681323f1..73fa04c2 100644 --- a/transport/internet/headers/http/config.pb.go +++ b/transport/internet/headers/http/config.pb.go @@ -374,7 +374,7 @@ type Config struct { unknownFields protoimpl.UnknownFields // Settings for authenticating requests. If not set, client side will not send - // authenication header, and server side will bypass authentication. + // authentication header, and server side will bypass authentication. Request *RequestConfig `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` // Settings for authenticating responses. If not set, client side will bypass // authentication, and server side will not send authentication header. diff --git a/transport/internet/headers/http/config.proto b/transport/internet/headers/http/config.proto index c7659371..fd5799c4 100644 --- a/transport/internet/headers/http/config.proto +++ b/transport/internet/headers/http/config.proto @@ -56,7 +56,7 @@ message ResponseConfig { message Config { // Settings for authenticating requests. If not set, client side will not send - // authenication header, and server side will bypass authentication. + // authentication header, and server side will bypass authentication. RequestConfig request = 1; // Settings for authenticating responses. If not set, client side will bypass diff --git a/transport/internet/httpupgrade/connection.go b/transport/internet/httpupgrade/connection.go index c7a33af9..1bc4d755 100644 --- a/transport/internet/httpupgrade/connection.go +++ b/transport/internet/httpupgrade/connection.go @@ -2,18 +2,18 @@ package httpupgrade import "net" -type connnection struct { +type connection struct { net.Conn remoteAddr net.Addr } -func newConnection(conn net.Conn, remoteAddr net.Addr) *connnection { - return &connnection{ +func newConnection(conn net.Conn, remoteAddr net.Addr) *connection { + return &connection{ Conn: conn, remoteAddr: remoteAddr, } } -func (c *connnection) RemoteAddr() net.Addr { +func (c *connection) RemoteAddr() net.Addr { return c.remoteAddr } diff --git a/transport/internet/memory_settings.go b/transport/internet/memory_settings.go index 3c4770d2..e1625f37 100644 --- a/transport/internet/memory_settings.go +++ b/transport/internet/memory_settings.go @@ -1,6 +1,6 @@ package internet -// MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce number of Protobuf parsing. +// MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce the number of Protobuf parsings. type MemoryStreamConfig struct { ProtocolName string ProtocolSettings interface{} diff --git a/transport/internet/tcp_hub.go b/transport/internet/tcp_hub.go index 0cdd50d1..cf0ad80d 100644 --- a/transport/internet/tcp_hub.go +++ b/transport/internet/tcp_hub.go @@ -40,7 +40,7 @@ func ListenUnix(ctx context.Context, address net.Address, settings *MemoryStream protocol := settings.ProtocolName listenFunc := transportListenerCache[protocol] if listenFunc == nil { - return nil, errors.New(protocol, " unix istener not registered.").AtError() + return nil, errors.New(protocol, " unix listener not registered.").AtError() } listener, err := listenFunc(ctx, address, net.Port(0), settings, handler) if err != nil { From 39675b7ef7174952946e46ea9e06069f690baf9b Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 12 Jul 2024 06:02:31 +0000 Subject: [PATCH 436/867] Upgrade github.com/xtls/reality to 20240712055506 Fixes https://github.com/XTLS/REALITY/pull/7#issuecomment-2223320694 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 14f57eb6..9f7b2a9b 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 - github.com/xtls/reality v0.0.0-20240711105359-4dbe0df83874 + github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.25.0 golang.org/x/net v0.27.0 diff --git a/go.sum b/go.sum index b08f8b71..c8f3b597 100644 --- a/go.sum +++ b/go.sum @@ -163,8 +163,8 @@ github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3/go.mo github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/reality v0.0.0-20240711105359-4dbe0df83874 h1:Y6YuIN3XH/x+klNP7C/BfY2EUJzqXyNkQNfqGa+OCS4= -github.com/xtls/reality v0.0.0-20240711105359-4dbe0df83874/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= +github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= +github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= From 558cfcc5072f438b735b6e4bfd88f20ca6093f95 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 12 Jul 2024 11:00:32 +0000 Subject: [PATCH 437/867] v1.8.17 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 53f58841..bbe83f50 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 16 + Version_z byte = 17 ) var ( From 573fb4f643916e39bfc6ed6a8b8979ed7a0c499d Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Mon, 15 Jul 2024 11:53:40 +0200 Subject: [PATCH 438/867] Add Windows 7 builds (#3530) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- .github/workflows/release.yml | 20 +++++++++++++++++--- .github/workflows/test.yml | 2 +- go.mod | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a2b9da73..d044a5c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,6 +78,9 @@ jobs: # Include amd64 on all platforms. goos: [windows, freebsd, openbsd, linux, darwin] goarch: [amd64, 386] + gotoolchain: [""] + patch-assetname: [""] + exclude: # Exclude i386 on darwin - goarch: 386 @@ -152,6 +155,16 @@ jobs: goarch: arm goarm: 7 # END OPENBSD ARM + # BEGIN Windows 7 + - goos: windows + goarch: amd64 + gotoolchain: 1.21.4 + patch-assetname: win7-64 + - goos: windows + goarch: 386 + gotoolchain: 1.21.4 + patch-assetname: win7-32 + # END Windows 7 fail-fast: false runs-on: ubuntu-latest @@ -164,16 +177,17 @@ jobs: - name: Checkout codebase uses: actions/checkout@v4 - - name: Show workflow information + - name: Show workflow information run: | - export _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) + _NAME=${{ matrix.patch-assetname }} + [ -n "$_NAME" ] || _NAME=$(jq ".[\"$GOOS-$GOARCH$GOARM$GOMIPS\"].friendlyName" -r < .github/build/friendly-filenames.json) echo "GOOS: $GOOS, GOARCH: $GOARCH, GOARM: $GOARM, GOMIPS: $GOMIPS, RELEASE_NAME: $_NAME" echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV - name: Set up Go uses: actions/setup-go@v5 with: - go-version-file: go.mod + go-version: ${{ matrix.gotoolchain || '1.22' }} check-latest: true - name: Get project dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index da178740..b2d91b09 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version-file: go.mod + go-version: '1.22' check-latest: true - name: Restore Cache uses: actions/cache/restore@v4 diff --git a/go.mod b/go.mod index 9f7b2a9b..b88896ad 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/xtls/xray-core -go 1.22 +go 1.21.4 require ( github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 From 59819e2a1b70347d0cd3e271ff55ce95c388a856 Mon Sep 17 00:00:00 2001 From: abvf <56146630+abvf@users.noreply.github.com> Date: Mon, 15 Jul 2024 15:34:04 +0330 Subject: [PATCH 439/867] Fix log severity (#3535) --- common/errors/errors.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/errors/errors.go b/common/errors/errors.go index 1915144a..7a35f254 100644 --- a/common/errors/errors.go +++ b/common/errors/errors.go @@ -151,7 +151,7 @@ func LogInfo(ctx context.Context, msg ...interface{}) { } func LogInfoInner(ctx context.Context, inner error, msg ...interface{}) { - doLog(ctx, inner, log.Severity_Debug, msg...) + doLog(ctx, inner, log.Severity_Info, msg...) } func LogWarning(ctx context.Context, msg ...interface{}) { @@ -159,7 +159,7 @@ func LogWarning(ctx context.Context, msg ...interface{}) { } func LogWarningInner(ctx context.Context, inner error, msg ...interface{}) { - doLog(ctx, inner, log.Severity_Debug, msg...) + doLog(ctx, inner, log.Severity_Warning, msg...) } func LogError(ctx context.Context, msg ...interface{}) { @@ -167,7 +167,7 @@ func LogError(ctx context.Context, msg ...interface{}) { } func LogErrorInner(ctx context.Context, inner error, msg ...interface{}) { - doLog(ctx, inner, log.Severity_Debug, msg...) + doLog(ctx, inner, log.Severity_Error, msg...) } func doLog(ctx context.Context, inner error, severity log.Severity, msg ...interface{}) { From a4bc422ed1bdfd513d0adaace6df65a1b6d08d3d Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:53:43 +0000 Subject: [PATCH 440/867] README: Remove 13 inactive projects --- README.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/README.md b/README.md index 1072b9df..66a8199f 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,7 @@ - [ghcr.io/xtls/xray-core](https://ghcr.io/xtls/xray-core) (**Official**) - [teddysun/xray](https://hub.docker.com/r/teddysun/xray) - Web Panel - - [X-UI-English](https://github.com/NidukaAkalanka/x-ui-english), [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [X-UI](https://github.com/diditra/x-ui) - - [Xray-UI](https://github.com/qist/xray-ui), [X-UI](https://github.com/sing-web/x-ui) + - [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [Xray-UI](https://github.com/qist/xray-ui) - [Hiddify](https://github.com/hiddify/hiddify-config) - [Marzban](https://github.com/Gozargah/Marzban) - [Libertea](https://github.com/VZiChoushaDui/Libertea) @@ -67,13 +66,10 @@ - [luci-app-xray](https://github.com/yichya/luci-app-xray) ([openwrt-xray](https://github.com/yichya/openwrt-xray)) - Windows - [v2rayN](https://github.com/2dust/v2rayN) - - [NekoRay](https://github.com/Matsuridayo/nekoray) - [Furious](https://github.com/LorenEteval/Furious) - - [HiddifyN](https://github.com/hiddify/HiddifyN) - [Invisible Man - Xray](https://github.com/InvisibleManVPN/InvisibleMan-XRayClient) - Android - [v2rayNG](https://github.com/2dust/v2rayNG) - - [HiddifyNG](https://github.com/hiddify/HiddifyNG) - [X-flutter](https://github.com/XTLS/X-flutter) - iOS & macOS arm64 - [FoXray](https://apps.apple.com/app/foxray/id6448898396) @@ -85,7 +81,6 @@ - [FoXray](https://apps.apple.com/app/foxray/id6448898396) - Linux - [v2rayA](https://github.com/v2rayA/v2rayA) - - [NekoRay](https://github.com/Matsuridayo/nekoray) - [Furious](https://github.com/LorenEteval/Furious) ## Others that support VLESS, XTLS, REALITY, XUDP, PLUX... @@ -98,21 +93,15 @@ - [XTLS/libXray](https://github.com/XTLS/libXray) - [xtlsapi](https://github.com/hiddify/xtlsapi) - [AndroidLibXrayLite](https://github.com/2dust/AndroidLibXrayLite) - - [XrayKit](https://github.com/arror/XrayKit) - [Xray-core-python](https://github.com/LorenEteval/Xray-core-python) - [xray-api](https://github.com/XVGuardian/xray-api) - [XrayR](https://github.com/XrayR-project/XrayR) - [XrayR-release](https://github.com/XrayR-project/XrayR-release) - [XrayR-V2Board](https://github.com/missuo/XrayR-V2Board) - [Clash.Meta](https://github.com/MetaCubeX/Clash.Meta) - - [Clash Verge](https://github.com/zzzgydi/clash-verge) - [clashN](https://github.com/2dust/clashN) - [Clash Meta for Android](https://github.com/MetaCubeX/ClashMetaForAndroid) - - [meta_for_ios](https://t.me/meta_for_ios) - [sing-box](https://github.com/SagerNet/sing-box) - - [installReality](https://github.com/BoxXt/installReality) - - [sbox-reality](https://github.com/Misaka-blog/sbox-reality) - - [sing-box-for-ios](https://github.com/SagerNet/sing-box-for-ios) ## Contributing From 9e6d7a3cb0c5d60b8ef3cedef7ffaf610547f619 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 15 Jul 2024 13:57:18 +0000 Subject: [PATCH 441/867] v1.8.18 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index bbe83f50..1e4d8713 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 17 + Version_z byte = 18 ) var ( From a7e198e1e2077071a368f626f683ec0de646824d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Wed, 17 Jul 2024 18:40:25 +0800 Subject: [PATCH 442/867] Fix WS reading X-Forwarded-For & Add tests (#3546) Fixes https://github.com/XTLS/Xray-core/issues/3545 --------- Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> --- transport/internet/httpupgrade/httpupgrade_test.go | 4 ++-- transport/internet/splithttp/splithttp_test.go | 4 ++-- transport/internet/websocket/connection.go | 14 +++++++++----- transport/internet/websocket/ws_test.go | 4 ++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/transport/internet/httpupgrade/httpupgrade_test.go b/transport/internet/httpupgrade/httpupgrade_test.go index f94298ca..6fcb7a97 100644 --- a/transport/internet/httpupgrade/httpupgrade_test.go +++ b/transport/internet/httpupgrade/httpupgrade_test.go @@ -151,7 +151,7 @@ func TestDialWithRemoteAddr(t *testing.T) { return } - _, err = c.Write([]byte("Response")) + _, err = c.Write([]byte(c.RemoteAddr().String())) common.Must(err) }(conn) }) @@ -169,7 +169,7 @@ func TestDialWithRemoteAddr(t *testing.T) { var b [1024]byte n, err := conn.Read(b[:]) common.Must(err) - if string(b[:n]) != "Response" { + if string(b[:n]) != "1.1.1.1:0" { t.Error("response: ", string(b[:n])) } diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index 7e22c9ad..d125cedd 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -96,7 +96,7 @@ func TestDialWithRemoteAddr(t *testing.T) { return } - _, err = c.Write([]byte("Response")) + _, err = c.Write([]byte(c.RemoteAddr().String())) common.Must(err) }(conn) }) @@ -113,7 +113,7 @@ func TestDialWithRemoteAddr(t *testing.T) { var b [1024]byte n, _ := conn.Read(b[:]) - if string(b[:n]) != "Response" { + if string(b[:n]) != "1.1.1.1:0" { t.Error("response: ", string(b[:n])) } diff --git a/transport/internet/websocket/connection.go b/transport/internet/websocket/connection.go index 0bb5dd7b..3ccead47 100644 --- a/transport/internet/websocket/connection.go +++ b/transport/internet/websocket/connection.go @@ -14,15 +14,19 @@ import ( var _ buf.Writer = (*connection)(nil) // connection is a wrapper for net.Conn over WebSocket connection. +// remoteAddr is used to pass "virtual" remote IP addresses in X-Forwarded-For. +// so we shouldn't directly read it form conn. type connection struct { - conn *websocket.Conn - reader io.Reader + conn *websocket.Conn + reader io.Reader + remoteAddr net.Addr } func NewConnection(conn *websocket.Conn, remoteAddr net.Addr, extraReader io.Reader) *connection { return &connection{ - conn: conn, - reader: extraReader, + conn: conn, + remoteAddr: remoteAddr, + reader: extraReader, } } @@ -90,7 +94,7 @@ func (c *connection) LocalAddr() net.Addr { } func (c *connection) RemoteAddr() net.Addr { - return c.conn.RemoteAddr() + return c.remoteAddr } func (c *connection) SetDeadline(t time.Time) error { diff --git a/transport/internet/websocket/ws_test.go b/transport/internet/websocket/ws_test.go index 637b7f72..5fcc0a47 100644 --- a/transport/internet/websocket/ws_test.go +++ b/transport/internet/websocket/ws_test.go @@ -91,7 +91,7 @@ func TestDialWithRemoteAddr(t *testing.T) { return } - _, err = c.Write([]byte("Response")) + _, err = c.Write([]byte(c.RemoteAddr().String())) common.Must(err) }(conn) }) @@ -109,7 +109,7 @@ func TestDialWithRemoteAddr(t *testing.T) { var b [1024]byte n, err := conn.Read(b[:]) common.Must(err) - if string(b[:n]) != "Response" { + if string(b[:n]) != "1.1.1.1:0" { t.Error("response: ", string(b[:n])) } From 02cd3b8c74335681ea4bb3664833cdef5298d994 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 17 Jul 2024 07:41:17 -0400 Subject: [PATCH 443/867] Fix SplitHTTP race condition when creating new sessions (#3533) Co-authored-by: nobody Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> --- transport/internet/splithttp/hub.go | 12 ++++++++++++ transport/internet/splithttp/splithttp_test.go | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 27fab68d..b31ec707 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -27,6 +27,7 @@ type requestHandler struct { host string path string ln *Listener + sessionMu *sync.Mutex sessions sync.Map localAddr gonet.TCPAddr } @@ -56,11 +57,21 @@ func (h *requestHandler) maybeReapSession(isFullyConnected *done.Instance, sessi } func (h *requestHandler) upsertSession(sessionId string) *httpSession { + // fast path currentSessionAny, ok := h.sessions.Load(sessionId) if ok { return currentSessionAny.(*httpSession) } + // slow path + h.sessionMu.Lock() + defer h.sessionMu.Unlock() + + currentSessionAny, ok = h.sessions.Load(sessionId) + if ok { + return currentSessionAny.(*httpSession) + } + s := &httpSession{ uploadQueue: NewUploadQueue(int(2 * h.ln.config.GetNormalizedMaxConcurrentUploads())), isFullyConnected: done.New(), @@ -277,6 +288,7 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet host: shSettings.Host, path: shSettings.GetNormalizedPath(), ln: l, + sessionMu: &sync.Mutex{}, sessions: sync.Map{}, localAddr: localAddr, } diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index d125cedd..c1c527ef 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -63,8 +63,8 @@ func Test_listenSHAndDial(t *testing.T) { } common.Must(conn.Close()) - <-time.After(time.Second * 5) conn, err = Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) + common.Must(err) _, err = conn.Write([]byte("Test connection 2")) common.Must(err) From c40fc44a34d35f851319c06a7ca2b03784be4e77 Mon Sep 17 00:00:00 2001 From: ll11l1lIllIl1lll <88377095+ll11l1lIllIl1lll@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:10:48 +0000 Subject: [PATCH 444/867] SplitHTTP: Client supports HTTP/3 (#3543) Closes https://github.com/XTLS/Xray-core/issues/3456 Co-authored-by: Fangliding Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> --- go.mod | 1 + go.sum | 2 ++ transport/internet/splithttp/client.go | 3 +- transport/internet/splithttp/dialer.go | 38 +++++++++++++++++++++----- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index b88896ad..9dee55e5 100644 --- a/go.mod +++ b/go.mod @@ -46,6 +46,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/onsi/ginkgo/v2 v2.19.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/quic-go/qpack v0.4.0 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.4.0 // indirect diff --git a/go.sum b/go.sum index c8f3b597..f30c211a 100644 --- a/go.sum +++ b/go.sum @@ -110,6 +110,8 @@ github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXP github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= +github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= github.com/quic-go/quic-go v0.45.1 h1:tPfeYCk+uZHjmDRwHHQmvHRYL2t44ROTujLeFVBmjCA= github.com/quic-go/quic-go v0.45.1/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index dd48ee6d..2a467d7d 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -32,6 +32,7 @@ type DefaultDialerClient struct { download *http.Client upload *http.Client isH2 bool + isH3 bool // pool of net.Conn, created using dialUploadConn uploadRawPool *sync.Pool dialUploadConn func(ctxInner context.Context) (net.Conn, error) @@ -118,7 +119,7 @@ func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, } req.Header = c.transportConfig.GetRequestHeader() - if c.isH2 { + if c.isH2 || c.isH3 { resp, err := c.upload.Do(req) if err != nil { return err diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 3a7ce641..9f98da3d 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -10,6 +10,8 @@ import ( "sync" "time" + "github.com/quic-go/quic-go" + "github.com/quic-go/quic-go/http3" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" @@ -50,12 +52,9 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return client } - if browser_dialer.HasBrowserDialer() { - return &BrowserDialerClient{} - } - tlsConfig := tls.ConfigFromStreamSettings(streamSettings) isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") + isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") var gotlsConfig *gotls.Config @@ -83,10 +82,35 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return conn, nil } - var uploadTransport http.RoundTripper var downloadTransport http.RoundTripper + var uploadTransport http.RoundTripper - if isH2 { + if isH3 { + dest.Network = net.Network_UDP + quicConfig := &quic.Config{ + HandshakeIdleTimeout: 10 * time.Second, + MaxIdleTimeout: 90 * time.Second, + KeepAlivePeriod: 3 * time.Second, + Allow0RTT: true, + } + roundTripper := &http3.RoundTripper{ + TLSClientConfig: gotlsConfig, + QUICConfig: quicConfig, + Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { + conn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) + if err != nil { + return nil, err + } + udpAddr, err := net.ResolveUDPAddr("udp", conn.RemoteAddr().String()) + if err != nil { + return nil, err + } + return quic.DialEarly(ctx, conn.(*internet.PacketConnWrapper).Conn.(*net.UDPConn), udpAddr, tlsCfg, cfg) + }, + } + downloadTransport = roundTripper + uploadTransport = roundTripper + } else if isH2 { downloadTransport = &http2.Transport{ DialTLSContext: func(ctxInner context.Context, network string, addr string, cfg *gotls.Config) (net.Conn, error) { return dialContext(ctxInner) @@ -107,7 +131,6 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in // http.Client and our custom dial context. DisableKeepAlives: true, } - // we use uploadRawPool for that uploadTransport = nil } @@ -121,6 +144,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in Transport: uploadTransport, }, isH2: isH2, + isH3: isH3, uploadRawPool: &sync.Pool{}, dialUploadConn: dialContext, } From 9288a7c0dce973559dbe017e82401dc99981e96b Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:45:16 +0000 Subject: [PATCH 445/867] Upgrade dependencies --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9dee55e5..e60acb4c 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/refraction-networking/utls v1.6.7 github.com/sagernet/sing v0.4.1 github.com/sagernet/sing-shadowsocks v0.2.7 - github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb + github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 github.com/stretchr/testify v1.9.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 diff --git a/go.sum b/go.sum index f30c211a..15137ad3 100644 --- a/go.sum +++ b/go.sum @@ -123,8 +123,8 @@ github.com/sagernet/sing v0.4.1 h1:zVlpE+7k7AFoC2pv6ReqLf0PIHjihL/jsBl5k05PQFk= github.com/sagernet/sing v0.4.1/go.mod h1:ieZHA/+Y9YZfXs2I3WtuwgyCZ6GPsIR7HdKb1SdEnls= github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8= github.com/sagernet/sing-shadowsocks v0.2.7/go.mod h1:0rIKJZBR65Qi0zwdKezt4s57y/Tl1ofkaq6NlkzVuyE= -github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= -github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg= +github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 h1:emzAzMZ1L9iaKCTxdy3Em8Wv4ChIAGnfiz18Cda70g4= +github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= From b277bacdf6bc64f251626ef59b8cea7de5fe9dd2 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 17 Jul 2024 13:51:21 +0000 Subject: [PATCH 446/867] v1.8.19 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 1e4d8713..3b695a47 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 18 + Version_z byte = 19 ) var ( From d8994b7603d4a66910ac5d3cdb7d8af6c560f9bd Mon Sep 17 00:00:00 2001 From: ll11l1lIllIl1lll <88377095+ll11l1lIllIl1lll@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:52:34 +0000 Subject: [PATCH 447/867] Fix SplitHTTP H3 crash on v2rayNG (#3559) Fixes https://github.com/XTLS/Xray-core/issues/3556 --- transport/internet/splithttp/dialer.go | 29 ++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 9f98da3d..5c22f845 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -101,11 +101,32 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in if err != nil { return nil, err } - udpAddr, err := net.ResolveUDPAddr("udp", conn.RemoteAddr().String()) - if err != nil { - return nil, err + + var udpConn *net.UDPConn + var udpAddr *net.UDPAddr + + switch c := conn.(type) { + case *internet.PacketConnWrapper: + var ok bool + udpConn, ok = c.Conn.(*net.UDPConn) + if !ok { + return nil, errors.New("PacketConnWrapper does not contain a UDP connection") + } + udpAddr, err = net.ResolveUDPAddr("udp", c.Dest.String()) + if err != nil { + return nil, err + } + case *net.UDPConn: + udpConn = c + udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) + if err != nil { + return nil, err + } + default: + return nil, errors.New("unsupported connection type: %T", conn) } - return quic.DialEarly(ctx, conn.(*internet.PacketConnWrapper).Conn.(*net.UDPConn), udpAddr, tlsCfg, cfg) + + return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg) }, } downloadTransport = roundTripper From a0040f13dd42264bf0790ce4fe770fd350fae585 Mon Sep 17 00:00:00 2001 From: ll11l1lIllIl1lll <88377095+ll11l1lIllIl1lll@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:53:47 +0000 Subject: [PATCH 448/867] SplitHTTP: Server supports HTTP/3 (#3554) Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> --- transport/internet/splithttp/hub.go | 106 ++++++++++++------ .../internet/splithttp/splithttp_test.go | 40 +++++++ 2 files changed, 113 insertions(+), 33 deletions(-) diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index b31ec707..1ce8da6b 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -11,6 +11,8 @@ import ( "sync" "time" + "github.com/quic-go/quic-go" + "github.com/quic-go/quic-go/http3" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" @@ -233,10 +235,13 @@ func (c *httpResponseBodyWriter) Close() error { type Listener struct { sync.Mutex - server http.Server - listener net.Listener - config *Config - addConn internet.ConnHandler + server http.Server + h3server *http3.Server + listener net.Listener + h3listener *quic.EarlyListener + config *Config + addConn internet.ConnHandler + isH3 bool } func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (internet.Listener, error) { @@ -253,6 +258,17 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet var listener net.Listener var err error var localAddr = gonet.TCPAddr{} + handler := &requestHandler{ + host: shSettings.Host, + path: shSettings.GetNormalizedPath(), + ln: l, + sessionMu: &sync.Mutex{}, + sessions: sync.Map{}, + localAddr: localAddr, + } + tlsConfig := getTLSConfig(streamSettings) + l.isH3 = len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "h3" + if port == net.Port(0) { // unix listener, err = internet.ListenSystem(ctx, &net.UnixAddr{ @@ -263,6 +279,29 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet return nil, errors.New("failed to listen unix domain socket(for SH) on ", address).Base(err) } errors.LogInfo(ctx, "listening unix domain socket(for SH) on ", address) + } else if l.isH3 { // quic + Conn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{ + IP: address.IP(), + Port: int(port), + }, streamSettings.SocketSettings) + if err != nil { + return nil, errors.New("failed to listen UDP(for SH3) on ", address, ":", port).Base(err) + } + h3listener, err := quic.ListenEarly(Conn,tlsConfig, nil) + if err != nil { + return nil, errors.New("failed to listen QUIC(for SH3) on ", address, ":", port).Base(err) + } + l.h3listener = h3listener + errors.LogInfo(ctx, "listening QUIC(for SH3) on ", address, ":", port) + + l.h3server = &http3.Server{ + Handler: handler, + } + go func() { + if err := l.h3server.ServeListener(l.h3listener); err != nil { + errors.LogWarningInner(ctx, err, "failed to serve http3 for splithttp") + } + }() } else { // tcp localAddr = gonet.TCPAddr{ IP: address.IP(), @@ -275,41 +314,29 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet if err != nil { return nil, errors.New("failed to listen TCP(for SH) on ", address, ":", port).Base(err) } + l.listener = listener errors.LogInfo(ctx, "listening TCP(for SH) on ", address, ":", port) - } + // h2cHandler can handle both plaintext HTTP/1.1 and h2c + h2cHandler := h2c.NewHandler(handler, &http2.Server{}) + l.server = http.Server{ + Handler: h2cHandler, + ReadHeaderTimeout: time.Second * 4, + MaxHeaderBytes: 8192, + } + go func() { + if err := l.server.Serve(l.listener); err != nil { + errors.LogWarningInner(ctx, err, "failed to serve http for splithttp") + } + }() + } + l.listener = listener if config := v2tls.ConfigFromStreamSettings(streamSettings); config != nil { if tlsConfig := config.GetTLSConfig(); tlsConfig != nil { listener = tls.NewListener(listener, tlsConfig) } } - handler := &requestHandler{ - host: shSettings.Host, - path: shSettings.GetNormalizedPath(), - ln: l, - sessionMu: &sync.Mutex{}, - sessions: sync.Map{}, - localAddr: localAddr, - } - - // h2cHandler can handle both plaintext HTTP/1.1 and h2c - h2cHandler := h2c.NewHandler(handler, &http2.Server{}) - - l.listener = listener - - l.server = http.Server{ - Handler: h2cHandler, - ReadHeaderTimeout: time.Second * 4, - MaxHeaderBytes: 8192, - } - - go func() { - if err := l.server.Serve(l.listener); err != nil { - errors.LogWarningInner(ctx, err, "failed to serve http for splithttp") - } - }() - return l, err } @@ -320,9 +347,22 @@ func (ln *Listener) Addr() net.Addr { // Close implements net.Listener.Close(). func (ln *Listener) Close() error { - return ln.listener.Close() + if ln.h3server != nil { + if err := ln.h3server.Close(); err != nil { + return err + } + } else if ln.listener != nil { + return ln.listener.Close() + } + return errors.New("listener does not have an HTTP/3 server or a net.listener") +} +func getTLSConfig(streamSettings *internet.MemoryStreamConfig) *tls.Config { + config := v2tls.ConfigFromStreamSettings(streamSettings) + if config == nil { + return &tls.Config{} + } + return config.GetTLSConfig() } - func init() { common.Must(internet.RegisterTransportListener(protocolName, ListenSH)) } diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index c1c527ef..5f59a738 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -14,6 +14,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol/tls/cert" "github.com/xtls/xray-core/testing/servers/tcp" + "github.com/xtls/xray-core/testing/servers/udp" "github.com/xtls/xray-core/transport/internet" . "github.com/xtls/xray-core/transport/internet/splithttp" "github.com/xtls/xray-core/transport/internet/stat" @@ -204,3 +205,42 @@ func Test_listenSHAndDial_H2C(t *testing.T) { t.Error("Expected h2 but got:", resp.ProtoMajor) } } + +func Test_listenSHAndDial_QUIC(t *testing.T) { + if runtime.GOARCH == "arm64" { + return + } + + listenPort := udp.PickPort() + + start := time.Now() + + streamSettings := &internet.MemoryStreamConfig{ + ProtocolName: "splithttp", + ProtocolSettings: &Config{ + Path: "shs", + }, + SecurityType: "tls", + SecuritySettings: &tls.Config{ + AllowInsecure: true, + Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("localhost")))}, + NextProtocol: []string{"h3"}, + }, + } + listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { + go func() { + _ = conn.Close() + }() + }) + common.Must(err) + defer listen.Close() + + conn, err := Dial(context.Background(), net.UDPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) + common.Must(err) + _ = conn.Close() + + end := time.Now() + if !end.Before(start.Add(time.Second * 5)) { + t.Error("end: ", end, " start: ", start) + } +} \ No newline at end of file From 8deb953aec3c194300150bb57d858819ed2c9966 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 20 Jul 2024 06:10:40 +0000 Subject: [PATCH 449/867] v1.8.20 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 3b695a47..262cf5f3 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 19 + Version_z byte = 20 ) var ( From 964859b4bca4e38bbf920594827d59a5823326f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=82=BB?= <123655015+chise0713@users.noreply.github.com> Date: Sun, 21 Jul 2024 01:26:06 +0800 Subject: [PATCH 450/867] SplitHTTP: Remove unnecessary keepalives (#3565) Remove keep alive since quic-go/http3 doesn't support stream reuse Discussion see https://t.me/projectXray/3782492 Co-authored-by: Fangliding Co-authored-by: xqzr <34030394+xqzr@users.noreply.github.com> Co-authored-by: ll11l1lIllIl1lll <88377095+ll11l1lIllIl1lll@users.noreply.github.com> --- transport/internet/splithttp/dialer.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 5c22f845..3df65381 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -87,15 +87,8 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in if isH3 { dest.Network = net.Network_UDP - quicConfig := &quic.Config{ - HandshakeIdleTimeout: 10 * time.Second, - MaxIdleTimeout: 90 * time.Second, - KeepAlivePeriod: 3 * time.Second, - Allow0RTT: true, - } roundTripper := &http3.RoundTripper{ TLSClientConfig: gotlsConfig, - QUICConfig: quicConfig, Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { conn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) if err != nil { From 529f206d33c35bcdfd6911aa37d604ff5338495b Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 21 Jul 2024 02:29:50 +0200 Subject: [PATCH 451/867] Fix serverside TLS support of SplitHTTP H1/H2 (#3567) Fix #3566 Also update testsuite so that all tests read and write some data. Opening a connection is not enough to trigger connection errors, because the connection is so lazy. --- transport/internet/splithttp/hub.go | 24 ++++--- .../internet/splithttp/splithttp_test.go | 64 +++++++++++++++++-- 2 files changed, 73 insertions(+), 15 deletions(-) diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 1ce8da6b..d4579bc7 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -269,7 +269,6 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet tlsConfig := getTLSConfig(streamSettings) l.isH3 = len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "h3" - if port == net.Port(0) { // unix listener, err = internet.ListenSystem(ctx, &net.UnixAddr{ Name: address.Domain(), @@ -285,9 +284,9 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet Port: int(port), }, streamSettings.SocketSettings) if err != nil { - return nil, errors.New("failed to listen UDP(for SH3) on ", address, ":", port).Base(err) + return nil, errors.New("failed to listen UDP(for SH3) on ", address, ":", port).Base(err) } - h3listener, err := quic.ListenEarly(Conn,tlsConfig, nil) + h3listener, err := quic.ListenEarly(Conn, tlsConfig, nil) if err != nil { return nil, errors.New("failed to listen QUIC(for SH3) on ", address, ":", port).Base(err) } @@ -314,7 +313,6 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet if err != nil { return nil, errors.New("failed to listen TCP(for SH) on ", address, ":", port).Base(err) } - l.listener = listener errors.LogInfo(ctx, "listening TCP(for SH) on ", address, ":", port) // h2cHandler can handle both plaintext HTTP/1.1 and h2c @@ -324,18 +322,24 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet ReadHeaderTimeout: time.Second * 4, MaxHeaderBytes: 8192, } + } + + // tcp/unix (h1/h2) + if listener != nil { + if config := v2tls.ConfigFromStreamSettings(streamSettings); config != nil { + if tlsConfig := config.GetTLSConfig(); tlsConfig != nil { + listener = tls.NewListener(listener, tlsConfig) + } + } + + l.listener = listener + go func() { if err := l.server.Serve(l.listener); err != nil { errors.LogWarningInner(ctx, err, "failed to serve http for splithttp") } }() } - l.listener = listener - if config := v2tls.ConfigFromStreamSettings(streamSettings); config != nil { - if tlsConfig := config.GetTLSConfig(); tlsConfig != nil { - listener = tls.NewListener(listener, tlsConfig) - } - } return l, err } diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index 5f59a738..a3b609ab 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -2,6 +2,7 @@ package splithttp_test import ( "context" + "crypto/rand" gotls "crypto/tls" "fmt" gonet "net" @@ -10,7 +11,9 @@ import ( "testing" "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" "github.com/xtls/xray-core/common/protocol/tls/cert" "github.com/xtls/xray-core/testing/servers/tcp" @@ -143,7 +146,16 @@ func Test_listenSHAndDial_TLS(t *testing.T) { } listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { go func() { - _ = conn.Close() + defer conn.Close() + + var b [1024]byte + conn.SetReadDeadline(time.Now().Add(2 * time.Second)) + _, err := conn.Read(b[:]) + if err != nil { + return + } + + common.Must2(conn.Write([]byte("Response"))) }() }) common.Must(err) @@ -151,7 +163,15 @@ func Test_listenSHAndDial_TLS(t *testing.T) { conn, err := Dial(context.Background(), net.TCPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) common.Must(err) - _ = conn.Close() + + _, err = conn.Write([]byte("Test connection 1")) + common.Must(err) + + var b [1024]byte + n, _ := conn.Read(b[:]) + if string(b[:n]) != "Response" { + t.Error("response: ", string(b[:n])) + } end := time.Now() if !end.Before(start.Add(time.Second * 5)) { @@ -229,18 +249,52 @@ func Test_listenSHAndDial_QUIC(t *testing.T) { } listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { go func() { - _ = conn.Close() + defer conn.Close() + + b := buf.New() + defer b.Release() + + for { + b.Clear() + if _, err := b.ReadFrom(conn); err != nil { + return + } + common.Must2(conn.Write(b.Bytes())) + } }() }) common.Must(err) defer listen.Close() + time.Sleep(time.Second) + conn, err := Dial(context.Background(), net.UDPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) common.Must(err) - _ = conn.Close() + defer conn.Close() + + const N = 1024 + b1 := make([]byte, N) + common.Must2(rand.Read(b1)) + b2 := buf.New() + + common.Must2(conn.Write(b1)) + + b2.Clear() + common.Must2(b2.ReadFullFrom(conn, N)) + if r := cmp.Diff(b2.Bytes(), b1); r != "" { + t.Error(r) + } + + common.Must2(conn.Write(b1)) + + b2.Clear() + common.Must2(b2.ReadFullFrom(conn, N)) + if r := cmp.Diff(b2.Bytes(), b1); r != "" { + t.Error(r) + } end := time.Now() if !end.Before(start.Add(time.Second * 5)) { t.Error("end: ", end, " start: ", start) } -} \ No newline at end of file +} From 22535d86439952a9764d65119bcc739929492717 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 21 Jul 2024 08:55:03 +0000 Subject: [PATCH 452/867] Fix SplitHTTP H3 didn't always reuse QUIC connection https://github.com/XTLS/Xray-core/issues/3560#issuecomment-2241531502 --- transport/internet/splithttp/dialer.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 3df65381..99558975 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -41,6 +41,10 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return &BrowserDialerClient{} } + tlsConfig := tls.ConfigFromStreamSettings(streamSettings) + isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") + isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") + globalDialerAccess.Lock() defer globalDialerAccess.Unlock() @@ -48,14 +52,13 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in globalDialerMap = make(map[dialerConf]DialerClient) } + if isH3 { + dest.Network = net.Network_UDP + } if client, found := globalDialerMap[dialerConf{dest, streamSettings}]; found { return client } - tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") - isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") - var gotlsConfig *gotls.Config if tlsConfig != nil { @@ -86,7 +89,6 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in var uploadTransport http.RoundTripper if isH3 { - dest.Network = net.Network_UDP roundTripper := &http3.RoundTripper{ TLSClientConfig: gotlsConfig, Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { From 0f65aa8ed803922abf9ce90ce963df54ac69af28 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 21 Jul 2024 20:45:05 +0000 Subject: [PATCH 453/867] Fix SplitHTTP H3 waited for downResponse before uploading https://github.com/XTLS/Xray-core/issues/3560#issuecomment-2241750579 --- transport/internet/splithttp/client.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index 2a467d7d..8330d5d7 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -94,6 +94,10 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) gotDownResponse.Close() }() + if c.isH3 { + gotConn.Close() + } + // we want to block Dial until we know the remote address of the server, // for logging purposes <-gotConn.Wait() From c27d652d80bf7a0692ee6b8e4bde7b4483d466ac Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 21 Jul 2024 21:32:26 +0000 Subject: [PATCH 454/867] v1.8.21 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 262cf5f3..077b2638 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 20 + Version_z byte = 21 ) var ( From 36f427f22b8aa650504a16a261d1f61c880a6f43 Mon Sep 17 00:00:00 2001 From: mayampi01 <176286256+mayampi01@users.noreply.github.com> Date: Mon, 22 Jul 2024 22:16:25 +0800 Subject: [PATCH 455/867] docker.yml: Set latest to auto to tag release version (#3581) --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 793d2748..89a0b693 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -19,7 +19,7 @@ jobs: uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository_owner }}/xray-core - flavor: latest=true + flavor: latest=auto tags: | type=sha type=ref,event=branch From edae38c62092b6db03af6dcb9efa22284ebc45bb Mon Sep 17 00:00:00 2001 From: hellokindle Date: Tue, 23 Jul 2024 04:19:31 +0800 Subject: [PATCH 456/867] Fix SplitHTTP Unix domain socket (#3577) Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> --- transport/internet/splithttp/client.go | 2 +- transport/internet/splithttp/hub.go | 15 +++-- .../internet/splithttp/splithttp_test.go | 62 +++++++++++++++++++ 3 files changed, 70 insertions(+), 9 deletions(-) diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index 8330d5d7..f9b7cba1 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -117,10 +117,10 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, payload io.ReadWriteCloser, contentLength int64) error { req, err := http.NewRequest("POST", url, payload) - req.ContentLength = contentLength if err != nil { return err } + req.ContentLength = contentLength req.Header = c.transportConfig.GetRequestHeader() if c.isH2 || c.isH3 { diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index d4579bc7..373e1613 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -314,14 +314,6 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet return nil, errors.New("failed to listen TCP(for SH) on ", address, ":", port).Base(err) } errors.LogInfo(ctx, "listening TCP(for SH) on ", address, ":", port) - - // h2cHandler can handle both plaintext HTTP/1.1 and h2c - h2cHandler := h2c.NewHandler(handler, &http2.Server{}) - l.server = http.Server{ - Handler: h2cHandler, - ReadHeaderTimeout: time.Second * 4, - MaxHeaderBytes: 8192, - } } // tcp/unix (h1/h2) @@ -332,7 +324,14 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet } } + // h2cHandler can handle both plaintext HTTP/1.1 and h2c + h2cHandler := h2c.NewHandler(handler, &http2.Server{}) l.listener = listener + l.server = http.Server{ + Handler: h2cHandler, + ReadHeaderTimeout: time.Second * 4, + MaxHeaderBytes: 8192, + } go func() { if err := l.server.Serve(l.listener); err != nil { diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index a3b609ab..5002e1a5 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -298,3 +298,65 @@ func Test_listenSHAndDial_QUIC(t *testing.T) { t.Error("end: ", end, " start: ", start) } } + +func Test_listenSHAndDial_Unix(t *testing.T) { + tempDir := t.TempDir() + tempSocket := tempDir + "/server.sock" + + listen, err := ListenSH(context.Background(), net.DomainAddress(tempSocket), 0, &internet.MemoryStreamConfig{ + ProtocolName: "splithttp", + ProtocolSettings: &Config{ + Path: "/sh", + }, + }, func(conn stat.Connection) { + go func(c stat.Connection) { + defer c.Close() + + var b [1024]byte + c.SetReadDeadline(time.Now().Add(2 * time.Second)) + _, err := c.Read(b[:]) + if err != nil { + return + } + + common.Must2(c.Write([]byte("Response"))) + }(conn) + }) + common.Must(err) + ctx := context.Background() + streamSettings := &internet.MemoryStreamConfig{ + ProtocolName: "splithttp", + ProtocolSettings: &Config{ + Host: "example.com", + Path: "sh", + }, + } + conn, err := Dial(ctx, net.UnixDestination(net.DomainAddress(tempSocket)), streamSettings) + + common.Must(err) + _, err = conn.Write([]byte("Test connection 1")) + common.Must(err) + + var b [1024]byte + fmt.Println("test2") + n, _ := conn.Read(b[:]) + fmt.Println("string is", n) + if string(b[:n]) != "Response" { + t.Error("response: ", string(b[:n])) + } + + common.Must(conn.Close()) + conn, err = Dial(ctx, net.UnixDestination(net.DomainAddress(tempSocket)), streamSettings) + + common.Must(err) + _, err = conn.Write([]byte("Test connection 2")) + common.Must(err) + n, _ = conn.Read(b[:]) + common.Must(err) + if string(b[:n]) != "Response" { + t.Error("response: ", string(b[:n])) + } + common.Must(conn.Close()) + + common.Must(listen.Close()) +} From 2becdd6414c10765f80cd124e3bed1d816fa4a72 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Fri, 26 Jul 2024 04:36:55 +0200 Subject: [PATCH 457/867] SplitHTTP server: Fix panic during concurrent Close and Push (#3593) When Close and Push are called concurrently, it may happen that Push attempts to write to an already-closed channel, and trigger a panic. From a user perspective, it results in logs like this: http: panic serving 172.19.0.6:50476: send on closed channel It's probably triggered when download is closed at the same time an upload packet is submitted. These panics don't crash the server and the inbound is still usable. --- transport/internet/splithttp/upload_queue.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/transport/internet/splithttp/upload_queue.go b/transport/internet/splithttp/upload_queue.go index 2d1fb5f4..23124c4f 100644 --- a/transport/internet/splithttp/upload_queue.go +++ b/transport/internet/splithttp/upload_queue.go @@ -6,6 +6,7 @@ package splithttp import ( "container/heap" "io" + "sync" "github.com/xtls/xray-core/common/errors" ) @@ -16,11 +17,12 @@ type Packet struct { } type uploadQueue struct { - pushedPackets chan Packet - heap uploadHeap - nextSeq uint64 - closed bool - maxPackets int + pushedPackets chan Packet + writeCloseMutex sync.Mutex + heap uploadHeap + nextSeq uint64 + closed bool + maxPackets int } func NewUploadQueue(maxPackets int) *uploadQueue { @@ -34,6 +36,9 @@ func NewUploadQueue(maxPackets int) *uploadQueue { } func (h *uploadQueue) Push(p Packet) error { + h.writeCloseMutex.Lock() + defer h.writeCloseMutex.Unlock() + if h.closed { return errors.New("splithttp packet queue closed") } @@ -43,6 +48,9 @@ func (h *uploadQueue) Push(p Packet) error { } func (h *uploadQueue) Close() error { + h.writeCloseMutex.Lock() + defer h.writeCloseMutex.Unlock() + h.closed = true close(h.pushedPackets) return nil From 7cf5ee8afd1a088c53397bdf6cbfa8f9f699b441 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sat, 27 Jul 2024 14:38:54 +0200 Subject: [PATCH 458/867] WS, HU: Remove unnecessary sleep from test (#3600) --- transport/internet/httpupgrade/httpupgrade_test.go | 2 -- transport/internet/websocket/ws_test.go | 1 - 2 files changed, 3 deletions(-) diff --git a/transport/internet/httpupgrade/httpupgrade_test.go b/transport/internet/httpupgrade/httpupgrade_test.go index 6fcb7a97..a8108fe6 100644 --- a/transport/internet/httpupgrade/httpupgrade_test.go +++ b/transport/internet/httpupgrade/httpupgrade_test.go @@ -58,7 +58,6 @@ func Test_listenHTTPUpgradeAndDial(t *testing.T) { } common.Must(conn.Close()) - <-time.After(time.Second * 5) conn, err = Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) common.Must(err) _, err = conn.Write([]byte("Test connection 2")) @@ -118,7 +117,6 @@ func Test_listenHTTPUpgradeAndDialWithHeaders(t *testing.T) { } common.Must(conn.Close()) - <-time.After(time.Second * 5) conn, err = Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) common.Must(err) _, err = conn.Write([]byte("Test connection 2")) diff --git a/transport/internet/websocket/ws_test.go b/transport/internet/websocket/ws_test.go index 5fcc0a47..a9a2b885 100644 --- a/transport/internet/websocket/ws_test.go +++ b/transport/internet/websocket/ws_test.go @@ -58,7 +58,6 @@ func Test_listenWSAndDial(t *testing.T) { } common.Must(conn.Close()) - <-time.After(time.Second * 5) conn, err = Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) common.Must(err) _, err = conn.Write([]byte("Test connection 2")) From 8a4217fdf57d31e7ddbfdccecc36bbfa6b311dfa Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sat, 27 Jul 2024 14:52:36 +0200 Subject: [PATCH 459/867] SplitHTTP client: Add minUploadInterval (#3592) --- infra/conf/common.go | 31 +++++ infra/conf/transport_internet.go | 5 + transport/internet/splithttp/config.go | 23 ++++ transport/internet/splithttp/config.pb.go | 137 ++++++++++++++++++---- transport/internet/splithttp/config.proto | 6 + transport/internet/splithttp/dialer.go | 11 ++ 6 files changed, 188 insertions(+), 25 deletions(-) diff --git a/infra/conf/common.go b/infra/conf/common.go index 9f9c0068..9d31bc0a 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -2,6 +2,7 @@ package conf import ( "encoding/json" + "strconv" "strings" "github.com/xtls/xray-core/common/errors" @@ -242,3 +243,33 @@ func (v *User) Build() *protocol.User { Level: uint32(v.LevelByte), } } + +// Int32Range deserializes from "1-2" or 1, so can deserialize from both int and number. +// Negative integers can be passed as sentinel values, but do not parse as ranges. +type Int32Range struct { + From int32 + To int32 +} + +func (v *Int32Range) UnmarshalJSON(data []byte) error { + var stringrange string + var rawint int32 + if err := json.Unmarshal(data, &stringrange); err == nil { + pair := strings.SplitN(stringrange, "-", 2) + if len(pair) == 2 { + from, err := strconv.Atoi(pair[0]) + to, err2 := strconv.Atoi(pair[1]) + if err == nil && err2 == nil { + v.From = int32(from) + v.To = int32(to) + return nil + } + } + } else if err := json.Unmarshal(data, &rawint); err == nil { + v.From = rawint + v.To = rawint + return nil + } + + return errors.New("Invalid integer range, expected either string of form \"1-2\" or plain integer.") +} diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 30fb3e74..bfaa7481 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -231,6 +231,7 @@ type SplitHTTPConfig struct { Headers map[string]string `json:"headers"` MaxConcurrentUploads int32 `json:"maxConcurrentUploads"` MaxUploadSize int32 `json:"maxUploadSize"` + MinUploadIntervalMs Int32Range `json:"minUploadIntervalMs"` } // Build implements Buildable. @@ -249,6 +250,10 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { Header: c.Headers, MaxConcurrentUploads: c.MaxConcurrentUploads, MaxUploadSize: c.MaxUploadSize, + MinUploadIntervalMs: &splithttp.RandRangeConfig{ + From: c.MinUploadIntervalMs.From, + To: c.MinUploadIntervalMs.To, + }, } return config, nil } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 4c44e361..3aa318c8 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -1,6 +1,8 @@ package splithttp import ( + "crypto/rand" + "math/big" "net/http" "github.com/xtls/xray-core/common" @@ -45,8 +47,29 @@ func (c *Config) GetNormalizedMaxUploadSize() int32 { return c.MaxUploadSize } +func (c *Config) GetNormalizedMinUploadInterval() RandRangeConfig { + r := c.MinUploadIntervalMs + + if r == nil { + r = &RandRangeConfig{ + From: 30, + To: 30, + } + } + + return *r +} + func init() { common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { return new(Config) })) } + +func (c RandRangeConfig) roll() int32 { + if c.From == c.To { + return c.From + } + bigInt, _ := rand.Int(rand.Reader, big.NewInt(int64(c.To-c.From))) + return c.From + int32(bigInt.Int64()) +} diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 3975b9f6..43f57e2f 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -30,6 +30,7 @@ type Config struct { Header map[string]string `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` MaxConcurrentUploads int32 `protobuf:"varint,4,opt,name=maxConcurrentUploads,proto3" json:"maxConcurrentUploads,omitempty"` MaxUploadSize int32 `protobuf:"varint,5,opt,name=maxUploadSize,proto3" json:"maxUploadSize,omitempty"` + MinUploadIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=minUploadIntervalMs,proto3" json:"minUploadIntervalMs,omitempty"` } func (x *Config) Reset() { @@ -99,6 +100,68 @@ func (x *Config) GetMaxUploadSize() int32 { return 0 } +func (x *Config) GetMinUploadIntervalMs() *RandRangeConfig { + if x != nil { + return x.MinUploadIntervalMs + } + return nil +} + +type RandRangeConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + From int32 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"` + To int32 `protobuf:"varint,2,opt,name=to,proto3" json:"to,omitempty"` +} + +func (x *RandRangeConfig) Reset() { + *x = RandRangeConfig{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_internet_splithttp_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RandRangeConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RandRangeConfig) ProtoMessage() {} + +func (x *RandRangeConfig) ProtoReflect() protoreflect.Message { + mi := &file_transport_internet_splithttp_config_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RandRangeConfig.ProtoReflect.Descriptor instead. +func (*RandRangeConfig) Descriptor() ([]byte, []int) { + return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{1} +} + +func (x *RandRangeConfig) GetFrom() int32 { + if x != nil { + return x.From + } + return 0 +} + +func (x *RandRangeConfig) GetTo() int32 { + if x != nil { + return x.To + } + return 0 +} + var File_transport_internet_splithttp_config_proto protoreflect.FileDescriptor var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ @@ -106,7 +169,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0x94, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xfa, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, @@ -120,20 +183,30 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, - 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, - 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, - 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, - 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, - 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x64, 0x0a, 0x13, 0x6d, 0x69, + 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, + 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, + 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x13, 0x6d, 0x69, 0x6e, + 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, + 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, + 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, + 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, + 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, + 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, + 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, + 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -148,18 +221,20 @@ func file_transport_internet_splithttp_config_proto_rawDescGZIP() []byte { return file_transport_internet_splithttp_config_proto_rawDescData } -var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_transport_internet_splithttp_config_proto_goTypes = []interface{}{ - (*Config)(nil), // 0: xray.transport.internet.splithttp.Config - nil, // 1: xray.transport.internet.splithttp.Config.HeaderEntry + (*Config)(nil), // 0: xray.transport.internet.splithttp.Config + (*RandRangeConfig)(nil), // 1: xray.transport.internet.splithttp.RandRangeConfig + nil, // 2: xray.transport.internet.splithttp.Config.HeaderEntry } var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ - 1, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 2, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry + 1, // 1: xray.transport.internet.splithttp.Config.minUploadIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_transport_internet_splithttp_config_proto_init() } @@ -180,6 +255,18 @@ func file_transport_internet_splithttp_config_proto_init() { return nil } } + file_transport_internet_splithttp_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RandRangeConfig); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -187,7 +274,7 @@ func file_transport_internet_splithttp_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_transport_internet_splithttp_config_proto_rawDesc, NumEnums: 0, - NumMessages: 2, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 43cecee2..c87ab459 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -12,4 +12,10 @@ message Config { map header = 3; int32 maxConcurrentUploads = 4; int32 maxUploadSize = 5; + RandRangeConfig minUploadIntervalMs = 6; +} + +message RandRangeConfig { + int32 from = 1; + int32 to = 2; } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 99558975..7c677bf9 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -183,6 +183,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me maxConcurrentUploads := transportConfiguration.GetNormalizedMaxConcurrentUploads() maxUploadSize := transportConfiguration.GetNormalizedMaxUploadSize() + minUploadInterval := transportConfiguration.GetNormalizedMinUploadInterval() if tlsConfig != nil { requestURL.Scheme = "https" @@ -207,6 +208,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestsLimiter := semaphore.New(int(maxConcurrentUploads)) var requestCounter int64 + lastWrite := time.Now() + // by offloading the uploads into a buffered pipe, multiple conn.Write // calls get automatically batched together into larger POST requests. // without batching, bandwidth is extremely limited. @@ -237,6 +240,14 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } }() + if minUploadInterval.From > 0 { + roll := time.Duration(minUploadInterval.roll()) * time.Millisecond + if time.Since(lastWrite) < roll { + time.Sleep(roll) + } + + lastWrite = time.Now() + } } }() From 4cb2a128db083475f137e6c6e2e136c0ca7d9125 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 24 Jul 2024 19:47:26 -0400 Subject: [PATCH 460/867] Don't do raw/splice copy in case of MITM --- proxy/freedom/freedom.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index dcb72b04..55ad353d 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -28,6 +28,7 @@ import ( "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" ) var useSplice bool @@ -225,9 +226,16 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte writeConn = inbound.Conn inTimer = inbound.Timer } - return proxy.CopyRawConnIfExist(ctx, conn, writeConn, link.Writer, timer, inTimer) + if !isTLSConn(conn) { // it would be tls conn in special use case of MITM, we need to let link handle traffic + return proxy.CopyRawConnIfExist(ctx, conn, writeConn, link.Writer, timer, inTimer) + } + } + var reader buf.Reader + if destination.Network == net.Network_TCP { + reader = buf.NewReader(conn) + } else { + reader = NewPacketReader(conn, UDPOverride) } - reader := NewPacketReader(conn, UDPOverride) if err := buf.Copy(reader, output, buf.UpdateActivity(timer)); err != nil { return errors.New("failed to process response").Base(err) } @@ -245,6 +253,19 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte return nil } +func isTLSConn(conn stat.Connection) bool { + if conn != nil { + statConn, ok := conn.(*stat.CounterConnection) + if ok { + conn = statConn.Connection + } + if _, ok := conn.(*tls.Conn); ok { + return true + } + } + return false +} + func NewPacketReader(conn net.Conn, UDPOverride net.Destination) buf.Reader { iConn := conn statConn, ok := iConn.(*stat.CounterConnection) From 59f668577499349b64371a10203a6202db0a8f58 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Mon, 29 Jul 2024 06:35:17 +0200 Subject: [PATCH 461/867] SplitHTTP: More range options, change defaults, enforce maxUploadSize, fix querystring behavior (#3603) * maxUploadSize and maxConcurrentUploads can now be ranges on the client * maxUploadSize is now enforced on the server * the default of maxUploadSize is 2MB on the server, and 1MB on the client * the default of maxConcurrentUploads is 200 on the server, and 100 on the client * ranges on the server are treated as a single number. if server is configured as `"1-2"`, server will enforce `2` * querystrings in `path` are now handled correctly --- infra/conf/transport_internet.go | 20 ++-- transport/internet/splithttp/config.go | 61 ++++++++---- transport/internet/splithttp/config.pb.go | 94 ++++++++++--------- transport/internet/splithttp/config.proto | 4 +- transport/internet/splithttp/config_test.go | 51 ++++++++++ transport/internet/splithttp/dialer.go | 17 ++-- transport/internet/splithttp/hub.go | 12 ++- .../internet/splithttp/splithttp_test.go | 46 +++++++++ 8 files changed, 223 insertions(+), 82 deletions(-) create mode 100644 transport/internet/splithttp/config_test.go diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index bfaa7481..91dc86be 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -229,8 +229,8 @@ type SplitHTTPConfig struct { Host string `json:"host"` Path string `json:"path"` Headers map[string]string `json:"headers"` - MaxConcurrentUploads int32 `json:"maxConcurrentUploads"` - MaxUploadSize int32 `json:"maxUploadSize"` + MaxConcurrentUploads Int32Range `json:"maxConcurrentUploads"` + MaxUploadSize Int32Range `json:"maxUploadSize"` MinUploadIntervalMs Int32Range `json:"minUploadIntervalMs"` } @@ -245,11 +245,17 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { c.Host = c.Headers["Host"] } config := &splithttp.Config{ - Path: c.Path, - Host: c.Host, - Header: c.Headers, - MaxConcurrentUploads: c.MaxConcurrentUploads, - MaxUploadSize: c.MaxUploadSize, + Path: c.Path, + Host: c.Host, + Header: c.Headers, + MaxConcurrentUploads: &splithttp.RandRangeConfig{ + From: c.MaxConcurrentUploads.From, + To: c.MaxConcurrentUploads.To, + }, + MaxUploadSize: &splithttp.RandRangeConfig{ + From: c.MaxUploadSize.From, + To: c.MaxUploadSize.To, + }, MinUploadIntervalMs: &splithttp.RandRangeConfig{ From: c.MinUploadIntervalMs.From, To: c.MinUploadIntervalMs.To, diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 3aa318c8..8bb61746 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -4,23 +4,28 @@ import ( "crypto/rand" "math/big" "net/http" + "strings" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/transport/internet" ) -func (c *Config) GetNormalizedPath() string { - path := c.Path - if path == "" { - path = "/" +func (c *Config) GetNormalizedPath(addPath string, addQuery bool) string { + pathAndQuery := strings.SplitN(c.Path, "?", 2) + path := pathAndQuery[0] + query := "" + if len(pathAndQuery) > 1 && addQuery { + query = "?" + pathAndQuery[1] } - if path[0] != '/' { + + if path == "" || path[0] != '/' { path = "/" + path } if path[len(path)-1] != '/' { path = path + "/" } - return path + + return path + addPath + query } func (c *Config) GetRequestHeader() http.Header { @@ -31,33 +36,51 @@ func (c *Config) GetRequestHeader() http.Header { return header } -func (c *Config) GetNormalizedMaxConcurrentUploads() int32 { - if c.MaxConcurrentUploads == 0 { - return 10 +func (c *Config) GetNormalizedMaxConcurrentUploads(isServer bool) RandRangeConfig { + if c.MaxConcurrentUploads == nil { + if isServer { + return RandRangeConfig{ + From: 200, + To: 200, + } + } else { + return RandRangeConfig{ + From: 100, + To: 100, + } + } } - return c.MaxConcurrentUploads + return *c.MaxConcurrentUploads } -func (c *Config) GetNormalizedMaxUploadSize() int32 { - if c.MaxUploadSize == 0 { - return 1000000 +func (c *Config) GetNormalizedMaxUploadSize(isServer bool) RandRangeConfig { + if c.MaxUploadSize == nil { + if isServer { + return RandRangeConfig{ + From: 2000000, + To: 2000000, + } + } else { + return RandRangeConfig{ + From: 1000000, + To: 1000000, + } + } } - return c.MaxUploadSize + return *c.MaxUploadSize } func (c *Config) GetNormalizedMinUploadInterval() RandRangeConfig { - r := c.MinUploadIntervalMs - - if r == nil { - r = &RandRangeConfig{ + if c.MinUploadIntervalMs == nil { + return RandRangeConfig{ From: 30, To: 30, } } - return *r + return *c.MinUploadIntervalMs } func init() { diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 43f57e2f..adde7162 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -28,8 +28,8 @@ type Config struct { Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` Header map[string]string `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - MaxConcurrentUploads int32 `protobuf:"varint,4,opt,name=maxConcurrentUploads,proto3" json:"maxConcurrentUploads,omitempty"` - MaxUploadSize int32 `protobuf:"varint,5,opt,name=maxUploadSize,proto3" json:"maxUploadSize,omitempty"` + MaxConcurrentUploads *RandRangeConfig `protobuf:"bytes,4,opt,name=maxConcurrentUploads,proto3" json:"maxConcurrentUploads,omitempty"` + MaxUploadSize *RandRangeConfig `protobuf:"bytes,5,opt,name=maxUploadSize,proto3" json:"maxUploadSize,omitempty"` MinUploadIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=minUploadIntervalMs,proto3" json:"minUploadIntervalMs,omitempty"` } @@ -86,18 +86,18 @@ func (x *Config) GetHeader() map[string]string { return nil } -func (x *Config) GetMaxConcurrentUploads() int32 { +func (x *Config) GetMaxConcurrentUploads() *RandRangeConfig { if x != nil { return x.MaxConcurrentUploads } - return 0 + return nil } -func (x *Config) GetMaxUploadSize() int32 { +func (x *Config) GetMaxUploadSize() *RandRangeConfig { if x != nil { return x.MaxUploadSize } - return 0 + return nil } func (x *Config) GetMinUploadIntervalMs() *RandRangeConfig { @@ -169,8 +169,8 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xfa, - 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xe2, + 0x03, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, @@ -178,35 +178,41 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x12, 0x32, 0x0a, 0x14, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x14, - 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x55, 0x70, 0x6c, - 0x6f, 0x61, 0x64, 0x73, 0x12, 0x24, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x55, 0x70, 0x6c, 0x6f, 0x61, - 0x64, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x6d, 0x61, 0x78, - 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x64, 0x0a, 0x13, 0x6d, 0x69, - 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, - 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, - 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x13, 0x6d, 0x69, 0x6e, - 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, - 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, - 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, - 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, - 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, - 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, - 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, - 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x12, 0x66, 0x0a, 0x14, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, + 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x52, 0x14, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x58, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x55, + 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, + 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, + 0x7a, 0x65, 0x12, 0x64, 0x0a, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, + 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, + 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x52, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x6e, + 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, + 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, + 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, + 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, + 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, + 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -229,12 +235,14 @@ var file_transport_internet_splithttp_config_proto_goTypes = []interface{}{ } var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 2, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry - 1, // 1: xray.transport.internet.splithttp.Config.minUploadIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 1, // 1: xray.transport.internet.splithttp.Config.maxConcurrentUploads:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 2: xray.transport.internet.splithttp.Config.maxUploadSize:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 3: xray.transport.internet.splithttp.Config.minUploadIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_transport_internet_splithttp_config_proto_init() } diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index c87ab459..95381feb 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -10,8 +10,8 @@ message Config { string host = 1; string path = 2; map header = 3; - int32 maxConcurrentUploads = 4; - int32 maxUploadSize = 5; + RandRangeConfig maxConcurrentUploads = 4; + RandRangeConfig maxUploadSize = 5; RandRangeConfig minUploadIntervalMs = 6; } diff --git a/transport/internet/splithttp/config_test.go b/transport/internet/splithttp/config_test.go new file mode 100644 index 00000000..b2891df9 --- /dev/null +++ b/transport/internet/splithttp/config_test.go @@ -0,0 +1,51 @@ +package splithttp_test + +import ( + "testing" + + . "github.com/xtls/xray-core/transport/internet/splithttp" +) + +func Test_GetNormalizedPath(t *testing.T) { + c := Config{ + Path: "/?world", + } + + path := c.GetNormalizedPath("hello", true) + if path != "/hello?world" { + t.Error("Unexpected: ", path) + } +} + +func Test_GetNormalizedPath2(t *testing.T) { + c := Config{ + Path: "?world", + } + + path := c.GetNormalizedPath("hello", true) + if path != "/hello?world" { + t.Error("Unexpected: ", path) + } +} + +func Test_GetNormalizedPath3(t *testing.T) { + c := Config{ + Path: "hello?world", + } + + path := c.GetNormalizedPath("", true) + if path != "/hello/?world" { + t.Error("Unexpected: ", path) + } +} + +func Test_GetNormalizedPath4(t *testing.T) { + c := Config{ + Path: "hello?world", + } + + path := c.GetNormalizedPath("", false) + if path != "/hello/" { + t.Error("Unexpected: ", path) + } +} diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 7c677bf9..0448b2f7 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -181,8 +181,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me transportConfiguration := streamSettings.ProtocolSettings.(*Config) tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - maxConcurrentUploads := transportConfiguration.GetNormalizedMaxConcurrentUploads() - maxUploadSize := transportConfiguration.GetNormalizedMaxUploadSize() + maxConcurrentUploads := transportConfiguration.GetNormalizedMaxConcurrentUploads(false) + maxUploadSize := transportConfiguration.GetNormalizedMaxUploadSize(false) minUploadInterval := transportConfiguration.GetNormalizedMinUploadInterval() if tlsConfig != nil { @@ -194,18 +194,17 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if requestURL.Host == "" { requestURL.Host = dest.NetAddr() } - requestURL.Path = transportConfiguration.GetNormalizedPath() + + sessionIdUuid := uuid.New() + requestURL.Path = transportConfiguration.GetNormalizedPath(sessionIdUuid.String(), true) + baseURL := requestURL.String() httpClient := getHTTPClient(ctx, dest, streamSettings) - sessionIdUuid := uuid.New() - sessionId := sessionIdUuid.String() - baseURL := requestURL.String() + sessionId - - uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize)) + uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize.roll())) go func() { - requestsLimiter := semaphore.New(int(maxConcurrentUploads)) + requestsLimiter := semaphore.New(int(maxConcurrentUploads.roll())) var requestCounter int64 lastWrite := time.Now() diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 373e1613..86125504 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -75,7 +75,7 @@ func (h *requestHandler) upsertSession(sessionId string) *httpSession { } s := &httpSession{ - uploadQueue: NewUploadQueue(int(2 * h.ln.config.GetNormalizedMaxConcurrentUploads())), + uploadQueue: NewUploadQueue(int(h.ln.config.GetNormalizedMaxConcurrentUploads(true).To)), isFullyConnected: done.New(), } @@ -122,6 +122,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } currentSession := h.upsertSession(sessionId) + maxUploadSize := int(h.ln.config.GetNormalizedMaxUploadSize(true).To) if request.Method == "POST" { seq := "" @@ -136,6 +137,13 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } payload, err := io.ReadAll(request.Body) + + if len(payload) > maxUploadSize { + errors.LogInfo(context.Background(), "Too large upload. maxUploadSize is set to", maxUploadSize, "but request had size", len(payload), ". Adjust maxUploadSize on the server to be at least as large as client.") + writer.WriteHeader(http.StatusRequestEntityTooLarge) + return + } + if err != nil { errors.LogInfoInner(context.Background(), err, "failed to upload") writer.WriteHeader(http.StatusInternalServerError) @@ -260,7 +268,7 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet var localAddr = gonet.TCPAddr{} handler := &requestHandler{ host: shSettings.Host, - path: shSettings.GetNormalizedPath(), + path: shSettings.GetNormalizedPath("", false), ln: l, sessionMu: &sync.Mutex{}, sessions: sync.Map{}, diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index 5002e1a5..1ac27b79 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -360,3 +360,49 @@ func Test_listenSHAndDial_Unix(t *testing.T) { common.Must(listen.Close()) } + +func Test_queryString(t *testing.T) { + listenPort := tcp.PickPort() + listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, &internet.MemoryStreamConfig{ + ProtocolName: "splithttp", + ProtocolSettings: &Config{ + // this querystring does not have any effect, but sometimes people blindly copy it from websocket config. make sure the outbound doesn't break + Path: "/sh?ed=2048", + }, + }, func(conn stat.Connection) { + go func(c stat.Connection) { + defer c.Close() + + var b [1024]byte + c.SetReadDeadline(time.Now().Add(2 * time.Second)) + _, err := c.Read(b[:]) + if err != nil { + return + } + + common.Must2(c.Write([]byte("Response"))) + }(conn) + }) + common.Must(err) + ctx := context.Background() + streamSettings := &internet.MemoryStreamConfig{ + ProtocolName: "splithttp", + ProtocolSettings: &Config{Path: "sh"}, + } + conn, err := Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) + + common.Must(err) + _, err = conn.Write([]byte("Test connection 1")) + common.Must(err) + + var b [1024]byte + fmt.Println("test2") + n, _ := conn.Read(b[:]) + fmt.Println("string is", n) + if string(b[:n]) != "Response" { + t.Error("response: ", string(b[:n])) + } + + common.Must(conn.Close()) + common.Must(listen.Close()) +} From 60553a6c262915da32a95b98d654aa437255e1df Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 29 Jul 2024 06:32:04 +0000 Subject: [PATCH 462/867] SplitHTTP server: Add noSSEHeader https://github.com/XTLS/Xray-core/pull/3603#issuecomment-2254968219 --- infra/conf/transport_internet.go | 2 + transport/internet/config.pb.go | 16 ++++---- transport/internet/splithttp/config.pb.go | 48 ++++++++++++++--------- transport/internet/splithttp/config.proto | 1 + transport/internet/splithttp/hub.go | 8 +++- 5 files changed, 46 insertions(+), 29 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 91dc86be..9e644e43 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -232,6 +232,7 @@ type SplitHTTPConfig struct { MaxConcurrentUploads Int32Range `json:"maxConcurrentUploads"` MaxUploadSize Int32Range `json:"maxUploadSize"` MinUploadIntervalMs Int32Range `json:"minUploadIntervalMs"` + NoSSEHeader bool `json:"noSSEHeader"` } // Build implements Buildable. @@ -260,6 +261,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { From: c.MinUploadIntervalMs.From, To: c.MinUploadIntervalMs.To, }, + NoSSEHeader: c.NoSSEHeader, } return config, nil } diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 903fa794..f0fe1ea5 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.2 +// protoc-gen-go v1.34.1 +// protoc v5.27.0 // source: transport/internet/config.proto package internet @@ -863,7 +863,7 @@ func file_transport_internet_config_proto_rawDescGZIP() []byte { var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_transport_internet_config_proto_goTypes = []any{ +var file_transport_internet_config_proto_goTypes = []interface{}{ (TransportProtocol)(0), // 0: xray.transport.internet.TransportProtocol (DomainStrategy)(0), // 1: xray.transport.internet.DomainStrategy (SocketConfig_TProxyMode)(0), // 2: xray.transport.internet.SocketConfig.TProxyMode @@ -897,7 +897,7 @@ func file_transport_internet_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_config_proto_msgTypes[0].Exporter = func(v any, i int) any { + file_transport_internet_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*TransportConfig); i { case 0: return &v.state @@ -909,7 +909,7 @@ func file_transport_internet_config_proto_init() { return nil } } - file_transport_internet_config_proto_msgTypes[1].Exporter = func(v any, i int) any { + file_transport_internet_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*StreamConfig); i { case 0: return &v.state @@ -921,7 +921,7 @@ func file_transport_internet_config_proto_init() { return nil } } - file_transport_internet_config_proto_msgTypes[2].Exporter = func(v any, i int) any { + file_transport_internet_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ProxyConfig); i { case 0: return &v.state @@ -933,7 +933,7 @@ func file_transport_internet_config_proto_init() { return nil } } - file_transport_internet_config_proto_msgTypes[3].Exporter = func(v any, i int) any { + file_transport_internet_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*CustomSockopt); i { case 0: return &v.state @@ -945,7 +945,7 @@ func file_transport_internet_config_proto_init() { return nil } } - file_transport_internet_config_proto_msgTypes[4].Exporter = func(v any, i int) any { + file_transport_internet_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*SocketConfig); i { case 0: return &v.state diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index adde7162..8e69867e 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -31,6 +31,7 @@ type Config struct { MaxConcurrentUploads *RandRangeConfig `protobuf:"bytes,4,opt,name=maxConcurrentUploads,proto3" json:"maxConcurrentUploads,omitempty"` MaxUploadSize *RandRangeConfig `protobuf:"bytes,5,opt,name=maxUploadSize,proto3" json:"maxUploadSize,omitempty"` MinUploadIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=minUploadIntervalMs,proto3" json:"minUploadIntervalMs,omitempty"` + NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` } func (x *Config) Reset() { @@ -107,6 +108,13 @@ func (x *Config) GetMinUploadIntervalMs() *RandRangeConfig { return nil } +func (x *Config) GetNoSSEHeader() bool { + if x != nil { + return x.NoSSEHeader + } + return false +} + type RandRangeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -169,8 +177,8 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xe2, - 0x03, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0x84, + 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, @@ -196,23 +204,25 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, - 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, - 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, - 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, - 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, - 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, - 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, + 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, + 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, + 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, + 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, + 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, + 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, + 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, + 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 95381feb..807732c3 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -13,6 +13,7 @@ message Config { RandRangeConfig maxConcurrentUploads = 4; RandRangeConfig maxUploadSize = 5; RandRangeConfig minUploadIntervalMs = 6; + bool noSSEHeader = 7; } message RandRangeConfig { diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 86125504..ce54ed07 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -26,6 +26,7 @@ import ( ) type requestHandler struct { + config *Config host string path string ln *Listener @@ -182,8 +183,10 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req // magic header instructs nginx + apache to not buffer response body writer.Header().Set("X-Accel-Buffering", "no") - // magic header to make the HTTP middle box consider this as SSE to disable buffer - writer.Header().Set("Content-Type", "text/event-stream") + if !h.config.NoSSEHeader { + // magic header to make the HTTP middle box consider this as SSE to disable buffer + writer.Header().Set("Content-Type", "text/event-stream") + } writer.WriteHeader(http.StatusOK) // send a chunk immediately to enable CDN streaming. @@ -267,6 +270,7 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet var err error var localAddr = gonet.TCPAddr{} handler := &requestHandler{ + config: shSettings, host: shSettings.Host, path: shSettings.GetNormalizedPath("", false), ln: l, From a342db3e2805e7ec217613ea4c23086a907abf6c Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Mon, 29 Jul 2024 02:43:46 -0400 Subject: [PATCH 463/867] Fix a nil pointer in Wireguard client logging (#3608) --- proxy/wireguard/client.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/proxy/wireguard/client.go b/proxy/wireguard/client.go index 56c91cef..1bb594b7 100644 --- a/proxy/wireguard/client.go +++ b/proxy/wireguard/client.go @@ -100,7 +100,7 @@ func (h *Handler) processWireGuard(ctx context.Context, dialer internet.Dialer) } // bind := conn.NewStdNetBind() // TODO: conn.Bind wrapper for dialer - bind := &netBindClient{ + h.bind = &netBindClient{ netBind: netBind{ dns: h.dns, dnsOption: dns.IPOption{ @@ -115,15 +115,14 @@ func (h *Handler) processWireGuard(ctx context.Context, dialer internet.Dialer) } defer func() { if err != nil { - _ = bind.Close() + _ = h.bind.Close() } }() - h.net, err = h.makeVirtualTun(bind) + h.net, err = h.makeVirtualTun() if err != nil { return errors.New("failed to create virtual tun interface").Base(err) } - h.bind = bind return nil } @@ -238,16 +237,16 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } // creates a tun interface on netstack given a configuration -func (h *Handler) makeVirtualTun(bind *netBindClient) (Tunnel, error) { +func (h *Handler) makeVirtualTun() (Tunnel, error) { t, err := h.conf.createTun()(h.endpoints, int(h.conf.Mtu), nil) if err != nil { return nil, err } - bind.dnsOption.IPv4Enable = h.hasIPv4 - bind.dnsOption.IPv6Enable = h.hasIPv6 + h.bind.dnsOption.IPv4Enable = h.hasIPv4 + h.bind.dnsOption.IPv6Enable = h.hasIPv6 - if err = t.BuildDevice(h.createIPCRequest(bind, h.conf), bind); err != nil { + if err = t.BuildDevice(h.createIPCRequest(), h.bind); err != nil { _ = t.Close() return nil, err } @@ -255,17 +254,17 @@ func (h *Handler) makeVirtualTun(bind *netBindClient) (Tunnel, error) { } // serialize the config into an IPC request -func (h *Handler) createIPCRequest(bind *netBindClient, conf *DeviceConfig) string { +func (h *Handler) createIPCRequest() string { var request strings.Builder - request.WriteString(fmt.Sprintf("private_key=%s\n", conf.SecretKey)) + request.WriteString(fmt.Sprintf("private_key=%s\n", h.conf.SecretKey)) - if !conf.IsClient { + if !h.conf.IsClient { // placeholder, we'll handle actual port listening on Xray request.WriteString("listen_port=1337\n") } - for _, peer := range conf.Peers { + for _, peer := range h.conf.Peers { if peer.PublicKey != "" { request.WriteString(fmt.Sprintf("public_key=%s\n", peer.PublicKey)) } @@ -280,7 +279,7 @@ func (h *Handler) createIPCRequest(bind *netBindClient, conf *DeviceConfig) stri } addr := net.ParseAddress(address) if addr.Family().IsDomain() { - dialerIp := bind.dialer.DestIpAddress() + dialerIp := h.bind.dialer.DestIpAddress() if dialerIp != nil { addr = net.ParseAddress(dialerIp.String()) errors.LogInfo(h.bind.ctx, "createIPCRequest use dialer dest ip: ", addr) From 4531a7e2286ee6dd7149301e5ba882e800a7a6e4 Mon Sep 17 00:00:00 2001 From: lelemka0 <20322043+lelemka0@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:58:58 +0800 Subject: [PATCH 464/867] CertificateObject: Enable auto-reload for cacert & Add buildChain & Fixes (#3607) --- common/protocol/tls/cert/cert.go | 15 ++- infra/conf/transport_internet.go | 2 + transport/internet/tls/config.go | 137 ++++++++++++++++------------ transport/internet/tls/config.pb.go | 132 ++++++++++++++------------- transport/internet/tls/config.proto | 2 + 5 files changed, 163 insertions(+), 125 deletions(-) diff --git a/common/protocol/tls/cert/cert.go b/common/protocol/tls/cert/cert.go index f7629327..b8f3266e 100644 --- a/common/protocol/tls/cert/cert.go +++ b/common/protocol/tls/cert/cert.go @@ -149,10 +149,6 @@ func Generate(parent *Certificate, opts ...Option) (*Certificate, error) { BasicConstraintsValid: true, } - for _, opt := range opts { - opt(template) - } - parentCert := template if parent != nil { pCert, err := x509.ParseCertificate(parent.Certificate) @@ -162,6 +158,17 @@ func Generate(parent *Certificate, opts ...Option) (*Certificate, error) { parentCert = pCert } + if parentCert.NotAfter.Before(template.NotAfter) { + template.NotAfter = parentCert.NotAfter + } + if parentCert.NotBefore.After(template.NotBefore) { + template.NotBefore = parentCert.NotBefore + } + + for _, opt := range opts { + opt(template) + } + derBytes, err := x509.CreateCertificate(rand.Reader, template, parentCert, publicKey(selfKey), parentKey) if err != nil { return nil, errors.New("failed to create certificate").Base(err) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 9e644e43..40f648b3 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -385,6 +385,7 @@ type TLSCertConfig struct { Usage string `json:"usage"` OcspStapling uint64 `json:"ocspStapling"` OneTimeLoading bool `json:"oneTimeLoading"` + BuildChain bool `json:"buildChain"` } // Build implements Buildable. @@ -423,6 +424,7 @@ func (c *TLSCertConfig) Build() (*tls.Certificate, error) { certificate.OneTimeLoading = c.OneTimeLoading } certificate.OcspStapling = c.OcspStapling + certificate.BuildChain = c.BuildChain return certificate, nil } diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 7adb5a84..b6c55c00 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -10,6 +10,7 @@ import ( "strings" "sync" "time" + "bytes" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" @@ -50,72 +51,84 @@ func (c *Config) BuildCertificates() []*tls.Certificate { if entry.Usage != Certificate_ENCIPHERMENT { continue } - keyPair, err := tls.X509KeyPair(entry.Certificate, entry.Key) - if err != nil { - errors.LogWarningInner(context.Background(), err, "ignoring invalid X509 key pair") - continue - } - keyPair.Leaf, err = x509.ParseCertificate(keyPair.Certificate[0]) - if err != nil { - errors.LogWarningInner(context.Background(), err, "ignoring invalid certificate") - continue - } - certs = append(certs, &keyPair) - if !entry.OneTimeLoading { - var isOcspstapling bool - hotReloadCertInterval := uint64(3600) - if entry.OcspStapling != 0 { - hotReloadCertInterval = entry.OcspStapling - isOcspstapling = true + getX509KeyPair := func() *tls.Certificate { + keyPair, err := tls.X509KeyPair(entry.Certificate, entry.Key) + if err != nil { + errors.LogWarningInner(context.Background(), err, "ignoring invalid X509 key pair") + return nil } - index := len(certs) - 1 - go func(entry *Certificate, cert *tls.Certificate, index int) { - t := time.NewTicker(time.Duration(hotReloadCertInterval) * time.Second) - for { - if entry.CertificatePath != "" && entry.KeyPath != "" { - newCert, err := filesystem.ReadFile(entry.CertificatePath) - if err != nil { - errors.LogErrorInner(context.Background(), err, "failed to parse certificate") - <-t.C - continue - } - newKey, err := filesystem.ReadFile(entry.KeyPath) - if err != nil { - errors.LogErrorInner(context.Background(), err, "failed to parse key") - <-t.C - continue - } - if string(newCert) != string(entry.Certificate) && string(newKey) != string(entry.Key) { - newKeyPair, err := tls.X509KeyPair(newCert, newKey) - if err != nil { - errors.LogErrorInner(context.Background(), err, "ignoring invalid X509 key pair") - <-t.C - continue - } - if newKeyPair.Leaf, err = x509.ParseCertificate(newKeyPair.Certificate[0]); err != nil { - errors.LogErrorInner(context.Background(), err, "ignoring invalid certificate") - <-t.C - continue - } - cert = &newKeyPair - } - } - if isOcspstapling { - if newOCSPData, err := ocsp.GetOCSPForCert(cert.Certificate); err != nil { - errors.LogWarningInner(context.Background(), err, "ignoring invalid OCSP") - } else if string(newOCSPData) != string(cert.OCSPStaple) { - cert.OCSPStaple = newOCSPData - } - } - certs[index] = cert - <-t.C - } - }(entry, certs[index], index) + keyPair.Leaf, err = x509.ParseCertificate(keyPair.Certificate[0]) + if err != nil { + errors.LogWarningInner(context.Background(), err, "ignoring invalid certificate") + return nil + } + return &keyPair } + if keyPair := getX509KeyPair(); keyPair != nil { + certs = append(certs, keyPair) + } else { + continue + } + index := len(certs) - 1 + setupOcspTicker(entry, func(isReloaded, isOcspstapling bool){ + cert := certs[index] + if isReloaded { + if newKeyPair := getX509KeyPair(); newKeyPair != nil { + cert = newKeyPair + } else { + return + } + } + if isOcspstapling { + if newOCSPData, err := ocsp.GetOCSPForCert(cert.Certificate); err != nil { + errors.LogWarningInner(context.Background(), err, "ignoring invalid OCSP") + } else if string(newOCSPData) != string(cert.OCSPStaple) { + cert.OCSPStaple = newOCSPData + } + } + certs[index] = cert + }) } return certs } +func setupOcspTicker(entry *Certificate, callback func(isReloaded, isOcspstapling bool)) { + go func() { + if entry.OneTimeLoading { + return + } + var isOcspstapling bool + hotReloadCertInterval := uint64(3600) + if entry.OcspStapling != 0 { + hotReloadCertInterval = entry.OcspStapling + isOcspstapling = true + } + t := time.NewTicker(time.Duration(hotReloadCertInterval) * time.Second) + for { + var isReloaded bool + if entry.CertificatePath != "" && entry.KeyPath != "" { + newCert, err := filesystem.ReadFile(entry.CertificatePath) + if err != nil { + errors.LogErrorInner(context.Background(), err, "failed to parse certificate") + return + } + newKey, err := filesystem.ReadFile(entry.KeyPath) + if err != nil { + errors.LogErrorInner(context.Background(), err, "failed to parse key") + return + } + if string(newCert) != string(entry.Certificate) || string(newKey) != string(entry.Key) { + entry.Certificate = newCert + entry.Key = newKey + isReloaded = true + } + } + callback(isReloaded, isOcspstapling) + <-t.C + } + }() +} + func isCertificateExpired(c *tls.Certificate) bool { if c.Leaf == nil && len(c.Certificate) > 0 { if pc, err := x509.ParseCertificate(c.Certificate[0]); err == nil { @@ -137,6 +150,9 @@ func issueCertificate(rawCA *Certificate, domain string) (*tls.Certificate, erro return nil, errors.New("failed to generate new certificate for ", domain).Base(err) } newCertPEM, newKeyPEM := newCert.ToPEM() + if rawCA.BuildChain { + newCertPEM = bytes.Join([][]byte{newCertPEM, rawCA.Certificate}, []byte("\n")) + } cert, err := tls.X509KeyPair(newCertPEM, newKeyPEM) return &cert, err } @@ -146,6 +162,7 @@ func (c *Config) getCustomCA() []*Certificate { for _, certificate := range c.Certificate { if certificate.Usage == Certificate_AUTHORITY_ISSUE { certs = append(certs, certificate) + setupOcspTicker(certificate, func(isReloaded, isOcspstapling bool){ }) } } return certs diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index 2613c3b9..3ba1893d 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -86,6 +86,7 @@ type Certificate struct { KeyPath string `protobuf:"bytes,6,opt,name=key_path,json=keyPath,proto3" json:"key_path,omitempty"` // If true, one-Time Loading OneTimeLoading bool `protobuf:"varint,7,opt,name=One_time_loading,json=OneTimeLoading,proto3" json:"One_time_loading,omitempty"` + BuildChain bool `protobuf:"varint,8,opt,name=build_chain,json=buildChain,proto3" json:"build_chain,omitempty"` } func (x *Certificate) Reset() { @@ -169,6 +170,13 @@ func (x *Certificate) GetOneTimeLoading() bool { return false } +func (x *Certificate) GetBuildChain() bool { + if x != nil { + return x.BuildChain + } + return false +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -359,7 +367,7 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, - 0x6c, 0x73, 0x22, 0xe2, 0x02, 0x0a, 0x0b, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, + 0x6c, 0x73, 0x22, 0x83, 0x03, 0x0a, 0x0b, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, @@ -377,66 +385,68 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x6b, 0x65, 0x79, 0x50, 0x61, 0x74, 0x68, 0x12, 0x28, 0x0a, 0x10, 0x4f, 0x6e, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x5f, 0x6c, 0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x4f, 0x6e, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x4c, 0x6f, 0x61, 0x64, 0x69, 0x6e, - 0x67, 0x22, 0x44, 0x0a, 0x05, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x45, 0x4e, - 0x43, 0x49, 0x50, 0x48, 0x45, 0x52, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, - 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, - 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, - 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xf6, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x6e, 0x73, 0x65, - 0x63, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, - 0x77, 0x49, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x63, 0x65, 0x72, - 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x2e, 0x43, 0x65, 0x72, - 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, - 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x6e, - 0x65, 0x78, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x3a, 0x0a, 0x19, 0x65, - 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, - 0x73, 0x75, 0x6d, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x17, - 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, - 0x75, 0x6d, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x0a, 0x13, 0x64, 0x69, 0x73, 0x61, 0x62, - 0x6c, 0x65, 0x5f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x79, 0x73, - 0x74, 0x65, 0x6d, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x69, 0x6e, 0x5f, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, 0x69, - 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x61, 0x78, 0x5f, - 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, - 0x61, 0x78, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x69, 0x70, - 0x68, 0x65, 0x72, 0x5f, 0x73, 0x75, 0x69, 0x74, 0x65, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0c, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x53, 0x75, 0x69, 0x74, 0x65, 0x73, 0x12, 0x41, - 0x0a, 0x1b, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, - 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x5f, 0x73, 0x75, 0x69, 0x74, 0x65, 0x73, 0x18, 0x0a, 0x20, - 0x01, 0x28, 0x08, 0x42, 0x02, 0x18, 0x01, 0x52, 0x18, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x53, 0x75, 0x69, 0x74, 0x65, - 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, - 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, - 0x69, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x75, 0x6e, - 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x73, 0x6e, 0x69, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x10, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x6e, - 0x69, 0x12, 0x4e, 0x0a, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, 0x72, - 0x5f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x68, 0x61, - 0x69, 0x6e, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0c, 0x52, - 0x20, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, 0x69, - 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x68, 0x61, 0x32, 0x35, - 0x36, 0x12, 0x57, 0x0a, 0x29, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, 0x72, - 0x5f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0e, - 0x20, 0x03, 0x28, 0x0c, 0x52, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, - 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, - 0x63, 0x4b, 0x65, 0x79, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x61, - 0x73, 0x74, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x0f, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, - 0x42, 0x73, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, - 0x74, 0x6c, 0x73, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, - 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x2e, 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x43, 0x68, 0x61, + 0x69, 0x6e, 0x22, 0x44, 0x0a, 0x05, 0x55, 0x73, 0x61, 0x67, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x45, + 0x4e, 0x43, 0x49, 0x50, 0x48, 0x45, 0x52, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x00, 0x12, 0x14, 0x0a, + 0x10, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x56, 0x45, 0x52, 0x49, 0x46, + 0x59, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, + 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xf6, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x6e, 0x73, + 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, + 0x6f, 0x77, 0x49, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x63, 0x65, + 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x2e, 0x43, 0x65, + 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x52, 0x0b, 0x63, 0x65, 0x72, 0x74, 0x69, + 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x6e, 0x65, 0x78, 0x74, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, + 0x6e, 0x65, 0x78, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x3a, 0x0a, 0x19, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x72, + 0x65, 0x73, 0x75, 0x6d, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x17, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x73, 0x75, 0x6d, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x0a, 0x13, 0x64, 0x69, 0x73, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x5f, 0x72, 0x6f, 0x6f, 0x74, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x11, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x79, + 0x73, 0x74, 0x65, 0x6d, 0x52, 0x6f, 0x6f, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x69, 0x6e, 0x5f, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6d, + 0x69, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a, 0x0b, 0x6d, 0x61, 0x78, + 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x6d, 0x61, 0x78, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x69, + 0x70, 0x68, 0x65, 0x72, 0x5f, 0x73, 0x75, 0x69, 0x74, 0x65, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x53, 0x75, 0x69, 0x74, 0x65, 0x73, 0x12, + 0x41, 0x0a, 0x1b, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, + 0x5f, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x5f, 0x73, 0x75, 0x69, 0x74, 0x65, 0x73, 0x18, 0x0a, + 0x20, 0x01, 0x28, 0x08, 0x42, 0x02, 0x18, 0x01, 0x52, 0x18, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x53, 0x75, 0x69, 0x74, + 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, + 0x72, 0x69, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x75, + 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x73, 0x6e, 0x69, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x10, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, + 0x6e, 0x69, 0x12, 0x4e, 0x0a, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, + 0x72, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x68, + 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0c, + 0x52, 0x20, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, + 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x68, 0x61, 0x32, + 0x35, 0x36, 0x12, 0x57, 0x0a, 0x29, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, + 0x72, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x75, + 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, + 0x0e, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, + 0x72, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, + 0x69, 0x63, 0x4b, 0x65, 0x79, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x24, 0x0a, 0x0e, 0x6d, + 0x61, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x0f, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, + 0x67, 0x42, 0x73, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2e, 0x74, 0x6c, 0x73, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, + 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/tls/config.proto b/transport/internet/tls/config.proto index 12c7b7cb..0bd44dee 100644 --- a/transport/internet/tls/config.proto +++ b/transport/internet/tls/config.proto @@ -31,6 +31,8 @@ message Certificate { // If true, one-Time Loading bool One_time_loading = 7; + + bool build_chain = 8; } message Config { From 521d8ef6a18a1567aa48df475d0db77ee64d1fb3 Mon Sep 17 00:00:00 2001 From: mayampi01 <176286256+mayampi01@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:36:30 +0800 Subject: [PATCH 465/867] Docker: Add multi-arch builds and Loyalsoldier flavor (#3589) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- .github/docker/Dockerfile | 28 +++++++++++++++---------- .github/workflows/docker.yml | 40 ++++++++++++++++++++++++++++++------ 2 files changed, 51 insertions(+), 17 deletions(-) diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index ad1e8c3d..211ef6d2 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -2,21 +2,27 @@ FROM --platform=$BUILDPLATFORM golang:alpine AS build WORKDIR /src COPY . . -ARG TARGETOS TARGETARCH +ARG TARGETOS +ARG TARGETARCH RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main +ADD https://github.com/v2fly/geoip/releases/latest/download/geoip.dat /v2fly/geoip.dat +ADD https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat /v2fly/geosite.dat +ADD https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat /loyalsoldier/geoip.dat +ADD https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat /loyalsoldier/geosite.dat -FROM --platform=${TARGETPLATFORM} alpine:latest -WORKDIR /root +# chainguard/static contains only tzdata and ca-certificates, can be built with multiarch static binaries. +FROM --platform=linux/amd64 chainguard/static:latest +WORKDIR /var/log/xray COPY .github/docker/files/config.json /etc/xray/config.json -COPY --from=build /src/xray /usr/bin/xray -RUN set -ex \ - && apk add --no-cache tzdata ca-certificates \ - && mkdir -p /var/log/xray /usr/share/xray \ - && chmod +x /usr/bin/xray \ - && wget -O /usr/share/xray/geosite.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat \ - && wget -O /usr/share/xray/geoip.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat +COPY --from=build --chmod=755 /src/xray /usr/bin/xray +USER root +WORKDIR /root VOLUME /etc/xray -ENV TZ=Asia/Shanghai +ARG TZ=Asia/Shanghai +ENV TZ=$TZ ENTRYPOINT [ "/usr/bin/xray" ] CMD [ "-config", "/etc/xray/config.json" ] + +ARG flavor=v2fly +COPY --from=build /$flavor /usr/share/xray diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 89a0b693..c0945db3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -25,24 +25,52 @@ jobs: type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} + - name: Docker metadata Loyalsoldier flavor + id: loyalsoldier + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository_owner }}/xray-core + flavor: | + latest=auto + suffix=-ls,onlatest=true + tags: | + type=sha + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - # Add support for more platforms with QEMU (optional) - # https://github.com/docker/setup-qemu-action - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Build and push uses: docker/build-push-action@v6 with: context: . - platforms: linux/amd64,linux/arm64 + platforms: | + linux/amd64 + linux/arm64 + linux/loong64 + linux/riscv64 + provenance: false file: .github/docker/Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + - name: Build and push Loyalsoldier flavor + uses: docker/build-push-action@v6 + with: + context: . + platforms: | + linux/amd64 + linux/arm64 + linux/loong64 + linux/riscv64 + provenance: false + file: .github/docker/Dockerfile + build-args: flavor=loyalsoldier + push: true + tags: | + ${{ steps.loyalsoldier.outputs.tags }} From 70383c50ccbbb0168260db157a5d4771d0afbef2 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 29 Jul 2024 08:22:12 +0000 Subject: [PATCH 466/867] v1.8.22 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 077b2638..dede7704 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 21 + Version_z byte = 22 ) var ( From 33daa0c94b5c48d0da195268f3ad34ea5511cbd3 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:50:59 +0200 Subject: [PATCH 467/867] SplitHTTP: Fix wrong config deserialization (#3610) Testing was conducted only using explicit parameters, and using testsuite. However, when the parameters are not explicitly set in JSON config, it seems that `c.MaxUploadSize` will contain `RandRangeConfig { From: 0, To: 0 }` instead of `nil`, which breaks upload entirely. --- transport/internet/splithttp/config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 8bb61746..7f2dc3f5 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -37,7 +37,7 @@ func (c *Config) GetRequestHeader() http.Header { } func (c *Config) GetNormalizedMaxConcurrentUploads(isServer bool) RandRangeConfig { - if c.MaxConcurrentUploads == nil { + if c.MaxConcurrentUploads == nil || c.MaxConcurrentUploads.To == 0 { if isServer { return RandRangeConfig{ From: 200, @@ -55,7 +55,7 @@ func (c *Config) GetNormalizedMaxConcurrentUploads(isServer bool) RandRangeConfi } func (c *Config) GetNormalizedMaxUploadSize(isServer bool) RandRangeConfig { - if c.MaxUploadSize == nil { + if c.MaxUploadSize == nil || c.MaxUploadSize.To == 0 { if isServer { return RandRangeConfig{ From: 2000000, @@ -73,7 +73,7 @@ func (c *Config) GetNormalizedMaxUploadSize(isServer bool) RandRangeConfig { } func (c *Config) GetNormalizedMinUploadInterval() RandRangeConfig { - if c.MinUploadIntervalMs == nil { + if c.MinUploadIntervalMs == nil || c.MinUploadIntervalMs.To == 0 { return RandRangeConfig{ From: 30, To: 30, From 30af792777fb3992026e90a066cde73311d9b90b Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Mon, 29 Jul 2024 12:10:29 +0200 Subject: [PATCH 468/867] SplitHTTP: Rename three options & Reduce server defaults (#3611) * maxUploadSize -> scMaxEachPostBytes, default is 1MB on both sides (was 2MB on the server) * minUploadIntervalMs -> scMinPostsIntervalMs, default is 30ms on the client (no server support for now) * maxConcurrentUploads -> scMaxConcurrentPosts, default is 100 on both sides (was 200 on the server) --- infra/conf/transport_internet.go | 24 +++---- transport/internet/splithttp/config.go | 44 ++++-------- transport/internet/splithttp/config.pb.go | 88 +++++++++++------------ transport/internet/splithttp/config.proto | 6 +- transport/internet/splithttp/dialer.go | 14 ++-- transport/internet/splithttp/hub.go | 8 +-- 6 files changed, 85 insertions(+), 99 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 40f648b3..f50a1edb 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -229,9 +229,9 @@ type SplitHTTPConfig struct { Host string `json:"host"` Path string `json:"path"` Headers map[string]string `json:"headers"` - MaxConcurrentUploads Int32Range `json:"maxConcurrentUploads"` - MaxUploadSize Int32Range `json:"maxUploadSize"` - MinUploadIntervalMs Int32Range `json:"minUploadIntervalMs"` + ScMaxConcurrentPosts Int32Range `json:"scMaxConcurrentPosts"` + ScMaxEachPostBytes Int32Range `json:"scMaxEachPostBytes"` + ScMinPostsIntervalMs Int32Range `json:"scMinPostsIntervalMs"` NoSSEHeader bool `json:"noSSEHeader"` } @@ -249,17 +249,17 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { Path: c.Path, Host: c.Host, Header: c.Headers, - MaxConcurrentUploads: &splithttp.RandRangeConfig{ - From: c.MaxConcurrentUploads.From, - To: c.MaxConcurrentUploads.To, + ScMaxConcurrentPosts: &splithttp.RandRangeConfig{ + From: c.ScMaxConcurrentPosts.From, + To: c.ScMaxConcurrentPosts.To, }, - MaxUploadSize: &splithttp.RandRangeConfig{ - From: c.MaxUploadSize.From, - To: c.MaxUploadSize.To, + ScMaxEachPostBytes: &splithttp.RandRangeConfig{ + From: c.ScMaxEachPostBytes.From, + To: c.ScMaxEachPostBytes.To, }, - MinUploadIntervalMs: &splithttp.RandRangeConfig{ - From: c.MinUploadIntervalMs.From, - To: c.MinUploadIntervalMs.To, + ScMinPostsIntervalMs: &splithttp.RandRangeConfig{ + From: c.ScMinPostsIntervalMs.From, + To: c.ScMinPostsIntervalMs.To, }, NoSSEHeader: c.NoSSEHeader, } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 7f2dc3f5..a2595038 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -36,51 +36,37 @@ func (c *Config) GetRequestHeader() http.Header { return header } -func (c *Config) GetNormalizedMaxConcurrentUploads(isServer bool) RandRangeConfig { - if c.MaxConcurrentUploads == nil || c.MaxConcurrentUploads.To == 0 { - if isServer { - return RandRangeConfig{ - From: 200, - To: 200, - } - } else { - return RandRangeConfig{ - From: 100, - To: 100, - } +func (c *Config) GetNormalizedScMaxConcurrentPosts() RandRangeConfig { + if c.ScMaxConcurrentPosts == nil || c.ScMaxConcurrentPosts.To == 0 { + return RandRangeConfig{ + From: 100, + To: 100, } } - return *c.MaxConcurrentUploads + return *c.ScMaxConcurrentPosts } -func (c *Config) GetNormalizedMaxUploadSize(isServer bool) RandRangeConfig { - if c.MaxUploadSize == nil || c.MaxUploadSize.To == 0 { - if isServer { - return RandRangeConfig{ - From: 2000000, - To: 2000000, - } - } else { - return RandRangeConfig{ - From: 1000000, - To: 1000000, - } +func (c *Config) GetNormalizedScMaxEachPostBytes() RandRangeConfig { + if c.ScMaxEachPostBytes == nil || c.ScMaxEachPostBytes.To == 0 { + return RandRangeConfig{ + From: 1000000, + To: 1000000, } } - return *c.MaxUploadSize + return *c.ScMaxEachPostBytes } -func (c *Config) GetNormalizedMinUploadInterval() RandRangeConfig { - if c.MinUploadIntervalMs == nil || c.MinUploadIntervalMs.To == 0 { +func (c *Config) GetNormalizedScMinPostsIntervalMs() RandRangeConfig { + if c.ScMinPostsIntervalMs == nil || c.ScMinPostsIntervalMs.To == 0 { return RandRangeConfig{ From: 30, To: 30, } } - return *c.MinUploadIntervalMs + return *c.ScMinPostsIntervalMs } func init() { diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 8e69867e..c543df00 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -28,9 +28,9 @@ type Config struct { Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` Header map[string]string `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - MaxConcurrentUploads *RandRangeConfig `protobuf:"bytes,4,opt,name=maxConcurrentUploads,proto3" json:"maxConcurrentUploads,omitempty"` - MaxUploadSize *RandRangeConfig `protobuf:"bytes,5,opt,name=maxUploadSize,proto3" json:"maxUploadSize,omitempty"` - MinUploadIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=minUploadIntervalMs,proto3" json:"minUploadIntervalMs,omitempty"` + ScMaxConcurrentPosts *RandRangeConfig `protobuf:"bytes,4,opt,name=scMaxConcurrentPosts,proto3" json:"scMaxConcurrentPosts,omitempty"` + ScMaxEachPostBytes *RandRangeConfig `protobuf:"bytes,5,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` + ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` } @@ -87,23 +87,23 @@ func (x *Config) GetHeader() map[string]string { return nil } -func (x *Config) GetMaxConcurrentUploads() *RandRangeConfig { +func (x *Config) GetScMaxConcurrentPosts() *RandRangeConfig { if x != nil { - return x.MaxConcurrentUploads + return x.ScMaxConcurrentPosts } return nil } -func (x *Config) GetMaxUploadSize() *RandRangeConfig { +func (x *Config) GetScMaxEachPostBytes() *RandRangeConfig { if x != nil { - return x.MaxUploadSize + return x.ScMaxEachPostBytes } return nil } -func (x *Config) GetMinUploadIntervalMs() *RandRangeConfig { +func (x *Config) GetScMinPostsIntervalMs() *RandRangeConfig { if x != nil { - return x.MinUploadIntervalMs + return x.ScMinPostsIntervalMs } return nil } @@ -177,7 +177,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0x84, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0x86, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, @@ -192,37 +192,37 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x14, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x58, 0x0a, 0x0d, 0x6d, 0x61, 0x78, 0x55, - 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, - 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x0d, 0x6d, 0x61, 0x78, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x69, - 0x7a, 0x65, 0x12, 0x64, 0x0a, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, - 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, - 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, - 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, - 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, - 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, - 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, - 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, - 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, - 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, - 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, - 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x55, + 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, + 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, + 0x79, 0x74, 0x65, 0x73, 0x12, 0x64, 0x0a, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, + 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, + 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, + 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, + 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, + 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x42, 0x85, + 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, + 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, + 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -245,9 +245,9 @@ var file_transport_internet_splithttp_config_proto_goTypes = []interface{}{ } var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 2, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry - 1, // 1: xray.transport.internet.splithttp.Config.maxConcurrentUploads:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 2: xray.transport.internet.splithttp.Config.maxUploadSize:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 3: xray.transport.internet.splithttp.Config.minUploadIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 1: xray.transport.internet.splithttp.Config.scMaxConcurrentPosts:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig 4, // [4:4] is the sub-list for method output_type 4, // [4:4] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 807732c3..b8af30c4 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -10,9 +10,9 @@ message Config { string host = 1; string path = 2; map header = 3; - RandRangeConfig maxConcurrentUploads = 4; - RandRangeConfig maxUploadSize = 5; - RandRangeConfig minUploadIntervalMs = 6; + RandRangeConfig scMaxConcurrentPosts = 4; + RandRangeConfig scMaxEachPostBytes = 5; + RandRangeConfig scMinPostsIntervalMs = 6; bool noSSEHeader = 7; } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 0448b2f7..07e5d5d1 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -181,9 +181,9 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me transportConfiguration := streamSettings.ProtocolSettings.(*Config) tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - maxConcurrentUploads := transportConfiguration.GetNormalizedMaxConcurrentUploads(false) - maxUploadSize := transportConfiguration.GetNormalizedMaxUploadSize(false) - minUploadInterval := transportConfiguration.GetNormalizedMinUploadInterval() + scMaxConcurrentPosts := transportConfiguration.GetNormalizedScMaxConcurrentPosts() + scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes() + scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs() if tlsConfig != nil { requestURL.Scheme = "https" @@ -201,10 +201,10 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me httpClient := getHTTPClient(ctx, dest, streamSettings) - uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize.roll())) + uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(scMaxEachPostBytes.roll())) go func() { - requestsLimiter := semaphore.New(int(maxConcurrentUploads.roll())) + requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll())) var requestCounter int64 lastWrite := time.Now() @@ -239,8 +239,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } }() - if minUploadInterval.From > 0 { - roll := time.Duration(minUploadInterval.roll()) * time.Millisecond + if scMinPostsIntervalMs.From > 0 { + roll := time.Duration(scMinPostsIntervalMs.roll()) * time.Millisecond if time.Since(lastWrite) < roll { time.Sleep(roll) } diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index ce54ed07..30bc8b1e 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -76,7 +76,7 @@ func (h *requestHandler) upsertSession(sessionId string) *httpSession { } s := &httpSession{ - uploadQueue: NewUploadQueue(int(h.ln.config.GetNormalizedMaxConcurrentUploads(true).To)), + uploadQueue: NewUploadQueue(int(h.ln.config.GetNormalizedScMaxConcurrentPosts().To)), isFullyConnected: done.New(), } @@ -123,7 +123,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } currentSession := h.upsertSession(sessionId) - maxUploadSize := int(h.ln.config.GetNormalizedMaxUploadSize(true).To) + scMaxEachPostBytes := int(h.ln.config.GetNormalizedScMaxEachPostBytes().To) if request.Method == "POST" { seq := "" @@ -139,8 +139,8 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req payload, err := io.ReadAll(request.Body) - if len(payload) > maxUploadSize { - errors.LogInfo(context.Background(), "Too large upload. maxUploadSize is set to", maxUploadSize, "but request had size", len(payload), ". Adjust maxUploadSize on the server to be at least as large as client.") + if len(payload) > scMaxEachPostBytes { + errors.LogInfo(context.Background(), "Too large upload. scMaxEachPostBytes is set to ", scMaxEachPostBytes, "but request had size ", len(payload), ". Adjust scMaxEachPostBytes on the server to be at least as large as client.") writer.WriteHeader(http.StatusRequestEntityTooLarge) return } From 4c82ef8a1b79a609efd3f7ba947896b6f8a2917c Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:23:04 +0000 Subject: [PATCH 469/867] v1.8.23 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index dede7704..084cea72 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 22 + Version_z byte = 23 ) var ( From 4b7947cca91cacd63262711210e96c2d444bc7b5 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Fri, 2 Aug 2024 03:16:19 +0200 Subject: [PATCH 470/867] SplitHTTP server: add ok padding (#3614) --- infra/conf/transport_internet.go | 42 ++++++++------- transport/internet/splithttp/config.go | 11 ++++ transport/internet/splithttp/config.pb.go | 64 ++++++++++++++--------- transport/internet/splithttp/config.proto | 1 + transport/internet/splithttp/hub.go | 5 ++ 5 files changed, 80 insertions(+), 43 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index f50a1edb..0fa6a381 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -229,10 +229,22 @@ type SplitHTTPConfig struct { Host string `json:"host"` Path string `json:"path"` Headers map[string]string `json:"headers"` - ScMaxConcurrentPosts Int32Range `json:"scMaxConcurrentPosts"` - ScMaxEachPostBytes Int32Range `json:"scMaxEachPostBytes"` - ScMinPostsIntervalMs Int32Range `json:"scMinPostsIntervalMs"` + ScMaxConcurrentPosts *Int32Range `json:"scMaxConcurrentPosts"` + ScMaxEachPostBytes *Int32Range `json:"scMaxEachPostBytes"` + ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"` NoSSEHeader bool `json:"noSSEHeader"` + ResponseOkPadding *Int32Range `json:"responseOkPadding"` +} + +func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { + if input == nil { + return nil + } + + return &splithttp.RandRangeConfig{ + From: input.From, + To: input.To, + } } // Build implements Buildable. @@ -246,22 +258,14 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { c.Host = c.Headers["Host"] } config := &splithttp.Config{ - Path: c.Path, - Host: c.Host, - Header: c.Headers, - ScMaxConcurrentPosts: &splithttp.RandRangeConfig{ - From: c.ScMaxConcurrentPosts.From, - To: c.ScMaxConcurrentPosts.To, - }, - ScMaxEachPostBytes: &splithttp.RandRangeConfig{ - From: c.ScMaxEachPostBytes.From, - To: c.ScMaxEachPostBytes.To, - }, - ScMinPostsIntervalMs: &splithttp.RandRangeConfig{ - From: c.ScMinPostsIntervalMs.From, - To: c.ScMinPostsIntervalMs.To, - }, - NoSSEHeader: c.NoSSEHeader, + Path: c.Path, + Host: c.Host, + Header: c.Headers, + ScMaxConcurrentPosts: splithttpNewRandRangeConfig(c.ScMaxConcurrentPosts), + ScMaxEachPostBytes: splithttpNewRandRangeConfig(c.ScMaxEachPostBytes), + ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs), + NoSSEHeader: c.NoSSEHeader, + ResponseOkPadding: splithttpNewRandRangeConfig(c.ResponseOkPadding), } return config, nil } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index a2595038..efdb3f65 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -69,6 +69,17 @@ func (c *Config) GetNormalizedScMinPostsIntervalMs() RandRangeConfig { return *c.ScMinPostsIntervalMs } +func (c *Config) GetNormalizedResponseOkPadding() RandRangeConfig { + if c.ResponseOkPadding == nil || c.ResponseOkPadding.To == 0 { + return RandRangeConfig{ + From: 100, + To: 1000, + } + } + + return *c.ResponseOkPadding +} + func init() { common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { return new(Config) diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index c543df00..b5cd7ce1 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -32,6 +32,7 @@ type Config struct { ScMaxEachPostBytes *RandRangeConfig `protobuf:"bytes,5,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` + ResponseOkPadding *RandRangeConfig `protobuf:"bytes,8,opt,name=responseOkPadding,proto3" json:"responseOkPadding,omitempty"` } func (x *Config) Reset() { @@ -115,6 +116,13 @@ func (x *Config) GetNoSSEHeader() bool { return false } +func (x *Config) GetResponseOkPadding() *RandRangeConfig { + if x != nil { + return x.ResponseOkPadding + } + return nil +} + type RandRangeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -177,7 +185,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0x86, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xf6, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, @@ -186,27 +194,34 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x12, 0x66, 0x0a, 0x14, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, + 0x12, 0x66, 0x0a, 0x14, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x14, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x74, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x55, - 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, - 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x42, - 0x79, 0x74, 0x65, 0x73, 0x12, 0x64, 0x0a, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, - 0x64, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, - 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x13, 0x6d, 0x69, 0x6e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, - 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, + 0x69, 0x67, 0x52, 0x14, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x62, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, + 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, + 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x45, + 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x66, 0x0a, 0x14, + 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, + 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, + 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x14, + 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, + 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x64, 0x0a, 0x13, 0x67, 0x65, 0x74, 0x48, 0x61, 0x6e, + 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, + 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, + 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x13, 0x67, 0x65, 0x74, 0x48, 0x61, 0x6e, 0x64, + 0x73, 0x68, 0x61, 0x6b, 0x65, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, @@ -248,11 +263,12 @@ var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 1, // 1: xray.transport.internet.splithttp.Config.scMaxConcurrentPosts:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 1, // 4: xray.transport.internet.splithttp.Config.responseOkPadding:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_transport_internet_splithttp_config_proto_init() } diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index b8af30c4..ee8a3909 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -14,6 +14,7 @@ message Config { RandRangeConfig scMaxEachPostBytes = 5; RandRangeConfig scMinPostsIntervalMs = 6; bool noSSEHeader = 7; + RandRangeConfig responseOkPadding = 8; } message RandRangeConfig { diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 30bc8b1e..3ba429ea 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -124,6 +124,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req currentSession := h.upsertSession(sessionId) scMaxEachPostBytes := int(h.ln.config.GetNormalizedScMaxEachPostBytes().To) + responseOkPadding := h.ln.config.GetNormalizedResponseOkPadding() if request.Method == "POST" { seq := "" @@ -192,6 +193,10 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req // send a chunk immediately to enable CDN streaming. // many CDN buffer the response headers until the origin starts sending // the body, with no way to turn it off. + padding := int(responseOkPadding.roll()) + for i := 0; i < padding; i++ { + writer.Write([]byte("o")) + } writer.Write([]byte("ok")) responseFlusher.Flush() From 7e24239c9acbaa37b8c0f31547b8292a0fd19de0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 03:16:37 +0200 Subject: [PATCH 471/867] Bump github.com/quic-go/quic-go from 0.45.1 to 0.45.2 (#3623) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e60acb4c..6faf30d9 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/miekg/dns v1.1.61 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.45.1 + github.com/quic-go/quic-go v0.45.2 github.com/refraction-networking/utls v1.6.7 github.com/sagernet/sing v0.4.1 github.com/sagernet/sing-shadowsocks v0.2.7 diff --git a/go.sum b/go.sum index 15137ad3..e2fe1fa6 100644 --- a/go.sum +++ b/go.sum @@ -112,8 +112,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/quic-go v0.45.1 h1:tPfeYCk+uZHjmDRwHHQmvHRYL2t44ROTujLeFVBmjCA= -github.com/quic-go/quic-go v0.45.1/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= +github.com/quic-go/quic-go v0.45.2 h1:DfqBmqjb4ExSdxRIb/+qXhPC+7k6+DUNZha4oeiC9fY= +github.com/quic-go/quic-go v0.45.2/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From 644901d1a5c1728f2d41a1ba3d86a059029b0b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Sat, 3 Aug 2024 10:08:23 +0800 Subject: [PATCH 472/867] Socks4a server: Check if the client sends an IP address as domain (#3628) Fixes https://github.com/XTLS/Xray-core/issues/3622 --- common/net/address.go | 5 +++++ proxy/socks/protocol.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/common/net/address.go b/common/net/address.go index a5f7c160..1567e4d1 100644 --- a/common/net/address.go +++ b/common/net/address.go @@ -121,6 +121,11 @@ func IPAddress(ip []byte) Address { } // DomainAddress creates an Address with given domain. +// This is an internal function that forcibly converts a string to domain. +// It's mainly used in test files and mux. +// Unless you have a specific reason, use net.ParseAddress instead, +// as this function does not check whether the input is an IP address. +// Otherwise, you will get strange results like domain: 1.1.1.1 func DomainAddress(domain string) Address { return domainAddress(domain) } diff --git a/proxy/socks/protocol.go b/proxy/socks/protocol.go index fe13f24f..9bccf607 100644 --- a/proxy/socks/protocol.go +++ b/proxy/socks/protocol.go @@ -74,7 +74,7 @@ func (s *ServerSession) handshake4(cmd byte, reader io.Reader, writer io.Writer) if err != nil { return nil, errors.New("failed to read domain for socks 4a").Base(err) } - address = net.DomainAddress(domain) + address = net.ParseAddress(domain) } switch cmd { From 4c9e4b9de7a4591c9e6ee01fa2181952784061d3 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 3 Aug 2024 14:56:05 +0000 Subject: [PATCH 473/867] README.md: Add NFTs --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 66a8199f..3c1d1ec2 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ [README](https://github.com/XTLS/Xray-core#readme) is open, so feel free to submit your project [here](https://github.com/XTLS/Xray-core/pulls). +## NFTs + +[Announcement of NFTs by Project X](https://github.com/XTLS/Xray-core/discussions/3633) + ## License [Mozilla Public License Version 2.0](https://github.com/XTLS/Xray-core/blob/main/LICENSE) From 2a5eb3db7d14aa1789a10d28a440f9e0c472bd14 Mon Sep 17 00:00:00 2001 From: definitio <37266727+definitio@users.noreply.github.com> Date: Mon, 5 Aug 2024 01:21:22 +0300 Subject: [PATCH 474/867] Docker: Fix permissions of geosite and geodat (#3634) --- .github/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index 211ef6d2..31139529 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -25,4 +25,4 @@ ENTRYPOINT [ "/usr/bin/xray" ] CMD [ "-config", "/etc/xray/config.json" ] ARG flavor=v2fly -COPY --from=build /$flavor /usr/share/xray +COPY --from=build --chmod=644 /$flavor /usr/share/xray From 1dfec5056de5df2ffa53ce1a6de131149f603857 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:22:12 -0400 Subject: [PATCH 475/867] Bump golang.org/x/sys from 0.22.0 to 0.23.0 (#3639) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.22.0 to 0.23.0. - [Commits](https://github.com/golang/sys/compare/v0.22.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6faf30d9..a5b21d8b 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/crypto v0.25.0 golang.org/x/net v0.27.0 golang.org/x/sync v0.7.0 - golang.org/x/sys v0.22.0 + golang.org/x/sys v0.23.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.65.0 google.golang.org/protobuf v1.34.2 diff --git a/go.sum b/go.sum index e2fe1fa6..cd878a98 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= +golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From c6d9d430bff8673f067047f788b6d648e14af389 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Aug 2024 22:24:16 -0400 Subject: [PATCH 476/867] Bump golang.org/x/sync from 0.7.0 to 0.8.0 (#3640) Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.7.0 to 0.8.0. - [Commits](https://github.com/golang/sync/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: golang.org/x/sync dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a5b21d8b..33dce206 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.25.0 golang.org/x/net v0.27.0 - golang.org/x/sync v0.7.0 + golang.org/x/sync v0.8.0 golang.org/x/sys v0.23.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.65.0 diff --git a/go.sum b/go.sum index cd878a98..ae0a5d97 100644 --- a/go.sum +++ b/go.sum @@ -214,8 +214,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= From 661cb901def783e68519b1a4ff13472c11b5f340 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 7 Aug 2024 00:28:06 +0000 Subject: [PATCH 477/867] Bump golang.org/x/net from 0.27.0 to 0.28.0 (#3649) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.27.0 to 0.28.0. - [Commits](https://github.com/golang/net/compare/v0.27.0...v0.28.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 33dce206..ff42f917 100644 --- a/go.mod +++ b/go.mod @@ -22,8 +22,8 @@ require ( github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.25.0 - golang.org/x/net v0.27.0 + golang.org/x/crypto v0.26.0 + golang.org/x/net v0.28.0 golang.org/x/sync v0.8.0 golang.org/x/sys v0.23.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 @@ -52,7 +52,7 @@ require ( go.uber.org/mock v0.4.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/mod v0.18.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/text v0.17.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect diff --git a/go.sum b/go.sum index ae0a5d97..8b16d691 100644 --- a/go.sum +++ b/go.sum @@ -179,8 +179,8 @@ golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= @@ -201,8 +201,8 @@ golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -235,8 +235,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= From 4a1c0d71240cb89ed26f2b9a2e433a2832415b90 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 7 Aug 2024 13:15:25 +0000 Subject: [PATCH 478/867] README.md: Rename NFTs to Donation & NFTs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c1d1ec2..026d1491 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [README](https://github.com/XTLS/Xray-core#readme) is open, so feel free to submit your project [here](https://github.com/XTLS/Xray-core/pulls). -## NFTs +## Donation & NFTs [Announcement of NFTs by Project X](https://github.com/XTLS/Xray-core/discussions/3633) From ac628a942770c6421402ad7ecc054d61b679512d Mon Sep 17 00:00:00 2001 From: nobody <59990325+vrnobody@users.noreply.github.com> Date: Thu, 8 Aug 2024 22:35:46 +0800 Subject: [PATCH 479/867] API: Improve MarshalToJson() in common/reflect/marshal.go (#3655) * Serialize enum to string in MarshalToJson(). * MarshalToJson() respect json tags. * Add insertTypeInfo parameter to MarshalToJson(). * Omit empty string in MarshalToJson(). * Serialize PortList to string in MarshalToJson(). --------- Co-authored-by: nobody --- common/reflect/marshal.go | 135 ++++++++++++++++++++++++++------- common/reflect/marshal_test.go | 52 ++++++++++--- infra/conf/serial/builder.go | 2 +- 3 files changed, 148 insertions(+), 41 deletions(-) diff --git a/common/reflect/marshal.go b/common/reflect/marshal.go index 736afc01..dce34168 100644 --- a/common/reflect/marshal.go +++ b/common/reflect/marshal.go @@ -2,13 +2,17 @@ package reflect import ( "encoding/json" + "fmt" "reflect" + "strings" + cnet "github.com/xtls/xray-core/common/net" cserial "github.com/xtls/xray-core/common/serial" + "github.com/xtls/xray-core/infra/conf" ) -func MarshalToJson(v interface{}) (string, bool) { - if itf := marshalInterface(v, true); itf != nil { +func MarshalToJson(v interface{}, insertTypeInfo bool) (string, bool) { + if itf := marshalInterface(v, true, insertTypeInfo); itf != nil { if b, err := json.MarshalIndent(itf, "", " "); err == nil { return string(b[:]), true } @@ -16,7 +20,7 @@ func MarshalToJson(v interface{}) (string, bool) { return "", false } -func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool) interface{} { +func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool, insertTypeInfo bool) interface{} { if v == nil { return nil } @@ -24,36 +28,67 @@ func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool) interfac if err != nil { return nil } - r := marshalInterface(tmsg, ignoreNullValue) - if msg, ok := r.(map[string]interface{}); ok { + r := marshalInterface(tmsg, ignoreNullValue, insertTypeInfo) + if msg, ok := r.(map[string]interface{}); ok && insertTypeInfo { msg["_TypedMessage_"] = v.Type } return r } -func marshalSlice(v reflect.Value, ignoreNullValue bool) interface{} { +func marshalSlice(v reflect.Value, ignoreNullValue bool, insertTypeInfo bool) interface{} { r := make([]interface{}, 0) for i := 0; i < v.Len(); i++ { rv := v.Index(i) if rv.CanInterface() { value := rv.Interface() - r = append(r, marshalInterface(value, ignoreNullValue)) + r = append(r, marshalInterface(value, ignoreNullValue, insertTypeInfo)) } } return r } -func marshalStruct(v reflect.Value, ignoreNullValue bool) interface{} { +func isNullValue(f reflect.StructField, rv reflect.Value) bool { + if rv.Kind() == reflect.String && rv.Len() == 0 { + return true + } else if !isValueKind(rv.Kind()) && rv.IsNil() { + return true + } else if tag := f.Tag.Get("json"); strings.Contains(tag, "omitempty") { + if !rv.IsValid() || rv.IsZero() { + return true + } + } + return false +} + +func toJsonName(f reflect.StructField) string { + if tags := f.Tag.Get("protobuf"); len(tags) > 0 { + for _, tag := range strings.Split(tags, ",") { + if before, after, ok := strings.Cut(tag, "="); ok && before == "json" { + return after + } + } + } + if tag := f.Tag.Get("json"); len(tag) > 0 { + if before, _, ok := strings.Cut(tag, ","); ok { + return before + } else { + return tag + } + } + return f.Name +} + +func marshalStruct(v reflect.Value, ignoreNullValue bool, insertTypeInfo bool) interface{} { r := make(map[string]interface{}) t := v.Type() for i := 0; i < v.NumField(); i++ { rv := v.Field(i) if rv.CanInterface() { ft := t.Field(i) - name := ft.Name - value := rv.Interface() - tv := marshalInterface(value, ignoreNullValue) - if tv != nil || !ignoreNullValue { + if !ignoreNullValue || !isNullValue(ft, rv) { + name := toJsonName(ft) + value := rv.Interface() + tv := marshalInterface(value, ignoreNullValue, insertTypeInfo) r[name] = tv } } @@ -61,7 +96,7 @@ func marshalStruct(v reflect.Value, ignoreNullValue bool) interface{} { return r } -func marshalMap(v reflect.Value, ignoreNullValue bool) interface{} { +func marshalMap(v reflect.Value, ignoreNullValue bool, insertTypeInfo bool) interface{} { // policy.level is map[uint32] *struct kt := v.Type().Key() vt := reflect.TypeOf((*interface{})(nil)) @@ -71,7 +106,7 @@ func marshalMap(v reflect.Value, ignoreNullValue bool) interface{} { rv := v.MapIndex(key) if rv.CanInterface() { iv := rv.Interface() - tv := marshalInterface(iv, ignoreNullValue) + tv := marshalInterface(iv, ignoreNullValue, insertTypeInfo) if tv != nil || !ignoreNullValue { r.SetMapIndex(key, reflect.ValueOf(&tv)) } @@ -87,27 +122,63 @@ func marshalIString(v interface{}) (r string, ok bool) { ok = false } }() - if iStringFn, ok := v.(interface{ String() string }); ok { return iStringFn.String(), true } return "", false } -func marshalKnownType(v interface{}, ignoreNullValue bool) (interface{}, bool) { +func serializePortList(portList *cnet.PortList) (interface{}, bool) { + if portList == nil { + return nil, false + } + + n := len(portList.Range) + if n == 1 { + if first := portList.Range[0]; first.From == first.To { + return first.From, true + } + } + + r := make([]string, 0, n) + for _, pr := range portList.Range { + if pr.From == pr.To { + r = append(r, pr.FromPort().String()) + } else { + r = append(r, fmt.Sprintf("%d-%d", pr.From, pr.To)) + } + } + return strings.Join(r, ","), true +} + +func marshalKnownType(v interface{}, ignoreNullValue bool, insertTypeInfo bool) (interface{}, bool) { switch ty := v.(type) { case cserial.TypedMessage: - return marshalTypedMessage(&ty, ignoreNullValue), true + return marshalTypedMessage(&ty, ignoreNullValue, insertTypeInfo), true case *cserial.TypedMessage: - return marshalTypedMessage(ty, ignoreNullValue), true + return marshalTypedMessage(ty, ignoreNullValue, insertTypeInfo), true case map[string]json.RawMessage: return ty, true case []json.RawMessage: return ty, true - case *json.RawMessage: - return ty, true - case json.RawMessage: + case *json.RawMessage, json.RawMessage: return ty, true + case *cnet.IPOrDomain: + if domain := v.(*cnet.IPOrDomain); domain != nil { + return domain.AsAddress().String(), true + } + return nil, false + case *cnet.PortList: + npl := v.(*cnet.PortList) + return serializePortList(npl) + case *conf.PortList: + cpl := v.(*conf.PortList) + return serializePortList(cpl.Build()) + case cnet.Address: + if addr := v.(cnet.Address); addr != nil { + return addr.String(), true + } + return nil, false default: return nil, false } @@ -138,9 +209,9 @@ func isValueKind(kind reflect.Kind) bool { } } -func marshalInterface(v interface{}, ignoreNullValue bool) interface{} { +func marshalInterface(v interface{}, ignoreNullValue bool, insertTypeInfo bool) interface{} { - if r, ok := marshalKnownType(v, ignoreNullValue); ok { + if r, ok := marshalKnownType(v, ignoreNullValue, insertTypeInfo); ok { return r } @@ -152,19 +223,27 @@ func marshalInterface(v interface{}, ignoreNullValue bool) interface{} { if k == reflect.Invalid { return nil } - if isValueKind(k) { + + if ty := rv.Type().Name(); isValueKind(k) { + if k.String() != ty { + if s, ok := marshalIString(v); ok { + return s + } + } return v } + // fmt.Println("kind:", k, "type:", rv.Type().Name()) + switch k { case reflect.Struct: - return marshalStruct(rv, ignoreNullValue) + return marshalStruct(rv, ignoreNullValue, insertTypeInfo) case reflect.Slice: - return marshalSlice(rv, ignoreNullValue) + return marshalSlice(rv, ignoreNullValue, insertTypeInfo) case reflect.Array: - return marshalSlice(rv, ignoreNullValue) + return marshalSlice(rv, ignoreNullValue, insertTypeInfo) case reflect.Map: - return marshalMap(rv, ignoreNullValue) + return marshalMap(rv, ignoreNullValue, insertTypeInfo) default: break } diff --git a/common/reflect/marshal_test.go b/common/reflect/marshal_test.go index 377ad4e9..359abae0 100644 --- a/common/reflect/marshal_test.go +++ b/common/reflect/marshal_test.go @@ -6,11 +6,40 @@ import ( "strings" "testing" + "github.com/xtls/xray-core/common/protocol" . "github.com/xtls/xray-core/common/reflect" cserial "github.com/xtls/xray-core/common/serial" iserial "github.com/xtls/xray-core/infra/conf/serial" + "github.com/xtls/xray-core/proxy/shadowsocks" ) +func TestMashalAccount(t *testing.T) { + account := &shadowsocks.Account{ + Password: "shadowsocks-password", + CipherType: shadowsocks.CipherType_CHACHA20_POLY1305, + } + + user := &protocol.User{ + Level: 0, + Email: "love@v2ray.com", + Account: cserial.ToTypedMessage(account), + } + + j, ok := MarshalToJson(user, false) + if !ok || strings.Contains(j, "_TypedMessage_") { + + t.Error("marshal account failed") + } + + kws := []string{"CHACHA20_POLY1305", "cipherType", "shadowsocks-password"} + for _, kw := range kws { + if !strings.Contains(j, kw) { + t.Error("marshal account failed") + } + } + // t.Log(j) +} + func TestMashalStruct(t *testing.T) { type Foo = struct { N int `json:"n"` @@ -36,8 +65,8 @@ func TestMashalStruct(t *testing.T) { Arr: &arr, } - s, ok1 := MarshalToJson(f1) - sp, ok2 := MarshalToJson(&f1) + s, ok1 := MarshalToJson(f1, true) + sp, ok2 := MarshalToJson(&f1, true) if !ok1 || !ok2 || s != sp { t.Error("marshal failed") @@ -69,7 +98,7 @@ func TestMarshalConfigJson(t *testing.T) { } tmsg := cserial.ToTypedMessage(bc) - tc, ok := MarshalToJson(tmsg) + tc, ok := MarshalToJson(tmsg, true) if !ok { t.Error("marshal config failed") } @@ -79,15 +108,14 @@ func TestMarshalConfigJson(t *testing.T) { keywords := []string{ "4784f9b8-a879-4fec-9718-ebddefa47750", "bing.com", - "DomainStrategy", - "InboundTag", - "Level", - "Stats", - "UserDownlink", - "UserUplink", - "System", - "InboundDownlink", - "OutboundUplink", + "inboundTag", + "level", + "stats", + "userDownlink", + "userUplink", + "system", + "inboundDownlink", + "outboundUplink", } for _, kw := range keywords { if !strings.Contains(tc, kw) { diff --git a/infra/conf/serial/builder.go b/infra/conf/serial/builder.go index 1ff4ed8a..a51648a8 100644 --- a/infra/conf/serial/builder.go +++ b/infra/conf/serial/builder.go @@ -17,7 +17,7 @@ func MergeConfigFromFiles(files []string, formats []string) (string, error) { return "", err } - if j, ok := creflect.MarshalToJson(c); ok { + if j, ok := creflect.MarshalToJson(c, true); ok { return j, nil } return "", errors.New("marshal to json failed.").AtError() From 1a95add8e3bd1e22578c384d4c5d56c9ac04e37d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:37:26 -0400 Subject: [PATCH 480/867] Bump github.com/quic-go/quic-go from 0.45.2 to 0.46.0 (#3658) Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.45.2 to 0.46.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.45.2...v0.46.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ff42f917..d4840167 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/miekg/dns v1.1.61 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 - github.com/quic-go/quic-go v0.45.2 + github.com/quic-go/quic-go v0.46.0 github.com/refraction-networking/utls v1.6.7 github.com/sagernet/sing v0.4.1 github.com/sagernet/sing-shadowsocks v0.2.7 diff --git a/go.sum b/go.sum index 8b16d691..59e6a9dc 100644 --- a/go.sum +++ b/go.sum @@ -112,8 +112,8 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/quic-go v0.45.2 h1:DfqBmqjb4ExSdxRIb/+qXhPC+7k6+DUNZha4oeiC9fY= -github.com/quic-go/quic-go v0.45.2/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= +github.com/quic-go/quic-go v0.46.0 h1:uuwLClEEyk1DNvchH8uCByQVjo3yKL9opKulExNDs7Y= +github.com/quic-go/quic-go v0.46.0/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From 96e8b8b27923741920fa3db5ab104028d6bdae2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 Aug 2024 02:25:33 +0000 Subject: [PATCH 481/867] Bump golang.org/x/sys from 0.23.0 to 0.24.0 (#3662) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.23.0 to 0.24.0. - [Commits](https://github.com/golang/sys/compare/v0.23.0...v0.24.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d4840167..87bb09e4 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/crypto v0.26.0 golang.org/x/net v0.28.0 golang.org/x/sync v0.8.0 - golang.org/x/sys v0.23.0 + golang.org/x/sys v0.24.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.65.0 google.golang.org/protobuf v1.34.2 diff --git a/go.sum b/go.sum index 59e6a9dc..1dfaa970 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM= -golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 9e93c19161e12abdb6122de268084101ae29e6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Sat, 10 Aug 2024 13:06:00 +0800 Subject: [PATCH 482/867] Freedom: Combine fragmented tlshello if interval is 0 (#3663) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> Co-authored-by: Ahmadreza Dorkhah --- proxy/freedom/freedom.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 55ad353d..6abcc553 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -402,6 +402,7 @@ func (f *FragmentWriter) Write(b []byte) (int, error) { } data := b[5:recordLen] buf := make([]byte, 1024) + var hello []byte for from := 0; ; { to := from + int(randBetween(int64(f.fragment.LengthMin), int64(f.fragment.LengthMax))) if to > len(data) { @@ -413,12 +414,22 @@ func (f *FragmentWriter) Write(b []byte) (int, error) { from = to buf[3] = byte(l >> 8) buf[4] = byte(l) - _, err := f.writer.Write(buf[:5+l]) - time.Sleep(time.Duration(randBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond) - if err != nil { - return 0, err + if f.fragment.IntervalMax == 0 { // combine fragmented tlshello if interval is 0 + hello = append(hello, buf[:5+l]...) + } else { + _, err := f.writer.Write(buf[:5+l]) + time.Sleep(time.Duration(randBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond) + if err != nil { + return 0, err + } } if from == len(data) { + if len(hello) > 0 { + _, err := f.writer.Write(hello) + if err != nil { + return 0, err + } + } if len(b) > recordLen { n, err := f.writer.Write(b[recordLen:]) if err != nil { From 85e2ebc6f757ad0f038c124a5d91830527d5ac9f Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sat, 10 Aug 2024 07:40:48 +0200 Subject: [PATCH 483/867] SplitHTTP client: Raise idle timeout to 5 minutes, Add h*KeepalivePeriod (#3624) --- transport/internet/splithttp/dialer.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 07e5d5d1..d50514e4 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -26,6 +26,16 @@ import ( "golang.org/x/net/http2" ) +// defines the maximum time an idle TCP session can survive in the tunnel, so +// it should be consistent across HTTP versions and with other transports. +const connIdleTimeout = 300 * time.Second + +// consistent with quic-go +const h3KeepalivePeriod = 10 * time.Second + +// consistent with chrome +const h2KeepalivePeriod = 45 * time.Second + type dialerConf struct { net.Destination *internet.MemoryStreamConfig @@ -89,7 +99,17 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in var uploadTransport http.RoundTripper if isH3 { + quicConfig := &quic.Config{ + MaxIdleTimeout: connIdleTimeout, + + // these two are defaults of quic-go/http3. the default of quic-go (no + // http3) is different, so it is hardcoded here for clarity. + // https://github.com/quic-go/quic-go/blob/b8ea5c798155950fb5bbfdd06cad1939c9355878/http3/client.go#L36-L39 + MaxIncomingStreams: -1, + KeepAlivePeriod: h3KeepalivePeriod, + } roundTripper := &http3.RoundTripper{ + QUICConfig: quicConfig, TLSClientConfig: gotlsConfig, Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { conn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) @@ -131,7 +151,8 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in DialTLSContext: func(ctxInner context.Context, network string, addr string, cfg *gotls.Config) (net.Conn, error) { return dialContext(ctxInner) }, - IdleConnTimeout: 90 * time.Second, + IdleConnTimeout: connIdleTimeout, + ReadIdleTimeout: h2KeepalivePeriod, } uploadTransport = downloadTransport } else { @@ -142,7 +163,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in downloadTransport = &http.Transport{ DialTLSContext: httpDialContext, DialContext: httpDialContext, - IdleConnTimeout: 90 * time.Second, + IdleConnTimeout: connIdleTimeout, // chunked transfer download with keepalives is buggy with // http.Client and our custom dial context. DisableKeepAlives: true, From f650d87083e86296023ec5b6b00f0b8678a5b630 Mon Sep 17 00:00:00 2001 From: nobody <59990325+vrnobody@users.noreply.github.com> Date: Sun, 11 Aug 2024 00:09:07 +0800 Subject: [PATCH 484/867] Commands: Add convert with two sub-commands (#3661) * Add back convert-configs-to-protobuf command. * Add convert-typedMessage-to-json command. * Add -debug and -type arguments into convert.pb sub-command. --------- Co-authored-by: nobody --- main/commands/all/commands.go | 3 +- main/commands/all/convert.go | 126 -------------------------- main/commands/all/convert/convert.go | 17 ++++ main/commands/all/convert/json.go | 71 +++++++++++++++ main/commands/all/convert/protobuf.go | 81 +++++++++++++++++ 5 files changed, 171 insertions(+), 127 deletions(-) delete mode 100644 main/commands/all/convert.go create mode 100644 main/commands/all/convert/convert.go create mode 100644 main/commands/all/convert/json.go create mode 100644 main/commands/all/convert/protobuf.go diff --git a/main/commands/all/commands.go b/main/commands/all/commands.go index 41d0e0f1..99f194dc 100644 --- a/main/commands/all/commands.go +++ b/main/commands/all/commands.go @@ -2,6 +2,7 @@ package all import ( "github.com/xtls/xray-core/main/commands/all/api" + "github.com/xtls/xray-core/main/commands/all/convert" "github.com/xtls/xray-core/main/commands/all/tls" "github.com/xtls/xray-core/main/commands/base" ) @@ -12,7 +13,7 @@ func init() { base.RootCommand.Commands = append( base.RootCommand.Commands, api.CmdAPI, - // cmdConvert, + convert.CmdConvert, tls.CmdTLS, cmdUUID, cmdX25519, diff --git a/main/commands/all/convert.go b/main/commands/all/convert.go deleted file mode 100644 index eab66d14..00000000 --- a/main/commands/all/convert.go +++ /dev/null @@ -1,126 +0,0 @@ -package all - -import ( - "bytes" - "fmt" - "io" - "net/http" - "net/url" - "os" - "strings" - "time" - - "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/common/buf" - "github.com/xtls/xray-core/common/errors" - "github.com/xtls/xray-core/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{ - UsageLine: "{{.Exec}} convert [json file] [json file] ...", - Short: "Convert multiple json config to protobuf", - Long: ` -Convert multiple json config to protobuf. - -Examples: - - {{.Exec}} convert config.json c1.json c2.json .json - `, -} - -func init() { - cmdConvert.Run = executeConvert // break init loop -} - -func executeConvert(cmd *base.Command, args []string) { - unnamedArgs := cmdConvert.Flag.Args() - if len(unnamedArgs) < 1 { - base.Fatalf("empty config list") - } - - conf := &conf.Config{} - for _, arg := range unnamedArgs { - fmt.Fprintf(os.Stderr, "Read config: %s", arg) - r, err := loadArg(arg) - common.Must(err) - c, err := serial.DecodeJSONConfig(r) - if err != nil { - base.Fatalf(err.Error()) - } - conf.Override(c, arg) - } - - pbConfig, err := conf.Build() - if err != nil { - base.Fatalf(err.Error()) - } - - bytesConfig, err := proto.Marshal(pbConfig) - if err != nil { - base.Fatalf("failed to marshal proto config: %s", err) - } - - if _, err := os.Stdout.Write(bytesConfig); err != nil { - base.Fatalf("failed to write proto config: %s", err) - } -} - -// loadArg loads one arg, maybe an remote url, or local file path -func loadArg(arg string) (out io.Reader, err error) { - var data []byte - switch { - case strings.HasPrefix(arg, "http://"), strings.HasPrefix(arg, "https://"): - data, err = FetchHTTPContent(arg) - - case arg == "stdin:": - data, err = io.ReadAll(os.Stdin) - - default: - data, err = os.ReadFile(arg) - } - - if err != nil { - return - } - out = bytes.NewBuffer(data) - return -} - -// FetchHTTPContent dials https for remote content -func FetchHTTPContent(target string) ([]byte, error) { - parsedTarget, err := url.Parse(target) - if err != nil { - return nil, errors.New("invalid URL: ", target).Base(err) - } - - if s := strings.ToLower(parsedTarget.Scheme); s != "http" && s != "https" { - return nil, errors.New("invalid scheme: ", parsedTarget.Scheme) - } - - client := &http.Client{ - Timeout: 30 * time.Second, - } - resp, err := client.Do(&http.Request{ - Method: "GET", - URL: parsedTarget, - Close: true, - }) - if err != nil { - return nil, errors.New("failed to dial to ", target).Base(err) - } - defer resp.Body.Close() - - if resp.StatusCode != 200 { - return nil, errors.New("unexpected HTTP status code: ", resp.StatusCode) - } - - content, err := buf.ReadAllToBytes(resp.Body) - if err != nil { - return nil, errors.New("failed to read HTTP response").Base(err) - } - - return content, nil -} diff --git a/main/commands/all/convert/convert.go b/main/commands/all/convert/convert.go new file mode 100644 index 00000000..3543b2e9 --- /dev/null +++ b/main/commands/all/convert/convert.go @@ -0,0 +1,17 @@ +package convert + +import ( + "github.com/xtls/xray-core/main/commands/base" +) + +// CmdConvert do config convertion +var CmdConvert = &base.Command{ + UsageLine: "{{.Exec}} convert", + Short: "Convert configs", + Long: `{{.Exec}} {{.LongName}} provides tools to convert config. +`, + Commands: []*base.Command{ + cmdProtobuf, + cmdJson, + }, +} diff --git a/main/commands/all/convert/json.go b/main/commands/all/convert/json.go new file mode 100644 index 00000000..d20634df --- /dev/null +++ b/main/commands/all/convert/json.go @@ -0,0 +1,71 @@ +package convert + +import ( + "encoding/json" + "fmt" + "io" + + creflect "github.com/xtls/xray-core/common/reflect" + cserial "github.com/xtls/xray-core/common/serial" + "github.com/xtls/xray-core/main/commands/base" + "github.com/xtls/xray-core/main/confloader" +) + +var cmdJson = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} convert json [-type] [stdin:] [typedMessage file] ", + Short: "Convert typedMessage to json", + Long: ` +Convert ONE typedMessage to json. + +Where typedMessage file need to be in the following format: + +{ + "type": "xray.proxy.shadowsocks.Account", + "value": "CgMxMTEQBg==" +} + +Arguments: + + -t, -type + Inject type infomation. + +Examples: + + {{.Exec}} convert json user.tmsg + `, + Run: executeTypedMessageToJson, +} + +func executeTypedMessageToJson(cmd *base.Command, args []string) { + + var injectTypeInfo bool + cmd.Flag.BoolVar(&injectTypeInfo, "t", false, "") + cmd.Flag.BoolVar(&injectTypeInfo, "type", false, "") + cmd.Flag.Parse(args) + + if cmd.Flag.NArg() < 1 { + base.Fatalf("empty input list") + } + + reader, err := confloader.LoadConfig(cmd.Flag.Arg(0)) + if err != nil { + base.Fatalf(err.Error()) + } + + b, err := io.ReadAll(reader) + if err != nil { + base.Fatalf(err.Error()) + } + + tm := cserial.TypedMessage{} + if err = json.Unmarshal(b, &tm); err != nil { + base.Fatalf(err.Error()) + } + + if j, ok := creflect.MarshalToJson(&tm, injectTypeInfo); ok { + fmt.Println(j) + } else { + base.Fatalf("marshal TypedMessage to json failed") + } +} diff --git a/main/commands/all/convert/protobuf.go b/main/commands/all/convert/protobuf.go new file mode 100644 index 00000000..17d6feae --- /dev/null +++ b/main/commands/all/convert/protobuf.go @@ -0,0 +1,81 @@ +package convert + +import ( + "fmt" + "os" + + "github.com/xtls/xray-core/common/cmdarg" + creflect "github.com/xtls/xray-core/common/reflect" + "github.com/xtls/xray-core/core" + "github.com/xtls/xray-core/main/commands/base" + + "google.golang.org/protobuf/proto" +) + +var cmdProtobuf = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} convert pb [-debug] [-type] [json file] [json file] ...", + Short: "Convert multiple json configs to protobuf", + Long: ` +Convert multiple json configs to protobuf. + +Arguments: + + -d, -debug + Show mix.pb as json. + FOR DEBUGGING ONLY! + DO NOT PASS THIS OUTPUT TO XRAY-CORE! + + -t, -type + Inject type information into debug output. + +Examples: + + {{.Exec}} convert pb config.json c1.json c2.json c3.json > mix.pb + `, + Run: executeConvertConfigsToProtobuf, +} + +func executeConvertConfigsToProtobuf(cmd *base.Command, args []string) { + + var optDump bool + var optType bool + + cmd.Flag.BoolVar(&optDump, "d", false, "") + cmd.Flag.BoolVar(&optDump, "debug", false, "") + cmd.Flag.BoolVar(&optType, "t", false, "") + cmd.Flag.BoolVar(&optType, "type", false, "") + cmd.Flag.Parse(args) + + unnamedArgs := cmdarg.Arg{} + for _, v := range cmd.Flag.Args() { + unnamedArgs.Set(v) + } + + if len(unnamedArgs) < 1 { + base.Fatalf("empty config list") + } + + pbConfig, err := core.LoadConfig("auto", unnamedArgs) + if err != nil { + base.Fatalf(err.Error()) + } + + if optDump { + if j, ok := creflect.MarshalToJson(pbConfig, optType); ok { + fmt.Println(j) + return + } else { + base.Fatalf("failed to marshal proto config to json.") + } + } + + bytesConfig, err := proto.Marshal(pbConfig) + if err != nil { + base.Fatalf("failed to marshal proto config: %s", err) + } + + if _, err := os.Stdout.Write(bytesConfig); err != nil { + base.Fatalf("failed to write proto config: %s", err) + } +} From a3b306aaa429392507078f8f1e1ab7871d3032e3 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sat, 10 Aug 2024 23:47:42 +0200 Subject: [PATCH 485/867] SplitHTTP: Replace responseOkPadding with xPaddingBytes (#3643) --- infra/conf/transport_internet.go | 4 +- transport/internet/splithttp/config.go | 43 +++++++++++--- transport/internet/splithttp/config.pb.go | 56 +++++++++---------- transport/internet/splithttp/config.proto | 2 +- transport/internet/splithttp/config_test.go | 37 +----------- transport/internet/splithttp/dialer.go | 50 ++++++++++++----- transport/internet/splithttp/hub.go | 18 +++--- .../internet/splithttp/splithttp_test.go | 15 ++--- 8 files changed, 119 insertions(+), 106 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 0fa6a381..9e13f246 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -233,7 +233,7 @@ type SplitHTTPConfig struct { ScMaxEachPostBytes *Int32Range `json:"scMaxEachPostBytes"` ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"` NoSSEHeader bool `json:"noSSEHeader"` - ResponseOkPadding *Int32Range `json:"responseOkPadding"` + XPaddingBytes *Int32Range `json:"xPaddingBytes"` } func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { @@ -265,7 +265,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { ScMaxEachPostBytes: splithttpNewRandRangeConfig(c.ScMaxEachPostBytes), ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs), NoSSEHeader: c.NoSSEHeader, - ResponseOkPadding: splithttpNewRandRangeConfig(c.ResponseOkPadding), + XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), } return config, nil } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index efdb3f65..6b5a2005 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -10,22 +10,39 @@ import ( "github.com/xtls/xray-core/transport/internet" ) -func (c *Config) GetNormalizedPath(addPath string, addQuery bool) string { +func (c *Config) GetNormalizedPath() string { pathAndQuery := strings.SplitN(c.Path, "?", 2) path := pathAndQuery[0] - query := "" - if len(pathAndQuery) > 1 && addQuery { - query = "?" + pathAndQuery[1] - } if path == "" || path[0] != '/' { path = "/" + path } + if path[len(path)-1] != '/' { path = path + "/" } - return path + addPath + query + return path +} + +func (c *Config) GetNormalizedQuery() string { + pathAndQuery := strings.SplitN(c.Path, "?", 2) + query := "" + + if len(pathAndQuery) > 1 { + query = pathAndQuery[1] + } + + if query != "" { + query += "&" + } + + paddingLen := c.GetNormalizedXPaddingBytes().roll() + if paddingLen > 0 { + query += "x_padding=" + strings.Repeat("0", int(paddingLen)) + } + + return query } func (c *Config) GetRequestHeader() http.Header { @@ -33,9 +50,17 @@ func (c *Config) GetRequestHeader() http.Header { for k, v := range c.Header { header.Add(k, v) } + return header } +func (c *Config) WriteResponseHeader(writer http.ResponseWriter) { + paddingLen := c.GetNormalizedXPaddingBytes().roll() + if paddingLen > 0 { + writer.Header().Set("X-Padding", strings.Repeat("0", int(paddingLen))) + } +} + func (c *Config) GetNormalizedScMaxConcurrentPosts() RandRangeConfig { if c.ScMaxConcurrentPosts == nil || c.ScMaxConcurrentPosts.To == 0 { return RandRangeConfig{ @@ -69,15 +94,15 @@ func (c *Config) GetNormalizedScMinPostsIntervalMs() RandRangeConfig { return *c.ScMinPostsIntervalMs } -func (c *Config) GetNormalizedResponseOkPadding() RandRangeConfig { - if c.ResponseOkPadding == nil || c.ResponseOkPadding.To == 0 { +func (c *Config) GetNormalizedXPaddingBytes() RandRangeConfig { + if c.XPaddingBytes == nil || c.XPaddingBytes.To == 0 { return RandRangeConfig{ From: 100, To: 1000, } } - return *c.ResponseOkPadding + return *c.XPaddingBytes } func init() { diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index b5cd7ce1..26dbb0b7 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -32,7 +32,7 @@ type Config struct { ScMaxEachPostBytes *RandRangeConfig `protobuf:"bytes,5,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` - ResponseOkPadding *RandRangeConfig `protobuf:"bytes,8,opt,name=responseOkPadding,proto3" json:"responseOkPadding,omitempty"` + XPaddingBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` } func (x *Config) Reset() { @@ -116,9 +116,9 @@ func (x *Config) GetNoSSEHeader() bool { return false } -func (x *Config) GetResponseOkPadding() *RandRangeConfig { +func (x *Config) GetXPaddingBytes() *RandRangeConfig { if x != nil { - return x.ResponseOkPadding + return x.XPaddingBytes } return nil } @@ -185,7 +185,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xf6, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xec, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, @@ -215,29 +215,29 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x64, 0x0a, 0x13, 0x67, 0x65, 0x74, 0x48, 0x61, 0x6e, - 0x64, 0x73, 0x68, 0x61, 0x6b, 0x65, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x08, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, - 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, - 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x13, 0x67, 0x65, 0x74, 0x48, 0x61, 0x6e, 0x64, - 0x73, 0x68, 0x61, 0x6b, 0x65, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x1a, 0x39, 0x0a, 0x0b, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, - 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, - 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, - 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x42, 0x85, - 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, - 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, - 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, - 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x5a, 0x0a, 0x0e, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, + 0x6e, 0x67, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, + 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x52, 0x0e, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, + 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, + 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x02, 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, + 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -263,7 +263,7 @@ var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 1, // 1: xray.transport.internet.splithttp.Config.scMaxConcurrentPosts:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 4: xray.transport.internet.splithttp.Config.responseOkPadding:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 4: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 5, // [5:5] is the sub-list for method output_type 5, // [5:5] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index ee8a3909..3f24cfd3 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -14,7 +14,7 @@ message Config { RandRangeConfig scMaxEachPostBytes = 5; RandRangeConfig scMinPostsIntervalMs = 6; bool noSSEHeader = 7; - RandRangeConfig responseOkPadding = 8; + RandRangeConfig xPaddingBytes = 8; } message RandRangeConfig { diff --git a/transport/internet/splithttp/config_test.go b/transport/internet/splithttp/config_test.go index b2891df9..39c3fd95 100644 --- a/transport/internet/splithttp/config_test.go +++ b/transport/internet/splithttp/config_test.go @@ -11,41 +11,8 @@ func Test_GetNormalizedPath(t *testing.T) { Path: "/?world", } - path := c.GetNormalizedPath("hello", true) - if path != "/hello?world" { - t.Error("Unexpected: ", path) - } -} - -func Test_GetNormalizedPath2(t *testing.T) { - c := Config{ - Path: "?world", - } - - path := c.GetNormalizedPath("hello", true) - if path != "/hello?world" { - t.Error("Unexpected: ", path) - } -} - -func Test_GetNormalizedPath3(t *testing.T) { - c := Config{ - Path: "hello?world", - } - - path := c.GetNormalizedPath("", true) - if path != "/hello/?world" { - t.Error("Unexpected: ", path) - } -} - -func Test_GetNormalizedPath4(t *testing.T) { - c := Config{ - Path: "hello?world", - } - - path := c.GetNormalizedPath("", false) - if path != "/hello/" { + path := c.GetNormalizedPath() + if path != "/" { t.Error("Unexpected: ", path) } } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index d50514e4..45bdc645 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -1,6 +1,7 @@ package splithttp import ( + "bytes" "context" gotls "crypto/tls" "io" @@ -217,8 +218,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } sessionIdUuid := uuid.New() - requestURL.Path = transportConfiguration.GetNormalizedPath(sessionIdUuid.String(), true) - baseURL := requestURL.String() + requestURL.Path = transportConfiguration.GetNormalizedPath() + sessionIdUuid.String() + requestURL.RawQuery = transportConfiguration.GetNormalizedQuery() httpClient := getHTTPClient(ctx, dest, streamSettings) @@ -247,9 +248,16 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me go func() { defer requestsLimiter.Signal() + // this intentionally makes a shallow-copy of the struct so we + // can reassign Path (potentially concurrently) + url := requestURL + url.Path += "/" + strconv.FormatInt(seq, 10) + // reassign query to get different padding + url.RawQuery = transportConfiguration.GetNormalizedQuery() + err := httpClient.SendUploadRequest( context.WithoutCancel(ctx), - baseURL+"/"+strconv.FormatInt(seq, 10), + url.String(), &buf.MultiBufferContainer{MultiBuffer: chunk}, int64(chunk.Len()), ) @@ -271,26 +279,38 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } }() - lazyRawDownload, remoteAddr, localAddr, err := httpClient.OpenDownload(context.WithoutCancel(ctx), baseURL) + lazyRawDownload, remoteAddr, localAddr, err := httpClient.OpenDownload(context.WithoutCancel(ctx), requestURL.String()) if err != nil { return nil, err } lazyDownload := &LazyReader{ CreateReader: func() (io.ReadCloser, error) { - // skip "ooooooooook" response - trashHeader := []byte{0} - for { - _, err := io.ReadFull(lazyRawDownload, trashHeader) - if err != nil { - return nil, errors.New("failed to read initial response").Base(err) - } - if trashHeader[0] == 'k' { - break - } + // skip "ok" response + trashHeader := []byte{0, 0} + _, err := io.ReadFull(lazyRawDownload, trashHeader) + if err != nil { + return nil, errors.New("failed to read initial response").Base(err) } - return lazyRawDownload, nil + if bytes.Equal(trashHeader, []byte("ok")) { + return lazyRawDownload, nil + } + + // we read some garbage byte that may not have been "ok" at + // all. return a reader that replays what we have read so far + reader := io.MultiReader( + bytes.NewReader(trashHeader), + lazyRawDownload, + ) + readCloser := struct { + io.Reader + io.Closer + }{ + Reader: reader, + Closer: lazyRawDownload, + } + return readCloser, nil }, } diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 3ba429ea..701c265e 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -124,7 +124,6 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req currentSession := h.upsertSession(sessionId) scMaxEachPostBytes := int(h.ln.config.GetNormalizedScMaxEachPostBytes().To) - responseOkPadding := h.ln.config.GetNormalizedResponseOkPadding() if request.Method == "POST" { seq := "" @@ -170,6 +169,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req return } + h.config.WriteResponseHeader(writer) writer.WriteHeader(http.StatusOK) } else if request.Method == "GET" { responseFlusher, ok := writer.(http.Flusher) @@ -189,14 +189,14 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req writer.Header().Set("Content-Type", "text/event-stream") } + h.config.WriteResponseHeader(writer) + writer.WriteHeader(http.StatusOK) - // send a chunk immediately to enable CDN streaming. - // many CDN buffer the response headers until the origin starts sending - // the body, with no way to turn it off. - padding := int(responseOkPadding.roll()) - for i := 0; i < padding; i++ { - writer.Write([]byte("o")) - } + // in earlier versions, this initial body data was used to immediately + // start a 200 OK on all CDN. but xray client since 1.8.16 does not + // actually require an immediate 200 OK, but now requires these + // additional bytes "ok". xray client 1.8.24+ doesn't require "ok" + // anymore, and so this line should be removed in later versions. writer.Write([]byte("ok")) responseFlusher.Flush() @@ -277,7 +277,7 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet handler := &requestHandler{ config: shSettings, host: shSettings.Host, - path: shSettings.GetNormalizedPath("", false), + path: shSettings.GetNormalizedPath(), ln: l, sessionMu: &sync.Mutex{}, sessions: sync.Map{}, diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index 1ac27b79..acb4addc 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -5,6 +5,7 @@ import ( "crypto/rand" gotls "crypto/tls" "fmt" + "io" gonet "net" "net/http" "runtime" @@ -60,7 +61,7 @@ func Test_listenSHAndDial(t *testing.T) { var b [1024]byte fmt.Println("test2") - n, _ := conn.Read(b[:]) + n, _ := io.ReadFull(conn, b[:]) fmt.Println("string is", n) if string(b[:n]) != "Response" { t.Error("response: ", string(b[:n])) @@ -72,7 +73,7 @@ func Test_listenSHAndDial(t *testing.T) { common.Must(err) _, err = conn.Write([]byte("Test connection 2")) common.Must(err) - n, _ = conn.Read(b[:]) + n, _ = io.ReadFull(conn, b[:]) common.Must(err) if string(b[:n]) != "Response" { t.Error("response: ", string(b[:n])) @@ -116,7 +117,7 @@ func TestDialWithRemoteAddr(t *testing.T) { common.Must(err) var b [1024]byte - n, _ := conn.Read(b[:]) + n, _ := io.ReadFull(conn, b[:]) if string(b[:n]) != "1.1.1.1:0" { t.Error("response: ", string(b[:n])) } @@ -168,7 +169,7 @@ func Test_listenSHAndDial_TLS(t *testing.T) { common.Must(err) var b [1024]byte - n, _ := conn.Read(b[:]) + n, _ := io.ReadFull(conn, b[:]) if string(b[:n]) != "Response" { t.Error("response: ", string(b[:n])) } @@ -339,7 +340,7 @@ func Test_listenSHAndDial_Unix(t *testing.T) { var b [1024]byte fmt.Println("test2") - n, _ := conn.Read(b[:]) + n, _ := io.ReadFull(conn, b[:]) fmt.Println("string is", n) if string(b[:n]) != "Response" { t.Error("response: ", string(b[:n])) @@ -351,7 +352,7 @@ func Test_listenSHAndDial_Unix(t *testing.T) { common.Must(err) _, err = conn.Write([]byte("Test connection 2")) common.Must(err) - n, _ = conn.Read(b[:]) + n, _ = io.ReadFull(conn, b[:]) common.Must(err) if string(b[:n]) != "Response" { t.Error("response: ", string(b[:n])) @@ -397,7 +398,7 @@ func Test_queryString(t *testing.T) { var b [1024]byte fmt.Println("test2") - n, _ := conn.Read(b[:]) + n, _ := io.ReadFull(conn, b[:]) fmt.Println("string is", n) if string(b[:n]) != "Response" { t.Error("response: ", string(b[:n])) From 513182adf35345b89a41fe2d4fa529fd346c4779 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 11 Aug 2024 01:56:25 +0200 Subject: [PATCH 486/867] SplitHTTP server: Only "ok" to older clients (#3671) https://github.com/XTLS/Xray-core/pull/3643#issuecomment-2282304185 --- transport/internet/splithttp/hub.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 701c265e..88acbcd3 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -192,12 +192,15 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req h.config.WriteResponseHeader(writer) writer.WriteHeader(http.StatusOK) - // in earlier versions, this initial body data was used to immediately - // start a 200 OK on all CDN. but xray client since 1.8.16 does not - // actually require an immediate 200 OK, but now requires these - // additional bytes "ok". xray client 1.8.24+ doesn't require "ok" - // anymore, and so this line should be removed in later versions. - writer.Write([]byte("ok")) + if _, ok := request.URL.Query()["x_padding"]; !ok { + // in earlier versions, this initial body data was used to immediately + // start a 200 OK on all CDN. but xray client since 1.8.16 does not + // actually require an immediate 200 OK, but now requires these + // additional bytes "ok". xray client 1.8.24+ doesn't require "ok" + // anymore, and so this line should be removed in later versions. + writer.Write([]byte("ok")) + } + responseFlusher.Flush() downloadDone := done.New() From 0c7303960abbce75d9561148021a29e6a5c222ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lumi=C3=A8re=20=C3=89lev=C3=A9?= <88174309+PoneyClairDeLune@users.noreply.github.com> Date: Sun, 11 Aug 2024 00:59:42 +0100 Subject: [PATCH 487/867] SplitHTTP server: Add "Cache-Control: no-store" to GET response (#3652) https://github.com/XTLS/Xray-core/pull/3652#issuecomment-2282308407 --- transport/internet/splithttp/hub.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 88acbcd3..9fdd15b4 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -184,6 +184,10 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req // magic header instructs nginx + apache to not buffer response body writer.Header().Set("X-Accel-Buffering", "no") + // A web-compliant header telling all middleboxes to disable caching. + // Should be able to prevent overloading the cache, or stop CDNs from + // teeing the response stream into their cache, causing slowdowns. + writer.Header().Set("Cache-Control", "no-store") if !h.config.NoSSEHeader { // magic header to make the HTTP middle box consider this as SSE to disable buffer writer.Header().Set("Content-Type", "text/event-stream") From 498d8eb3ccdc94c7e1b5e54d838dc51203a3bd1d Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 11 Aug 2024 18:58:52 +0200 Subject: [PATCH 488/867] DialerProxy: Fix SplitHTTP H3 dialerProxy (#3570) * wip * wip * formatting * cnc connection no longer needs to be a Packetconn * dialerProxy: do not cancel connection when Dial context is cancelled --- transport/internet/dialer.go | 14 +++++++++---- transport/internet/splithttp/dialer.go | 8 +++++-- transport/internet/system_dialer.go | 29 +++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/transport/internet/dialer.go b/transport/internet/dialer.go index 989bfa03..8ab51551 100644 --- a/transport/internet/dialer.go +++ b/transport/internet/dialer.go @@ -111,7 +111,7 @@ func canLookupIP(ctx context.Context, dst net.Destination, sockopt *SocketConfig } func redirect(ctx context.Context, dst net.Destination, obt string) net.Conn { - errors.LogInfo(ctx, "redirecting request " + dst.String() + " to " + obt) + errors.LogInfo(ctx, "redirecting request "+dst.String()+" to "+obt) h := obm.GetHandler(obt) outbounds := session.OutboundsFromContext(ctx) ctx = session.ContextWithOutbounds(ctx, append(outbounds, &session.Outbound{ @@ -123,10 +123,16 @@ func redirect(ctx context.Context, dst net.Destination, obt string) net.Conn { ur, uw := pipe.New(pipe.OptionsFromContext(ctx)...) dr, dw := pipe.New(pipe.OptionsFromContext(ctx)...) - go h.Dispatch(ctx, &transport.Link{Reader: ur, Writer: dw}) + go h.Dispatch(context.WithoutCancel(ctx), &transport.Link{Reader: ur, Writer: dw}) + var readerOpt cnc.ConnectionOption + if dst.Network == net.Network_TCP { + readerOpt = cnc.ConnectionOutputMulti(dr) + } else { + readerOpt = cnc.ConnectionOutputMultiUDP(dr) + } nc := cnc.NewConnection( cnc.ConnectionInputMulti(uw), - cnc.ConnectionOutputMulti(dr), + readerOpt, cnc.ConnectionOnClose(common.ChainedClosable{uw, dw}), ) return nc @@ -150,7 +156,7 @@ func DialSystem(ctx context.Context, dest net.Destination, sockopt *SocketConfig ips, err := lookupIP(dest.Address.String(), sockopt.DomainStrategy, src) if err == nil && len(ips) > 0 { dest.Address = net.IPAddress(ips[dice.Roll(len(ips))]) - errors.LogInfo(ctx, "replace destination with " + dest.String()) + errors.LogInfo(ctx, "replace destination with "+dest.String()) } else if err != nil { errors.LogWarningInner(ctx, err, "failed to resolve ip") } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 45bdc645..0d487b58 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -118,7 +118,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return nil, err } - var udpConn *net.UDPConn + var udpConn net.PacketConn var udpAddr *net.UDPAddr switch c := conn.(type) { @@ -139,7 +139,11 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return nil, err } default: - return nil, errors.New("unsupported connection type: %T", conn) + udpConn = &internet.FakePacketConn{c} + udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) + if err != nil { + return nil, err + } } return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg) diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index 73379e41..52b1e830 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -2,6 +2,7 @@ package internet import ( "context" + "math/rand" "syscall" "time" @@ -48,7 +49,7 @@ func hasBindAddr(sockopt *SocketConfig) bool { } func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest net.Destination, sockopt *SocketConfig) (net.Conn, error) { - errors.LogDebug(ctx, "dialing to " + dest.String()) + errors.LogDebug(ctx, "dialing to "+dest.String()) if dest.Network == net.Network_UDP && !hasBindAddr(sockopt) { srcAddr := resolveSrcAddr(net.Network_UDP, src) @@ -221,3 +222,29 @@ func RegisterDialerController(ctl control.Func) error { dialer.controllers = append(dialer.controllers, ctl) return nil } + +type FakePacketConn struct { + net.Conn +} + +func (c *FakePacketConn) ReadFrom(p []byte) (n int, addr net.Addr, err error) { + n, err = c.Read(p) + return n, c.RemoteAddr(), err +} + +func (c *FakePacketConn) WriteTo(p []byte, _ net.Addr) (n int, err error) { + return c.Write(p) +} + +func (c *FakePacketConn) LocalAddr() net.Addr { + return &net.TCPAddr{ + IP: net.IP{byte(rand.Intn(256)), byte(rand.Intn(256)), byte(rand.Intn(256)), byte(rand.Intn(256))}, + Port: rand.Intn(65536), + } +} + +func (c *FakePacketConn) SetReadBuffer(bytes int) error { + // do nothing, this function is only there to suppress quic-go printing + // random warnings about UDP buffers to stdout + return nil +} From f0547bc04d5402c59e365a9fc3917d4d7756684f Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 8 Aug 2024 00:41:19 -0400 Subject: [PATCH 489/867] Commands: Use creflect.MarshalToJson() as output (#3674) --- common/reflect/marshal.go | 12 +++++++++++- main/commands/all/api/shared.go | 14 +++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/common/reflect/marshal.go b/common/reflect/marshal.go index dce34168..6d9798cc 100644 --- a/common/reflect/marshal.go +++ b/common/reflect/marshal.go @@ -1,6 +1,7 @@ package reflect import ( + "bytes" "encoding/json" "fmt" "reflect" @@ -13,13 +14,22 @@ import ( func MarshalToJson(v interface{}, insertTypeInfo bool) (string, bool) { if itf := marshalInterface(v, true, insertTypeInfo); itf != nil { - if b, err := json.MarshalIndent(itf, "", " "); err == nil { + if b, err := JSONMarshalWithoutEscape(itf); err == nil { return string(b[:]), true } } return "", false } +func JSONMarshalWithoutEscape(t interface{}) ([]byte, error) { + buffer := &bytes.Buffer{} + encoder := json.NewEncoder(buffer) + encoder.SetIndent("", " ") + encoder.SetEscapeHTML(false) + err := encoder.Encode(t) + return buffer.Bytes(), err +} + func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool, insertTypeInfo bool) interface{} { if v == nil { return nil diff --git a/main/commands/all/api/shared.go b/main/commands/all/api/shared.go index 751b8615..870ef5fc 100644 --- a/main/commands/all/api/shared.go +++ b/main/commands/all/api/shared.go @@ -13,10 +13,10 @@ import ( "time" "google.golang.org/grpc/credentials/insecure" - "google.golang.org/protobuf/encoding/protojson" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/main/commands/base" + creflect "github.com/xtls/xray-core/common/reflect" "google.golang.org/grpc" "google.golang.org/protobuf/proto" ) @@ -107,20 +107,16 @@ func fetchHTTPContent(target string) ([]byte, error) { return content, nil } -func protoToJSONString(m proto.Message, prefix, indent string) (string, error) { - return strings.TrimSpace(protojson.MarshalOptions{Indent: indent}.Format(m)), nil -} - func showJSONResponse(m proto.Message) { if isNil(m) { return } - output, err := protoToJSONString(m, "", " ") - if err != nil { + if j, ok := creflect.MarshalToJson(m, true); ok { + fmt.Println(j) + } else { fmt.Fprintf(os.Stdout, "%v\n", m) - base.Fatalf("error encode json: %s", err) + base.Fatalf("error encode json") } - fmt.Println(output) } func isNil(i interface{}) bool { From 08d184034407b8fd0a29c2136f092e086d2339c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Aug 2024 09:51:50 +0000 Subject: [PATCH 490/867] Bump github.com/miekg/dns from 1.1.61 to 1.1.62 (#3680) * Bump github.com/miekg/dns from 1.1.61 to 1.1.62 Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.61 to 1.1.62. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.61...v1.1.62) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Update go.mod * Update go.sum --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 87bb09e4..498a25c0 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.6.0 github.com/gorilla/websocket v1.5.3 - github.com/miekg/dns v1.1.61 + github.com/miekg/dns v1.1.62 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.46.0 diff --git a/go.sum b/go.sum index 1dfaa970..44cf822b 100644 --- a/go.sum +++ b/go.sum @@ -86,8 +86,8 @@ github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= -github.com/miekg/dns v1.1.61 h1:nLxbwF3XxhwVSm8g9Dghm9MHPaUZuqhPiGL+675ZmEs= -github.com/miekg/dns v1.1.61/go.mod h1:mnAarhS3nWaW+NVP2wTkYVIZyHNJ098SJZUki3eykwQ= +github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= +github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= From 030c9efc8ce914bf2fcf97aa7cc91282397fa590 Mon Sep 17 00:00:00 2001 From: HunterQ Date: Thu, 15 Aug 2024 18:04:09 +1000 Subject: [PATCH 491/867] Commands: Comment some useless codes (#3681) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- main/commands/base/env.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/main/commands/base/env.go b/main/commands/base/env.go index 75d141e9..27ba0b1c 100644 --- a/main/commands/base/env.go +++ b/main/commands/base/env.go @@ -1,10 +1,5 @@ package base -import ( - "os" - "path" -) - // CommandEnvHolder is a struct holds the environment info of commands type CommandEnvHolder struct { // Executable name of current binary @@ -17,10 +12,12 @@ type CommandEnvHolder struct { var CommandEnv CommandEnvHolder func init() { - exec, err := os.Executable() - if err != nil { - return - } - CommandEnv.Exec = path.Base(exec) + /* + exec, err := os.Executable() + if err != nil { + return + } + CommandEnv.Exec = path.Base(exec) + */ CommandEnv.Exec = "xray" } From b612da26ebc2819ca2328174ad643fb38e8f9d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 15 Aug 2024 11:15:02 +0000 Subject: [PATCH 492/867] Socks inbound: Support HTTP inbound by default (#3682) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- proxy/http/server.go | 19 +++++++- proxy/socks/server.go | 25 ++++++++-- testing/scenarios/socks_test.go | 82 +++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 5 deletions(-) diff --git a/proxy/http/server.go b/proxy/http/server.go index 60a01747..42cf4299 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -2,6 +2,7 @@ package http import ( "bufio" + "bytes" "context" "encoding/base64" "io" @@ -83,14 +84,28 @@ type readerOnly struct { } func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error { + return s.ProcessWithFirstbyte(ctx, network, conn, dispatcher) +} + +// Firstbyte is for forwarded conn from SOCKS inbound +// Because it needs first byte to choose protocol +// We need to add it back +// Other parts are the same as the process function +func (s *Server) ProcessWithFirstbyte(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher, firstbyte ...byte) error { inbound := session.InboundFromContext(ctx) inbound.Name = "http" inbound.CanSpliceCopy = 2 inbound.User = &protocol.MemoryUser{ Level: s.config.UserLevel, } - - reader := bufio.NewReaderSize(readerOnly{conn}, buf.Size) + var reader *bufio.Reader + if len(firstbyte) > 0 { + readerWithoutFirstbyte := bufio.NewReaderSize(readerOnly{conn}, buf.Size) + multiReader := io.MultiReader(bytes.NewReader(firstbyte), readerWithoutFirstbyte) + reader = bufio.NewReaderSize(multiReader, buf.Size) + } else { + reader = bufio.NewReaderSize(readerOnly{conn}, buf.Size) + } Start: if err := conn.SetReadDeadline(time.Now().Add(s.policy().Timeouts.Handshake)); err != nil { diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 19c6c906..571fabb2 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -19,6 +19,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/proxy/http" "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/udp" ) @@ -29,6 +30,7 @@ type Server struct { policyManager policy.Manager cone bool udpFilter *UDPFilter + httpServer *http.Server } // NewServer creates a new Server object. @@ -39,9 +41,14 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) { policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), cone: ctx.Value("cone").(bool), } + httpConfig := &http.ServerConfig{ + UserLevel: config.UserLevel, + } if config.AuthType == AuthType_PASSWORD { + httpConfig.Accounts = config.Accounts s.udpFilter = new(UDPFilter) // We only use this when auth is enabled } + s.httpServer, _ = http.NewServer(ctx, httpConfig) return s, nil } @@ -77,7 +84,13 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con switch network { case net.Network_TCP: - return s.processTCP(ctx, conn, dispatcher) + firstbyte := make([]byte, 1) + conn.Read(firstbyte) + if firstbyte[0] != 5 && firstbyte[0] != 4 { // Check if it is Socks5/4/4a + errors.LogDebug(ctx, "Not Socks request, try to parse as HTTP request") + return s.httpServer.ProcessWithFirstbyte(ctx, network, conn, dispatcher, firstbyte...) + } + return s.processTCP(ctx, conn, dispatcher, firstbyte) case net.Network_UDP: return s.handleUDPPayload(ctx, conn, dispatcher) default: @@ -85,7 +98,7 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con } } -func (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatcher routing.Dispatcher) error { +func (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatcher routing.Dispatcher, firstbyte []byte) error { plcy := s.policy() if err := conn.SetReadDeadline(time.Now().Add(plcy.Timeouts.Handshake)); err != nil { errors.LogInfoInner(ctx, err, "failed to set deadline") @@ -103,7 +116,13 @@ func (s *Server) processTCP(ctx context.Context, conn stat.Connection, dispatche localAddress: net.IPAddress(conn.LocalAddr().(*net.TCPAddr).IP), } - reader := &buf.BufferedReader{Reader: buf.NewReader(conn)} + // Firstbyte is for forwarded conn from SOCKS inbound + // Because it needs first byte to choose protocol + // We need to add it back + reader := &buf.BufferedReader{ + Reader: buf.NewReader(conn), + Buffer: buf.MultiBuffer{buf.FromBytes(firstbyte)}, + } request, err := svrSession.Handshake(reader, conn) if err != nil { if inbound.Source.IsValid() { diff --git a/testing/scenarios/socks_test.go b/testing/scenarios/socks_test.go index cb158c58..1df7f353 100644 --- a/testing/scenarios/socks_test.go +++ b/testing/scenarios/socks_test.go @@ -14,6 +14,7 @@ import ( "github.com/xtls/xray-core/proxy/blackhole" "github.com/xtls/xray-core/proxy/dokodemo" "github.com/xtls/xray-core/proxy/freedom" + "github.com/xtls/xray-core/proxy/http" "github.com/xtls/xray-core/proxy/socks" "github.com/xtls/xray-core/testing/servers/tcp" "github.com/xtls/xray-core/testing/servers/udp" @@ -102,6 +103,87 @@ func TestSocksBridgeTCP(t *testing.T) { } } +func TestSocksWithHttpRequest(t *testing.T) { + tcpServer := tcp.Server{ + MsgProcessor: xor, + } + dest, err := tcpServer.Start() + common.Must(err) + defer tcpServer.Close() + + serverPort := tcp.PickPort() + serverConfig := &core.Config{ + Inbound: []*core.InboundHandlerConfig{ + { + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + }), + ProxySettings: serial.ToTypedMessage(&socks.ServerConfig{ + AuthType: socks.AuthType_PASSWORD, + Accounts: map[string]string{ + "Test Account": "Test Password", + }, + Address: net.NewIPOrDomain(net.LocalHostIP), + UdpEnabled: false, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + ProxySettings: serial.ToTypedMessage(&freedom.Config{}), + }, + }, + } + + clientPort := tcp.PickPort() + clientConfig := &core.Config{ + Inbound: []*core.InboundHandlerConfig{ + { + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + }), + ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), + NetworkList: &net.NetworkList{ + Network: []net.Network{net.Network_TCP}, + }, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + ProxySettings: serial.ToTypedMessage(&http.ClientConfig{ + Server: []*protocol.ServerEndpoint{ + { + Address: net.NewIPOrDomain(net.LocalHostIP), + Port: uint32(serverPort), + User: []*protocol.User{ + { + Account: serial.ToTypedMessage(&http.Account{ + Username: "Test Account", + Password: "Test Password", + }), + }, + }, + }, + }, + }), + }, + }, + } + + servers, err := InitializeServerConfigs(serverConfig, clientConfig) + common.Must(err) + defer CloseAllServers(servers) + + if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil { + t.Error(err) + } +} + func TestSocksBridageUDP(t *testing.T) { udpServer := udp.Server{ MsgProcessor: xor, From 11b04807b9e50f05786747481548bae2607f6204 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 16 Aug 2024 02:18:39 +0000 Subject: [PATCH 493/867] Log: Add "from" before source address https://github.com/XTLS/Xray-core/pull/3682#issuecomment-2292600144 --- common/log/access.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/log/access.go b/common/log/access.go index 22b84cf6..204212dc 100644 --- a/common/log/access.go +++ b/common/log/access.go @@ -31,6 +31,8 @@ type AccessMessage struct { func (m *AccessMessage) String() string { builder := strings.Builder{} + builder.WriteString("from") + builder.WriteByte(' ') builder.WriteString(serial.ToString(m.From)) builder.WriteByte(' ') builder.WriteString(string(m.Status)) From 1562e1ffb9435d66fa0f776de276e0c891fd1113 Mon Sep 17 00:00:00 2001 From: HunterQ Date: Fri, 16 Aug 2024 15:32:05 +1000 Subject: [PATCH 494/867] Config: Combine filename and format into a new struct (#3687) --- core/config.go | 30 +++++++++++++++++++----------- infra/conf/serial/builder.go | 16 ++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/core/config.go b/core/config.go index aa9b63c9..e101c920 100644 --- a/core/config.go +++ b/core/config.go @@ -19,14 +19,19 @@ type ConfigFormat struct { Loader ConfigLoader } +type ConfigSource struct { + Name string + Format string +} + // ConfigLoader is a utility to load Xray config from external source. type ConfigLoader func(input interface{}) (*Config, error) // ConfigBuilder is a builder to build core.Config from filenames and formats -type ConfigBuilder func(files []string, formats []string) (*Config, error) +type ConfigBuilder func(files []*ConfigSource) (*Config, error) // ConfigsMerger merge multiple json configs into on config -type ConfigsMerger func(files []string, formats []string) (string, error) +type ConfigsMerger func(files []*ConfigSource) (string, error) var ( configLoaderByName = make(map[string]*ConfigFormat) @@ -55,20 +60,21 @@ func RegisterConfigLoader(format *ConfigFormat) error { } func GetMergedConfig(args cmdarg.Arg) (string, error) { - files := make([]string, 0) - formats := make([]string, 0) + var files []*ConfigSource supported := []string{"json", "yaml", "toml"} for _, file := range args { format := getFormat(file) for _, s := range supported { if s == format { - files = append(files, file) - formats = append(formats, format) + files = append(files, &ConfigSource{ + Name: file, + Format: format, + }) break } } } - return ConfigMergedFormFiles(files, formats) + return ConfigMergedFormFiles(files) } func GetFormatByExtension(ext string) string { @@ -101,7 +107,7 @@ func getFormat(filename string) string { func LoadConfig(formatName string, input interface{}) (*Config, error) { switch v := input.(type) { case cmdarg.Arg: - formats := make([]string, len(v)) + files := make([]*ConfigSource, len(v)) hasProtobuf := false for i, file := range v { var f string @@ -123,7 +129,10 @@ func LoadConfig(formatName string, input interface{}) (*Config, error) { if f == "protobuf" { hasProtobuf = true } - formats[i] = f + files[i] = &ConfigSource{ + Name: file, + Format: f, + } } // only one protobuf config file is allowed @@ -136,8 +145,7 @@ func LoadConfig(formatName string, input interface{}) (*Config, error) { } // to avoid import cycle - return ConfigBuilderForFiles(v, formats) - + return ConfigBuilderForFiles(files) case io.Reader: if f, found := configLoaderByName[formatName]; found { return f.Loader(v) diff --git a/infra/conf/serial/builder.go b/infra/conf/serial/builder.go index a51648a8..3ae98025 100644 --- a/infra/conf/serial/builder.go +++ b/infra/conf/serial/builder.go @@ -11,8 +11,8 @@ import ( "github.com/xtls/xray-core/main/confloader" ) -func MergeConfigFromFiles(files []string, formats []string) (string, error) { - c, err := mergeConfigs(files, formats) +func MergeConfigFromFiles(files []*core.ConfigSource) (string, error) { + c, err := mergeConfigs(files) if err != nil { return "", err } @@ -23,15 +23,15 @@ func MergeConfigFromFiles(files []string, formats []string) (string, error) { return "", errors.New("marshal to json failed.").AtError() } -func mergeConfigs(files []string, formats []string) (*conf.Config, error) { +func mergeConfigs(files []*core.ConfigSource) (*conf.Config, error) { cf := &conf.Config{} for i, file := range files { errors.LogInfo(context.Background(), "Reading config: ", file) - r, err := confloader.LoadConfig(file) + r, err := confloader.LoadConfig(file.Name) if err != nil { return nil, errors.New("failed to read config: ", file).Base(err) } - c, err := ReaderDecoderByFormat[formats[i]](r) + c, err := ReaderDecoderByFormat[file.Format](r) if err != nil { return nil, errors.New("failed to decode config: ", file).Base(err) } @@ -39,13 +39,13 @@ func mergeConfigs(files []string, formats []string) (*conf.Config, error) { *cf = *c continue } - cf.Override(c, file) + cf.Override(c, file.Name) } return cf, nil } -func BuildConfig(files []string, formats []string) (*core.Config, error) { - config, err := mergeConfigs(files, formats) +func BuildConfig(files []*core.ConfigSource) (*core.Config, error) { + config, err := mergeConfigs(files) if err != nil { return nil, err } From 160316d53c8a757695542b1071e251be41ae913a Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sat, 17 Aug 2024 13:01:58 +0200 Subject: [PATCH 495/867] SplitHTTP: Do not produce too large upload (#3691) --- transport/internet/splithttp/dialer.go | 46 +++++++++++++-- .../internet/splithttp/splithttp_test.go | 56 ++++++++++++++++++- transport/pipe/impl.go | 8 +++ transport/pipe/writer.go | 4 ++ 4 files changed, 108 insertions(+), 6 deletions(-) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 0d487b58..a95ab34b 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -227,7 +227,11 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me httpClient := getHTTPClient(ctx, dest, streamSettings) - uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(scMaxEachPostBytes.roll())) + maxUploadSize := scMaxEachPostBytes.roll() + // WithSizeLimit(0) will still allow single bytes to pass, and a lot of + // code relies on this behavior. Subtract 1 so that together with + // uploadWriter wrapper, exact size limits can be enforced + uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1)) go func() { requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll())) @@ -318,12 +322,13 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me }, } - // necessary in order to send larger chunks in upload - bufferedUploadPipeWriter := buf.NewBufferedWriter(uploadPipeWriter) - bufferedUploadPipeWriter.SetBuffered(false) + writer := uploadWriter{ + uploadPipeWriter, + maxUploadSize, + } conn := splitConn{ - writer: bufferedUploadPipeWriter, + writer: writer, reader: lazyDownload, remoteAddr: remoteAddr, localAddr: localAddr, @@ -331,3 +336,34 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me return stat.Connection(&conn), nil } + +// A wrapper around pipe that ensures the size limit is exactly honored. +// +// The MultiBuffer pipe accepts any single WriteMultiBuffer call even if that +// single MultiBuffer exceeds the size limit, and then starts blocking on the +// next WriteMultiBuffer call. This means that ReadMultiBuffer can return more +// bytes than the size limit. We work around this by splitting a potentially +// too large write up into multiple. +type uploadWriter struct { + *pipe.Writer + maxLen int32 +} + +func (w uploadWriter) Write(b []byte) (int, error) { + capacity := int(w.maxLen - w.Len()) + if capacity > 0 && capacity < len(b) { + b = b[:capacity] + } + + buffer := buf.New() + n, err := buffer.Write(b) + if err != nil { + return 0, err + } + + err = w.WriteMultiBuffer([]*buf.Buffer{buffer}) + if err != nil { + return 0, err + } + return n, nil +} diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index acb4addc..30f92c7f 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -388,7 +388,7 @@ func Test_queryString(t *testing.T) { ctx := context.Background() streamSettings := &internet.MemoryStreamConfig{ ProtocolName: "splithttp", - ProtocolSettings: &Config{Path: "sh"}, + ProtocolSettings: &Config{Path: "sh?ed=2048"}, } conn, err := Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) @@ -407,3 +407,57 @@ func Test_queryString(t *testing.T) { common.Must(conn.Close()) common.Must(listen.Close()) } + +func Test_maxUpload(t *testing.T) { + listenPort := tcp.PickPort() + streamSettings := &internet.MemoryStreamConfig{ + ProtocolName: "splithttp", + ProtocolSettings: &Config{ + Path: "/sh", + ScMaxEachPostBytes: &RandRangeConfig{ + From: 100, + To: 100, + }, + }, + } + + var uploadSize int + listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { + go func(c stat.Connection) { + defer c.Close() + var b [1024]byte + c.SetReadDeadline(time.Now().Add(2 * time.Second)) + n, err := c.Read(b[:]) + if err != nil { + return + } + + uploadSize = n + + common.Must2(c.Write([]byte("Response"))) + }(conn) + }) + common.Must(err) + ctx := context.Background() + + conn, err := Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) + + // send a slightly too large upload + var upload [101]byte + _, err = conn.Write(upload[:]) + common.Must(err) + + var b [1024]byte + n, _ := io.ReadFull(conn, b[:]) + fmt.Println("string is", n) + if string(b[:n]) != "Response" { + t.Error("response: ", string(b[:n])) + } + common.Must(conn.Close()) + + if uploadSize > 100 || uploadSize == 0 { + t.Error("incorrect upload size: ", uploadSize) + } + + common.Must(listen.Close()) +} diff --git a/transport/pipe/impl.go b/transport/pipe/impl.go index dbdb050e..8bf58a34 100644 --- a/transport/pipe/impl.go +++ b/transport/pipe/impl.go @@ -46,6 +46,14 @@ var ( errSlowDown = errors.New("slow down") ) +func (p *pipe) Len() int32 { + data := p.data + if data == nil { + return 0 + } + return data.Len() +} + func (p *pipe) getState(forRead bool) error { switch p.state { case open: diff --git a/transport/pipe/writer.go b/transport/pipe/writer.go index 8230ec76..0a192ca0 100644 --- a/transport/pipe/writer.go +++ b/transport/pipe/writer.go @@ -19,6 +19,10 @@ func (w *Writer) Close() error { return w.pipe.Close() } +func (w *Writer) Len() int32 { + return w.pipe.Len() +} + // Interrupt implements common.Interruptible. func (w *Writer) Interrupt() { w.pipe.Interrupt() From 41d03d1856a5b16521610792601a20fb1195418e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=82=BB?= <123655015+chise0713@users.noreply.github.com> Date: Tue, 20 Aug 2024 07:21:19 +0800 Subject: [PATCH 496/867] Wireguard inbound: Fix no route when bind to interface (#3698) --- proxy/wireguard/tun_linux.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/proxy/wireguard/tun_linux.go b/proxy/wireguard/tun_linux.go index 88446339..22c638d3 100644 --- a/proxy/wireguard/tun_linux.go +++ b/proxy/wireguard/tun_linux.go @@ -200,6 +200,9 @@ func createKernelTun(localAddresses []netip.Addr, mtu int, handler promiscuousMo r := netlink.NewRule() r.Table, r.Family, r.Src = ipv6TableIndex, unix.AF_INET6, addr.IPNet out.rules = append(out.rules, r) + r = netlink.NewRule() + r.Table, r.Family, r.OifName = ipv6TableIndex, unix.AF_INET6, n + out.rules = append(out.rules, r) } for _, addr := range out.linkAddrs { From 0df7fa23f8bc14c34be5c304cada84850239142c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:36:25 -0400 Subject: [PATCH 497/867] Bump github.com/cloudflare/circl from 1.3.9 to 1.4.0 (#3712) Bumps [github.com/cloudflare/circl](https://github.com/cloudflare/circl) from 1.3.9 to 1.4.0. - [Release notes](https://github.com/cloudflare/circl/releases) - [Commits](https://github.com/cloudflare/circl/compare/v1.3.9...v1.4.0) --- updated-dependencies: - dependency-name: github.com/cloudflare/circl dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 498a25c0..20876387 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21.4 require ( github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 - github.com/cloudflare/circl v1.3.9 + github.com/cloudflare/circl v1.4.0 github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.6.0 diff --git a/go.sum b/go.sum index 44cf822b..2960e875 100644 --- a/go.sum +++ b/go.sum @@ -17,8 +17,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/circl v1.3.9 h1:QFrlgFYf2Qpi8bSpVPK1HBvWpx16v/1TZivyo7pGuBE= -github.com/cloudflare/circl v1.3.9/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= +github.com/cloudflare/circl v1.4.0 h1:BV7h5MgrktNzytKmWjpOtdYrf0lkkbF8YMlBGPhJQrY= +github.com/cloudflare/circl v1.4.0/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= From 790f908f0b1eba45c00ace4b5caa76bac060e8ad Mon Sep 17 00:00:00 2001 From: curlwget Date: Thu, 22 Aug 2024 17:32:38 +0800 Subject: [PATCH 498/867] chore: fix some comment typos (#3716) Signed-off-by: curlwget --- app/dns/nameserver.go | 2 +- app/stats/channel_test.go | 2 +- common/mux/client.go | 2 +- main/commands/base/execute.go | 2 +- proxy/proxy.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index c7ff8a84..8dfa9dc2 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -90,7 +90,7 @@ func NewClient( ns.PrioritizedDomain = append(ns.PrioritizedDomain, localTLDsAndDotlessDomains...) ns.OriginalRules = append(ns.OriginalRules, localTLDsAndDotlessDomainsRule) // The following lines is a solution to avoid core panics(rule index out of range) when setting `localhost` DNS client in config. - // Because the `localhost` DNS client will apend len(localTLDsAndDotlessDomains) rules into matcherInfos to match `geosite:private` default rule. + // Because the `localhost` DNS client will append len(localTLDsAndDotlessDomains) rules into matcherInfos to match `geosite:private` default rule. // But `matcherInfos` has no enough length to add rules, which leads to core panics (rule index out of range). // To avoid this, the length of `matcherInfos` must be equal to the expected, so manually append it with Golang default zero value first for later modification. // Related issues: diff --git a/app/stats/channel_test.go b/app/stats/channel_test.go index ccae8269..f35b95c6 100644 --- a/app/stats/channel_test.go +++ b/app/stats/channel_test.go @@ -203,7 +203,7 @@ func TestStatsChannelBlocking(t *testing.T) { // Test blocking channel publishing go func() { - // Dummy messsage with no subscriber receiving, will block broadcasting goroutine + // Dummy message with no subscriber receiving, will block broadcasting goroutine c.Publish(context.Background(), nil) <-pauseCh diff --git a/common/mux/client.go b/common/mux/client.go index 1cbc530a..df74ef17 100644 --- a/common/mux/client.go +++ b/common/mux/client.go @@ -22,7 +22,7 @@ import ( ) type ClientManager struct { - Enabled bool // wheather mux is enabled from user config + Enabled bool // whether mux is enabled from user config Picker WorkerPicker } diff --git a/main/commands/base/execute.go b/main/commands/base/execute.go index 2d18371e..8e23dabf 100644 --- a/main/commands/base/execute.go +++ b/main/commands/base/execute.go @@ -12,7 +12,7 @@ import ( // Use of this source code is governed by a BSD-style // copied from "github.com/golang/go/main.go" -// Execute excute the commands +// Execute execute the commands func Execute() { flag.Parse() args := flag.Args() diff --git a/proxy/proxy.go b/proxy/proxy.go index 926bf164..b507cc39 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -319,7 +319,7 @@ func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool // XtlsUnpadding remove padding and parse command func XtlsUnpadding(b *buf.Buffer, s *TrafficState, ctx context.Context) *buf.Buffer { - if s.RemainingCommand == -1 && s.RemainingContent == -1 && s.RemainingPadding == -1 { // inital state + if s.RemainingCommand == -1 && s.RemainingContent == -1 && s.RemainingPadding == -1 { // initial state if b.Len() >= 21 && bytes.Equal(s.UserUUID, b.BytesTo(16)) { b.Advance(16) s.RemainingCommand = 5 From 2be03c56cb57268e48d9c59b90c2e711a20b16a6 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:18:36 +0200 Subject: [PATCH 499/867] Pin protobuf packages (#3715) * Pin protobuf packages It happened in the past that I ran with the wrong protobuf version installed locally, and apparently there is even still some file wrong in splithttp. Fix this issue once and for all. * bump protobuf packages * Revert "bump protobuf packages" This reverts commit 7a3509346a0e29721bb2ddf7857addd622b5674c. * Revert "Revert "bump protobuf packages"" This reverts commit bb79707d15ca79527fba789276874844605d1d81. * fix deprecated grpc usage --- app/commander/config.pb.go | 8 +- app/dispatcher/config.pb.go | 8 +- app/dns/config.pb.go | 14 +- app/dns/fakedns/fakedns.pb.go | 8 +- app/log/command/config.pb.go | 10 +- app/log/command/config_grpc.pb.go | 28 +++- app/log/config.pb.go | 6 +- app/metrics/config.pb.go | 6 +- app/observatory/burst/config.pb.go | 8 +- app/observatory/command/command.pb.go | 10 +- app/observatory/command/command_grpc.pb.go | 28 +++- app/observatory/config.pb.go | 16 +- app/policy/config.pb.go | 20 +-- app/proxyman/command/command.pb.go | 34 ++-- app/proxyman/command/command_grpc.pb.go | 43 +++-- app/proxyman/config.pb.go | 24 +-- app/reverse/config.pb.go | 12 +- app/router/command/command.pb.go | 34 ++-- app/router/command/command_grpc.pb.go | 87 +++++------ app/router/config.pb.go | 32 ++-- app/stats/command/command.pb.go | 20 +-- app/stats/command/command_grpc.pb.go | 34 ++-- app/stats/config.pb.go | 8 +- common/log/log.pb.go | 4 +- common/net/address.pb.go | 8 +- common/net/destination.pb.go | 6 +- common/net/network.pb.go | 6 +- common/net/port.pb.go | 8 +- common/protocol/headers.pb.go | 6 +- common/protocol/server_spec.pb.go | 6 +- common/protocol/user.pb.go | 6 +- common/serial/typed_message.pb.go | 6 +- core/config.pb.go | 10 +- core/proto.go | 4 +- proxy/blackhole/config.pb.go | 10 +- proxy/dns/config.pb.go | 6 +- proxy/dokodemo/config.pb.go | 6 +- proxy/freedom/config.pb.go | 10 +- proxy/http/config.pb.go | 12 +- proxy/loopback/config.pb.go | 6 +- proxy/shadowsocks/config.pb.go | 10 +- proxy/shadowsocks_2022/config.pb.go | 16 +- proxy/socks/config.pb.go | 10 +- proxy/trojan/config.pb.go | 12 +- proxy/vless/account.pb.go | 6 +- proxy/vless/encoding/addons.pb.go | 6 +- proxy/vless/inbound/config.pb.go | 8 +- proxy/vless/outbound/config.pb.go | 6 +- proxy/vmess/account.pb.go | 6 +- proxy/vmess/inbound/config.pb.go | 10 +- proxy/vmess/outbound/config.pb.go | 6 +- proxy/wireguard/config.pb.go | 8 +- transport/global/config.pb.go | 6 +- transport/internet/config.pb.go | 14 +- transport/internet/domainsocket/config.pb.go | 6 +- transport/internet/grpc/config.pb.go | 6 +- .../grpc/encoding/customSeviceName.go | 4 +- transport/internet/grpc/encoding/stream.pb.go | 8 +- .../internet/grpc/encoding/stream_grpc.pb.go | 147 +++++------------- transport/internet/headers/dns/config.pb.go | 6 +- transport/internet/headers/http/config.pb.go | 18 +-- transport/internet/headers/noop/config.pb.go | 8 +- transport/internet/headers/srtp/config.pb.go | 6 +- transport/internet/headers/tls/config.pb.go | 6 +- transport/internet/headers/utp/config.pb.go | 6 +- .../internet/headers/wechat/config.pb.go | 6 +- .../internet/headers/wireguard/config.pb.go | 6 +- transport/internet/http/config.pb.go | 6 +- transport/internet/httpupgrade/config.pb.go | 6 +- transport/internet/kcp/config.pb.go | 22 +-- transport/internet/quic/config.pb.go | 6 +- transport/internet/reality/config.pb.go | 6 +- transport/internet/splithttp/config.pb.go | 56 +++---- transport/internet/tcp/config.pb.go | 6 +- transport/internet/tls/config.pb.go | 8 +- transport/internet/udp/config.pb.go | 6 +- transport/internet/websocket/config.pb.go | 6 +- 77 files changed, 544 insertions(+), 559 deletions(-) diff --git a/app/commander/config.pb.go b/app/commander/config.pb.go index 7601b74c..1fb145c8 100644 --- a/app/commander/config.pb.go +++ b/app/commander/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/commander/config.proto @@ -166,7 +166,7 @@ func file_app_commander_config_proto_rawDescGZIP() []byte { } var file_app_commander_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_app_commander_config_proto_goTypes = []interface{}{ +var file_app_commander_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.app.commander.Config (*ReflectionConfig)(nil), // 1: xray.app.commander.ReflectionConfig (*serial.TypedMessage)(nil), // 2: xray.common.serial.TypedMessage @@ -186,7 +186,7 @@ func file_app_commander_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_commander_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_commander_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -198,7 +198,7 @@ func file_app_commander_config_proto_init() { return nil } } - file_app_commander_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_commander_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ReflectionConfig); i { case 0: return &v.state diff --git a/app/dispatcher/config.pb.go b/app/dispatcher/config.pb.go index 13af96ea..9b8adb09 100644 --- a/app/dispatcher/config.pb.go +++ b/app/dispatcher/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/dispatcher/config.proto @@ -139,7 +139,7 @@ func file_app_dispatcher_config_proto_rawDescGZIP() []byte { } var file_app_dispatcher_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_app_dispatcher_config_proto_goTypes = []interface{}{ +var file_app_dispatcher_config_proto_goTypes = []any{ (*SessionConfig)(nil), // 0: xray.app.dispatcher.SessionConfig (*Config)(nil), // 1: xray.app.dispatcher.Config } @@ -158,7 +158,7 @@ func file_app_dispatcher_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_dispatcher_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_dispatcher_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*SessionConfig); i { case 0: return &v.state @@ -170,7 +170,7 @@ func file_app_dispatcher_config_proto_init() { return nil } } - file_app_dispatcher_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_dispatcher_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index c37190c8..bab4dc1c 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/dns/config.proto @@ -658,7 +658,7 @@ func file_app_dns_config_proto_rawDescGZIP() []byte { var file_app_dns_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_app_dns_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_app_dns_config_proto_goTypes = []interface{}{ +var file_app_dns_config_proto_goTypes = []any{ (DomainMatchingType)(0), // 0: xray.app.dns.DomainMatchingType (QueryStrategy)(0), // 1: xray.app.dns.QueryStrategy (*NameServer)(nil), // 2: xray.app.dns.NameServer @@ -698,7 +698,7 @@ func file_app_dns_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_dns_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_dns_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*NameServer); i { case 0: return &v.state @@ -710,7 +710,7 @@ func file_app_dns_config_proto_init() { return nil } } - file_app_dns_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_dns_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -722,7 +722,7 @@ func file_app_dns_config_proto_init() { return nil } } - file_app_dns_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_dns_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*NameServer_PriorityDomain); i { case 0: return &v.state @@ -734,7 +734,7 @@ func file_app_dns_config_proto_init() { return nil } } - file_app_dns_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_app_dns_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*NameServer_OriginalRule); i { case 0: return &v.state @@ -746,7 +746,7 @@ func file_app_dns_config_proto_init() { return nil } } - file_app_dns_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_app_dns_config_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*Config_HostMapping); i { case 0: return &v.state diff --git a/app/dns/fakedns/fakedns.pb.go b/app/dns/fakedns/fakedns.pb.go index 7e3615f2..a44e77b3 100644 --- a/app/dns/fakedns/fakedns.pb.go +++ b/app/dns/fakedns/fakedns.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/dns/fakedns/fakedns.proto @@ -159,7 +159,7 @@ func file_app_dns_fakedns_fakedns_proto_rawDescGZIP() []byte { } var file_app_dns_fakedns_fakedns_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_app_dns_fakedns_fakedns_proto_goTypes = []interface{}{ +var file_app_dns_fakedns_fakedns_proto_goTypes = []any{ (*FakeDnsPool)(nil), // 0: xray.app.dns.fakedns.FakeDnsPool (*FakeDnsPoolMulti)(nil), // 1: xray.app.dns.fakedns.FakeDnsPoolMulti } @@ -178,7 +178,7 @@ func file_app_dns_fakedns_fakedns_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_dns_fakedns_fakedns_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_dns_fakedns_fakedns_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*FakeDnsPool); i { case 0: return &v.state @@ -190,7 +190,7 @@ func file_app_dns_fakedns_fakedns_proto_init() { return nil } } - file_app_dns_fakedns_fakedns_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_dns_fakedns_fakedns_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*FakeDnsPoolMulti); i { case 0: return &v.state diff --git a/app/log/command/config.pb.go b/app/log/command/config.pb.go index c39f466b..a6fd81cd 100644 --- a/app/log/command/config.pb.go +++ b/app/log/command/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/log/command/config.proto @@ -174,7 +174,7 @@ func file_app_log_command_config_proto_rawDescGZIP() []byte { } var file_app_log_command_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_app_log_command_config_proto_goTypes = []interface{}{ +var file_app_log_command_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.app.log.command.Config (*RestartLoggerRequest)(nil), // 1: xray.app.log.command.RestartLoggerRequest (*RestartLoggerResponse)(nil), // 2: xray.app.log.command.RestartLoggerResponse @@ -195,7 +195,7 @@ func file_app_log_command_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_log_command_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_log_command_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -207,7 +207,7 @@ func file_app_log_command_config_proto_init() { return nil } } - file_app_log_command_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_log_command_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*RestartLoggerRequest); i { case 0: return &v.state @@ -219,7 +219,7 @@ func file_app_log_command_config_proto_init() { return nil } } - file_app_log_command_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_log_command_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*RestartLoggerResponse); i { case 0: return &v.state diff --git a/app/log/command/config_grpc.pb.go b/app/log/command/config_grpc.pb.go index 3ad15288..2eb9bb66 100644 --- a/app/log/command/config_grpc.pb.go +++ b/app/log/command/config_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc v5.27.0 // source: app/log/command/config.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( LoggerService_RestartLogger_FullMethodName = "/xray.app.log.command.LoggerService/RestartLogger" @@ -38,8 +38,9 @@ func NewLoggerServiceClient(cc grpc.ClientConnInterface) LoggerServiceClient { } func (c *loggerServiceClient) RestartLogger(ctx context.Context, in *RestartLoggerRequest, opts ...grpc.CallOption) (*RestartLoggerResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(RestartLoggerResponse) - err := c.cc.Invoke(ctx, LoggerService_RestartLogger_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, LoggerService_RestartLogger_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -48,20 +49,24 @@ func (c *loggerServiceClient) RestartLogger(ctx context.Context, in *RestartLogg // LoggerServiceServer is the server API for LoggerService service. // All implementations must embed UnimplementedLoggerServiceServer -// for forward compatibility +// for forward compatibility. type LoggerServiceServer interface { RestartLogger(context.Context, *RestartLoggerRequest) (*RestartLoggerResponse, error) mustEmbedUnimplementedLoggerServiceServer() } -// UnimplementedLoggerServiceServer must be embedded to have forward compatible implementations. -type UnimplementedLoggerServiceServer struct { -} +// UnimplementedLoggerServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedLoggerServiceServer struct{} func (UnimplementedLoggerServiceServer) RestartLogger(context.Context, *RestartLoggerRequest) (*RestartLoggerResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RestartLogger not implemented") } func (UnimplementedLoggerServiceServer) mustEmbedUnimplementedLoggerServiceServer() {} +func (UnimplementedLoggerServiceServer) testEmbeddedByValue() {} // UnsafeLoggerServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to LoggerServiceServer will @@ -71,6 +76,13 @@ type UnsafeLoggerServiceServer interface { } func RegisterLoggerServiceServer(s grpc.ServiceRegistrar, srv LoggerServiceServer) { + // If the following call pancis, it indicates UnimplementedLoggerServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&LoggerService_ServiceDesc, srv) } diff --git a/app/log/config.pb.go b/app/log/config.pb.go index 7dc40d80..eb7abc50 100644 --- a/app/log/config.pb.go +++ b/app/log/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/log/config.proto @@ -211,7 +211,7 @@ func file_app_log_config_proto_rawDescGZIP() []byte { var file_app_log_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_app_log_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_app_log_config_proto_goTypes = []interface{}{ +var file_app_log_config_proto_goTypes = []any{ (LogType)(0), // 0: xray.app.log.LogType (*Config)(nil), // 1: xray.app.log.Config (log.Severity)(0), // 2: xray.common.log.Severity @@ -233,7 +233,7 @@ func file_app_log_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_log_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_log_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/app/metrics/config.pb.go b/app/metrics/config.pb.go index fd0e6b0a..5544b24f 100644 --- a/app/metrics/config.pb.go +++ b/app/metrics/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/metrics/config.proto @@ -98,7 +98,7 @@ func file_app_metrics_config_proto_rawDescGZIP() []byte { } var file_app_metrics_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_app_metrics_config_proto_goTypes = []interface{}{ +var file_app_metrics_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.app.metrics.Config } var file_app_metrics_config_proto_depIdxs = []int32{ @@ -115,7 +115,7 @@ func file_app_metrics_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_metrics_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_metrics_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/app/observatory/burst/config.pb.go b/app/observatory/burst/config.pb.go index bdbcd8c4..b38f9d8b 100644 --- a/app/observatory/burst/config.pb.go +++ b/app/observatory/burst/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/observatory/burst/config.proto @@ -211,7 +211,7 @@ func file_app_observatory_burst_config_proto_rawDescGZIP() []byte { } var file_app_observatory_burst_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_app_observatory_burst_config_proto_goTypes = []interface{}{ +var file_app_observatory_burst_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.core.app.observatory.burst.Config (*HealthPingConfig)(nil), // 1: xray.core.app.observatory.burst.HealthPingConfig } @@ -230,7 +230,7 @@ func file_app_observatory_burst_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_observatory_burst_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_burst_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -242,7 +242,7 @@ func file_app_observatory_burst_config_proto_init() { return nil } } - file_app_observatory_burst_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_burst_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*HealthPingConfig); i { case 0: return &v.state diff --git a/app/observatory/command/command.pb.go b/app/observatory/command/command.pb.go index 7ec43f33..3b239e79 100644 --- a/app/observatory/command/command.pb.go +++ b/app/observatory/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/observatory/command/command.proto @@ -197,7 +197,7 @@ func file_app_observatory_command_command_proto_rawDescGZIP() []byte { } var file_app_observatory_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_app_observatory_command_command_proto_goTypes = []interface{}{ +var file_app_observatory_command_command_proto_goTypes = []any{ (*GetOutboundStatusRequest)(nil), // 0: xray.core.app.observatory.command.GetOutboundStatusRequest (*GetOutboundStatusResponse)(nil), // 1: xray.core.app.observatory.command.GetOutboundStatusResponse (*Config)(nil), // 2: xray.core.app.observatory.command.Config @@ -220,7 +220,7 @@ func file_app_observatory_command_command_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_observatory_command_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*GetOutboundStatusRequest); i { case 0: return &v.state @@ -232,7 +232,7 @@ func file_app_observatory_command_command_proto_init() { return nil } } - file_app_observatory_command_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*GetOutboundStatusResponse); i { case 0: return &v.state @@ -244,7 +244,7 @@ func file_app_observatory_command_command_proto_init() { return nil } } - file_app_observatory_command_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/app/observatory/command/command_grpc.pb.go b/app/observatory/command/command_grpc.pb.go index 035cee07..18d29092 100644 --- a/app/observatory/command/command_grpc.pb.go +++ b/app/observatory/command/command_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc v5.27.0 // source: app/observatory/command/command.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( ObservatoryService_GetOutboundStatus_FullMethodName = "/xray.core.app.observatory.command.ObservatoryService/GetOutboundStatus" @@ -38,8 +38,9 @@ func NewObservatoryServiceClient(cc grpc.ClientConnInterface) ObservatoryService } func (c *observatoryServiceClient) GetOutboundStatus(ctx context.Context, in *GetOutboundStatusRequest, opts ...grpc.CallOption) (*GetOutboundStatusResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetOutboundStatusResponse) - err := c.cc.Invoke(ctx, ObservatoryService_GetOutboundStatus_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, ObservatoryService_GetOutboundStatus_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -48,20 +49,24 @@ func (c *observatoryServiceClient) GetOutboundStatus(ctx context.Context, in *Ge // ObservatoryServiceServer is the server API for ObservatoryService service. // All implementations must embed UnimplementedObservatoryServiceServer -// for forward compatibility +// for forward compatibility. type ObservatoryServiceServer interface { GetOutboundStatus(context.Context, *GetOutboundStatusRequest) (*GetOutboundStatusResponse, error) mustEmbedUnimplementedObservatoryServiceServer() } -// UnimplementedObservatoryServiceServer must be embedded to have forward compatible implementations. -type UnimplementedObservatoryServiceServer struct { -} +// UnimplementedObservatoryServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedObservatoryServiceServer struct{} func (UnimplementedObservatoryServiceServer) GetOutboundStatus(context.Context, *GetOutboundStatusRequest) (*GetOutboundStatusResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetOutboundStatus not implemented") } func (UnimplementedObservatoryServiceServer) mustEmbedUnimplementedObservatoryServiceServer() {} +func (UnimplementedObservatoryServiceServer) testEmbeddedByValue() {} // UnsafeObservatoryServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to ObservatoryServiceServer will @@ -71,6 +76,13 @@ type UnsafeObservatoryServiceServer interface { } func RegisterObservatoryServiceServer(s grpc.ServiceRegistrar, srv ObservatoryServiceServer) { + // If the following call pancis, it indicates UnimplementedObservatoryServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&ObservatoryService_ServiceDesc, srv) } diff --git a/app/observatory/config.pb.go b/app/observatory/config.pb.go index c1ff512e..a6a97d69 100644 --- a/app/observatory/config.pb.go +++ b/app/observatory/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/observatory/config.proto @@ -536,7 +536,7 @@ func file_app_observatory_config_proto_rawDescGZIP() []byte { } var file_app_observatory_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_app_observatory_config_proto_goTypes = []interface{}{ +var file_app_observatory_config_proto_goTypes = []any{ (*ObservationResult)(nil), // 0: xray.core.app.observatory.ObservationResult (*HealthPingMeasurementResult)(nil), // 1: xray.core.app.observatory.HealthPingMeasurementResult (*OutboundStatus)(nil), // 2: xray.core.app.observatory.OutboundStatus @@ -560,7 +560,7 @@ func file_app_observatory_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_observatory_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ObservationResult); i { case 0: return &v.state @@ -572,7 +572,7 @@ func file_app_observatory_config_proto_init() { return nil } } - file_app_observatory_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*HealthPingMeasurementResult); i { case 0: return &v.state @@ -584,7 +584,7 @@ func file_app_observatory_config_proto_init() { return nil } } - file_app_observatory_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*OutboundStatus); i { case 0: return &v.state @@ -596,7 +596,7 @@ func file_app_observatory_config_proto_init() { return nil } } - file_app_observatory_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ProbeResult); i { case 0: return &v.state @@ -608,7 +608,7 @@ func file_app_observatory_config_proto_init() { return nil } } - file_app_observatory_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_config_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Intensity); i { case 0: return &v.state @@ -620,7 +620,7 @@ func file_app_observatory_config_proto_init() { return nil } } - file_app_observatory_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_app_observatory_config_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/app/policy/config.pb.go b/app/policy/config.pb.go index adcb363a..2ebdd61f 100644 --- a/app/policy/config.pb.go +++ b/app/policy/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/policy/config.proto @@ -570,7 +570,7 @@ func file_app_policy_config_proto_rawDescGZIP() []byte { } var file_app_policy_config_proto_msgTypes = make([]protoimpl.MessageInfo, 9) -var file_app_policy_config_proto_goTypes = []interface{}{ +var file_app_policy_config_proto_goTypes = []any{ (*Second)(nil), // 0: xray.app.policy.Second (*Policy)(nil), // 1: xray.app.policy.Policy (*SystemPolicy)(nil), // 2: xray.app.policy.SystemPolicy @@ -606,7 +606,7 @@ func file_app_policy_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_policy_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_policy_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Second); i { case 0: return &v.state @@ -618,7 +618,7 @@ func file_app_policy_config_proto_init() { return nil } } - file_app_policy_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_policy_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Policy); i { case 0: return &v.state @@ -630,7 +630,7 @@ func file_app_policy_config_proto_init() { return nil } } - file_app_policy_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_policy_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*SystemPolicy); i { case 0: return &v.state @@ -642,7 +642,7 @@ func file_app_policy_config_proto_init() { return nil } } - file_app_policy_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_app_policy_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -654,7 +654,7 @@ func file_app_policy_config_proto_init() { return nil } } - file_app_policy_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_app_policy_config_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Policy_Timeout); i { case 0: return &v.state @@ -666,7 +666,7 @@ func file_app_policy_config_proto_init() { return nil } } - file_app_policy_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_app_policy_config_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*Policy_Stats); i { case 0: return &v.state @@ -678,7 +678,7 @@ func file_app_policy_config_proto_init() { return nil } } - file_app_policy_config_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_app_policy_config_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*Policy_Buffer); i { case 0: return &v.state @@ -690,7 +690,7 @@ func file_app_policy_config_proto_init() { return nil } } - file_app_policy_config_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_app_policy_config_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*SystemPolicy_Stats); i { case 0: return &v.state diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index 7ce5904c..a3cb5526 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/proxyman/command/command.proto @@ -806,7 +806,7 @@ func file_app_proxyman_command_command_proto_rawDescGZIP() []byte { } var file_app_proxyman_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 15) -var file_app_proxyman_command_command_proto_goTypes = []interface{}{ +var file_app_proxyman_command_command_proto_goTypes = []any{ (*AddUserOperation)(nil), // 0: xray.app.proxyman.command.AddUserOperation (*RemoveUserOperation)(nil), // 1: xray.app.proxyman.command.RemoveUserOperation (*AddInboundRequest)(nil), // 2: xray.app.proxyman.command.AddInboundRequest @@ -858,7 +858,7 @@ func file_app_proxyman_command_command_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_proxyman_command_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*AddUserOperation); i { case 0: return &v.state @@ -870,7 +870,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*RemoveUserOperation); i { case 0: return &v.state @@ -882,7 +882,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*AddInboundRequest); i { case 0: return &v.state @@ -894,7 +894,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*AddInboundResponse); i { case 0: return &v.state @@ -906,7 +906,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*RemoveInboundRequest); i { case 0: return &v.state @@ -918,7 +918,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*RemoveInboundResponse); i { case 0: return &v.state @@ -930,7 +930,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*AlterInboundRequest); i { case 0: return &v.state @@ -942,7 +942,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*AlterInboundResponse); i { case 0: return &v.state @@ -954,7 +954,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*AddOutboundRequest); i { case 0: return &v.state @@ -966,7 +966,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*AddOutboundResponse); i { case 0: return &v.state @@ -978,7 +978,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*RemoveOutboundRequest); i { case 0: return &v.state @@ -990,7 +990,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*RemoveOutboundResponse); i { case 0: return &v.state @@ -1002,7 +1002,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*AlterOutboundRequest); i { case 0: return &v.state @@ -1014,7 +1014,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*AlterOutboundResponse); i { case 0: return &v.state @@ -1026,7 +1026,7 @@ func file_app_proxyman_command_command_proto_init() { return nil } } - file_app_proxyman_command_command_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_command_command_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/app/proxyman/command/command_grpc.pb.go b/app/proxyman/command/command_grpc.pb.go index 8478780e..de11193a 100644 --- a/app/proxyman/command/command_grpc.pb.go +++ b/app/proxyman/command/command_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc v5.27.0 // source: app/proxyman/command/command.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( HandlerService_AddInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddInbound" @@ -48,8 +48,9 @@ func NewHandlerServiceClient(cc grpc.ClientConnInterface) HandlerServiceClient { } func (c *handlerServiceClient) AddInbound(ctx context.Context, in *AddInboundRequest, opts ...grpc.CallOption) (*AddInboundResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AddInboundResponse) - err := c.cc.Invoke(ctx, HandlerService_AddInbound_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_AddInbound_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -57,8 +58,9 @@ func (c *handlerServiceClient) AddInbound(ctx context.Context, in *AddInboundReq } func (c *handlerServiceClient) RemoveInbound(ctx context.Context, in *RemoveInboundRequest, opts ...grpc.CallOption) (*RemoveInboundResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(RemoveInboundResponse) - err := c.cc.Invoke(ctx, HandlerService_RemoveInbound_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_RemoveInbound_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -66,8 +68,9 @@ func (c *handlerServiceClient) RemoveInbound(ctx context.Context, in *RemoveInbo } func (c *handlerServiceClient) AlterInbound(ctx context.Context, in *AlterInboundRequest, opts ...grpc.CallOption) (*AlterInboundResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AlterInboundResponse) - err := c.cc.Invoke(ctx, HandlerService_AlterInbound_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_AlterInbound_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -75,8 +78,9 @@ func (c *handlerServiceClient) AlterInbound(ctx context.Context, in *AlterInboun } func (c *handlerServiceClient) AddOutbound(ctx context.Context, in *AddOutboundRequest, opts ...grpc.CallOption) (*AddOutboundResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AddOutboundResponse) - err := c.cc.Invoke(ctx, HandlerService_AddOutbound_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_AddOutbound_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -84,8 +88,9 @@ func (c *handlerServiceClient) AddOutbound(ctx context.Context, in *AddOutboundR } func (c *handlerServiceClient) RemoveOutbound(ctx context.Context, in *RemoveOutboundRequest, opts ...grpc.CallOption) (*RemoveOutboundResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(RemoveOutboundResponse) - err := c.cc.Invoke(ctx, HandlerService_RemoveOutbound_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_RemoveOutbound_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -93,8 +98,9 @@ func (c *handlerServiceClient) RemoveOutbound(ctx context.Context, in *RemoveOut } func (c *handlerServiceClient) AlterOutbound(ctx context.Context, in *AlterOutboundRequest, opts ...grpc.CallOption) (*AlterOutboundResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AlterOutboundResponse) - err := c.cc.Invoke(ctx, HandlerService_AlterOutbound_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, HandlerService_AlterOutbound_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -103,7 +109,7 @@ func (c *handlerServiceClient) AlterOutbound(ctx context.Context, in *AlterOutbo // HandlerServiceServer is the server API for HandlerService service. // All implementations must embed UnimplementedHandlerServiceServer -// for forward compatibility +// for forward compatibility. type HandlerServiceServer interface { AddInbound(context.Context, *AddInboundRequest) (*AddInboundResponse, error) RemoveInbound(context.Context, *RemoveInboundRequest) (*RemoveInboundResponse, error) @@ -114,9 +120,12 @@ type HandlerServiceServer interface { mustEmbedUnimplementedHandlerServiceServer() } -// UnimplementedHandlerServiceServer must be embedded to have forward compatible implementations. -type UnimplementedHandlerServiceServer struct { -} +// UnimplementedHandlerServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedHandlerServiceServer struct{} func (UnimplementedHandlerServiceServer) AddInbound(context.Context, *AddInboundRequest) (*AddInboundResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddInbound not implemented") @@ -137,6 +146,7 @@ func (UnimplementedHandlerServiceServer) AlterOutbound(context.Context, *AlterOu return nil, status.Errorf(codes.Unimplemented, "method AlterOutbound not implemented") } func (UnimplementedHandlerServiceServer) mustEmbedUnimplementedHandlerServiceServer() {} +func (UnimplementedHandlerServiceServer) testEmbeddedByValue() {} // UnsafeHandlerServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to HandlerServiceServer will @@ -146,6 +156,13 @@ type UnsafeHandlerServiceServer interface { } func RegisterHandlerServiceServer(s grpc.ServiceRegistrar, srv HandlerServiceServer) { + // If the following call pancis, it indicates UnimplementedHandlerServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&HandlerService_ServiceDesc, srv) } diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index 3f4a8fbf..aed85b98 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/proxyman/config.proto @@ -920,7 +920,7 @@ func file_app_proxyman_config_proto_rawDescGZIP() []byte { var file_app_proxyman_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_app_proxyman_config_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_app_proxyman_config_proto_goTypes = []interface{}{ +var file_app_proxyman_config_proto_goTypes = []any{ (KnownProtocols)(0), // 0: xray.app.proxyman.KnownProtocols (AllocationStrategy_Type)(0), // 1: xray.app.proxyman.AllocationStrategy.Type (*InboundConfig)(nil), // 2: xray.app.proxyman.InboundConfig @@ -968,7 +968,7 @@ func file_app_proxyman_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_proxyman_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*InboundConfig); i { case 0: return &v.state @@ -980,7 +980,7 @@ func file_app_proxyman_config_proto_init() { return nil } } - file_app_proxyman_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*AllocationStrategy); i { case 0: return &v.state @@ -992,7 +992,7 @@ func file_app_proxyman_config_proto_init() { return nil } } - file_app_proxyman_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*SniffingConfig); i { case 0: return &v.state @@ -1004,7 +1004,7 @@ func file_app_proxyman_config_proto_init() { return nil } } - file_app_proxyman_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ReceiverConfig); i { case 0: return &v.state @@ -1016,7 +1016,7 @@ func file_app_proxyman_config_proto_init() { return nil } } - file_app_proxyman_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_config_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*InboundHandlerConfig); i { case 0: return &v.state @@ -1028,7 +1028,7 @@ func file_app_proxyman_config_proto_init() { return nil } } - file_app_proxyman_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_config_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*OutboundConfig); i { case 0: return &v.state @@ -1040,7 +1040,7 @@ func file_app_proxyman_config_proto_init() { return nil } } - file_app_proxyman_config_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_config_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*SenderConfig); i { case 0: return &v.state @@ -1052,7 +1052,7 @@ func file_app_proxyman_config_proto_init() { return nil } } - file_app_proxyman_config_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_config_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*MultiplexingConfig); i { case 0: return &v.state @@ -1064,7 +1064,7 @@ func file_app_proxyman_config_proto_init() { return nil } } - file_app_proxyman_config_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_config_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*AllocationStrategy_AllocationStrategyConcurrency); i { case 0: return &v.state @@ -1076,7 +1076,7 @@ func file_app_proxyman_config_proto_init() { return nil } } - file_app_proxyman_config_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_app_proxyman_config_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*AllocationStrategy_AllocationStrategyRefresh); i { case 0: return &v.state diff --git a/app/reverse/config.pb.go b/app/reverse/config.pb.go index c7572e2a..f2578d1f 100644 --- a/app/reverse/config.pb.go +++ b/app/reverse/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/reverse/config.proto @@ -338,7 +338,7 @@ func file_app_reverse_config_proto_rawDescGZIP() []byte { var file_app_reverse_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_app_reverse_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_app_reverse_config_proto_goTypes = []interface{}{ +var file_app_reverse_config_proto_goTypes = []any{ (Control_State)(0), // 0: xray.app.reverse.Control.State (*Control)(nil), // 1: xray.app.reverse.Control (*BridgeConfig)(nil), // 2: xray.app.reverse.BridgeConfig @@ -362,7 +362,7 @@ func file_app_reverse_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_reverse_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_reverse_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Control); i { case 0: return &v.state @@ -374,7 +374,7 @@ func file_app_reverse_config_proto_init() { return nil } } - file_app_reverse_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_reverse_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*BridgeConfig); i { case 0: return &v.state @@ -386,7 +386,7 @@ func file_app_reverse_config_proto_init() { return nil } } - file_app_reverse_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_reverse_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*PortalConfig); i { case 0: return &v.state @@ -398,7 +398,7 @@ func file_app_reverse_config_proto_init() { return nil } } - file_app_reverse_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_app_reverse_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/app/router/command/command.pb.go b/app/router/command/command.pb.go index 56b5798e..4b7cde3e 100644 --- a/app/router/command/command.pb.go +++ b/app/router/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/router/command/command.proto @@ -1019,7 +1019,7 @@ func file_app_router_command_command_proto_rawDescGZIP() []byte { } var file_app_router_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 16) -var file_app_router_command_command_proto_goTypes = []interface{}{ +var file_app_router_command_command_proto_goTypes = []any{ (*RoutingContext)(nil), // 0: xray.app.router.command.RoutingContext (*SubscribeRoutingStatsRequest)(nil), // 1: xray.app.router.command.SubscribeRoutingStatsRequest (*TestRouteRequest)(nil), // 2: xray.app.router.command.TestRouteRequest @@ -1072,7 +1072,7 @@ func file_app_router_command_command_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_router_command_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*RoutingContext); i { case 0: return &v.state @@ -1084,7 +1084,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*SubscribeRoutingStatsRequest); i { case 0: return &v.state @@ -1096,7 +1096,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*TestRouteRequest); i { case 0: return &v.state @@ -1108,7 +1108,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*PrincipleTargetInfo); i { case 0: return &v.state @@ -1120,7 +1120,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*OverrideInfo); i { case 0: return &v.state @@ -1132,7 +1132,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*BalancerMsg); i { case 0: return &v.state @@ -1144,7 +1144,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*GetBalancerInfoRequest); i { case 0: return &v.state @@ -1156,7 +1156,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*GetBalancerInfoResponse); i { case 0: return &v.state @@ -1168,7 +1168,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*OverrideBalancerTargetRequest); i { case 0: return &v.state @@ -1180,7 +1180,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*OverrideBalancerTargetResponse); i { case 0: return &v.state @@ -1192,7 +1192,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*AddRuleRequest); i { case 0: return &v.state @@ -1204,7 +1204,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*AddRuleResponse); i { case 0: return &v.state @@ -1216,7 +1216,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[12].Exporter = func(v any, i int) any { switch v := v.(*RemoveRuleRequest); i { case 0: return &v.state @@ -1228,7 +1228,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[13].Exporter = func(v any, i int) any { switch v := v.(*RemoveRuleResponse); i { case 0: return &v.state @@ -1240,7 +1240,7 @@ func file_app_router_command_command_proto_init() { return nil } } - file_app_router_command_command_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + file_app_router_command_command_proto_msgTypes[14].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/app/router/command/command_grpc.pb.go b/app/router/command/command_grpc.pb.go index 157fd57e..018cbe06 100644 --- a/app/router/command/command_grpc.pb.go +++ b/app/router/command/command_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc v5.27.0 // source: app/router/command/command.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( RoutingService_SubscribeRoutingStats_FullMethodName = "/xray.app.router.command.RoutingService/SubscribeRoutingStats" @@ -31,7 +31,7 @@ const ( // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type RoutingServiceClient interface { - SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error) + SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[RoutingContext], error) TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error) GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error) OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error) @@ -47,12 +47,13 @@ func NewRoutingServiceClient(cc grpc.ClientConnInterface) RoutingServiceClient { return &routingServiceClient{cc} } -func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (RoutingService_SubscribeRoutingStatsClient, error) { - stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], RoutingService_SubscribeRoutingStats_FullMethodName, opts...) +func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *SubscribeRoutingStatsRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[RoutingContext], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &RoutingService_ServiceDesc.Streams[0], RoutingService_SubscribeRoutingStats_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &routingServiceSubscribeRoutingStatsClient{stream} + x := &grpc.GenericClientStream[SubscribeRoutingStatsRequest, RoutingContext]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } @@ -62,26 +63,13 @@ func (c *routingServiceClient) SubscribeRoutingStats(ctx context.Context, in *Su return x, nil } -type RoutingService_SubscribeRoutingStatsClient interface { - Recv() (*RoutingContext, error) - grpc.ClientStream -} - -type routingServiceSubscribeRoutingStatsClient struct { - grpc.ClientStream -} - -func (x *routingServiceSubscribeRoutingStatsClient) Recv() (*RoutingContext, error) { - m := new(RoutingContext) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type RoutingService_SubscribeRoutingStatsClient = grpc.ServerStreamingClient[RoutingContext] func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteRequest, opts ...grpc.CallOption) (*RoutingContext, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(RoutingContext) - err := c.cc.Invoke(ctx, RoutingService_TestRoute_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_TestRoute_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -89,8 +77,9 @@ func (c *routingServiceClient) TestRoute(ctx context.Context, in *TestRouteReque } func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalancerInfoRequest, opts ...grpc.CallOption) (*GetBalancerInfoResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetBalancerInfoResponse) - err := c.cc.Invoke(ctx, RoutingService_GetBalancerInfo_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_GetBalancerInfo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -98,8 +87,9 @@ func (c *routingServiceClient) GetBalancerInfo(ctx context.Context, in *GetBalan } func (c *routingServiceClient) OverrideBalancerTarget(ctx context.Context, in *OverrideBalancerTargetRequest, opts ...grpc.CallOption) (*OverrideBalancerTargetResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OverrideBalancerTargetResponse) - err := c.cc.Invoke(ctx, RoutingService_OverrideBalancerTarget_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_OverrideBalancerTarget_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -107,8 +97,9 @@ func (c *routingServiceClient) OverrideBalancerTarget(ctx context.Context, in *O } func (c *routingServiceClient) AddRule(ctx context.Context, in *AddRuleRequest, opts ...grpc.CallOption) (*AddRuleResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AddRuleResponse) - err := c.cc.Invoke(ctx, RoutingService_AddRule_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_AddRule_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -116,8 +107,9 @@ func (c *routingServiceClient) AddRule(ctx context.Context, in *AddRuleRequest, } func (c *routingServiceClient) RemoveRule(ctx context.Context, in *RemoveRuleRequest, opts ...grpc.CallOption) (*RemoveRuleResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(RemoveRuleResponse) - err := c.cc.Invoke(ctx, RoutingService_RemoveRule_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, RoutingService_RemoveRule_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -126,9 +118,9 @@ func (c *routingServiceClient) RemoveRule(ctx context.Context, in *RemoveRuleReq // RoutingServiceServer is the server API for RoutingService service. // All implementations must embed UnimplementedRoutingServiceServer -// for forward compatibility +// for forward compatibility. type RoutingServiceServer interface { - SubscribeRoutingStats(*SubscribeRoutingStatsRequest, RoutingService_SubscribeRoutingStatsServer) error + SubscribeRoutingStats(*SubscribeRoutingStatsRequest, grpc.ServerStreamingServer[RoutingContext]) error TestRoute(context.Context, *TestRouteRequest) (*RoutingContext, error) GetBalancerInfo(context.Context, *GetBalancerInfoRequest) (*GetBalancerInfoResponse, error) OverrideBalancerTarget(context.Context, *OverrideBalancerTargetRequest) (*OverrideBalancerTargetResponse, error) @@ -137,11 +129,14 @@ type RoutingServiceServer interface { mustEmbedUnimplementedRoutingServiceServer() } -// UnimplementedRoutingServiceServer must be embedded to have forward compatible implementations. -type UnimplementedRoutingServiceServer struct { -} +// UnimplementedRoutingServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedRoutingServiceServer struct{} -func (UnimplementedRoutingServiceServer) SubscribeRoutingStats(*SubscribeRoutingStatsRequest, RoutingService_SubscribeRoutingStatsServer) error { +func (UnimplementedRoutingServiceServer) SubscribeRoutingStats(*SubscribeRoutingStatsRequest, grpc.ServerStreamingServer[RoutingContext]) error { return status.Errorf(codes.Unimplemented, "method SubscribeRoutingStats not implemented") } func (UnimplementedRoutingServiceServer) TestRoute(context.Context, *TestRouteRequest) (*RoutingContext, error) { @@ -160,6 +155,7 @@ func (UnimplementedRoutingServiceServer) RemoveRule(context.Context, *RemoveRule return nil, status.Errorf(codes.Unimplemented, "method RemoveRule not implemented") } func (UnimplementedRoutingServiceServer) mustEmbedUnimplementedRoutingServiceServer() {} +func (UnimplementedRoutingServiceServer) testEmbeddedByValue() {} // UnsafeRoutingServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to RoutingServiceServer will @@ -169,6 +165,13 @@ type UnsafeRoutingServiceServer interface { } func RegisterRoutingServiceServer(s grpc.ServiceRegistrar, srv RoutingServiceServer) { + // If the following call pancis, it indicates UnimplementedRoutingServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&RoutingService_ServiceDesc, srv) } @@ -177,21 +180,11 @@ func _RoutingService_SubscribeRoutingStats_Handler(srv interface{}, stream grpc. if err := stream.RecvMsg(m); err != nil { return err } - return srv.(RoutingServiceServer).SubscribeRoutingStats(m, &routingServiceSubscribeRoutingStatsServer{stream}) + return srv.(RoutingServiceServer).SubscribeRoutingStats(m, &grpc.GenericServerStream[SubscribeRoutingStatsRequest, RoutingContext]{ServerStream: stream}) } -type RoutingService_SubscribeRoutingStatsServer interface { - Send(*RoutingContext) error - grpc.ServerStream -} - -type routingServiceSubscribeRoutingStatsServer struct { - grpc.ServerStream -} - -func (x *routingServiceSubscribeRoutingStatsServer) Send(m *RoutingContext) error { - return x.ServerStream.SendMsg(m) -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type RoutingService_SubscribeRoutingStatsServer = grpc.ServerStreamingServer[RoutingContext] func _RoutingService_TestRoute_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(TestRouteRequest) diff --git a/app/router/config.pb.go b/app/router/config.pb.go index 43f3bcfc..c606ab47 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/router/config.proto @@ -1275,7 +1275,7 @@ func file_app_router_config_proto_rawDescGZIP() []byte { var file_app_router_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_app_router_config_proto_msgTypes = make([]protoimpl.MessageInfo, 13) -var file_app_router_config_proto_goTypes = []interface{}{ +var file_app_router_config_proto_goTypes = []any{ (Domain_Type)(0), // 0: xray.app.router.Domain.Type (Config_DomainStrategy)(0), // 1: xray.app.router.Config.DomainStrategy (*Domain)(nil), // 2: xray.app.router.Domain @@ -1333,7 +1333,7 @@ func file_app_router_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_router_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Domain); i { case 0: return &v.state @@ -1345,7 +1345,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*CIDR); i { case 0: return &v.state @@ -1357,7 +1357,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*GeoIP); i { case 0: return &v.state @@ -1369,7 +1369,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*GeoIPList); i { case 0: return &v.state @@ -1381,7 +1381,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*GeoSite); i { case 0: return &v.state @@ -1393,7 +1393,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*GeoSiteList); i { case 0: return &v.state @@ -1405,7 +1405,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*RoutingRule); i { case 0: return &v.state @@ -1417,7 +1417,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*BalancingRule); i { case 0: return &v.state @@ -1429,7 +1429,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*StrategyWeight); i { case 0: return &v.state @@ -1441,7 +1441,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*StrategyLeastLoadConfig); i { case 0: return &v.state @@ -1453,7 +1453,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -1465,7 +1465,7 @@ func file_app_router_config_proto_init() { return nil } } - file_app_router_config_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_app_router_config_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*Domain_Attribute); i { case 0: return &v.state @@ -1478,11 +1478,11 @@ func file_app_router_config_proto_init() { } } } - file_app_router_config_proto_msgTypes[6].OneofWrappers = []interface{}{ + file_app_router_config_proto_msgTypes[6].OneofWrappers = []any{ (*RoutingRule_Tag)(nil), (*RoutingRule_BalancingTag)(nil), } - file_app_router_config_proto_msgTypes[11].OneofWrappers = []interface{}{ + file_app_router_config_proto_msgTypes[11].OneofWrappers = []any{ (*Domain_Attribute_BoolValue)(nil), (*Domain_Attribute_IntValue)(nil), } diff --git a/app/stats/command/command.pb.go b/app/stats/command/command.pb.go index 418e7fb1..cbfe2aa3 100644 --- a/app/stats/command/command.pb.go +++ b/app/stats/command/command.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/stats/command/command.proto @@ -565,7 +565,7 @@ func file_app_stats_command_command_proto_rawDescGZIP() []byte { } var file_app_stats_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_app_stats_command_command_proto_goTypes = []interface{}{ +var file_app_stats_command_command_proto_goTypes = []any{ (*GetStatsRequest)(nil), // 0: xray.app.stats.command.GetStatsRequest (*Stat)(nil), // 1: xray.app.stats.command.Stat (*GetStatsResponse)(nil), // 2: xray.app.stats.command.GetStatsResponse @@ -597,7 +597,7 @@ func file_app_stats_command_command_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_stats_command_command_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_stats_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*GetStatsRequest); i { case 0: return &v.state @@ -609,7 +609,7 @@ func file_app_stats_command_command_proto_init() { return nil } } - file_app_stats_command_command_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_stats_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Stat); i { case 0: return &v.state @@ -621,7 +621,7 @@ func file_app_stats_command_command_proto_init() { return nil } } - file_app_stats_command_command_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_app_stats_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*GetStatsResponse); i { case 0: return &v.state @@ -633,7 +633,7 @@ func file_app_stats_command_command_proto_init() { return nil } } - file_app_stats_command_command_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_app_stats_command_command_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*QueryStatsRequest); i { case 0: return &v.state @@ -645,7 +645,7 @@ func file_app_stats_command_command_proto_init() { return nil } } - file_app_stats_command_command_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_app_stats_command_command_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*QueryStatsResponse); i { case 0: return &v.state @@ -657,7 +657,7 @@ func file_app_stats_command_command_proto_init() { return nil } } - file_app_stats_command_command_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_app_stats_command_command_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*SysStatsRequest); i { case 0: return &v.state @@ -669,7 +669,7 @@ func file_app_stats_command_command_proto_init() { return nil } } - file_app_stats_command_command_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_app_stats_command_command_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*SysStatsResponse); i { case 0: return &v.state @@ -681,7 +681,7 @@ func file_app_stats_command_command_proto_init() { return nil } } - file_app_stats_command_command_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_app_stats_command_command_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/app/stats/command/command_grpc.pb.go b/app/stats/command/command_grpc.pb.go index e9420299..365bfbd6 100644 --- a/app/stats/command/command_grpc.pb.go +++ b/app/stats/command/command_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc v5.27.0 // source: app/stats/command/command.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( StatsService_GetStats_FullMethodName = "/xray.app.stats.command.StatsService/GetStats" @@ -42,8 +42,9 @@ func NewStatsServiceClient(cc grpc.ClientConnInterface) StatsServiceClient { } func (c *statsServiceClient) GetStats(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetStatsResponse) - err := c.cc.Invoke(ctx, StatsService_GetStats_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, StatsService_GetStats_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -51,8 +52,9 @@ func (c *statsServiceClient) GetStats(ctx context.Context, in *GetStatsRequest, } func (c *statsServiceClient) QueryStats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryStatsResponse) - err := c.cc.Invoke(ctx, StatsService_QueryStats_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, StatsService_QueryStats_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -60,8 +62,9 @@ func (c *statsServiceClient) QueryStats(ctx context.Context, in *QueryStatsReque } func (c *statsServiceClient) GetSysStats(ctx context.Context, in *SysStatsRequest, opts ...grpc.CallOption) (*SysStatsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(SysStatsResponse) - err := c.cc.Invoke(ctx, StatsService_GetSysStats_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, StatsService_GetSysStats_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -70,7 +73,7 @@ func (c *statsServiceClient) GetSysStats(ctx context.Context, in *SysStatsReques // StatsServiceServer is the server API for StatsService service. // All implementations must embed UnimplementedStatsServiceServer -// for forward compatibility +// for forward compatibility. type StatsServiceServer interface { GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error) QueryStats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error) @@ -78,9 +81,12 @@ type StatsServiceServer interface { mustEmbedUnimplementedStatsServiceServer() } -// UnimplementedStatsServiceServer must be embedded to have forward compatible implementations. -type UnimplementedStatsServiceServer struct { -} +// UnimplementedStatsServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedStatsServiceServer struct{} func (UnimplementedStatsServiceServer) GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStats not implemented") @@ -92,6 +98,7 @@ func (UnimplementedStatsServiceServer) GetSysStats(context.Context, *SysStatsReq return nil, status.Errorf(codes.Unimplemented, "method GetSysStats not implemented") } func (UnimplementedStatsServiceServer) mustEmbedUnimplementedStatsServiceServer() {} +func (UnimplementedStatsServiceServer) testEmbeddedByValue() {} // UnsafeStatsServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to StatsServiceServer will @@ -101,6 +108,13 @@ type UnsafeStatsServiceServer interface { } func RegisterStatsServiceServer(s grpc.ServiceRegistrar, srv StatsServiceServer) { + // If the following call pancis, it indicates UnimplementedStatsServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&StatsService_ServiceDesc, srv) } diff --git a/app/stats/config.pb.go b/app/stats/config.pb.go index 4f5e04d9..bfe526f2 100644 --- a/app/stats/config.pb.go +++ b/app/stats/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: app/stats/config.proto @@ -155,7 +155,7 @@ func file_app_stats_config_proto_rawDescGZIP() []byte { } var file_app_stats_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_app_stats_config_proto_goTypes = []interface{}{ +var file_app_stats_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.app.stats.Config (*ChannelConfig)(nil), // 1: xray.app.stats.ChannelConfig } @@ -173,7 +173,7 @@ func file_app_stats_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_app_stats_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_app_stats_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -185,7 +185,7 @@ func file_app_stats_config_proto_init() { return nil } } - file_app_stats_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_app_stats_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ChannelConfig); i { case 0: return &v.state diff --git a/common/log/log.pb.go b/common/log/log.pb.go index 2a970b54..57215685 100644 --- a/common/log/log.pb.go +++ b/common/log/log.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: common/log/log.proto @@ -106,7 +106,7 @@ func file_common_log_log_proto_rawDescGZIP() []byte { } var file_common_log_log_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_common_log_log_proto_goTypes = []interface{}{ +var file_common_log_log_proto_goTypes = []any{ (Severity)(0), // 0: xray.common.log.Severity } var file_common_log_log_proto_depIdxs = []int32{ diff --git a/common/net/address.pb.go b/common/net/address.pb.go index fd61b16a..973d8d3a 100644 --- a/common/net/address.pb.go +++ b/common/net/address.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: common/net/address.proto @@ -136,7 +136,7 @@ func file_common_net_address_proto_rawDescGZIP() []byte { } var file_common_net_address_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_common_net_address_proto_goTypes = []interface{}{ +var file_common_net_address_proto_goTypes = []any{ (*IPOrDomain)(nil), // 0: xray.common.net.IPOrDomain } var file_common_net_address_proto_depIdxs = []int32{ @@ -153,7 +153,7 @@ func file_common_net_address_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_common_net_address_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_common_net_address_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*IPOrDomain); i { case 0: return &v.state @@ -166,7 +166,7 @@ func file_common_net_address_proto_init() { } } } - file_common_net_address_proto_msgTypes[0].OneofWrappers = []interface{}{ + file_common_net_address_proto_msgTypes[0].OneofWrappers = []any{ (*IPOrDomain_Ip)(nil), (*IPOrDomain_Domain)(nil), } diff --git a/common/net/destination.pb.go b/common/net/destination.pb.go index 3e4de52c..c796f042 100644 --- a/common/net/destination.pb.go +++ b/common/net/destination.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: common/net/destination.proto @@ -123,7 +123,7 @@ func file_common_net_destination_proto_rawDescGZIP() []byte { } var file_common_net_destination_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_common_net_destination_proto_goTypes = []interface{}{ +var file_common_net_destination_proto_goTypes = []any{ (*Endpoint)(nil), // 0: xray.common.net.Endpoint (Network)(0), // 1: xray.common.net.Network (*IPOrDomain)(nil), // 2: xray.common.net.IPOrDomain @@ -146,7 +146,7 @@ func file_common_net_destination_proto_init() { file_common_net_network_proto_init() file_common_net_address_proto_init() if !protoimpl.UnsafeEnabled { - file_common_net_destination_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_common_net_destination_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Endpoint); i { case 0: return &v.state diff --git a/common/net/network.pb.go b/common/net/network.pb.go index f720ca54..e2320475 100644 --- a/common/net/network.pb.go +++ b/common/net/network.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: common/net/network.proto @@ -160,7 +160,7 @@ func file_common_net_network_proto_rawDescGZIP() []byte { var file_common_net_network_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_common_net_network_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_common_net_network_proto_goTypes = []interface{}{ +var file_common_net_network_proto_goTypes = []any{ (Network)(0), // 0: xray.common.net.Network (*NetworkList)(nil), // 1: xray.common.net.NetworkList } @@ -179,7 +179,7 @@ func file_common_net_network_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_common_net_network_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_common_net_network_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*NetworkList); i { case 0: return &v.state diff --git a/common/net/port.pb.go b/common/net/port.pb.go index 36af4942..70415158 100644 --- a/common/net/port.pb.go +++ b/common/net/port.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: common/net/port.proto @@ -159,7 +159,7 @@ func file_common_net_port_proto_rawDescGZIP() []byte { } var file_common_net_port_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_common_net_port_proto_goTypes = []interface{}{ +var file_common_net_port_proto_goTypes = []any{ (*PortRange)(nil), // 0: xray.common.net.PortRange (*PortList)(nil), // 1: xray.common.net.PortList } @@ -178,7 +178,7 @@ func file_common_net_port_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_common_net_port_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_common_net_port_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*PortRange); i { case 0: return &v.state @@ -190,7 +190,7 @@ func file_common_net_port_proto_init() { return nil } } - file_common_net_port_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_common_net_port_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*PortList); i { case 0: return &v.state diff --git a/common/protocol/headers.pb.go b/common/protocol/headers.pb.go index bb6e810b..f256bf2e 100644 --- a/common/protocol/headers.pb.go +++ b/common/protocol/headers.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: common/protocol/headers.proto @@ -165,7 +165,7 @@ func file_common_protocol_headers_proto_rawDescGZIP() []byte { var file_common_protocol_headers_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_common_protocol_headers_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_common_protocol_headers_proto_goTypes = []interface{}{ +var file_common_protocol_headers_proto_goTypes = []any{ (SecurityType)(0), // 0: xray.common.protocol.SecurityType (*SecurityConfig)(nil), // 1: xray.common.protocol.SecurityConfig } @@ -184,7 +184,7 @@ func file_common_protocol_headers_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_common_protocol_headers_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_common_protocol_headers_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*SecurityConfig); i { case 0: return &v.state diff --git a/common/protocol/server_spec.pb.go b/common/protocol/server_spec.pb.go index cb19e91e..42c7569a 100644 --- a/common/protocol/server_spec.pb.go +++ b/common/protocol/server_spec.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: common/protocol/server_spec.proto @@ -125,7 +125,7 @@ func file_common_protocol_server_spec_proto_rawDescGZIP() []byte { } var file_common_protocol_server_spec_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_common_protocol_server_spec_proto_goTypes = []interface{}{ +var file_common_protocol_server_spec_proto_goTypes = []any{ (*ServerEndpoint)(nil), // 0: xray.common.protocol.ServerEndpoint (*net.IPOrDomain)(nil), // 1: xray.common.net.IPOrDomain (*User)(nil), // 2: xray.common.protocol.User @@ -147,7 +147,7 @@ func file_common_protocol_server_spec_proto_init() { } file_common_protocol_user_proto_init() if !protoimpl.UnsafeEnabled { - file_common_protocol_server_spec_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_common_protocol_server_spec_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ServerEndpoint); i { case 0: return &v.state diff --git a/common/protocol/user.pb.go b/common/protocol/user.pb.go index dfa89b33..c97765ff 100644 --- a/common/protocol/user.pb.go +++ b/common/protocol/user.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: common/protocol/user.proto @@ -124,7 +124,7 @@ func file_common_protocol_user_proto_rawDescGZIP() []byte { } var file_common_protocol_user_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_common_protocol_user_proto_goTypes = []interface{}{ +var file_common_protocol_user_proto_goTypes = []any{ (*User)(nil), // 0: xray.common.protocol.User (*serial.TypedMessage)(nil), // 1: xray.common.serial.TypedMessage } @@ -143,7 +143,7 @@ func file_common_protocol_user_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_common_protocol_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_common_protocol_user_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*User); i { case 0: return &v.state diff --git a/common/serial/typed_message.pb.go b/common/serial/typed_message.pb.go index 719a2d04..361f16c7 100644 --- a/common/serial/typed_message.pb.go +++ b/common/serial/typed_message.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: common/serial/typed_message.proto @@ -110,7 +110,7 @@ func file_common_serial_typed_message_proto_rawDescGZIP() []byte { } var file_common_serial_typed_message_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_common_serial_typed_message_proto_goTypes = []interface{}{ +var file_common_serial_typed_message_proto_goTypes = []any{ (*TypedMessage)(nil), // 0: xray.common.serial.TypedMessage } var file_common_serial_typed_message_proto_depIdxs = []int32{ @@ -127,7 +127,7 @@ func file_common_serial_typed_message_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_common_serial_typed_message_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_common_serial_typed_message_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*TypedMessage); i { case 0: return &v.state diff --git a/core/config.pb.go b/core/config.pb.go index 1b2591dc..fc31c903 100644 --- a/core/config.pb.go +++ b/core/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: core/config.proto @@ -347,7 +347,7 @@ func file_core_config_proto_rawDescGZIP() []byte { } var file_core_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_core_config_proto_goTypes = []interface{}{ +var file_core_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.core.Config (*InboundHandlerConfig)(nil), // 1: xray.core.InboundHandlerConfig (*OutboundHandlerConfig)(nil), // 2: xray.core.OutboundHandlerConfig @@ -377,7 +377,7 @@ func file_core_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_core_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_core_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -389,7 +389,7 @@ func file_core_config_proto_init() { return nil } } - file_core_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_core_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*InboundHandlerConfig); i { case 0: return &v.state @@ -401,7 +401,7 @@ func file_core_config_proto_init() { return nil } } - file_core_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_core_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*OutboundHandlerConfig); i { case 0: return &v.state diff --git a/core/proto.go b/core/proto.go index 030365cc..b85d99d8 100644 --- a/core/proto.go +++ b/core/proto.go @@ -1,5 +1,5 @@ package core -//go:generate go install -v google.golang.org/protobuf/cmd/protoc-gen-go@latest -//go:generate go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest +//go:generate go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2 +//go:generate go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 //go:generate go run ../infra/vprotogen/main.go -pwd ./.. diff --git a/proxy/blackhole/config.pb.go b/proxy/blackhole/config.pb.go index f2e54293..d9ebaeab 100644 --- a/proxy/blackhole/config.pb.go +++ b/proxy/blackhole/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/blackhole/config.proto @@ -181,7 +181,7 @@ func file_proxy_blackhole_config_proto_rawDescGZIP() []byte { } var file_proxy_blackhole_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_proxy_blackhole_config_proto_goTypes = []interface{}{ +var file_proxy_blackhole_config_proto_goTypes = []any{ (*NoneResponse)(nil), // 0: xray.proxy.blackhole.NoneResponse (*HTTPResponse)(nil), // 1: xray.proxy.blackhole.HTTPResponse (*Config)(nil), // 2: xray.proxy.blackhole.Config @@ -202,7 +202,7 @@ func file_proxy_blackhole_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_blackhole_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_blackhole_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*NoneResponse); i { case 0: return &v.state @@ -214,7 +214,7 @@ func file_proxy_blackhole_config_proto_init() { return nil } } - file_proxy_blackhole_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_blackhole_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*HTTPResponse); i { case 0: return &v.state @@ -226,7 +226,7 @@ func file_proxy_blackhole_config_proto_init() { return nil } } - file_proxy_blackhole_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_proxy_blackhole_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/proxy/dns/config.pb.go b/proxy/dns/config.pb.go index d8a46aed..52c680d3 100644 --- a/proxy/dns/config.pb.go +++ b/proxy/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/dns/config.proto @@ -122,7 +122,7 @@ func file_proxy_dns_config_proto_rawDescGZIP() []byte { } var file_proxy_dns_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_proxy_dns_config_proto_goTypes = []interface{}{ +var file_proxy_dns_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.proxy.dns.Config (*net.Endpoint)(nil), // 1: xray.common.net.Endpoint } @@ -141,7 +141,7 @@ func file_proxy_dns_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_dns_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_dns_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/proxy/dokodemo/config.pb.go b/proxy/dokodemo/config.pb.go index 4f698be1..b0446a40 100644 --- a/proxy/dokodemo/config.pb.go +++ b/proxy/dokodemo/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/dokodemo/config.proto @@ -175,7 +175,7 @@ func file_proxy_dokodemo_config_proto_rawDescGZIP() []byte { } var file_proxy_dokodemo_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_proxy_dokodemo_config_proto_goTypes = []interface{}{ +var file_proxy_dokodemo_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.proxy.dokodemo.Config (*net.IPOrDomain)(nil), // 1: xray.common.net.IPOrDomain (*net.NetworkList)(nil), // 2: xray.common.net.NetworkList @@ -198,7 +198,7 @@ func file_proxy_dokodemo_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_dokodemo_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_dokodemo_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index c8f6c3df..723d4de4 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/freedom/config.proto @@ -399,7 +399,7 @@ func file_proxy_freedom_config_proto_rawDescGZIP() []byte { var file_proxy_freedom_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_proxy_freedom_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_proxy_freedom_config_proto_goTypes = []interface{}{ +var file_proxy_freedom_config_proto_goTypes = []any{ (Config_DomainStrategy)(0), // 0: xray.proxy.freedom.Config.DomainStrategy (*DestinationOverride)(nil), // 1: xray.proxy.freedom.DestinationOverride (*Fragment)(nil), // 2: xray.proxy.freedom.Fragment @@ -424,7 +424,7 @@ func file_proxy_freedom_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_freedom_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_freedom_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*DestinationOverride); i { case 0: return &v.state @@ -436,7 +436,7 @@ func file_proxy_freedom_config_proto_init() { return nil } } - file_proxy_freedom_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_freedom_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Fragment); i { case 0: return &v.state @@ -448,7 +448,7 @@ func file_proxy_freedom_config_proto_init() { return nil } } - file_proxy_freedom_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_proxy_freedom_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/proxy/http/config.pb.go b/proxy/http/config.pb.go index c4494a26..08804d9a 100644 --- a/proxy/http/config.pb.go +++ b/proxy/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/http/config.proto @@ -322,7 +322,7 @@ func file_proxy_http_config_proto_rawDescGZIP() []byte { } var file_proxy_http_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_proxy_http_config_proto_goTypes = []interface{}{ +var file_proxy_http_config_proto_goTypes = []any{ (*Account)(nil), // 0: xray.proxy.http.Account (*ServerConfig)(nil), // 1: xray.proxy.http.ServerConfig (*Header)(nil), // 2: xray.proxy.http.Header @@ -347,7 +347,7 @@ func file_proxy_http_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_http_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_http_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Account); i { case 0: return &v.state @@ -359,7 +359,7 @@ func file_proxy_http_config_proto_init() { return nil } } - file_proxy_http_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_http_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ServerConfig); i { case 0: return &v.state @@ -371,7 +371,7 @@ func file_proxy_http_config_proto_init() { return nil } } - file_proxy_http_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_proxy_http_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Header); i { case 0: return &v.state @@ -383,7 +383,7 @@ func file_proxy_http_config_proto_init() { return nil } } - file_proxy_http_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_proxy_http_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ClientConfig); i { case 0: return &v.state diff --git a/proxy/loopback/config.pb.go b/proxy/loopback/config.pb.go index f66696ee..22482623 100644 --- a/proxy/loopback/config.pb.go +++ b/proxy/loopback/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/loopback/config.proto @@ -98,7 +98,7 @@ func file_proxy_loopback_config_proto_rawDescGZIP() []byte { } var file_proxy_loopback_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_proxy_loopback_config_proto_goTypes = []interface{}{ +var file_proxy_loopback_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.proxy.loopback.Config } var file_proxy_loopback_config_proto_depIdxs = []int32{ @@ -115,7 +115,7 @@ func file_proxy_loopback_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_loopback_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_loopback_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/proxy/shadowsocks/config.pb.go b/proxy/shadowsocks/config.pb.go index 03dd3342..d2f96de7 100644 --- a/proxy/shadowsocks/config.pb.go +++ b/proxy/shadowsocks/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/shadowsocks/config.proto @@ -309,7 +309,7 @@ func file_proxy_shadowsocks_config_proto_rawDescGZIP() []byte { var file_proxy_shadowsocks_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_proxy_shadowsocks_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_proxy_shadowsocks_config_proto_goTypes = []interface{}{ +var file_proxy_shadowsocks_config_proto_goTypes = []any{ (CipherType)(0), // 0: xray.proxy.shadowsocks.CipherType (*Account)(nil), // 1: xray.proxy.shadowsocks.Account (*ServerConfig)(nil), // 2: xray.proxy.shadowsocks.ServerConfig @@ -336,7 +336,7 @@ func file_proxy_shadowsocks_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_shadowsocks_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_shadowsocks_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Account); i { case 0: return &v.state @@ -348,7 +348,7 @@ func file_proxy_shadowsocks_config_proto_init() { return nil } } - file_proxy_shadowsocks_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_shadowsocks_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ServerConfig); i { case 0: return &v.state @@ -360,7 +360,7 @@ func file_proxy_shadowsocks_config_proto_init() { return nil } } - file_proxy_shadowsocks_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_proxy_shadowsocks_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ClientConfig); i { case 0: return &v.state diff --git a/proxy/shadowsocks_2022/config.pb.go b/proxy/shadowsocks_2022/config.pb.go index 41978474..b65be80a 100644 --- a/proxy/shadowsocks_2022/config.pb.go +++ b/proxy/shadowsocks_2022/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/shadowsocks_2022/config.proto @@ -566,7 +566,7 @@ func file_proxy_shadowsocks_2022_config_proto_rawDescGZIP() []byte { } var file_proxy_shadowsocks_2022_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_proxy_shadowsocks_2022_config_proto_goTypes = []interface{}{ +var file_proxy_shadowsocks_2022_config_proto_goTypes = []any{ (*ServerConfig)(nil), // 0: xray.proxy.shadowsocks_2022.ServerConfig (*MultiUserServerConfig)(nil), // 1: xray.proxy.shadowsocks_2022.MultiUserServerConfig (*RelayDestination)(nil), // 2: xray.proxy.shadowsocks_2022.RelayDestination @@ -597,7 +597,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_shadowsocks_2022_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_shadowsocks_2022_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ServerConfig); i { case 0: return &v.state @@ -609,7 +609,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() { return nil } } - file_proxy_shadowsocks_2022_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_shadowsocks_2022_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*MultiUserServerConfig); i { case 0: return &v.state @@ -621,7 +621,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() { return nil } } - file_proxy_shadowsocks_2022_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_proxy_shadowsocks_2022_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*RelayDestination); i { case 0: return &v.state @@ -633,7 +633,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() { return nil } } - file_proxy_shadowsocks_2022_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_proxy_shadowsocks_2022_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*RelayServerConfig); i { case 0: return &v.state @@ -645,7 +645,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() { return nil } } - file_proxy_shadowsocks_2022_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_proxy_shadowsocks_2022_config_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*User); i { case 0: return &v.state @@ -657,7 +657,7 @@ func file_proxy_shadowsocks_2022_config_proto_init() { return nil } } - file_proxy_shadowsocks_2022_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_proxy_shadowsocks_2022_config_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*ClientConfig); i { case 0: return &v.state diff --git a/proxy/socks/config.pb.go b/proxy/socks/config.pb.go index d13ebd10..0bc5fe15 100644 --- a/proxy/socks/config.pb.go +++ b/proxy/socks/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/socks/config.proto @@ -395,7 +395,7 @@ func file_proxy_socks_config_proto_rawDescGZIP() []byte { var file_proxy_socks_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_proxy_socks_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_proxy_socks_config_proto_goTypes = []interface{}{ +var file_proxy_socks_config_proto_goTypes = []any{ (AuthType)(0), // 0: xray.proxy.socks.AuthType (Version)(0), // 1: xray.proxy.socks.Version (*Account)(nil), // 2: xray.proxy.socks.Account @@ -424,7 +424,7 @@ func file_proxy_socks_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_socks_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_socks_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Account); i { case 0: return &v.state @@ -436,7 +436,7 @@ func file_proxy_socks_config_proto_init() { return nil } } - file_proxy_socks_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_socks_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ServerConfig); i { case 0: return &v.state @@ -448,7 +448,7 @@ func file_proxy_socks_config_proto_init() { return nil } } - file_proxy_socks_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_proxy_socks_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ClientConfig); i { case 0: return &v.state diff --git a/proxy/trojan/config.pb.go b/proxy/trojan/config.pb.go index 6cd360ed..073e6792 100644 --- a/proxy/trojan/config.pb.go +++ b/proxy/trojan/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/trojan/config.proto @@ -312,7 +312,7 @@ func file_proxy_trojan_config_proto_rawDescGZIP() []byte { } var file_proxy_trojan_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_proxy_trojan_config_proto_goTypes = []interface{}{ +var file_proxy_trojan_config_proto_goTypes = []any{ (*Account)(nil), // 0: xray.proxy.trojan.Account (*Fallback)(nil), // 1: xray.proxy.trojan.Fallback (*ClientConfig)(nil), // 2: xray.proxy.trojan.ClientConfig @@ -337,7 +337,7 @@ func file_proxy_trojan_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_trojan_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_trojan_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Account); i { case 0: return &v.state @@ -349,7 +349,7 @@ func file_proxy_trojan_config_proto_init() { return nil } } - file_proxy_trojan_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_trojan_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Fallback); i { case 0: return &v.state @@ -361,7 +361,7 @@ func file_proxy_trojan_config_proto_init() { return nil } } - file_proxy_trojan_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_proxy_trojan_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ClientConfig); i { case 0: return &v.state @@ -373,7 +373,7 @@ func file_proxy_trojan_config_proto_init() { return nil } } - file_proxy_trojan_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_proxy_trojan_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ServerConfig); i { case 0: return &v.state diff --git a/proxy/vless/account.pb.go b/proxy/vless/account.pb.go index 24564a36..78854359 100644 --- a/proxy/vless/account.pb.go +++ b/proxy/vless/account.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/vless/account.proto @@ -118,7 +118,7 @@ func file_proxy_vless_account_proto_rawDescGZIP() []byte { } var file_proxy_vless_account_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_proxy_vless_account_proto_goTypes = []interface{}{ +var file_proxy_vless_account_proto_goTypes = []any{ (*Account)(nil), // 0: xray.proxy.vless.Account } var file_proxy_vless_account_proto_depIdxs = []int32{ @@ -135,7 +135,7 @@ func file_proxy_vless_account_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_vless_account_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_vless_account_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Account); i { case 0: return &v.state diff --git a/proxy/vless/encoding/addons.pb.go b/proxy/vless/encoding/addons.pb.go index c876d543..f093dda4 100644 --- a/proxy/vless/encoding/addons.pb.go +++ b/proxy/vless/encoding/addons.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/vless/encoding/addons.proto @@ -108,7 +108,7 @@ func file_proxy_vless_encoding_addons_proto_rawDescGZIP() []byte { } var file_proxy_vless_encoding_addons_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_proxy_vless_encoding_addons_proto_goTypes = []interface{}{ +var file_proxy_vless_encoding_addons_proto_goTypes = []any{ (*Addons)(nil), // 0: xray.proxy.vless.encoding.Addons } var file_proxy_vless_encoding_addons_proto_depIdxs = []int32{ @@ -125,7 +125,7 @@ func file_proxy_vless_encoding_addons_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_vless_encoding_addons_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_vless_encoding_addons_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Addons); i { case 0: return &v.state diff --git a/proxy/vless/inbound/config.pb.go b/proxy/vless/inbound/config.pb.go index c60cd9c5..66adee6f 100644 --- a/proxy/vless/inbound/config.pb.go +++ b/proxy/vless/inbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/vless/inbound/config.proto @@ -223,7 +223,7 @@ func file_proxy_vless_inbound_config_proto_rawDescGZIP() []byte { } var file_proxy_vless_inbound_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_proxy_vless_inbound_config_proto_goTypes = []interface{}{ +var file_proxy_vless_inbound_config_proto_goTypes = []any{ (*Fallback)(nil), // 0: xray.proxy.vless.inbound.Fallback (*Config)(nil), // 1: xray.proxy.vless.inbound.Config (*protocol.User)(nil), // 2: xray.common.protocol.User @@ -244,7 +244,7 @@ func file_proxy_vless_inbound_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_vless_inbound_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_vless_inbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Fallback); i { case 0: return &v.state @@ -256,7 +256,7 @@ func file_proxy_vless_inbound_config_proto_init() { return nil } } - file_proxy_vless_inbound_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_vless_inbound_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/proxy/vless/outbound/config.pb.go b/proxy/vless/outbound/config.pb.go index f7fa0e33..4df54775 100644 --- a/proxy/vless/outbound/config.pb.go +++ b/proxy/vless/outbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/vless/outbound/config.proto @@ -104,7 +104,7 @@ func file_proxy_vless_outbound_config_proto_rawDescGZIP() []byte { } var file_proxy_vless_outbound_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_proxy_vless_outbound_config_proto_goTypes = []interface{}{ +var file_proxy_vless_outbound_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.proxy.vless.outbound.Config (*protocol.ServerEndpoint)(nil), // 1: xray.common.protocol.ServerEndpoint } @@ -123,7 +123,7 @@ func file_proxy_vless_outbound_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_vless_outbound_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_vless_outbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/proxy/vmess/account.pb.go b/proxy/vmess/account.pb.go index d961130a..8e406071 100644 --- a/proxy/vmess/account.pb.go +++ b/proxy/vmess/account.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/vmess/account.proto @@ -126,7 +126,7 @@ func file_proxy_vmess_account_proto_rawDescGZIP() []byte { } var file_proxy_vmess_account_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_proxy_vmess_account_proto_goTypes = []interface{}{ +var file_proxy_vmess_account_proto_goTypes = []any{ (*Account)(nil), // 0: xray.proxy.vmess.Account (*protocol.SecurityConfig)(nil), // 1: xray.common.protocol.SecurityConfig } @@ -145,7 +145,7 @@ func file_proxy_vmess_account_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_vmess_account_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_vmess_account_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Account); i { case 0: return &v.state diff --git a/proxy/vmess/inbound/config.pb.go b/proxy/vmess/inbound/config.pb.go index 5b0c8c98..43457e69 100644 --- a/proxy/vmess/inbound/config.pb.go +++ b/proxy/vmess/inbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/vmess/inbound/config.proto @@ -226,7 +226,7 @@ func file_proxy_vmess_inbound_config_proto_rawDescGZIP() []byte { } var file_proxy_vmess_inbound_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_proxy_vmess_inbound_config_proto_goTypes = []interface{}{ +var file_proxy_vmess_inbound_config_proto_goTypes = []any{ (*DetourConfig)(nil), // 0: xray.proxy.vmess.inbound.DetourConfig (*DefaultConfig)(nil), // 1: xray.proxy.vmess.inbound.DefaultConfig (*Config)(nil), // 2: xray.proxy.vmess.inbound.Config @@ -249,7 +249,7 @@ func file_proxy_vmess_inbound_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_vmess_inbound_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_vmess_inbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*DetourConfig); i { case 0: return &v.state @@ -261,7 +261,7 @@ func file_proxy_vmess_inbound_config_proto_init() { return nil } } - file_proxy_vmess_inbound_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_vmess_inbound_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*DefaultConfig); i { case 0: return &v.state @@ -273,7 +273,7 @@ func file_proxy_vmess_inbound_config_proto_init() { return nil } } - file_proxy_vmess_inbound_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_proxy_vmess_inbound_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/proxy/vmess/outbound/config.pb.go b/proxy/vmess/outbound/config.pb.go index ecadd1c0..b1840d1d 100644 --- a/proxy/vmess/outbound/config.pb.go +++ b/proxy/vmess/outbound/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/vmess/outbound/config.proto @@ -105,7 +105,7 @@ func file_proxy_vmess_outbound_config_proto_rawDescGZIP() []byte { } var file_proxy_vmess_outbound_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_proxy_vmess_outbound_config_proto_goTypes = []interface{}{ +var file_proxy_vmess_outbound_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.proxy.vmess.outbound.Config (*protocol.ServerEndpoint)(nil), // 1: xray.common.protocol.ServerEndpoint } @@ -124,7 +124,7 @@ func file_proxy_vmess_outbound_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_vmess_outbound_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_vmess_outbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/proxy/wireguard/config.pb.go b/proxy/wireguard/config.pb.go index 25036ba7..fb0d6582 100644 --- a/proxy/wireguard/config.pb.go +++ b/proxy/wireguard/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: proxy/wireguard/config.proto @@ -334,7 +334,7 @@ func file_proxy_wireguard_config_proto_rawDescGZIP() []byte { var file_proxy_wireguard_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_proxy_wireguard_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_proxy_wireguard_config_proto_goTypes = []interface{}{ +var file_proxy_wireguard_config_proto_goTypes = []any{ (DeviceConfig_DomainStrategy)(0), // 0: xray.proxy.wireguard.DeviceConfig.DomainStrategy (*PeerConfig)(nil), // 1: xray.proxy.wireguard.PeerConfig (*DeviceConfig)(nil), // 2: xray.proxy.wireguard.DeviceConfig @@ -355,7 +355,7 @@ func file_proxy_wireguard_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_proxy_wireguard_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_proxy_wireguard_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*PeerConfig); i { case 0: return &v.state @@ -367,7 +367,7 @@ func file_proxy_wireguard_config_proto_init() { return nil } } - file_proxy_wireguard_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_proxy_wireguard_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*DeviceConfig); i { case 0: return &v.state diff --git a/transport/global/config.pb.go b/transport/global/config.pb.go index 7459ab6b..7b3abb99 100644 --- a/transport/global/config.pb.go +++ b/transport/global/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/global/config.proto @@ -109,7 +109,7 @@ func file_transport_global_config_proto_rawDescGZIP() []byte { } var file_transport_global_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_global_config_proto_goTypes = []interface{}{ +var file_transport_global_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.Config (*internet.TransportConfig)(nil), // 1: xray.transport.internet.TransportConfig } @@ -128,7 +128,7 @@ func file_transport_global_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_global_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_global_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index f0fe1ea5..6c71bcc3 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/config.proto @@ -863,7 +863,7 @@ func file_transport_internet_config_proto_rawDescGZIP() []byte { var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5) -var file_transport_internet_config_proto_goTypes = []interface{}{ +var file_transport_internet_config_proto_goTypes = []any{ (TransportProtocol)(0), // 0: xray.transport.internet.TransportProtocol (DomainStrategy)(0), // 1: xray.transport.internet.DomainStrategy (SocketConfig_TProxyMode)(0), // 2: xray.transport.internet.SocketConfig.TProxyMode @@ -897,7 +897,7 @@ func file_transport_internet_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*TransportConfig); i { case 0: return &v.state @@ -909,7 +909,7 @@ func file_transport_internet_config_proto_init() { return nil } } - file_transport_internet_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*StreamConfig); i { case 0: return &v.state @@ -921,7 +921,7 @@ func file_transport_internet_config_proto_init() { return nil } } - file_transport_internet_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ProxyConfig); i { case 0: return &v.state @@ -933,7 +933,7 @@ func file_transport_internet_config_proto_init() { return nil } } - file_transport_internet_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*CustomSockopt); i { case 0: return &v.state @@ -945,7 +945,7 @@ func file_transport_internet_config_proto_init() { return nil } } - file_transport_internet_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_config_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*SocketConfig); i { case 0: return &v.state diff --git a/transport/internet/domainsocket/config.pb.go b/transport/internet/domainsocket/config.pb.go index cc33be07..dc9f5371 100644 --- a/transport/internet/domainsocket/config.pb.go +++ b/transport/internet/domainsocket/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/domainsocket/config.proto @@ -129,7 +129,7 @@ func file_transport_internet_domainsocket_config_proto_rawDescGZIP() []byte { } var file_transport_internet_domainsocket_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_domainsocket_config_proto_goTypes = []interface{}{ +var file_transport_internet_domainsocket_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.domainsocket.Config } var file_transport_internet_domainsocket_config_proto_depIdxs = []int32{ @@ -146,7 +146,7 @@ func file_transport_internet_domainsocket_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_domainsocket_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_domainsocket_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/grpc/config.pb.go b/transport/internet/grpc/config.pb.go index a0996e57..b86858e3 100644 --- a/transport/internet/grpc/config.pb.go +++ b/transport/internet/grpc/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/grpc/config.proto @@ -170,7 +170,7 @@ func file_transport_internet_grpc_config_proto_rawDescGZIP() []byte { } var file_transport_internet_grpc_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_grpc_config_proto_goTypes = []interface{}{ +var file_transport_internet_grpc_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.grpc.encoding.Config } var file_transport_internet_grpc_config_proto_depIdxs = []int32{ @@ -187,7 +187,7 @@ func file_transport_internet_grpc_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_grpc_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_grpc_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/grpc/encoding/customSeviceName.go b/transport/internet/grpc/encoding/customSeviceName.go index dd990755..3b136fd3 100644 --- a/transport/internet/grpc/encoding/customSeviceName.go +++ b/transport/internet/grpc/encoding/customSeviceName.go @@ -34,7 +34,7 @@ func (c *gRPCServiceClient) TunCustomName(ctx context.Context, name, tun string, if err != nil { return nil, err } - x := &gRPCServiceTunClient{stream} + x := &grpc.GenericClientStream[Hunk, Hunk]{ClientStream: stream} return x, nil } @@ -43,7 +43,7 @@ func (c *gRPCServiceClient) TunMultiCustomName(ctx context.Context, name, tunMul if err != nil { return nil, err } - x := &gRPCServiceTunMultiClient{stream} + x := &grpc.GenericClientStream[MultiHunk, MultiHunk]{ClientStream: stream} return x, nil } diff --git a/transport/internet/grpc/encoding/stream.pb.go b/transport/internet/grpc/encoding/stream.pb.go index 519adb7e..3c872f9b 100644 --- a/transport/internet/grpc/encoding/stream.pb.go +++ b/transport/internet/grpc/encoding/stream.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/grpc/encoding/stream.proto @@ -161,7 +161,7 @@ func file_transport_internet_grpc_encoding_stream_proto_rawDescGZIP() []byte { } var file_transport_internet_grpc_encoding_stream_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_transport_internet_grpc_encoding_stream_proto_goTypes = []interface{}{ +var file_transport_internet_grpc_encoding_stream_proto_goTypes = []any{ (*Hunk)(nil), // 0: xray.transport.internet.grpc.encoding.Hunk (*MultiHunk)(nil), // 1: xray.transport.internet.grpc.encoding.MultiHunk } @@ -183,7 +183,7 @@ func file_transport_internet_grpc_encoding_stream_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_grpc_encoding_stream_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_grpc_encoding_stream_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Hunk); i { case 0: return &v.state @@ -195,7 +195,7 @@ func file_transport_internet_grpc_encoding_stream_proto_init() { return nil } } - file_transport_internet_grpc_encoding_stream_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_grpc_encoding_stream_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*MultiHunk); i { case 0: return &v.state diff --git a/transport/internet/grpc/encoding/stream_grpc.pb.go b/transport/internet/grpc/encoding/stream_grpc.pb.go index 5daf42a6..d96d7490 100644 --- a/transport/internet/grpc/encoding/stream_grpc.pb.go +++ b/transport/internet/grpc/encoding/stream_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.5.1 // - protoc v5.27.0 // source: transport/internet/grpc/encoding/stream.proto @@ -15,8 +15,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 const ( GRPCService_Tun_FullMethodName = "/xray.transport.internet.grpc.encoding.GRPCService/Tun" @@ -27,8 +27,8 @@ const ( // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type GRPCServiceClient interface { - Tun(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunClient, error) - TunMulti(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error) + Tun(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[Hunk, Hunk], error) + TunMulti(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[MultiHunk, MultiHunk], error) } type gRPCServiceClient struct { @@ -39,88 +39,56 @@ func NewGRPCServiceClient(cc grpc.ClientConnInterface) GRPCServiceClient { return &gRPCServiceClient{cc} } -func (c *gRPCServiceClient) Tun(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunClient, error) { - stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[0], GRPCService_Tun_FullMethodName, opts...) +func (c *gRPCServiceClient) Tun(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[Hunk, Hunk], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[0], GRPCService_Tun_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &gRPCServiceTunClient{stream} + x := &grpc.GenericClientStream[Hunk, Hunk]{ClientStream: stream} return x, nil } -type GRPCService_TunClient interface { - Send(*Hunk) error - Recv() (*Hunk, error) - grpc.ClientStream -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type GRPCService_TunClient = grpc.BidiStreamingClient[Hunk, Hunk] -type gRPCServiceTunClient struct { - grpc.ClientStream -} - -func (x *gRPCServiceTunClient) Send(m *Hunk) error { - return x.ClientStream.SendMsg(m) -} - -func (x *gRPCServiceTunClient) Recv() (*Hunk, error) { - m := new(Hunk) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *gRPCServiceClient) TunMulti(ctx context.Context, opts ...grpc.CallOption) (GRPCService_TunMultiClient, error) { - stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[1], GRPCService_TunMulti_FullMethodName, opts...) +func (c *gRPCServiceClient) TunMulti(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[MultiHunk, MultiHunk], error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + stream, err := c.cc.NewStream(ctx, &GRPCService_ServiceDesc.Streams[1], GRPCService_TunMulti_FullMethodName, cOpts...) if err != nil { return nil, err } - x := &gRPCServiceTunMultiClient{stream} + x := &grpc.GenericClientStream[MultiHunk, MultiHunk]{ClientStream: stream} return x, nil } -type GRPCService_TunMultiClient interface { - Send(*MultiHunk) error - Recv() (*MultiHunk, error) - grpc.ClientStream -} - -type gRPCServiceTunMultiClient struct { - grpc.ClientStream -} - -func (x *gRPCServiceTunMultiClient) Send(m *MultiHunk) error { - return x.ClientStream.SendMsg(m) -} - -func (x *gRPCServiceTunMultiClient) Recv() (*MultiHunk, error) { - m := new(MultiHunk) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type GRPCService_TunMultiClient = grpc.BidiStreamingClient[MultiHunk, MultiHunk] // GRPCServiceServer is the server API for GRPCService service. // All implementations must embed UnimplementedGRPCServiceServer -// for forward compatibility +// for forward compatibility. type GRPCServiceServer interface { - Tun(GRPCService_TunServer) error - TunMulti(GRPCService_TunMultiServer) error + Tun(grpc.BidiStreamingServer[Hunk, Hunk]) error + TunMulti(grpc.BidiStreamingServer[MultiHunk, MultiHunk]) error mustEmbedUnimplementedGRPCServiceServer() } -// UnimplementedGRPCServiceServer must be embedded to have forward compatible implementations. -type UnimplementedGRPCServiceServer struct { -} +// UnimplementedGRPCServiceServer must be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedGRPCServiceServer struct{} -func (UnimplementedGRPCServiceServer) Tun(GRPCService_TunServer) error { +func (UnimplementedGRPCServiceServer) Tun(grpc.BidiStreamingServer[Hunk, Hunk]) error { return status.Errorf(codes.Unimplemented, "method Tun not implemented") } -func (UnimplementedGRPCServiceServer) TunMulti(GRPCService_TunMultiServer) error { +func (UnimplementedGRPCServiceServer) TunMulti(grpc.BidiStreamingServer[MultiHunk, MultiHunk]) error { return status.Errorf(codes.Unimplemented, "method TunMulti not implemented") } func (UnimplementedGRPCServiceServer) mustEmbedUnimplementedGRPCServiceServer() {} +func (UnimplementedGRPCServiceServer) testEmbeddedByValue() {} // UnsafeGRPCServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to GRPCServiceServer will @@ -130,60 +98,29 @@ type UnsafeGRPCServiceServer interface { } func RegisterGRPCServiceServer(s grpc.ServiceRegistrar, srv GRPCServiceServer) { + // If the following call pancis, it indicates UnimplementedGRPCServiceServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } s.RegisterService(&GRPCService_ServiceDesc, srv) } func _GRPCService_Tun_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(GRPCServiceServer).Tun(&gRPCServiceTunServer{stream}) + return srv.(GRPCServiceServer).Tun(&grpc.GenericServerStream[Hunk, Hunk]{ServerStream: stream}) } -type GRPCService_TunServer interface { - Send(*Hunk) error - Recv() (*Hunk, error) - grpc.ServerStream -} - -type gRPCServiceTunServer struct { - grpc.ServerStream -} - -func (x *gRPCServiceTunServer) Send(m *Hunk) error { - return x.ServerStream.SendMsg(m) -} - -func (x *gRPCServiceTunServer) Recv() (*Hunk, error) { - m := new(Hunk) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type GRPCService_TunServer = grpc.BidiStreamingServer[Hunk, Hunk] func _GRPCService_TunMulti_Handler(srv interface{}, stream grpc.ServerStream) error { - return srv.(GRPCServiceServer).TunMulti(&gRPCServiceTunMultiServer{stream}) + return srv.(GRPCServiceServer).TunMulti(&grpc.GenericServerStream[MultiHunk, MultiHunk]{ServerStream: stream}) } -type GRPCService_TunMultiServer interface { - Send(*MultiHunk) error - Recv() (*MultiHunk, error) - grpc.ServerStream -} - -type gRPCServiceTunMultiServer struct { - grpc.ServerStream -} - -func (x *gRPCServiceTunMultiServer) Send(m *MultiHunk) error { - return x.ServerStream.SendMsg(m) -} - -func (x *gRPCServiceTunMultiServer) Recv() (*MultiHunk, error) { - m := new(MultiHunk) - if err := x.ServerStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} +// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. +type GRPCService_TunMultiServer = grpc.BidiStreamingServer[MultiHunk, MultiHunk] // GRPCService_ServiceDesc is the grpc.ServiceDesc for GRPCService service. // It's only intended for direct use with grpc.RegisterService, diff --git a/transport/internet/headers/dns/config.pb.go b/transport/internet/headers/dns/config.pb.go index 78e5e99b..137f7676 100644 --- a/transport/internet/headers/dns/config.pb.go +++ b/transport/internet/headers/dns/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/headers/dns/config.proto @@ -102,7 +102,7 @@ func file_transport_internet_headers_dns_config_proto_rawDescGZIP() []byte { } var file_transport_internet_headers_dns_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_headers_dns_config_proto_goTypes = []interface{}{ +var file_transport_internet_headers_dns_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.headers.dns.Config } var file_transport_internet_headers_dns_config_proto_depIdxs = []int32{ @@ -119,7 +119,7 @@ func file_transport_internet_headers_dns_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_dns_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_dns_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/headers/http/config.pb.go b/transport/internet/headers/http/config.pb.go index 73fa04c2..0dbaa753 100644 --- a/transport/internet/headers/http/config.pb.go +++ b/transport/internet/headers/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/headers/http/config.proto @@ -512,7 +512,7 @@ func file_transport_internet_headers_http_config_proto_rawDescGZIP() []byte { } var file_transport_internet_headers_http_config_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_transport_internet_headers_http_config_proto_goTypes = []interface{}{ +var file_transport_internet_headers_http_config_proto_goTypes = []any{ (*Header)(nil), // 0: xray.transport.internet.headers.http.Header (*Version)(nil), // 1: xray.transport.internet.headers.http.Version (*Method)(nil), // 2: xray.transport.internet.headers.http.Method @@ -543,7 +543,7 @@ func file_transport_internet_headers_http_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_http_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_http_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Header); i { case 0: return &v.state @@ -555,7 +555,7 @@ func file_transport_internet_headers_http_config_proto_init() { return nil } } - file_transport_internet_headers_http_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_http_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Version); i { case 0: return &v.state @@ -567,7 +567,7 @@ func file_transport_internet_headers_http_config_proto_init() { return nil } } - file_transport_internet_headers_http_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_http_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Method); i { case 0: return &v.state @@ -579,7 +579,7 @@ func file_transport_internet_headers_http_config_proto_init() { return nil } } - file_transport_internet_headers_http_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_http_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*RequestConfig); i { case 0: return &v.state @@ -591,7 +591,7 @@ func file_transport_internet_headers_http_config_proto_init() { return nil } } - file_transport_internet_headers_http_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_http_config_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Status); i { case 0: return &v.state @@ -603,7 +603,7 @@ func file_transport_internet_headers_http_config_proto_init() { return nil } } - file_transport_internet_headers_http_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_http_config_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*ResponseConfig); i { case 0: return &v.state @@ -615,7 +615,7 @@ func file_transport_internet_headers_http_config_proto_init() { return nil } } - file_transport_internet_headers_http_config_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_http_config_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/headers/noop/config.pb.go b/transport/internet/headers/noop/config.pb.go index 844c3f2b..e750b66e 100644 --- a/transport/internet/headers/noop/config.pb.go +++ b/transport/internet/headers/noop/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/headers/noop/config.proto @@ -131,7 +131,7 @@ func file_transport_internet_headers_noop_config_proto_rawDescGZIP() []byte { } var file_transport_internet_headers_noop_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_transport_internet_headers_noop_config_proto_goTypes = []interface{}{ +var file_transport_internet_headers_noop_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.headers.noop.Config (*ConnectionConfig)(nil), // 1: xray.transport.internet.headers.noop.ConnectionConfig } @@ -149,7 +149,7 @@ func file_transport_internet_headers_noop_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_noop_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_noop_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -161,7 +161,7 @@ func file_transport_internet_headers_noop_config_proto_init() { return nil } } - file_transport_internet_headers_noop_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_noop_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ConnectionConfig); i { case 0: return &v.state diff --git a/transport/internet/headers/srtp/config.pb.go b/transport/internet/headers/srtp/config.pb.go index f0bff8f4..5c77a15c 100644 --- a/transport/internet/headers/srtp/config.pb.go +++ b/transport/internet/headers/srtp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/headers/srtp/config.proto @@ -152,7 +152,7 @@ func file_transport_internet_headers_srtp_config_proto_rawDescGZIP() []byte { } var file_transport_internet_headers_srtp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_headers_srtp_config_proto_goTypes = []interface{}{ +var file_transport_internet_headers_srtp_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.headers.srtp.Config } var file_transport_internet_headers_srtp_config_proto_depIdxs = []int32{ @@ -169,7 +169,7 @@ func file_transport_internet_headers_srtp_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_srtp_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_srtp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/headers/tls/config.pb.go b/transport/internet/headers/tls/config.pb.go index 3c4786ce..f5564c4e 100644 --- a/transport/internet/headers/tls/config.pb.go +++ b/transport/internet/headers/tls/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/headers/tls/config.proto @@ -92,7 +92,7 @@ func file_transport_internet_headers_tls_config_proto_rawDescGZIP() []byte { } var file_transport_internet_headers_tls_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_headers_tls_config_proto_goTypes = []interface{}{ +var file_transport_internet_headers_tls_config_proto_goTypes = []any{ (*PacketConfig)(nil), // 0: xray.transport.internet.headers.tls.PacketConfig } var file_transport_internet_headers_tls_config_proto_depIdxs = []int32{ @@ -109,7 +109,7 @@ func file_transport_internet_headers_tls_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_tls_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_tls_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*PacketConfig); i { case 0: return &v.state diff --git a/transport/internet/headers/utp/config.pb.go b/transport/internet/headers/utp/config.pb.go index ed047880..913dc318 100644 --- a/transport/internet/headers/utp/config.pb.go +++ b/transport/internet/headers/utp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/headers/utp/config.proto @@ -102,7 +102,7 @@ func file_transport_internet_headers_utp_config_proto_rawDescGZIP() []byte { } var file_transport_internet_headers_utp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_headers_utp_config_proto_goTypes = []interface{}{ +var file_transport_internet_headers_utp_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.headers.utp.Config } var file_transport_internet_headers_utp_config_proto_depIdxs = []int32{ @@ -119,7 +119,7 @@ func file_transport_internet_headers_utp_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_utp_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_utp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/headers/wechat/config.pb.go b/transport/internet/headers/wechat/config.pb.go index 39611810..65384f4a 100644 --- a/transport/internet/headers/wechat/config.pb.go +++ b/transport/internet/headers/wechat/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/headers/wechat/config.proto @@ -93,7 +93,7 @@ func file_transport_internet_headers_wechat_config_proto_rawDescGZIP() []byte { } var file_transport_internet_headers_wechat_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_headers_wechat_config_proto_goTypes = []interface{}{ +var file_transport_internet_headers_wechat_config_proto_goTypes = []any{ (*VideoConfig)(nil), // 0: xray.transport.internet.headers.wechat.VideoConfig } var file_transport_internet_headers_wechat_config_proto_depIdxs = []int32{ @@ -110,7 +110,7 @@ func file_transport_internet_headers_wechat_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_wechat_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_wechat_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*VideoConfig); i { case 0: return &v.state diff --git a/transport/internet/headers/wireguard/config.pb.go b/transport/internet/headers/wireguard/config.pb.go index 2212c69e..ca459bfa 100644 --- a/transport/internet/headers/wireguard/config.pb.go +++ b/transport/internet/headers/wireguard/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/headers/wireguard/config.proto @@ -94,7 +94,7 @@ func file_transport_internet_headers_wireguard_config_proto_rawDescGZIP() []byte } var file_transport_internet_headers_wireguard_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_headers_wireguard_config_proto_goTypes = []interface{}{ +var file_transport_internet_headers_wireguard_config_proto_goTypes = []any{ (*WireguardConfig)(nil), // 0: xray.transport.internet.headers.wireguard.WireguardConfig } var file_transport_internet_headers_wireguard_config_proto_depIdxs = []int32{ @@ -111,7 +111,7 @@ func file_transport_internet_headers_wireguard_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_wireguard_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_headers_wireguard_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*WireguardConfig); i { case 0: return &v.state diff --git a/transport/internet/http/config.pb.go b/transport/internet/http/config.pb.go index d0f7e632..fcd4f77e 100644 --- a/transport/internet/http/config.pb.go +++ b/transport/internet/http/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/http/config.proto @@ -156,7 +156,7 @@ func file_transport_internet_http_config_proto_rawDescGZIP() []byte { } var file_transport_internet_http_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_http_config_proto_goTypes = []interface{}{ +var file_transport_internet_http_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.http.Config (*http.Header)(nil), // 1: xray.transport.internet.headers.http.Header } @@ -175,7 +175,7 @@ func file_transport_internet_http_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_http_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_http_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/httpupgrade/config.pb.go b/transport/internet/httpupgrade/config.pb.go index 9c0a4dee..be06ce79 100644 --- a/transport/internet/httpupgrade/config.pb.go +++ b/transport/internet/httpupgrade/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/httpupgrade/config.proto @@ -148,7 +148,7 @@ func file_transport_internet_httpupgrade_config_proto_rawDescGZIP() []byte { } var file_transport_internet_httpupgrade_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_transport_internet_httpupgrade_config_proto_goTypes = []interface{}{ +var file_transport_internet_httpupgrade_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.httpupgrade.Config nil, // 1: xray.transport.internet.httpupgrade.Config.HeaderEntry } @@ -167,7 +167,7 @@ func file_transport_internet_httpupgrade_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_httpupgrade_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_httpupgrade_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/kcp/config.pb.go b/transport/internet/kcp/config.pb.go index d4273da5..ff711185 100644 --- a/transport/internet/kcp/config.pb.go +++ b/transport/internet/kcp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/kcp/config.proto @@ -604,7 +604,7 @@ func file_transport_internet_kcp_config_proto_rawDescGZIP() []byte { } var file_transport_internet_kcp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 9) -var file_transport_internet_kcp_config_proto_goTypes = []interface{}{ +var file_transport_internet_kcp_config_proto_goTypes = []any{ (*MTU)(nil), // 0: xray.transport.internet.kcp.MTU (*TTI)(nil), // 1: xray.transport.internet.kcp.TTI (*UplinkCapacity)(nil), // 2: xray.transport.internet.kcp.UplinkCapacity @@ -638,7 +638,7 @@ func file_transport_internet_kcp_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_kcp_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_kcp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*MTU); i { case 0: return &v.state @@ -650,7 +650,7 @@ func file_transport_internet_kcp_config_proto_init() { return nil } } - file_transport_internet_kcp_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_kcp_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*TTI); i { case 0: return &v.state @@ -662,7 +662,7 @@ func file_transport_internet_kcp_config_proto_init() { return nil } } - file_transport_internet_kcp_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_kcp_config_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*UplinkCapacity); i { case 0: return &v.state @@ -674,7 +674,7 @@ func file_transport_internet_kcp_config_proto_init() { return nil } } - file_transport_internet_kcp_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_kcp_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*DownlinkCapacity); i { case 0: return &v.state @@ -686,7 +686,7 @@ func file_transport_internet_kcp_config_proto_init() { return nil } } - file_transport_internet_kcp_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_kcp_config_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*WriteBuffer); i { case 0: return &v.state @@ -698,7 +698,7 @@ func file_transport_internet_kcp_config_proto_init() { return nil } } - file_transport_internet_kcp_config_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_kcp_config_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*ReadBuffer); i { case 0: return &v.state @@ -710,7 +710,7 @@ func file_transport_internet_kcp_config_proto_init() { return nil } } - file_transport_internet_kcp_config_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_kcp_config_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*ConnectionReuse); i { case 0: return &v.state @@ -722,7 +722,7 @@ func file_transport_internet_kcp_config_proto_init() { return nil } } - file_transport_internet_kcp_config_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_kcp_config_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*EncryptionSeed); i { case 0: return &v.state @@ -734,7 +734,7 @@ func file_transport_internet_kcp_config_proto_init() { return nil } } - file_transport_internet_kcp_config_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_kcp_config_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/quic/config.pb.go b/transport/internet/quic/config.pb.go index 0a387a10..992cbdf2 100644 --- a/transport/internet/quic/config.pb.go +++ b/transport/internet/quic/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/quic/config.proto @@ -129,7 +129,7 @@ func file_transport_internet_quic_config_proto_rawDescGZIP() []byte { } var file_transport_internet_quic_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_quic_config_proto_goTypes = []interface{}{ +var file_transport_internet_quic_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.quic.Config (*protocol.SecurityConfig)(nil), // 1: xray.common.protocol.SecurityConfig (*serial.TypedMessage)(nil), // 2: xray.common.serial.TypedMessage @@ -150,7 +150,7 @@ func file_transport_internet_quic_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_quic_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_quic_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/reality/config.pb.go b/transport/internet/reality/config.pb.go index 99dec214..06d314d4 100644 --- a/transport/internet/reality/config.pb.go +++ b/transport/internet/reality/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/reality/config.proto @@ -259,7 +259,7 @@ func file_transport_internet_reality_config_proto_rawDescGZIP() []byte { } var file_transport_internet_reality_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_reality_config_proto_goTypes = []interface{}{ +var file_transport_internet_reality_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.reality.Config } var file_transport_internet_reality_config_proto_depIdxs = []int32{ @@ -276,7 +276,7 @@ func file_transport_internet_reality_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_reality_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_reality_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 26dbb0b7..24768490 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/splithttp/config.proto @@ -185,7 +185,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xec, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xea, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, @@ -215,29 +215,29 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x5a, 0x0a, 0x0e, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, - 0x6e, 0x67, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, - 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x0e, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, - 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, - 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x02, 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, - 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, + 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, + 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x52, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, + 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, + 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, + 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, + 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, + 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, + 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, + 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, + 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, + 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -253,7 +253,7 @@ func file_transport_internet_splithttp_config_proto_rawDescGZIP() []byte { } var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_transport_internet_splithttp_config_proto_goTypes = []interface{}{ +var file_transport_internet_splithttp_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.splithttp.Config (*RandRangeConfig)(nil), // 1: xray.transport.internet.splithttp.RandRangeConfig nil, // 2: xray.transport.internet.splithttp.Config.HeaderEntry @@ -277,7 +277,7 @@ func file_transport_internet_splithttp_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_splithttp_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_splithttp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -289,7 +289,7 @@ func file_transport_internet_splithttp_config_proto_init() { return nil } } - file_transport_internet_splithttp_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_splithttp_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*RandRangeConfig); i { case 0: return &v.state diff --git a/transport/internet/tcp/config.pb.go b/transport/internet/tcp/config.pb.go index e06c481b..df7d3ad1 100644 --- a/transport/internet/tcp/config.pb.go +++ b/transport/internet/tcp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/tcp/config.proto @@ -118,7 +118,7 @@ func file_transport_internet_tcp_config_proto_rawDescGZIP() []byte { } var file_transport_internet_tcp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_tcp_config_proto_goTypes = []interface{}{ +var file_transport_internet_tcp_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.tcp.Config (*serial.TypedMessage)(nil), // 1: xray.common.serial.TypedMessage } @@ -137,7 +137,7 @@ func file_transport_internet_tcp_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_tcp_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_tcp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index 3ba1893d..c141c375 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/tls/config.proto @@ -463,7 +463,7 @@ func file_transport_internet_tls_config_proto_rawDescGZIP() []byte { var file_transport_internet_tls_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_transport_internet_tls_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_transport_internet_tls_config_proto_goTypes = []interface{}{ +var file_transport_internet_tls_config_proto_goTypes = []any{ (Certificate_Usage)(0), // 0: xray.transport.internet.tls.Certificate.Usage (*Certificate)(nil), // 1: xray.transport.internet.tls.Certificate (*Config)(nil), // 2: xray.transport.internet.tls.Config @@ -484,7 +484,7 @@ func file_transport_internet_tls_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_tls_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_tls_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Certificate); i { case 0: return &v.state @@ -496,7 +496,7 @@ func file_transport_internet_tls_config_proto_init() { return nil } } - file_transport_internet_tls_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_tls_config_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/udp/config.pb.go b/transport/internet/udp/config.pb.go index 760e230c..12c10070 100644 --- a/transport/internet/udp/config.pb.go +++ b/transport/internet/udp/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/udp/config.proto @@ -89,7 +89,7 @@ func file_transport_internet_udp_config_proto_rawDescGZIP() []byte { } var file_transport_internet_udp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_udp_config_proto_goTypes = []interface{}{ +var file_transport_internet_udp_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.udp.Config } var file_transport_internet_udp_config_proto_depIdxs = []int32{ @@ -106,7 +106,7 @@ func file_transport_internet_udp_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_udp_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_udp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state diff --git a/transport/internet/websocket/config.pb.go b/transport/internet/websocket/config.pb.go index 9631e7e9..3b1103f7 100644 --- a/transport/internet/websocket/config.pb.go +++ b/transport/internet/websocket/config.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.1 +// protoc-gen-go v1.34.2 // protoc v5.27.0 // source: transport/internet/websocket/config.proto @@ -147,7 +147,7 @@ func file_transport_internet_websocket_config_proto_rawDescGZIP() []byte { } var file_transport_internet_websocket_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_transport_internet_websocket_config_proto_goTypes = []interface{}{ +var file_transport_internet_websocket_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.websocket.Config nil, // 1: xray.transport.internet.websocket.Config.HeaderEntry } @@ -166,7 +166,7 @@ func file_transport_internet_websocket_config_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_transport_internet_websocket_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_transport_internet_websocket_config_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state From 83eef6bc1f554be84aeb799417688a070cd32ab8 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:07:57 +0200 Subject: [PATCH 500/867] SplitHTTP: Fix connection leaks and crashes (#3710) --- transport/internet/splithttp/client.go | 41 ++++++++++++---- transport/internet/splithttp/dialer.go | 34 +------------ transport/internet/splithttp/hub.go | 6 ++- transport/internet/splithttp/lazy_reader.go | 26 +++------- .../internet/splithttp/splithttp_test.go | 13 ++++- .../internet/splithttp/strip_ok_reader.go | 48 +++++++++++++++++++ transport/internet/splithttp/upload_queue.go | 6 ++- 7 files changed, 109 insertions(+), 65 deletions(-) create mode 100644 transport/internet/splithttp/strip_ok_reader.go diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index f9b7cba1..e491ef3e 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -49,6 +49,8 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) var downResponse io.ReadCloser gotDownResponse := done.New() + ctx, ctxCancel := context.WithCancel(ctx) + go func() { trace := &httptrace.ClientTrace{ GotConn: func(connInfo httptrace.GotConnInfo) { @@ -61,8 +63,10 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) // in case we hit an error, we want to unblock this part defer gotConn.Close() + ctx = httptrace.WithClientTrace(ctx, trace) + req, err := http.NewRequestWithContext( - httptrace.WithClientTrace(ctx, trace), + ctx, "GET", baseURL, nil, @@ -94,16 +98,17 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) gotDownResponse.Close() }() - if c.isH3 { - gotConn.Close() + if !c.isH3 { + // in quic-go, sometimes gotConn is never closed for the lifetime of + // the entire connection, and the download locks up + // https://github.com/quic-go/quic-go/issues/3342 + // for other HTTP versions, we want to block Dial until we know the + // remote address of the server, for logging purposes + <-gotConn.Wait() } - // we want to block Dial until we know the remote address of the server, - // for logging purposes - <-gotConn.Wait() - lazyDownload := &LazyReader{ - CreateReader: func() (io.ReadCloser, error) { + CreateReader: func() (io.Reader, error) { <-gotDownResponse.Wait() if downResponse == nil { return nil, errors.New("downResponse failed") @@ -112,7 +117,15 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) }, } - return lazyDownload, remoteAddr, localAddr, nil + // workaround for https://github.com/quic-go/quic-go/issues/2143 -- + // always cancel request context so that Close cancels any Read. + // Should then match the behavior of http2 and http1. + reader := downloadBody{ + lazyDownload, + ctxCancel, + } + + return reader, remoteAddr, localAddr, nil } func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, payload io.ReadWriteCloser, contentLength int64) error { @@ -172,3 +185,13 @@ func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, return nil } + +type downloadBody struct { + io.Reader + cancel context.CancelFunc +} + +func (c downloadBody) Close() error { + c.cancel() + return nil +} diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index a95ab34b..35e8c7b4 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -1,10 +1,8 @@ package splithttp import ( - "bytes" "context" gotls "crypto/tls" - "io" "net/http" "net/url" "strconv" @@ -292,35 +290,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me return nil, err } - lazyDownload := &LazyReader{ - CreateReader: func() (io.ReadCloser, error) { - // skip "ok" response - trashHeader := []byte{0, 0} - _, err := io.ReadFull(lazyRawDownload, trashHeader) - if err != nil { - return nil, errors.New("failed to read initial response").Base(err) - } - - if bytes.Equal(trashHeader, []byte("ok")) { - return lazyRawDownload, nil - } - - // we read some garbage byte that may not have been "ok" at - // all. return a reader that replays what we have read so far - reader := io.MultiReader( - bytes.NewReader(trashHeader), - lazyRawDownload, - ) - readCloser := struct { - io.Reader - io.Closer - }{ - Reader: reader, - Closer: lazyRawDownload, - } - return readCloser, nil - }, - } + reader := &stripOkReader{ReadCloser: lazyRawDownload} writer := uploadWriter{ uploadPipeWriter, @@ -329,7 +299,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me conn := splitConn{ writer: writer, - reader: lazyDownload, + reader: reader, remoteAddr: remoteAddr, localAddr: localAddr, } diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 9fdd15b4..4a05e1c3 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -222,8 +222,12 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req h.ln.addConn(stat.Connection(&conn)) // "A ResponseWriter may not be used after [Handler.ServeHTTP] has returned." - <-downloadDone.Wait() + select { + case <-request.Context().Done(): + case <-downloadDone.Wait(): + } + conn.Close() } else { writer.WriteHeader(http.StatusMethodNotAllowed) } diff --git a/transport/internet/splithttp/lazy_reader.go b/transport/internet/splithttp/lazy_reader.go index 8641cbac..35d1f436 100644 --- a/transport/internet/splithttp/lazy_reader.go +++ b/transport/internet/splithttp/lazy_reader.go @@ -3,18 +3,20 @@ package splithttp import ( "io" "sync" - - "github.com/xtls/xray-core/common/errors" ) +// Close is intentionally not supported by LazyReader because it's not clear +// how CreateReader should be aborted in case of Close. It's best to wrap +// LazyReader in another struct that handles Close correctly, or better, stop +// using LazyReader entirely. type LazyReader struct { readerSync sync.Mutex - CreateReader func() (io.ReadCloser, error) - reader io.ReadCloser + CreateReader func() (io.Reader, error) + reader io.Reader readerError error } -func (r *LazyReader) getReader() (io.ReadCloser, error) { +func (r *LazyReader) getReader() (io.Reader, error) { r.readerSync.Lock() defer r.readerSync.Unlock() if r.reader != nil { @@ -43,17 +45,3 @@ func (r *LazyReader) Read(b []byte) (int, error) { n, err := reader.Read(b) return n, err } - -func (r *LazyReader) Close() error { - r.readerSync.Lock() - defer r.readerSync.Unlock() - - var err error - if r.reader != nil { - err = r.reader.Close() - r.reader = nil - r.readerError = errors.New("closed reader") - } - - return err -} diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index 30f92c7f..b01727e0 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -248,6 +248,8 @@ func Test_listenSHAndDial_QUIC(t *testing.T) { NextProtocol: []string{"h3"}, }, } + + serverClosed := false listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { go func() { defer conn.Close() @@ -258,10 +260,12 @@ func Test_listenSHAndDial_QUIC(t *testing.T) { for { b.Clear() if _, err := b.ReadFrom(conn); err != nil { - return + break } common.Must2(conn.Write(b.Bytes())) } + + serverClosed = true }() }) common.Must(err) @@ -271,7 +275,6 @@ func Test_listenSHAndDial_QUIC(t *testing.T) { conn, err := Dial(context.Background(), net.UDPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) common.Must(err) - defer conn.Close() const N = 1024 b1 := make([]byte, N) @@ -294,6 +297,12 @@ func Test_listenSHAndDial_QUIC(t *testing.T) { t.Error(r) } + conn.Close() + time.Sleep(100 * time.Millisecond) + if !serverClosed { + t.Error("server did not get closed") + } + end := time.Now() if !end.Before(start.Add(time.Second * 5)) { t.Error("end: ", end, " start: ", start) diff --git a/transport/internet/splithttp/strip_ok_reader.go b/transport/internet/splithttp/strip_ok_reader.go new file mode 100644 index 00000000..5dbbe22b --- /dev/null +++ b/transport/internet/splithttp/strip_ok_reader.go @@ -0,0 +1,48 @@ +package splithttp + +import ( + "bytes" + "io" + + "github.com/xtls/xray-core/common/errors" +) + +// in older versions of splithttp, the server would respond with `ok` to flush +// out HTTP response headers early. Response headers and a 200 OK were required +// to initiate the connection. Later versions of splithttp dropped this +// requirement, and in xray 1.8.24 the server stopped sending "ok" if it sees +// x_padding. For compatibility, we need to remove "ok" from the underlying +// reader if it exists, and otherwise forward the stream as-is. +type stripOkReader struct { + io.ReadCloser + firstDone bool + prefixRead []byte +} + +func (r *stripOkReader) Read(b []byte) (int, error) { + if !r.firstDone { + r.firstDone = true + + // skip "ok" response + prefixRead := []byte{0, 0} + _, err := io.ReadFull(r.ReadCloser, prefixRead) + if err != nil { + return 0, errors.New("failed to read initial response").Base(err) + } + + if !bytes.Equal(prefixRead, []byte("ok")) { + // we read some garbage byte that may not have been "ok" at + // all. return a reader that replays what we have read so far + r.prefixRead = prefixRead + } + } + + if len(r.prefixRead) > 0 { + n := copy(b, r.prefixRead) + r.prefixRead = r.prefixRead[n:] + return n, nil + } + + n, err := r.ReadCloser.Read(b) + return n, err +} diff --git a/transport/internet/splithttp/upload_queue.go b/transport/internet/splithttp/upload_queue.go index 23124c4f..9ac38f8b 100644 --- a/transport/internet/splithttp/upload_queue.go +++ b/transport/internet/splithttp/upload_queue.go @@ -51,8 +51,10 @@ func (h *uploadQueue) Close() error { h.writeCloseMutex.Lock() defer h.writeCloseMutex.Unlock() - h.closed = true - close(h.pushedPackets) + if !h.closed { + h.closed = true + close(h.pushedPackets) + } return nil } From 34e0a2fb414615e3c89e74ac3eb3fafd1cb4f793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 23 Aug 2024 06:48:25 +0000 Subject: [PATCH 501/867] Issues template: Add require for latest version --- .github/ISSUE_TEMPLATE/bug_report.yml | 12 +++++------- .github/ISSUE_TEMPLATE/bug_report_zh.yml | 14 ++++++-------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 9efeede7..32f58b19 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -13,16 +13,14 @@ body: required: true - label: I searched issues and did not find any similar issues. required: true - - type: input - attributes: - label: Version - description: Version of Xray-core - validations: - required: true + - label: The problem can be successfully reproduced in the latest Release + required: true - type: textarea attributes: label: Description - description: Please provide a detailed description of the error. And the information you think valuable. + description: |- + Please provide a detailed description of the error. And the information you think valuable. + If the problem occurs after the update, please provide the **specific** version validations: required: true - type: textarea diff --git a/.github/ISSUE_TEMPLATE/bug_report_zh.yml b/.github/ISSUE_TEMPLATE/bug_report_zh.yml index 2fd33c56..201f847e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_zh.yml +++ b/.github/ISSUE_TEMPLATE/bug_report_zh.yml @@ -11,18 +11,16 @@ body: required: true - label: 我提供了完整的配置文件和日志,而不是出于自己的判断只给出截取的部分。 required: true - - label: 我搜索了issues,没有发现已提出的类似问题。 + - label: 我搜索了 issues, 没有发现已提出的类似问题。 + required: true + - label: 问题在 Release 最新的版本上可以成功复现 required: true - - type: input - attributes: - label: 版本 - description: 使用的Xray-core版本 - validations: - required: true - type: textarea attributes: label: 描述 - description: 请提供错误的详细描述。以及你认为有价值的信息。 + description: |- + 请提供错误的详细描述。以及你认为有价值的信息。 + 如果问题在更新后出现,请提供**具体**出现问题的版本号。 validations: required: true - type: textarea From c0c23fdfeb9ea813482a110a32f5203371499512 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 08:41:35 +0000 Subject: [PATCH 502/867] Bump github.com/vishvananda/netlink (#3719) Bumps [github.com/vishvananda/netlink](https://github.com/vishvananda/netlink) from 1.2.1-beta.2.0.20230316163032-ced5aaba43e3 to 1.2.1. - [Release notes](https://github.com/vishvananda/netlink/releases) - [Commits](https://github.com/vishvananda/netlink/commits/v1.2.1) --- updated-dependencies: - dependency-name: github.com/vishvananda/netlink dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 20876387..874d26d3 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 github.com/stretchr/testify v1.9.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e - github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 + github.com/vishvananda/netlink v1.2.1 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.26.0 diff --git a/go.sum b/go.sum index 2960e875..2942ecb8 100644 --- a/go.sum +++ b/go.sum @@ -160,9 +160,8 @@ github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3 h1:tkMT5pTye+1NlKIXETU78NXw0fyjnaNHmJyyLyzw8+U= -github.com/vishvananda/netlink v1.2.1-beta.2.0.20230316163032-ced5aaba43e3/go.mod h1:cAAsePK2e15YDAMJNyOpGYEWNe4sIghTY7gpz4cX/Ik= -github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= +github.com/vishvananda/netlink v1.2.1 h1:pfLv/qlJUwOTPvtWREA7c3PI4u81YkqZw1DYhI2HmLA= +github.com/vishvananda/netlink v1.2.1/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= @@ -222,12 +221,12 @@ golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220804214406-8e32c043e418/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= From 3dd3bf94d4e2519eb549803c3be08fe9368b715c Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 25 Aug 2024 21:02:01 +0200 Subject: [PATCH 503/867] Fix data leak between mux.cool connections (#3718) Fix #116 --- common/mux/server.go | 5 +- common/mux/server_test.go | 124 ++++++++++++++++++++++++++++++++++++++ common/session/context.go | 16 +++++ 3 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 common/mux/server_test.go diff --git a/common/mux/server.go b/common/mux/server.go index 5a4e9974..480175ba 100644 --- a/common/mux/server.go +++ b/common/mux/server.go @@ -118,6 +118,9 @@ func (w *ServerWorker) handleStatusKeepAlive(meta *FrameMetadata, reader *buf.Bu } func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, reader *buf.BufferedReader) error { + // deep-clone outbounds because it is going to be mutated concurrently + // (Target and OriginalTarget) + ctx = session.ContextCloneOutbounds(ctx) errors.LogInfo(ctx, "received request for ", meta.Target) { msg := &log.AccessMessage{ @@ -170,7 +173,7 @@ func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, b.Release() mb = nil } - errors.LogInfoInner(ctx, err,"XUDP hit ", meta.GlobalID) + errors.LogInfoInner(ctx, err, "XUDP hit ", meta.GlobalID) } if mb != nil { ctx = session.ContextWithTimeoutOnly(ctx, true) diff --git a/common/mux/server_test.go b/common/mux/server_test.go new file mode 100644 index 00000000..4158bf46 --- /dev/null +++ b/common/mux/server_test.go @@ -0,0 +1,124 @@ +package mux_test + +import ( + "context" + "testing" + + "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/mux" + "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/session" + "github.com/xtls/xray-core/features/routing" + "github.com/xtls/xray-core/transport" + "github.com/xtls/xray-core/transport/pipe" +) + +func newLinkPair() (*transport.Link, *transport.Link) { + opt := pipe.WithoutSizeLimit() + uplinkReader, uplinkWriter := pipe.New(opt) + downlinkReader, downlinkWriter := pipe.New(opt) + + uplink := &transport.Link{ + Reader: uplinkReader, + Writer: downlinkWriter, + } + + downlink := &transport.Link{ + Reader: downlinkReader, + Writer: uplinkWriter, + } + + return uplink, downlink +} + +type TestDispatcher struct { + OnDispatch func(ctx context.Context, dest net.Destination) (*transport.Link, error) +} + +func (d *TestDispatcher) Dispatch(ctx context.Context, dest net.Destination) (*transport.Link, error) { + return d.OnDispatch(ctx, dest) +} + +func (d *TestDispatcher) DispatchLink(ctx context.Context, destination net.Destination, outbound *transport.Link) error { + return nil +} + +func (d *TestDispatcher) Start() error { + return nil +} + +func (d *TestDispatcher) Close() error { + return nil +} + +func (*TestDispatcher) Type() interface{} { + return routing.DispatcherType() +} + +func TestRegressionOutboundLeak(t *testing.T) { + originalOutbounds := []*session.Outbound{{}} + serverCtx := session.ContextWithOutbounds(context.Background(), originalOutbounds) + + websiteUplink, websiteDownlink := newLinkPair() + + dispatcher := TestDispatcher{ + OnDispatch: func(ctx context.Context, dest net.Destination) (*transport.Link, error) { + // emulate what DefaultRouter.Dispatch does, and mutate something on the context + ob := session.OutboundsFromContext(ctx)[0] + ob.Target = dest + return websiteDownlink, nil + }, + } + + muxServerUplink, muxServerDownlink := newLinkPair() + _, err := mux.NewServerWorker(serverCtx, &dispatcher, muxServerUplink) + common.Must(err) + + client, err := mux.NewClientWorker(*muxServerDownlink, mux.ClientStrategy{}) + common.Must(err) + + clientCtx := session.ContextWithOutbounds(context.Background(), []*session.Outbound{{ + Target: net.TCPDestination(net.DomainAddress("www.example.com"), 80), + }}) + + muxClientUplink, muxClientDownlink := newLinkPair() + + ok := client.Dispatch(clientCtx, muxClientUplink) + if !ok { + t.Error("failed to dispatch") + } + + { + b := buf.FromBytes([]byte("hello")) + common.Must(muxClientDownlink.Writer.WriteMultiBuffer(buf.MultiBuffer{b})) + } + + resMb, err := websiteUplink.Reader.ReadMultiBuffer() + common.Must(err) + res := resMb.String() + if res != "hello" { + t.Error("upload: ", res) + } + + { + b := buf.FromBytes([]byte("world")) + common.Must(websiteUplink.Writer.WriteMultiBuffer(buf.MultiBuffer{b})) + } + + resMb, err = muxClientDownlink.Reader.ReadMultiBuffer() + common.Must(err) + res = resMb.String() + if res != "world" { + t.Error("download: ", res) + } + + outbounds := session.OutboundsFromContext(serverCtx) + if outbounds[0] != originalOutbounds[0] { + t.Error("outbound got reassigned: ", outbounds[0]) + } + + if outbounds[0].Target.Address != nil { + t.Error("outbound target got leaked: ", outbounds[0].Target.String()) + } +} diff --git a/common/session/context.go b/common/session/context.go index 3fed0151..b7af69cc 100644 --- a/common/session/context.go +++ b/common/session/context.go @@ -40,6 +40,22 @@ func ContextWithOutbounds(ctx context.Context, outbounds []*Outbound) context.Co return context.WithValue(ctx, outboundSessionKey, outbounds) } +func ContextCloneOutbounds(ctx context.Context) context.Context { + outbounds := OutboundsFromContext(ctx) + newOutbounds := make([]*Outbound, len(outbounds)) + for i, ob := range outbounds { + if ob == nil { + continue + } + + // copy outbound by value + v := *ob + newOutbounds[i] = &v + } + + return ContextWithOutbounds(ctx, newOutbounds) +} + func OutboundsFromContext(ctx context.Context) []*Outbound { if outbounds, ok := ctx.Value(outboundSessionKey).([]*Outbound); ok { return outbounds From 5d7dfbbcacfd588349e500a8d619e0765f467f86 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 25 Aug 2024 22:07:31 -0400 Subject: [PATCH 504/867] Bump github.com/vishvananda/netlink from 1.2.1 to 1.3.0 (#3729) Bumps [github.com/vishvananda/netlink](https://github.com/vishvananda/netlink) from 1.2.1 to 1.3.0. - [Release notes](https://github.com/vishvananda/netlink/releases) - [Commits](https://github.com/vishvananda/netlink/compare/v1.2.1...v1.3.0) --- updated-dependencies: - dependency-name: github.com/vishvananda/netlink dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 874d26d3..b234a137 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 github.com/stretchr/testify v1.9.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e - github.com/vishvananda/netlink v1.2.1 + github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.26.0 diff --git a/go.sum b/go.sum index 2942ecb8..1847c4b9 100644 --- a/go.sum +++ b/go.sum @@ -160,8 +160,8 @@ github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= -github.com/vishvananda/netlink v1.2.1 h1:pfLv/qlJUwOTPvtWREA7c3PI4u81YkqZw1DYhI2HmLA= -github.com/vishvananda/netlink v1.2.1/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= +github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQdrZk= +github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= From 592c2daf58f3b7a41edb3feb664e77ebaa1d2da4 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 25 Aug 2024 22:30:38 -0400 Subject: [PATCH 505/867] Update go 1.23 (#3730) --- .github/workflows/release.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d044a5c1..77e668b4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -187,7 +187,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: ${{ matrix.gotoolchain || '1.22' }} + go-version: ${{ matrix.gotoolchain || '1.23' }} check-latest: true - name: Get project dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b2d91b09..1e531d52 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.22' + go-version: '1.23' check-latest: true - name: Restore Cache uses: actions/cache/restore@v4 From 1cfed96aba9d8e8c855d79b6ef23f61f7a19db9b Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 26 Aug 2024 02:33:03 +0000 Subject: [PATCH 506/867] README.md: Add Project VLESS to Telegram --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 026d1491..9485f944 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ [Project X Channel](https://t.me/projectXtls) +[Project VLESS](https://t.me/projectVless) (non-Chinese) + ## Installation - Linux Script From 815a959c9625f5fcb6e7568558a52c2b0f3ee85f Mon Sep 17 00:00:00 2001 From: dyhkwong <50692134+dyhkwong@users.noreply.github.com> Date: Tue, 27 Aug 2024 22:17:55 +0800 Subject: [PATCH 507/867] Fix freedom PacketReader/PacketWriter type assertion (#3734) --- proxy/freedom/freedom.go | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 6abcc553..feee98c0 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -276,24 +276,24 @@ func NewPacketReader(conn net.Conn, UDPOverride net.Destination) buf.Reader { if statConn != nil { counter = statConn.ReadCounter } - if c, ok := iConn.(*internet.PacketConnWrapper); ok && UDPOverride.Address == nil && UDPOverride.Port == 0 { + if c, ok := iConn.(net.PacketConn); ok && UDPOverride.Address == nil && UDPOverride.Port == 0 { return &PacketReader{ - PacketConnWrapper: c, - Counter: counter, + PacketConn: c, + Counter: counter, } } return &buf.PacketReader{Reader: conn} } type PacketReader struct { - *internet.PacketConnWrapper + net.PacketConn stats.Counter } func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) { b := buf.New() b.Resize(0, buf.Size) - n, d, err := r.PacketConnWrapper.ReadFrom(b.Bytes()) + n, d, err := r.PacketConn.ReadFrom(b.Bytes()) if err != nil { b.Release() return nil, err @@ -320,24 +320,26 @@ func NewPacketWriter(conn net.Conn, h *Handler, ctx context.Context, UDPOverride if statConn != nil { counter = statConn.WriteCounter } - if c, ok := iConn.(*internet.PacketConnWrapper); ok { + if c, ok := iConn.(net.PacketConn); ok { return &PacketWriter{ - PacketConnWrapper: c, - Counter: counter, - Handler: h, - Context: ctx, - UDPOverride: UDPOverride, + PacketConn: c, + Counter: counter, + Handler: h, + Context: ctx, + UDPOverride: UDPOverride, + Conn: iConn, } } return &buf.SequentialWriter{Writer: conn} } type PacketWriter struct { - *internet.PacketConnWrapper + net.PacketConn stats.Counter *Handler context.Context UDPOverride net.Destination + Conn net.Conn } func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { @@ -367,9 +369,9 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { b.Release() continue } - n, err = w.PacketConnWrapper.WriteTo(b.Bytes(), destAddr) + n, err = w.PacketConn.WriteTo(b.Bytes(), destAddr) } else { - n, err = w.PacketConnWrapper.Write(b.Bytes()) + n, err = w.Conn.Write(b.Bytes()) } b.Release() if err != nil { From 8674ed5a0db0627d0f55803ebc685397a1847bb9 Mon Sep 17 00:00:00 2001 From: xiaorouji Date: Tue, 27 Aug 2024 22:19:33 +0800 Subject: [PATCH 508/867] Support DNS queryStrategy config for UDP NameServer (#3728) --- app/dns/nameserver.go | 2 +- app/dns/nameserver_udp.go | 34 ++++++++++++++++++++-------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index 8dfa9dc2..cf79103f 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -62,7 +62,7 @@ func NewServer(dest net.Destination, dispatcher routing.Dispatcher, queryStrateg dest.Network = net.Network_UDP } if dest.Network == net.Network_UDP { // UDP classic DNS mode - return NewClassicNameServer(dest, dispatcher), nil + return NewClassicNameServer(dest, dispatcher, queryStrategy), nil } return nil, errors.New("No available name server could be created from ", dest).AtWarning() } diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index 67e1d73a..24a99593 100644 --- a/app/dns/nameserver_udp.go +++ b/app/dns/nameserver_udp.go @@ -24,29 +24,31 @@ import ( // ClassicNameServer implemented traditional UDP DNS. type ClassicNameServer struct { sync.RWMutex - name string - address *net.Destination - ips map[string]*record - requests map[uint16]*dnsRequest - pub *pubsub.Service - udpServer *udp.Dispatcher - cleanup *task.Periodic - reqID uint32 + name string + address *net.Destination + ips map[string]*record + requests map[uint16]*dnsRequest + pub *pubsub.Service + udpServer *udp.Dispatcher + cleanup *task.Periodic + reqID uint32 + queryStrategy QueryStrategy } // NewClassicNameServer creates udp server object for remote resolving. -func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher) *ClassicNameServer { +func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) *ClassicNameServer { // default to 53 if unspecific if address.Port == 0 { address.Port = net.Port(53) } s := &ClassicNameServer{ - address: &address, - ips: make(map[string]*record), - requests: make(map[uint16]*dnsRequest), - pub: pubsub.NewService(), - name: strings.ToUpper(address.String()), + address: &address, + ips: make(map[string]*record), + requests: make(map[uint16]*dnsRequest), + pub: pubsub.NewService(), + name: strings.ToUpper(address.String()), + queryStrategy: queryStrategy, } s.cleanup = &task.Periodic{ Interval: time.Minute, @@ -239,6 +241,10 @@ func (s *ClassicNameServer) findIPsForDomain(domain string, option dns_feature.I // QueryIP implements Server. func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, error) { fqdn := Fqdn(domain) + option = ResolveIpOptionOverride(s.queryStrategy, option) + if !option.IPv4Enable && !option.IPv6Enable { + return nil, dns_feature.ErrEmptyResponse + } if disableCache { errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) From 002d08bf834ed6abfb402a040300bd17f2f3b21b Mon Sep 17 00:00:00 2001 From: dragonbreath2000 <168475359+dragonbreath2000@users.noreply.github.com> Date: Wed, 28 Aug 2024 14:10:11 -0700 Subject: [PATCH 509/867] UDP noise (#3711) * added udp noise * adding protobuf settings * freedom json parser and clean up * resolve confict * fix and clean up * use net.conn instead of packetconnwrapper * avoid constructing SequentialWriter directly --------- Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> --- infra/conf/freedom.go | 76 +++++++++++++++ proxy/freedom/config.pb.go | 188 +++++++++++++++++++++++++++++-------- proxy/freedom/config.proto | 8 ++ proxy/freedom/freedom.go | 60 ++++++++++++ 4 files changed, 295 insertions(+), 37 deletions(-) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index d90b7c2d..e172afa8 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -18,6 +18,7 @@ type FreedomConfig struct { Redirect string `json:"redirect"` UserLevel uint32 `json:"userLevel"` Fragment *Fragment `json:"fragment"` + Noise *Noise `json:"noise"` ProxyProtocol uint32 `json:"proxyProtocol"` } @@ -27,6 +28,11 @@ type Fragment struct { Interval string `json:"interval"` } +type Noise struct { + Packet string `json:"packet"` + Delay string `json:"delay"` +} + // Build implements Buildable func (c *FreedomConfig) Build() (proto.Message, error) { config := new(freedom.Config) @@ -143,6 +149,76 @@ func (c *FreedomConfig) Build() (proto.Message, error) { } } } + if c.Noise != nil { + config.Noise = new(freedom.Noise) + var err, err2 error + p := strings.Split(strings.ToLower(c.Noise.Packet), ":") + if len(p) != 2 { + return nil, errors.New("invalid type for packet") + } + switch p[0] { + case "rand": + randValue := strings.Split(p[1], "-") + if len(randValue) > 2 { + return nil, errors.New("Only 2 values are allowed for rand") + } + if len(randValue) == 2 { + config.Noise.LengthMin, err = strconv.ParseUint(randValue[0], 10, 64) + config.Noise.LengthMax, err2 = strconv.ParseUint(randValue[1], 10, 64) + } + if len(randValue) == 1 { + config.Noise.LengthMin, err = strconv.ParseUint(randValue[0], 10, 64) + config.Noise.LengthMax = config.Noise.LengthMin + } + if err != nil { + return nil, errors.New("invalid value for rand LengthMin").Base(err) + } + if err2 != nil { + return nil, errors.New("invalid value for rand LengthMax").Base(err2) + } + if config.Noise.LengthMin > config.Noise.LengthMax { + config.Noise.LengthMin, config.Noise.LengthMax = config.Noise.LengthMax, config.Noise.LengthMin + } + if config.Noise.LengthMin == 0 { + return nil, errors.New("rand lengthMin or lengthMax cannot be 0") + } + + case "str": + //user input string + config.Noise.StrNoise = strings.TrimSpace(p[1]) + + default: + return nil, errors.New("Invalid packet,only rand and str are supported") + } + if c.Noise.Delay != "" { + d := strings.Split(strings.ToLower(c.Noise.Delay), "-") + if len(d) > 2 { + return nil, errors.New("Invalid delay value") + } + if len(d) == 2 { + config.Noise.DelayMin, err = strconv.ParseUint(d[0], 10, 64) + config.Noise.DelayMax, err2 = strconv.ParseUint(d[1], 10, 64) + + } else { + config.Noise.DelayMin, err = strconv.ParseUint(d[0], 10, 64) + config.Noise.DelayMax = config.Noise.DelayMin + } + if err != nil { + return nil, errors.New("Invalid value for DelayMin").Base(err) + } + if err2 != nil { + return nil, errors.New("Invalid value for DelayMax").Base(err2) + } + if config.Noise.DelayMin > config.Noise.DelayMax { + config.Noise.DelayMin, config.Noise.DelayMax = config.Noise.DelayMax, config.Noise.DelayMin + } + if config.Noise.DelayMin == 0 { + return nil, errors.New("DelayMin or DelayMax cannot be 0") + } + } else { + config.Noise.DelayMin = 0 + } + } if c.Timeout != nil { config.Timeout = *c.Timeout diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 723d4de4..9d829251 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -91,7 +91,7 @@ func (x Config_DomainStrategy) Number() protoreflect.EnumNumber { // Deprecated: Use Config_DomainStrategy.Descriptor instead. func (Config_DomainStrategy) EnumDescriptor() ([]byte, []int) { - return file_proxy_freedom_config_proto_rawDescGZIP(), []int{2, 0} + return file_proxy_freedom_config_proto_rawDescGZIP(), []int{3, 0} } type DestinationOverride struct { @@ -228,6 +228,85 @@ func (x *Fragment) GetIntervalMax() uint64 { return 0 } +type Noise struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LengthMin uint64 `protobuf:"varint,1,opt,name=length_min,json=lengthMin,proto3" json:"length_min,omitempty"` + LengthMax uint64 `protobuf:"varint,2,opt,name=length_max,json=lengthMax,proto3" json:"length_max,omitempty"` + DelayMin uint64 `protobuf:"varint,3,opt,name=delay_min,json=delayMin,proto3" json:"delay_min,omitempty"` + DelayMax uint64 `protobuf:"varint,4,opt,name=delay_max,json=delayMax,proto3" json:"delay_max,omitempty"` + StrNoise string `protobuf:"bytes,5,opt,name=str_noise,json=strNoise,proto3" json:"str_noise,omitempty"` +} + +func (x *Noise) Reset() { + *x = Noise{} + if protoimpl.UnsafeEnabled { + mi := &file_proxy_freedom_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Noise) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Noise) ProtoMessage() {} + +func (x *Noise) ProtoReflect() protoreflect.Message { + mi := &file_proxy_freedom_config_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Noise.ProtoReflect.Descriptor instead. +func (*Noise) Descriptor() ([]byte, []int) { + return file_proxy_freedom_config_proto_rawDescGZIP(), []int{2} +} + +func (x *Noise) GetLengthMin() uint64 { + if x != nil { + return x.LengthMin + } + return 0 +} + +func (x *Noise) GetLengthMax() uint64 { + if x != nil { + return x.LengthMax + } + return 0 +} + +func (x *Noise) GetDelayMin() uint64 { + if x != nil { + return x.DelayMin + } + return 0 +} + +func (x *Noise) GetDelayMax() uint64 { + if x != nil { + return x.DelayMax + } + return 0 +} + +func (x *Noise) GetStrNoise() string { + if x != nil { + return x.StrNoise + } + return "" +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -240,12 +319,13 @@ type Config struct { UserLevel uint32 `protobuf:"varint,4,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` Fragment *Fragment `protobuf:"bytes,5,opt,name=fragment,proto3" json:"fragment,omitempty"` ProxyProtocol uint32 `protobuf:"varint,6,opt,name=proxy_protocol,json=proxyProtocol,proto3" json:"proxy_protocol,omitempty"` + Noise *Noise `protobuf:"bytes,7,opt,name=noise,proto3" json:"noise,omitempty"` } func (x *Config) Reset() { *x = Config{} if protoimpl.UnsafeEnabled { - mi := &file_proxy_freedom_config_proto_msgTypes[2] + mi := &file_proxy_freedom_config_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -258,7 +338,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_proxy_freedom_config_proto_msgTypes[2] + mi := &file_proxy_freedom_config_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -271,7 +351,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_proxy_freedom_config_proto_rawDescGZIP(), []int{2} + return file_proxy_freedom_config_proto_rawDescGZIP(), []int{3} } func (x *Config) GetDomainStrategy() Config_DomainStrategy { @@ -317,6 +397,13 @@ func (x *Config) GetProxyProtocol() uint32 { return 0 } +func (x *Config) GetNoise() *Noise { + if x != nil { + return x.Noise + } + return nil +} + var File_proxy_freedom_config_proto protoreflect.FileDescriptor var file_proxy_freedom_config_proto_rawDesc = []byte{ @@ -343,29 +430,42 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x6c, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0x82, 0x04, 0x0a, 0x06, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, - 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x1c, 0x0a, 0x07, 0x74, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, - 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x5a, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52, - 0x13, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, - 0x72, 0x69, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, - 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, - 0x76, 0x65, 0x6c, 0x12, 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, - 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0x9c, 0x01, 0x0a, 0x05, + 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5f, + 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6c, 0x65, 0x6e, 0x67, 0x74, + 0x68, 0x4d, 0x69, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5f, 0x6d, + 0x61, 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x4d, 0x61, 0x78, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x69, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, + 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x61, 0x78, 0x12, 0x1b, 0x0a, + 0x09, 0x73, 0x74, 0x72, 0x5f, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x73, 0x74, 0x72, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x22, 0xb3, 0x04, 0x0a, 0x06, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, + 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, + 0x64, 0x6f, 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x1c, 0x0a, 0x07, 0x74, 0x69, 0x6d, + 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x5a, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x13, + 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, + 0x69, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65, + 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, 0x76, + 0x65, 0x6c, 0x12, 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, + 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x6f, 0x6c, 0x12, 0x2f, 0x0a, 0x05, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, + 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x52, 0x05, 0x6e, + 0x6f, 0x69, 0x73, 0x65, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, @@ -398,24 +498,26 @@ func file_proxy_freedom_config_proto_rawDescGZIP() []byte { } var file_proxy_freedom_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_proxy_freedom_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_proxy_freedom_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_proxy_freedom_config_proto_goTypes = []any{ (Config_DomainStrategy)(0), // 0: xray.proxy.freedom.Config.DomainStrategy (*DestinationOverride)(nil), // 1: xray.proxy.freedom.DestinationOverride (*Fragment)(nil), // 2: xray.proxy.freedom.Fragment - (*Config)(nil), // 3: xray.proxy.freedom.Config - (*protocol.ServerEndpoint)(nil), // 4: xray.common.protocol.ServerEndpoint + (*Noise)(nil), // 3: xray.proxy.freedom.Noise + (*Config)(nil), // 4: xray.proxy.freedom.Config + (*protocol.ServerEndpoint)(nil), // 5: xray.common.protocol.ServerEndpoint } var file_proxy_freedom_config_proto_depIdxs = []int32{ - 4, // 0: xray.proxy.freedom.DestinationOverride.server:type_name -> xray.common.protocol.ServerEndpoint + 5, // 0: xray.proxy.freedom.DestinationOverride.server:type_name -> xray.common.protocol.ServerEndpoint 0, // 1: xray.proxy.freedom.Config.domain_strategy:type_name -> xray.proxy.freedom.Config.DomainStrategy 1, // 2: xray.proxy.freedom.Config.destination_override:type_name -> xray.proxy.freedom.DestinationOverride 2, // 3: xray.proxy.freedom.Config.fragment:type_name -> xray.proxy.freedom.Fragment - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 3, // 4: xray.proxy.freedom.Config.noise:type_name -> xray.proxy.freedom.Noise + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_proxy_freedom_config_proto_init() } @@ -449,6 +551,18 @@ func file_proxy_freedom_config_proto_init() { } } file_proxy_freedom_config_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*Noise); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proxy_freedom_config_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*Config); i { case 0: return &v.state @@ -467,7 +581,7 @@ func file_proxy_freedom_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proxy_freedom_config_proto_rawDesc, NumEnums: 1, - NumMessages: 3, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/proxy/freedom/config.proto b/proxy/freedom/config.proto index 1eabedb7..85b71979 100644 --- a/proxy/freedom/config.proto +++ b/proxy/freedom/config.proto @@ -20,6 +20,13 @@ message Fragment { uint64 interval_min = 5; uint64 interval_max = 6; } +message Noise { + uint64 length_min = 1; + uint64 length_max = 2; + uint64 delay_min = 3; + uint64 delay_max = 4; + string str_noise = 5; +} message Config { enum DomainStrategy { @@ -41,4 +48,5 @@ message Config { uint32 user_level = 4; Fragment fragment = 5; uint32 proxy_protocol = 6; + Noise noise = 7; } diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index feee98c0..c387d158 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -208,6 +208,16 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } } else { writer = NewPacketWriter(conn, h, ctx, UDPOverride) + if h.config.Noise != nil { + errors.LogDebug(ctx, "NOISE", h.config.Noise.StrNoise, h.config.Noise.LengthMin, h.config.Noise.LengthMax, + h.config.Noise.DelayMin, h.config.Noise.DelayMax) + writer = &NoisePacketWriter{ + Writer: writer, + noise: h.config.Noise, + firstWrite: true, + UDPOverride: UDPOverride, + } + } } if err := buf.Copy(input, writer, buf.UpdateActivity(timer)); err != nil { @@ -329,6 +339,7 @@ func NewPacketWriter(conn net.Conn, h *Handler, ctx context.Context, UDPOverride UDPOverride: UDPOverride, Conn: iConn, } + } return &buf.SequentialWriter{Writer: conn} } @@ -385,6 +396,45 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { return nil } +type NoisePacketWriter struct { + buf.Writer + noise *Noise + firstWrite bool + UDPOverride net.Destination +} + +// MultiBuffer writer with Noise in first packet +func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { + if w.firstWrite { + w.firstWrite = false + //Do not send Noise for dns requests(just to be safe) + if w.UDPOverride.Port == 53 { + return w.Writer.WriteMultiBuffer(mb) + } + var noise []byte + var err error + //User input string + if w.noise.StrNoise != "" { + noise = []byte(w.noise.StrNoise) + } else { + //Random noise + noise, err = GenerateRandomBytes(randBetween(int64(w.noise.LengthMin), + int64(w.noise.LengthMax))) + } + + if err != nil { + return err + } + w.Writer.WriteMultiBuffer(buf.MultiBuffer{buf.FromBytes(noise)}) + + if w.noise.DelayMin != 0 { + time.Sleep(time.Duration(randBetween(int64(w.noise.DelayMin), int64(w.noise.DelayMax))) * time.Millisecond) + } + + } + return w.Writer.WriteMultiBuffer(mb) +} + type FragmentWriter struct { fragment *Fragment writer io.Writer @@ -471,3 +521,13 @@ func randBetween(left int64, right int64) int64 { bigInt, _ := rand.Int(rand.Reader, big.NewInt(right-left)) return left + bigInt.Int64() } +func GenerateRandomBytes(n int64) ([]byte, error) { + b := make([]byte, n) + _, err := rand.Read(b) + // Note that err == nil only if we read len(b) bytes. + if err != nil { + return nil, err + } + + return b, nil +} From 98e85b7f3c137656ea7306b40f8d334cf98deed0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Aug 2024 11:32:36 -0400 Subject: [PATCH 510/867] Bump google.golang.org/grpc from 1.65.0 to 1.66.0 (#3740) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.65.0 to 1.66.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.65.0...v1.66.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index b234a137..d90c87f4 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.8.0 golang.org/x/sys v0.24.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.65.0 + google.golang.org/grpc v1.66.0 google.golang.org/protobuf v1.34.2 gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 @@ -56,7 +56,7 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 1847c4b9..c2011cc5 100644 --- a/go.sum +++ b/go.sum @@ -268,14 +268,14 @@ google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 h1:Zy9XzmMEflZ/MAaA7vNcoebnRAld7FsPW1EeBB7V0m8= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c= +google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 6baad79f9881ee2cf75bdc825b3e2e92b289477a Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 30 Aug 2024 07:01:01 +0000 Subject: [PATCH 511/867] v1.8.24 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 084cea72..a1423efb 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 1 Version_y byte = 8 - Version_z byte = 23 + Version_z byte = 24 ) var ( From f1c439c2aa0e64e2e3ab8f7b823c1f07ce8150e6 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 1 Sep 2024 10:59:31 -0500 Subject: [PATCH 512/867] Revert "Fix freedom PacketReader/PacketWriter type assertion (#3734)" This reverts commit 815a959c9625f5fcb6e7568558a52c2b0f3ee85f. --- proxy/freedom/freedom.go | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index c387d158..4c3d963e 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -286,24 +286,24 @@ func NewPacketReader(conn net.Conn, UDPOverride net.Destination) buf.Reader { if statConn != nil { counter = statConn.ReadCounter } - if c, ok := iConn.(net.PacketConn); ok && UDPOverride.Address == nil && UDPOverride.Port == 0 { + if c, ok := iConn.(*internet.PacketConnWrapper); ok && UDPOverride.Address == nil && UDPOverride.Port == 0 { return &PacketReader{ - PacketConn: c, - Counter: counter, + PacketConnWrapper: c, + Counter: counter, } } return &buf.PacketReader{Reader: conn} } type PacketReader struct { - net.PacketConn + *internet.PacketConnWrapper stats.Counter } func (r *PacketReader) ReadMultiBuffer() (buf.MultiBuffer, error) { b := buf.New() b.Resize(0, buf.Size) - n, d, err := r.PacketConn.ReadFrom(b.Bytes()) + n, d, err := r.PacketConnWrapper.ReadFrom(b.Bytes()) if err != nil { b.Release() return nil, err @@ -330,14 +330,13 @@ func NewPacketWriter(conn net.Conn, h *Handler, ctx context.Context, UDPOverride if statConn != nil { counter = statConn.WriteCounter } - if c, ok := iConn.(net.PacketConn); ok { + if c, ok := iConn.(*internet.PacketConnWrapper); ok { return &PacketWriter{ - PacketConn: c, - Counter: counter, - Handler: h, - Context: ctx, - UDPOverride: UDPOverride, - Conn: iConn, + PacketConnWrapper: c, + Counter: counter, + Handler: h, + Context: ctx, + UDPOverride: UDPOverride, } } @@ -345,12 +344,11 @@ func NewPacketWriter(conn net.Conn, h *Handler, ctx context.Context, UDPOverride } type PacketWriter struct { - net.PacketConn + *internet.PacketConnWrapper stats.Counter *Handler context.Context UDPOverride net.Destination - Conn net.Conn } func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { @@ -380,9 +378,9 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { b.Release() continue } - n, err = w.PacketConn.WriteTo(b.Bytes(), destAddr) + n, err = w.PacketConnWrapper.WriteTo(b.Bytes(), destAddr) } else { - n, err = w.Conn.Write(b.Bytes()) + n, err = w.PacketConnWrapper.Write(b.Bytes()) } b.Release() if err != nil { From ab3c00e96b3af6885c09acfdd1f8d36e60d90bad Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Tue, 3 Sep 2024 04:25:15 +0200 Subject: [PATCH 513/867] SplitHTTP: Remove `ok` compatibility logic (#3753) Remove some code that was added to maintain compatibility with older Xray versions. This breaks compatibility with Xray-core v1.8.23 or older. --- transport/internet/splithttp/dialer.go | 4 +- transport/internet/splithttp/hub.go | 8 ---- .../internet/splithttp/strip_ok_reader.go | 48 ------------------- 3 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 transport/internet/splithttp/strip_ok_reader.go diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 35e8c7b4..69a30870 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -285,13 +285,11 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } }() - lazyRawDownload, remoteAddr, localAddr, err := httpClient.OpenDownload(context.WithoutCancel(ctx), requestURL.String()) + reader, remoteAddr, localAddr, err := httpClient.OpenDownload(context.WithoutCancel(ctx), requestURL.String()) if err != nil { return nil, err } - reader := &stripOkReader{ReadCloser: lazyRawDownload} - writer := uploadWriter{ uploadPipeWriter, maxUploadSize, diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 4a05e1c3..423bf6e3 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -196,14 +196,6 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req h.config.WriteResponseHeader(writer) writer.WriteHeader(http.StatusOK) - if _, ok := request.URL.Query()["x_padding"]; !ok { - // in earlier versions, this initial body data was used to immediately - // start a 200 OK on all CDN. but xray client since 1.8.16 does not - // actually require an immediate 200 OK, but now requires these - // additional bytes "ok". xray client 1.8.24+ doesn't require "ok" - // anymore, and so this line should be removed in later versions. - writer.Write([]byte("ok")) - } responseFlusher.Flush() diff --git a/transport/internet/splithttp/strip_ok_reader.go b/transport/internet/splithttp/strip_ok_reader.go deleted file mode 100644 index 5dbbe22b..00000000 --- a/transport/internet/splithttp/strip_ok_reader.go +++ /dev/null @@ -1,48 +0,0 @@ -package splithttp - -import ( - "bytes" - "io" - - "github.com/xtls/xray-core/common/errors" -) - -// in older versions of splithttp, the server would respond with `ok` to flush -// out HTTP response headers early. Response headers and a 200 OK were required -// to initiate the connection. Later versions of splithttp dropped this -// requirement, and in xray 1.8.24 the server stopped sending "ok" if it sees -// x_padding. For compatibility, we need to remove "ok" from the underlying -// reader if it exists, and otherwise forward the stream as-is. -type stripOkReader struct { - io.ReadCloser - firstDone bool - prefixRead []byte -} - -func (r *stripOkReader) Read(b []byte) (int, error) { - if !r.firstDone { - r.firstDone = true - - // skip "ok" response - prefixRead := []byte{0, 0} - _, err := io.ReadFull(r.ReadCloser, prefixRead) - if err != nil { - return 0, errors.New("failed to read initial response").Base(err) - } - - if !bytes.Equal(prefixRead, []byte("ok")) { - // we read some garbage byte that may not have been "ok" at - // all. return a reader that replays what we have read so far - r.prefixRead = prefixRead - } - } - - if len(r.prefixRead) > 0 { - n := copy(b, r.prefixRead) - r.prefixRead = r.prefixRead[n:] - return n, nil - } - - n, err := r.ReadCloser.Read(b) - return n, err -} From 9a953c070f9c3bd2b7f255fb50f076ae8ece7bce Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Tue, 3 Sep 2024 04:39:44 +0200 Subject: [PATCH 514/867] Transport: Remove QUIC (#3754) https://github.com/XTLS/Xray-core/pull/3554#issuecomment-2236171077 --- infra/conf/transport.go | 12 -- infra/conf/transport_internet.go | 56 ------ infra/conf/transport_test.go | 19 --- main/distro/all/all.go | 1 - testing/scenarios/transport_test.go | 139 --------------- transport/internet/quic/config.go | 48 ------ transport/internet/quic/config.pb.go | 184 -------------------- transport/internet/quic/config.proto | 16 -- transport/internet/quic/conn.go | 198 --------------------- transport/internet/quic/dialer.go | 236 -------------------------- transport/internet/quic/hub.go | 146 ---------------- transport/internet/quic/pool.go | 21 --- transport/internet/quic/qlogWriter.go | 24 --- transport/internet/quic/quic.go | 25 --- transport/internet/quic/quic_test.go | 223 ------------------------ 15 files changed, 1348 deletions(-) delete mode 100644 transport/internet/quic/config.go delete mode 100644 transport/internet/quic/config.pb.go delete mode 100644 transport/internet/quic/config.proto delete mode 100644 transport/internet/quic/conn.go delete mode 100644 transport/internet/quic/dialer.go delete mode 100644 transport/internet/quic/hub.go delete mode 100644 transport/internet/quic/pool.go delete mode 100644 transport/internet/quic/qlogWriter.go delete mode 100644 transport/internet/quic/quic.go delete mode 100644 transport/internet/quic/quic_test.go diff --git a/infra/conf/transport.go b/infra/conf/transport.go index b401dcab..5577e823 100644 --- a/infra/conf/transport.go +++ b/infra/conf/transport.go @@ -13,7 +13,6 @@ type TransportConfig struct { WSConfig *WebSocketConfig `json:"wsSettings"` HTTPConfig *HTTPConfig `json:"httpSettings"` DSConfig *DomainSocketConfig `json:"dsSettings"` - QUICConfig *QUICConfig `json:"quicSettings"` GRPCConfig *GRPCConfig `json:"grpcSettings"` GUNConfig *GRPCConfig `json:"gunSettings"` HTTPUPGRADEConfig *HttpUpgradeConfig `json:"httpupgradeSettings"` @@ -79,17 +78,6 @@ func (c *TransportConfig) Build() (*global.Config, error) { }) } - if c.QUICConfig != nil { - qs, err := c.QUICConfig.Build() - if err != nil { - return nil, errors.New("Failed to build QUIC config.").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "quic", - Settings: serial.ToTypedMessage(qs), - }) - } - if c.GRPCConfig == nil { c.GRPCConfig = c.GUNConfig } diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 9e13f246..8e84d0f3 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -14,7 +14,6 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/platform/filesystem" - "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/domainsocket" @@ -22,7 +21,6 @@ import ( "github.com/xtls/xray-core/transport/internet/http" "github.com/xtls/xray-core/transport/internet/httpupgrade" "github.com/xtls/xray-core/transport/internet/kcp" - "github.com/xtls/xray-core/transport/internet/quic" "github.com/xtls/xray-core/transport/internet/reality" "github.com/xtls/xray-core/transport/internet/splithttp" "github.com/xtls/xray-core/transport/internet/tcp" @@ -315,47 +313,6 @@ func (c *HTTPConfig) Build() (proto.Message, error) { return config, nil } -type QUICConfig struct { - Header json.RawMessage `json:"header"` - Security string `json:"security"` - Key string `json:"key"` -} - -// Build implements Buildable. -func (c *QUICConfig) Build() (proto.Message, error) { - config := &quic.Config{ - Key: c.Key, - } - - if len(c.Header) > 0 { - headerConfig, _, err := kcpHeaderLoader.Load(c.Header) - if err != nil { - return nil, errors.New("invalid QUIC header config.").Base(err).AtError() - } - ts, err := headerConfig.(Buildable).Build() - if err != nil { - return nil, errors.New("invalid QUIC header config").Base(err).AtError() - } - config.Header = serial.ToTypedMessage(ts) - } - - var st protocol.SecurityType - switch strings.ToLower(c.Security) { - case "aes-128-gcm": - st = protocol.SecurityType_AES128_GCM - case "chacha20-poly1305": - st = protocol.SecurityType_CHACHA20_POLY1305 - default: - st = protocol.SecurityType_NONE - } - - config.Security = &protocol.SecurityConfig{ - Type: st, - } - - return config, nil -} - type DomainSocketConfig struct { Path string `json:"path"` Abstract bool `json:"abstract"` @@ -691,8 +648,6 @@ func (p TransportProtocol) Build() (string, error) { return "http", nil case "ds", "domainsocket": return "domainsocket", nil - case "quic": - return "quic", nil case "grpc", "gun": return "grpc", nil case "httpupgrade": @@ -829,7 +784,6 @@ type StreamConfig struct { WSSettings *WebSocketConfig `json:"wsSettings"` HTTPSettings *HTTPConfig `json:"httpSettings"` DSSettings *DomainSocketConfig `json:"dsSettings"` - QUICSettings *QUICConfig `json:"quicSettings"` SocketSettings *SocketConfig `json:"sockopt"` GRPCConfig *GRPCConfig `json:"grpcSettings"` GUNConfig *GRPCConfig `json:"gunSettings"` @@ -932,16 +886,6 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { Settings: serial.ToTypedMessage(ds), }) } - if c.QUICSettings != nil { - qs, err := c.QUICSettings.Build() - if err != nil { - return nil, errors.New("Failed to build QUIC config").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "quic", - Settings: serial.ToTypedMessage(qs), - }) - } if c.GRPCConfig == nil { c.GRPCConfig = c.GUNConfig } diff --git a/infra/conf/transport_test.go b/infra/conf/transport_test.go index 989c259c..86f707bd 100644 --- a/infra/conf/transport_test.go +++ b/infra/conf/transport_test.go @@ -4,7 +4,6 @@ import ( "encoding/json" "testing" - "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/serial" . "github.com/xtls/xray-core/infra/conf" "github.com/xtls/xray-core/transport/global" @@ -12,9 +11,7 @@ import ( "github.com/xtls/xray-core/transport/internet/grpc" "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/tls" "github.com/xtls/xray-core/transport/internet/kcp" - "github.com/xtls/xray-core/transport/internet/quic" "github.com/xtls/xray-core/transport/internet/tcp" "github.com/xtls/xray-core/transport/internet/websocket" "google.golang.org/protobuf/proto" @@ -203,12 +200,6 @@ func TestTransportConfig(t *testing.T) { "wsSettings": { "path": "/t" }, - "quicSettings": { - "key": "abcd", - "header": { - "type": "dtls" - } - }, "grpcSettings": { "serviceName": "name", "multiMode": true @@ -272,16 +263,6 @@ func TestTransportConfig(t *testing.T) { Path: "/t", }), }, - { - ProtocolName: "quic", - Settings: serial.ToTypedMessage(&quic.Config{ - Key: "abcd", - Security: &protocol.SecurityConfig{ - Type: protocol.SecurityType_NONE, - }, - Header: serial.ToTypedMessage(&tls.PacketConfig{}), - }), - }, { ProtocolName: "grpc", Settings: serial.ToTypedMessage(&grpc.Config{ diff --git a/main/distro/all/all.go b/main/distro/all/all.go index ae717653..56ae664b 100644 --- a/main/distro/all/all.go +++ b/main/distro/all/all.go @@ -55,7 +55,6 @@ import ( _ "github.com/xtls/xray-core/transport/internet/http" _ "github.com/xtls/xray-core/transport/internet/httpupgrade" _ "github.com/xtls/xray-core/transport/internet/kcp" - _ "github.com/xtls/xray-core/transport/internet/quic" _ "github.com/xtls/xray-core/transport/internet/reality" _ "github.com/xtls/xray-core/transport/internet/splithttp" _ "github.com/xtls/xray-core/transport/internet/tcp" diff --git a/testing/scenarios/transport_test.go b/testing/scenarios/transport_test.go index e1db105e..d6abbebd 100644 --- a/testing/scenarios/transport_test.go +++ b/testing/scenarios/transport_test.go @@ -6,10 +6,8 @@ import ( "testing" "time" - "github.com/xtls/xray-core/app/log" "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" - clog "github.com/xtls/xray-core/common/log" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/serial" @@ -21,14 +19,10 @@ 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" - "github.com/xtls/xray-core/testing/servers/udp" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/domainsocket" "github.com/xtls/xray-core/transport/internet/headers/http" - "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) { @@ -248,136 +242,3 @@ func TestDomainSocket(t *testing.T) { } } -func TestVMessQuic(t *testing.T) { - tcpServer := tcp.Server{ - MsgProcessor: xor, - } - dest, err := tcpServer.Start() - common.Must(err) - defer tcpServer.Close() - - userID := protocol.NewID(uuid.New()) - serverPort := udp.PickPort() - serverConfig := &core.Config{ - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: clog.Severity_Debug, - ErrorLogType: log.LogType_Console, - }), - }, - Inbound: []*core.InboundHandlerConfig{ - { - ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ - PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, - Listen: net.NewIPOrDomain(net.LocalHostIP), - StreamSettings: &internet.StreamConfig{ - ProtocolName: "quic", - TransportSettings: []*internet.TransportConfig{ - { - ProtocolName: "quic", - Settings: serial.ToTypedMessage(&quic.Config{ - Header: serial.ToTypedMessage(&wechat.VideoConfig{}), - Security: &protocol.SecurityConfig{ - Type: protocol.SecurityType_NONE, - }, - }), - }, - }, - }, - }), - ProxySettings: serial.ToTypedMessage(&inbound.Config{ - User: []*protocol.User{ - { - Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - }), - }, - }, - }), - }, - }, - Outbound: []*core.OutboundHandlerConfig{ - { - ProxySettings: serial.ToTypedMessage(&freedom.Config{}), - }, - }, - } - - clientPort := tcp.PickPort() - clientConfig := &core.Config{ - App: []*serial.TypedMessage{ - serial.ToTypedMessage(&log.Config{ - ErrorLogLevel: clog.Severity_Debug, - ErrorLogType: log.LogType_Console, - }), - }, - Inbound: []*core.InboundHandlerConfig{ - { - ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ - PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, - Listen: net.NewIPOrDomain(net.LocalHostIP), - }), - ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(dest.Address), - Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, - }), - }, - }, - Outbound: []*core.OutboundHandlerConfig{ - { - SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ - StreamSettings: &internet.StreamConfig{ - ProtocolName: "quic", - TransportSettings: []*internet.TransportConfig{ - { - ProtocolName: "quic", - Settings: serial.ToTypedMessage(&quic.Config{ - Header: serial.ToTypedMessage(&wechat.VideoConfig{}), - Security: &protocol.SecurityConfig{ - Type: protocol.SecurityType_NONE, - }, - }), - }, - }, - }, - }), - ProxySettings: serial.ToTypedMessage(&outbound.Config{ - Receiver: []*protocol.ServerEndpoint{ - { - Address: net.NewIPOrDomain(net.LocalHostIP), - Port: uint32(serverPort), - User: []*protocol.User{ - { - Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - SecuritySettings: &protocol.SecurityConfig{ - Type: protocol.SecurityType_AES128_GCM, - }, - }), - }, - }, - }, - }, - }), - }, - }, - } - - servers, err := InitializeServerConfigs(serverConfig, clientConfig) - if err != nil { - t.Fatal("Failed to initialize all servers: ", err.Error()) - } - defer CloseAllServers(servers) - - var errg errgroup.Group - for i := 0; i < 10; i++ { - errg.Go(testTCPConn(clientPort, 10240*1024, time.Second*40)) - } - - if err := errg.Wait(); err != nil { - t.Error(err) - } -} diff --git a/transport/internet/quic/config.go b/transport/internet/quic/config.go deleted file mode 100644 index 364ada7c..00000000 --- a/transport/internet/quic/config.go +++ /dev/null @@ -1,48 +0,0 @@ -package quic - -import ( - "crypto/aes" - "crypto/cipher" - "crypto/sha256" - "errors" - - "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) { - security := config.Security.GetSecurityType() - if security == protocol.SecurityType_NONE { - return nil, nil - } - - salted := []byte(config.Key + "xray-quic-salt") - key := sha256.Sum256(salted) - - if security == protocol.SecurityType_AES128_GCM { - block, err := aes.NewCipher(key[:16]) - common.Must(err) - return cipher.NewGCM(block) - } - - if security == protocol.SecurityType_CHACHA20_POLY1305 { - return chacha20poly1305.New(key[:]) - } - - return nil, errors.New("unsupported security type") -} - -func getHeader(config *Config) (internet.PacketHeader, error) { - if config.Header == nil { - return nil, nil - } - - msg, err := config.Header.GetInstance() - if err != nil { - return nil, err - } - - return internet.CreatePacketHeader(msg) -} diff --git a/transport/internet/quic/config.pb.go b/transport/internet/quic/config.pb.go deleted file mode 100644 index 992cbdf2..00000000 --- a/transport/internet/quic/config.pb.go +++ /dev/null @@ -1,184 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 -// source: transport/internet/quic/config.proto - -package quic - -import ( - protocol "github.com/xtls/xray-core/common/protocol" - serial "github.com/xtls/xray-core/common/serial" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Config struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Security *protocol.SecurityConfig `protobuf:"bytes,2,opt,name=security,proto3" json:"security,omitempty"` - Header *serial.TypedMessage `protobuf:"bytes,3,opt,name=header,proto3" json:"header,omitempty"` -} - -func (x *Config) Reset() { - *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_quic_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Config) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Config) ProtoMessage() {} - -func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_transport_internet_quic_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Config.ProtoReflect.Descriptor instead. -func (*Config) Descriptor() ([]byte, []int) { - return file_transport_internet_quic_config_proto_rawDescGZIP(), []int{0} -} - -func (x *Config) GetKey() string { - if x != nil { - return x.Key - } - return "" -} - -func (x *Config) GetSecurity() *protocol.SecurityConfig { - if x != nil { - return x.Security - } - return nil -} - -func (x *Config) GetHeader() *serial.TypedMessage { - if x != nil { - return x.Header - } - return nil -} - -var File_transport_internet_quic_config_proto protoreflect.FileDescriptor - -var file_transport_internet_quic_config_proto_rawDesc = []byte{ - 0x0a, 0x24, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x71, 0x75, 0x69, 0x63, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, - 0x71, 0x75, 0x69, 0x63, 0x1a, 0x21, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x73, 0x65, 0x72, - 0x69, 0x61, 0x6c, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1d, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x96, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x40, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x63, - 0x75, 0x72, 0x69, 0x74, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x73, 0x65, 0x63, - 0x75, 0x72, 0x69, 0x74, 0x79, 0x12, 0x38, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x42, - 0x76, 0x0a, 0x20, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x71, - 0x75, 0x69, 0x63, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, - 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x2f, 0x71, 0x75, 0x69, 0x63, 0xaa, 0x02, 0x1c, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x51, 0x75, 0x69, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_transport_internet_quic_config_proto_rawDescOnce sync.Once - file_transport_internet_quic_config_proto_rawDescData = file_transport_internet_quic_config_proto_rawDesc -) - -func file_transport_internet_quic_config_proto_rawDescGZIP() []byte { - file_transport_internet_quic_config_proto_rawDescOnce.Do(func() { - file_transport_internet_quic_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_internet_quic_config_proto_rawDescData) - }) - return file_transport_internet_quic_config_proto_rawDescData -} - -var file_transport_internet_quic_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_quic_config_proto_goTypes = []any{ - (*Config)(nil), // 0: xray.transport.internet.quic.Config - (*protocol.SecurityConfig)(nil), // 1: xray.common.protocol.SecurityConfig - (*serial.TypedMessage)(nil), // 2: xray.common.serial.TypedMessage -} -var file_transport_internet_quic_config_proto_depIdxs = []int32{ - 1, // 0: xray.transport.internet.quic.Config.security:type_name -> xray.common.protocol.SecurityConfig - 2, // 1: xray.transport.internet.quic.Config.header:type_name -> xray.common.serial.TypedMessage - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_transport_internet_quic_config_proto_init() } -func file_transport_internet_quic_config_proto_init() { - if File_transport_internet_quic_config_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_transport_internet_quic_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_transport_internet_quic_config_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_transport_internet_quic_config_proto_goTypes, - DependencyIndexes: file_transport_internet_quic_config_proto_depIdxs, - MessageInfos: file_transport_internet_quic_config_proto_msgTypes, - }.Build() - File_transport_internet_quic_config_proto = out.File - file_transport_internet_quic_config_proto_rawDesc = nil - file_transport_internet_quic_config_proto_goTypes = nil - file_transport_internet_quic_config_proto_depIdxs = nil -} diff --git a/transport/internet/quic/config.proto b/transport/internet/quic/config.proto deleted file mode 100644 index b08e531e..00000000 --- a/transport/internet/quic/config.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package xray.transport.internet.quic; -option csharp_namespace = "Xray.Transport.Internet.Quic"; -option go_package = "github.com/xtls/xray-core/transport/internet/quic"; -option java_package = "com.xray.transport.internet.quic"; -option java_multiple_files = true; - -import "common/serial/typed_message.proto"; -import "common/protocol/headers.proto"; - -message Config { - string key = 1; - xray.common.protocol.SecurityConfig security = 2; - xray.common.serial.TypedMessage header = 3; -} diff --git a/transport/internet/quic/conn.go b/transport/internet/quic/conn.go deleted file mode 100644 index 11bee7c5..00000000 --- a/transport/internet/quic/conn.go +++ /dev/null @@ -1,198 +0,0 @@ -package quic - -import ( - "crypto/cipher" - "crypto/rand" - "errors" - "syscall" - "time" - - "github.com/quic-go/quic-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" -) - -type sysConn struct { - conn *net.UDPConn - header internet.PacketHeader - auth cipher.AEAD -} - -func wrapSysConn(rawConn *net.UDPConn, config *Config) (*sysConn, error) { - header, err := getHeader(config) - if err != nil { - return nil, err - } - auth, err := getAuth(config) - if err != nil { - return nil, err - } - return &sysConn{ - conn: rawConn, - header: header, - auth: auth, - }, nil -} - -var errInvalidPacket = errors.New("invalid packet") - -func (c *sysConn) readFromInternal(p []byte) (int, net.Addr, error) { - buffer := getBuffer() - defer putBuffer(buffer) - - nBytes, addr, err := c.conn.ReadFrom(buffer) - if err != nil { - return 0, nil, err - } - - payload := buffer[:nBytes] - if c.header != nil { - if len(payload) <= int(c.header.Size()) { - return 0, nil, errInvalidPacket - } - payload = payload[c.header.Size():] - } - - if c.auth == nil { - n := copy(p, payload) - return n, addr, nil - } - - if len(payload) <= c.auth.NonceSize() { - return 0, nil, errInvalidPacket - } - - nonce := payload[:c.auth.NonceSize()] - payload = payload[c.auth.NonceSize():] - - p, err = c.auth.Open(p[:0], nonce, payload, nil) - if err != nil { - return 0, nil, errInvalidPacket - } - - return len(p), addr, nil -} - -func (c *sysConn) ReadFrom(p []byte) (int, net.Addr, error) { - if c.header == nil && c.auth == nil { - return c.conn.ReadFrom(p) - } - - for { - n, addr, err := c.readFromInternal(p) - if err != nil && err != errInvalidPacket { - return 0, nil, err - } - if err == nil { - return n, addr, nil - } - } -} - -func (c *sysConn) WriteTo(p []byte, addr net.Addr) (int, error) { - if c.header == nil && c.auth == nil { - return c.conn.WriteTo(p, addr) - } - - buffer := getBuffer() - defer putBuffer(buffer) - - payload := buffer - n := 0 - if c.header != nil { - c.header.Serialize(payload) - n = int(c.header.Size()) - } - - if c.auth == nil { - nBytes := copy(payload[n:], p) - n += nBytes - } else { - nounce := payload[n : n+c.auth.NonceSize()] - common.Must2(rand.Read(nounce)) - n += c.auth.NonceSize() - pp := c.auth.Seal(payload[:n], nounce, p, nil) - n = len(pp) - } - - return c.conn.WriteTo(payload[:n], addr) -} - -func (c *sysConn) Close() error { - return c.conn.Close() -} - -func (c *sysConn) LocalAddr() net.Addr { - return c.conn.LocalAddr() -} - -func (c *sysConn) SetReadBuffer(bytes int) error { - return c.conn.SetReadBuffer(bytes) -} - -func (c *sysConn) SetWriteBuffer(bytes int) error { - return c.conn.SetWriteBuffer(bytes) -} - -func (c *sysConn) SetDeadline(t time.Time) error { - return c.conn.SetDeadline(t) -} - -func (c *sysConn) SetReadDeadline(t time.Time) error { - return c.conn.SetReadDeadline(t) -} - -func (c *sysConn) SetWriteDeadline(t time.Time) error { - return c.conn.SetWriteDeadline(t) -} - -func (c *sysConn) SyscallConn() (syscall.RawConn, error) { - return c.conn.SyscallConn() -} - -type interConn struct { - stream quic.Stream - local net.Addr - remote net.Addr -} - -func (c *interConn) Read(b []byte) (int, error) { - return c.stream.Read(b) -} - -func (c *interConn) WriteMultiBuffer(mb buf.MultiBuffer) error { - mb = buf.Compact(mb) - mb, err := buf.WriteMultiBuffer(c, mb) - buf.ReleaseMulti(mb) - return err -} - -func (c *interConn) Write(b []byte) (int, error) { - return c.stream.Write(b) -} - -func (c *interConn) Close() error { - return c.stream.Close() -} - -func (c *interConn) LocalAddr() net.Addr { - return c.local -} - -func (c *interConn) RemoteAddr() net.Addr { - return c.remote -} - -func (c *interConn) SetDeadline(t time.Time) error { - return c.stream.SetDeadline(t) -} - -func (c *interConn) SetReadDeadline(t time.Time) error { - return c.stream.SetReadDeadline(t) -} - -func (c *interConn) SetWriteDeadline(t time.Time) error { - return c.stream.SetWriteDeadline(t) -} diff --git a/transport/internet/quic/dialer.go b/transport/internet/quic/dialer.go deleted file mode 100644 index df73e169..00000000 --- a/transport/internet/quic/dialer.go +++ /dev/null @@ -1,236 +0,0 @@ -package quic - -import ( - "context" - "sync" - "time" - - "github.com/quic-go/quic-go" - "github.com/quic-go/quic-go/logging" - "github.com/quic-go/quic-go/qlog" - "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/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" -) - -type connectionContext struct { - rawConn *sysConn - conn quic.Connection -} - -var errConnectionClosed = errors.New("connection closed") - -func (c *connectionContext) openStream(destAddr net.Addr) (*interConn, error) { - if !isActive(c.conn) { - return nil, errConnectionClosed - } - - stream, err := c.conn.OpenStream() - if err != nil { - return nil, err - } - - conn := &interConn{ - stream: stream, - local: c.conn.LocalAddr(), - remote: destAddr, - } - - return conn, nil -} - -type clientConnections struct { - access sync.Mutex - conns map[net.Destination][]*connectionContext - cleanup *task.Periodic -} - -func isActive(s quic.Connection) bool { - select { - case <-s.Context().Done(): - return false - default: - return true - } -} - -func removeInactiveConnections(conns []*connectionContext) []*connectionContext { - activeConnections := make([]*connectionContext, 0, len(conns)) - for i, s := range conns { - if isActive(s.conn) { - activeConnections = append(activeConnections, s) - continue - } - - errors.LogInfo(context.Background(), "closing quic connection at index: ", i) - if err := s.conn.CloseWithError(0, ""); err != nil { - errors.LogInfoInner(context.Background(), err, "failed to close connection") - } - if err := s.rawConn.Close(); err != nil { - errors.LogInfoInner(context.Background(), err, "failed to close raw connection") - } - } - - if len(activeConnections) < len(conns) { - errors.LogInfo(context.Background(), "active quic connection reduced from ", len(conns), " to ", len(activeConnections)) - return activeConnections - } - - return conns -} - -func (s *clientConnections) cleanConnections() error { - s.access.Lock() - defer s.access.Unlock() - - if len(s.conns) == 0 { - return nil - } - - newConnMap := make(map[net.Destination][]*connectionContext) - - for dest, conns := range s.conns { - conns = removeInactiveConnections(conns) - if len(conns) > 0 { - newConnMap[dest] = conns - } - } - - s.conns = newConnMap - return nil -} - -func (s *clientConnections) openConnection(ctx context.Context, destAddr net.Addr, config *Config, tlsConfig *tls.Config, sockopt *internet.SocketConfig) (stat.Connection, error) { - s.access.Lock() - defer s.access.Unlock() - - if s.conns == nil { - s.conns = make(map[net.Destination][]*connectionContext) - } - - dest := net.DestinationFromAddr(destAddr) - - var conns []*connectionContext - if s, found := s.conns[dest]; found { - conns = s - } - - if len(conns) > 0 { - s := conns[len(conns)-1] - if isActive(s.conn) { - conn, err := s.openStream(destAddr) - if err == nil { - return conn, nil - } - errors.LogInfoInner(ctx, err, "failed to openStream: ") - } else { - errors.LogInfo(ctx, "current quic connection is not active!") - } - } - - conns = removeInactiveConnections(conns) - errors.LogInfo(ctx, "dialing quic to ", dest) - rawConn, err := internet.DialSystem(ctx, dest, sockopt) - if err != nil { - return nil, errors.New("failed to dial to dest: ", err).AtWarning().Base(err) - } - - quicConfig := &quic.Config{ - KeepAlivePeriod: 0, - HandshakeIdleTimeout: time.Second * 8, - MaxIdleTimeout: time.Second * 300, - Tracer: func(ctx context.Context, p logging.Perspective, ci quic.ConnectionID) *logging.ConnectionTracer { - return qlog.NewConnectionTracer(&QlogWriter{connID: ci}, p, ci) - }, - } - - var udpConn *net.UDPConn - switch conn := rawConn.(type) { - case *net.UDPConn: - udpConn = conn - case *internet.PacketConnWrapper: - udpConn = conn.Conn.(*net.UDPConn) - default: - // TODO: Support sockopt for QUIC - rawConn.Close() - return nil, errors.New("QUIC with sockopt is unsupported").AtWarning() - } - - sysConn, err := wrapSysConn(udpConn, config) - if err != nil { - rawConn.Close() - return nil, err - } - tr := quic.Transport{ - ConnectionIDLength: 12, - Conn: sysConn, - } - conn, err := tr.Dial(context.Background(), destAddr, tlsConfig.GetTLSConfig(tls.WithDestination(dest)), quicConfig) - if err != nil { - sysConn.Close() - return nil, err - } - - context := &connectionContext{ - conn: conn, - rawConn: sysConn, - } - s.conns[dest] = append(conns, context) - return context.openStream(destAddr) -} - -var client clientConnections - -func init() { - client.conns = make(map[net.Destination][]*connectionContext) - client.cleanup = &task.Periodic{ - Interval: time.Minute, - Execute: client.cleanConnections, - } - common.Must(client.cleanup.Start()) -} - -func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) { - tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - if tlsConfig == nil { - tlsConfig = &tls.Config{ - ServerName: internalDomain, - AllowInsecure: true, - } - } - - var destAddr *net.UDPAddr - if dest.Address.Family().IsIP() { - destAddr = &net.UDPAddr{ - IP: dest.Address.IP(), - Port: int(dest.Port), - } - } else { - dialerIp := internet.DestIpAddress() - if dialerIp != nil { - destAddr = &net.UDPAddr{ - IP: dialerIp, - Port: int(dest.Port), - } - errors.LogInfo(ctx, "quic Dial use dialer dest addr: ", destAddr) - } else { - addr, err := net.ResolveUDPAddr("udp", dest.NetAddr()) - if err != nil { - return nil, err - } - destAddr = addr - } - } - - config := streamSettings.ProtocolSettings.(*Config) - - return client.openConnection(ctx, destAddr, config, tlsConfig, streamSettings.SocketSettings) -} - -func init() { - common.Must(internet.RegisterTransportDialer(protocolName, Dial)) -} diff --git a/transport/internet/quic/hub.go b/transport/internet/quic/hub.go deleted file mode 100644 index de8919fd..00000000 --- a/transport/internet/quic/hub.go +++ /dev/null @@ -1,146 +0,0 @@ -package quic - -import ( - "context" - "time" - - "github.com/quic-go/quic-go" - "github.com/quic-go/quic-go/logging" - "github.com/quic-go/quic-go/qlog" - "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/common/protocol/tls/cert" - "github.com/xtls/xray-core/common/signal/done" - "github.com/xtls/xray-core/transport/internet" - "github.com/xtls/xray-core/transport/internet/tls" -) - -// Listener is an internet.Listener that listens for TCP connections. -type Listener struct { - rawConn *sysConn - listener *quic.Listener - done *done.Instance - addConn internet.ConnHandler -} - -func (l *Listener) acceptStreams(conn quic.Connection) { - for { - stream, err := conn.AcceptStream(context.Background()) - if err != nil { - errors.LogInfoInner(context.Background(), err, "failed to accept stream") - select { - case <-conn.Context().Done(): - return - case <-l.done.Wait(): - if err := conn.CloseWithError(0, ""); err != nil { - errors.LogInfoInner(context.Background(), err, "failed to close connection") - } - return - default: - time.Sleep(time.Second) - continue - } - } - - conn := &interConn{ - stream: stream, - local: conn.LocalAddr(), - remote: conn.RemoteAddr(), - } - - l.addConn(conn) - } -} - -func (l *Listener) keepAccepting() { - for { - conn, err := l.listener.Accept(context.Background()) - if err != nil { - errors.LogInfoInner(context.Background(), err, "failed to accept QUIC connection") - if l.done.Done() { - break - } - time.Sleep(time.Second) - continue - } - go l.acceptStreams(conn) - } -} - -// Addr implements internet.Listener.Addr. -func (l *Listener) Addr() net.Addr { - return l.listener.Addr() -} - -// Close implements internet.Listener.Close. -func (l *Listener) Close() error { - l.done.Close() - l.listener.Close() - l.rawConn.Close() - return nil -} - -// Listen creates a new Listener based on configurations. -func Listen(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, handler internet.ConnHandler) (internet.Listener, error) { - if address.Family().IsDomain() { - return nil, errors.New("domain address is not allows for listening quic") - } - - tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - if tlsConfig == nil { - tlsConfig = &tls.Config{ - Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.DNSNames(internalDomain), cert.CommonName(internalDomain)))}, - } - } - - config := streamSettings.ProtocolSettings.(*Config) - rawConn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{ - IP: address.IP(), - Port: int(port), - }, streamSettings.SocketSettings) - if err != nil { - return nil, err - } - - quicConfig := &quic.Config{ - KeepAlivePeriod: 0, - HandshakeIdleTimeout: time.Second * 8, - MaxIdleTimeout: time.Second * 300, - MaxIncomingStreams: 32, - MaxIncomingUniStreams: -1, - Tracer: func(ctx context.Context, p logging.Perspective, ci quic.ConnectionID) *logging.ConnectionTracer { - return qlog.NewConnectionTracer(&QlogWriter{connID: ci}, p, ci) - }, - } - - conn, err := wrapSysConn(rawConn.(*net.UDPConn), config) - if err != nil { - conn.Close() - return nil, err - } - tr := quic.Transport{ - ConnectionIDLength: 12, - Conn: conn, - } - qListener, err := tr.Listen(tlsConfig.GetTLSConfig(), quicConfig) - if err != nil { - conn.Close() - return nil, err - } - - listener := &Listener{ - done: done.New(), - rawConn: conn, - listener: qListener, - addConn: handler, - } - - go listener.keepAccepting() - - return listener, nil -} - -func init() { - common.Must(internet.RegisterTransportListener(protocolName, Listen)) -} diff --git a/transport/internet/quic/pool.go b/transport/internet/quic/pool.go deleted file mode 100644 index 7309147f..00000000 --- a/transport/internet/quic/pool.go +++ /dev/null @@ -1,21 +0,0 @@ -package quic - -import ( - "sync" - - "github.com/xtls/xray-core/common/bytespool" -) - -var pool *sync.Pool - -func init() { - pool = bytespool.GetPool(2048) -} - -func getBuffer() []byte { - return pool.Get().([]byte) -} - -func putBuffer(p []byte) { - pool.Put(p) -} diff --git a/transport/internet/quic/qlogWriter.go b/transport/internet/quic/qlogWriter.go deleted file mode 100644 index 54284d29..00000000 --- a/transport/internet/quic/qlogWriter.go +++ /dev/null @@ -1,24 +0,0 @@ -package quic - -import "github.com/quic-go/quic-go" - -type QlogWriter struct { - connID quic.ConnectionID -} - -func (w *QlogWriter) Write(b []byte) (int, error) { - // to much log, only turn on when debug Quic - - // if len(b) > 1 { // skip line separator "0a" in qlog - // log.Record(&log.GeneralMessage{ - // Severity: log.Severity_Debug, - // Content: fmt.Sprintf("[%x] %s", w.connID, b), - // }) - // } - return len(b), nil -} - -func (w *QlogWriter) Close() error { - // Noop - return nil -} diff --git a/transport/internet/quic/quic.go b/transport/internet/quic/quic.go deleted file mode 100644 index fe462139..00000000 --- a/transport/internet/quic/quic.go +++ /dev/null @@ -1,25 +0,0 @@ -package quic - -import ( - "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/transport/internet" -) - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - -// Here is some modification needs to be done before update quic vendor. -// * use bytespool in buffer_pool.go -// * set MaxReceivePacketSize to 1452 - 32 (16 bytes auth, 16 bytes head) -// -// - -const ( - protocolName = "quic" - internalDomain = "quic.internal.example.com" -) - -func init() { - common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { - return new(Config) - })) -} diff --git a/transport/internet/quic/quic_test.go b/transport/internet/quic/quic_test.go deleted file mode 100644 index ab071058..00000000 --- a/transport/internet/quic/quic_test.go +++ /dev/null @@ -1,223 +0,0 @@ -package quic_test - -import ( - "context" - "crypto/rand" - "testing" - "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" - "github.com/xtls/xray-core/common/protocol" - "github.com/xtls/xray-core/common/protocol/tls/cert" - "github.com/xtls/xray-core/common/serial" - "github.com/xtls/xray-core/testing/servers/udp" - "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" -) - -func TestQuicConnection(t *testing.T) { - port := udp.PickPort() - - listener, err := quic.Listen(context.Background(), net.LocalHostIP, port, &internet.MemoryStreamConfig{ - ProtocolName: "quic", - ProtocolSettings: &quic.Config{}, - SecurityType: "tls", - SecuritySettings: &tls.Config{ - Certificate: []*tls.Certificate{ - tls.ParseCertificate( - cert.MustGenerate(nil, - cert.DNSNames("www.example.com"), - ), - ), - }, - }, - }, func(conn stat.Connection) { - go func() { - defer conn.Close() - - b := buf.New() - defer b.Release() - - for { - b.Clear() - if _, err := b.ReadFrom(conn); err != nil { - return - } - common.Must2(conn.Write(b.Bytes())) - } - }() - }) - common.Must(err) - - defer listener.Close() - - time.Sleep(time.Second) - - dctx := context.Background() - conn, err := quic.Dial(dctx, net.TCPDestination(net.LocalHostIP, port), &internet.MemoryStreamConfig{ - ProtocolName: "quic", - ProtocolSettings: &quic.Config{}, - SecurityType: "tls", - SecuritySettings: &tls.Config{ - ServerName: "www.example.com", - AllowInsecure: true, - }, - }) - common.Must(err) - defer conn.Close() - - const N = 1024 - b1 := make([]byte, N) - common.Must2(rand.Read(b1)) - b2 := buf.New() - - common.Must2(conn.Write(b1)) - - b2.Clear() - common.Must2(b2.ReadFullFrom(conn, N)) - if r := cmp.Diff(b2.Bytes(), b1); r != "" { - t.Error(r) - } - - common.Must2(conn.Write(b1)) - - b2.Clear() - common.Must2(b2.ReadFullFrom(conn, N)) - if r := cmp.Diff(b2.Bytes(), b1); r != "" { - t.Error(r) - } -} - -func TestQuicConnectionWithoutTLS(t *testing.T) { - port := udp.PickPort() - - listener, err := quic.Listen(context.Background(), net.LocalHostIP, port, &internet.MemoryStreamConfig{ - ProtocolName: "quic", - ProtocolSettings: &quic.Config{}, - }, func(conn stat.Connection) { - go func() { - defer conn.Close() - - b := buf.New() - defer b.Release() - - for { - b.Clear() - if _, err := b.ReadFrom(conn); err != nil { - return - } - common.Must2(conn.Write(b.Bytes())) - } - }() - }) - common.Must(err) - - defer listener.Close() - - time.Sleep(time.Second) - - dctx := context.Background() - conn, err := quic.Dial(dctx, net.TCPDestination(net.LocalHostIP, port), &internet.MemoryStreamConfig{ - ProtocolName: "quic", - ProtocolSettings: &quic.Config{}, - }) - common.Must(err) - defer conn.Close() - - const N = 1024 - b1 := make([]byte, N) - common.Must2(rand.Read(b1)) - b2 := buf.New() - - common.Must2(conn.Write(b1)) - - b2.Clear() - common.Must2(b2.ReadFullFrom(conn, N)) - if r := cmp.Diff(b2.Bytes(), b1); r != "" { - t.Error(r) - } - - common.Must2(conn.Write(b1)) - - b2.Clear() - common.Must2(b2.ReadFullFrom(conn, N)) - if r := cmp.Diff(b2.Bytes(), b1); r != "" { - t.Error(r) - } -} - -func TestQuicConnectionAuthHeader(t *testing.T) { - port := udp.PickPort() - - listener, err := quic.Listen(context.Background(), net.LocalHostIP, port, &internet.MemoryStreamConfig{ - ProtocolName: "quic", - ProtocolSettings: &quic.Config{ - Header: serial.ToTypedMessage(&wireguard.WireguardConfig{}), - Key: "abcd", - Security: &protocol.SecurityConfig{ - Type: protocol.SecurityType_AES128_GCM, - }, - }, - }, func(conn stat.Connection) { - go func() { - defer conn.Close() - - b := buf.New() - defer b.Release() - - for { - b.Clear() - if _, err := b.ReadFrom(conn); err != nil { - return - } - common.Must2(conn.Write(b.Bytes())) - } - }() - }) - common.Must(err) - - defer listener.Close() - - time.Sleep(time.Second) - - dctx := context.Background() - conn, err := quic.Dial(dctx, net.TCPDestination(net.LocalHostIP, port), &internet.MemoryStreamConfig{ - ProtocolName: "quic", - ProtocolSettings: &quic.Config{ - Header: serial.ToTypedMessage(&wireguard.WireguardConfig{}), - Key: "abcd", - Security: &protocol.SecurityConfig{ - Type: protocol.SecurityType_AES128_GCM, - }, - }, - }) - common.Must(err) - defer conn.Close() - - const N = 1024 - b1 := make([]byte, N) - common.Must2(rand.Read(b1)) - b2 := buf.New() - - common.Must2(conn.Write(b1)) - - b2.Clear() - common.Must2(b2.ReadFullFrom(conn, N)) - if r := cmp.Diff(b2.Bytes(), b1); r != "" { - t.Error(r) - } - - common.Must2(conn.Write(b1)) - - b2.Clear() - common.Must2(b2.ReadFullFrom(conn, N)) - if r := cmp.Diff(b2.Bytes(), b1); r != "" { - t.Error(r) - } -} From c0a98f74fc9bc9ff2fcbc27903a942600d4fb220 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Tue, 3 Sep 2024 13:36:11 +0200 Subject: [PATCH 515/867] Transport: Remove DomainSocket (#3757) https://github.com/XTLS/Xray-core/pull/3755#issuecomment-2325533003 --- infra/conf/transport.go | 12 -- infra/conf/transport_internet.go | 33 +--- infra/conf/xray.go | 3 - main/distro/all/all.go | 1 - testing/scenarios/transport_test.go | 117 ------------ transport/internet/config.go | 2 - transport/internet/config.pb.go | 74 ++++--- transport/internet/config.proto | 1 - transport/internet/domainsocket/config.go | 39 ---- transport/internet/domainsocket/config.pb.go | 180 ------------------ transport/internet/domainsocket/config.proto | 20 -- transport/internet/domainsocket/dial.go | 41 ---- transport/internet/domainsocket/errgen.go | 3 - transport/internet/domainsocket/listener.go | 141 -------------- .../internet/domainsocket/listener_test.go | 94 --------- 15 files changed, 37 insertions(+), 724 deletions(-) delete mode 100644 transport/internet/domainsocket/config.go delete mode 100644 transport/internet/domainsocket/config.pb.go delete mode 100644 transport/internet/domainsocket/config.proto delete mode 100644 transport/internet/domainsocket/dial.go delete mode 100644 transport/internet/domainsocket/errgen.go delete mode 100644 transport/internet/domainsocket/listener.go delete mode 100644 transport/internet/domainsocket/listener_test.go diff --git a/infra/conf/transport.go b/infra/conf/transport.go index 5577e823..7957ee7d 100644 --- a/infra/conf/transport.go +++ b/infra/conf/transport.go @@ -12,7 +12,6 @@ type TransportConfig struct { KCPConfig *KCPConfig `json:"kcpSettings"` WSConfig *WebSocketConfig `json:"wsSettings"` HTTPConfig *HTTPConfig `json:"httpSettings"` - DSConfig *DomainSocketConfig `json:"dsSettings"` GRPCConfig *GRPCConfig `json:"grpcSettings"` GUNConfig *GRPCConfig `json:"gunSettings"` HTTPUPGRADEConfig *HttpUpgradeConfig `json:"httpupgradeSettings"` @@ -67,17 +66,6 @@ func (c *TransportConfig) Build() (*global.Config, error) { }) } - if c.DSConfig != nil { - ds, err := c.DSConfig.Build() - if err != nil { - return nil, errors.New("Failed to build DomainSocket config.").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "domainsocket", - Settings: serial.ToTypedMessage(ds), - }) - } - if c.GRPCConfig == nil { c.GRPCConfig = c.GUNConfig } diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 8e84d0f3..8cc057a8 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -16,7 +16,6 @@ import ( "github.com/xtls/xray-core/common/platform/filesystem" "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/transport/internet" - "github.com/xtls/xray-core/transport/internet/domainsocket" httpheader "github.com/xtls/xray-core/transport/internet/headers/http" "github.com/xtls/xray-core/transport/internet/http" "github.com/xtls/xray-core/transport/internet/httpupgrade" @@ -313,21 +312,6 @@ func (c *HTTPConfig) Build() (proto.Message, error) { return config, nil } -type DomainSocketConfig struct { - Path string `json:"path"` - Abstract bool `json:"abstract"` - Padding bool `json:"padding"` -} - -// Build implements Buildable. -func (c *DomainSocketConfig) Build() (proto.Message, error) { - return &domainsocket.Config{ - Path: c.Path, - Abstract: c.Abstract, - Padding: c.Padding, - }, nil -} - func readFileOrString(f string, s []string) ([]byte, error) { if len(f) > 0 { return filesystem.ReadFile(f) @@ -646,8 +630,6 @@ func (p TransportProtocol) Build() (string, error) { return "websocket", nil case "h2", "http": return "http", nil - case "ds", "domainsocket": - return "domainsocket", nil case "grpc", "gun": return "grpc", nil case "httpupgrade": @@ -783,7 +765,6 @@ type StreamConfig struct { KCPSettings *KCPConfig `json:"kcpSettings"` WSSettings *WebSocketConfig `json:"wsSettings"` HTTPSettings *HTTPConfig `json:"httpSettings"` - DSSettings *DomainSocketConfig `json:"dsSettings"` SocketSettings *SocketConfig `json:"sockopt"` GRPCConfig *GRPCConfig `json:"grpcSettings"` GUNConfig *GRPCConfig `json:"gunSettings"` @@ -818,8 +799,8 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { config.SecuritySettings = append(config.SecuritySettings, tm) config.SecurityType = tm.Type case "reality": - if config.ProtocolName != "tcp" && config.ProtocolName != "http" && config.ProtocolName != "grpc" && config.ProtocolName != "domainsocket" { - return nil, errors.New("REALITY only supports TCP, H2, gRPC and DomainSocket for now.") + if config.ProtocolName != "tcp" && config.ProtocolName != "http" && config.ProtocolName != "grpc" { + return nil, errors.New("REALITY only supports TCP, H2 and gRPC for now.") } if c.REALITYSettings == nil { return nil, errors.New(`REALITY: Empty "realitySettings".`) @@ -876,16 +857,6 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { Settings: serial.ToTypedMessage(ts), }) } - if c.DSSettings != nil { - ds, err := c.DSSettings.Build() - if err != nil { - return nil, errors.New("Failed to build DomainSocket config.").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "domainsocket", - Settings: serial.ToTypedMessage(ds), - }) - } if c.GRPCConfig == nil { c.GRPCConfig = c.GUNConfig } diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 29616ef3..9488589c 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -553,9 +553,6 @@ func applyTransportConfig(s *StreamConfig, t *TransportConfig) { if s.HTTPSettings == nil { s.HTTPSettings = t.HTTPConfig } - if s.DSSettings == nil { - s.DSSettings = t.DSConfig - } if s.HTTPUPGRADESettings == nil { s.HTTPUPGRADESettings = t.HTTPUPGRADEConfig } diff --git a/main/distro/all/all.go b/main/distro/all/all.go index 56ae664b..4e9ac3c0 100644 --- a/main/distro/all/all.go +++ b/main/distro/all/all.go @@ -50,7 +50,6 @@ import ( _ "github.com/xtls/xray-core/proxy/wireguard" // Transports - _ "github.com/xtls/xray-core/transport/internet/domainsocket" _ "github.com/xtls/xray-core/transport/internet/grpc" _ "github.com/xtls/xray-core/transport/internet/http" _ "github.com/xtls/xray-core/transport/internet/httpupgrade" diff --git a/testing/scenarios/transport_test.go b/testing/scenarios/transport_test.go index d6abbebd..ac9db7ac 100644 --- a/testing/scenarios/transport_test.go +++ b/testing/scenarios/transport_test.go @@ -1,8 +1,6 @@ package scenarios import ( - "os" - "runtime" "testing" "time" @@ -20,7 +18,6 @@ import ( "github.com/xtls/xray-core/proxy/vmess/outbound" "github.com/xtls/xray-core/testing/servers/tcp" "github.com/xtls/xray-core/transport/internet" - "github.com/xtls/xray-core/transport/internet/domainsocket" "github.com/xtls/xray-core/transport/internet/headers/http" tcptransport "github.com/xtls/xray-core/transport/internet/tcp" ) @@ -128,117 +125,3 @@ func TestHTTPConnectionHeader(t *testing.T) { t.Error(err) } } - -func TestDomainSocket(t *testing.T) { - if runtime.GOOS == "windows" || runtime.GOOS == "android" { - t.Skip("Not supported on windows or android") - return - } - tcpServer := tcp.Server{ - MsgProcessor: xor, - } - dest, err := tcpServer.Start() - common.Must(err) - defer tcpServer.Close() - - const dsPath = "/tmp/ds_scenario" - os.Remove(dsPath) - - userID := protocol.NewID(uuid.New()) - serverPort := tcp.PickPort() - serverConfig := &core.Config{ - Inbound: []*core.InboundHandlerConfig{ - { - ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ - PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, - Listen: net.NewIPOrDomain(net.LocalHostIP), - StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_DomainSocket, - TransportSettings: []*internet.TransportConfig{ - { - Protocol: internet.TransportProtocol_DomainSocket, - Settings: serial.ToTypedMessage(&domainsocket.Config{ - Path: dsPath, - }), - }, - }, - }, - }), - ProxySettings: serial.ToTypedMessage(&inbound.Config{ - User: []*protocol.User{ - { - Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - }), - }, - }, - }), - }, - }, - Outbound: []*core.OutboundHandlerConfig{ - { - ProxySettings: serial.ToTypedMessage(&freedom.Config{}), - }, - }, - } - - clientPort := tcp.PickPort() - clientConfig := &core.Config{ - Inbound: []*core.InboundHandlerConfig{ - { - ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ - PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, - Listen: net.NewIPOrDomain(net.LocalHostIP), - }), - ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(dest.Address), - Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, - }), - }, - }, - Outbound: []*core.OutboundHandlerConfig{ - { - ProxySettings: serial.ToTypedMessage(&outbound.Config{ - Receiver: []*protocol.ServerEndpoint{ - { - Address: net.NewIPOrDomain(net.LocalHostIP), - Port: uint32(serverPort), - User: []*protocol.User{ - { - Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - }), - }, - }, - }, - }, - }), - SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ - StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_DomainSocket, - TransportSettings: []*internet.TransportConfig{ - { - Protocol: internet.TransportProtocol_DomainSocket, - Settings: serial.ToTypedMessage(&domainsocket.Config{ - Path: dsPath, - }), - }, - }, - }, - }), - }, - }, - } - - servers, err := InitializeServerConfigs(serverConfig, clientConfig) - common.Must(err) - defer CloseAllServers(servers) - - if err := testTCPConn(clientPort, 1024, time.Second*2)(); err != nil { - t.Error(err) - } -} - diff --git a/transport/internet/config.go b/transport/internet/config.go index 80353f39..5968b564 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -42,8 +42,6 @@ func transportProtocolToString(protocol TransportProtocol) string { return "mkcp" case TransportProtocol_WebSocket: return "websocket" - case TransportProtocol_DomainSocket: - return "domainsocket" case TransportProtocol_HTTPUpgrade: return "httpupgrade" default: diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 6c71bcc3..2cbe7fac 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -24,14 +24,13 @@ const ( type TransportProtocol int32 const ( - TransportProtocol_TCP TransportProtocol = 0 - TransportProtocol_UDP TransportProtocol = 1 - TransportProtocol_MKCP TransportProtocol = 2 - TransportProtocol_WebSocket TransportProtocol = 3 - TransportProtocol_HTTP TransportProtocol = 4 - TransportProtocol_DomainSocket TransportProtocol = 5 - TransportProtocol_HTTPUpgrade TransportProtocol = 6 - TransportProtocol_SplitHTTP TransportProtocol = 7 + TransportProtocol_TCP TransportProtocol = 0 + TransportProtocol_UDP TransportProtocol = 1 + TransportProtocol_MKCP TransportProtocol = 2 + TransportProtocol_WebSocket TransportProtocol = 3 + TransportProtocol_HTTP TransportProtocol = 4 + TransportProtocol_HTTPUpgrade TransportProtocol = 6 + TransportProtocol_SplitHTTP TransportProtocol = 7 ) // Enum value maps for TransportProtocol. @@ -42,19 +41,17 @@ var ( 2: "MKCP", 3: "WebSocket", 4: "HTTP", - 5: "DomainSocket", 6: "HTTPUpgrade", 7: "SplitHTTP", } TransportProtocol_value = map[string]int32{ - "TCP": 0, - "UDP": 1, - "MKCP": 2, - "WebSocket": 3, - "HTTP": 4, - "DomainSocket": 5, - "HTTPUpgrade": 6, - "SplitHTTP": 7, + "TCP": 0, + "UDP": 1, + "MKCP": 2, + "WebSocket": 3, + "HTTP": 4, + "HTTPUpgrade": 6, + "SplitHTTP": 7, } ) @@ -821,32 +818,31 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x7a, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x68, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, 0x62, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, - 0x04, 0x12, 0x10, 0x0a, 0x0c, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, 0x6b, 0x65, - 0x74, 0x10, 0x05, 0x12, 0x0f, 0x0a, 0x0b, 0x48, 0x54, 0x54, 0x50, 0x55, 0x70, 0x67, 0x72, 0x61, - 0x64, 0x65, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x54, 0x54, - 0x50, 0x10, 0x07, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, - 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, - 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, - 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, - 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, - 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, - 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, - 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, - 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, - 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, - 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, - 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, - 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x04, 0x12, 0x0f, 0x0a, 0x0b, 0x48, 0x54, 0x54, 0x50, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, + 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x54, 0x54, 0x50, 0x10, + 0x07, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, + 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, + 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, + 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, + 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, + 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, + 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, + 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, + 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, + 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, 0x67, 0x0a, + 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, + 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, + 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/config.proto b/transport/internet/config.proto index b0a63524..cab6162c 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -14,7 +14,6 @@ enum TransportProtocol { MKCP = 2; WebSocket = 3; HTTP = 4; - DomainSocket = 5; HTTPUpgrade = 6; SplitHTTP = 7; } diff --git a/transport/internet/domainsocket/config.go b/transport/internet/domainsocket/config.go deleted file mode 100644 index 7f80a595..00000000 --- a/transport/internet/domainsocket/config.go +++ /dev/null @@ -1,39 +0,0 @@ -package domainsocket - -import ( - "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" -) - -const ( - protocolName = "domainsocket" - sizeofSunPath = 108 -) - -func (c *Config) GetUnixAddr() (*net.UnixAddr, error) { - path := c.Path - if path == "" { - return nil, errors.New("empty domain socket path") - } - if c.Abstract && path[0] != '@' { - path = "@" + path - } - if c.Abstract && c.Padding { - raw := []byte(path) - addr := make([]byte, sizeofSunPath) - copy(addr, raw) - path = string(addr) - } - return &net.UnixAddr{ - Name: path, - Net: "unix", - }, nil -} - -func init() { - common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { - return new(Config) - })) -} diff --git a/transport/internet/domainsocket/config.pb.go b/transport/internet/domainsocket/config.pb.go deleted file mode 100644 index dc9f5371..00000000 --- a/transport/internet/domainsocket/config.pb.go +++ /dev/null @@ -1,180 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 -// source: transport/internet/domainsocket/config.proto - -package domainsocket - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Config struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // Path of the domain socket. This overrides the IP/Port parameter from - // upstream caller. - Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` - // Abstract specifies whether to use abstract namespace or not. - // Traditionally Unix domain socket is file system based. Abstract domain - // socket can be used without acquiring file lock. - Abstract bool `protobuf:"varint,2,opt,name=abstract,proto3" json:"abstract,omitempty"` - // Some apps, eg. haproxy, use the full length of sockaddr_un.sun_path to - // connect(2) or bind(2) when using abstract UDS. - Padding bool `protobuf:"varint,3,opt,name=padding,proto3" json:"padding,omitempty"` -} - -func (x *Config) Reset() { - *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_domainsocket_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Config) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Config) ProtoMessage() {} - -func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_transport_internet_domainsocket_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Config.ProtoReflect.Descriptor instead. -func (*Config) Descriptor() ([]byte, []int) { - return file_transport_internet_domainsocket_config_proto_rawDescGZIP(), []int{0} -} - -func (x *Config) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *Config) GetAbstract() bool { - if x != nil { - return x.Abstract - } - return false -} - -func (x *Config) GetPadding() bool { - if x != nil { - return x.Padding - } - return false -} - -var File_transport_internet_domainsocket_config_proto protoreflect.FileDescriptor - -var file_transport_internet_domainsocket_config_proto_rawDesc = []byte{ - 0x0a, 0x2c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x6f, 0x63, 0x6b, 0x65, - 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x24, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x6f, - 0x63, 0x6b, 0x65, 0x74, 0x22, 0x52, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, - 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x62, 0x73, 0x74, 0x72, 0x61, 0x63, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x62, 0x73, 0x74, 0x72, 0x61, 0x63, 0x74, 0x12, 0x18, - 0x0a, 0x07, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x07, 0x70, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x8e, 0x01, 0x0a, 0x28, 0x63, 0x6f, 0x6d, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, - 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, - 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x73, 0x6f, 0x63, 0x6b, - 0x65, 0x74, 0xaa, 0x02, 0x24, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x44, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} - -var ( - file_transport_internet_domainsocket_config_proto_rawDescOnce sync.Once - file_transport_internet_domainsocket_config_proto_rawDescData = file_transport_internet_domainsocket_config_proto_rawDesc -) - -func file_transport_internet_domainsocket_config_proto_rawDescGZIP() []byte { - file_transport_internet_domainsocket_config_proto_rawDescOnce.Do(func() { - file_transport_internet_domainsocket_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_internet_domainsocket_config_proto_rawDescData) - }) - return file_transport_internet_domainsocket_config_proto_rawDescData -} - -var file_transport_internet_domainsocket_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_domainsocket_config_proto_goTypes = []any{ - (*Config)(nil), // 0: xray.transport.internet.domainsocket.Config -} -var file_transport_internet_domainsocket_config_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_transport_internet_domainsocket_config_proto_init() } -func file_transport_internet_domainsocket_config_proto_init() { - if File_transport_internet_domainsocket_config_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_transport_internet_domainsocket_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_transport_internet_domainsocket_config_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_transport_internet_domainsocket_config_proto_goTypes, - DependencyIndexes: file_transport_internet_domainsocket_config_proto_depIdxs, - MessageInfos: file_transport_internet_domainsocket_config_proto_msgTypes, - }.Build() - File_transport_internet_domainsocket_config_proto = out.File - file_transport_internet_domainsocket_config_proto_rawDesc = nil - file_transport_internet_domainsocket_config_proto_goTypes = nil - file_transport_internet_domainsocket_config_proto_depIdxs = nil -} diff --git a/transport/internet/domainsocket/config.proto b/transport/internet/domainsocket/config.proto deleted file mode 100644 index dafb9bc6..00000000 --- a/transport/internet/domainsocket/config.proto +++ /dev/null @@ -1,20 +0,0 @@ -syntax = "proto3"; - -package xray.transport.internet.domainsocket; -option csharp_namespace = "Xray.Transport.Internet.DomainSocket"; -option go_package = "github.com/xtls/xray-core/transport/internet/domainsocket"; -option java_package = "com.xray.transport.internet.domainsocket"; -option java_multiple_files = true; - -message Config { - // Path of the domain socket. This overrides the IP/Port parameter from - // upstream caller. - string path = 1; - // Abstract specifies whether to use abstract namespace or not. - // Traditionally Unix domain socket is file system based. Abstract domain - // socket can be used without acquiring file lock. - bool abstract = 2; - // Some apps, eg. haproxy, use the full length of sockaddr_un.sun_path to - // connect(2) or bind(2) when using abstract UDS. - bool padding = 3; -} diff --git a/transport/internet/domainsocket/dial.go b/transport/internet/domainsocket/dial.go deleted file mode 100644 index a060da78..00000000 --- a/transport/internet/domainsocket/dial.go +++ /dev/null @@ -1,41 +0,0 @@ -//go:build !windows && !wasm -// +build !windows,!wasm - -package domainsocket - -import ( - "context" - - "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/reality" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/transport/internet/tls" -) - -func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) { - settings := streamSettings.ProtocolSettings.(*Config) - addr, err := settings.GetUnixAddr() - if err != nil { - return nil, err - } - - conn, err := net.DialUnix("unix", nil, addr) - if err != nil { - return nil, errors.New("failed to dial unix: ", settings.Path).Base(err).AtWarning() - } - - if config := tls.ConfigFromStreamSettings(streamSettings); config != nil { - return tls.Client(conn, config.GetTLSConfig(tls.WithDestination(dest))), nil - } else if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { - return reality.UClient(conn, config, ctx, dest) - } - - return conn, nil -} - -func init() { - common.Must(internet.RegisterTransportDialer(protocolName, Dial)) -} diff --git a/transport/internet/domainsocket/errgen.go b/transport/internet/domainsocket/errgen.go deleted file mode 100644 index 83ac04d0..00000000 --- a/transport/internet/domainsocket/errgen.go +++ /dev/null @@ -1,3 +0,0 @@ -package domainsocket - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/transport/internet/domainsocket/listener.go b/transport/internet/domainsocket/listener.go deleted file mode 100644 index 0b19c681..00000000 --- a/transport/internet/domainsocket/listener.go +++ /dev/null @@ -1,141 +0,0 @@ -//go:build !windows && !wasm -// +build !windows,!wasm - -package domainsocket - -import ( - "context" - gotls "crypto/tls" - "os" - "strings" - - goreality "github.com/xtls/reality" - "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/reality" - "github.com/xtls/xray-core/transport/internet/stat" - "github.com/xtls/xray-core/transport/internet/tls" - "golang.org/x/sys/unix" -) - -type Listener struct { - addr *net.UnixAddr - ln net.Listener - tlsConfig *gotls.Config - realityConfig *goreality.Config - config *Config - addConn internet.ConnHandler - locker *fileLocker -} - -func Listen(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, handler internet.ConnHandler) (internet.Listener, error) { - settings := streamSettings.ProtocolSettings.(*Config) - addr, err := settings.GetUnixAddr() - if err != nil { - return nil, err - } - - unixListener, err := net.ListenUnix("unix", addr) - if err != nil { - return nil, errors.New("failed to listen domain socket").Base(err).AtWarning() - } - - ln := &Listener{ - addr: addr, - ln: unixListener, - config: settings, - addConn: handler, - } - - if !settings.Abstract { - ln.locker = &fileLocker{ - path: settings.Path + ".lock", - } - if err := ln.locker.Acquire(); err != nil { - unixListener.Close() - return nil, err - } - } - - if config := tls.ConfigFromStreamSettings(streamSettings); config != nil { - ln.tlsConfig = config.GetTLSConfig() - } - if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { - ln.realityConfig = config.GetREALITYConfig() - } - - go ln.run() - - return ln, nil -} - -func (ln *Listener) Addr() net.Addr { - return ln.addr -} - -func (ln *Listener) Close() error { - if ln.locker != nil { - ln.locker.Release() - } - return ln.ln.Close() -} - -func (ln *Listener) run() { - for { - conn, err := ln.ln.Accept() - if err != nil { - if strings.Contains(err.Error(), "closed") { - break - } - errors.LogWarningInner(context.Background(), err, "failed to accepted raw connections") - continue - } - go func() { - if ln.tlsConfig != nil { - conn = tls.Server(conn, ln.tlsConfig) - } else if ln.realityConfig != nil { - if conn, err = reality.Server(conn, ln.realityConfig); err != nil { - errors.LogInfo(context.Background(), err.Error()) - return - } - } - ln.addConn(stat.Connection(conn)) - }() - } -} - -type fileLocker struct { - path string - file *os.File -} - -func (fl *fileLocker) Acquire() error { - f, err := os.Create(fl.path) - if err != nil { - return err - } - if err := unix.Flock(int(f.Fd()), unix.LOCK_EX); err != nil { - f.Close() - return errors.New("failed to lock file: ", fl.path).Base(err) - } - fl.file = f - return nil -} - -func (fl *fileLocker) Release() { - if err := unix.Flock(int(fl.file.Fd()), unix.LOCK_UN); err != nil { - errors.LogInfoInner(context.Background(), err, "failed to unlock file: ", fl.path) - } - if err := fl.file.Close(); err != nil { - errors.LogInfoInner(context.Background(), err, "failed to close file: ", fl.path) - } - if err := os.Remove(fl.path); err != nil { - errors.LogInfoInner(context.Background(), err, "failed to remove file: ", fl.path) - } -} - -func init() { - common.Must(internet.RegisterTransportListener(protocolName, Listen)) -} diff --git a/transport/internet/domainsocket/listener_test.go b/transport/internet/domainsocket/listener_test.go deleted file mode 100644 index 308fa07b..00000000 --- a/transport/internet/domainsocket/listener_test.go +++ /dev/null @@ -1,94 +0,0 @@ -//go:build !windows && !android -// +build !windows,!android - -package domainsocket_test - -import ( - "context" - "runtime" - "testing" - - "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) { - ctx := context.Background() - streamSettings := &internet.MemoryStreamConfig{ - ProtocolName: "domainsocket", - ProtocolSettings: &Config{ - Path: "/tmp/ts3", - }, - } - listener, err := Listen(ctx, nil, net.Port(0), streamSettings, func(conn stat.Connection) { - defer conn.Close() - - b := buf.New() - defer b.Release() - common.Must2(b.ReadFrom(conn)) - b.WriteString("Response") - - common.Must2(conn.Write(b.Bytes())) - }) - common.Must(err) - defer listener.Close() - - conn, err := Dial(ctx, net.Destination{}, streamSettings) - common.Must(err) - defer conn.Close() - - common.Must2(conn.Write([]byte("Request"))) - - b := buf.New() - defer b.Release() - common.Must2(b.ReadFrom(conn)) - - if b.String() != "RequestResponse" { - t.Error("expected response as 'RequestResponse' but got ", b.String()) - } -} - -func TestListenAbstract(t *testing.T) { - if runtime.GOOS != "linux" { - return - } - - ctx := context.Background() - streamSettings := &internet.MemoryStreamConfig{ - ProtocolName: "domainsocket", - ProtocolSettings: &Config{ - Path: "/tmp/ts3", - Abstract: true, - }, - } - listener, err := Listen(ctx, nil, net.Port(0), streamSettings, func(conn stat.Connection) { - defer conn.Close() - - b := buf.New() - defer b.Release() - common.Must2(b.ReadFrom(conn)) - b.WriteString("Response") - - common.Must2(conn.Write(b.Bytes())) - }) - common.Must(err) - defer listener.Close() - - conn, err := Dial(ctx, net.Destination{}, streamSettings) - common.Must(err) - defer conn.Close() - - common.Must2(conn.Write([]byte("Request"))) - - b := buf.New() - defer b.Release() - common.Must2(b.ReadFrom(conn)) - - if b.String() != "RequestResponse" { - t.Error("expected response as 'RequestResponse' but got ", b.String()) - } -} From f357245f939a46ef8ed83f34ebed09fc7f06ad5b Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Fri, 6 Sep 2024 06:31:26 +0800 Subject: [PATCH 516/867] Config: Remove global `transport` (#3751) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/XTLS/Xray-core/pull/3751#issuecomment-2329564039 --------- Co-authored-by: 风扇滑翔翼 --- infra/conf/transport.go | 106 -------------------------- infra/conf/transport_test.go | 144 ----------------------------------- infra/conf/xray.go | 42 ++-------- infra/conf/xray_test.go | 53 ------------- 4 files changed, 8 insertions(+), 337 deletions(-) delete mode 100644 infra/conf/transport.go diff --git a/infra/conf/transport.go b/infra/conf/transport.go deleted file mode 100644 index 7957ee7d..00000000 --- a/infra/conf/transport.go +++ /dev/null @@ -1,106 +0,0 @@ -package conf - -import ( - "github.com/xtls/xray-core/common/errors" - "github.com/xtls/xray-core/common/serial" - "github.com/xtls/xray-core/transport/global" - "github.com/xtls/xray-core/transport/internet" -) - -type TransportConfig struct { - TCPConfig *TCPConfig `json:"tcpSettings"` - KCPConfig *KCPConfig `json:"kcpSettings"` - WSConfig *WebSocketConfig `json:"wsSettings"` - HTTPConfig *HTTPConfig `json:"httpSettings"` - GRPCConfig *GRPCConfig `json:"grpcSettings"` - GUNConfig *GRPCConfig `json:"gunSettings"` - HTTPUPGRADEConfig *HttpUpgradeConfig `json:"httpupgradeSettings"` - SplitHTTPConfig *SplitHTTPConfig `json:"splithttpSettings"` -} - -// Build implements Buildable. -func (c *TransportConfig) Build() (*global.Config, error) { - config := new(global.Config) - - if c.TCPConfig != nil { - ts, err := c.TCPConfig.Build() - if err != nil { - return nil, errors.New("failed to build TCP config").Base(err).AtError() - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "tcp", - Settings: serial.ToTypedMessage(ts), - }) - } - - if c.KCPConfig != nil { - ts, err := c.KCPConfig.Build() - if err != nil { - return nil, errors.New("failed to build mKCP config").Base(err).AtError() - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "mkcp", - Settings: serial.ToTypedMessage(ts), - }) - } - - if c.WSConfig != nil { - ts, err := c.WSConfig.Build() - if err != nil { - return nil, errors.New("failed to build WebSocket config").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "websocket", - Settings: serial.ToTypedMessage(ts), - }) - } - - if c.HTTPConfig != nil { - ts, err := c.HTTPConfig.Build() - if err != nil { - return nil, errors.New("Failed to build HTTP config.").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "http", - Settings: serial.ToTypedMessage(ts), - }) - } - - if c.GRPCConfig == nil { - c.GRPCConfig = c.GUNConfig - } - if c.GRPCConfig != nil { - gs, err := c.GRPCConfig.Build() - if err != nil { - return nil, errors.New("Failed to build gRPC config.").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "grpc", - Settings: serial.ToTypedMessage(gs), - }) - } - - if c.HTTPUPGRADEConfig != nil { - hs, err := c.HTTPUPGRADEConfig.Build() - if err != nil { - return nil, errors.New("failed to build HttpUpgrade config").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "httpupgrade", - Settings: serial.ToTypedMessage(hs), - }) - } - - if c.SplitHTTPConfig != nil { - shs, err := c.SplitHTTPConfig.Build() - if err != nil { - return nil, errors.New("failed to build SplitHTTP config").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "splithttp", - Settings: serial.ToTypedMessage(shs), - }) - } - - return config, nil -} diff --git a/infra/conf/transport_test.go b/infra/conf/transport_test.go index 86f707bd..e7470082 100644 --- a/infra/conf/transport_test.go +++ b/infra/conf/transport_test.go @@ -4,16 +4,8 @@ import ( "encoding/json" "testing" - "github.com/xtls/xray-core/common/serial" . "github.com/xtls/xray-core/infra/conf" - "github.com/xtls/xray-core/transport/global" "github.com/xtls/xray-core/transport/internet" - "github.com/xtls/xray-core/transport/internet/grpc" - "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/kcp" - "github.com/xtls/xray-core/transport/internet/tcp" - "github.com/xtls/xray-core/transport/internet/websocket" "google.golang.org/protobuf/proto" ) @@ -157,139 +149,3 @@ func TestSocketConfig(t *testing.T) { t.Fatalf("unexpected parsed TFO value, which should be -1") } } - -func TestTransportConfig(t *testing.T) { - createParser := func() func(string) (proto.Message, error) { - return func(s string) (proto.Message, error) { - config := new(TransportConfig) - if err := json.Unmarshal([]byte(s), config); err != nil { - return nil, err - } - return config.Build() - } - } - - runMultiTestCase(t, []TestCase{ - { - Input: `{ - "tcpSettings": { - "header": { - "type": "http", - "request": { - "version": "1.1", - "method": "GET", - "path": "/b", - "headers": { - "a": "b", - "c": "d" - } - }, - "response": { - "version": "1.0", - "status": "404", - "reason": "Not Found" - } - } - }, - "kcpSettings": { - "mtu": 1200, - "header": { - "type": "none" - } - }, - "wsSettings": { - "path": "/t" - }, - "grpcSettings": { - "serviceName": "name", - "multiMode": true - } - }`, - Parser: createParser(), - Output: &global.Config{ - TransportSettings: []*internet.TransportConfig{ - { - ProtocolName: "tcp", - Settings: serial.ToTypedMessage(&tcp.Config{ - HeaderSettings: serial.ToTypedMessage(&http.Config{ - Request: &http.RequestConfig{ - Version: &http.Version{Value: "1.1"}, - Method: &http.Method{Value: "GET"}, - Uri: []string{"/b"}, - Header: []*http.Header{ - {Name: "a", Value: []string{"b"}}, - {Name: "c", Value: []string{"d"}}, - }, - }, - Response: &http.ResponseConfig{ - Version: &http.Version{Value: "1.0"}, - Status: &http.Status{Code: "404", Reason: "Not Found"}, - Header: []*http.Header{ - { - Name: "Content-Type", - Value: []string{"application/octet-stream", "video/mpeg"}, - }, - { - Name: "Transfer-Encoding", - Value: []string{"chunked"}, - }, - { - Name: "Connection", - Value: []string{"keep-alive"}, - }, - { - Name: "Pragma", - Value: []string{"no-cache"}, - }, - { - Name: "Cache-Control", - Value: []string{"private", "no-cache"}, - }, - }, - }, - }), - }), - }, - { - ProtocolName: "mkcp", - Settings: serial.ToTypedMessage(&kcp.Config{ - Mtu: &kcp.MTU{Value: 1200}, - HeaderConfig: serial.ToTypedMessage(&noop.Config{}), - }), - }, - { - ProtocolName: "websocket", - Settings: serial.ToTypedMessage(&websocket.Config{ - Path: "/t", - }), - }, - { - ProtocolName: "grpc", - Settings: serial.ToTypedMessage(&grpc.Config{ - ServiceName: "name", - MultiMode: true, - }), - }, - }, - }, - }, - { - Input: `{ - "gunSettings": { - "serviceName": "name" - } - }`, - Parser: createParser(), - Output: &global.Config{ - TransportSettings: []*internet.TransportConfig{ - { - ProtocolName: "grpc", - Settings: serial.ToTypedMessage(&grpc.Config{ - ServiceName: "name", - }), - }, - }, - }, - }, - }) -} diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 9488589c..e0f838c8 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -405,12 +405,15 @@ type Config struct { // and should not be used. OutboundDetours []OutboundDetourConfig `json:"outboundDetour"` + // Deprecated: Global transport config is no longer used + // left for returning error + Transport map[string]json.RawMessage `json:"transport"` + LogConfig *LogConfig `json:"log"` RouterConfig *RouterConfig `json:"routing"` DNSConfig *DNSConfig `json:"dns"` InboundConfigs []InboundDetourConfig `json:"inbounds"` OutboundConfigs []OutboundDetourConfig `json:"outbounds"` - Transport *TransportConfig `json:"transport"` Policy *PolicyConfig `json:"policy"` API *APIConfig `json:"api"` Metrics *MetricsConfig `json:"metrics"` @@ -540,27 +543,6 @@ func (c *Config) Override(o *Config, fn string) { } } -func applyTransportConfig(s *StreamConfig, t *TransportConfig) { - if s.TCPSettings == nil { - s.TCPSettings = t.TCPConfig - } - if s.KCPSettings == nil { - s.KCPSettings = t.KCPConfig - } - if s.WSSettings == nil { - s.WSSettings = t.WSConfig - } - if s.HTTPSettings == nil { - s.HTTPSettings = t.HTTPConfig - } - if s.HTTPUPGRADESettings == nil { - s.HTTPUPGRADESettings = t.HTTPUPGRADEConfig - } - if s.SplitHTTPSettings == nil { - s.SplitHTTPSettings = t.SplitHTTPConfig - } -} - // Build implements Buildable. func (c *Config) Build() (*core.Config, error) { if err := PostProcessConfigureFile(c); err != nil { @@ -685,13 +667,11 @@ func (c *Config) Build() (*core.Config, error) { }}} } + if len(c.Transport) > 0 { + return nil, errors.New("Global transport config is deprecated") + } + for _, rawInboundConfig := range inbounds { - if c.Transport != nil { - if rawInboundConfig.StreamSetting == nil { - rawInboundConfig.StreamSetting = &StreamConfig{} - } - applyTransportConfig(rawInboundConfig.StreamSetting, c.Transport) - } ic, err := rawInboundConfig.Build() if err != nil { return nil, err @@ -714,12 +694,6 @@ func (c *Config) Build() (*core.Config, error) { } for _, rawOutboundConfig := range outbounds { - if c.Transport != nil { - if rawOutboundConfig.StreamSetting == nil { - rawOutboundConfig.StreamSetting = &StreamConfig{} - } - applyTransportConfig(rawOutboundConfig.StreamSetting, c.Transport) - } oc, err := rawOutboundConfig.Build() if err != nil { return nil, err diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index 03e27142..0e0b28f4 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -23,7 +23,6 @@ import ( "github.com/xtls/xray-core/proxy/vmess" "github.com/xtls/xray-core/proxy/vmess/inbound" "github.com/xtls/xray-core/transport/internet" - "github.com/xtls/xray-core/transport/internet/http" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/internet/websocket" "google.golang.org/protobuf/proto" @@ -128,11 +127,6 @@ func TestXrayConfig(t *testing.T) { } ] } - }, - "transport": { - "httpSettings": { - "path": "/test" - } } }`, Parser: createParser(), @@ -172,17 +166,6 @@ func TestXrayConfig(t *testing.T) { Outbound: []*core.OutboundHandlerConfig{ { SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ - StreamSettings: &internet.StreamConfig{ - ProtocolName: "tcp", - TransportSettings: []*internet.TransportConfig{ - { - ProtocolName: "http", - Settings: serial.ToTypedMessage(&http.Config{ - Path: "/test", - }), - }, - }, - }, }), ProxySettings: serial.ToTypedMessage(&freedom.Config{ DomainStrategy: freedom.Config_AS_IS, @@ -192,33 +175,11 @@ func TestXrayConfig(t *testing.T) { { Tag: "blocked", SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ - StreamSettings: &internet.StreamConfig{ - ProtocolName: "tcp", - TransportSettings: []*internet.TransportConfig{ - { - ProtocolName: "http", - Settings: serial.ToTypedMessage(&http.Config{ - Path: "/test", - }), - }, - }, - }, }), ProxySettings: serial.ToTypedMessage(&blackhole.Config{}), }, { SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ - StreamSettings: &internet.StreamConfig{ - ProtocolName: "tcp", - TransportSettings: []*internet.TransportConfig{ - { - ProtocolName: "http", - Settings: serial.ToTypedMessage(&http.Config{ - Path: "/test", - }), - }, - }, - }, }), ProxySettings: serial.ToTypedMessage(&dns_proxy.Config{ Server: &net.Endpoint{}, @@ -242,12 +203,6 @@ func TestXrayConfig(t *testing.T) { }, }), }, - { - ProtocolName: "http", - Settings: serial.ToTypedMessage(&http.Config{ - Path: "/test", - }), - }, }, SecurityType: "xray.transport.internet.tls.Config", SecuritySettings: []*serial.TypedMessage{ @@ -295,12 +250,6 @@ func TestXrayConfig(t *testing.T) { }, }), }, - { - ProtocolName: "http", - Settings: serial.ToTypedMessage(&http.Config{ - Path: "/test", - }), - }, }, SecurityType: "xray.transport.internet.tls.Config", SecuritySettings: []*serial.TypedMessage{ @@ -387,7 +336,6 @@ func TestConfig_Override(t *testing.T) { LogConfig: &LogConfig{}, RouterConfig: &RouterConfig{}, DNSConfig: &DNSConfig{}, - Transport: &TransportConfig{}, Policy: &PolicyConfig{}, API: &APIConfig{}, Stats: &StatsConfig{}, @@ -398,7 +346,6 @@ func TestConfig_Override(t *testing.T) { LogConfig: &LogConfig{}, RouterConfig: &RouterConfig{}, DNSConfig: &DNSConfig{}, - Transport: &TransportConfig{}, Policy: &PolicyConfig{}, API: &APIConfig{}, Stats: &StatsConfig{}, From d36e027a5097b42d6c74a6d49e385e37c2caa4a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 01:47:43 +0000 Subject: [PATCH 517/867] Bump golang.org/x/sys from 0.24.0 to 0.25.0 (#3762) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.24.0 to 0.25.0. - [Commits](https://github.com/golang/sys/compare/v0.24.0...v0.25.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 3 +- go.sum | 159 +-------------------------------------------------------- 2 files changed, 3 insertions(+), 159 deletions(-) diff --git a/go.mod b/go.mod index d90c87f4..7a99e517 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/crypto v0.26.0 golang.org/x/net v0.28.0 golang.org/x/sync v0.8.0 - golang.org/x/sys v0.24.0 + golang.org/x/sys v0.25.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.66.0 google.golang.org/protobuf v1.34.2 @@ -38,7 +38,6 @@ require ( github.com/andybalholm/brotli v1.1.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect - github.com/francoispqt/gojay v1.2.13 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/pprof v0.0.0-20240528025155-186aa0362fba // indirect diff --git a/go.sum b/go.sum index c2011cc5..50d6217a 100644 --- a/go.sum +++ b/go.sum @@ -1,115 +1,51 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.37.0/go.mod h1:TS1dMSSfndXH133OKGwekG838Om/cQT0BUHV3HcBgoo= -dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= -dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= -dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= -dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= -git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 h1:Wo41lDOevRJSGpevP+8Pk5bANX7fJacO2w04aqLiC5I= github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0/go.mod h1:FVGavL/QEBQDcBpr3fAojoK17xX5k9bicBphrOpP7uM= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= -github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= -github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/circl v1.4.0 h1:BV7h5MgrktNzytKmWjpOtdYrf0lkkbF8YMlBGPhJQrY= github.com/cloudflare/circl v1.4.0/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= -github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 h1:y7y0Oa6UawqTFPCDw9JG6pdKt4F9pAhHv0B7FMGaGD0= github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= -github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= -github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= -github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3A65HN+7CMjSDP/gofXL4CZt1V4= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= -github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= -github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U= github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= -github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20240528025155-186aa0362fba h1:ql1qNgCyOB7iAEk8JTNM+zJrgIbnyCKX/wdlyPufP5g= github.com/google/pprof v0.0.0-20240528025155-186aa0362fba/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= -github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= -github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364 h1:5XxdakFhqd9dnXoAZy1Mb2R/DZ6D1e+0bGC/JhucGYI= github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364/go.mod h1:eDJQioIyy4Yn3MVivT7rv/39gAJTrA7lgmYr8EW950c= -github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= -github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= -github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= -github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/pires/go-proxyproto v0.7.0 h1:IukmRewDQFWC7kfnb66CSomk2q/seBuilHBYFwyq0Hs= github.com/pires/go-proxyproto v0.7.0/go.mod h1:Vz/1JPY/OACxWGQNIRY2BeyDmpoaWmEP40O9LbuiFR4= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= github.com/quic-go/quic-go v0.46.0 h1:uuwLClEEyk1DNvchH8uCByQVjo3yKL9opKulExNDs7Y= @@ -118,48 +54,18 @@ github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/sagernet/sing v0.4.1 h1:zVlpE+7k7AFoC2pv6ReqLf0PIHjihL/jsBl5k05PQFk= github.com/sagernet/sing v0.4.1/go.mod h1:ieZHA/+Y9YZfXs2I3WtuwgyCZ6GPsIR7HdKb1SdEnls= github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8= github.com/sagernet/sing-shadowsocks v0.2.7/go.mod h1:0rIKJZBR65Qi0zwdKezt4s57y/Tl1ofkaq6NlkzVuyE= github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 h1:emzAzMZ1L9iaKCTxdy3Em8Wv4ChIAGnfiz18Cda70g4= github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg= -github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= -github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= -github.com/shurcooL/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0= -github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= -github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= -github.com/shurcooL/gofontwoff v0.0.0-20180329035133-29b52fc0a18d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw= -github.com/shurcooL/gopherjslib v0.0.0-20160914041154-feb6d3990c2c/go.mod h1:8d3azKNyqcHP1GaQE/c6dDgjkgSx2BZ4IoEi4F1reUI= -github.com/shurcooL/highlight_diff v0.0.0-20170515013008-09bb4053de1b/go.mod h1:ZpfEhSmds4ytuByIcDnOLkTHGUI6KNqRNPDLHDk+mUU= -github.com/shurcooL/highlight_go v0.0.0-20181028180052-98c3abbbae20/go.mod h1:UDKB5a1T23gOMUJrI+uSuH0VRDStOiUVSjBTRDVBVag= -github.com/shurcooL/home v0.0.0-20181020052607-80b7ffcb30f9/go.mod h1:+rgNQw2P9ARFAs37qieuu7ohDNQ3gds9msbT2yn85sg= -github.com/shurcooL/htmlg v0.0.0-20170918183704-d01228ac9e50/go.mod h1:zPn1wHpTIePGnXSHpsVPWEktKXHr6+SS6x/IKRb7cpw= -github.com/shurcooL/httperror v0.0.0-20170206035902-86b7830d14cc/go.mod h1:aYMfkZ6DWSJPJ6c4Wwz3QtW22G7mf/PEgaB9k/ik5+Y= -github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= -github.com/shurcooL/httpgzip v0.0.0-20180522190206-b1c53ac65af9/go.mod h1:919LwcH0M7/W4fcZ0/jy0qGght1GIhqyS/EgWGH2j5Q= -github.com/shurcooL/issues v0.0.0-20181008053335-6292fdc1e191/go.mod h1:e2qWDig5bLteJ4fwvDAc2NHzqFEthkqn7aOZAOpj+PQ= -github.com/shurcooL/issuesapp v0.0.0-20180602232740-048589ce2241/go.mod h1:NPpHK2TI7iSaM0buivtFUc9offApnI0Alt/K8hcHy0I= -github.com/shurcooL/notifications v0.0.0-20181007000457-627ab5aea122/go.mod h1:b5uSkrEVM1jQUspwbixRBhaIjIzL2xazXp6kntxYle0= -github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ= -github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk= -github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= -github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= -github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= -github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF8gHIiADmOVOV5LS43gt3ONnlEl3xkwI= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= -github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= -github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQdrZk= github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= @@ -167,59 +73,29 @@ github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZla github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= -go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= -golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= -golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= -golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -227,24 +103,17 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= @@ -256,32 +125,14 @@ golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeu golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= -google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= -google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= -google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= -google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= -google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= -google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c= google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= @@ -289,15 +140,9 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h1:ze1vwAdliUAr68RQ5NtufWaXaOg8WUO2OACzEV+TNdE= gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489/go.mod h1:10sU+Uh5KKNv1+2x2A0Gvzt8FjD3ASIhorV3YsauXhk= h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo= h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= -sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= -sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= From 397153279848914b48729a920c27d4334bf111b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Sep 2024 01:52:47 +0000 Subject: [PATCH 518/867] Bump golang.org/x/net from 0.28.0 to 0.29.0 (#3766) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.28.0 to 0.29.0. - [Commits](https://github.com/golang/net/compare/v0.28.0...v0.29.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 7a99e517..fb2e7ca5 100644 --- a/go.mod +++ b/go.mod @@ -22,8 +22,8 @@ require ( github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.26.0 - golang.org/x/net v0.28.0 + golang.org/x/crypto v0.27.0 + golang.org/x/net v0.29.0 golang.org/x/sync v0.8.0 golang.org/x/sys v0.25.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 @@ -51,7 +51,7 @@ require ( go.uber.org/mock v0.4.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/mod v0.18.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect diff --git a/go.sum b/go.sum index 50d6217a..7900f26d 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= @@ -89,8 +89,8 @@ golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= @@ -109,8 +109,8 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 6838a0ae55515f79080c19e2ee1752cc88fa365c Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sat, 7 Sep 2024 01:43:58 +0200 Subject: [PATCH 519/867] Config: Remove legacy `inbound/outbound/detours` (#3769) https://github.com/XTLS/Xray-core/pull/3769#issuecomment-2334915139 --- infra/conf/xray.go | 47 ------------------ infra/conf/xray_test.go | 103 ---------------------------------------- 2 files changed, 150 deletions(-) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index e0f838c8..cce7c3bf 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -389,22 +389,6 @@ type Config struct { // and should not be used. Port uint16 `json:"port"` - // Deprecated: InboundConfig exists for historical compatibility - // and should not be used. - InboundConfig *InboundDetourConfig `json:"inbound"` - - // Deprecated: OutboundConfig exists for historical compatibility - // and should not be used. - OutboundConfig *OutboundDetourConfig `json:"outbound"` - - // Deprecated: InboundDetours exists for historical compatibility - // and should not be used. - InboundDetours []InboundDetourConfig `json:"inboundDetour"` - - // Deprecated: OutboundDetours exists for historical compatibility - // and should not be used. - OutboundDetours []OutboundDetourConfig `json:"outboundDetour"` - // Deprecated: Global transport config is no longer used // left for returning error Transport map[string]json.RawMessage `json:"transport"` @@ -490,21 +474,6 @@ func (c *Config) Override(o *Config, fn string) { c.BurstObservatory = o.BurstObservatory } - // deprecated attrs... keep them for now - if o.InboundConfig != nil { - c.InboundConfig = o.InboundConfig - } - if o.OutboundConfig != nil { - c.OutboundConfig = o.OutboundConfig - } - if o.InboundDetours != nil { - c.InboundDetours = o.InboundDetours - } - if o.OutboundDetours != nil { - c.OutboundDetours = o.OutboundDetours - } - // deprecated attrs - // update the Inbound in slice if the only one in override config has same tag if len(o.InboundConfigs) > 0 { for i := range o.InboundConfigs { @@ -647,14 +616,6 @@ func (c *Config) Build() (*core.Config, error) { var inbounds []InboundDetourConfig - if c.InboundConfig != nil { - inbounds = append(inbounds, *c.InboundConfig) - } - - if len(c.InboundDetours) > 0 { - inbounds = append(inbounds, c.InboundDetours...) - } - if len(c.InboundConfigs) > 0 { inbounds = append(inbounds, c.InboundConfigs...) } @@ -681,14 +642,6 @@ func (c *Config) Build() (*core.Config, error) { var outbounds []OutboundDetourConfig - if c.OutboundConfig != nil { - outbounds = append(outbounds, *c.OutboundConfig) - } - - if len(c.OutboundDetours) > 0 { - outbounds = append(outbounds, c.OutboundDetours...) - } - if len(c.OutboundConfigs) > 0 { outbounds = append(outbounds, c.OutboundConfigs...) } diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index 0e0b28f4..7d3e2c4c 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -17,9 +17,6 @@ import ( "github.com/xtls/xray-core/common/serial" core "github.com/xtls/xray-core/core" . "github.com/xtls/xray-core/infra/conf" - "github.com/xtls/xray-core/proxy/blackhole" - dns_proxy "github.com/xtls/xray-core/proxy/dns" - "github.com/xtls/xray-core/proxy/freedom" "github.com/xtls/xray-core/proxy/vmess" "github.com/xtls/xray-core/proxy/vmess/inbound" "github.com/xtls/xray-core/transport/internet" @@ -42,40 +39,11 @@ func TestXrayConfig(t *testing.T) { runMultiTestCase(t, []TestCase{ { Input: `{ - "outbound": { - "protocol": "freedom", - "settings": {} - }, "log": { "access": "/var/log/xray/access.log", "loglevel": "error", "error": "/var/log/xray/error.log" }, - "inbound": { - "streamSettings": { - "network": "ws", - "wsSettings": { - "headers": { - "host": "example.domain" - }, - "path": "" - }, - "tlsSettings": { - "alpn": "h2" - }, - "security": "tls" - }, - "protocol": "vmess", - "port": 443, - "settings": { - "clients": [ - { - "security": "aes-128-gcm", - "id": "0cdf8a45-303d-4fed-9780-29aa7f54175e" - } - ] - } - }, "inbounds": [{ "streamSettings": { "network": "ws", @@ -105,15 +73,6 @@ func TestXrayConfig(t *testing.T) { ] } }], - "outboundDetour": [ - { - "tag": "blocked", - "protocol": "blackhole" - }, - { - "protocol": "dns" - } - ], "routing": { "strategy": "rules", "settings": { @@ -163,69 +122,7 @@ func TestXrayConfig(t *testing.T) { }, }), }, - Outbound: []*core.OutboundHandlerConfig{ - { - SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ - }), - ProxySettings: serial.ToTypedMessage(&freedom.Config{ - DomainStrategy: freedom.Config_AS_IS, - UserLevel: 0, - }), - }, - { - Tag: "blocked", - SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ - }), - ProxySettings: serial.ToTypedMessage(&blackhole.Config{}), - }, - { - SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ - }), - ProxySettings: serial.ToTypedMessage(&dns_proxy.Config{ - Server: &net.Endpoint{}, - Non_IPQuery: "drop", - }), - }, - }, Inbound: []*core.InboundHandlerConfig{ - { - ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ - PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(443)}}, - StreamSettings: &internet.StreamConfig{ - ProtocolName: "websocket", - TransportSettings: []*internet.TransportConfig{ - { - ProtocolName: "websocket", - Settings: serial.ToTypedMessage(&websocket.Config{ - Host: "example.domain", - Header: map[string]string{ - "host": "example.domain", - }, - }), - }, - }, - SecurityType: "xray.transport.internet.tls.Config", - SecuritySettings: []*serial.TypedMessage{ - serial.ToTypedMessage(&tls.Config{ - NextProtocol: []string{"h2"}, - }), - }, - }, - }), - ProxySettings: serial.ToTypedMessage(&inbound.Config{ - User: []*protocol.User{ - { - Level: 0, - Account: serial.ToTypedMessage(&vmess.Account{ - Id: "0cdf8a45-303d-4fed-9780-29aa7f54175e", - SecuritySettings: &protocol.SecurityConfig{ - Type: protocol.SecurityType_AES128_GCM, - }, - }), - }, - }, - }), - }, { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ PortList: &net.PortList{Range: []*net.PortRange{{ From 3d9137cb6fddbcd2e94d9811569362caf9196ccf Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 7 Sep 2024 00:30:27 +0000 Subject: [PATCH 520/867] v24.9.7 --- core/core.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/core.go b/core/core.go index a1423efb..d79b89a6 100644 --- a/core/core.go +++ b/core/core.go @@ -19,9 +19,9 @@ import ( ) var ( - Version_x byte = 1 - Version_y byte = 8 - Version_z byte = 24 + Version_x byte = 24 + Version_y byte = 9 + Version_z byte = 7 ) var ( From 9438517130cd093d5eb3fba43f83d00ae3f5650a Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 8 Sep 2024 17:10:10 -0500 Subject: [PATCH 521/867] README.md: Add SaeedDev94/Xray to Android clients Closes https://github.com/XTLS/Xray-core/issues/3778 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9485f944..016a65d4 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ - Android - [v2rayNG](https://github.com/2dust/v2rayNG) - [X-flutter](https://github.com/XTLS/X-flutter) + - [SaeedDev94/Xray](https://github.com/SaeedDev94/Xray) - iOS & macOS arm64 - [FoXray](https://apps.apple.com/app/foxray/id6448898396) - [Streisand](https://apps.apple.com/app/streisand/id6450534064) From f04cb0b2887cc17a4ae2a5f679fc2c45a881a66a Mon Sep 17 00:00:00 2001 From: Kobe Arthur Scofield <26771058+KobeArthurScofield@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:03:21 +0800 Subject: [PATCH 522/867] Config: Remove some legacy fields from V2Ray 3.x era (#3776) https://github.com/XTLS/Xray-core/pull/3776#issue-2512316726 --- app/proxyman/config.go | 16 --- app/proxyman/config.pb.go | 169 +++++++++--------------------- app/proxyman/config.proto | 10 +- infra/conf/vmess.go | 7 -- infra/conf/xray.go | 23 ---- testing/scenarios/feature_test.go | 5 +- 6 files changed, 54 insertions(+), 176 deletions(-) diff --git a/app/proxyman/config.go b/app/proxyman/config.go index 73c00c74..76d7a194 100644 --- a/app/proxyman/config.go +++ b/app/proxyman/config.go @@ -19,21 +19,5 @@ func (c *ReceiverConfig) GetEffectiveSniffingSettings() *SniffingConfig { return c.SniffingSettings } - if len(c.DomainOverride) > 0 { - var p []string - for _, kd := range c.DomainOverride { - switch kd { - case KnownProtocols_HTTP: - p = append(p, "http") - case KnownProtocols_TLS: - p = append(p, "tls") - } - } - return &SniffingConfig{ - Enabled: true, - DestinationOverride: p, - } - } - return nil } diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index aed85b98..5ba3ac56 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: app/proxyman/config.proto package proxyman @@ -23,52 +23,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type KnownProtocols int32 - -const ( - KnownProtocols_HTTP KnownProtocols = 0 - KnownProtocols_TLS KnownProtocols = 1 -) - -// Enum value maps for KnownProtocols. -var ( - KnownProtocols_name = map[int32]string{ - 0: "HTTP", - 1: "TLS", - } - KnownProtocols_value = map[string]int32{ - "HTTP": 0, - "TLS": 1, - } -) - -func (x KnownProtocols) Enum() *KnownProtocols { - p := new(KnownProtocols) - *p = x - return p -} - -func (x KnownProtocols) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (KnownProtocols) Descriptor() protoreflect.EnumDescriptor { - return file_app_proxyman_config_proto_enumTypes[0].Descriptor() -} - -func (KnownProtocols) Type() protoreflect.EnumType { - return &file_app_proxyman_config_proto_enumTypes[0] -} - -func (x KnownProtocols) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use KnownProtocols.Descriptor instead. -func (KnownProtocols) EnumDescriptor() ([]byte, []int) { - return file_app_proxyman_config_proto_rawDescGZIP(), []int{0} -} - type AllocationStrategy_Type int32 const ( @@ -105,11 +59,11 @@ func (x AllocationStrategy_Type) String() string { } func (AllocationStrategy_Type) Descriptor() protoreflect.EnumDescriptor { - return file_app_proxyman_config_proto_enumTypes[1].Descriptor() + return file_app_proxyman_config_proto_enumTypes[0].Descriptor() } func (AllocationStrategy_Type) Type() protoreflect.EnumType { - return &file_app_proxyman_config_proto_enumTypes[1] + return &file_app_proxyman_config_proto_enumTypes[0] } func (x AllocationStrategy_Type) Number() protoreflect.EnumNumber { @@ -323,12 +277,7 @@ type ReceiverConfig struct { AllocationStrategy *AllocationStrategy `protobuf:"bytes,3,opt,name=allocation_strategy,json=allocationStrategy,proto3" json:"allocation_strategy,omitempty"` StreamSettings *internet.StreamConfig `protobuf:"bytes,4,opt,name=stream_settings,json=streamSettings,proto3" json:"stream_settings,omitempty"` ReceiveOriginalDestination bool `protobuf:"varint,5,opt,name=receive_original_destination,json=receiveOriginalDestination,proto3" json:"receive_original_destination,omitempty"` - // Override domains for the given protocol. - // Deprecated. Use sniffing_settings. - // - // Deprecated: Marked as deprecated in app/proxyman/config.proto. - DomainOverride []KnownProtocols `protobuf:"varint,7,rep,packed,name=domain_override,json=domainOverride,proto3,enum=xray.app.proxyman.KnownProtocols" json:"domain_override,omitempty"` - SniffingSettings *SniffingConfig `protobuf:"bytes,8,opt,name=sniffing_settings,json=sniffingSettings,proto3" json:"sniffing_settings,omitempty"` + SniffingSettings *SniffingConfig `protobuf:"bytes,7,opt,name=sniffing_settings,json=sniffingSettings,proto3" json:"sniffing_settings,omitempty"` } func (x *ReceiverConfig) Reset() { @@ -398,14 +347,6 @@ func (x *ReceiverConfig) GetReceiveOriginalDestination() bool { return false } -// Deprecated: Marked as deprecated in app/proxyman/config.proto. -func (x *ReceiverConfig) GetDomainOverride() []KnownProtocols { - if x != nil { - return x.DomainOverride - } - return nil -} - func (x *ReceiverConfig) GetSniffingSettings() *SniffingConfig { if x != nil { return x.SniffingSettings @@ -817,7 +758,7 @@ var file_app_proxyman_config_proto_rawDesc = []byte{ 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x4f, 0x6e, 0x6c, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x72, 0x6f, 0x75, 0x74, 0x65, - 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0x8d, 0x04, 0x0a, 0x0e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x4f, 0x6e, 0x6c, 0x79, 0x22, 0xbd, 0x03, 0x0a, 0x0e, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x36, 0x0a, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, @@ -840,13 +781,8 @@ var file_app_proxyman_config_proto_rawDesc = []byte{ 0x5f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4e, - 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, - 0x65, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, - 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x4b, 0x6e, 0x6f, 0x77, - 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0e, - 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x12, 0x4e, 0x0a, 0x11, 0x73, 0x6e, 0x69, 0x66, 0x66, 0x69, 0x6e, 0x67, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, - 0x6e, 0x67, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x6e, 0x67, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x53, 0x6e, 0x69, 0x66, 0x66, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x73, 0x6e, 0x69, 0x66, 0x66, 0x69, 0x6e, 0x67, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x4a, 0x04, @@ -894,16 +830,13 @@ var file_app_proxyman_config_proto_rawDesc = []byte{ 0x01, 0x28, 0x05, 0x52, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x78, 0x75, 0x64, 0x70, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x55, 0x44, 0x50, 0x34, 0x34, 0x33, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x78, - 0x75, 0x64, 0x70, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x55, 0x44, 0x50, 0x34, 0x34, 0x33, 0x2a, 0x23, - 0x0a, 0x0e, 0x4b, 0x6e, 0x6f, 0x77, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x73, - 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x4c, - 0x53, 0x10, 0x01, 0x42, 0x55, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x50, 0x01, 0x5a, 0x26, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, - 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, - 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x75, 0x64, 0x70, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x55, 0x44, 0x50, 0x34, 0x34, 0x33, 0x42, 0x55, + 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x50, 0x01, 0x5a, 0x26, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, + 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, + 0x6e, 0xaa, 0x02, 0x11, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, + 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -918,48 +851,46 @@ func file_app_proxyman_config_proto_rawDescGZIP() []byte { return file_app_proxyman_config_proto_rawDescData } -var file_app_proxyman_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_app_proxyman_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_app_proxyman_config_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_app_proxyman_config_proto_goTypes = []any{ - (KnownProtocols)(0), // 0: xray.app.proxyman.KnownProtocols - (AllocationStrategy_Type)(0), // 1: xray.app.proxyman.AllocationStrategy.Type - (*InboundConfig)(nil), // 2: xray.app.proxyman.InboundConfig - (*AllocationStrategy)(nil), // 3: xray.app.proxyman.AllocationStrategy - (*SniffingConfig)(nil), // 4: xray.app.proxyman.SniffingConfig - (*ReceiverConfig)(nil), // 5: xray.app.proxyman.ReceiverConfig - (*InboundHandlerConfig)(nil), // 6: xray.app.proxyman.InboundHandlerConfig - (*OutboundConfig)(nil), // 7: xray.app.proxyman.OutboundConfig - (*SenderConfig)(nil), // 8: xray.app.proxyman.SenderConfig - (*MultiplexingConfig)(nil), // 9: xray.app.proxyman.MultiplexingConfig - (*AllocationStrategy_AllocationStrategyConcurrency)(nil), // 10: xray.app.proxyman.AllocationStrategy.AllocationStrategyConcurrency - (*AllocationStrategy_AllocationStrategyRefresh)(nil), // 11: xray.app.proxyman.AllocationStrategy.AllocationStrategyRefresh - (*net.PortList)(nil), // 12: xray.common.net.PortList - (*net.IPOrDomain)(nil), // 13: xray.common.net.IPOrDomain - (*internet.StreamConfig)(nil), // 14: xray.transport.internet.StreamConfig - (*serial.TypedMessage)(nil), // 15: xray.common.serial.TypedMessage - (*internet.ProxyConfig)(nil), // 16: xray.transport.internet.ProxyConfig + (AllocationStrategy_Type)(0), // 0: xray.app.proxyman.AllocationStrategy.Type + (*InboundConfig)(nil), // 1: xray.app.proxyman.InboundConfig + (*AllocationStrategy)(nil), // 2: xray.app.proxyman.AllocationStrategy + (*SniffingConfig)(nil), // 3: xray.app.proxyman.SniffingConfig + (*ReceiverConfig)(nil), // 4: xray.app.proxyman.ReceiverConfig + (*InboundHandlerConfig)(nil), // 5: xray.app.proxyman.InboundHandlerConfig + (*OutboundConfig)(nil), // 6: xray.app.proxyman.OutboundConfig + (*SenderConfig)(nil), // 7: xray.app.proxyman.SenderConfig + (*MultiplexingConfig)(nil), // 8: xray.app.proxyman.MultiplexingConfig + (*AllocationStrategy_AllocationStrategyConcurrency)(nil), // 9: xray.app.proxyman.AllocationStrategy.AllocationStrategyConcurrency + (*AllocationStrategy_AllocationStrategyRefresh)(nil), // 10: xray.app.proxyman.AllocationStrategy.AllocationStrategyRefresh + (*net.PortList)(nil), // 11: xray.common.net.PortList + (*net.IPOrDomain)(nil), // 12: xray.common.net.IPOrDomain + (*internet.StreamConfig)(nil), // 13: xray.transport.internet.StreamConfig + (*serial.TypedMessage)(nil), // 14: xray.common.serial.TypedMessage + (*internet.ProxyConfig)(nil), // 15: xray.transport.internet.ProxyConfig } var file_app_proxyman_config_proto_depIdxs = []int32{ - 1, // 0: xray.app.proxyman.AllocationStrategy.type:type_name -> xray.app.proxyman.AllocationStrategy.Type - 10, // 1: xray.app.proxyman.AllocationStrategy.concurrency:type_name -> xray.app.proxyman.AllocationStrategy.AllocationStrategyConcurrency - 11, // 2: xray.app.proxyman.AllocationStrategy.refresh:type_name -> xray.app.proxyman.AllocationStrategy.AllocationStrategyRefresh - 12, // 3: xray.app.proxyman.ReceiverConfig.port_list:type_name -> xray.common.net.PortList - 13, // 4: xray.app.proxyman.ReceiverConfig.listen:type_name -> xray.common.net.IPOrDomain - 3, // 5: xray.app.proxyman.ReceiverConfig.allocation_strategy:type_name -> xray.app.proxyman.AllocationStrategy - 14, // 6: xray.app.proxyman.ReceiverConfig.stream_settings:type_name -> xray.transport.internet.StreamConfig - 0, // 7: xray.app.proxyman.ReceiverConfig.domain_override:type_name -> xray.app.proxyman.KnownProtocols - 4, // 8: xray.app.proxyman.ReceiverConfig.sniffing_settings:type_name -> xray.app.proxyman.SniffingConfig - 15, // 9: xray.app.proxyman.InboundHandlerConfig.receiver_settings:type_name -> xray.common.serial.TypedMessage - 15, // 10: xray.app.proxyman.InboundHandlerConfig.proxy_settings:type_name -> xray.common.serial.TypedMessage - 13, // 11: xray.app.proxyman.SenderConfig.via:type_name -> xray.common.net.IPOrDomain - 14, // 12: xray.app.proxyman.SenderConfig.stream_settings:type_name -> xray.transport.internet.StreamConfig - 16, // 13: xray.app.proxyman.SenderConfig.proxy_settings:type_name -> xray.transport.internet.ProxyConfig - 9, // 14: xray.app.proxyman.SenderConfig.multiplex_settings:type_name -> xray.app.proxyman.MultiplexingConfig - 15, // [15:15] is the sub-list for method output_type - 15, // [15:15] is the sub-list for method input_type - 15, // [15:15] is the sub-list for extension type_name - 15, // [15:15] is the sub-list for extension extendee - 0, // [0:15] is the sub-list for field type_name + 0, // 0: xray.app.proxyman.AllocationStrategy.type:type_name -> xray.app.proxyman.AllocationStrategy.Type + 9, // 1: xray.app.proxyman.AllocationStrategy.concurrency:type_name -> xray.app.proxyman.AllocationStrategy.AllocationStrategyConcurrency + 10, // 2: xray.app.proxyman.AllocationStrategy.refresh:type_name -> xray.app.proxyman.AllocationStrategy.AllocationStrategyRefresh + 11, // 3: xray.app.proxyman.ReceiverConfig.port_list:type_name -> xray.common.net.PortList + 12, // 4: xray.app.proxyman.ReceiverConfig.listen:type_name -> xray.common.net.IPOrDomain + 2, // 5: xray.app.proxyman.ReceiverConfig.allocation_strategy:type_name -> xray.app.proxyman.AllocationStrategy + 13, // 6: xray.app.proxyman.ReceiverConfig.stream_settings:type_name -> xray.transport.internet.StreamConfig + 3, // 7: xray.app.proxyman.ReceiverConfig.sniffing_settings:type_name -> xray.app.proxyman.SniffingConfig + 14, // 8: xray.app.proxyman.InboundHandlerConfig.receiver_settings:type_name -> xray.common.serial.TypedMessage + 14, // 9: xray.app.proxyman.InboundHandlerConfig.proxy_settings:type_name -> xray.common.serial.TypedMessage + 12, // 10: xray.app.proxyman.SenderConfig.via:type_name -> xray.common.net.IPOrDomain + 13, // 11: xray.app.proxyman.SenderConfig.stream_settings:type_name -> xray.transport.internet.StreamConfig + 15, // 12: xray.app.proxyman.SenderConfig.proxy_settings:type_name -> xray.transport.internet.ProxyConfig + 8, // 13: xray.app.proxyman.SenderConfig.multiplex_settings:type_name -> xray.app.proxyman.MultiplexingConfig + 14, // [14:14] is the sub-list for method output_type + 14, // [14:14] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name } func init() { file_app_proxyman_config_proto_init() } @@ -1094,7 +1025,7 @@ func file_app_proxyman_config_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_proxyman_config_proto_rawDesc, - NumEnums: 2, + NumEnums: 1, NumMessages: 10, NumExtensions: 0, NumServices: 0, diff --git a/app/proxyman/config.proto b/app/proxyman/config.proto index fe18c378..635ffad2 100644 --- a/app/proxyman/config.proto +++ b/app/proxyman/config.proto @@ -40,11 +40,6 @@ message AllocationStrategy { AllocationStrategyRefresh refresh = 3; } -enum KnownProtocols { - HTTP = 0; - TLS = 1; -} - message SniffingConfig { // Whether or not to enable content sniffing on an inbound connection. bool enabled = 1; @@ -71,10 +66,7 @@ message ReceiverConfig { xray.transport.internet.StreamConfig stream_settings = 4; bool receive_original_destination = 5; reserved 6; - // Override domains for the given protocol. - // Deprecated. Use sniffing_settings. - repeated KnownProtocols domain_override = 7 [ deprecated = true ]; - SniffingConfig sniffing_settings = 8; + SniffingConfig sniffing_settings = 7; } message InboundHandlerConfig { diff --git a/infra/conf/vmess.go b/infra/conf/vmess.go index 23eb6948..90ab92d4 100644 --- a/infra/conf/vmess.go +++ b/infra/conf/vmess.go @@ -57,10 +57,6 @@ func (c *VMessDetourConfig) Build() *inbound.DetourConfig { } } -type FeaturesConfig struct { - Detour *VMessDetourConfig `json:"detour"` -} - type VMessDefaultConfig struct { Level byte `json:"level"` } @@ -74,7 +70,6 @@ func (c *VMessDefaultConfig) Build() *inbound.DefaultConfig { type VMessInboundConfig struct { Users []json.RawMessage `json:"clients"` - Features *FeaturesConfig `json:"features"` Defaults *VMessDefaultConfig `json:"default"` DetourConfig *VMessDetourConfig `json:"detour"` } @@ -89,8 +84,6 @@ func (c *VMessInboundConfig) Build() (proto.Message, error) { if c.DetourConfig != nil { config.Detour = c.DetourConfig.Build() - } else if c.Features != nil && c.Features.Detour != nil { - config.Detour = c.Features.Detour.Build() } config.User = make([]*protocol.User, len(c.Users)) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index cce7c3bf..6daca0f7 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -48,21 +48,6 @@ var ( ctllog = log.New(os.Stderr, "xctl> ", 0) ) -func toProtocolList(s []string) ([]proxyman.KnownProtocols, error) { - kp := make([]proxyman.KnownProtocols, 0, 8) - for _, p := range s { - switch strings.ToLower(p) { - case "http": - kp = append(kp, proxyman.KnownProtocols_HTTP) - case "https", "tls", "ssl": - kp = append(kp, proxyman.KnownProtocols_TLS) - default: - return nil, errors.New("Unknown protocol: ", p) - } - } - return kp, nil -} - type SniffingConfig struct { Enabled bool `json:"enabled"` DestOverride *StringList `json:"destOverride"` @@ -175,7 +160,6 @@ type InboundDetourConfig struct { Tag string `json:"tag"` Allocation *InboundDetourAllocationConfig `json:"allocate"` StreamSetting *StreamConfig `json:"streamSettings"` - DomainOverride *StringList `json:"domainOverride"` SniffingConfig *SniffingConfig `json:"sniffing"` } @@ -249,13 +233,6 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) { } receiverSettings.SniffingSettings = s } - if c.DomainOverride != nil { - kp, err := toProtocolList(*c.DomainOverride) - if err != nil { - return nil, errors.New("failed to parse inbound detour config").Base(err) - } - receiverSettings.DomainOverride = kp - } settings := []byte("{}") if c.Settings != nil { diff --git a/testing/scenarios/feature_test.go b/testing/scenarios/feature_test.go index bee4598f..0e2f8785 100644 --- a/testing/scenarios/feature_test.go +++ b/testing/scenarios/feature_test.go @@ -560,8 +560,9 @@ func TestDomainSniffing(t *testing.T) { ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(sniffingPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), - DomainOverride: []proxyman.KnownProtocols{ - proxyman.KnownProtocols_TLS, + SniffingSettings: &proxyman.SniffingConfig{ + Enabled: true, + DestinationOverride: []string{"tls"}, }, }), ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ From 3d0feae462040c243a0ff388269dc4d0a9181643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Mon, 9 Sep 2024 23:37:39 +0800 Subject: [PATCH 523/867] Transport: Add REALITY TLS1.3 support warning (#3774) --- transport/internet/reality/reality.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 8c77e79f..44402f31 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -140,6 +140,9 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati if err != nil { return nil, errors.New("REALITY: publicKey == nil") } + if uConn.HandshakeState.State13.EcdheKey == nil { + return nil, errors.New("Current fingerprint ", uConn.ClientHelloID.Client, uConn.ClientHelloID.Version, " does not support TLS 1.3, REALITY handshake cannot establish.") + } uConn.AuthKey, _ = uConn.HandshakeState.State13.EcdheKey.ECDH(publicKey) if uConn.AuthKey == nil { return nil, errors.New("REALITY: SharedKey == nil") From c90affe7dbed973af3e789881d246e3ab9506d8e Mon Sep 17 00:00:00 2001 From: yu <1758031883@qq.com> Date: Mon, 9 Sep 2024 23:44:22 +0800 Subject: [PATCH 524/867] Fix: RPC call causes xray panic problem using wrong account type (#3744) * fix:RPC call causes xray panic problem. Problem details: add a VMess protocol user in an inbound proxy. If inTag: "VMess-xxx", but the developer carelessly calls the add user method of vless or other protocols, such as xrayCtl.AddVlessUser(user), causing xray panic * fix:use xray log system return error --------- Co-authored-by: chengtao@snqu.com --- proxy/vmess/validator.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proxy/vmess/validator.go b/proxy/vmess/validator.go index 00e49ae2..43ced006 100644 --- a/proxy/vmess/validator.go +++ b/proxy/vmess/validator.go @@ -39,7 +39,10 @@ func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error { v.users = append(v.users, u) - account := u.Account.(*MemoryAccount) + account, ok := u.Account.(*MemoryAccount) + if !ok { + return errors.New("account type is incorrect") + } if !v.behaviorFused { hashkdf := hmac.New(sha256.New, []byte("VMESSBSKDF")) hashkdf.Write(account.ID.Bytes()) From 6b1bf312d7cd28edb69e6351af13e8a4a887b27f Mon Sep 17 00:00:00 2001 From: Kobe Arthur Scofield <26771058+KobeArthurScofield@users.noreply.github.com> Date: Wed, 11 Sep 2024 22:37:25 +0800 Subject: [PATCH 525/867] Config: Remove legacy config fields again (#3782) * Remove more lecacy fields * Patch missing bracket * Fix tests * Fix missing comma * Fix buried test bomb * Cleanup test after removed legacy test content --- infra/conf/router.go | 12 --- infra/conf/router_test.go | 161 +++++++++++--------------------------- infra/conf/xray.go | 13 --- infra/conf/xray_test.go | 21 +++-- 4 files changed, 55 insertions(+), 152 deletions(-) diff --git a/infra/conf/router.go b/infra/conf/router.go index 44f9e8fa..69198d6a 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -14,11 +14,6 @@ import ( "google.golang.org/protobuf/proto" ) -type RouterRulesConfig struct { - RuleList []json.RawMessage `json:"rules"` - DomainStrategy string `json:"domainStrategy"` -} - // StrategyConfig represents a strategy config type StrategyConfig struct { Type string `json:"type"` @@ -76,7 +71,6 @@ func (r *BalancingRule) Build() (*router.BalancingRule, error) { } type RouterConfig struct { - Settings *RouterRulesConfig `json:"settings"` // Deprecated RuleList []json.RawMessage `json:"rules"` DomainStrategy *string `json:"domainStrategy"` Balancers []*BalancingRule `json:"balancers"` @@ -88,8 +82,6 @@ func (c *RouterConfig) getDomainStrategy() router.Config_DomainStrategy { ds := "" if c.DomainStrategy != nil { ds = *c.DomainStrategy - } else if c.Settings != nil { - ds = c.Settings.DomainStrategy } switch strings.ToLower(ds) { @@ -111,10 +103,6 @@ func (c *RouterConfig) Build() (*router.Config, error) { var rawRuleList []json.RawMessage if c != nil { rawRuleList = c.RuleList - if c.Settings != nil { - c.RuleList = append(c.RuleList, c.Settings.RuleList...) - rawRuleList = c.RuleList - } } for _, rawRule := range rawRuleList { diff --git a/infra/conf/router_test.go b/infra/conf/router_test.go index de4c8ed2..340b871c 100644 --- a/infra/conf/router_test.go +++ b/infra/conf/router_test.go @@ -64,36 +64,33 @@ func TestRouterConfig(t *testing.T) { runMultiTestCase(t, []TestCase{ { Input: `{ - "strategy": "rules", - "settings": { - "domainStrategy": "AsIs", - "rules": [ - { - "type": "field", - "domain": [ - "baidu.com", - "qq.com" - ], - "outboundTag": "direct" - }, - { - "type": "field", - "ip": [ - "10.0.0.0/8", - "::1/128" - ], - "outboundTag": "test" - },{ - "type": "field", - "port": "53, 443, 1000-2000", - "outboundTag": "test" - },{ - "type": "field", - "port": 123, - "outboundTag": "test" - } - ] - }, + "domainStrategy": "AsIs", + "rules": [ + { + "type": "field", + "domain": [ + "baidu.com", + "qq.com" + ], + "outboundTag": "direct" + }, + { + "type": "field", + "ip": [ + "10.0.0.0/8", + "::1/128" + ], + "outboundTag": "test" + },{ + "type": "field", + "port": "53, 443, 1000-2000", + "outboundTag": "test" + },{ + "type": "field", + "port": 123, + "outboundTag": "test" + } + ], "balancers": [ { "tag": "b1", @@ -225,28 +222,25 @@ func TestRouterConfig(t *testing.T) { }, { Input: `{ - "strategy": "rules", - "settings": { - "domainStrategy": "IPIfNonMatch", - "rules": [ - { - "type": "field", - "domain": [ - "baidu.com", - "qq.com" - ], - "outboundTag": "direct" - }, - { - "type": "field", - "ip": [ - "10.0.0.0/8", - "::1/128" - ], - "outboundTag": "test" - } - ] - } + "domainStrategy": "IPIfNonMatch", + "rules": [ + { + "type": "field", + "domain": [ + "baidu.com", + "qq.com" + ], + "outboundTag": "direct" + }, + { + "type": "field", + "ip": [ + "10.0.0.0/8", + "::1/128" + ], + "outboundTag": "test" + } + ] }`, Parser: createParser(), Output: &router.Config{ @@ -289,68 +283,5 @@ func TestRouterConfig(t *testing.T) { }, }, }, - { - Input: `{ - "domainStrategy": "AsIs", - "rules": [ - { - "type": "field", - "domain": [ - "baidu.com", - "qq.com" - ], - "outboundTag": "direct" - }, - { - "type": "field", - "ip": [ - "10.0.0.0/8", - "::1/128" - ], - "outboundTag": "test" - } - ] - }`, - Parser: createParser(), - Output: &router.Config{ - DomainStrategy: router.Config_AsIs, - Rule: []*router.RoutingRule{ - { - Domain: []*router.Domain{ - { - Type: router.Domain_Plain, - Value: "baidu.com", - }, - { - Type: router.Domain_Plain, - Value: "qq.com", - }, - }, - TargetTag: &router.RoutingRule_Tag{ - Tag: "direct", - }, - }, - { - Geoip: []*router.GeoIP{ - { - Cidr: []*router.CIDR{ - { - Ip: []byte{10, 0, 0, 0}, - Prefix: 8, - }, - { - Ip: []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, - Prefix: 128, - }, - }, - }, - }, - TargetTag: &router.RoutingRule_Tag{ - Tag: "test", - }, - }, - }, - }, - }, }) } diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 6daca0f7..07f70273 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -361,11 +361,6 @@ func (c *StatsConfig) Build() (*stats.Config, error) { } type Config struct { - // Port of this Point server. - // Deprecated: Port exists for historical compatibility - // and should not be used. - Port uint16 `json:"port"` - // Deprecated: Global transport config is no longer used // left for returning error Transport map[string]json.RawMessage `json:"transport"` @@ -597,14 +592,6 @@ func (c *Config) Build() (*core.Config, error) { inbounds = append(inbounds, c.InboundConfigs...) } - // Backward compatibility. - if len(inbounds) > 0 && inbounds[0].PortList == nil && c.Port > 0 { - inbounds[0].PortList = &PortList{[]PortRange{{ - From: uint32(c.Port), - To: uint32(c.Port), - }}} - } - if len(c.Transport) > 0 { return nil, errors.New("Global transport config is deprecated") } diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index 7d3e2c4c..d225dbf9 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -74,18 +74,15 @@ func TestXrayConfig(t *testing.T) { } }], "routing": { - "strategy": "rules", - "settings": { - "rules": [ - { - "ip": [ - "10.0.0.0/8" - ], - "type": "field", - "outboundTag": "blocked" - } - ] - } + "rules": [ + { + "ip": [ + "10.0.0.0/8" + ], + "type": "field", + "outboundTag": "blocked" + } + ] } }`, Parser: createParser(), From a247997e388cda3b31108a8f107ad87680dcd9ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Wed, 11 Sep 2024 22:45:47 +0800 Subject: [PATCH 526/867] Log: Add MaskAddress option to hide IP addresses (#3783) * Log: Add maskAddress option * Correct IPv6 subnet --- app/log/config.pb.go | 31 ++++++++++++++------- app/log/config.proto | 1 + app/log/log.go | 66 ++++++++++++++++++++++++++++++++++++++++++-- infra/conf/log.go | 10 ++++--- 4 files changed, 91 insertions(+), 17 deletions(-) diff --git a/app/log/config.pb.go b/app/log/config.pb.go index eb7abc50..43197238 100644 --- a/app/log/config.pb.go +++ b/app/log/config.pb.go @@ -84,6 +84,7 @@ type Config struct { AccessLogType LogType `protobuf:"varint,4,opt,name=access_log_type,json=accessLogType,proto3,enum=xray.app.log.LogType" json:"access_log_type,omitempty"` AccessLogPath string `protobuf:"bytes,5,opt,name=access_log_path,json=accessLogPath,proto3" json:"access_log_path,omitempty"` EnableDnsLog bool `protobuf:"varint,6,opt,name=enable_dns_log,json=enableDnsLog,proto3" json:"enable_dns_log,omitempty"` + MaskAddress string `protobuf:"bytes,7,opt,name=mask_address,json=maskAddress,proto3" json:"mask_address,omitempty"` } func (x *Config) Reset() { @@ -160,13 +161,20 @@ func (x *Config) GetEnableDnsLog() bool { return false } +func (x *Config) GetMaskAddress() string { + if x != nil { + return x.MaskAddress + } + return "" +} + var File_app_log_config_proto protoreflect.FileDescriptor var file_app_log_config_proto_rawDesc = []byte{ 0x0a, 0x14, 0x61, 0x70, 0x70, 0x2f, 0x6c, 0x6f, 0x67, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x1a, 0x14, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6c, 0x6f, 0x67, - 0x2f, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xbb, 0x02, 0x0a, 0x06, 0x43, + 0x2f, 0x6c, 0x6f, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xde, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3b, 0x0a, 0x0e, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6c, 0x6f, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x2e, 0x4c, 0x6f, 0x67, @@ -186,15 +194,18 @@ var file_app_log_config_proto_rawDesc = []byte{ 0x01, 0x28, 0x09, 0x52, 0x0d, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x4c, 0x6f, 0x67, 0x50, 0x61, 0x74, 0x68, 0x12, 0x24, 0x0a, 0x0e, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x64, 0x6e, 0x73, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x65, 0x6e, 0x61, 0x62, - 0x6c, 0x65, 0x44, 0x6e, 0x73, 0x4c, 0x6f, 0x67, 0x2a, 0x35, 0x0a, 0x07, 0x4c, 0x6f, 0x67, 0x54, - 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0b, 0x0a, - 0x07, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x69, - 0x6c, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x10, 0x03, 0x42, - 0x46, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x6c, 0x6f, 0x67, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, - 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6c, 0x6f, 0x67, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x41, 0x70, 0x70, 0x2e, 0x4c, 0x6f, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x65, 0x44, 0x6e, 0x73, 0x4c, 0x6f, 0x67, 0x12, 0x21, 0x0a, 0x0c, 0x6d, 0x61, 0x73, 0x6b, + 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, + 0x6d, 0x61, 0x73, 0x6b, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2a, 0x35, 0x0a, 0x07, 0x4c, + 0x6f, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, + 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x10, 0x01, 0x12, 0x08, 0x0a, + 0x04, 0x46, 0x69, 0x6c, 0x65, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, + 0x10, 0x03, 0x42, 0x46, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x6c, 0x6f, 0x67, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6c, 0x6f, 0x67, 0xaa, 0x02, 0x0c, 0x58, 0x72, + 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4c, 0x6f, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/app/log/config.proto b/app/log/config.proto index 47e010d2..8dc729d0 100644 --- a/app/log/config.proto +++ b/app/log/config.proto @@ -23,4 +23,5 @@ message Config { LogType access_log_type = 4; string access_log_path = 5; bool enable_dns_log = 6; + string mask_address= 7; } diff --git a/app/log/log.go b/app/log/log.go index 098fe631..8b3d3367 100644 --- a/app/log/log.go +++ b/app/log/log.go @@ -4,6 +4,9 @@ package log import ( "context" + "fmt" + "regexp" + "strings" "sync" "github.com/xtls/xray-core/common" @@ -101,18 +104,25 @@ func (g *Instance) Handle(msg log.Message) { return } + var Msg log.Message + if g.config.MaskAddress != "" { + Msg = &MaskedMsgWrapper{Message: msg, config: g.config} + } else { + Msg = msg + } + switch msg := msg.(type) { case *log.AccessMessage: if g.accessLogger != nil { - g.accessLogger.Handle(msg) + g.accessLogger.Handle(Msg) } case *log.DNSLog: if g.dns && g.accessLogger != nil { - g.accessLogger.Handle(msg) + g.accessLogger.Handle(Msg) } case *log.GeneralMessage: if g.errorLogger != nil && msg.Severity <= g.config.ErrorLogLevel { - g.errorLogger.Handle(msg) + g.errorLogger.Handle(Msg) } default: // Swallow @@ -141,6 +151,56 @@ func (g *Instance) Close() error { return nil } +// MaskedMsgWrapper is to wrap the string() method to mask IP addresses in the log. +type MaskedMsgWrapper struct { + log.Message + config *Config +} + +func (m *MaskedMsgWrapper) String() string { + str := m.Message.String() + + ipv4Regex := regexp.MustCompile(`(\d{1,3}\.){3}\d{1,3}`) + ipv6Regex := regexp.MustCompile(`((?:[\da-fA-F]{0,4}:[\da-fA-F]{0,4}){2,7})(?:[\/\\%](\d{1,3}))?`) + + // Process ipv4 + maskedMsg := ipv4Regex.ReplaceAllStringFunc(str, func(ip string) string { + parts := strings.Split(ip, ".") + switch m.config.MaskAddress { + case "half": + return fmt.Sprintf("%s.%s.*.*", parts[0], parts[1]) + case "quarter": + return fmt.Sprintf("%s.*.*.*", parts[0]) + case "full": + return "[Masked IPv4]" + default: + return ip + } + }) + + // process ipv6 + maskedMsg = ipv6Regex.ReplaceAllStringFunc(maskedMsg, func(ip string) string { + parts := strings.Split(ip, ":") + switch m.config.MaskAddress { + case "half": + if len(parts) >= 2 { + return fmt.Sprintf("%s:%s::/32", parts[0], parts[1]) + } + case "quarter": + if len(parts) >= 1 { + return fmt.Sprintf("%s::/16", parts[0]) + } + case "full": + return "Masked IPv6" // Do not use [Masked IPv6] like ipv4, or you will get "[[Masked IPv6]]" (v6 address already has []) + default: + return ip + } + return ip + }) + + return maskedMsg +} + func init() { common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { return New(ctx, config.(*Config)) diff --git a/infra/conf/log.go b/infra/conf/log.go index 14f2a694..fee8f570 100644 --- a/infra/conf/log.go +++ b/infra/conf/log.go @@ -16,10 +16,11 @@ func DefaultLogConfig() *log.Config { } type LogConfig struct { - AccessLog string `json:"access"` - ErrorLog string `json:"error"` - LogLevel string `json:"loglevel"` - DNSLog bool `json:"dnsLog"` + AccessLog string `json:"access"` + ErrorLog string `json:"error"` + LogLevel string `json:"loglevel"` + DNSLog bool `json:"dnsLog"` + MaskAddress string `json:"maskAddress"` } func (v *LogConfig) Build() *log.Config { @@ -59,5 +60,6 @@ func (v *LogConfig) Build() *log.Config { default: config.ErrorLogLevel = clog.Severity_Warning } + config.MaskAddress = v.MaskAddress return config } From 297a9ae7bd5bcf2af08e2a6d44b3db40599ab7d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 11:34:03 -0400 Subject: [PATCH 527/867] Bump google.golang.org/grpc from 1.66.0 to 1.66.1 (#3786) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.66.0 to 1.66.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.66.0...v1.66.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fb2e7ca5..8c8473a4 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.8.0 golang.org/x/sys v0.25.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.66.0 + google.golang.org/grpc v1.66.1 google.golang.org/protobuf v1.34.2 gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 7900f26d..c154ef84 100644 --- a/go.sum +++ b/go.sum @@ -127,8 +127,8 @@ golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uI golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= -google.golang.org/grpc v1.66.0 h1:DibZuoBznOxbDQxRINckZcUvnCEvrW9pcWIE2yF9r1c= -google.golang.org/grpc v1.66.0/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/grpc v1.66.1 h1:hO5qAXR19+/Z44hmvIM4dQFMSYX9XcWsByfoxutBpAM= +google.golang.org/grpc v1.66.1/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 7496413e5c7940c1114eb3be36e2a3a27f43c77d Mon Sep 17 00:00:00 2001 From: Kobe Arthur Scofield <26771058+KobeArthurScofield@users.noreply.github.com> Date: Thu, 12 Sep 2024 02:06:11 +0800 Subject: [PATCH 528/867] Remove remnants of global `transport` (#3792) * Remove remenants * Generate pb.go * Remove function --- core/config.pb.go | 137 ++++++++++++---------------- core/config.proto | 11 ++- core/xray.go | 7 -- transport/global/config.go | 13 --- transport/global/config.pb.go | 162 ---------------------------------- transport/global/config.proto | 16 ---- transport/internet/config.go | 14 --- 7 files changed, 62 insertions(+), 298 deletions(-) delete mode 100644 transport/global/config.go delete mode 100644 transport/global/config.pb.go delete mode 100644 transport/global/config.proto diff --git a/core/config.pb.go b/core/config.pb.go index fc31c903..ba952da5 100644 --- a/core/config.pb.go +++ b/core/config.pb.go @@ -1,14 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: core/config.proto package core import ( serial "github.com/xtls/xray-core/common/serial" - global "github.com/xtls/xray-core/transport/global" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -38,12 +37,6 @@ type Config struct { // implement the Feature interface, and its config type must be registered // through common.RegisterConfig. App []*serial.TypedMessage `protobuf:"bytes,4,rep,name=app,proto3" json:"app,omitempty"` - // Transport settings. - // Deprecated. Each inbound and outbound should choose their own transport - // config. Date to remove: 2020-01-13 - // - // Deprecated: Marked as deprecated in core/config.proto. - Transport *global.Config `protobuf:"bytes,5,opt,name=transport,proto3" json:"transport,omitempty"` // Configuration for extensions. The config may not work if corresponding // extension is not loaded into Xray. Xray will ignore such config during // initialization. @@ -103,14 +96,6 @@ func (x *Config) GetApp() []*serial.TypedMessage { return nil } -// Deprecated: Marked as deprecated in core/config.proto. -func (x *Config) GetTransport() *global.Config { - if x != nil { - return x.Transport - } - return nil -} - func (x *Config) GetExtension() []*serial.TypedMessage { if x != nil { return x.Extension @@ -278,60 +263,54 @@ var file_core_config_proto_rawDesc = []byte{ 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x1a, 0x21, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x1d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x6c, 0x6f, - 0x62, 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0xb5, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x07, 0x69, - 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, - 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x07, 0x69, - 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x3c, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, - 0x6e, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, - 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x32, 0x0a, 0x03, 0x61, 0x70, 0x70, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x6f, 0x22, 0xfb, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x07, + 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x07, + 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x3c, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, + 0x75, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, + 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x6f, 0x75, 0x74, + 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x32, 0x0a, 0x03, 0x61, 0x70, 0x70, 0x18, 0x04, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, + 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x52, 0x03, 0x61, 0x70, 0x70, 0x12, 0x3e, 0x0a, 0x09, 0x65, 0x78, 0x74, + 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, + 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, + 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x22, + 0xc0, 0x01, 0x0a, 0x14, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, + 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x4d, 0x0a, 0x11, 0x72, 0x65, + 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, + 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x10, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x52, 0x03, 0x61, 0x70, 0x70, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x42, 0x02, 0x18, 0x01, 0x52, 0x09, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x12, 0x3e, 0x0a, 0x09, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, - 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, - 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, - 0x6f, 0x6e, 0x4a, 0x04, 0x08, 0x03, 0x10, 0x04, 0x22, 0xc0, 0x01, 0x0a, 0x14, 0x49, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x74, 0x61, 0x67, 0x12, 0x4d, 0x0a, 0x11, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x5f, - 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, - 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x52, 0x10, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, - 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0d, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0xef, 0x01, 0x0a, 0x15, - 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x49, 0x0a, 0x0f, 0x73, 0x65, 0x6e, 0x64, 0x65, - 0x72, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, - 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x52, 0x0e, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, - 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0d, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x65, - 0x78, 0x70, 0x69, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x65, 0x78, 0x70, - 0x69, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x3d, 0x0a, - 0x0d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x50, 0x01, - 0x5a, 0x1e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x63, 0x6f, 0x72, 0x65, - 0xaa, 0x02, 0x09, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x43, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x67, 0x65, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, + 0x67, 0x73, 0x22, 0xef, 0x01, 0x0a, 0x15, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, + 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, + 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x49, + 0x0a, 0x0f, 0x73, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, + 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0e, 0x73, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x47, 0x0a, 0x0e, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, + 0x67, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x06, 0x65, 0x78, 0x70, 0x69, 0x72, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6d, + 0x6d, 0x65, 0x6e, 0x74, 0x42, 0x3d, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x50, 0x01, 0x5a, 0x1e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, + 0x72, 0x65, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0xaa, 0x02, 0x09, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x43, + 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -352,23 +331,21 @@ var file_core_config_proto_goTypes = []any{ (*InboundHandlerConfig)(nil), // 1: xray.core.InboundHandlerConfig (*OutboundHandlerConfig)(nil), // 2: xray.core.OutboundHandlerConfig (*serial.TypedMessage)(nil), // 3: xray.common.serial.TypedMessage - (*global.Config)(nil), // 4: xray.transport.Config } var file_core_config_proto_depIdxs = []int32{ 1, // 0: xray.core.Config.inbound:type_name -> xray.core.InboundHandlerConfig 2, // 1: xray.core.Config.outbound:type_name -> xray.core.OutboundHandlerConfig 3, // 2: xray.core.Config.app:type_name -> xray.common.serial.TypedMessage - 4, // 3: xray.core.Config.transport:type_name -> xray.transport.Config - 3, // 4: xray.core.Config.extension:type_name -> xray.common.serial.TypedMessage - 3, // 5: xray.core.InboundHandlerConfig.receiver_settings:type_name -> xray.common.serial.TypedMessage - 3, // 6: xray.core.InboundHandlerConfig.proxy_settings:type_name -> xray.common.serial.TypedMessage - 3, // 7: xray.core.OutboundHandlerConfig.sender_settings:type_name -> xray.common.serial.TypedMessage - 3, // 8: xray.core.OutboundHandlerConfig.proxy_settings:type_name -> xray.common.serial.TypedMessage - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 3, // 3: xray.core.Config.extension:type_name -> xray.common.serial.TypedMessage + 3, // 4: xray.core.InboundHandlerConfig.receiver_settings:type_name -> xray.common.serial.TypedMessage + 3, // 5: xray.core.InboundHandlerConfig.proxy_settings:type_name -> xray.common.serial.TypedMessage + 3, // 6: xray.core.OutboundHandlerConfig.sender_settings:type_name -> xray.common.serial.TypedMessage + 3, // 7: xray.core.OutboundHandlerConfig.proxy_settings:type_name -> xray.common.serial.TypedMessage + 8, // [8:8] is the sub-list for method output_type + 8, // [8:8] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_core_config_proto_init() } diff --git a/core/config.proto b/core/config.proto index 821633a8..0b724bfc 100644 --- a/core/config.proto +++ b/core/config.proto @@ -7,7 +7,6 @@ option java_package = "com.xray.core"; option java_multiple_files = true; import "common/serial/typed_message.proto"; -import "transport/global/config.proto"; // Config is the master config of Xray. Xray takes this config as input and // functions accordingly. @@ -26,15 +25,15 @@ message Config { // through common.RegisterConfig. repeated xray.common.serial.TypedMessage app = 4; - // Transport settings. - // Deprecated. Each inbound and outbound should choose their own transport - // config. Date to remove: 2020-01-13 - xray.transport.Config transport = 5 [deprecated = true]; - // Configuration for extensions. The config may not work if corresponding // extension is not loaded into Xray. Xray will ignore such config during // initialization. repeated xray.common.serial.TypedMessage extension = 6; + + // Transport settings. + // Deprecated. Each inbound and outbound should choose their own transport + // config. Date to remove: 2020-01-13 + // xray.transport.Config transport = 5 [deprecated = true]; } // InboundHandlerConfig is the configuration for inbound handler. diff --git a/core/xray.go b/core/xray.go index a81cf19b..09d35d9f 100644 --- a/core/xray.go +++ b/core/xray.go @@ -185,13 +185,6 @@ func initInstanceWithConfig(config *Config, server *Instance) (bool, error) { server.ctx = context.WithValue(server.ctx, "cone", platform.NewEnvFlag(platform.UseCone).GetValue(func() string { return "" }) != "true") - if config.Transport != nil { - features.PrintDeprecatedFeatureWarning("global transport settings") - } - if err := config.Transport.Apply(); err != nil { - return true, err - } - for _, appSettings := range config.App { settings, err := appSettings.GetInstance() if err != nil { diff --git a/transport/global/config.go b/transport/global/config.go deleted file mode 100644 index b6dd8e2a..00000000 --- a/transport/global/config.go +++ /dev/null @@ -1,13 +0,0 @@ -package global - -import ( - "github.com/xtls/xray-core/transport/internet" -) - -// Apply applies this Config. -func (c *Config) Apply() error { - if c == nil { - return nil - } - return internet.ApplyGlobalTransportSettings(c.TransportSettings) -} diff --git a/transport/global/config.pb.go b/transport/global/config.pb.go deleted file mode 100644 index 7b3abb99..00000000 --- a/transport/global/config.pb.go +++ /dev/null @@ -1,162 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 -// source: transport/global/config.proto - -package global - -import ( - internet "github.com/xtls/xray-core/transport/internet" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// Global transport settings. This affects all type of connections that go -// through Xray. Deprecated. Use each settings in StreamConfig. -// -// Deprecated: Marked as deprecated in transport/global/config.proto. -type Config struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - TransportSettings []*internet.TransportConfig `protobuf:"bytes,1,rep,name=transport_settings,json=transportSettings,proto3" json:"transport_settings,omitempty"` -} - -func (x *Config) Reset() { - *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_global_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Config) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Config) ProtoMessage() {} - -func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_transport_global_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Config.ProtoReflect.Descriptor instead. -func (*Config) Descriptor() ([]byte, []int) { - return file_transport_global_config_proto_rawDescGZIP(), []int{0} -} - -func (x *Config) GetTransportSettings() []*internet.TransportConfig { - if x != nil { - return x.TransportSettings - } - return nil -} - -var File_transport_global_config_proto protoreflect.FileDescriptor - -var file_transport_global_config_proto_rawDesc = []byte{ - 0x0a, 0x1d, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x6c, 0x6f, 0x62, - 0x61, 0x6c, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x0e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x1a, - 0x1f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x65, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x57, 0x0a, 0x12, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, - 0x6e, 0x67, 0x73, 0x3a, 0x02, 0x18, 0x01, 0x42, 0x61, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x67, 0x6c, - 0x6f, 0x62, 0x61, 0x6c, 0x50, 0x01, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, - 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x67, 0x6c, 0x6f, 0x62, - 0x61, 0x6c, 0xaa, 0x02, 0x15, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_transport_global_config_proto_rawDescOnce sync.Once - file_transport_global_config_proto_rawDescData = file_transport_global_config_proto_rawDesc -) - -func file_transport_global_config_proto_rawDescGZIP() []byte { - file_transport_global_config_proto_rawDescOnce.Do(func() { - file_transport_global_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_global_config_proto_rawDescData) - }) - return file_transport_global_config_proto_rawDescData -} - -var file_transport_global_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_global_config_proto_goTypes = []any{ - (*Config)(nil), // 0: xray.transport.Config - (*internet.TransportConfig)(nil), // 1: xray.transport.internet.TransportConfig -} -var file_transport_global_config_proto_depIdxs = []int32{ - 1, // 0: xray.transport.Config.transport_settings:type_name -> xray.transport.internet.TransportConfig - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_transport_global_config_proto_init() } -func file_transport_global_config_proto_init() { - if File_transport_global_config_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_transport_global_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_transport_global_config_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_transport_global_config_proto_goTypes, - DependencyIndexes: file_transport_global_config_proto_depIdxs, - MessageInfos: file_transport_global_config_proto_msgTypes, - }.Build() - File_transport_global_config_proto = out.File - file_transport_global_config_proto_rawDesc = nil - file_transport_global_config_proto_goTypes = nil - file_transport_global_config_proto_depIdxs = nil -} diff --git a/transport/global/config.proto b/transport/global/config.proto deleted file mode 100644 index 367036ec..00000000 --- a/transport/global/config.proto +++ /dev/null @@ -1,16 +0,0 @@ -syntax = "proto3"; - -package xray.transport; -option csharp_namespace = "Xray.Transport.Global"; -option go_package = "github.com/xtls/xray-core/transport/global"; -option java_package = "com.xray.transport.global"; -option java_multiple_files = true; - -import "transport/internet/config.proto"; - -// Global transport settings. This affects all type of connections that go -// through Xray. Deprecated. Use each settings in StreamConfig. -message Config { - option deprecated = true; - repeated xray.transport.internet.TransportConfig transport_settings = 1; -} diff --git a/transport/internet/config.go b/transport/internet/config.go index 5968b564..96cf53b7 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -3,14 +3,12 @@ package internet import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/serial" - "github.com/xtls/xray-core/features" ) type ConfigCreator func() interface{} var ( globalTransportConfigCreatorCache = make(map[string]ConfigCreator) - globalTransportSettings []*TransportConfig ) var strategy = [][]byte{ @@ -105,12 +103,6 @@ func (c *StreamConfig) GetTransportSettingsFor(protocol string) (interface{}, er } } - for _, settings := range globalTransportSettings { - if settings.GetUnifiedProtocolName() == protocol { - return settings.GetTypedSettings() - } - } - return CreateTransportConfig(protocol) } @@ -127,12 +119,6 @@ func (c *StreamConfig) HasSecuritySettings() bool { return len(c.SecurityType) > 0 } -func ApplyGlobalTransportSettings(settings []*TransportConfig) error { - features.PrintDeprecatedFeatureWarning("global transport settings") - globalTransportSettings = settings - return nil -} - func (c *ProxyConfig) HasTag() bool { return c != nil && len(c.Tag) > 0 } From 1b607ff8742d100bebf7193ff2d64f7fd7eabe89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 12 Sep 2024 22:34:45 +0800 Subject: [PATCH 529/867] DNS: Do not hit cache if encounted err (#3784) --- app/dns/nameserver_doh.go | 2 +- app/dns/nameserver_quic.go | 2 +- app/dns/nameserver_tcp.go | 2 +- app/dns/nameserver_udp.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index d34709e9..bc160135 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -365,7 +365,7 @@ func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, clientIP net errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { ips, err := s.findIPsForDomain(fqdn, option) - if err != errRecordNotFound { + if err == nil || err == dns_feature.ErrEmptyResponse { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, err diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 2d56f43e..435cd0a3 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -300,7 +300,7 @@ func (s *QUICNameServer) QueryIP(ctx context.Context, domain string, clientIP ne errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { ips, err := s.findIPsForDomain(fqdn, option) - if err != errRecordNotFound { + if err == nil || err == dns_feature.ErrEmptyResponse { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, err diff --git a/app/dns/nameserver_tcp.go b/app/dns/nameserver_tcp.go index bc5bab44..0146e007 100644 --- a/app/dns/nameserver_tcp.go +++ b/app/dns/nameserver_tcp.go @@ -323,7 +323,7 @@ func (s *TCPNameServer) QueryIP(ctx context.Context, domain string, clientIP net errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { ips, err := s.findIPsForDomain(fqdn, option) - if err != errRecordNotFound { + if err == nil || err == dns_feature.ErrEmptyResponse { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, err diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index 24a99593..47d70435 100644 --- a/app/dns/nameserver_udp.go +++ b/app/dns/nameserver_udp.go @@ -250,7 +250,7 @@ func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, clientIP errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { ips, err := s.findIPsForDomain(fqdn, option) - if err != errRecordNotFound { + if err == nil || err == dns_feature.ErrEmptyResponse { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, err From 1919a1e86f987165a7777308b443671750094f41 Mon Sep 17 00:00:00 2001 From: Kobe Arthur Scofield <26771058+KobeArthurScofield@users.noreply.github.com> Date: Thu, 12 Sep 2024 22:38:17 +0800 Subject: [PATCH 530/867] Log: Improve feature deprecation/removal logs (#3793) * Improve feature deprecation/removal logs * Add a note about the new feature * When the feature has removed, this should be an error not a warning --- features/feature.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/features/feature.go b/features/feature.go index 7c749622..4ed71600 100644 --- a/features/feature.go +++ b/features/feature.go @@ -18,5 +18,10 @@ type Feature interface { // PrintDeprecatedFeatureWarning prints a warning for deprecated feature. func PrintDeprecatedFeatureWarning(feature string) { - errors.LogInfo(context.Background(), "You are using a deprecated feature: " + feature + ". Please update your config file with latest configuration format, or update your client software.") + errors.LogWarning(context.Background(), "You are using a deprecated feature: " + feature + ". Please update your config file(s) with latest configuration format, or update your client software.") +} + +// PrintRemovedFeatureError prints an error message for removed feature. And after long enough time the message can also be removed, use as an indicator. +func PrintRemovedFeatureError(feature string) { + errors.New("The feature " + feature + " is removed. Please update your config file(s) according to release notes and documentations.") } From 12c3908e8c8e3a82b31ffc23f642a93d422c8eed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 10:38:51 -0400 Subject: [PATCH 531/867] Bump google.golang.org/grpc from 1.66.1 to 1.66.2 (#3798) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.66.1 to 1.66.2. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.66.1...v1.66.2) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8c8473a4..e851f44c 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.8.0 golang.org/x/sys v0.25.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.66.1 + google.golang.org/grpc v1.66.2 google.golang.org/protobuf v1.34.2 gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index c154ef84..31a0e0f8 100644 --- a/go.sum +++ b/go.sum @@ -127,8 +127,8 @@ golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uI golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= -google.golang.org/grpc v1.66.1 h1:hO5qAXR19+/Z44hmvIM4dQFMSYX9XcWsByfoxutBpAM= -google.golang.org/grpc v1.66.1/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= +google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 3a8c5f38e824203da59a09e277e56bf961f37175 Mon Sep 17 00:00:00 2001 From: vnxme <46669194+vnxme@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:48:41 +0300 Subject: [PATCH 532/867] Routing: Add regexp syntax support to UserMatcher (#3799) --- app/router/condition.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/router/condition.go b/app/router/condition.go index d53530e0..dc806372 100644 --- a/app/router/condition.go +++ b/app/router/condition.go @@ -192,18 +192,28 @@ func (v NetworkMatcher) Apply(ctx routing.Context) bool { } type UserMatcher struct { - user []string + user []string + pattern []*regexp.Regexp } func NewUserMatcher(users []string) *UserMatcher { usersCopy := make([]string, 0, len(users)) + patternsCopy := make([]*regexp.Regexp, 0, len(users)) for _, user := range users { if len(user) > 0 { + if len(user) > 7 && strings.HasPrefix(user, "regexp:") { + if re, err := regexp.Compile(user[7:]); err != nil { + patternsCopy = append(patternsCopy, re) + } + // Items of users slice with an invalid regexp syntax are ignored. + continue + } usersCopy = append(usersCopy, user) } } return &UserMatcher{ - user: usersCopy, + user: usersCopy, + pattern: patternsCopy, } } @@ -218,6 +228,11 @@ func (v *UserMatcher) Apply(ctx routing.Context) bool { return true } } + for _, re := range v.pattern { + if re.MatchString(user) { + return true + } + } return false } From c259e4e4a6e22b34ca2dbbac026fcc2da307919e Mon Sep 17 00:00:00 2001 From: Torikki <84802990+torikki-tou@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:51:26 +0300 Subject: [PATCH 533/867] Allow to inject custom validator in VLESS controller (#3453) * Make Validator an interface * Move validator creation away from VLESS inbound controller --- proxy/vless/encoding/encoding.go | 2 +- proxy/vless/encoding/encoding_test.go | 6 ++--- proxy/vless/inbound/inbound.go | 32 +++++++++++++++------------ proxy/vless/validator.go | 16 +++++++++----- 4 files changed, 33 insertions(+), 23 deletions(-) diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index 038c0ed3..f0699b96 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -64,7 +64,7 @@ func EncodeRequestHeader(writer io.Writer, request *protocol.RequestHeader, requ } // DecodeRequestHeader decodes and returns (if successful) a RequestHeader from an input stream. -func DecodeRequestHeader(isfb bool, first *buf.Buffer, reader io.Reader, validator *vless.Validator) (*protocol.RequestHeader, *Addons, bool, error) { +func DecodeRequestHeader(isfb bool, first *buf.Buffer, reader io.Reader, validator vless.Validator) (*protocol.RequestHeader, *Addons, bool, error) { buffer := buf.StackNew() defer buffer.Release() diff --git a/proxy/vless/encoding/encoding_test.go b/proxy/vless/encoding/encoding_test.go index ee7c6df0..9180154a 100644 --- a/proxy/vless/encoding/encoding_test.go +++ b/proxy/vless/encoding/encoding_test.go @@ -42,7 +42,7 @@ func TestRequestSerialization(t *testing.T) { buffer := buf.StackNew() common.Must(EncodeRequestHeader(&buffer, expectedRequest, expectedAddons)) - Validator := new(vless.Validator) + Validator := new(vless.MemoryValidator) Validator.Add(user) actualRequest, actualAddons, _, err := DecodeRequestHeader(false, nil, &buffer, Validator) @@ -83,7 +83,7 @@ func TestInvalidRequest(t *testing.T) { buffer := buf.StackNew() common.Must(EncodeRequestHeader(&buffer, expectedRequest, expectedAddons)) - Validator := new(vless.Validator) + Validator := new(vless.MemoryValidator) Validator.Add(user) _, _, _, err := DecodeRequestHeader(false, nil, &buffer, Validator) @@ -114,7 +114,7 @@ func TestMuxRequest(t *testing.T) { buffer := buf.StackNew() common.Must(EncodeRequestHeader(&buffer, expectedRequest, expectedAddons)) - Validator := new(vless.Validator) + Validator := new(vless.MemoryValidator) Validator.Add(user) actualRequest, actualAddons, _, err := DecodeRequestHeader(false, nil, &buffer, Validator) diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index 3bb2c09c..bcd8a24b 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -45,7 +45,21 @@ func init() { }); err != nil { return nil, err } - return New(ctx, config.(*Config), dc) + + c := config.(*Config) + + validator := new(vless.MemoryValidator) + for _, user := range c.Clients { + u, err := user.ToMemoryUser() + if err != nil { + return nil, errors.New("failed to get VLESS user").Base(err).AtError() + } + if err := validator.Add(u); err != nil { + return nil, errors.New("failed to initiate user").Base(err).AtError() + } + } + + return New(ctx, c, dc, validator) })) } @@ -53,30 +67,20 @@ func init() { type Handler struct { inboundHandlerManager feature_inbound.Manager policyManager policy.Manager - validator *vless.Validator + validator vless.Validator dns dns.Client fallbacks map[string]map[string]map[string]*Fallback // or nil // regexps map[string]*regexp.Regexp // or nil } // New creates a new VLess inbound handler. -func New(ctx context.Context, config *Config, dc dns.Client) (*Handler, error) { +func New(ctx context.Context, config *Config, dc dns.Client, validator vless.Validator) (*Handler, error) { v := core.MustFromContext(ctx) handler := &Handler{ inboundHandlerManager: v.GetFeature(feature_inbound.ManagerType()).(feature_inbound.Manager), policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), - validator: new(vless.Validator), dns: dc, - } - - for _, user := range config.Clients { - u, err := user.ToMemoryUser() - if err != nil { - return nil, errors.New("failed to get VLESS user").Base(err).AtError() - } - if err := handler.AddUser(ctx, u); err != nil { - return nil, errors.New("failed to initiate user").Base(err).AtError() - } + validator: validator, } if config.Fallbacks != nil { diff --git a/proxy/vless/validator.go b/proxy/vless/validator.go index 72038cab..596cb62f 100644 --- a/proxy/vless/validator.go +++ b/proxy/vless/validator.go @@ -9,15 +9,21 @@ import ( "github.com/xtls/xray-core/common/uuid" ) -// Validator stores valid VLESS users. -type Validator struct { +type Validator interface { + Get(id uuid.UUID) *protocol.MemoryUser + Add(u *protocol.MemoryUser) error + Del(email string) error +} + +// MemoryValidator stores valid VLESS users. +type MemoryValidator struct { // Considering email's usage here, map + sync.Mutex/RWMutex may have better performance. email sync.Map users sync.Map } // Add a VLESS user, Email must be empty or unique. -func (v *Validator) Add(u *protocol.MemoryUser) error { +func (v *MemoryValidator) Add(u *protocol.MemoryUser) error { if u.Email != "" { _, loaded := v.email.LoadOrStore(strings.ToLower(u.Email), u) if loaded { @@ -29,7 +35,7 @@ func (v *Validator) Add(u *protocol.MemoryUser) error { } // Del a VLESS user with a non-empty Email. -func (v *Validator) Del(e string) error { +func (v *MemoryValidator) Del(e string) error { if e == "" { return errors.New("Email must not be empty.") } @@ -44,7 +50,7 @@ func (v *Validator) Del(e string) error { } // Get a VLESS user with UUID, nil if user doesn't exist. -func (v *Validator) Get(id uuid.UUID) *protocol.MemoryUser { +func (v *MemoryValidator) Get(id uuid.UUID) *protocol.MemoryUser { u, _ := v.users.Load(id) if u != nil { return u.(*protocol.MemoryUser) From 88ae774cced77a5698d2ba6c1ac2bb0e740ae968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Sat, 14 Sep 2024 00:26:36 +0800 Subject: [PATCH 534/867] =?UTF-8?q?Sniff:=20Routing=20=E2=80=9Cattrs?= =?UTF-8?q?=E2=80=9D=20support=20non=20http=20inbound=20(#3808)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Sniff: Support attrs route in non http inbound * Add capability to sniff method and path * Fix test * Skip HTTP inbound PlainHTTP mode * Fix test again --- app/dispatcher/sniffer.go | 2 +- common/protocol/http/sniff.go | 27 +++++++++++++++++++++++++-- common/protocol/http/sniff_test.go | 3 ++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/dispatcher/sniffer.go b/app/dispatcher/sniffer.go index 4d62f1b3..c138447d 100644 --- a/app/dispatcher/sniffer.go +++ b/app/dispatcher/sniffer.go @@ -35,7 +35,7 @@ type Sniffer struct { func NewSniffer(ctx context.Context) *Sniffer { ret := &Sniffer{ sniffer: []protocolSnifferWithMetadata{ - {func(c context.Context, b []byte) (SniffResult, error) { return http.SniffHTTP(b) }, false, net.Network_TCP}, + {func(c context.Context, b []byte) (SniffResult, error) { return http.SniffHTTP(b, c) }, false, net.Network_TCP}, {func(c context.Context, b []byte) (SniffResult, error) { return tls.SniffTLS(b) }, false, net.Network_TCP}, {func(c context.Context, b []byte) (SniffResult, error) { return bittorrent.SniffBittorrent(b) }, false, net.Network_TCP}, {func(c context.Context, b []byte) (SniffResult, error) { return quic.SniffQUIC(b) }, false, net.Network_UDP}, diff --git a/common/protocol/http/sniff.go b/common/protocol/http/sniff.go index ceedede2..e85a0792 100644 --- a/common/protocol/http/sniff.go +++ b/common/protocol/http/sniff.go @@ -2,11 +2,13 @@ package http import ( "bytes" + "context" "errors" "strings" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/session" ) type version byte @@ -56,7 +58,14 @@ func beginWithHTTPMethod(b []byte) error { return errNotHTTPMethod } -func SniffHTTP(b []byte) (*SniffHeader, error) { +func SniffHTTP(b []byte, c context.Context) (*SniffHeader, error) { + content := session.ContentFromContext(c) + ShouldSniffAttr := true + // If content.Attributes have information, that means it comes from HTTP inbound PlainHTTP mode. + // It will set attributes, so skip it. + if content == nil || len(content.Attributes) != 0 { + ShouldSniffAttr = false + } if err := beginWithHTTPMethod(b); err != nil { return nil, err } @@ -76,8 +85,12 @@ func SniffHTTP(b []byte) (*SniffHeader, error) { continue } key := strings.ToLower(string(parts[0])) + value := string(bytes.TrimSpace(parts[1])) + if ShouldSniffAttr { + content.SetAttribute(key, value) // Put header in attribute + } if key == "host" { - rawHost := strings.ToLower(string(bytes.TrimSpace(parts[1]))) + rawHost := strings.ToLower(value) dest, err := ParseHost(rawHost, net.Port(80)) if err != nil { return nil, err @@ -85,6 +98,16 @@ func SniffHTTP(b []byte) (*SniffHeader, error) { sh.host = dest.Address.String() } } + // Parse request line + // Request line is like this + // "GET /homo/114514 HTTP/1.1" + if len(headers) > 0 && ShouldSniffAttr { + RequestLineParts := bytes.Split(headers[0], []byte{' '}) + if len(RequestLineParts) == 3 { + content.SetAttribute(":method", string(RequestLineParts[0])) + content.SetAttribute(":path", string(RequestLineParts[1])) + } + } if len(sh.host) > 0 { return sh, nil diff --git a/common/protocol/http/sniff_test.go b/common/protocol/http/sniff_test.go index fff66415..09ce7d6c 100644 --- a/common/protocol/http/sniff_test.go +++ b/common/protocol/http/sniff_test.go @@ -1,6 +1,7 @@ package http_test import ( + "context" "testing" . "github.com/xtls/xray-core/common/protocol/http" @@ -88,7 +89,7 @@ first_name=John&last_name=Doe&action=Submit`, } for _, test := range cases { - header, err := SniffHTTP([]byte(test.input)) + header, err := SniffHTTP([]byte(test.input), context.TODO()) if test.err { if err == nil { t.Errorf("Expect error but nil, in test: %v", test) From 7970f240de69d0da5efd1d136e8aa581274a4c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Sat, 14 Sep 2024 01:05:19 +0800 Subject: [PATCH 535/867] Log: show the matching rule tag (#3809) --- app/dispatcher/default.go | 8 ++++++-- app/router/command/config.go | 4 ++++ app/router/router.go | 7 ++++++- features/routing/router.go | 3 +++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 34119ac2..f38b56c9 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -10,8 +10,8 @@ import ( "time" "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/log" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" @@ -421,7 +421,11 @@ func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport. outTag := route.GetOutboundTag() if h := d.ohm.GetHandler(outTag); h != nil { isPickRoute = 2 - errors.LogInfo(ctx, "taking detour [", outTag, "] for [", destination, "]") + if route.GetRuleTag() == "" { + errors.LogInfo(ctx, "taking detour [", outTag, "] for [", destination, "]") + } else { + errors.LogInfo(ctx, "Hit route rule: [", route.GetRuleTag(), "] so taking detour [", outTag, "] for [", destination, "]") + } handler = h } else { errors.LogWarning(ctx, "non existing outTag: ", outTag) diff --git a/app/router/command/config.go b/app/router/command/config.go index a033e731..8c2e1343 100644 --- a/app/router/command/config.go +++ b/app/router/command/config.go @@ -28,6 +28,10 @@ func (c routingContext) GetTargetPort() net.Port { return net.Port(c.RoutingContext.GetTargetPort()) } +func (c routingContext) GetRuleTag() string { + return "" +} + // GetSkipDNSResolve is a mock implementation here to match the interface, // SkipDNSResolve is set from dns module, no use if coming from a protobuf object? // TODO: please confirm @Vigilans diff --git a/app/router/router.go b/app/router/router.go index 753ddfa8..2a1e2e62 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -34,6 +34,7 @@ type Route struct { routing.Context outboundGroupTags []string outboundTag string + ruleTag string } // Init initializes the Router. @@ -89,7 +90,7 @@ func (r *Router) PickRoute(ctx routing.Context) (routing.Route, error) { if err != nil { return nil, err } - return &Route{Context: ctx, outboundTag: tag}, nil + return &Route{Context: ctx, outboundTag: tag, ruleTag: rule.RuleTag}, nil } // AddRule implements routing.Router. @@ -239,6 +240,10 @@ func (r *Route) GetOutboundTag() string { return r.outboundTag } +func (r *Route) GetRuleTag() string { + return r.ruleTag +} + func init() { common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { r := new(Router) diff --git a/features/routing/router.go b/features/routing/router.go index 97246cdb..174d59fd 100644 --- a/features/routing/router.go +++ b/features/routing/router.go @@ -30,6 +30,9 @@ type Route interface { // GetOutboundTag returns the tag of the outbound the connection was dispatched to. GetOutboundTag() string + + // GetRuleTag returns the matching rule tag for debugging if exists + GetRuleTag() string } // RouterType return the type of Router interface. Can be used to implement common.HasType. From 781aaee21f6ca65fb1e7e73f03c464b21aa3c3d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Sat, 14 Sep 2024 01:32:43 +0800 Subject: [PATCH 536/867] QUIC sniffer: handle multiple initial packets (#3802) * QUIC sniffer: handle multiple initial packets Basically copied from Vigilans/v2ray-core@8f33db0 Co-Authored-By: Vigilans * Remove unnecessary file --------- Co-authored-by: Vigilans --- app/dispatcher/default.go | 10 +- common/buf/buffer.go | 15 ++ common/protocol/quic/sniff.go | 370 ++++++++++++++++++---------------- 3 files changed, 217 insertions(+), 178 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index f38b56c9..de8d1913 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -41,8 +41,14 @@ func (r *cachedReader) Cache(b *buf.Buffer) { if !mb.IsEmpty() { r.cache, _ = buf.MergeMulti(r.cache, mb) } - b.Clear() - rawBytes := b.Extend(buf.Size) + cacheLen := r.cache.Len() + if cacheLen <= b.Cap() { + b.Clear() + } else { + b.Release() + *b = *buf.NewWithSize(cacheLen) + } + rawBytes := b.Extend(cacheLen) n := r.cache.Copy(rawBytes) b.Resize(0, int32(n)) r.Unlock() diff --git a/common/buf/buffer.go b/common/buf/buffer.go index 57105d67..15d4d4a5 100644 --- a/common/buf/buffer.go +++ b/common/buf/buffer.go @@ -207,6 +207,21 @@ func (b *Buffer) Len() int32 { return b.end - b.start } +// Cap returns the capacity of the buffer content. +func (b *Buffer) Cap() int32 { + if b == nil { + return 0 + } + return int32(len(b.v)) +} + +// NewWithSize creates a Buffer with 0 length and capacity with at least the given size. +func NewWithSize(size int32) *Buffer { + return &Buffer{ + v: bytespool.Alloc(size), + } +} + // IsEmpty returns true if the buffer is empty. func (b *Buffer) IsEmpty() bool { return b.Len() == 0 diff --git a/common/protocol/quic/sniff.go b/common/protocol/quic/sniff.go index bf461464..8719a085 100644 --- a/common/protocol/quic/sniff.go +++ b/common/protocol/quic/sniff.go @@ -47,206 +47,224 @@ var ( ) func SniffQUIC(b []byte) (*SniffHeader, error) { - buffer := buf.FromBytes(b) - typeByte, err := buffer.ReadByte() - if err != nil { - return nil, errNotQuic - } - isLongHeader := typeByte&0x80 > 0 - if !isLongHeader || typeByte&0x40 == 0 { - return nil, errNotQuicInitial - } + // Crypto data separated across packets + cryptoLen := 0 + cryptoData := bytespool.Alloc(int32(len(b))) + defer bytespool.Free(cryptoData) - vb, err := buffer.ReadBytes(4) - if err != nil { - return nil, errNotQuic - } + // Parse QUIC packets + for len(b) > 0 { + buffer := buf.FromBytes(b) + typeByte, err := buffer.ReadByte() + if err != nil { + return nil, errNotQuic + } - versionNumber := binary.BigEndian.Uint32(vb) + isLongHeader := typeByte&0x80 > 0 + if !isLongHeader || typeByte&0x40 == 0 { + return nil, errNotQuicInitial + } - if versionNumber != 0 && typeByte&0x40 == 0 { - return nil, errNotQuic - } else if versionNumber != versionDraft29 && versionNumber != version1 { - return nil, errNotQuic - } + vb, err := buffer.ReadBytes(4) + if err != nil { + return nil, errNotQuic + } - if (typeByte&0x30)>>4 != 0x0 { - return nil, errNotQuicInitial - } + versionNumber := binary.BigEndian.Uint32(vb) + if versionNumber != 0 && typeByte&0x40 == 0 { + return nil, errNotQuic + } else if versionNumber != versionDraft29 && versionNumber != version1 { + return nil, errNotQuic + } - var destConnID []byte - if l, err := buffer.ReadByte(); err != nil { - return nil, errNotQuic - } else if destConnID, err = buffer.ReadBytes(int32(l)); err != nil { - return nil, errNotQuic - } + packetType := (typeByte & 0x30) >> 4 + isQuicInitial := packetType == 0x0 - if l, err := buffer.ReadByte(); err != nil { - return nil, errNotQuic - } else if common.Error2(buffer.ReadBytes(int32(l))) != nil { - return nil, errNotQuic - } + var destConnID []byte + if l, err := buffer.ReadByte(); err != nil { + return nil, errNotQuic + } else if destConnID, err = buffer.ReadBytes(int32(l)); err != nil { + return nil, errNotQuic + } - tokenLen, err := quicvarint.Read(buffer) - if err != nil || tokenLen > uint64(len(b)) { - return nil, errNotQuic - } + if l, err := buffer.ReadByte(); err != nil { + return nil, errNotQuic + } else if common.Error2(buffer.ReadBytes(int32(l))) != nil { + return nil, errNotQuic + } - if _, err = buffer.ReadBytes(int32(tokenLen)); err != nil { - return nil, errNotQuic - } + tokenLen, err := quicvarint.Read(buffer) + if err != nil || tokenLen > uint64(len(b)) { + return nil, errNotQuic + } - packetLen, err := quicvarint.Read(buffer) - if err != nil { - return nil, errNotQuic - } + if _, err = buffer.ReadBytes(int32(tokenLen)); err != nil { + return nil, errNotQuic + } - hdrLen := len(b) - int(buffer.Len()) + packetLen, err := quicvarint.Read(buffer) + if err != nil { + return nil, errNotQuic + } - origPNBytes := make([]byte, 4) - copy(origPNBytes, b[hdrLen:hdrLen+4]) + hdrLen := len(b) - int(buffer.Len()) + if len(b) < hdrLen+int(packetLen) { + return nil, common.ErrNoClue // Not enough data to read as a QUIC packet. QUIC is UDP-based, so this is unlikely to happen. + } - var salt []byte - if versionNumber == version1 { - salt = quicSalt - } else { - salt = quicSaltOld - } - initialSecret := hkdf.Extract(crypto.SHA256.New, destConnID, salt) - secret := hkdfExpandLabel(crypto.SHA256, initialSecret, []byte{}, "client in", crypto.SHA256.Size()) - hpKey := hkdfExpandLabel(initialSuite.Hash, secret, []byte{}, "quic hp", initialSuite.KeyLen) - block, err := aes.NewCipher(hpKey) - if err != nil { - return nil, err - } + restPayload := b[hdrLen+int(packetLen):] + if !isQuicInitial { // Skip this packet if it's not initial packet + b = restPayload + continue + } - cache := buf.New() - defer cache.Release() + origPNBytes := make([]byte, 4) + copy(origPNBytes, b[hdrLen:hdrLen+4]) - mask := cache.Extend(int32(block.BlockSize())) - block.Encrypt(mask, b[hdrLen+4:hdrLen+4+16]) - b[0] ^= mask[0] & 0xf - for i := range b[hdrLen : hdrLen+4] { - b[hdrLen+i] ^= mask[i+1] - } - packetNumberLength := b[0]&0x3 + 1 - if packetNumberLength != 1 { - return nil, errNotQuicInitial - } - var packetNumber uint32 - { - n, err := buffer.ReadByte() + var salt []byte + if versionNumber == version1 { + salt = quicSalt + } else { + salt = quicSaltOld + } + initialSecret := hkdf.Extract(crypto.SHA256.New, destConnID, salt) + secret := hkdfExpandLabel(crypto.SHA256, initialSecret, []byte{}, "client in", crypto.SHA256.Size()) + hpKey := hkdfExpandLabel(initialSuite.Hash, secret, []byte{}, "quic hp", initialSuite.KeyLen) + block, err := aes.NewCipher(hpKey) if err != nil { return nil, err } - packetNumber = uint32(n) - } - if packetNumber != 0 && packetNumber != 1 { - return nil, errNotQuicInitial - } + cache := buf.New() + defer cache.Release() - extHdrLen := hdrLen + int(packetNumberLength) - copy(b[extHdrLen:hdrLen+4], origPNBytes[packetNumberLength:]) - data := b[extHdrLen : int(packetLen)+hdrLen] - - key := hkdfExpandLabel(crypto.SHA256, secret, []byte{}, "quic key", 16) - iv := hkdfExpandLabel(crypto.SHA256, secret, []byte{}, "quic iv", 12) - cipher := AEADAESGCMTLS13(key, iv) - nonce := cache.Extend(int32(cipher.NonceSize())) - binary.BigEndian.PutUint64(nonce[len(nonce)-8:], uint64(packetNumber)) - decrypted, err := cipher.Open(b[extHdrLen:extHdrLen], nonce, data, b[:extHdrLen]) - if err != nil { - return nil, err - } - buffer = buf.FromBytes(decrypted) - - cryptoLen := uint(0) - cryptoData := bytespool.Alloc(buffer.Len()) - defer bytespool.Free(cryptoData) - for i := 0; !buffer.IsEmpty(); i++ { - frameType := byte(0x0) // Default to PADDING frame - for frameType == 0x0 && !buffer.IsEmpty() { - frameType, _ = buffer.ReadByte() + mask := cache.Extend(int32(block.BlockSize())) + block.Encrypt(mask, b[hdrLen+4:hdrLen+4+16]) + b[0] ^= mask[0] & 0xf + for i := range b[hdrLen : hdrLen+4] { + b[hdrLen+i] ^= mask[i+1] } - switch frameType { - case 0x00: // PADDING frame - case 0x01: // PING frame - case 0x02, 0x03: // ACK frame - if _, err = quicvarint.Read(buffer); err != nil { // Field: Largest Acknowledged - return nil, io.ErrUnexpectedEOF - } - if _, err = quicvarint.Read(buffer); err != nil { // Field: ACK Delay - return nil, io.ErrUnexpectedEOF - } - ackRangeCount, err := quicvarint.Read(buffer) // Field: ACK Range Count - if err != nil { - return nil, io.ErrUnexpectedEOF - } - if _, err = quicvarint.Read(buffer); err != nil { // Field: First ACK Range - return nil, io.ErrUnexpectedEOF - } - for i := 0; i < int(ackRangeCount); i++ { // Field: ACK Range - if _, err = quicvarint.Read(buffer); err != nil { // Field: ACK Range -> Gap - return nil, io.ErrUnexpectedEOF - } - if _, err = quicvarint.Read(buffer); err != nil { // Field: ACK Range -> ACK Range Length - return nil, io.ErrUnexpectedEOF - } - } - if frameType == 0x03 { - if _, err = quicvarint.Read(buffer); err != nil { // Field: ECN Counts -> ECT0 Count - return nil, io.ErrUnexpectedEOF - } - if _, err = quicvarint.Read(buffer); err != nil { // Field: ECN Counts -> ECT1 Count - return nil, io.ErrUnexpectedEOF - } - if _, err = quicvarint.Read(buffer); err != nil { //nolint:misspell // Field: ECN Counts -> ECT-CE Count - return nil, io.ErrUnexpectedEOF - } - } - case 0x06: // CRYPTO frame, we will use this frame - offset, err := quicvarint.Read(buffer) // Field: Offset - if err != nil { - return nil, io.ErrUnexpectedEOF - } - length, err := quicvarint.Read(buffer) // Field: Length - if err != nil || length > uint64(buffer.Len()) { - return nil, io.ErrUnexpectedEOF - } - if cryptoLen < uint(offset+length) { - cryptoLen = uint(offset + length) - } - if _, err := buffer.Read(cryptoData[offset : offset+length]); err != nil { // Field: Crypto Data - return nil, io.ErrUnexpectedEOF - } - case 0x1c: // CONNECTION_CLOSE frame, only 0x1c is permitted in initial packet - if _, err = quicvarint.Read(buffer); err != nil { // Field: Error Code - return nil, io.ErrUnexpectedEOF - } - if _, err = quicvarint.Read(buffer); err != nil { // Field: Frame Type - return nil, io.ErrUnexpectedEOF - } - length, err := quicvarint.Read(buffer) // Field: Reason Phrase Length - if err != nil { - return nil, io.ErrUnexpectedEOF - } - if _, err := buffer.ReadBytes(int32(length)); err != nil { // Field: Reason Phrase - return nil, io.ErrUnexpectedEOF - } - default: - // Only above frame types are permitted in initial packet. - // See https://www.rfc-editor.org/rfc/rfc9000.html#section-17.2.2-8 + packetNumberLength := b[0]&0x3 + 1 + if packetNumberLength != 1 { return nil, errNotQuicInitial } - } + var packetNumber uint32 + { + n, err := buffer.ReadByte() + if err != nil { + return nil, err + } + packetNumber = uint32(n) + } - tlsHdr := &ptls.SniffHeader{} - err = ptls.ReadClientHello(cryptoData[:cryptoLen], tlsHdr) - if err != nil { - return nil, err + extHdrLen := hdrLen + int(packetNumberLength) + copy(b[extHdrLen:hdrLen+4], origPNBytes[packetNumberLength:]) + data := b[extHdrLen : int(packetLen)+hdrLen] + + key := hkdfExpandLabel(crypto.SHA256, secret, []byte{}, "quic key", 16) + iv := hkdfExpandLabel(crypto.SHA256, secret, []byte{}, "quic iv", 12) + cipher := AEADAESGCMTLS13(key, iv) + nonce := cache.Extend(int32(cipher.NonceSize())) + binary.BigEndian.PutUint64(nonce[len(nonce)-8:], uint64(packetNumber)) + decrypted, err := cipher.Open(b[extHdrLen:extHdrLen], nonce, data, b[:extHdrLen]) + if err != nil { + return nil, err + } + buffer = buf.FromBytes(decrypted) + for i := 0; !buffer.IsEmpty(); i++ { + frameType := byte(0x0) // Default to PADDING frame + for frameType == 0x0 && !buffer.IsEmpty() { + frameType, _ = buffer.ReadByte() + } + switch frameType { + case 0x00: // PADDING frame + case 0x01: // PING frame + case 0x02, 0x03: // ACK frame + if _, err = quicvarint.Read(buffer); err != nil { // Field: Largest Acknowledged + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { // Field: ACK Delay + return nil, io.ErrUnexpectedEOF + } + ackRangeCount, err := quicvarint.Read(buffer) // Field: ACK Range Count + if err != nil { + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { // Field: First ACK Range + return nil, io.ErrUnexpectedEOF + } + for i := 0; i < int(ackRangeCount); i++ { // Field: ACK Range + if _, err = quicvarint.Read(buffer); err != nil { // Field: ACK Range -> Gap + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { // Field: ACK Range -> ACK Range Length + return nil, io.ErrUnexpectedEOF + } + } + if frameType == 0x03 { + if _, err = quicvarint.Read(buffer); err != nil { // Field: ECN Counts -> ECT0 Count + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { // Field: ECN Counts -> ECT1 Count + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { //nolint:misspell // Field: ECN Counts -> ECT-CE Count + return nil, io.ErrUnexpectedEOF + } + } + case 0x06: // CRYPTO frame, we will use this frame + offset, err := quicvarint.Read(buffer) // Field: Offset + if err != nil { + return nil, io.ErrUnexpectedEOF + } + length, err := quicvarint.Read(buffer) // Field: Length + if err != nil || length > uint64(buffer.Len()) { + return nil, io.ErrUnexpectedEOF + } + if cryptoLen < int(offset+length) { + cryptoLen = int(offset + length) + if len(cryptoData) < cryptoLen { + newCryptoData := bytespool.Alloc(int32(cryptoLen)) + copy(newCryptoData, cryptoData) + bytespool.Free(cryptoData) + cryptoData = newCryptoData + } + } + if _, err := buffer.Read(cryptoData[offset : offset+length]); err != nil { // Field: Crypto Data + return nil, io.ErrUnexpectedEOF + } + case 0x1c: // CONNECTION_CLOSE frame, only 0x1c is permitted in initial packet + if _, err = quicvarint.Read(buffer); err != nil { // Field: Error Code + return nil, io.ErrUnexpectedEOF + } + if _, err = quicvarint.Read(buffer); err != nil { // Field: Frame Type + return nil, io.ErrUnexpectedEOF + } + length, err := quicvarint.Read(buffer) // Field: Reason Phrase Length + if err != nil { + return nil, io.ErrUnexpectedEOF + } + if _, err := buffer.ReadBytes(int32(length)); err != nil { // Field: Reason Phrase + return nil, io.ErrUnexpectedEOF + } + default: + // Only above frame types are permitted in initial packet. + // See https://www.rfc-editor.org/rfc/rfc9000.html#section-17.2.2-8 + return nil, errNotQuicInitial + } + } + + tlsHdr := &ptls.SniffHeader{} + err = ptls.ReadClientHello(cryptoData[:cryptoLen], tlsHdr) + if err != nil { + // The crypto data may have not been fully recovered in current packets, + // So we continue to sniff rest packets. + b = restPayload + continue + } + return &SniffHeader{domain: tlsHdr.Domain()}, nil } - return &SniffHeader{domain: tlsHdr.Domain()}, nil + return nil, common.ErrNoClue } func hkdfExpandLabel(hash crypto.Hash, secret, context []byte, label string, length int) []byte { From d7c5a0fc5f45519da280cbe55f29511ef8b08ba7 Mon Sep 17 00:00:00 2001 From: Kuzmin Vladimir Date: Sun, 15 Sep 2024 06:47:16 +0300 Subject: [PATCH 537/867] Fix int overflow on x32 processors causing panic (#3810) During the roll, "duration" is converted to int, causing overflow on x32 processors. The value may be very small or negative, causing a panic in rand.Intn. --- app/observatory/burst/healthping.go | 2 +- common/dice/dice.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/observatory/burst/healthping.go b/app/observatory/burst/healthping.go index 41d5e754..cd4d5fc0 100644 --- a/app/observatory/burst/healthping.go +++ b/app/observatory/burst/healthping.go @@ -156,7 +156,7 @@ func (h *HealthPing) doCheck(tags []string, duration time.Duration, rounds int) for i := 0; i < rounds; i++ { delay := time.Duration(0) if duration > 0 { - delay = time.Duration(dice.Roll(int(duration))) + delay = time.Duration(dice.RollInt63n(int64(duration))) } time.AfterFunc(delay, func() { errors.LogDebug(h.ctx, "checking ", handler) diff --git a/common/dice/dice.go b/common/dice/dice.go index 2ff925b8..0a0a40e4 100644 --- a/common/dice/dice.go +++ b/common/dice/dice.go @@ -14,6 +14,14 @@ func Roll(n int) int { return rand.Intn(n) } +// RollInt63n returns a non-negative number between 0 (inclusive) and n (exclusive). +func RollInt63n(n int64) int64 { + if n == 1 { + return 0 + } + return rand.Int63n(n) +} + // Roll returns a non-negative number between 0 (inclusive) and n (exclusive). func RollDeterministic(n int, seed int64) int { if n == 1 { From 3fed0c773f2b8af594b3b9016612b8a6919e96bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Sun, 15 Sep 2024 12:21:51 +0800 Subject: [PATCH 538/867] DNS outbound: Add blockTypes (#3812) --- infra/conf/dns_proxy.go | 2 ++ proxy/dns/config.pb.go | 38 ++++++++++++++++++++++++-------------- proxy/dns/config.proto | 1 + proxy/dns/dns.go | 14 ++++++++++++-- 4 files changed, 39 insertions(+), 16 deletions(-) diff --git a/infra/conf/dns_proxy.go b/infra/conf/dns_proxy.go index 712f4b1f..cb135584 100644 --- a/infra/conf/dns_proxy.go +++ b/infra/conf/dns_proxy.go @@ -13,6 +13,7 @@ type DNSOutboundConfig struct { Port uint16 `json:"port"` UserLevel uint32 `json:"userLevel"` NonIPQuery string `json:"nonIPQuery"` + BlockTypes []int32 `json:"blockTypes"` } func (c *DNSOutboundConfig) Build() (proto.Message, error) { @@ -34,5 +35,6 @@ func (c *DNSOutboundConfig) Build() (proto.Message, error) { return nil, errors.New(`unknown "nonIPQuery": `, c.NonIPQuery) } config.Non_IPQuery = c.NonIPQuery + config.BlockTypes = c.BlockTypes return config, nil } diff --git a/proxy/dns/config.pb.go b/proxy/dns/config.pb.go index 52c680d3..e9927632 100644 --- a/proxy/dns/config.pb.go +++ b/proxy/dns/config.pb.go @@ -31,6 +31,7 @@ type Config struct { Server *net.Endpoint `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"` UserLevel uint32 `protobuf:"varint,2,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` Non_IPQuery string `protobuf:"bytes,3,opt,name=non_IP_query,json=nonIPQuery,proto3" json:"non_IP_query,omitempty"` + BlockTypes []int32 `protobuf:"varint,4,rep,packed,name=block_types,json=blockTypes,proto3" json:"block_types,omitempty"` } func (x *Config) Reset() { @@ -86,6 +87,13 @@ func (x *Config) GetNon_IPQuery() string { return "" } +func (x *Config) GetBlockTypes() []int32 { + if x != nil { + return x.BlockTypes + } + return nil +} + var File_proxy_dns_config_proto protoreflect.FileDescriptor var file_proxy_dns_config_proto_rawDesc = []byte{ @@ -93,20 +101,22 @@ var file_proxy_dns_config_proto_rawDesc = []byte{ 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x1c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x7c, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x31, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, - 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x06, 0x73, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65, - 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, 0x76, - 0x65, 0x6c, 0x12, 0x20, 0x0a, 0x0c, 0x6e, 0x6f, 0x6e, 0x5f, 0x49, 0x50, 0x5f, 0x71, 0x75, 0x65, - 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6e, 0x6f, 0x6e, 0x49, 0x50, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x42, 0x4c, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x64, 0x6e, 0x73, 0x50, 0x01, 0x5a, 0x23, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, - 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x64, 0x6e, - 0x73, 0xaa, 0x02, 0x0e, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x44, - 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9d, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x31, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x06, 0x73, 0x65, + 0x72, 0x76, 0x65, 0x72, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, + 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, + 0x76, 0x65, 0x6c, 0x12, 0x20, 0x0a, 0x0c, 0x6e, 0x6f, 0x6e, 0x5f, 0x49, 0x50, 0x5f, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x6e, 0x6f, 0x6e, 0x49, 0x50, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x05, 0x52, 0x0a, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x54, 0x79, 0x70, 0x65, 0x73, 0x42, 0x4c, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x64, 0x6e, 0x73, 0x50, 0x01, 0x5a, 0x23, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, + 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, + 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x0e, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, + 0x2e, 0x44, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/dns/config.proto b/proxy/dns/config.proto index e9304a51..af2aad8c 100644 --- a/proxy/dns/config.proto +++ b/proxy/dns/config.proto @@ -14,4 +14,5 @@ message Config { xray.common.net.Endpoint server = 1; uint32 user_level = 2; string non_IP_query = 3; + repeated int32 block_types = 4; } diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index d797ca86..eeaa4c4c 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -49,6 +49,7 @@ type Handler struct { server net.Destination timeout time.Duration nonIPQuery string + blockTypes []int32 } func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager policy.Manager) error { @@ -63,6 +64,7 @@ func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager polic h.server = config.Server.AsDestination() } h.nonIPQuery = config.Non_IPQuery + h.blockTypes = config.BlockTypes return nil } @@ -84,12 +86,12 @@ func parseIPQuery(b []byte) (r bool, domain string, id uint16, qType dnsmessage. errors.LogInfoInner(context.Background(), err, "question") return } + domain = q.Name.String() qType = q.Type if qType != dnsmessage.TypeA && qType != dnsmessage.TypeAAAA { return } - domain = q.Name.String() r = true return } @@ -181,10 +183,18 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet. if !h.isOwnLink(ctx) { isIPQuery, domain, id, qType := parseIPQuery(b.Bytes()) + if len(h.blockTypes) > 0 { + for _, blocktype := range h.blockTypes { + if blocktype == int32(qType) { + errors.LogInfo(ctx, "blocked type ", qType, " query for domain ", domain) + return nil + } + } + } if isIPQuery { go h.handleIPQuery(id, qType, domain, writer) } - if isIPQuery || h.nonIPQuery == "drop" || qType == 65 { + if isIPQuery || h.nonIPQuery == "drop" { b.Release() continue } From 5f0642a671e4c611c4d86604f7d6f3d488452d93 Mon Sep 17 00:00:00 2001 From: Kobe Arthur Scofield <26771058+KobeArthurScofield@users.noreply.github.com> Date: Sun, 15 Sep 2024 12:55:54 +0800 Subject: [PATCH 539/867] Errors: Add PrintRemovedFeatureError & PrintDeprecatedFeatureWarning (#3804) --- app/dns/dns.go | 3 +-- app/dns/hosts.go | 3 +-- common/errors/feature_errors.go | 25 +++++++++++++++++++++++++ features/feature.go | 15 --------------- infra/conf/transport_internet.go | 2 +- infra/conf/trojan.go | 4 ++-- infra/conf/xray.go | 2 +- proxy/socks/server.go | 3 +-- 8 files changed, 32 insertions(+), 25 deletions(-) create mode 100644 common/errors/feature_errors.go diff --git a/app/dns/dns.go b/app/dns/dns.go index 4abc8b33..f4802275 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -15,7 +15,6 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/common/strmatcher" - "github.com/xtls/xray-core/features" "github.com/xtls/xray-core/features/dns" ) @@ -96,7 +95,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) { geoipContainer := router.GeoIPMatcherContainer{} for _, endpoint := range config.NameServers { - features.PrintDeprecatedFeatureWarning("simple DNS server") + errors.PrintDeprecatedFeatureWarning("simple DNS server", "") client, err := NewSimpleClient(ctx, endpoint, clientIP) if err != nil { return nil, errors.New("failed to create client").Base(err) diff --git a/app/dns/hosts.go b/app/dns/hosts.go index a60d2514..4dd01041 100644 --- a/app/dns/hosts.go +++ b/app/dns/hosts.go @@ -7,7 +7,6 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/strmatcher" - "github.com/xtls/xray-core/features" "github.com/xtls/xray-core/features/dns" ) @@ -26,7 +25,7 @@ func NewStaticHosts(hosts []*Config_HostMapping, legacy map[string]*net.IPOrDoma } if legacy != nil { - features.PrintDeprecatedFeatureWarning("simple host mapping") + errors.PrintDeprecatedFeatureWarning("simple host mapping", "") for domain, ip := range legacy { matcher, err := strmatcher.Full.New(domain) diff --git a/common/errors/feature_errors.go b/common/errors/feature_errors.go new file mode 100644 index 00000000..ea9b4c03 --- /dev/null +++ b/common/errors/feature_errors.go @@ -0,0 +1,25 @@ +package errors + +import ( + "context" +) + +// PrintDeprecatedFeatureWarning prints a warning for deprecated and going to be removed feature. +// Do not remove this function even there is no reference to it. +func PrintDeprecatedFeatureWarning(feature string, migrateFeature string) { + if len(migrateFeature) > 0 { + LogWarning(context.Background(), "This feature " + feature + " is deprecated and being migrated to " + migrateFeature + ". Please update your config(s) according to release note and documentation before removal.") + } else { + LogWarning(context.Background(), "This feature " + feature + " is deprecated. Please update your config(s) according to release note and documentation before removal.") + } +} + +// PrintRemovedFeatureError prints an error message for removed feature then return an error. And after long enough time the message can also be removed, uses as an indicator. +// Do not remove this function even there is no reference to it. +func PrintRemovedFeatureError(feature string, migrateFeature string) (error) { + if len(migrateFeature) > 0 { + return New("The feature " + feature + " has been removed and migrated to " + migrateFeature + ". Please update your config(s) according to release note and documentation.") + } else { + return New("The feature " + feature + " has been removed. Please update your config(s) according to release note and documentation.") + } +} diff --git a/features/feature.go b/features/feature.go index 4ed71600..026b8fa5 100644 --- a/features/feature.go +++ b/features/feature.go @@ -1,27 +1,12 @@ package features import ( - "context" - "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/common/errors" ) -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - // Feature is the interface for Xray features. All features must implement this interface. // All existing features have an implementation in app directory. These features can be replaced by third-party ones. type Feature interface { common.HasType common.Runnable } - -// PrintDeprecatedFeatureWarning prints a warning for deprecated feature. -func PrintDeprecatedFeatureWarning(feature string) { - errors.LogWarning(context.Background(), "You are using a deprecated feature: " + feature + ". Please update your config file(s) with latest configuration format, or update your client software.") -} - -// PrintRemovedFeatureError prints an error message for removed feature. And after long enough time the message can also be removed, use as an indicator. -func PrintRemovedFeatureError(feature string) { - errors.New("The feature " + feature + " is removed. Please update your config file(s) according to release notes and documentations.") -} diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 8cc057a8..b61914ae 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -813,7 +813,7 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { config.SecuritySettings = append(config.SecuritySettings, tm) config.SecurityType = tm.Type case "xtls": - return nil, errors.New(`Please use VLESS flow "xtls-rprx-vision" with TLS or REALITY.`) + return nil, errors.PrintRemovedFeatureError(`Legacy XTLS`, `xtls-rprx-vision with TLS or REALITY`) default: return nil, errors.New(`Unknown security "` + c.Security + `".`) } diff --git a/infra/conf/trojan.go b/infra/conf/trojan.go index 13a1df73..03ac6f46 100644 --- a/infra/conf/trojan.go +++ b/infra/conf/trojan.go @@ -52,7 +52,7 @@ func (c *TrojanClientConfig) Build() (proto.Message, error) { return nil, errors.New("Trojan password is not specified.") } if rec.Flow != "" { - return nil, errors.New(`Trojan doesn't support "flow" anymore.`) + return nil, errors.PrintRemovedFeatureError(`Flow for Trojan`, ``) } config.Server[idx] = &protocol.ServerEndpoint{ @@ -106,7 +106,7 @@ func (c *TrojanServerConfig) Build() (proto.Message, error) { for idx, rawUser := range c.Clients { if rawUser.Flow != "" { - return nil, errors.New(`Trojan doesn't support "flow" anymore.`) + return nil, errors.PrintRemovedFeatureError(`Flow for Trojan`, ``) } config.Users[idx] = &protocol.User{ diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 07f70273..0b5c60e6 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -593,7 +593,7 @@ func (c *Config) Build() (*core.Config, error) { } if len(c.Transport) > 0 { - return nil, errors.New("Global transport config is deprecated") + return nil, errors.PrintRemovedFeatureError("Global transport config", "streamSettings in inbounds and outbounds") } for _, rawInboundConfig := range inbounds { diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 571fabb2..2b7bca7b 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -16,7 +16,6 @@ import ( "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/common/task" "github.com/xtls/xray-core/core" - "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/proxy/http" @@ -56,7 +55,7 @@ func (s *Server) policy() policy.Session { config := s.config p := s.policyManager.ForLevel(config.UserLevel) if config.Timeout > 0 { - features.PrintDeprecatedFeatureWarning("Socks timeout") + errors.PrintDeprecatedFeatureWarning("Socks timeout", "Policy level") } if config.Timeout > 0 && config.UserLevel == 0 { p.Timeouts.ConnectionIdle = time.Duration(config.Timeout) * time.Second From 67c2a290650f8bd6bfdffa9a273832c430f986df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 15 Sep 2024 21:20:12 -0400 Subject: [PATCH 540/867] Bump github.com/sagernet/sing from 0.4.1 to 0.4.3 (#3818) Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.4.1 to 0.4.3. - [Commits](https://github.com/sagernet/sing/compare/v0.4.1...v0.4.3) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e851f44c..cf8788c7 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/pires/go-proxyproto v0.7.0 github.com/quic-go/quic-go v0.46.0 github.com/refraction-networking/utls v1.6.7 - github.com/sagernet/sing v0.4.1 + github.com/sagernet/sing v0.4.3 github.com/sagernet/sing-shadowsocks v0.2.7 github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index 31a0e0f8..e0dadcc9 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= -github.com/sagernet/sing v0.4.1 h1:zVlpE+7k7AFoC2pv6ReqLf0PIHjihL/jsBl5k05PQFk= -github.com/sagernet/sing v0.4.1/go.mod h1:ieZHA/+Y9YZfXs2I3WtuwgyCZ6GPsIR7HdKb1SdEnls= +github.com/sagernet/sing v0.4.3 h1:Ty/NAiNnVd6844k7ujlL5lkzydhcTH5Psc432jXA4Y8= +github.com/sagernet/sing v0.4.3/go.mod h1:ieZHA/+Y9YZfXs2I3WtuwgyCZ6GPsIR7HdKb1SdEnls= github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8= github.com/sagernet/sing-shadowsocks v0.2.7/go.mod h1:0rIKJZBR65Qi0zwdKezt4s57y/Tl1ofkaq6NlkzVuyE= github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 h1:emzAzMZ1L9iaKCTxdy3Em8Wv4ChIAGnfiz18Cda70g4= From a931507dd67b1143e58d475414ca91191bea4cf0 Mon Sep 17 00:00:00 2001 From: Dmitry Anderson <58323684+4nd3r5on@users.noreply.github.com> Date: Mon, 16 Sep 2024 14:33:03 +0200 Subject: [PATCH 541/867] SplitHTTP: Read and validate HTTP/1.1 responses (#3797) --- .gitignore | 3 +++ transport/internet/splithttp/client.go | 27 ++++++++++++++++++++----- transport/internet/splithttp/dialer.go | 1 - transport/internet/splithttp/h1_conn.go | 19 +++++++++++++++++ 4 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 transport/internet/splithttp/h1_conn.go diff --git a/.gitignore b/.gitignore index c77bc579..22469b88 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ errorgen *.dat .vscode /build_assets + +# Output from dlv test +**/debug.* diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index e491ef3e..7fc26945 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -3,6 +3,7 @@ package splithttp import ( "bytes" "context" + "fmt" "io" gonet "net" "net/http" @@ -152,23 +153,39 @@ func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, // safely retried. if instead req.Write is called multiple // times, the body is already drained after the first // request - requestBytes := new(bytes.Buffer) - common.Must(req.Write(requestBytes)) + requestBuff := new(bytes.Buffer) + common.Must(req.Write(requestBuff)) var uploadConn any + var h1UploadConn *H1Conn for { uploadConn = c.uploadRawPool.Get() newConnection := uploadConn == nil if newConnection { - uploadConn, err = c.dialUploadConn(context.WithoutCancel(ctx)) + newConn, err := c.dialUploadConn(context.WithoutCancel(ctx)) if err != nil { return err } + h1UploadConn = NewH1Conn(newConn) + uploadConn = h1UploadConn + } else { + h1UploadConn = uploadConn.(*H1Conn) + + // TODO: Replace 0 here with a config value later + // Or add some other condition for optimization purposes + if h1UploadConn.UnreadedResponsesCount > 0 { + resp, err := http.ReadResponse(h1UploadConn.RespBufReader, req) + if err != nil { + return fmt.Errorf("error while reading response: %s", err.Error()) + } + if resp.StatusCode != 200 { + return fmt.Errorf("got non-200 error response code: %d", resp.StatusCode) + } + } } - _, err = uploadConn.(net.Conn).Write(requestBytes.Bytes()) - + _, err := h1UploadConn.Write(requestBuff.Bytes()) // if the write failed, we try another connection from // the pool, until the write on a new connection fails. // failed writes to a pooled connection are normal when diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 69a30870..ff1501a8 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -267,7 +267,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me &buf.MultiBufferContainer{MultiBuffer: chunk}, int64(chunk.Len()), ) - if err != nil { errors.LogInfoInner(ctx, err, "failed to send upload") uploadPipeReader.Interrupt() diff --git a/transport/internet/splithttp/h1_conn.go b/transport/internet/splithttp/h1_conn.go new file mode 100644 index 00000000..f89f2a66 --- /dev/null +++ b/transport/internet/splithttp/h1_conn.go @@ -0,0 +1,19 @@ +package splithttp + +import ( + "bufio" + "net" +) + +type H1Conn struct { + UnreadedResponsesCount int + RespBufReader *bufio.Reader + net.Conn +} + +func NewH1Conn(conn net.Conn) *H1Conn { + return &H1Conn{ + RespBufReader: bufio.NewReader(conn), + Conn: conn, + } +} From b1c6471eebd2ec4ef5e0ef6af4b6ceb5f4a06734 Mon Sep 17 00:00:00 2001 From: ll11l1lIllIl1lll <88377095+ll11l1lIllIl1lll@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:42:01 +0000 Subject: [PATCH 542/867] SplitHTTP client: Add xmux (multiplex controller) for H3 & H2 (#3613) https://github.com/XTLS/Xray-core/pull/3613#issuecomment-2351954957 Closes https://github.com/XTLS/Xray-core/issues/3560#issuecomment-2247495778 --------- Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> --- infra/conf/transport_internet.go | 22 +++ transport/internet/splithttp/client.go | 7 +- transport/internet/splithttp/config.go | 43 +++++ transport/internet/splithttp/config.pb.go | 187 +++++++++++++++++---- transport/internet/splithttp/config.proto | 8 + transport/internet/splithttp/connection.go | 5 + transport/internet/splithttp/dialer.go | 77 +++++---- transport/internet/splithttp/mux.go | 102 +++++++++++ transport/internet/splithttp/mux_test.go | 88 ++++++++++ 9 files changed, 475 insertions(+), 64 deletions(-) create mode 100644 transport/internet/splithttp/mux.go create mode 100644 transport/internet/splithttp/mux_test.go diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index b61914ae..67e57c0c 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -231,6 +231,14 @@ type SplitHTTPConfig struct { ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"` NoSSEHeader bool `json:"noSSEHeader"` XPaddingBytes *Int32Range `json:"xPaddingBytes"` + Xmux Xmux `json:"xmux"` +} + +type Xmux struct { + maxConnections *Int32Range `json:"maxConnections"` + maxConcurrency *Int32Range `json:"maxConcurrency"` + cMaxReuseTimes *Int32Range `json:"cMaxReuseTimes"` + cMaxLifetimeMs *Int32Range `json:"cMaxLifetimeMs"` } func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { @@ -254,6 +262,19 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { } else if c.Host == "" && c.Headers["Host"] != "" { c.Host = c.Headers["Host"] } + + if c.Xmux.maxConnections != nil && c.Xmux.maxConcurrency != nil { + return nil, errors.New("maxConnections cannot be specified together with maxConcurrency") + } + + // Multiplexing config + muxProtobuf := splithttp.Multiplexing{ + MaxConnections: splithttpNewRandRangeConfig(c.Xmux.maxConnections), + MaxConcurrency: splithttpNewRandRangeConfig(c.Xmux.maxConcurrency), + CMaxReuseTimes: splithttpNewRandRangeConfig(c.Xmux.cMaxReuseTimes), + CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.cMaxLifetimeMs), + } + config := &splithttp.Config{ Path: c.Path, Host: c.Host, @@ -263,6 +284,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs), NoSSEHeader: c.NoSSEHeader, XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), + Xmux: &muxProtobuf, } return config, nil } diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index 7fc26945..3f278aa7 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -30,8 +30,7 @@ type DialerClient interface { // implements splithttp.DialerClient in terms of direct network connections type DefaultDialerClient struct { transportConfig *Config - download *http.Client - upload *http.Client + client *http.Client isH2 bool isH3 bool // pool of net.Conn, created using dialUploadConn @@ -80,7 +79,7 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) req.Header = c.transportConfig.GetRequestHeader() - response, err := c.download.Do(req) + response, err := c.client.Do(req) gotConn.Close() if err != nil { errors.LogInfoInner(ctx, err, "failed to send download http request") @@ -138,7 +137,7 @@ func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, req.Header = c.transportConfig.GetRequestHeader() if c.isH2 || c.isH3 { - resp, err := c.upload.Do(req) + resp, err := c.client.Do(req) if err != nil { return err } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 6b5a2005..5309b180 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -105,6 +105,49 @@ func (c *Config) GetNormalizedXPaddingBytes() RandRangeConfig { return *c.XPaddingBytes } +func (m *Multiplexing) GetNormalizedCMaxReuseTimes() RandRangeConfig { + if m.CMaxReuseTimes == nil { + return RandRangeConfig{ + From: 0, + To: 0, + } + } + + return *m.CMaxReuseTimes +} + +func (m *Multiplexing) GetNormalizedCMaxLifetimeMs() RandRangeConfig { + if m.CMaxLifetimeMs == nil || m.CMaxLifetimeMs.To == 0 { + return RandRangeConfig{ + From: 0, + To: 0, + } + } + return *m.CMaxLifetimeMs +} + +func (m *Multiplexing) GetNormalizedMaxConnections() RandRangeConfig { + if m.MaxConnections == nil { + return RandRangeConfig{ + From: 0, + To: 0, + } + } + + return *m.MaxConnections +} + +func (m *Multiplexing) GetNormalizedMaxConcurrency() RandRangeConfig { + if m.MaxConcurrency == nil { + return RandRangeConfig{ + From: 0, + To: 0, + } + } + + return *m.MaxConcurrency +} + func init() { common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { return new(Config) diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 24768490..51fc2091 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -33,6 +33,7 @@ type Config struct { ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` XPaddingBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` + Xmux *Multiplexing `protobuf:"bytes,9,opt,name=xmux,proto3" json:"xmux,omitempty"` } func (x *Config) Reset() { @@ -123,6 +124,13 @@ func (x *Config) GetXPaddingBytes() *RandRangeConfig { return nil } +func (x *Config) GetXmux() *Multiplexing { + if x != nil { + return x.Xmux + } + return nil +} + type RandRangeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -178,6 +186,77 @@ func (x *RandRangeConfig) GetTo() int32 { return 0 } +type Multiplexing struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MaxConnections *RandRangeConfig `protobuf:"bytes,1,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` + MaxConcurrency *RandRangeConfig `protobuf:"bytes,2,opt,name=maxConcurrency,proto3" json:"maxConcurrency,omitempty"` + CMaxReuseTimes *RandRangeConfig `protobuf:"bytes,3,opt,name=cMaxReuseTimes,proto3" json:"cMaxReuseTimes,omitempty"` + CMaxLifetimeMs *RandRangeConfig `protobuf:"bytes,4,opt,name=cMaxLifetimeMs,proto3" json:"cMaxLifetimeMs,omitempty"` +} + +func (x *Multiplexing) Reset() { + *x = Multiplexing{} + if protoimpl.UnsafeEnabled { + mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Multiplexing) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Multiplexing) ProtoMessage() {} + +func (x *Multiplexing) ProtoReflect() protoreflect.Message { + mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Multiplexing.ProtoReflect.Descriptor instead. +func (*Multiplexing) Descriptor() ([]byte, []int) { + return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} +} + +func (x *Multiplexing) GetMaxConnections() *RandRangeConfig { + if x != nil { + return x.MaxConnections + } + return nil +} + +func (x *Multiplexing) GetMaxConcurrency() *RandRangeConfig { + if x != nil { + return x.MaxConcurrency + } + return nil +} + +func (x *Multiplexing) GetCMaxReuseTimes() *RandRangeConfig { + if x != nil { + return x.CMaxReuseTimes + } + return nil +} + +func (x *Multiplexing) GetCMaxLifetimeMs() *RandRangeConfig { + if x != nil { + return x.CMaxLifetimeMs + } + return nil +} + var File_transport_internet_splithttp_config_proto protoreflect.FileDescriptor var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ @@ -185,8 +264,8 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xea, - 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xaf, + 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, @@ -221,23 +300,51 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, - 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, - 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, - 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, - 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, - 0x74, 0x6f, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x12, 0x43, 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, + 0x74, 0x70, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, + 0x04, 0x78, 0x6d, 0x75, 0x78, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, + 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, + 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, + 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, + 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, + 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, - 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, - 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, + 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, + 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, + 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, + 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, + 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, + 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, + 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -252,23 +359,29 @@ func file_transport_internet_splithttp_config_proto_rawDescGZIP() []byte { return file_transport_internet_splithttp_config_proto_rawDescData } -var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_transport_internet_splithttp_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.splithttp.Config (*RandRangeConfig)(nil), // 1: xray.transport.internet.splithttp.RandRangeConfig - nil, // 2: xray.transport.internet.splithttp.Config.HeaderEntry + (*Multiplexing)(nil), // 2: xray.transport.internet.splithttp.Multiplexing + nil, // 3: xray.transport.internet.splithttp.Config.HeaderEntry } var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ - 2, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry - 1, // 1: xray.transport.internet.splithttp.Config.scMaxConcurrentPosts:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 4: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 3, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry + 1, // 1: xray.transport.internet.splithttp.Config.scMaxConcurrentPosts:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 4: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 2, // 5: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.Multiplexing + 1, // 6: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 7: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 8: xray.transport.internet.splithttp.Multiplexing.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 9: xray.transport.internet.splithttp.Multiplexing.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_transport_internet_splithttp_config_proto_init() } @@ -301,6 +414,18 @@ func file_transport_internet_splithttp_config_proto_init() { return nil } } + file_transport_internet_splithttp_config_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*Multiplexing); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -308,7 +433,7 @@ func file_transport_internet_splithttp_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_transport_internet_splithttp_config_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 3f24cfd3..019f4d00 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -15,9 +15,17 @@ message Config { RandRangeConfig scMinPostsIntervalMs = 6; bool noSSEHeader = 7; RandRangeConfig xPaddingBytes = 8; + Multiplexing xmux = 9; } message RandRangeConfig { int32 from = 1; int32 to = 2; } + +message Multiplexing { + RandRangeConfig maxConnections = 1; + RandRangeConfig maxConcurrency = 2; + RandRangeConfig cMaxReuseTimes = 3; + RandRangeConfig cMaxLifetimeMs = 4; +} diff --git a/transport/internet/splithttp/connection.go b/transport/internet/splithttp/connection.go index 697381d4..613e1f36 100644 --- a/transport/internet/splithttp/connection.go +++ b/transport/internet/splithttp/connection.go @@ -11,6 +11,7 @@ type splitConn struct { reader io.ReadCloser remoteAddr net.Addr localAddr net.Addr + onClose func() } func (c *splitConn) Write(b []byte) (int, error) { @@ -22,6 +23,10 @@ func (c *splitConn) Read(b []byte) (int, error) { } func (c *splitConn) Close() error { + if c.onClose != nil { + c.onClose() + } + err := c.writer.Close() err2 := c.reader.Close() if err != nil { diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index ff1501a8..60f8c628 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -41,32 +41,51 @@ type dialerConf struct { } var ( - globalDialerMap map[dialerConf]DialerClient + globalDialerMap map[dialerConf]*muxManager globalDialerAccess sync.Mutex ) -func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) DialerClient { +func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (DialerClient, *muxResource) { if browser_dialer.HasBrowserDialer() { - return &BrowserDialerClient{} + return &BrowserDialerClient{}, nil } - tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") - isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") - globalDialerAccess.Lock() defer globalDialerAccess.Unlock() if globalDialerMap == nil { - globalDialerMap = make(map[dialerConf]DialerClient) + globalDialerMap = make(map[dialerConf]*muxManager) } + key := dialerConf{dest, streamSettings} + + muxManager, found := globalDialerMap[key] + + if !found { + transportConfig := streamSettings.ProtocolSettings.(*Config) + var mux Multiplexing + if transportConfig.Xmux != nil { + mux = *transportConfig.Xmux + } + + muxManager = NewMuxManager(mux, func() interface{} { + return createHTTPClient(dest, streamSettings) + }) + globalDialerMap[key] = muxManager + } + + res := muxManager.GetResource(ctx) + return res.Resource.(DialerClient), res +} + +func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStreamConfig) DialerClient { + tlsConfig := tls.ConfigFromStreamSettings(streamSettings) + isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") + isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") + if isH3 { dest.Network = net.Network_UDP } - if client, found := globalDialerMap[dialerConf{dest, streamSettings}]; found { - return client - } var gotlsConfig *gotls.Config @@ -74,6 +93,8 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in gotlsConfig = tlsConfig.GetTLSConfig(tls.WithDestination(dest)) } + transportConfig := streamSettings.ProtocolSettings.(*Config) + dialContext := func(ctxInner context.Context) (net.Conn, error) { conn, err := internet.DialSystem(ctxInner, dest, streamSettings.SocketSettings) if err != nil { @@ -94,8 +115,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return conn, nil } - var downloadTransport http.RoundTripper - var uploadTransport http.RoundTripper + var transport http.RoundTripper if isH3 { quicConfig := &quic.Config{ @@ -107,7 +127,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in MaxIncomingStreams: -1, KeepAlivePeriod: h3KeepalivePeriod, } - roundTripper := &http3.RoundTripper{ + transport = &http3.RoundTripper{ QUICConfig: quicConfig, TLSClientConfig: gotlsConfig, Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { @@ -147,23 +167,20 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg) }, } - downloadTransport = roundTripper - uploadTransport = roundTripper } else if isH2 { - downloadTransport = &http2.Transport{ + transport = &http2.Transport{ DialTLSContext: func(ctxInner context.Context, network string, addr string, cfg *gotls.Config) (net.Conn, error) { return dialContext(ctxInner) }, IdleConnTimeout: connIdleTimeout, ReadIdleTimeout: h2KeepalivePeriod, } - uploadTransport = downloadTransport } else { httpDialContext := func(ctxInner context.Context, network string, addr string) (net.Conn, error) { return dialContext(ctxInner) } - downloadTransport = &http.Transport{ + transport = &http.Transport{ DialTLSContext: httpDialContext, DialContext: httpDialContext, IdleConnTimeout: connIdleTimeout, @@ -171,17 +188,12 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in // http.Client and our custom dial context. DisableKeepAlives: true, } - // we use uploadRawPool for that - uploadTransport = nil } client := &DefaultDialerClient{ - transportConfig: streamSettings.ProtocolSettings.(*Config), - download: &http.Client{ - Transport: downloadTransport, - }, - upload: &http.Client{ - Transport: uploadTransport, + transportConfig: transportConfig, + client: &http.Client{ + Transport: transport, }, isH2: isH2, isH3: isH3, @@ -189,7 +201,6 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in dialUploadConn: dialContext, } - globalDialerMap[dialerConf{dest, streamSettings}] = client return client } @@ -223,7 +234,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestURL.Path = transportConfiguration.GetNormalizedPath() + sessionIdUuid.String() requestURL.RawQuery = transportConfiguration.GetNormalizedQuery() - httpClient := getHTTPClient(ctx, dest, streamSettings) + httpClient, muxResource := getHTTPClient(ctx, dest, streamSettings) maxUploadSize := scMaxEachPostBytes.roll() // WithSizeLimit(0) will still allow single bytes to pass, and a lot of @@ -231,7 +242,15 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me // uploadWriter wrapper, exact size limits can be enforced uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1)) + if muxResource != nil { + muxResource.OpenRequests.Add(1) + } + go func() { + if muxResource != nil { + defer muxResource.OpenRequests.Add(-1) + } + requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll())) var requestCounter int64 diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go new file mode 100644 index 00000000..83ab25b0 --- /dev/null +++ b/transport/internet/splithttp/mux.go @@ -0,0 +1,102 @@ +package splithttp + +import ( + "context" + "math/rand" + "sync/atomic" + "time" + + "github.com/xtls/xray-core/common/errors" +) + +type muxResource struct { + Resource interface{} + OpenRequests atomic.Int32 + leftUsage int32 + expirationTime time.Time +} + +type muxManager struct { + newResourceFn func() interface{} + config Multiplexing + concurrency int32 + connections int32 + instances []*muxResource +} + +func NewMuxManager(config Multiplexing, newResource func() interface{}) *muxManager { + return &muxManager{ + config: config, + concurrency: config.GetNormalizedMaxConcurrency().roll(), + connections: config.GetNormalizedMaxConnections().roll(), + newResourceFn: newResource, + instances: make([]*muxResource, 0), + } +} + +func (m *muxManager) GetResource(ctx context.Context) *muxResource { + m.removeExpiredConnections(ctx) + + if m.connections > 0 && len(m.instances) < int(m.connections) { + errors.LogDebug(ctx, "xmux: creating client, connections=", len(m.instances)) + return m.newResource() + } + + if len(m.instances) == 0 { + errors.LogDebug(ctx, "xmux: creating client because instances is empty, connections=", len(m.instances)) + return m.newResource() + } + + clients := make([]*muxResource, 0) + if m.concurrency > 0 { + for _, client := range m.instances { + openRequests := client.OpenRequests.Load() + if openRequests < m.concurrency { + clients = append(clients, client) + } + } + } else { + clients = m.instances + } + + if len(clients) == 0 { + errors.LogDebug(ctx, "xmux: creating client because concurrency was hit, total clients=", len(m.instances)) + return m.newResource() + } + + client := clients[rand.Intn(len(clients))] + if client.leftUsage > 0 { + client.leftUsage -= 1 + } + return client +} + +func (m *muxManager) newResource() *muxResource { + leftUsage := int32(-1) + if x := m.config.GetNormalizedCMaxReuseTimes().roll(); x > 0 { + leftUsage = x - 1 + } + expirationTime := time.UnixMilli(0) + if x := m.config.GetNormalizedCMaxLifetimeMs().roll(); x > 0 { + expirationTime = time.Now().Add(time.Duration(x) * time.Millisecond) + } + + client := &muxResource{ + Resource: m.newResourceFn(), + leftUsage: leftUsage, + expirationTime: expirationTime, + } + m.instances = append(m.instances, client) + return client +} + +func (m *muxManager) removeExpiredConnections(ctx context.Context) { + for i := 0; i < len(m.instances); i++ { + client := m.instances[i] + if client.leftUsage == 0 || (client.expirationTime != time.UnixMilli(0) && time.Now().After(client.expirationTime)) { + errors.LogDebug(ctx, "xmux: removing client, leftUsage = ", client.leftUsage, ", expirationTime = ", client.expirationTime) + m.instances = append(m.instances[:i], m.instances[i+1:]...) + i-- + } + } +} diff --git a/transport/internet/splithttp/mux_test.go b/transport/internet/splithttp/mux_test.go new file mode 100644 index 00000000..e59eff0e --- /dev/null +++ b/transport/internet/splithttp/mux_test.go @@ -0,0 +1,88 @@ +package splithttp_test + +import ( + "context" + "testing" + + . "github.com/xtls/xray-core/transport/internet/splithttp" +) + +type fakeRoundTripper struct{} + +func TestMaxConnections(t *testing.T) { + config := Multiplexing{ + MaxConnections: &RandRangeConfig{From: 4, To: 4}, + } + + mux := NewMuxManager(config, func() interface{} { + return &fakeRoundTripper{} + }) + + clients := make(map[interface{}]struct{}) + for i := 0; i < 8; i++ { + clients[mux.GetResource(context.Background())] = struct{}{} + } + + if len(clients) != 4 { + t.Error("did not get 4 distinct clients, got ", len(clients)) + } +} + +func TestCMaxReuseTimes(t *testing.T) { + config := Multiplexing{ + CMaxReuseTimes: &RandRangeConfig{From: 2, To: 2}, + } + + mux := NewMuxManager(config, func() interface{} { + return &fakeRoundTripper{} + }) + + clients := make(map[interface{}]struct{}) + for i := 0; i < 64; i++ { + clients[mux.GetResource(context.Background())] = struct{}{} + } + + if len(clients) != 32 { + t.Error("did not get 32 distinct clients, got ", len(clients)) + } +} + +func TestMaxConcurrency(t *testing.T) { + config := Multiplexing{ + MaxConcurrency: &RandRangeConfig{From: 2, To: 2}, + } + + mux := NewMuxManager(config, func() interface{} { + return &fakeRoundTripper{} + }) + + clients := make(map[interface{}]struct{}) + for i := 0; i < 64; i++ { + client := mux.GetResource(context.Background()) + client.OpenRequests.Add(1) + clients[client] = struct{}{} + } + + if len(clients) != 32 { + t.Error("did not get 32 distinct clients, got ", len(clients)) + } +} + +func TestDefault(t *testing.T) { + config := Multiplexing{} + + mux := NewMuxManager(config, func() interface{} { + return &fakeRoundTripper{} + }) + + clients := make(map[interface{}]struct{}) + for i := 0; i < 64; i++ { + client := mux.GetResource(context.Background()) + client.OpenRequests.Add(1) + clients[client] = struct{}{} + } + + if len(clients) != 1 { + t.Error("did not get 1 distinct clients, got ", len(clients)) + } +} From 363e86c5857eb963b23183a19024d1d28ebbd03f Mon Sep 17 00:00:00 2001 From: dragonbreath2000 <168475359+dragonbreath2000@users.noreply.github.com> Date: Mon, 16 Sep 2024 05:46:30 -0700 Subject: [PATCH 543/867] UDP noises: Add base64 and multi-packet support (#3794) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/XTLS/Xray-core/pull/3794#issuecomment-2351329251 --------- Co-authored-by: 风扇滑翔翼 Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> --- infra/conf/freedom.go | 145 ++++++++++++++++++++----------------- proxy/freedom/config.pb.go | 60 +++++++-------- proxy/freedom/config.proto | 4 +- proxy/freedom/freedom.go | 42 +++++------ 4 files changed, 131 insertions(+), 120 deletions(-) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index e172afa8..4a54936f 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -1,6 +1,7 @@ package conf import ( + "encoding/base64" "net" "strconv" "strings" @@ -19,6 +20,7 @@ type FreedomConfig struct { UserLevel uint32 `json:"userLevel"` Fragment *Fragment `json:"fragment"` Noise *Noise `json:"noise"` + Noises []*Noise `json:"noises"` ProxyProtocol uint32 `json:"proxyProtocol"` } @@ -29,8 +31,9 @@ type Fragment struct { } type Noise struct { - Packet string `json:"packet"` - Delay string `json:"delay"` + Type string `json:"type"` + Packet string `json:"packet"` + Delay *Int32Range `json:"delay"` } // Build implements Buildable @@ -149,74 +152,18 @@ func (c *FreedomConfig) Build() (proto.Message, error) { } } } + if c.Noise != nil { - config.Noise = new(freedom.Noise) - var err, err2 error - p := strings.Split(strings.ToLower(c.Noise.Packet), ":") - if len(p) != 2 { - return nil, errors.New("invalid type for packet") - } - switch p[0] { - case "rand": - randValue := strings.Split(p[1], "-") - if len(randValue) > 2 { - return nil, errors.New("Only 2 values are allowed for rand") - } - if len(randValue) == 2 { - config.Noise.LengthMin, err = strconv.ParseUint(randValue[0], 10, 64) - config.Noise.LengthMax, err2 = strconv.ParseUint(randValue[1], 10, 64) - } - if len(randValue) == 1 { - config.Noise.LengthMin, err = strconv.ParseUint(randValue[0], 10, 64) - config.Noise.LengthMax = config.Noise.LengthMin - } + return nil, errors.PrintRemovedFeatureError("noise = { ... }", "noises = [ { ... } ]") + } + + if c.Noises != nil { + for _, n := range c.Noises { + NConfig, err := ParseNoise(n) if err != nil { - return nil, errors.New("invalid value for rand LengthMin").Base(err) + return nil, err } - if err2 != nil { - return nil, errors.New("invalid value for rand LengthMax").Base(err2) - } - if config.Noise.LengthMin > config.Noise.LengthMax { - config.Noise.LengthMin, config.Noise.LengthMax = config.Noise.LengthMax, config.Noise.LengthMin - } - if config.Noise.LengthMin == 0 { - return nil, errors.New("rand lengthMin or lengthMax cannot be 0") - } - - case "str": - //user input string - config.Noise.StrNoise = strings.TrimSpace(p[1]) - - default: - return nil, errors.New("Invalid packet,only rand and str are supported") - } - if c.Noise.Delay != "" { - d := strings.Split(strings.ToLower(c.Noise.Delay), "-") - if len(d) > 2 { - return nil, errors.New("Invalid delay value") - } - if len(d) == 2 { - config.Noise.DelayMin, err = strconv.ParseUint(d[0], 10, 64) - config.Noise.DelayMax, err2 = strconv.ParseUint(d[1], 10, 64) - - } else { - config.Noise.DelayMin, err = strconv.ParseUint(d[0], 10, 64) - config.Noise.DelayMax = config.Noise.DelayMin - } - if err != nil { - return nil, errors.New("Invalid value for DelayMin").Base(err) - } - if err2 != nil { - return nil, errors.New("Invalid value for DelayMax").Base(err2) - } - if config.Noise.DelayMin > config.Noise.DelayMax { - config.Noise.DelayMin, config.Noise.DelayMax = config.Noise.DelayMax, config.Noise.DelayMin - } - if config.Noise.DelayMin == 0 { - return nil, errors.New("DelayMin or DelayMax cannot be 0") - } - } else { - config.Noise.DelayMin = 0 + config.Noises = append(config.Noises, NConfig) } } @@ -248,3 +195,67 @@ func (c *FreedomConfig) Build() (proto.Message, error) { } return config, nil } + +func ParseNoise(noise *Noise) (*freedom.Noise, error) { + var err, err2 error + NConfig := new(freedom.Noise) + + switch strings.ToLower(noise.Type) { + case "rand": + randValue := strings.Split(noise.Packet, "-") + if len(randValue) > 2 { + return nil, errors.New("Only 2 values are allowed for rand") + } + if len(randValue) == 2 { + NConfig.LengthMin, err = strconv.ParseUint(randValue[0], 10, 64) + NConfig.LengthMax, err2 = strconv.ParseUint(randValue[1], 10, 64) + } + if len(randValue) == 1 { + NConfig.LengthMin, err = strconv.ParseUint(randValue[0], 10, 64) + NConfig.LengthMax = NConfig.LengthMin + } + if err != nil { + return nil, errors.New("invalid value for rand LengthMin").Base(err) + } + if err2 != nil { + return nil, errors.New("invalid value for rand LengthMax").Base(err2) + } + if NConfig.LengthMin > NConfig.LengthMax { + NConfig.LengthMin, NConfig.LengthMax = NConfig.LengthMax, NConfig.LengthMin + } + if NConfig.LengthMin == 0 { + return nil, errors.New("rand lengthMin or lengthMax cannot be 0") + } + + case "str": + //user input string + NConfig.StrNoise = []byte(strings.TrimSpace(noise.Packet)) + + case "base64": + //user input base64 + NConfig.StrNoise, err = base64.StdEncoding.DecodeString(strings.TrimSpace(noise.Packet)) + if err != nil { + return nil, errors.New("Invalid base64 string") + } + + default: + return nil, errors.New("Invalid packet,only rand,str,base64 are supported") + } + + if noise.Delay != nil { + if noise.Delay.From != 0 && noise.Delay.To != 0 { + NConfig.DelayMin = uint64(noise.Delay.From) + NConfig.DelayMax = uint64(noise.Delay.To) + if NConfig.DelayMin > NConfig.LengthMax { + NConfig.DelayMin, NConfig.DelayMax = NConfig.LengthMax, NConfig.DelayMin + } + } else { + return nil, errors.New("DelayMin or DelayMax cannot be zero") + } + + } else { + NConfig.DelayMin = 0 + NConfig.DelayMax = 0 + } + return NConfig, nil +} diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 9d829251..f7b307c4 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -237,7 +237,7 @@ type Noise struct { LengthMax uint64 `protobuf:"varint,2,opt,name=length_max,json=lengthMax,proto3" json:"length_max,omitempty"` DelayMin uint64 `protobuf:"varint,3,opt,name=delay_min,json=delayMin,proto3" json:"delay_min,omitempty"` DelayMax uint64 `protobuf:"varint,4,opt,name=delay_max,json=delayMax,proto3" json:"delay_max,omitempty"` - StrNoise string `protobuf:"bytes,5,opt,name=str_noise,json=strNoise,proto3" json:"str_noise,omitempty"` + StrNoise []byte `protobuf:"bytes,5,opt,name=str_noise,json=strNoise,proto3" json:"str_noise,omitempty"` } func (x *Noise) Reset() { @@ -300,11 +300,11 @@ func (x *Noise) GetDelayMax() uint64 { return 0 } -func (x *Noise) GetStrNoise() string { +func (x *Noise) GetStrNoise() []byte { if x != nil { return x.StrNoise } - return "" + return nil } type Config struct { @@ -319,7 +319,7 @@ type Config struct { UserLevel uint32 `protobuf:"varint,4,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` Fragment *Fragment `protobuf:"bytes,5,opt,name=fragment,proto3" json:"fragment,omitempty"` ProxyProtocol uint32 `protobuf:"varint,6,opt,name=proxy_protocol,json=proxyProtocol,proto3" json:"proxy_protocol,omitempty"` - Noise *Noise `protobuf:"bytes,7,opt,name=noise,proto3" json:"noise,omitempty"` + Noises []*Noise `protobuf:"bytes,7,rep,name=noises,proto3" json:"noises,omitempty"` } func (x *Config) Reset() { @@ -397,9 +397,9 @@ func (x *Config) GetProxyProtocol() uint32 { return 0 } -func (x *Config) GetNoise() *Noise { +func (x *Config) GetNoises() []*Noise { if x != nil { - return x.Noise + return x.Noises } return nil } @@ -439,8 +439,8 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x61, 0x78, 0x12, 0x1b, 0x0a, - 0x09, 0x73, 0x74, 0x72, 0x5f, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x08, 0x73, 0x74, 0x72, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x22, 0xb3, 0x04, 0x0a, 0x06, 0x43, + 0x09, 0x73, 0x74, 0x72, 0x5f, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x08, 0x73, 0x74, 0x72, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x22, 0xb5, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, @@ -462,27 +462,27 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x63, 0x6f, 0x6c, 0x12, 0x2f, 0x0a, 0x05, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x18, 0x07, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, - 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x52, 0x05, 0x6e, - 0x6f, 0x69, 0x73, 0x65, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, - 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, - 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, - 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, - 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, - 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, - 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, - 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, - 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, - 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, - 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, - 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x66, 0x72, - 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, - 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x63, 0x6f, 0x6c, 0x12, 0x31, 0x0a, 0x06, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x73, 0x18, 0x07, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x52, 0x06, + 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x73, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, + 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, + 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, + 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, + 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, + 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, + 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, + 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, + 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, + 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, + 0x10, 0x0a, 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x50, 0x01, 0x5a, 0x27, + 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, + 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, + 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, + 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -512,7 +512,7 @@ var file_proxy_freedom_config_proto_depIdxs = []int32{ 0, // 1: xray.proxy.freedom.Config.domain_strategy:type_name -> xray.proxy.freedom.Config.DomainStrategy 1, // 2: xray.proxy.freedom.Config.destination_override:type_name -> xray.proxy.freedom.DestinationOverride 2, // 3: xray.proxy.freedom.Config.fragment:type_name -> xray.proxy.freedom.Fragment - 3, // 4: xray.proxy.freedom.Config.noise:type_name -> xray.proxy.freedom.Noise + 3, // 4: xray.proxy.freedom.Config.noises:type_name -> xray.proxy.freedom.Noise 5, // [5:5] is the sub-list for method output_type 5, // [5:5] is the sub-list for method input_type 5, // [5:5] is the sub-list for extension type_name diff --git a/proxy/freedom/config.proto b/proxy/freedom/config.proto index 85b71979..b3bef518 100644 --- a/proxy/freedom/config.proto +++ b/proxy/freedom/config.proto @@ -25,7 +25,7 @@ message Noise { uint64 length_max = 2; uint64 delay_min = 3; uint64 delay_max = 4; - string str_noise = 5; + bytes str_noise = 5; } message Config { @@ -48,5 +48,5 @@ message Config { uint32 user_level = 4; Fragment fragment = 5; uint32 proxy_protocol = 6; - Noise noise = 7; + repeated Noise noises = 7; } diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 4c3d963e..30028bc6 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -208,12 +208,11 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } } else { writer = NewPacketWriter(conn, h, ctx, UDPOverride) - if h.config.Noise != nil { - errors.LogDebug(ctx, "NOISE", h.config.Noise.StrNoise, h.config.Noise.LengthMin, h.config.Noise.LengthMax, - h.config.Noise.DelayMin, h.config.Noise.DelayMax) + if h.config.Noises != nil { + errors.LogDebug(ctx, "NOISE", h.config.Noises) writer = &NoisePacketWriter{ Writer: writer, - noise: h.config.Noise, + noises: h.config.Noises, firstWrite: true, UDPOverride: UDPOverride, } @@ -396,12 +395,12 @@ func (w *PacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { type NoisePacketWriter struct { buf.Writer - noise *Noise + noises []*Noise firstWrite bool UDPOverride net.Destination } -// MultiBuffer writer with Noise in first packet +// MultiBuffer writer with Noise before first packet func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { if w.firstWrite { w.firstWrite = false @@ -411,22 +410,23 @@ func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { } var noise []byte var err error - //User input string - if w.noise.StrNoise != "" { - noise = []byte(w.noise.StrNoise) - } else { - //Random noise - noise, err = GenerateRandomBytes(randBetween(int64(w.noise.LengthMin), - int64(w.noise.LengthMax))) - } + for _, n := range w.noises { + //User input string or base64 encoded string + if n.StrNoise != nil { + noise = n.StrNoise + } else { + //Random noise + noise, err = GenerateRandomBytes(randBetween(int64(n.LengthMin), + int64(n.LengthMax))) + } + if err != nil { + return err + } + w.Writer.WriteMultiBuffer(buf.MultiBuffer{buf.FromBytes(noise)}) - if err != nil { - return err - } - w.Writer.WriteMultiBuffer(buf.MultiBuffer{buf.FromBytes(noise)}) - - if w.noise.DelayMin != 0 { - time.Sleep(time.Duration(randBetween(int64(w.noise.DelayMin), int64(w.noise.DelayMax))) * time.Millisecond) + if n.DelayMin != 0 { + time.Sleep(time.Duration(randBetween(int64(n.DelayMin), int64(n.DelayMax))) * time.Millisecond) + } } } From a35d5719f425f061a3274e2ba51481299853ea82 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:48:28 +0000 Subject: [PATCH 544/867] v24.9.16 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index d79b89a6..f824ecef 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 24 Version_y byte = 9 - Version_z byte = 7 + Version_z byte = 16 ) var ( From f406b2dee02b4adaa7bb29ac3bf96e0a7ceac4df Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Thu, 19 Sep 2024 02:45:39 +0200 Subject: [PATCH 545/867] SplitHTTP client: Fix xmux config deserialization (#3827) --- infra/conf/transport_internet.go | 18 ++++++++-------- transport/internet/splithttp/config.pb.go | 26 +++++++++++------------ transport/internet/splithttp/config.proto | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 67e57c0c..9605d2a2 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -235,10 +235,10 @@ type SplitHTTPConfig struct { } type Xmux struct { - maxConnections *Int32Range `json:"maxConnections"` - maxConcurrency *Int32Range `json:"maxConcurrency"` - cMaxReuseTimes *Int32Range `json:"cMaxReuseTimes"` - cMaxLifetimeMs *Int32Range `json:"cMaxLifetimeMs"` + MaxConcurrency *Int32Range `json:"maxConcurrency"` + MaxConnections *Int32Range `json:"maxConnections"` + CMaxReuseTimes *Int32Range `json:"cMaxReuseTimes"` + CMaxLifetimeMs *Int32Range `json:"cMaxLifetimeMs"` } func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { @@ -263,16 +263,16 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { c.Host = c.Headers["Host"] } - if c.Xmux.maxConnections != nil && c.Xmux.maxConcurrency != nil { + if c.Xmux.MaxConnections != nil && c.Xmux.MaxConcurrency != nil { return nil, errors.New("maxConnections cannot be specified together with maxConcurrency") } // Multiplexing config muxProtobuf := splithttp.Multiplexing{ - MaxConnections: splithttpNewRandRangeConfig(c.Xmux.maxConnections), - MaxConcurrency: splithttpNewRandRangeConfig(c.Xmux.maxConcurrency), - CMaxReuseTimes: splithttpNewRandRangeConfig(c.Xmux.cMaxReuseTimes), - CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.cMaxLifetimeMs), + MaxConcurrency: splithttpNewRandRangeConfig(c.Xmux.MaxConcurrency), + MaxConnections: splithttpNewRandRangeConfig(c.Xmux.MaxConnections), + CMaxReuseTimes: splithttpNewRandRangeConfig(c.Xmux.CMaxReuseTimes), + CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.CMaxLifetimeMs), } config := &splithttp.Config{ diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 51fc2091..6bd6a9dd 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -191,8 +191,8 @@ type Multiplexing struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - MaxConnections *RandRangeConfig `protobuf:"bytes,1,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` - MaxConcurrency *RandRangeConfig `protobuf:"bytes,2,opt,name=maxConcurrency,proto3" json:"maxConcurrency,omitempty"` + MaxConcurrency *RandRangeConfig `protobuf:"bytes,1,opt,name=maxConcurrency,proto3" json:"maxConcurrency,omitempty"` + MaxConnections *RandRangeConfig `protobuf:"bytes,2,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` CMaxReuseTimes *RandRangeConfig `protobuf:"bytes,3,opt,name=cMaxReuseTimes,proto3" json:"cMaxReuseTimes,omitempty"` CMaxLifetimeMs *RandRangeConfig `protobuf:"bytes,4,opt,name=cMaxLifetimeMs,proto3" json:"cMaxLifetimeMs,omitempty"` } @@ -229,16 +229,16 @@ func (*Multiplexing) Descriptor() ([]byte, []int) { return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} } -func (x *Multiplexing) GetMaxConnections() *RandRangeConfig { +func (x *Multiplexing) GetMaxConcurrency() *RandRangeConfig { if x != nil { - return x.MaxConnections + return x.MaxConcurrency } return nil } -func (x *Multiplexing) GetMaxConcurrency() *RandRangeConfig { +func (x *Multiplexing) GetMaxConnections() *RandRangeConfig { if x != nil { - return x.MaxConcurrency + return x.MaxConnections } return nil } @@ -313,17 +313,17 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, - 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, + 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, + 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, @@ -373,8 +373,8 @@ var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 1, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 4: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 2, // 5: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.Multiplexing - 1, // 6: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 7: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 6: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 7: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 8: xray.transport.internet.splithttp.Multiplexing.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 9: xray.transport.internet.splithttp.Multiplexing.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig 10, // [10:10] is the sub-list for method output_type diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 019f4d00..249f1e93 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -24,8 +24,8 @@ message RandRangeConfig { } message Multiplexing { - RandRangeConfig maxConnections = 1; - RandRangeConfig maxConcurrency = 2; + RandRangeConfig maxConcurrency = 1; + RandRangeConfig maxConnections = 2; RandRangeConfig cMaxReuseTimes = 3; RandRangeConfig cMaxLifetimeMs = 4; } From 57a41f3b4ba00cbc3db0dbd65f2f22eb724e3974 Mon Sep 17 00:00:00 2001 From: Kobe Arthur Scofield <26771058+KobeArthurScofield@users.noreply.github.com> Date: Thu, 19 Sep 2024 09:05:59 +0800 Subject: [PATCH 546/867] Config: Remove more legacy fields (#3817) --- app/dns/config.pb.go | 250 ++++++++++------------- app/dns/config.proto | 11 +- app/dns/dns.go | 11 +- app/dns/dns_test.go | 122 ++++++------ app/dns/hosts.go | 22 +-- app/dns/hosts_test.go | 2 +- app/dns/nameserver.go | 25 --- app/router/condition_test.go | 46 +---- app/router/config.go | 17 -- app/router/config.pb.go | 295 +++++++++++----------------- app/router/config.proto | 14 -- app/router/router_test.go | 30 ++- core/config.proto | 5 - core/xray_test.go | 4 +- infra/conf/dokodemo.go | 2 - infra/conf/dokodemo_test.go | 2 - infra/conf/freedom.go | 4 - infra/conf/freedom_test.go | 2 - infra/conf/http.go | 2 - infra/conf/http_test.go | 2 - infra/conf/socks.go | 17 -- infra/conf/socks_test.go | 2 - infra/conf/trojan.go | 4 - infra/conf/vless.go | 4 - proxy/dns/dns_test.go | 14 +- proxy/dokodemo/config.pb.go | 90 +++------ proxy/dokodemo/config.proto | 4 - proxy/dokodemo/dokodemo.go | 12 +- proxy/freedom/config.pb.go | 98 ++++----- proxy/freedom/config.proto | 1 - proxy/freedom/freedom.go | 3 - proxy/http/config.pb.go | 76 +++---- proxy/http/config.proto | 1 - proxy/http/server.go | 5 +- proxy/socks/client.go | 33 +--- proxy/socks/config.pb.go | 157 ++++----------- proxy/socks/config.proto | 8 - proxy/socks/server.go | 6 - testing/scenarios/command_test.go | 12 +- testing/scenarios/dns_test.go | 18 +- testing/scenarios/dokodemo_test.go | 8 +- testing/scenarios/feature_test.go | 32 +-- testing/scenarios/policy_test.go | 8 +- testing/scenarios/reverse_test.go | 16 +- testing/scenarios/socks_test.go | 24 +-- testing/scenarios/tls_test.go | 44 ++--- testing/scenarios/transport_test.go | 4 +- testing/scenarios/vless_test.go | 16 +- testing/scenarios/vmess_test.go | 60 ++---- testing/scenarios/wireguard_test.go | 4 +- transport/internet/tls/config.pb.go | 73 +++---- transport/internet/tls/config.proto | 4 - 52 files changed, 569 insertions(+), 1157 deletions(-) diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index bab4dc1c..e2a9e6aa 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: app/dns/config.proto package dns @@ -223,19 +223,9 @@ type Config struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Nameservers used by this DNS. Only traditional UDP servers are support at - // the moment. A special value 'localhost' as a domain address can be set to - // use DNS on local system. - // - // Deprecated: Marked as deprecated in app/dns/config.proto. - NameServers []*net.Endpoint `protobuf:"bytes,1,rep,name=NameServers,proto3" json:"NameServers,omitempty"` // NameServer list used by this DNS client. + // A special value 'localhost' as a domain address can be set to use DNS on local system. NameServer []*NameServer `protobuf:"bytes,5,rep,name=name_server,json=nameServer,proto3" json:"name_server,omitempty"` - // Static hosts. Domain to IP. - // Deprecated. Use static_hosts. - // - // Deprecated: Marked as deprecated in app/dns/config.proto. - Hosts map[string]*net.IPOrDomain `protobuf:"bytes,2,rep,name=Hosts,proto3" json:"Hosts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes // (IPv6). ClientIp []byte `protobuf:"bytes,3,opt,name=client_ip,json=clientIp,proto3" json:"client_ip,omitempty"` @@ -281,14 +271,6 @@ func (*Config) Descriptor() ([]byte, []int) { return file_app_dns_config_proto_rawDescGZIP(), []int{1} } -// Deprecated: Marked as deprecated in app/dns/config.proto. -func (x *Config) GetNameServers() []*net.Endpoint { - if x != nil { - return x.NameServers - } - return nil -} - func (x *Config) GetNameServer() []*NameServer { if x != nil { return x.NameServer @@ -296,14 +278,6 @@ func (x *Config) GetNameServer() []*NameServer { return nil } -// Deprecated: Marked as deprecated in app/dns/config.proto. -func (x *Config) GetHosts() map[string]*net.IPOrDomain { - if x != nil { - return x.Hosts - } - return nil -} - func (x *Config) GetClientIp() []byte { if x != nil { return x.ClientIp @@ -479,7 +453,7 @@ type Config_HostMapping struct { func (x *Config_HostMapping) Reset() { *x = Config_HostMapping{} if protoimpl.UnsafeEnabled { - mi := &file_app_dns_config_proto_msgTypes[5] + mi := &file_app_dns_config_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -492,7 +466,7 @@ func (x *Config_HostMapping) String() string { func (*Config_HostMapping) ProtoMessage() {} func (x *Config_HostMapping) ProtoReflect() protoreflect.Message { - mi := &file_app_dns_config_proto_msgTypes[5] + mi := &file_app_dns_config_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -505,7 +479,7 @@ func (x *Config_HostMapping) ProtoReflect() protoreflect.Message { // Deprecated: Use Config_HostMapping.ProtoReflect.Descriptor instead. func (*Config_HostMapping) Descriptor() ([]byte, []int) { - return file_app_dns_config_proto_rawDescGZIP(), []int{1, 1} + return file_app_dns_config_proto_rawDescGZIP(), []int{1, 0} } func (x *Config_HostMapping) GetType() DomainMatchingType { @@ -541,107 +515,92 @@ var File_app_dns_config_proto protoreflect.FileDescriptor var file_app_dns_config_proto_rawDesc = []byte{ 0x0a, 0x14, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, - 0x2f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, - 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, - 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x61, 0x70, - 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb2, 0x04, 0x0a, 0x0a, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, - 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x6b, 0x69, 0x70, 0x46, 0x61, - 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x73, 0x6b, - 0x69, 0x70, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x56, 0x0a, 0x12, 0x70, 0x72, - 0x69, 0x6f, 0x72, 0x69, 0x74, 0x69, 0x7a, 0x65, 0x64, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, - 0x11, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x69, 0x7a, 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x12, 0x2c, 0x0a, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, - 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, - 0x12, 0x4c, 0x0a, 0x0e, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x72, 0x75, 0x6c, - 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x52, - 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x42, + 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x1c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, + 0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x17, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb2, 0x04, 0x0a, 0x0a, + 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, + 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, + 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x22, 0x0a, 0x0c, + 0x73, 0x6b, 0x69, 0x70, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0c, 0x73, 0x6b, 0x69, 0x70, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x12, 0x56, 0x0a, 0x12, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x69, 0x7a, 0x65, 0x64, 0x5f, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, + 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x11, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x69, 0x7a, + 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x2c, 0x0a, 0x05, 0x67, 0x65, 0x6f, 0x69, + 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, + 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x4c, 0x0a, 0x0e, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, + 0x61, 0x6c, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, + 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, + 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, + 0x75, 0x6c, 0x65, 0x73, 0x12, 0x42, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, + 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, 0x69, 0x6f, + 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, + 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x36, 0x0a, 0x0c, 0x4f, 0x72, 0x69, 0x67, + 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, + 0x22, 0x9c, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x0b, 0x6e, + 0x61, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, + 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x49, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, + 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x0b, 0x73, 0x74, 0x61, + 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, + 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x42, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x67, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x64, 0x69, 0x73, + 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x36, 0x0a, 0x16, + 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, + 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x64, 0x69, + 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, 0x66, 0x4d, + 0x61, 0x74, 0x63, 0x68, 0x1a, 0x92, 0x01, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, + 0x70, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x1a, 0x36, 0x0a, 0x0c, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, - 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0xef, 0x05, 0x0a, 0x06, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3f, 0x0a, 0x0b, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, - 0x76, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, 0x64, - 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0b, 0x4e, 0x61, 0x6d, 0x65, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x73, 0x12, 0x39, 0x0a, 0x0b, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x73, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x12, 0x39, 0x0a, 0x05, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x1f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x42, 0x02, 0x18, 0x01, 0x52, 0x05, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x1b, 0x0a, 0x09, - 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x74, 0x61, - 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, - 0x67, 0x52, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, - 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, - 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, - 0x61, 0x63, 0x68, 0x65, 0x12, 0x42, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, - 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, - 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, - 0x63, 0x6b, 0x12, 0x36, 0x0a, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, - 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, - 0x61, 0x63, 0x6b, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x1a, 0x55, 0x0a, 0x0a, 0x48, 0x6f, - 0x73, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x31, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x1a, 0x92, 0x01, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, - 0x67, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, - 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x02, 0x69, 0x70, 0x12, - 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x2a, 0x45, 0x0a, 0x12, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, - 0x53, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x4b, - 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x65, 0x67, 0x65, - 0x78, 0x10, 0x03, 0x2a, 0x35, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x67, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x00, - 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x01, 0x12, 0x0b, 0x0a, - 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x42, 0x46, 0x0a, 0x10, 0x63, 0x6f, - 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x50, 0x01, - 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, - 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x44, - 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x02, + 0x69, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x5f, 0x64, 0x6f, + 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, + 0x69, 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x2a, + 0x45, 0x0a, 0x12, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, + 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, + 0x0d, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x01, 0x12, 0x0b, + 0x0a, 0x07, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x52, + 0x65, 0x67, 0x65, 0x78, 0x10, 0x03, 0x2a, 0x35, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, + 0x50, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x01, + 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x42, 0x46, 0x0a, + 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, + 0x73, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, + 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, + 0x70, 0x2e, 0x44, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -657,7 +616,7 @@ func file_app_dns_config_proto_rawDescGZIP() []byte { } var file_app_dns_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_app_dns_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_app_dns_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_app_dns_config_proto_goTypes = []any{ (DomainMatchingType)(0), // 0: xray.app.dns.DomainMatchingType (QueryStrategy)(0), // 1: xray.app.dns.QueryStrategy @@ -665,31 +624,26 @@ var file_app_dns_config_proto_goTypes = []any{ (*Config)(nil), // 3: xray.app.dns.Config (*NameServer_PriorityDomain)(nil), // 4: xray.app.dns.NameServer.PriorityDomain (*NameServer_OriginalRule)(nil), // 5: xray.app.dns.NameServer.OriginalRule - nil, // 6: xray.app.dns.Config.HostsEntry - (*Config_HostMapping)(nil), // 7: xray.app.dns.Config.HostMapping - (*net.Endpoint)(nil), // 8: xray.common.net.Endpoint - (*router.GeoIP)(nil), // 9: xray.app.router.GeoIP - (*net.IPOrDomain)(nil), // 10: xray.common.net.IPOrDomain + (*Config_HostMapping)(nil), // 6: xray.app.dns.Config.HostMapping + (*net.Endpoint)(nil), // 7: xray.common.net.Endpoint + (*router.GeoIP)(nil), // 8: xray.app.router.GeoIP } var file_app_dns_config_proto_depIdxs = []int32{ - 8, // 0: xray.app.dns.NameServer.address:type_name -> xray.common.net.Endpoint + 7, // 0: xray.app.dns.NameServer.address:type_name -> xray.common.net.Endpoint 4, // 1: xray.app.dns.NameServer.prioritized_domain:type_name -> xray.app.dns.NameServer.PriorityDomain - 9, // 2: xray.app.dns.NameServer.geoip:type_name -> xray.app.router.GeoIP + 8, // 2: xray.app.dns.NameServer.geoip:type_name -> xray.app.router.GeoIP 5, // 3: xray.app.dns.NameServer.original_rules:type_name -> xray.app.dns.NameServer.OriginalRule 1, // 4: xray.app.dns.NameServer.query_strategy:type_name -> xray.app.dns.QueryStrategy - 8, // 5: xray.app.dns.Config.NameServers:type_name -> xray.common.net.Endpoint - 2, // 6: xray.app.dns.Config.name_server:type_name -> xray.app.dns.NameServer - 6, // 7: xray.app.dns.Config.Hosts:type_name -> xray.app.dns.Config.HostsEntry - 7, // 8: xray.app.dns.Config.static_hosts:type_name -> xray.app.dns.Config.HostMapping - 1, // 9: xray.app.dns.Config.query_strategy:type_name -> xray.app.dns.QueryStrategy - 0, // 10: xray.app.dns.NameServer.PriorityDomain.type:type_name -> xray.app.dns.DomainMatchingType - 10, // 11: xray.app.dns.Config.HostsEntry.value:type_name -> xray.common.net.IPOrDomain - 0, // 12: xray.app.dns.Config.HostMapping.type:type_name -> xray.app.dns.DomainMatchingType - 13, // [13:13] is the sub-list for method output_type - 13, // [13:13] is the sub-list for method input_type - 13, // [13:13] is the sub-list for extension type_name - 13, // [13:13] is the sub-list for extension extendee - 0, // [0:13] is the sub-list for field type_name + 2, // 5: xray.app.dns.Config.name_server:type_name -> xray.app.dns.NameServer + 6, // 6: xray.app.dns.Config.static_hosts:type_name -> xray.app.dns.Config.HostMapping + 1, // 7: xray.app.dns.Config.query_strategy:type_name -> xray.app.dns.QueryStrategy + 0, // 8: xray.app.dns.NameServer.PriorityDomain.type:type_name -> xray.app.dns.DomainMatchingType + 0, // 9: xray.app.dns.Config.HostMapping.type:type_name -> xray.app.dns.DomainMatchingType + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_app_dns_config_proto_init() } @@ -746,7 +700,7 @@ func file_app_dns_config_proto_init() { return nil } } - file_app_dns_config_proto_msgTypes[5].Exporter = func(v any, i int) any { + file_app_dns_config_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Config_HostMapping); i { case 0: return &v.state @@ -765,7 +719,7 @@ func file_app_dns_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_dns_config_proto_rawDesc, NumEnums: 2, - NumMessages: 6, + NumMessages: 5, NumExtensions: 0, NumServices: 0, }, diff --git a/app/dns/config.proto b/app/dns/config.proto index 2c420651..11e0c8de 100644 --- a/app/dns/config.proto +++ b/app/dns/config.proto @@ -6,7 +6,6 @@ option go_package = "github.com/xtls/xray-core/app/dns"; option java_package = "com.xray.app.dns"; option java_multiple_files = true; -import "common/net/address.proto"; import "common/net/destination.proto"; import "app/router/config.proto"; @@ -45,18 +44,10 @@ enum QueryStrategy { } message Config { - // Nameservers used by this DNS. Only traditional UDP servers are support at - // the moment. A special value 'localhost' as a domain address can be set to - // use DNS on local system. - repeated xray.common.net.Endpoint NameServers = 1 [deprecated = true]; - // NameServer list used by this DNS client. + // A special value 'localhost' as a domain address can be set to use DNS on local system. repeated NameServer name_server = 5; - // Static hosts. Domain to IP. - // Deprecated. Use static_hosts. - map Hosts = 2 [deprecated = true]; - // Client IP for EDNS client subnet. Must be 4 bytes (IPv4) or 16 bytes // (IPv6). bytes client_ip = 3; diff --git a/app/dns/dns.go b/app/dns/dns.go index f4802275..24cbbb11 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -78,7 +78,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) { } } - hosts, err := NewStaticHosts(config.StaticHosts, config.Hosts) + hosts, err := NewStaticHosts(config.StaticHosts) if err != nil { return nil, errors.New("failed to create hosts").Base(err) } @@ -94,15 +94,6 @@ func New(ctx context.Context, config *Config) (*DNS, error) { domainMatcher := &strmatcher.MatcherGroup{} geoipContainer := router.GeoIPMatcherContainer{} - for _, endpoint := range config.NameServers { - errors.PrintDeprecatedFeatureWarning("simple DNS server", "") - client, err := NewSimpleClient(ctx, endpoint, clientIP) - if err != nil { - return nil, errors.New("failed to create client").Base(err) - } - clients = append(clients, client) - } - for _, ns := range config.NameServer { clientIdx := len(clients) updateDomain := func(domainRule strmatcher.Matcher, originalRuleIdx int, matcherInfos []*DomainMatcherInfo) error { diff --git a/app/dns/dns_test.go b/app/dns/dns_test.go index 74c7a125..500c057e 100644 --- a/app/dns/dns_test.go +++ b/app/dns/dns_test.go @@ -124,15 +124,17 @@ func TestUDPServerSubnet(t *testing.T) { config := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&Config{ - NameServers: []*net.Endpoint{ + NameServer: []*NameServer{ { - Network: net.Network_UDP, - Address: &net.IPOrDomain{ - Address: &net.IPOrDomain_Ip{ - Ip: []byte{127, 0, 0, 1}, + Address: &net.Endpoint{ + Network: net.Network_UDP, + Address: &net.IPOrDomain{ + Address: &net.IPOrDomain_Ip{ + Ip: []byte{127, 0, 0, 1}, + }, }, + Port: uint32(port), }, - Port: uint32(port), }, }, ClientIp: []byte{7, 8, 9, 10}, @@ -183,15 +185,17 @@ func TestUDPServer(t *testing.T) { config := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&Config{ - NameServers: []*net.Endpoint{ + NameServer: []*NameServer{ { - Network: net.Network_UDP, - Address: &net.IPOrDomain{ - Address: &net.IPOrDomain_Ip{ - Ip: []byte{127, 0, 0, 1}, + Address: &net.Endpoint{ + Network: net.Network_UDP, + Address: &net.IPOrDomain{ + Address: &net.IPOrDomain_Ip{ + Ip: []byte{127, 0, 0, 1}, + }, }, + Port: uint32(port), }, - Port: uint32(port), }, }, }), @@ -303,18 +307,18 @@ func TestPrioritizedDomain(t *testing.T) { config := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&Config{ - NameServers: []*net.Endpoint{ - { - Network: net.Network_UDP, - Address: &net.IPOrDomain{ - Address: &net.IPOrDomain_Ip{ - Ip: []byte{127, 0, 0, 1}, - }, - }, - Port: 9999, /* unreachable */ - }, - }, NameServer: []*NameServer{ + { + Address: &net.Endpoint{ + Network: net.Network_UDP, + Address: &net.IPOrDomain{ + Address: &net.IPOrDomain_Ip{ + Ip: []byte{127, 0, 0, 1}, + }, + }, + Port: 9999, /* unreachable */ + }, + }, { Address: &net.Endpoint{ Network: net.Network_UDP, @@ -389,15 +393,17 @@ func TestUDPServerIPv6(t *testing.T) { config := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&Config{ - NameServers: []*net.Endpoint{ + NameServer: []*NameServer{ { - Network: net.Network_UDP, - Address: &net.IPOrDomain{ - Address: &net.IPOrDomain_Ip{ - Ip: []byte{127, 0, 0, 1}, + Address: &net.Endpoint{ + Network: net.Network_UDP, + Address: &net.IPOrDomain{ + Address: &net.IPOrDomain_Ip{ + Ip: []byte{127, 0, 0, 1}, + }, }, + Port: uint32(port), }, - Port: uint32(port), }, }, }), @@ -448,15 +454,17 @@ func TestStaticHostDomain(t *testing.T) { config := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&Config{ - NameServers: []*net.Endpoint{ + NameServer: []*NameServer{ { - Network: net.Network_UDP, - Address: &net.IPOrDomain{ - Address: &net.IPOrDomain_Ip{ - Ip: []byte{127, 0, 0, 1}, + Address: &net.Endpoint{ + Network: net.Network_UDP, + Address: &net.IPOrDomain{ + Address: &net.IPOrDomain_Ip{ + Ip: []byte{127, 0, 0, 1}, + }, }, + Port: uint32(port), }, - Port: uint32(port), }, }, StaticHosts: []*Config_HostMapping{ @@ -631,18 +639,18 @@ func TestLocalDomain(t *testing.T) { config := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&Config{ - NameServers: []*net.Endpoint{ - { - Network: net.Network_UDP, - Address: &net.IPOrDomain{ - Address: &net.IPOrDomain_Ip{ - Ip: []byte{127, 0, 0, 1}, - }, - }, - Port: 9999, /* unreachable */ - }, - }, NameServer: []*NameServer{ + { + Address: &net.Endpoint{ + Network: net.Network_UDP, + Address: &net.IPOrDomain{ + Address: &net.IPOrDomain_Ip{ + Ip: []byte{127, 0, 0, 1}, + }, + }, + Port: 9999, /* unreachable */ + }, + }, { Address: &net.Endpoint{ Network: net.Network_UDP, @@ -859,18 +867,18 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) { config := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&Config{ - NameServers: []*net.Endpoint{ - { - Network: net.Network_UDP, - Address: &net.IPOrDomain{ - Address: &net.IPOrDomain_Ip{ - Ip: []byte{127, 0, 0, 1}, - }, - }, - Port: 9999, /* unreachable */ - }, - }, NameServer: []*NameServer{ + { + Address: &net.Endpoint{ + Network: net.Network_UDP, + Address: &net.IPOrDomain{ + Address: &net.IPOrDomain_Ip{ + Ip: []byte{127, 0, 0, 1}, + }, + }, + Port: 9999, /* unreachable */ + }, + }, { Address: &net.Endpoint{ Network: net.Network_UDP, diff --git a/app/dns/hosts.go b/app/dns/hosts.go index 4dd01041..e1ceb9c7 100644 --- a/app/dns/hosts.go +++ b/app/dns/hosts.go @@ -3,7 +3,6 @@ package dns import ( "context" - "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/common/strmatcher" @@ -17,30 +16,13 @@ type StaticHosts struct { } // NewStaticHosts creates a new StaticHosts instance. -func NewStaticHosts(hosts []*Config_HostMapping, legacy map[string]*net.IPOrDomain) (*StaticHosts, error) { +func NewStaticHosts(hosts []*Config_HostMapping) (*StaticHosts, error) { g := new(strmatcher.MatcherGroup) sh := &StaticHosts{ - ips: make([][]net.Address, len(hosts)+len(legacy)+16), + ips: make([][]net.Address, len(hosts)+16), matchers: g, } - if legacy != nil { - errors.PrintDeprecatedFeatureWarning("simple host mapping", "") - - for domain, ip := range legacy { - matcher, err := strmatcher.Full.New(domain) - common.Must(err) - id := g.Add(matcher) - - address := ip.AsAddress() - if address.Family().IsDomain() { - return nil, errors.New("invalid domain address in static hosts: ", address.Domain()).AtWarning() - } - - sh.ips[id] = []net.Address{address} - } - } - for _, mapping := range hosts { matcher, err := toStrMatcher(mapping.Type, mapping.Domain) if err != nil { diff --git a/app/dns/hosts_test.go b/app/dns/hosts_test.go index 40533b11..380c7cb2 100644 --- a/app/dns/hosts_test.go +++ b/app/dns/hosts_test.go @@ -50,7 +50,7 @@ func TestStaticHosts(t *testing.T) { }, } - hosts, err := NewStaticHosts(pb, nil) + hosts, err := NewStaticHosts(pb) common.Must(err) { diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index cf79103f..f3ce2778 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -163,31 +163,6 @@ func NewClient( return client, err } -// NewSimpleClient creates a DNS client with a simple destination. -func NewSimpleClient(ctx context.Context, endpoint *net.Endpoint, clientIP net.IP) (*Client, error) { - client := &Client{} - err := core.RequireFeatures(ctx, func(dispatcher routing.Dispatcher) error { - server, err := NewServer(endpoint.AsDestination(), dispatcher, QueryStrategy_USE_IP) - if err != nil { - return errors.New("failed to create nameserver").Base(err).AtWarning() - } - client.server = server - client.clientIP = clientIP - return nil - }) - - if len(clientIP) > 0 { - switch endpoint.Address.GetAddress().(type) { - case *net.IPOrDomain_Domain: - errors.LogInfo(ctx, "DNS: client ", endpoint.Address.GetDomain(), " uses clientIP ", clientIP.String()) - case *net.IPOrDomain_Ip: - errors.LogInfo(ctx, "DNS: client ", endpoint.Address.GetIp(), " uses clientIP ", clientIP.String()) - } - } - - return client, err -} - // Name returns the server name the client manages. func (c *Client) Name() string { return c.server.Name() diff --git a/app/router/condition_test.go b/app/router/condition_test.go index b5d59297..75ee86dd 100644 --- a/app/router/condition_test.go +++ b/app/router/condition_test.go @@ -106,42 +106,6 @@ func TestRoutingRule(t *testing.T) { }, }, }, - { - rule: &RoutingRule{ - Cidr: []*CIDR{ - { - Ip: []byte{8, 8, 8, 8}, - Prefix: 32, - }, - { - Ip: []byte{8, 8, 8, 8}, - Prefix: 32, - }, - { - Ip: net.ParseAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334").IP(), - Prefix: 128, - }, - }, - }, - test: []ruleTest{ - { - input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.ParseAddress("8.8.8.8"), 80)}), - output: true, - }, - { - input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.ParseAddress("8.8.4.4"), 80)}), - output: false, - }, - { - input: withOutbound(&session.Outbound{Target: net.TCPDestination(net.ParseAddress("2001:0db8:85a3:0000:0000:8a2e:0370:7334"), 80)}), - output: true, - }, - { - input: withBackground(), - output: false, - }, - }, - }, { rule: &RoutingRule{ Geoip: []*GeoIP{ @@ -184,10 +148,14 @@ func TestRoutingRule(t *testing.T) { }, { rule: &RoutingRule{ - SourceCidr: []*CIDR{ + SourceGeoip: []*GeoIP{ { - Ip: []byte{192, 168, 0, 0}, - Prefix: 16, + Cidr: []*CIDR{ + { + Ip: []byte{192, 168, 0, 0}, + Prefix: 16, + }, + }, }, }, }, diff --git a/app/router/config.go b/app/router/config.go index f2bad88f..f1740610 100644 --- a/app/router/config.go +++ b/app/router/config.go @@ -6,7 +6,6 @@ import ( "strings" "github.com/xtls/xray-core/common/errors" - "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/features/outbound" "github.com/xtls/xray-core/features/routing" ) @@ -63,8 +62,6 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) { if rr.PortList != nil { conds.Add(NewPortMatcher(rr.PortList, false)) - } else if rr.PortRange != nil { - conds.Add(NewPortMatcher(&net.PortList{Range: []*net.PortRange{rr.PortRange}}, false)) } if rr.SourcePortList != nil { @@ -73,8 +70,6 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) { if len(rr.Networks) > 0 { conds.Add(NewNetworkMatcher(rr.Networks)) - } else if rr.NetworkList != nil { - conds.Add(NewNetworkMatcher(rr.NetworkList.Network)) } if len(rr.Geoip) > 0 { @@ -83,12 +78,6 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) { return nil, err } conds.Add(cond) - } else if len(rr.Cidr) > 0 { - cond, err := NewMultiGeoIPMatcher([]*GeoIP{{Cidr: rr.Cidr}}, false) - if err != nil { - return nil, err - } - conds.Add(cond) } if len(rr.SourceGeoip) > 0 { @@ -97,12 +86,6 @@ func (rr *RoutingRule) BuildCondition() (Condition, error) { return nil, err } conds.Add(cond) - } else if len(rr.SourceCidr) > 0 { - cond, err := NewMultiGeoIPMatcher([]*GeoIP{{Cidr: rr.SourceCidr}}, true) - if err != nil { - return nil, err - } - conds.Add(cond) } if len(rr.Protocol) > 0 { diff --git a/app/router/config.pb.go b/app/router/config.pb.go index c606ab47..b214d12a 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: app/router/config.proto package router @@ -485,33 +485,15 @@ type RoutingRule struct { RuleTag string `protobuf:"bytes,18,opt,name=rule_tag,json=ruleTag,proto3" json:"rule_tag,omitempty"` // List of domains for target domain matching. Domain []*Domain `protobuf:"bytes,2,rep,name=domain,proto3" json:"domain,omitempty"` - // List of CIDRs for target IP address matching. - // Deprecated. Use geoip below. - // - // Deprecated: Marked as deprecated in app/router/config.proto. - Cidr []*CIDR `protobuf:"bytes,3,rep,name=cidr,proto3" json:"cidr,omitempty"` // List of GeoIPs for target IP address matching. If this entry exists, the // cidr above will have no effect. GeoIP fields with the same country code are // supposed to contain exactly same content. They will be merged during // runtime. For customized GeoIPs, please leave country code empty. Geoip []*GeoIP `protobuf:"bytes,10,rep,name=geoip,proto3" json:"geoip,omitempty"` - // A range of port [from, to]. If the destination port is in this range, this - // rule takes effect. Deprecated. Use port_list. - // - // Deprecated: Marked as deprecated in app/router/config.proto. - PortRange *net.PortRange `protobuf:"bytes,4,opt,name=port_range,json=portRange,proto3" json:"port_range,omitempty"` // List of ports. PortList *net.PortList `protobuf:"bytes,14,opt,name=port_list,json=portList,proto3" json:"port_list,omitempty"` - // List of networks. Deprecated. Use networks. - // - // Deprecated: Marked as deprecated in app/router/config.proto. - NetworkList *net.NetworkList `protobuf:"bytes,5,opt,name=network_list,json=networkList,proto3" json:"network_list,omitempty"` // List of networks for matching. Networks []net.Network `protobuf:"varint,13,rep,packed,name=networks,proto3,enum=xray.common.net.Network" json:"networks,omitempty"` - // List of CIDRs for source IP address matching. - // - // Deprecated: Marked as deprecated in app/router/config.proto. - SourceCidr []*CIDR `protobuf:"bytes,6,rep,name=source_cidr,json=sourceCidr,proto3" json:"source_cidr,omitempty"` // List of GeoIPs for source IP address matching. If this entry exists, the // source_cidr above will have no effect. SourceGeoip []*GeoIP `protobuf:"bytes,11,rep,name=source_geoip,json=sourceGeoip,proto3" json:"source_geoip,omitempty"` @@ -591,14 +573,6 @@ func (x *RoutingRule) GetDomain() []*Domain { return nil } -// Deprecated: Marked as deprecated in app/router/config.proto. -func (x *RoutingRule) GetCidr() []*CIDR { - if x != nil { - return x.Cidr - } - return nil -} - func (x *RoutingRule) GetGeoip() []*GeoIP { if x != nil { return x.Geoip @@ -606,14 +580,6 @@ func (x *RoutingRule) GetGeoip() []*GeoIP { return nil } -// Deprecated: Marked as deprecated in app/router/config.proto. -func (x *RoutingRule) GetPortRange() *net.PortRange { - if x != nil { - return x.PortRange - } - return nil -} - func (x *RoutingRule) GetPortList() *net.PortList { if x != nil { return x.PortList @@ -621,14 +587,6 @@ func (x *RoutingRule) GetPortList() *net.PortList { return nil } -// Deprecated: Marked as deprecated in app/router/config.proto. -func (x *RoutingRule) GetNetworkList() *net.NetworkList { - if x != nil { - return x.NetworkList - } - return nil -} - func (x *RoutingRule) GetNetworks() []net.Network { if x != nil { return x.Networks @@ -636,14 +594,6 @@ func (x *RoutingRule) GetNetworks() []net.Network { return nil } -// Deprecated: Marked as deprecated in app/router/config.proto. -func (x *RoutingRule) GetSourceCidr() []*CIDR { - if x != nil { - return x.SourceCidr - } - return nil -} - func (x *RoutingRule) GetSourceGeoip() []*GeoIP { if x != nil { return x.SourceGeoip @@ -1143,7 +1093,7 @@ var file_app_router_config_proto_rawDesc = []byte{ 0x6f, 0x53, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2e, 0x0a, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x53, 0x69, - 0x74, 0x65, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0xbd, 0x07, 0x0a, 0x0b, 0x52, 0x6f, + 0x74, 0x65, 0x52, 0x05, 0x65, 0x6e, 0x74, 0x72, 0x79, 0x22, 0xce, 0x05, 0x0a, 0x0b, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x25, 0x0a, 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x0c, @@ -1153,112 +1103,97 @@ var file_app_router_config_proto_rawDesc = []byte{ 0x2f, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x12, 0x2d, 0x0a, 0x04, 0x63, 0x69, 0x64, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x2e, 0x43, 0x49, 0x44, 0x52, 0x42, 0x02, 0x18, 0x01, 0x52, 0x04, 0x63, 0x69, 0x64, 0x72, 0x12, - 0x2c, 0x0a, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x3d, 0x0a, - 0x0a, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, - 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x42, 0x02, 0x18, - 0x01, 0x52, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x36, 0x0a, 0x09, - 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, - 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x08, 0x70, 0x6f, 0x72, 0x74, - 0x4c, 0x69, 0x73, 0x74, 0x12, 0x43, 0x0a, 0x0c, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, - 0x6c, 0x69, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x42, 0x02, 0x18, 0x01, 0x52, 0x0b, 0x6e, 0x65, - 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x6e, 0x65, 0x74, - 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, - 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x12, - 0x3a, 0x0a, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x69, 0x64, 0x72, 0x18, 0x06, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x49, 0x44, 0x52, 0x42, 0x02, 0x18, 0x01, 0x52, - 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x69, 0x64, 0x72, 0x12, 0x39, 0x0a, 0x0c, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0b, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, - 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x0b, 0x73, 0x6f, 0x75, 0x72, 0x63, - 0x65, 0x47, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x43, 0x0a, 0x10, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, - 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x0e, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x09, 0x75, 0x73, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x69, 0x6e, - 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, 0x52, - 0x0a, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x4c, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, - 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x6f, - 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x2e, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, - 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, - 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, - 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x1a, 0x3d, 0x0a, 0x0f, - 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0c, 0x0a, 0x0a, 0x74, - 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x61, 0x67, 0x22, 0xdc, 0x01, 0x0a, 0x0d, 0x42, 0x61, - 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x74, - 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x2b, 0x0a, - 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, - 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, - 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x4d, 0x0a, 0x11, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, - 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x52, 0x10, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x53, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x61, 0x6c, - 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x54, 0x0a, 0x0e, 0x53, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x67, 0x79, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, - 0x67, 0x65, 0x78, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, 0x65, 0x67, 0x65, - 0x78, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xc0, - 0x01, 0x0a, 0x17, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x4c, 0x65, 0x61, 0x73, 0x74, - 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, 0x0a, 0x05, 0x63, 0x6f, - 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x67, 0x79, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x05, 0x63, 0x6f, 0x73, 0x74, - 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x61, 0x73, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x03, 0x52, 0x09, 0x62, 0x61, 0x73, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x12, - 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x08, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6d, - 0x61, 0x78, 0x52, 0x54, 0x54, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6d, 0x61, 0x78, - 0x52, 0x54, 0x54, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x6f, 0x6c, 0x65, 0x72, 0x61, 0x6e, 0x63, 0x65, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x74, 0x6f, 0x6c, 0x65, 0x72, 0x61, 0x6e, 0x63, - 0x65, 0x22, 0x9b, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4f, 0x0a, 0x0f, - 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x30, 0x0a, - 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x52, 0x6f, - 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, - 0x45, 0x0a, 0x0e, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, - 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, - 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, 0x63, - 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, - 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x47, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x73, 0x49, 0x73, - 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x49, 0x70, 0x10, 0x01, 0x12, 0x10, 0x0a, - 0x0c, 0x49, 0x70, 0x49, 0x66, 0x4e, 0x6f, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x02, 0x12, - 0x0e, 0x0a, 0x0a, 0x49, 0x70, 0x4f, 0x6e, 0x44, 0x65, 0x6d, 0x61, 0x6e, 0x64, 0x10, 0x03, 0x42, - 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, - 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0xaa, 0x02, - 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, 0x72, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x2c, 0x0a, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, + 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x36, + 0x0a, 0x09, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x0e, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x08, 0x70, 0x6f, + 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x34, 0x0a, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x73, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x52, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x12, 0x39, 0x0a, 0x0c, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0b, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, + 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x0b, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x47, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x43, 0x0a, 0x10, 0x73, 0x6f, 0x75, 0x72, 0x63, + 0x65, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x6e, 0x65, 0x74, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x0e, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, + 0x75, 0x73, 0x65, 0x72, 0x5f, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x07, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x69, + 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x08, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x0a, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x54, 0x61, 0x67, 0x12, 0x1a, 0x0a, 0x08, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x09, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x4c, 0x0a, 0x0a, 0x61, 0x74, 0x74, 0x72, + 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x52, + 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x2e, 0x41, 0x74, 0x74, 0x72, 0x69, + 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x61, 0x74, 0x74, 0x72, + 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x5f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x65, 0x72, 0x1a, 0x3d, 0x0a, + 0x0f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x0c, 0x0a, 0x0a, + 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x74, 0x61, 0x67, 0x22, 0xdc, 0x01, 0x0a, 0x0d, 0x42, + 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x10, 0x0a, 0x03, + 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x2b, + 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x73, 0x65, 0x6c, 0x65, 0x63, + 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, + 0x75, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x4d, 0x0a, 0x11, 0x73, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, + 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x52, 0x10, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x61, 0x6c, 0x6c, 0x62, 0x61, + 0x63, 0x6b, 0x5f, 0x74, 0x61, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x61, + 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x54, 0x61, 0x67, 0x22, 0x54, 0x0a, 0x0e, 0x53, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, + 0x65, 0x67, 0x65, 0x78, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x72, 0x65, 0x67, + 0x65, 0x78, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, + 0xc0, 0x01, 0x0a, 0x17, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x4c, 0x65, 0x61, 0x73, + 0x74, 0x4c, 0x6f, 0x61, 0x64, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, 0x0a, 0x05, 0x63, + 0x6f, 0x73, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x05, 0x63, 0x6f, 0x73, + 0x74, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x61, 0x73, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x03, 0x52, 0x09, 0x62, 0x61, 0x73, 0x65, 0x6c, 0x69, 0x6e, 0x65, 0x73, + 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x16, 0x0a, 0x06, + 0x6d, 0x61, 0x78, 0x52, 0x54, 0x54, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6d, 0x61, + 0x78, 0x52, 0x54, 0x54, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x6f, 0x6c, 0x65, 0x72, 0x61, 0x6e, 0x63, + 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x02, 0x52, 0x09, 0x74, 0x6f, 0x6c, 0x65, 0x72, 0x61, 0x6e, + 0x63, 0x65, 0x22, 0x9b, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x4f, 0x0a, + 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x30, + 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x52, + 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, + 0x12, 0x45, 0x0a, 0x0e, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, + 0x6c, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x42, 0x61, 0x6c, 0x61, 0x6e, + 0x63, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x62, 0x61, 0x6c, 0x61, 0x6e, 0x63, + 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x22, 0x47, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, + 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, 0x04, 0x41, 0x73, 0x49, + 0x73, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x55, 0x73, 0x65, 0x49, 0x70, 0x10, 0x01, 0x12, 0x10, + 0x0a, 0x0c, 0x49, 0x70, 0x49, 0x66, 0x4e, 0x6f, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x10, 0x02, + 0x12, 0x0e, 0x0a, 0x0a, 0x49, 0x70, 0x4f, 0x6e, 0x44, 0x65, 0x6d, 0x61, 0x6e, 0x64, 0x10, 0x03, + 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, + 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, + 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0xaa, + 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x65, + 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1291,11 +1226,9 @@ var file_app_router_config_proto_goTypes = []any{ (*Config)(nil), // 12: xray.app.router.Config (*Domain_Attribute)(nil), // 13: xray.app.router.Domain.Attribute nil, // 14: xray.app.router.RoutingRule.AttributesEntry - (*net.PortRange)(nil), // 15: xray.common.net.PortRange - (*net.PortList)(nil), // 16: xray.common.net.PortList - (*net.NetworkList)(nil), // 17: xray.common.net.NetworkList - (net.Network)(0), // 18: xray.common.net.Network - (*serial.TypedMessage)(nil), // 19: xray.common.serial.TypedMessage + (*net.PortList)(nil), // 15: xray.common.net.PortList + (net.Network)(0), // 16: xray.common.net.Network + (*serial.TypedMessage)(nil), // 17: xray.common.serial.TypedMessage } var file_app_router_config_proto_depIdxs = []int32{ 0, // 0: xray.app.router.Domain.type:type_name -> xray.app.router.Domain.Type @@ -1305,26 +1238,22 @@ var file_app_router_config_proto_depIdxs = []int32{ 2, // 4: xray.app.router.GeoSite.domain:type_name -> xray.app.router.Domain 6, // 5: xray.app.router.GeoSiteList.entry:type_name -> xray.app.router.GeoSite 2, // 6: xray.app.router.RoutingRule.domain:type_name -> xray.app.router.Domain - 3, // 7: xray.app.router.RoutingRule.cidr:type_name -> xray.app.router.CIDR - 4, // 8: xray.app.router.RoutingRule.geoip:type_name -> xray.app.router.GeoIP - 15, // 9: xray.app.router.RoutingRule.port_range:type_name -> xray.common.net.PortRange - 16, // 10: xray.app.router.RoutingRule.port_list:type_name -> xray.common.net.PortList - 17, // 11: xray.app.router.RoutingRule.network_list:type_name -> xray.common.net.NetworkList - 18, // 12: xray.app.router.RoutingRule.networks:type_name -> xray.common.net.Network - 3, // 13: xray.app.router.RoutingRule.source_cidr:type_name -> xray.app.router.CIDR - 4, // 14: xray.app.router.RoutingRule.source_geoip:type_name -> xray.app.router.GeoIP - 16, // 15: xray.app.router.RoutingRule.source_port_list:type_name -> xray.common.net.PortList - 14, // 16: xray.app.router.RoutingRule.attributes:type_name -> xray.app.router.RoutingRule.AttributesEntry - 19, // 17: xray.app.router.BalancingRule.strategy_settings:type_name -> xray.common.serial.TypedMessage - 10, // 18: xray.app.router.StrategyLeastLoadConfig.costs:type_name -> xray.app.router.StrategyWeight - 1, // 19: xray.app.router.Config.domain_strategy:type_name -> xray.app.router.Config.DomainStrategy - 8, // 20: xray.app.router.Config.rule:type_name -> xray.app.router.RoutingRule - 9, // 21: xray.app.router.Config.balancing_rule:type_name -> xray.app.router.BalancingRule - 22, // [22:22] is the sub-list for method output_type - 22, // [22:22] is the sub-list for method input_type - 22, // [22:22] is the sub-list for extension type_name - 22, // [22:22] is the sub-list for extension extendee - 0, // [0:22] is the sub-list for field type_name + 4, // 7: xray.app.router.RoutingRule.geoip:type_name -> xray.app.router.GeoIP + 15, // 8: xray.app.router.RoutingRule.port_list:type_name -> xray.common.net.PortList + 16, // 9: xray.app.router.RoutingRule.networks:type_name -> xray.common.net.Network + 4, // 10: xray.app.router.RoutingRule.source_geoip:type_name -> xray.app.router.GeoIP + 15, // 11: xray.app.router.RoutingRule.source_port_list:type_name -> xray.common.net.PortList + 14, // 12: xray.app.router.RoutingRule.attributes:type_name -> xray.app.router.RoutingRule.AttributesEntry + 17, // 13: xray.app.router.BalancingRule.strategy_settings:type_name -> xray.common.serial.TypedMessage + 10, // 14: xray.app.router.StrategyLeastLoadConfig.costs:type_name -> xray.app.router.StrategyWeight + 1, // 15: xray.app.router.Config.domain_strategy:type_name -> xray.app.router.Config.DomainStrategy + 8, // 16: xray.app.router.Config.rule:type_name -> xray.app.router.RoutingRule + 9, // 17: xray.app.router.Config.balancing_rule:type_name -> xray.app.router.BalancingRule + 18, // [18:18] is the sub-list for method output_type + 18, // [18:18] is the sub-list for method input_type + 18, // [18:18] is the sub-list for extension type_name + 18, // [18:18] is the sub-list for extension extendee + 0, // [0:18] is the sub-list for field type_name } func init() { file_app_router_config_proto_init() } diff --git a/app/router/config.proto b/app/router/config.proto index fdd2e61d..505f0712 100644 --- a/app/router/config.proto +++ b/app/router/config.proto @@ -84,32 +84,18 @@ message RoutingRule { // List of domains for target domain matching. repeated Domain domain = 2; - // List of CIDRs for target IP address matching. - // Deprecated. Use geoip below. - repeated CIDR cidr = 3 [deprecated = true]; - // List of GeoIPs for target IP address matching. If this entry exists, the // cidr above will have no effect. GeoIP fields with the same country code are // supposed to contain exactly same content. They will be merged during // runtime. For customized GeoIPs, please leave country code empty. repeated GeoIP geoip = 10; - // A range of port [from, to]. If the destination port is in this range, this - // rule takes effect. Deprecated. Use port_list. - xray.common.net.PortRange port_range = 4 [deprecated = true]; - // List of ports. xray.common.net.PortList port_list = 14; - // List of networks. Deprecated. Use networks. - xray.common.net.NetworkList network_list = 5 [deprecated = true]; - // List of networks for matching. repeated xray.common.net.Network networks = 13; - // List of CIDRs for source IP address matching. - repeated CIDR source_cidr = 6 [deprecated = true]; - // List of GeoIPs for source IP address matching. If this entry exists, the // source_cidr above will have no effect. repeated GeoIP source_geoip = 11; diff --git a/app/router/router_test.go b/app/router/router_test.go index 2c33aae1..09f831b2 100644 --- a/app/router/router_test.go +++ b/app/router/router_test.go @@ -155,10 +155,14 @@ func TestIPOnDemand(t *testing.T) { TargetTag: &RoutingRule_Tag{ Tag: "test", }, - Cidr: []*CIDR{ + Geoip: []*GeoIP{ { - Ip: []byte{192, 168, 0, 0}, - Prefix: 16, + Cidr: []*CIDR{ + { + Ip: []byte{192, 168, 0, 0}, + Prefix: 16, + }, + }, }, }, }, @@ -196,10 +200,14 @@ func TestIPIfNonMatchDomain(t *testing.T) { TargetTag: &RoutingRule_Tag{ Tag: "test", }, - Cidr: []*CIDR{ + Geoip: []*GeoIP{ { - Ip: []byte{192, 168, 0, 0}, - Prefix: 16, + Cidr: []*CIDR{ + { + Ip: []byte{192, 168, 0, 0}, + Prefix: 16, + }, + }, }, }, }, @@ -237,10 +245,14 @@ func TestIPIfNonMatchIP(t *testing.T) { TargetTag: &RoutingRule_Tag{ Tag: "test", }, - Cidr: []*CIDR{ + Geoip: []*GeoIP{ { - Ip: []byte{127, 0, 0, 0}, - Prefix: 8, + Cidr: []*CIDR{ + { + Ip: []byte{127, 0, 0, 0}, + Prefix: 8, + }, + }, }, }, }, diff --git a/core/config.proto b/core/config.proto index 0b724bfc..32595d6d 100644 --- a/core/config.proto +++ b/core/config.proto @@ -29,11 +29,6 @@ message Config { // extension is not loaded into Xray. Xray will ignore such config during // initialization. repeated xray.common.serial.TypedMessage extension = 6; - - // Transport settings. - // Deprecated. Each inbound and outbound should choose their own transport - // config. Date to remove: 2020-01-13 - // xray.transport.Config transport = 5 [deprecated = true]; } // InboundHandlerConfig is the configuration for inbound handler. diff --git a/core/xray_test.go b/core/xray_test.go index a4a8ec9f..eea0a408 100644 --- a/core/xray_test.go +++ b/core/xray_test.go @@ -56,9 +56,7 @@ func TestXrayClose(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(net.LocalHostIP), Port: uint32(0), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, diff --git a/infra/conf/dokodemo.go b/infra/conf/dokodemo.go index 2a4b74ea..e0f76733 100644 --- a/infra/conf/dokodemo.go +++ b/infra/conf/dokodemo.go @@ -9,7 +9,6 @@ type DokodemoConfig struct { Host *Address `json:"address"` PortValue uint16 `json:"port"` NetworkList *NetworkList `json:"network"` - TimeoutValue uint32 `json:"timeout"` Redirect bool `json:"followRedirect"` UserLevel uint32 `json:"userLevel"` } @@ -21,7 +20,6 @@ func (v *DokodemoConfig) Build() (proto.Message, error) { } config.Port = uint32(v.PortValue) config.Networks = v.NetworkList.Build() - config.Timeout = v.TimeoutValue config.FollowRedirect = v.Redirect config.UserLevel = v.UserLevel return config, nil diff --git a/infra/conf/dokodemo_test.go b/infra/conf/dokodemo_test.go index 6432eb42..264cc8d7 100644 --- a/infra/conf/dokodemo_test.go +++ b/infra/conf/dokodemo_test.go @@ -19,7 +19,6 @@ func TestDokodemoConfig(t *testing.T) { "address": "8.8.8.8", "port": 53, "network": "tcp", - "timeout": 10, "followRedirect": true, "userLevel": 1 }`, @@ -32,7 +31,6 @@ func TestDokodemoConfig(t *testing.T) { }, Port: 53, Networks: []net.Network{net.Network_TCP}, - Timeout: 10, FollowRedirect: true, UserLevel: 1, }, diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 4a54936f..653f8815 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -15,7 +15,6 @@ import ( type FreedomConfig struct { DomainStrategy string `json:"domainStrategy"` - Timeout *uint32 `json:"timeout"` Redirect string `json:"redirect"` UserLevel uint32 `json:"userLevel"` Fragment *Fragment `json:"fragment"` @@ -167,9 +166,6 @@ func (c *FreedomConfig) Build() (proto.Message, error) { } } - if c.Timeout != nil { - config.Timeout = *c.Timeout - } config.UserLevel = c.UserLevel if len(c.Redirect) > 0 { host, portStr, err := net.SplitHostPort(c.Redirect) diff --git a/infra/conf/freedom_test.go b/infra/conf/freedom_test.go index 0d061558..3d9d142a 100644 --- a/infra/conf/freedom_test.go +++ b/infra/conf/freedom_test.go @@ -18,14 +18,12 @@ func TestFreedomConfig(t *testing.T) { { Input: `{ "domainStrategy": "AsIs", - "timeout": 10, "redirect": "127.0.0.1:3366", "userLevel": 1 }`, Parser: loadJSON(creator), Output: &freedom.Config{ DomainStrategy: freedom.Config_AS_IS, - Timeout: 10, DestinationOverride: &freedom.DestinationOverride{ Server: &protocol.ServerEndpoint{ Address: &net.IPOrDomain{ diff --git a/infra/conf/http.go b/infra/conf/http.go index ef16cac7..7f59bd79 100644 --- a/infra/conf/http.go +++ b/infra/conf/http.go @@ -23,7 +23,6 @@ func (v *HTTPAccount) Build() *http.Account { } type HTTPServerConfig struct { - Timeout uint32 `json:"timeout"` Accounts []*HTTPAccount `json:"accounts"` Transparent bool `json:"allowTransparent"` UserLevel uint32 `json:"userLevel"` @@ -31,7 +30,6 @@ type HTTPServerConfig struct { func (c *HTTPServerConfig) Build() (proto.Message, error) { config := &http.ServerConfig{ - Timeout: c.Timeout, AllowTransparent: c.Transparent, UserLevel: c.UserLevel, } diff --git a/infra/conf/http_test.go b/infra/conf/http_test.go index 110cac6b..66cca396 100644 --- a/infra/conf/http_test.go +++ b/infra/conf/http_test.go @@ -15,7 +15,6 @@ func TestHTTPServerConfig(t *testing.T) { runMultiTestCase(t, []TestCase{ { Input: `{ - "timeout": 10, "accounts": [ { "user": "my-username", @@ -32,7 +31,6 @@ func TestHTTPServerConfig(t *testing.T) { }, AllowTransparent: true, UserLevel: 1, - Timeout: 10, }, }, }) diff --git a/infra/conf/socks.go b/infra/conf/socks.go index 52fbe4c6..4e14ffdc 100644 --- a/infra/conf/socks.go +++ b/infra/conf/socks.go @@ -2,7 +2,6 @@ package conf import ( "encoding/json" - "strings" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/protocol" @@ -33,7 +32,6 @@ type SocksServerConfig struct { Accounts []*SocksAccount `json:"accounts"` UDP bool `json:"udp"` Host *Address `json:"ip"` - Timeout uint32 `json:"timeout"` UserLevel uint32 `json:"userLevel"` } @@ -61,7 +59,6 @@ func (v *SocksServerConfig) Build() (proto.Message, error) { config.Address = v.Host.Build() } - config.Timeout = v.Timeout config.UserLevel = v.UserLevel return config, nil } @@ -74,22 +71,11 @@ type SocksRemoteConfig struct { type SocksClientConfig struct { Servers []*SocksRemoteConfig `json:"servers"` - Version string `json:"version"` } func (v *SocksClientConfig) Build() (proto.Message, error) { config := new(socks.ClientConfig) config.Server = make([]*protocol.ServerEndpoint, len(v.Servers)) - switch strings.ToLower(v.Version) { - case "4": - config.Version = socks.Version_SOCKS4 - case "4a": - config.Version = socks.Version_SOCKS4A - case "", "5": - config.Version = socks.Version_SOCKS5 - default: - return nil, errors.New("failed to parse socks server version: ", v.Version).AtError() - } for idx, serverConfig := range v.Servers { server := &protocol.ServerEndpoint{ Address: serverConfig.Address.Build(), @@ -104,9 +90,6 @@ func (v *SocksClientConfig) Build() (proto.Message, error) { if err := json.Unmarshal(rawUser, account); err != nil { return nil, errors.New("failed to parse socks account").Base(err).AtError() } - if config.Version != socks.Version_SOCKS5 && account.Password != "" { - return nil, errors.New("password is only supported in socks5").AtError() - } user.Account = serial.ToTypedMessage(account.Build()) server.User = append(server.User, user) } diff --git a/infra/conf/socks_test.go b/infra/conf/socks_test.go index ff1833b8..bd7b570a 100644 --- a/infra/conf/socks_test.go +++ b/infra/conf/socks_test.go @@ -27,7 +27,6 @@ func TestSocksInboundConfig(t *testing.T) { ], "udp": false, "ip": "127.0.0.1", - "timeout": 5, "userLevel": 1 }`, Parser: loadJSON(creator), @@ -42,7 +41,6 @@ func TestSocksInboundConfig(t *testing.T) { Ip: []byte{127, 0, 0, 1}, }, }, - Timeout: 5, UserLevel: 1, }, }, diff --git a/infra/conf/trojan.go b/infra/conf/trojan.go index 03ac6f46..62c8f55b 100644 --- a/infra/conf/trojan.go +++ b/infra/conf/trojan.go @@ -94,7 +94,6 @@ type TrojanUserConfig struct { // TrojanServerConfig is Inbound configuration type TrojanServerConfig struct { Clients []*TrojanUserConfig `json:"clients"` - Fallback *TrojanInboundFallback `json:"fallback"` Fallbacks []*TrojanInboundFallback `json:"fallbacks"` } @@ -118,9 +117,6 @@ func (c *TrojanServerConfig) Build() (proto.Message, error) { } } - if c.Fallback != nil { - return nil, errors.New(`Trojan settings: please use "fallbacks":[{}] instead of "fallback":{}`) - } for _, fb := range c.Fallbacks { var i uint16 var s string diff --git a/infra/conf/vless.go b/infra/conf/vless.go index e9517614..27da68dc 100644 --- a/infra/conf/vless.go +++ b/infra/conf/vless.go @@ -31,7 +31,6 @@ type VLessInboundFallback struct { type VLessInboundConfig struct { Clients []json.RawMessage `json:"clients"` Decryption string `json:"decryption"` - Fallback *VLessInboundFallback `json:"fallback"` Fallbacks []*VLessInboundFallback `json:"fallbacks"` } @@ -74,9 +73,6 @@ func (c *VLessInboundConfig) Build() (proto.Message, error) { } config.Decryption = c.Decryption - if c.Fallback != nil { - return nil, errors.New(`VLESS settings: please use "fallbacks":[{}] instead of "fallback":{}`) - } for _, fb := range c.Fallbacks { var i uint16 var s string diff --git a/proxy/dns/dns_test.go b/proxy/dns/dns_test.go index ba6ee00e..2a005d68 100644 --- a/proxy/dns/dns_test.go +++ b/proxy/dns/dns_test.go @@ -91,15 +91,17 @@ func TestUDPDNSTunnel(t *testing.T) { config := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&dnsapp.Config{ - NameServers: []*net.Endpoint{ + NameServer: []*dnsapp.NameServer{ { - Network: net.Network_UDP, - Address: &net.IPOrDomain{ - Address: &net.IPOrDomain_Ip{ - Ip: []byte{127, 0, 0, 1}, + Address: &net.Endpoint{ + Network: net.Network_UDP, + Address: &net.IPOrDomain{ + Address: &net.IPOrDomain_Ip{ + Ip: []byte{127, 0, 0, 1}, + }, }, + Port: uint32(port), }, - Port: uint32(port), }, }, }), diff --git a/proxy/dokodemo/config.pb.go b/proxy/dokodemo/config.pb.go index b0446a40..985b7f1f 100644 --- a/proxy/dokodemo/config.pb.go +++ b/proxy/dokodemo/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: proxy/dokodemo/config.proto package dokodemo @@ -29,16 +29,9 @@ type Config struct { Address *net.IPOrDomain `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` Port uint32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` // List of networks that the Dokodemo accepts. - // Deprecated. Use networks. - // - // Deprecated: Marked as deprecated in proxy/dokodemo/config.proto. - NetworkList *net.NetworkList `protobuf:"bytes,3,opt,name=network_list,json=networkList,proto3" json:"network_list,omitempty"` - // List of networks that the Dokodemo accepts. - Networks []net.Network `protobuf:"varint,7,rep,packed,name=networks,proto3,enum=xray.common.net.Network" json:"networks,omitempty"` - // Deprecated: Marked as deprecated in proxy/dokodemo/config.proto. - Timeout uint32 `protobuf:"varint,4,opt,name=timeout,proto3" json:"timeout,omitempty"` - FollowRedirect bool `protobuf:"varint,5,opt,name=follow_redirect,json=followRedirect,proto3" json:"follow_redirect,omitempty"` - UserLevel uint32 `protobuf:"varint,6,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` + Networks []net.Network `protobuf:"varint,7,rep,packed,name=networks,proto3,enum=xray.common.net.Network" json:"networks,omitempty"` + FollowRedirect bool `protobuf:"varint,5,opt,name=follow_redirect,json=followRedirect,proto3" json:"follow_redirect,omitempty"` + UserLevel uint32 `protobuf:"varint,6,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` } func (x *Config) Reset() { @@ -87,14 +80,6 @@ func (x *Config) GetPort() uint32 { return 0 } -// Deprecated: Marked as deprecated in proxy/dokodemo/config.proto. -func (x *Config) GetNetworkList() *net.NetworkList { - if x != nil { - return x.NetworkList - } - return nil -} - func (x *Config) GetNetworks() []net.Network { if x != nil { return x.Networks @@ -102,14 +87,6 @@ func (x *Config) GetNetworks() []net.Network { return nil } -// Deprecated: Marked as deprecated in proxy/dokodemo/config.proto. -func (x *Config) GetTimeout() uint32 { - if x != nil { - return x.Timeout - } - return 0 -} - func (x *Config) GetFollowRedirect() bool { if x != nil { return x.FollowRedirect @@ -133,33 +110,26 @@ var file_proxy_dokodemo_config_proto_rawDesc = []byte{ 0x6d, 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb4, 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd1, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x43, 0x0a, 0x0c, - 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, - 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, - 0x42, 0x02, 0x18, 0x01, 0x52, 0x0b, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, - 0x74, 0x12, 0x34, 0x0a, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x07, 0x20, - 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, - 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x08, 0x6e, - 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x12, 0x1c, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, - 0x75, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07, 0x74, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, - 0x72, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, - 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x12, 0x1d, - 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x42, 0x5b, 0x0a, - 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, - 0x64, 0x6f, 0x6b, 0x6f, 0x64, 0x65, 0x6d, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, - 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x64, 0x6f, 0x6b, 0x6f, - 0x64, 0x65, 0x6d, 0x6f, 0xaa, 0x02, 0x13, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, - 0x79, 0x2e, 0x44, 0x6f, 0x6b, 0x6f, 0x64, 0x65, 0x6d, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x34, 0x0a, 0x08, + 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, + 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x08, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, + 0x6b, 0x73, 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x72, 0x65, 0x64, + 0x69, 0x72, 0x65, 0x63, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x66, 0x6f, 0x6c, + 0x6c, 0x6f, 0x77, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x42, 0x5b, 0x0a, 0x17, 0x63, 0x6f, + 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x64, 0x6f, 0x6b, + 0x6f, 0x64, 0x65, 0x6d, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, + 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x64, 0x6f, 0x6b, 0x6f, 0x64, 0x65, 0x6d, + 0x6f, 0xaa, 0x02, 0x13, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x44, + 0x6f, 0x6b, 0x6f, 0x64, 0x65, 0x6d, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -176,20 +146,18 @@ func file_proxy_dokodemo_config_proto_rawDescGZIP() []byte { var file_proxy_dokodemo_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_proxy_dokodemo_config_proto_goTypes = []any{ - (*Config)(nil), // 0: xray.proxy.dokodemo.Config - (*net.IPOrDomain)(nil), // 1: xray.common.net.IPOrDomain - (*net.NetworkList)(nil), // 2: xray.common.net.NetworkList - (net.Network)(0), // 3: xray.common.net.Network + (*Config)(nil), // 0: xray.proxy.dokodemo.Config + (*net.IPOrDomain)(nil), // 1: xray.common.net.IPOrDomain + (net.Network)(0), // 2: xray.common.net.Network } var file_proxy_dokodemo_config_proto_depIdxs = []int32{ 1, // 0: xray.proxy.dokodemo.Config.address:type_name -> xray.common.net.IPOrDomain - 2, // 1: xray.proxy.dokodemo.Config.network_list:type_name -> xray.common.net.NetworkList - 3, // 2: xray.proxy.dokodemo.Config.networks:type_name -> xray.common.net.Network - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 2, // 1: xray.proxy.dokodemo.Config.networks:type_name -> xray.common.net.Network + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_proxy_dokodemo_config_proto_init() } diff --git a/proxy/dokodemo/config.proto b/proxy/dokodemo/config.proto index 6b5b262b..2b60ea6f 100644 --- a/proxy/dokodemo/config.proto +++ b/proxy/dokodemo/config.proto @@ -13,13 +13,9 @@ message Config { xray.common.net.IPOrDomain address = 1; uint32 port = 2; - // List of networks that the Dokodemo accepts. - // Deprecated. Use networks. - xray.common.net.NetworkList network_list = 3 [deprecated = true]; // List of networks that the Dokodemo accepts. repeated xray.common.net.Network networks = 7; - uint32 timeout = 4 [deprecated = true]; bool follow_redirect = 5; uint32 user_level = 6; } diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 14ff7c72..3e6e0b5b 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -5,7 +5,6 @@ package dokodemo import ( "context" "sync/atomic" - "time" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" @@ -42,7 +41,7 @@ type DokodemoDoor struct { // Init initializes the DokodemoDoor instance with necessary parameters. func (d *DokodemoDoor) Init(config *Config, pm policy.Manager, sockopt *session.Sockopt) error { - if (config.NetworkList == nil || len(config.NetworkList.Network) == 0) && len(config.Networks) == 0 { + if len(config.Networks) == 0 { return errors.New("no network specified") } d.config = config @@ -56,19 +55,12 @@ func (d *DokodemoDoor) Init(config *Config, pm policy.Manager, sockopt *session. // Network implements proxy.Inbound. func (d *DokodemoDoor) Network() []net.Network { - if len(d.config.Networks) > 0 { - return d.config.Networks - } - - return d.config.NetworkList.Network + return d.config.Networks } func (d *DokodemoDoor) policy() policy.Session { config := d.config p := d.policyManager.ForLevel(config.UserLevel) - if config.Timeout > 0 && config.UserLevel == 0 { - p.Timeouts.ConnectionIdle = time.Duration(config.Timeout) * time.Second - } return p } diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index f7b307c4..56fb1a6e 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: proxy/freedom/config.proto package freedom @@ -312,14 +312,12 @@ type Config struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - DomainStrategy Config_DomainStrategy `protobuf:"varint,1,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.proxy.freedom.Config_DomainStrategy" json:"domain_strategy,omitempty"` - // Deprecated: Marked as deprecated in proxy/freedom/config.proto. - Timeout uint32 `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` - DestinationOverride *DestinationOverride `protobuf:"bytes,3,opt,name=destination_override,json=destinationOverride,proto3" json:"destination_override,omitempty"` - UserLevel uint32 `protobuf:"varint,4,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` - Fragment *Fragment `protobuf:"bytes,5,opt,name=fragment,proto3" json:"fragment,omitempty"` - ProxyProtocol uint32 `protobuf:"varint,6,opt,name=proxy_protocol,json=proxyProtocol,proto3" json:"proxy_protocol,omitempty"` - Noises []*Noise `protobuf:"bytes,7,rep,name=noises,proto3" json:"noises,omitempty"` + DomainStrategy Config_DomainStrategy `protobuf:"varint,1,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.proxy.freedom.Config_DomainStrategy" json:"domain_strategy,omitempty"` + DestinationOverride *DestinationOverride `protobuf:"bytes,3,opt,name=destination_override,json=destinationOverride,proto3" json:"destination_override,omitempty"` + UserLevel uint32 `protobuf:"varint,4,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` + Fragment *Fragment `protobuf:"bytes,5,opt,name=fragment,proto3" json:"fragment,omitempty"` + ProxyProtocol uint32 `protobuf:"varint,6,opt,name=proxy_protocol,json=proxyProtocol,proto3" json:"proxy_protocol,omitempty"` + Noises []*Noise `protobuf:"bytes,7,rep,name=noises,proto3" json:"noises,omitempty"` } func (x *Config) Reset() { @@ -361,14 +359,6 @@ func (x *Config) GetDomainStrategy() Config_DomainStrategy { return Config_AS_IS } -// Deprecated: Marked as deprecated in proxy/freedom/config.proto. -func (x *Config) GetTimeout() uint32 { - if x != nil { - return x.Timeout - } - return 0 -} - func (x *Config) GetDestinationOverride() *DestinationOverride { if x != nil { return x.DestinationOverride @@ -440,49 +430,47 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x61, 0x78, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x74, 0x72, 0x5f, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x08, 0x73, 0x74, 0x72, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x22, 0xb5, 0x04, 0x0a, 0x06, 0x43, + 0x52, 0x08, 0x73, 0x74, 0x72, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x22, 0x97, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x1c, 0x0a, 0x07, 0x74, 0x69, 0x6d, - 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07, - 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x5a, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, - 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x69, - 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x13, - 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, - 0x69, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65, - 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, 0x76, - 0x65, 0x6c, 0x12, 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, - 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x63, 0x6f, 0x6c, 0x12, 0x31, 0x0a, 0x06, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x73, 0x18, 0x07, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x52, 0x06, - 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x73, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, - 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, - 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, - 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, - 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, - 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, - 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, - 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, - 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, - 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, - 0x10, 0x0a, 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x50, 0x01, 0x5a, 0x27, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, - 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, - 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, - 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x5a, 0x0a, 0x14, 0x64, 0x65, 0x73, + 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x44, 0x65, 0x73, + 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, + 0x52, 0x13, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, + 0x72, 0x72, 0x69, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, + 0x76, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, + 0x65, 0x76, 0x65, 0x6c, 0x12, 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, + 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, + 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x31, 0x0a, 0x06, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x73, 0x18, + 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x4e, 0x6f, 0x69, 0x73, 0x65, + 0x52, 0x06, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x73, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, + 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, + 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, + 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, + 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, + 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, + 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, + 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, + 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, + 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, + 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, + 0x36, 0x34, 0x10, 0x0a, 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x50, 0x01, + 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x2f, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, + 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/freedom/config.proto b/proxy/freedom/config.proto index b3bef518..5268598b 100644 --- a/proxy/freedom/config.proto +++ b/proxy/freedom/config.proto @@ -43,7 +43,6 @@ message Config { FORCE_IP64 = 10; } DomainStrategy domain_strategy = 1; - uint32 timeout = 2 [deprecated = true]; DestinationOverride destination_override = 3; uint32 user_level = 4; Fragment fragment = 5; diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 30028bc6..79074f23 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -69,9 +69,6 @@ func (h *Handler) Init(config *Config, pm policy.Manager, d dns.Client) error { func (h *Handler) policy() policy.Session { p := h.policyManager.ForLevel(h.config.UserLevel) - if h.config.Timeout > 0 && h.config.UserLevel == 0 { - p.Timeouts.ConnectionIdle = time.Duration(h.config.Timeout) * time.Second - } return p } diff --git a/proxy/http/config.pb.go b/proxy/http/config.pb.go index 08804d9a..bbcddffb 100644 --- a/proxy/http/config.pb.go +++ b/proxy/http/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: proxy/http/config.proto package http @@ -82,8 +82,6 @@ type ServerConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Deprecated: Marked as deprecated in proxy/http/config.proto. - Timeout uint32 `protobuf:"varint,1,opt,name=timeout,proto3" json:"timeout,omitempty"` Accounts map[string]string `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` AllowTransparent bool `protobuf:"varint,3,opt,name=allow_transparent,json=allowTransparent,proto3" json:"allow_transparent,omitempty"` UserLevel uint32 `protobuf:"varint,4,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` @@ -121,14 +119,6 @@ func (*ServerConfig) Descriptor() ([]byte, []int) { return file_proxy_http_config_proto_rawDescGZIP(), []int{1} } -// Deprecated: Marked as deprecated in proxy/http/config.proto. -func (x *ServerConfig) GetTimeout() uint32 { - if x != nil { - return x.Timeout - } - return 0 -} - func (x *ServerConfig) GetAccounts() map[string]string { if x != nil { return x.Accounts @@ -274,39 +264,37 @@ var file_proxy_http_config_proto_rawDesc = []byte{ 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, - 0x22, 0xfe, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x1c, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, - 0x47, 0x0a, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x2b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x68, - 0x74, 0x74, 0x70, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x61, 0x6c, 0x6c, 0x6f, - 0x77, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x10, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, - 0x76, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, - 0x65, 0x76, 0x65, 0x6c, 0x1a, 0x3b, 0x0a, 0x0d, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, - 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, - 0x01, 0x22, 0x30, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x22, 0x7d, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x3c, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, - 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x12, 0x2f, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x68, - 0x74, 0x74, 0x70, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x68, 0x74, 0x74, - 0x70, 0xaa, 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x48, - 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0xe0, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x47, 0x0a, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x12, 0x2b, 0x0a, 0x11, 0x61, 0x6c, + 0x6c, 0x6f, 0x77, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, + 0x72, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x1a, 0x3b, 0x0a, 0x0d, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, + 0x02, 0x38, 0x01, 0x22, 0x30, 0x0a, 0x06, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x7d, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3c, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x06, 0x73, 0x65, 0x72, + 0x76, 0x65, 0x72, 0x12, 0x2f, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x06, 0x68, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x24, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, + 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x68, + 0x74, 0x74, 0x70, 0xaa, 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, + 0x2e, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/http/config.proto b/proxy/http/config.proto index 743c8551..bc939df7 100644 --- a/proxy/http/config.proto +++ b/proxy/http/config.proto @@ -15,7 +15,6 @@ message Account { // Config for HTTP proxy server. message ServerConfig { - uint32 timeout = 1 [deprecated = true]; map accounts = 2; bool allow_transparent = 3; uint32 user_level = 4; diff --git a/proxy/http/server.go b/proxy/http/server.go index 42cf4299..01216513 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -46,9 +46,6 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) { func (s *Server) policy() policy.Session { config := s.config p := s.policyManager.ForLevel(config.UserLevel) - if config.Timeout > 0 && config.UserLevel == 0 { - p.Timeouts.ConnectionIdle = time.Duration(config.Timeout) * time.Second - } return p } @@ -302,7 +299,7 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, wri if response.ContentLength >= 0 { response.Header.Set("Proxy-Connection", "keep-alive") response.Header.Set("Connection", "keep-alive") - response.Header.Set("Keep-Alive", "timeout=4") + response.Header.Set("Keep-Alive", "timeout=60") response.Close = false } else { response.Close = true diff --git a/proxy/socks/client.go b/proxy/socks/client.go index ec1a3ce1..e5af3161 100644 --- a/proxy/socks/client.go +++ b/proxy/socks/client.go @@ -14,7 +14,6 @@ import ( "github.com/xtls/xray-core/common/signal" "github.com/xtls/xray-core/common/task" "github.com/xtls/xray-core/core" - "github.com/xtls/xray-core/features/dns" "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/transport" "github.com/xtls/xray-core/transport/internet" @@ -25,8 +24,6 @@ import ( type Client struct { serverPicker protocol.ServerPicker policyManager policy.Manager - version Version - dns dns.Client } // NewClient create a new Socks5 client based on the given config. @@ -47,12 +44,8 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) { c := &Client{ serverPicker: protocol.NewRoundRobinServerPicker(serverList), policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), - version: config.Version, } - if config.Version == Version_SOCKS4 { - c.dns = v.GetFeature(dns.ClientType()).(dns.Client) - } - + return c, nil } @@ -104,30 +97,6 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter Port: destination.Port, } - switch c.version { - case Version_SOCKS4: - if request.Address.Family().IsDomain() { - ips, err := c.dns.LookupIP(request.Address.Domain(), dns.IPOption{ - IPv4Enable: true, - }) - if err != nil { - return err - } else if len(ips) == 0 { - return dns.ErrEmptyResponse - } - request.Address = net.IPAddress(ips[0]) - } - fallthrough - case Version_SOCKS4A: - request.Version = socks4Version - - if destination.Network == net.Network_UDP { - return errors.New("udp is not supported in socks4") - } else if destination.Address.Family().IsIPv6() { - return errors.New("ipv6 is not supported in socks4") - } - } - if destination.Network == net.Network_UDP { request.Command = protocol.RequestCommandUDP } diff --git a/proxy/socks/config.pb.go b/proxy/socks/config.pb.go index 0bc5fe15..e1bd9872 100644 --- a/proxy/socks/config.pb.go +++ b/proxy/socks/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: proxy/socks/config.proto package socks @@ -71,55 +71,6 @@ func (AuthType) EnumDescriptor() ([]byte, []int) { return file_proxy_socks_config_proto_rawDescGZIP(), []int{0} } -type Version int32 - -const ( - Version_SOCKS5 Version = 0 - Version_SOCKS4 Version = 1 - Version_SOCKS4A Version = 2 -) - -// Enum value maps for Version. -var ( - Version_name = map[int32]string{ - 0: "SOCKS5", - 1: "SOCKS4", - 2: "SOCKS4A", - } - Version_value = map[string]int32{ - "SOCKS5": 0, - "SOCKS4": 1, - "SOCKS4A": 2, - } -) - -func (x Version) Enum() *Version { - p := new(Version) - *p = x - return p -} - -func (x Version) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (Version) Descriptor() protoreflect.EnumDescriptor { - return file_proxy_socks_config_proto_enumTypes[1].Descriptor() -} - -func (Version) Type() protoreflect.EnumType { - return &file_proxy_socks_config_proto_enumTypes[1] -} - -func (x Version) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use Version.Descriptor instead. -func (Version) EnumDescriptor() ([]byte, []int) { - return file_proxy_socks_config_proto_rawDescGZIP(), []int{1} -} - // Account represents a Socks account. type Account struct { state protoimpl.MessageState @@ -186,9 +137,7 @@ type ServerConfig struct { Accounts map[string]string `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` Address *net.IPOrDomain `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` UdpEnabled bool `protobuf:"varint,4,opt,name=udp_enabled,json=udpEnabled,proto3" json:"udp_enabled,omitempty"` - // Deprecated: Marked as deprecated in proxy/socks/config.proto. - Timeout uint32 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` - UserLevel uint32 `protobuf:"varint,6,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` + UserLevel uint32 `protobuf:"varint,6,opt,name=user_level,json=userLevel,proto3" json:"user_level,omitempty"` } func (x *ServerConfig) Reset() { @@ -251,14 +200,6 @@ func (x *ServerConfig) GetUdpEnabled() bool { return false } -// Deprecated: Marked as deprecated in proxy/socks/config.proto. -func (x *ServerConfig) GetTimeout() uint32 { - if x != nil { - return x.Timeout - } - return 0 -} - func (x *ServerConfig) GetUserLevel() uint32 { if x != nil { return x.UserLevel @@ -273,8 +214,7 @@ type ClientConfig struct { unknownFields protoimpl.UnknownFields // Sever is a list of Socks server addresses. - Server []*protocol.ServerEndpoint `protobuf:"bytes,1,rep,name=server,proto3" json:"server,omitempty"` - Version Version `protobuf:"varint,2,opt,name=version,proto3,enum=xray.proxy.socks.Version" json:"version,omitempty"` + Server []*protocol.ServerEndpoint `protobuf:"bytes,1,rep,name=server,proto3" json:"server,omitempty"` } func (x *ClientConfig) Reset() { @@ -316,13 +256,6 @@ func (x *ClientConfig) GetServer() []*protocol.ServerEndpoint { return nil } -func (x *ClientConfig) GetVersion() Version { - if x != nil { - return x.Version - } - return Version_SOCKS5 -} - var File_proxy_socks_config_proto protoreflect.FileDescriptor var file_proxy_socks_config_proto_rawDesc = []byte{ @@ -336,7 +269,7 @@ var file_proxy_socks_config_proto_rawDesc = []byte{ 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0xe3, 0x02, 0x0a, + 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0xc5, 0x02, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x37, 0x0a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x6f, @@ -351,34 +284,26 @@ var file_proxy_socks_config_proto_rawDesc = []byte{ 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x64, 0x70, 0x5f, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x75, 0x64, - 0x70, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1c, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, - 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x42, 0x02, 0x18, 0x01, 0x52, 0x07, 0x74, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, - 0x65, 0x76, 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, - 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x1a, 0x3b, 0x0a, 0x0d, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x22, 0x81, 0x01, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x3c, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, - 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x12, 0x33, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, - 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x2a, 0x25, 0x0a, 0x08, 0x41, 0x75, 0x74, 0x68, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x4e, 0x4f, 0x5f, 0x41, 0x55, 0x54, 0x48, 0x10, 0x00, 0x12, - 0x0c, 0x0a, 0x08, 0x50, 0x41, 0x53, 0x53, 0x57, 0x4f, 0x52, 0x44, 0x10, 0x01, 0x2a, 0x2e, 0x0a, - 0x07, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x4f, 0x43, 0x4b, - 0x53, 0x35, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x4f, 0x43, 0x4b, 0x53, 0x34, 0x10, 0x01, - 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x4f, 0x43, 0x4b, 0x53, 0x34, 0x41, 0x10, 0x02, 0x42, 0x52, 0x0a, - 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, - 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x50, 0x01, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, - 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0xaa, 0x02, - 0x10, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x6f, 0x63, 0x6b, - 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, + 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, + 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x1a, 0x3b, 0x0a, 0x0d, 0x41, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x22, 0x4c, 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x3c, 0x0a, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x01, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x53, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x45, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x2a, 0x25, 0x0a, 0x08, 0x41, 0x75, 0x74, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0b, + 0x0a, 0x07, 0x4e, 0x4f, 0x5f, 0x41, 0x55, 0x54, 0x48, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x50, + 0x41, 0x53, 0x53, 0x57, 0x4f, 0x52, 0x44, 0x10, 0x01, 0x42, 0x52, 0x0a, 0x14, 0x63, 0x6f, 0x6d, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x6f, 0x63, 0x6b, + 0x73, 0x50, 0x01, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0xaa, 0x02, 0x10, 0x58, 0x72, 0x61, + 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x73, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -393,29 +318,27 @@ func file_proxy_socks_config_proto_rawDescGZIP() []byte { return file_proxy_socks_config_proto_rawDescData } -var file_proxy_socks_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_proxy_socks_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_proxy_socks_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_proxy_socks_config_proto_goTypes = []any{ (AuthType)(0), // 0: xray.proxy.socks.AuthType - (Version)(0), // 1: xray.proxy.socks.Version - (*Account)(nil), // 2: xray.proxy.socks.Account - (*ServerConfig)(nil), // 3: xray.proxy.socks.ServerConfig - (*ClientConfig)(nil), // 4: xray.proxy.socks.ClientConfig - nil, // 5: xray.proxy.socks.ServerConfig.AccountsEntry - (*net.IPOrDomain)(nil), // 6: xray.common.net.IPOrDomain - (*protocol.ServerEndpoint)(nil), // 7: xray.common.protocol.ServerEndpoint + (*Account)(nil), // 1: xray.proxy.socks.Account + (*ServerConfig)(nil), // 2: xray.proxy.socks.ServerConfig + (*ClientConfig)(nil), // 3: xray.proxy.socks.ClientConfig + nil, // 4: xray.proxy.socks.ServerConfig.AccountsEntry + (*net.IPOrDomain)(nil), // 5: xray.common.net.IPOrDomain + (*protocol.ServerEndpoint)(nil), // 6: xray.common.protocol.ServerEndpoint } var file_proxy_socks_config_proto_depIdxs = []int32{ 0, // 0: xray.proxy.socks.ServerConfig.auth_type:type_name -> xray.proxy.socks.AuthType - 5, // 1: xray.proxy.socks.ServerConfig.accounts:type_name -> xray.proxy.socks.ServerConfig.AccountsEntry - 6, // 2: xray.proxy.socks.ServerConfig.address:type_name -> xray.common.net.IPOrDomain - 7, // 3: xray.proxy.socks.ClientConfig.server:type_name -> xray.common.protocol.ServerEndpoint - 1, // 4: xray.proxy.socks.ClientConfig.version:type_name -> xray.proxy.socks.Version - 5, // [5:5] is the sub-list for method output_type - 5, // [5:5] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 4, // 1: xray.proxy.socks.ServerConfig.accounts:type_name -> xray.proxy.socks.ServerConfig.AccountsEntry + 5, // 2: xray.proxy.socks.ServerConfig.address:type_name -> xray.common.net.IPOrDomain + 6, // 3: xray.proxy.socks.ClientConfig.server:type_name -> xray.common.protocol.ServerEndpoint + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_proxy_socks_config_proto_init() } @@ -466,7 +389,7 @@ func file_proxy_socks_config_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proxy_socks_config_proto_rawDesc, - NumEnums: 2, + NumEnums: 1, NumMessages: 4, NumExtensions: 0, NumServices: 0, diff --git a/proxy/socks/config.proto b/proxy/socks/config.proto index 85dded0d..32d553d3 100644 --- a/proxy/socks/config.proto +++ b/proxy/socks/config.proto @@ -23,19 +23,12 @@ enum AuthType { PASSWORD = 1; } -enum Version { - SOCKS5 = 0; - SOCKS4 = 1; - SOCKS4A = 2; -} - // ServerConfig is the protobuf config for Socks server. message ServerConfig { AuthType auth_type = 1; map accounts = 2; xray.common.net.IPOrDomain address = 3; bool udp_enabled = 4; - uint32 timeout = 5 [deprecated = true]; uint32 user_level = 6; } @@ -43,5 +36,4 @@ message ServerConfig { message ClientConfig { // Sever is a list of Socks server addresses. repeated xray.common.protocol.ServerEndpoint server = 1; - Version version = 2; } diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 2b7bca7b..34c42ae9 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -54,12 +54,6 @@ func NewServer(ctx context.Context, config *ServerConfig) (*Server, error) { func (s *Server) policy() policy.Session { config := s.config p := s.policyManager.ForLevel(config.UserLevel) - if config.Timeout > 0 { - errors.PrintDeprecatedFeatureWarning("Socks timeout", "Policy level") - } - if config.Timeout > 0 && config.UserLevel == 0 { - p.Timeouts.ConnectionIdle = time.Duration(config.Timeout) * time.Second - } return p } diff --git a/testing/scenarios/command_test.go b/testing/scenarios/command_test.go index f535e268..b20d6f10 100644 --- a/testing/scenarios/command_test.go +++ b/testing/scenarios/command_test.go @@ -305,9 +305,7 @@ func TestCommanderAddRemoveUser(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -462,9 +460,7 @@ func TestCommanderStats(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -486,9 +482,7 @@ func TestCommanderStats(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, diff --git a/testing/scenarios/dns_test.go b/testing/scenarios/dns_test.go index 3280cbec..1c6d8277 100644 --- a/testing/scenarios/dns_test.go +++ b/testing/scenarios/dns_test.go @@ -31,18 +31,26 @@ func TestResolveIP(t *testing.T) { serverConfig := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&dns.Config{ - Hosts: map[string]*net.IPOrDomain{ - "google.com": net.NewIPOrDomain(dest.Address), + StaticHosts: []*dns.Config_HostMapping{ + { + Type: dns.DomainMatchingType_Full, + Domain: "google.com", + Ip: [][]byte{dest.Address.IP()}, + }, }, }), serial.ToTypedMessage(&router.Config{ DomainStrategy: router.Config_IpIfNonMatch, Rule: []*router.RoutingRule{ { - Cidr: []*router.CIDR{ + Geoip: []*router.GeoIP{ { - Ip: []byte{127, 0, 0, 0}, - Prefix: 8, + Cidr: []*router.CIDR{ + { + Ip: []byte{127, 0, 0, 0}, + Prefix: 8, + }, + }, }, }, TargetTag: &router.RoutingRule_Tag{ diff --git a/testing/scenarios/dokodemo_test.go b/testing/scenarios/dokodemo_test.go index 0744cac9..d6b69823 100644 --- a/testing/scenarios/dokodemo_test.go +++ b/testing/scenarios/dokodemo_test.go @@ -87,9 +87,7 @@ func TestDokodemoTCP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -185,9 +183,7 @@ func TestDokodemoUDP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_UDP}, - }, + Networks: []net.Network{net.Network_UDP}, }), }, }, diff --git a/testing/scenarios/feature_test.go b/testing/scenarios/feature_test.go index 0e2f8785..a03a64ea 100644 --- a/testing/scenarios/feature_test.go +++ b/testing/scenarios/feature_test.go @@ -55,9 +55,7 @@ func TestPassiveConnection(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -165,9 +163,7 @@ func TestProxy(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -305,9 +301,7 @@ func TestProxyOverKCP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -394,9 +388,7 @@ func TestBlackhole(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, { @@ -407,9 +399,7 @@ func TestBlackhole(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest2.Address), Port: uint32(dest2.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -430,7 +420,9 @@ func TestBlackhole(t *testing.T) { TargetTag: &router.RoutingRule_Tag{ Tag: "blocked", }, - PortRange: net.SinglePortRange(dest2.Port), + PortList: &net.PortList{ + Range: []*net.PortRange{net.SinglePortRange(dest2.Port)}, + }, }, }, }), @@ -522,9 +514,7 @@ func TestUDPConnection(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_UDP}, - }, + Networks: []net.Network{net.Network_UDP}, }), }, }, @@ -568,9 +558,7 @@ func TestDomainSniffing(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(net.LocalHostIP), Port: 443, - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, { diff --git a/testing/scenarios/policy_test.go b/testing/scenarios/policy_test.go index e45748d5..773e6bcf 100644 --- a/testing/scenarios/policy_test.go +++ b/testing/scenarios/policy_test.go @@ -112,9 +112,7 @@ func TestVMessClosing(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -218,9 +216,7 @@ func TestZeroBuffer(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, diff --git a/testing/scenarios/reverse_test.go b/testing/scenarios/reverse_test.go index a87020b6..197f6d1f 100644 --- a/testing/scenarios/reverse_test.go +++ b/testing/scenarios/reverse_test.go @@ -78,9 +78,7 @@ func TestReverseProxy(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, { @@ -145,9 +143,7 @@ func TestReverseProxy(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -261,9 +257,7 @@ func TestReverseProxyLongRunning(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, { @@ -342,9 +336,7 @@ func TestReverseProxyLongRunning(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, diff --git a/testing/scenarios/socks_test.go b/testing/scenarios/socks_test.go index 1df7f353..13e6f869 100644 --- a/testing/scenarios/socks_test.go +++ b/testing/scenarios/socks_test.go @@ -66,9 +66,7 @@ func TestSocksBridgeTCP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -147,9 +145,7 @@ func TestSocksWithHttpRequest(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -219,9 +215,7 @@ func TestSocksBridageUDP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_UDP}, - }, + Networks: []net.Network{net.Network_UDP}, }), }, }, @@ -255,9 +249,7 @@ func TestSocksBridageUDP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_UDP}, - }, + Networks: []net.Network{net.Network_UDP}, }), }, }, @@ -338,9 +330,7 @@ func TestSocksBridageUDPWithRouting(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_UDP}, - }, + Networks: []net.Network{net.Network_UDP}, }), }, }, @@ -378,9 +368,7 @@ func TestSocksBridageUDPWithRouting(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_UDP}, - }, + Networks: []net.Network{net.Network_UDP}, }), }, }, diff --git a/testing/scenarios/tls_test.go b/testing/scenarios/tls_test.go index 0b752ecf..4acb2d18 100644 --- a/testing/scenarios/tls_test.go +++ b/testing/scenarios/tls_test.go @@ -83,9 +83,7 @@ func TestSimpleTLSConnection(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -200,9 +198,7 @@ func TestAutoIssuingCertificate(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -307,9 +303,7 @@ func TestTLSOverKCP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -409,9 +403,7 @@ func TestTLSOverWebSocket(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -530,9 +522,7 @@ func TestHTTP2(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -651,9 +641,7 @@ func TestGRPC(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -769,9 +757,7 @@ func TestGRPCMultiMode(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -882,9 +868,7 @@ func TestSimpleTLSConnectionPinned(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -986,9 +970,7 @@ func TestSimpleTLSConnectionPinnedWrongCert(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -1089,9 +1071,7 @@ func TestUTLSConnectionPinned(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -1194,9 +1174,7 @@ func TestUTLSConnectionPinnedWrongCert(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, diff --git a/testing/scenarios/transport_test.go b/testing/scenarios/transport_test.go index ac9db7ac..15648ed7 100644 --- a/testing/scenarios/transport_test.go +++ b/testing/scenarios/transport_test.go @@ -78,9 +78,7 @@ func TestHTTPConnectionHeader(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, diff --git a/testing/scenarios/vless_test.go b/testing/scenarios/vless_test.go index ddb0bdb7..f4cf58f1 100644 --- a/testing/scenarios/vless_test.go +++ b/testing/scenarios/vless_test.go @@ -87,9 +87,7 @@ func TestVless(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -194,9 +192,7 @@ func TestVlessTls(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -319,9 +315,7 @@ func TestVlessXtlsVision(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -455,9 +449,7 @@ func TestVlessXtlsVisionReality(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, diff --git a/testing/scenarios/vmess_test.go b/testing/scenarios/vmess_test.go index 8b7e646f..07235b2c 100644 --- a/testing/scenarios/vmess_test.go +++ b/testing/scenarios/vmess_test.go @@ -73,9 +73,7 @@ func TestVMessDynamicPort(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, { @@ -135,9 +133,7 @@ func TestVMessDynamicPort(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -229,9 +225,7 @@ func TestVMessGCM(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -333,9 +327,7 @@ func TestVMessGCMReadv(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -440,9 +432,7 @@ func TestVMessGCMUDP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_UDP}, - }, + Networks: []net.Network{net.Network_UDP}, }), }, }, @@ -541,9 +531,7 @@ func TestVMessChacha20(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -643,9 +631,7 @@ func TestVMessNone(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -747,9 +733,7 @@ func TestVMessKCP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -875,9 +859,7 @@ func TestVMessKCPLarge(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -1004,9 +986,7 @@ func TestVMessGCMMux(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -1122,9 +1102,7 @@ func TestVMessGCMMuxUDP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, { @@ -1135,9 +1113,7 @@ func TestVMessGCMMuxUDP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(udpDest.Address), Port: uint32(udpDest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_UDP}, - }, + Networks: []net.Network{net.Network_UDP}, }), }, }, @@ -1250,9 +1226,7 @@ func TestVMessZero(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -1351,9 +1325,7 @@ func TestVMessGCMLengthAuth(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, @@ -1457,9 +1429,7 @@ func TestVMessGCMLengthAuthPlusNoTerminationSignal(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, diff --git a/testing/scenarios/wireguard_test.go b/testing/scenarios/wireguard_test.go index 6b16ca16..0609ec77 100644 --- a/testing/scenarios/wireguard_test.go +++ b/testing/scenarios/wireguard_test.go @@ -84,9 +84,7 @@ func TestWireguard(t *testing.T) { ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ Address: net.NewIPOrDomain(dest.Address), Port: uint32(dest.Port), - NetworkList: &net.NetworkList{ - Network: []net.Network{net.Network_TCP}, - }, + Networks: []net.Network{net.Network_TCP}, }), }, }, diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index c141c375..14bb90ab 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: transport/internet/tls/config.proto package tls @@ -201,11 +201,6 @@ type Config struct { MaxVersion string `protobuf:"bytes,8,opt,name=max_version,json=maxVersion,proto3" json:"max_version,omitempty"` // Specify cipher suites, except for TLS 1.3. CipherSuites string `protobuf:"bytes,9,opt,name=cipher_suites,json=cipherSuites,proto3" json:"cipher_suites,omitempty"` - // Whether the server selects its most preferred ciphersuite. - // Deprecated: crypto/tls has ignored this field. - // - // Deprecated: Marked as deprecated in transport/internet/tls/config.proto. - PreferServerCipherSuites bool `protobuf:"varint,10,opt,name=prefer_server_cipher_suites,json=preferServerCipherSuites,proto3" json:"prefer_server_cipher_suites,omitempty"` // TLS Client Hello fingerprint (uTLS). Fingerprint string `protobuf:"bytes,11,opt,name=fingerprint,proto3" json:"fingerprint,omitempty"` RejectUnknownSni bool `protobuf:"varint,12,opt,name=reject_unknown_sni,json=rejectUnknownSni,proto3" json:"reject_unknown_sni,omitempty"` @@ -317,14 +312,6 @@ func (x *Config) GetCipherSuites() string { return "" } -// Deprecated: Marked as deprecated in transport/internet/tls/config.proto. -func (x *Config) GetPreferServerCipherSuites() bool { - if x != nil { - return x.PreferServerCipherSuites - } - return false -} - func (x *Config) GetFingerprint() string { if x != nil { return x.Fingerprint @@ -391,7 +378,7 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x4e, 0x43, 0x49, 0x50, 0x48, 0x45, 0x52, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, - 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xf6, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, + 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xb3, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x49, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x63, 0x65, @@ -417,36 +404,32 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x6d, 0x61, 0x78, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x5f, 0x73, 0x75, 0x69, 0x74, 0x65, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x53, 0x75, 0x69, 0x74, 0x65, 0x73, 0x12, - 0x41, 0x0a, 0x1b, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x5f, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x5f, 0x73, 0x75, 0x69, 0x74, 0x65, 0x73, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x08, 0x42, 0x02, 0x18, 0x01, 0x52, 0x18, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, - 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x69, 0x70, 0x68, 0x65, 0x72, 0x53, 0x75, 0x69, 0x74, - 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, - 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, - 0x72, 0x69, 0x6e, 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x75, - 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x5f, 0x73, 0x6e, 0x69, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x10, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, - 0x6e, 0x69, 0x12, 0x4e, 0x0a, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, - 0x72, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x68, - 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0c, - 0x52, 0x20, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, - 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x68, 0x61, 0x32, - 0x35, 0x36, 0x12, 0x57, 0x0a, 0x29, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, - 0x72, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x75, - 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, - 0x0e, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, - 0x72, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, - 0x69, 0x63, 0x4b, 0x65, 0x79, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x24, 0x0a, 0x0e, 0x6d, - 0x61, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x0f, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, - 0x67, 0x42, 0x73, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x74, 0x6c, 0x73, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, - 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x20, 0x0a, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x66, 0x69, 0x6e, 0x67, 0x65, 0x72, 0x70, 0x72, 0x69, 0x6e, + 0x74, 0x12, 0x2c, 0x0a, 0x12, 0x72, 0x65, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x75, 0x6e, 0x6b, 0x6e, + 0x6f, 0x77, 0x6e, 0x5f, 0x73, 0x6e, 0x69, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x72, + 0x65, 0x6a, 0x65, 0x63, 0x74, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x53, 0x6e, 0x69, 0x12, + 0x4e, 0x0a, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x63, + 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, + 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0d, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x20, 0x70, + 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, + 0x63, 0x61, 0x74, 0x65, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, + 0x57, 0x0a, 0x29, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x5f, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x63, + 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, + 0x63, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x73, 0x68, 0x61, 0x32, 0x35, 0x36, 0x18, 0x0e, 0x20, 0x03, + 0x28, 0x0c, 0x52, 0x24, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x50, 0x65, 0x65, 0x72, 0x43, 0x65, + 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, + 0x65, 0x79, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x61, 0x73, 0x74, + 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, 0x42, 0x73, + 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, + 0x73, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, + 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/tls/config.proto b/transport/internet/tls/config.proto index 0bd44dee..526bc0dd 100644 --- a/transport/internet/tls/config.proto +++ b/transport/internet/tls/config.proto @@ -64,10 +64,6 @@ message Config { // Specify cipher suites, except for TLS 1.3. string cipher_suites = 9; - // Whether the server selects its most preferred ciphersuite. - // Deprecated: crypto/tls has ignored this field. - bool prefer_server_cipher_suites = 10 [deprecated = true]; - // TLS Client Hello fingerprint (uTLS). string fingerprint = 11; From bc28cad8f87a01981650d05cc92901d05562bc75 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 19 Sep 2024 01:12:29 +0000 Subject: [PATCH 547/867] v24.9.19 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index f824ecef..bae28973 100644 --- a/core/core.go +++ b/core/core.go @@ -21,7 +21,7 @@ import ( var ( Version_x byte = 24 Version_y byte = 9 - Version_z byte = 16 + Version_z byte = 19 ) var ( From 7677ac980d590413993a8c54cd246b59f4c7d72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lumi=C3=A8re=20=C3=89lev=C3=A9?= <88174309+PoneyClairDeLune@users.noreply.github.com> Date: Thu, 19 Sep 2024 09:57:43 +0100 Subject: [PATCH 548/867] Browser Dialer: Change from ES5 to ES6+ for performance (#3832) --- transport/internet/browser_dialer/dialer.html | 237 +++++++++--------- 1 file changed, 123 insertions(+), 114 deletions(-) diff --git a/transport/internet/browser_dialer/dialer.html b/transport/internet/browser_dialer/dialer.html index 3429ca9a..241d2102 100644 --- a/transport/internet/browser_dialer/dialer.html +++ b/transport/internet/browser_dialer/dialer.html @@ -5,132 +5,141 @@ From 93cff1a576975d9375a47a0d3658a30d295878d8 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:20:12 +0200 Subject: [PATCH 549/867] Xmux: Value of 0 is treated the same as no value (#3835) It turns out that some panels like to set `"xmux": {"maxConnections": 0, "maxConcurrency": 0}`, and of course that fails now. To make their job easier, let's treat `0` the same as not setting the parameter. Again, I don't like that xray's defaults are hardcoded all over the place. I would have liked a different default value for Xmux in a future version, but it actually can't be done in practice because everybody just copypastes the defaults from the docs into their own sourcecode (and sometimes changes them silently to their own idea of a good default) --- infra/conf/transport_internet.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 9605d2a2..21cffc07 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -263,7 +263,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { c.Host = c.Headers["Host"] } - if c.Xmux.MaxConnections != nil && c.Xmux.MaxConcurrency != nil { + if c.Xmux.MaxConnections != nil && c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency != nil && c.Xmux.MaxConcurrency.To > 0 { return nil, errors.New("maxConnections cannot be specified together with maxConcurrency") } @@ -779,19 +779,19 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { } type StreamConfig struct { - Network *TransportProtocol `json:"network"` - Security string `json:"security"` - TLSSettings *TLSConfig `json:"tlsSettings"` - REALITYSettings *REALITYConfig `json:"realitySettings"` - TCPSettings *TCPConfig `json:"tcpSettings"` - KCPSettings *KCPConfig `json:"kcpSettings"` - WSSettings *WebSocketConfig `json:"wsSettings"` - HTTPSettings *HTTPConfig `json:"httpSettings"` - SocketSettings *SocketConfig `json:"sockopt"` - GRPCConfig *GRPCConfig `json:"grpcSettings"` - GUNConfig *GRPCConfig `json:"gunSettings"` - HTTPUPGRADESettings *HttpUpgradeConfig `json:"httpupgradeSettings"` - SplitHTTPSettings *SplitHTTPConfig `json:"splithttpSettings"` + Network *TransportProtocol `json:"network"` + Security string `json:"security"` + TLSSettings *TLSConfig `json:"tlsSettings"` + REALITYSettings *REALITYConfig `json:"realitySettings"` + TCPSettings *TCPConfig `json:"tcpSettings"` + KCPSettings *KCPConfig `json:"kcpSettings"` + WSSettings *WebSocketConfig `json:"wsSettings"` + HTTPSettings *HTTPConfig `json:"httpSettings"` + SocketSettings *SocketConfig `json:"sockopt"` + GRPCConfig *GRPCConfig `json:"grpcSettings"` + GUNConfig *GRPCConfig `json:"gunSettings"` + HTTPUPGRADESettings *HttpUpgradeConfig `json:"httpupgradeSettings"` + SplitHTTPSettings *SplitHTTPConfig `json:"splithttpSettings"` } // Build implements Buildable. From acbf36e21b8ed2fe4f0efef17ae77a7ed1a8b3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lumi=C3=A8re=20=C3=89lev=C3=A9?= <88174309+PoneyClairDeLune@users.noreply.github.com> Date: Fri, 20 Sep 2024 08:55:54 +0100 Subject: [PATCH 550/867] SplitHTTP server: Add global CORS headers for browser dialer (#3830) --- transport/internet/splithttp/config.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 5309b180..eb32adf7 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -55,6 +55,9 @@ func (c *Config) GetRequestHeader() http.Header { } func (c *Config) WriteResponseHeader(writer http.ResponseWriter) { + // CORS headers for the browser dialer + writer.Header().Set("Access-Control-Allow-Origin", "*") + writer.Header().Set("Access-Control-Allow-Methods", "GET, POST") paddingLen := c.GetNormalizedXPaddingBytes().roll() if paddingLen > 0 { writer.Header().Set("X-Padding", strings.Repeat("0", int(paddingLen))) From d497de916f8001fe57c4aea3ffdf68fce669927f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Sep 2024 05:37:54 +0000 Subject: [PATCH 551/867] Bump google.golang.org/grpc from 1.66.2 to 1.67.0 (#3845) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.66.2 to 1.67.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.66.2...v1.67.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index cf8788c7..272e0ae7 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.8.0 golang.org/x/sys v0.25.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.66.2 + google.golang.org/grpc v1.67.0 google.golang.org/protobuf v1.34.2 gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 @@ -55,7 +55,7 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index e0dadcc9..fb73b74c 100644 --- a/go.sum +++ b/go.sum @@ -125,10 +125,10 @@ golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeu golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117 h1:1GBuWVLM/KMVUv1t1En5Gs+gFZCNd360GGb4sSxtrhU= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240604185151-ef581f913117/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0= -google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= -google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw= +google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 7086d286be67aa61942f08d2c2115655cb9fcfc1 Mon Sep 17 00:00:00 2001 From: Kobe Arthur Scofield <26771058+KobeArthurScofield@users.noreply.github.com> Date: Mon, 23 Sep 2024 23:28:19 +0800 Subject: [PATCH 552/867] Remove legacy code (#3838) * Add feature migration notice * Remove legacy code of transport processing * Clear legacy proto field * Fix missing * Unify protocolname * Test remove * Supressor * Weird code * Remove errorgen related comments --- app/commander/commander.go | 2 - app/dispatcher/default.go | 2 - app/dispatcher/dispatcher.go | 2 - app/dns/dns.go | 2 - app/dns/fakedns/fakedns.go | 2 - app/log/command/command.go | 2 - app/log/log.go | 2 - app/observatory/burst/burst.go | 2 - app/observatory/observatory.go | 2 - app/policy/policy.go | 2 - app/proxyman/command/doc.go | 2 - app/proxyman/inbound/inbound.go | 2 - app/proxyman/outbound/outbound.go | 2 - app/reverse/reverse.go | 2 - app/router/command/command.go | 2 - app/router/router.go | 2 - app/stats/command/command.go | 2 - app/stats/stats.go | 2 - common/buf/buf.go | 2 - common/common.go | 2 - common/crypto/crypto.go | 2 - common/drain/drain.go | 2 - common/errors/feature_errors.go | 9 + common/mux/mux.go | 2 - common/net/net.go | 2 - common/net/network.pb.go | 17 +- common/net/network.proto | 1 - common/platform/ctlcmd/ctlcmd.go | 2 - common/protocol/protocol.go | 2 - common/protocol/tls/cert/cert.go | 2 - common/retry/retry.go | 2 - core/core.go | 2 - features/routing/dns/context.go | 2 - features/stats/stats.go | 2 - infra/conf/conf.go | 2 - infra/conf/serial/serial.go | 2 - main/commands/all/commands.go | 2 - main/confloader/external/external.go | 2 - proxy/blackhole/blackhole.go | 2 - proxy/dokodemo/dokodemo.go | 2 - proxy/freedom/freedom.go | 2 - proxy/http/http.go | 2 - proxy/loopback/config.go | 2 - proxy/shadowsocks/shadowsocks.go | 2 - proxy/shadowsocks_2022/shadowsocks_2022.go | 2 - proxy/socks/socks.go | 2 - proxy/trojan/trojan.go | 2 - proxy/vless/encoding/encoding.go | 2 - proxy/vless/inbound/inbound.go | 2 - proxy/vless/outbound/outbound.go | 2 - proxy/vless/vless.go | 2 - proxy/vmess/encoding/encoding.go | 2 - proxy/vmess/inbound/inbound.go | 2 - proxy/vmess/outbound/outbound.go | 2 - proxy/vmess/vmess.go | 2 - proxy/wireguard/wireguard.go | 2 - testing/scenarios/feature_test.go | 6 +- testing/scenarios/tls_test.go | 24 +- testing/scenarios/transport_test.go | 8 +- testing/scenarios/vless_test.go | 24 +- testing/scenarios/vmess_test.go | 16 +- transport/internet/config.go | 33 +- transport/internet/config.pb.go | 393 +++++++----------- transport/internet/config.proto | 17 - transport/internet/grpc/config.go | 2 - transport/internet/grpc/encoding/encoding.go | 2 - transport/internet/grpc/grpc.go | 2 +- transport/internet/headers/http/http.go | 2 - transport/internet/http/config.go | 2 - transport/internet/http/http.go | 2 +- transport/internet/httpupgrade/httpupgrade.go | 15 - transport/internet/internet.go | 2 - transport/internet/kcp/config.go | 2 - transport/internet/kcp/kcp.go | 2 +- transport/internet/reality/reality.go | 2 - transport/internet/splithttp/splithttp.go | 15 - .../internet/tagged/taggedimpl/taggedimpl.go | 2 - transport/internet/tcp/config.go | 2 - transport/internet/tcp/tcp.go | 2 +- transport/internet/tls/tls.go | 2 - transport/internet/udp/udp.go | 2 - transport/internet/websocket/config.go | 2 - transport/internet/websocket/ws.go | 2 +- 83 files changed, 206 insertions(+), 512 deletions(-) diff --git a/app/commander/commander.go b/app/commander/commander.go index c433454a..9ea71e6e 100644 --- a/app/commander/commander.go +++ b/app/commander/commander.go @@ -1,7 +1,5 @@ package commander -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "net" diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index de8d1913..4eb39d75 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -1,7 +1,5 @@ package dispatcher -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "regexp" diff --git a/app/dispatcher/dispatcher.go b/app/dispatcher/dispatcher.go index 2ae48c85..909218d5 100644 --- a/app/dispatcher/dispatcher.go +++ b/app/dispatcher/dispatcher.go @@ -1,3 +1 @@ package dispatcher - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/app/dns/dns.go b/app/dns/dns.go index 24cbbb11..db59f292 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -1,8 +1,6 @@ // Package dns is an implementation of core.DNS feature. package dns -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "fmt" diff --git a/app/dns/fakedns/fakedns.go b/app/dns/fakedns/fakedns.go index 710b8a6f..05da03a5 100644 --- a/app/dns/fakedns/fakedns.go +++ b/app/dns/fakedns/fakedns.go @@ -1,3 +1 @@ package fakedns - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/app/log/command/command.go b/app/log/command/command.go index 74ce2d5b..2df8ce6d 100644 --- a/app/log/command/command.go +++ b/app/log/command/command.go @@ -1,7 +1,5 @@ package command -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" diff --git a/app/log/log.go b/app/log/log.go index 8b3d3367..90de99e2 100644 --- a/app/log/log.go +++ b/app/log/log.go @@ -1,7 +1,5 @@ package log -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "fmt" diff --git a/app/observatory/burst/burst.go b/app/observatory/burst/burst.go index 13eb0fd6..8658086a 100644 --- a/app/observatory/burst/burst.go +++ b/app/observatory/burst/burst.go @@ -5,8 +5,6 @@ import ( "time" ) -//go:generate go run github.com/v2fly/v2ray-core/v4/common/errors/errorgen - const ( rttFailed = time.Duration(math.MaxInt64 - iota) rttUntested diff --git a/app/observatory/observatory.go b/app/observatory/observatory.go index 64726885..43e79a60 100644 --- a/app/observatory/observatory.go +++ b/app/observatory/observatory.go @@ -1,3 +1 @@ package observatory - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/app/policy/policy.go b/app/policy/policy.go index cbb1d90e..60613a65 100644 --- a/app/policy/policy.go +++ b/app/policy/policy.go @@ -1,4 +1,2 @@ // Package policy is an implementation of policy.Manager feature. package policy - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/app/proxyman/command/doc.go b/app/proxyman/command/doc.go index 2aa6d95f..d47dcf0d 100644 --- a/app/proxyman/command/doc.go +++ b/app/proxyman/command/doc.go @@ -1,3 +1 @@ package command - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/app/proxyman/inbound/inbound.go b/app/proxyman/inbound/inbound.go index 1881283a..fc0c16a4 100644 --- a/app/proxyman/inbound/inbound.go +++ b/app/proxyman/inbound/inbound.go @@ -1,7 +1,5 @@ package inbound -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "sync" diff --git a/app/proxyman/outbound/outbound.go b/app/proxyman/outbound/outbound.go index f697801a..8660e6a5 100644 --- a/app/proxyman/outbound/outbound.go +++ b/app/proxyman/outbound/outbound.go @@ -1,7 +1,5 @@ package outbound -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "sort" diff --git a/app/reverse/reverse.go b/app/reverse/reverse.go index 077a89c1..f550a23f 100644 --- a/app/reverse/reverse.go +++ b/app/reverse/reverse.go @@ -1,7 +1,5 @@ package reverse -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" diff --git a/app/router/command/command.go b/app/router/command/command.go index 515e2614..baf76b8b 100644 --- a/app/router/command/command.go +++ b/app/router/command/command.go @@ -1,7 +1,5 @@ package command -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "time" diff --git a/app/router/router.go b/app/router/router.go index 2a1e2e62..2f35b3e7 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -1,7 +1,5 @@ package router -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" sync "sync" diff --git a/app/stats/command/command.go b/app/stats/command/command.go index 2c603ca2..b2cc196c 100644 --- a/app/stats/command/command.go +++ b/app/stats/command/command.go @@ -1,7 +1,5 @@ package command -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "runtime" diff --git a/app/stats/stats.go b/app/stats/stats.go index 95d5ae9c..5e9d0b59 100644 --- a/app/stats/stats.go +++ b/app/stats/stats.go @@ -1,7 +1,5 @@ package stats -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "sync" diff --git a/common/buf/buf.go b/common/buf/buf.go index dde7e22c..9f5c5cbe 100644 --- a/common/buf/buf.go +++ b/common/buf/buf.go @@ -1,4 +1,2 @@ // Package buf provides a light-weight memory allocation mechanism. package buf // import "github.com/xtls/xray-core/common/buf" - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/common/common.go b/common/common.go index cada9973..c00371be 100644 --- a/common/common.go +++ b/common/common.go @@ -12,8 +12,6 @@ import ( "github.com/xtls/xray-core/common/errors" ) -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - // ErrNoClue is for the situation that existing information is not enough to make a decision. For example, Router may return this error when there is no suitable route. var ErrNoClue = errors.New("not enough information for making a decision") diff --git a/common/crypto/crypto.go b/common/crypto/crypto.go index a7ed1a4a..4ed70634 100644 --- a/common/crypto/crypto.go +++ b/common/crypto/crypto.go @@ -1,4 +1,2 @@ // Package crypto provides common crypto libraries for Xray. package crypto // import "github.com/xtls/xray-core/common/crypto" - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/common/drain/drain.go b/common/drain/drain.go index 5a935789..5a3be246 100644 --- a/common/drain/drain.go +++ b/common/drain/drain.go @@ -2,8 +2,6 @@ package drain import "io" -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - type Drainer interface { AcknowledgeReceive(size int) Drain(reader io.Reader) error diff --git a/common/errors/feature_errors.go b/common/errors/feature_errors.go index ea9b4c03..3cacd2b9 100644 --- a/common/errors/feature_errors.go +++ b/common/errors/feature_errors.go @@ -4,6 +4,15 @@ import ( "context" ) +// PrintMigrateFeatureInfo prints a notice of the upcoming feature migration. +// Place it after the source feature related config file pharser code. +// Important note: Only use this when the target migrating feature is under construction. +// Important note: Even when the target migrating feature has finished its construction, this notice can still be used yet before announcing deprecation of the old feature. +// Do not remove this function even there is no reference to it. +func PrintMigrateFeatureInfo(sourceFeature string, targetFeature string) { + LogInfo(context.Background(), "The feature " + sourceFeature + " will be migrated to " + targetFeature + " in the future.") +} + // PrintDeprecatedFeatureWarning prints a warning for deprecated and going to be removed feature. // Do not remove this function even there is no reference to it. func PrintDeprecatedFeatureWarning(feature string, migrateFeature string) { diff --git a/common/mux/mux.go b/common/mux/mux.go index 0eaebf51..707f4622 100644 --- a/common/mux/mux.go +++ b/common/mux/mux.go @@ -1,3 +1 @@ package mux - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/common/net/net.go b/common/net/net.go index 5027617c..ce321425 100644 --- a/common/net/net.go +++ b/common/net/net.go @@ -1,4 +1,2 @@ // Package net is a drop-in replacement to Golang's net package, with some more functionalities. package net // import "github.com/xtls/xray-core/common/net" - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/common/net/network.pb.go b/common/net/network.pb.go index e2320475..b75d3564 100644 --- a/common/net/network.pb.go +++ b/common/net/network.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: common/net/network.proto package net @@ -24,25 +24,21 @@ type Network int32 const ( Network_Unknown Network = 0 - // Deprecated: Marked as deprecated in common/net/network.proto. - Network_RawTCP Network = 1 - Network_TCP Network = 2 - Network_UDP Network = 3 - Network_UNIX Network = 4 + Network_TCP Network = 2 + Network_UDP Network = 3 + Network_UNIX Network = 4 ) // Enum value maps for Network. var ( Network_name = map[int32]string{ 0: "Unknown", - 1: "RawTCP", 2: "TCP", 3: "UDP", 4: "UNIX", } Network_value = map[string]int32{ "Unknown": 0, - "RawTCP": 1, "TCP": 2, "UDP": 3, "UNIX": 4, @@ -133,10 +129,9 @@ var file_common_net_network_proto_rawDesc = []byte{ 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, - 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2a, 0x42, + 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2a, 0x32, 0x0a, 0x07, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x6e, 0x6b, - 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x06, 0x52, 0x61, 0x77, 0x54, 0x43, 0x50, - 0x10, 0x01, 0x1a, 0x02, 0x08, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x02, 0x12, + 0x6e, 0x6f, 0x77, 0x6e, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x43, 0x50, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x55, 0x4e, 0x49, 0x58, 0x10, 0x04, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, diff --git a/common/net/network.proto b/common/net/network.proto index f2487fbc..e7579a21 100644 --- a/common/net/network.proto +++ b/common/net/network.proto @@ -9,7 +9,6 @@ option java_multiple_files = true; enum Network { Unknown = 0; - RawTCP = 1 [deprecated = true]; TCP = 2; UDP = 3; UNIX = 4; diff --git a/common/platform/ctlcmd/ctlcmd.go b/common/platform/ctlcmd/ctlcmd.go index a5c21872..bc28ace1 100644 --- a/common/platform/ctlcmd/ctlcmd.go +++ b/common/platform/ctlcmd/ctlcmd.go @@ -12,8 +12,6 @@ import ( "github.com/xtls/xray-core/common/platform" ) -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - func Run(args []string, input io.Reader) (buf.MultiBuffer, error) { xctl := platform.GetToolLocation("xctl") if _, err := os.Stat(xctl); err != nil { diff --git a/common/protocol/protocol.go b/common/protocol/protocol.go index bd49ba69..28b5e51b 100644 --- a/common/protocol/protocol.go +++ b/common/protocol/protocol.go @@ -1,3 +1 @@ package protocol // import "github.com/xtls/xray-core/common/protocol" - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/common/protocol/tls/cert/cert.go b/common/protocol/tls/cert/cert.go index b8f3266e..00498579 100644 --- a/common/protocol/tls/cert/cert.go +++ b/common/protocol/tls/cert/cert.go @@ -16,8 +16,6 @@ import ( "github.com/xtls/xray-core/common/errors" ) -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - type Certificate struct { // certificate in ASN.1 DER format Certificate []byte diff --git a/common/retry/retry.go b/common/retry/retry.go index 346caf0c..02dcbfb9 100644 --- a/common/retry/retry.go +++ b/common/retry/retry.go @@ -1,7 +1,5 @@ package retry // import "github.com/xtls/xray-core/common/retry" -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "time" diff --git a/core/core.go b/core/core.go index bae28973..d0a25478 100644 --- a/core/core.go +++ b/core/core.go @@ -9,8 +9,6 @@ // connections. package core -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "fmt" "runtime" diff --git a/features/routing/dns/context.go b/features/routing/dns/context.go index 4ad7d267..d5b138d7 100644 --- a/features/routing/dns/context.go +++ b/features/routing/dns/context.go @@ -1,7 +1,5 @@ package dns -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" diff --git a/features/stats/stats.go b/features/stats/stats.go index a6c1f6be..010dd767 100644 --- a/features/stats/stats.go +++ b/features/stats/stats.go @@ -1,7 +1,5 @@ package stats -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" diff --git a/infra/conf/conf.go b/infra/conf/conf.go index 9bd3f667..8f52a955 100644 --- a/infra/conf/conf.go +++ b/infra/conf/conf.go @@ -1,3 +1 @@ package conf - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/infra/conf/serial/serial.go b/infra/conf/serial/serial.go index 3e6711ff..86baba80 100644 --- a/infra/conf/serial/serial.go +++ b/infra/conf/serial/serial.go @@ -1,3 +1 @@ package serial - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/main/commands/all/commands.go b/main/commands/all/commands.go index 99f194dc..70457a72 100644 --- a/main/commands/all/commands.go +++ b/main/commands/all/commands.go @@ -7,8 +7,6 @@ import ( "github.com/xtls/xray-core/main/commands/base" ) -// go:generate go run github.com/xtls/xray-core/common/errors/errorgen - func init() { base.RootCommand.Commands = append( base.RootCommand.Commands, diff --git a/main/confloader/external/external.go b/main/confloader/external/external.go index 1e349ebf..f1ad437b 100644 --- a/main/confloader/external/external.go +++ b/main/confloader/external/external.go @@ -1,7 +1,5 @@ package external -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "bytes" "io" diff --git a/proxy/blackhole/blackhole.go b/proxy/blackhole/blackhole.go index 23c9c291..ea3049ad 100644 --- a/proxy/blackhole/blackhole.go +++ b/proxy/blackhole/blackhole.go @@ -1,8 +1,6 @@ // Package blackhole is an outbound handler that blocks all connections. package blackhole -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "time" diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 3e6e0b5b..bbeab18f 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -1,7 +1,5 @@ package dokodemo -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "sync/atomic" diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 79074f23..f2d68eea 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -1,7 +1,5 @@ package freedom -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "crypto/rand" diff --git a/proxy/http/http.go b/proxy/http/http.go index 3c0d015f..d02cfda6 100644 --- a/proxy/http/http.go +++ b/proxy/http/http.go @@ -1,3 +1 @@ package http - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/proxy/loopback/config.go b/proxy/loopback/config.go index 95b1ae94..460b3070 100644 --- a/proxy/loopback/config.go +++ b/proxy/loopback/config.go @@ -1,3 +1 @@ package loopback - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/proxy/shadowsocks/shadowsocks.go b/proxy/shadowsocks/shadowsocks.go index 6d950db2..7bb16943 100644 --- a/proxy/shadowsocks/shadowsocks.go +++ b/proxy/shadowsocks/shadowsocks.go @@ -4,5 +4,3 @@ // // R.I.P Shadowsocks package shadowsocks - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/proxy/shadowsocks_2022/shadowsocks_2022.go b/proxy/shadowsocks_2022/shadowsocks_2022.go index 4f8d88ab..96f62c74 100644 --- a/proxy/shadowsocks_2022/shadowsocks_2022.go +++ b/proxy/shadowsocks_2022/shadowsocks_2022.go @@ -1,3 +1 @@ package shadowsocks_2022 - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/proxy/socks/socks.go b/proxy/socks/socks.go index 557609c7..2f885d39 100644 --- a/proxy/socks/socks.go +++ b/proxy/socks/socks.go @@ -1,4 +1,2 @@ // Package socks provides implements of Socks protocol 4, 4a and 5. package socks - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/proxy/trojan/trojan.go b/proxy/trojan/trojan.go index d0cf5de4..73b3154f 100644 --- a/proxy/trojan/trojan.go +++ b/proxy/trojan/trojan.go @@ -1,3 +1 @@ package trojan - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index f0699b96..8b067a96 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -1,7 +1,5 @@ package encoding -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "bytes" "context" diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index bcd8a24b..f443007d 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -1,7 +1,5 @@ package inbound -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "bytes" "context" diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index 027a241f..ed9e07dc 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -1,7 +1,5 @@ package outbound -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "bytes" "context" diff --git a/proxy/vless/vless.go b/proxy/vless/vless.go index 09827a54..ed63b641 100644 --- a/proxy/vless/vless.go +++ b/proxy/vless/vless.go @@ -5,8 +5,6 @@ // clients with 'socks' for proxying. package vless -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - const ( XRV = "xtls-rprx-vision" ) diff --git a/proxy/vmess/encoding/encoding.go b/proxy/vmess/encoding/encoding.go index 6a93dd12..45c5d207 100644 --- a/proxy/vmess/encoding/encoding.go +++ b/proxy/vmess/encoding/encoding.go @@ -5,8 +5,6 @@ import ( "github.com/xtls/xray-core/common/protocol" ) -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - const ( Version = byte(1) ) diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index 77db249f..3102414d 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -1,7 +1,5 @@ package inbound -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "io" diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index 2c339e42..27079e03 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -1,7 +1,5 @@ package outbound -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "context" "crypto/hmac" diff --git a/proxy/vmess/vmess.go b/proxy/vmess/vmess.go index 836b1889..dd86f516 100644 --- a/proxy/vmess/vmess.go +++ b/proxy/vmess/vmess.go @@ -4,5 +4,3 @@ // together with 'freedom' to talk to final destination, while VMess outbound is usually used on // clients with 'socks' for proxying. package vmess - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/proxy/wireguard/wireguard.go b/proxy/wireguard/wireguard.go index 16a73ca2..0d75ee00 100644 --- a/proxy/wireguard/wireguard.go +++ b/proxy/wireguard/wireguard.go @@ -12,8 +12,6 @@ import ( "golang.zx2c4.com/wireguard/device" ) -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - var wgLogger = &device.Logger{ Verbosef: func(format string, args ...any) { log.Record(&log.GeneralMessage{ diff --git a/testing/scenarios/feature_test.go b/testing/scenarios/feature_test.go index a03a64ea..5dd08ec4 100644 --- a/testing/scenarios/feature_test.go +++ b/testing/scenarios/feature_test.go @@ -237,7 +237,7 @@ func TestProxyOverKCP(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_MKCP, + ProtocolName: "mkcp", }, }), ProxySettings: serial.ToTypedMessage(&inbound.Config{ @@ -283,7 +283,7 @@ func TestProxyOverKCP(t *testing.T) { ProxySettings: serial.ToTypedMessage(&freedom.Config{}), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_MKCP, + ProtocolName: "mkcp", }, }), }, @@ -327,7 +327,7 @@ func TestProxyOverKCP(t *testing.T) { Tag: "proxy", }, StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_MKCP, + ProtocolName: "mkcp", }, }), }, diff --git a/testing/scenarios/tls_test.go b/testing/scenarios/tls_test.go index 4acb2d18..f1955877 100644 --- a/testing/scenarios/tls_test.go +++ b/testing/scenarios/tls_test.go @@ -265,7 +265,7 @@ func TestTLSOverKCP(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_MKCP, + ProtocolName: "mkcp", SecurityType: serial.GetMessageType(&tls.Config{}), SecuritySettings: []*serial.TypedMessage{ serial.ToTypedMessage(&tls.Config{ @@ -326,7 +326,7 @@ func TestTLSOverKCP(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_MKCP, + ProtocolName: "mkcp", SecurityType: serial.GetMessageType(&tls.Config{}), SecuritySettings: []*serial.TypedMessage{ serial.ToTypedMessage(&tls.Config{ @@ -365,7 +365,7 @@ func TestTLSOverWebSocket(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_WebSocket, + ProtocolName: "websocket", SecurityType: serial.GetMessageType(&tls.Config{}), SecuritySettings: []*serial.TypedMessage{ serial.ToTypedMessage(&tls.Config{ @@ -426,11 +426,11 @@ func TestTLSOverWebSocket(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_WebSocket, + ProtocolName: "websocket", TransportSettings: []*internet.TransportConfig{ { - Protocol: internet.TransportProtocol_WebSocket, - Settings: serial.ToTypedMessage(&websocket.Config{}), + ProtocolName: "websocket", + Settings: serial.ToTypedMessage(&websocket.Config{}), }, }, SecurityType: serial.GetMessageType(&tls.Config{}), @@ -475,11 +475,11 @@ func TestHTTP2(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_HTTP, + ProtocolName: "http", TransportSettings: []*internet.TransportConfig{ { - Protocol: internet.TransportProtocol_HTTP, - Settings: serial.ToTypedMessage(&http.Config{ + ProtocolName: "http", + Settings: serial.ToTypedMessage(&http.Config{ Host: []string{"example.com"}, Path: "/testpath", }), @@ -545,11 +545,11 @@ func TestHTTP2(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_HTTP, + ProtocolName: "http", TransportSettings: []*internet.TransportConfig{ { - Protocol: internet.TransportProtocol_HTTP, - Settings: serial.ToTypedMessage(&http.Config{ + ProtocolName: "http", + Settings: serial.ToTypedMessage(&http.Config{ Host: []string{"example.com"}, Path: "/testpath", }), diff --git a/testing/scenarios/transport_test.go b/testing/scenarios/transport_test.go index 15648ed7..e6ece892 100644 --- a/testing/scenarios/transport_test.go +++ b/testing/scenarios/transport_test.go @@ -41,8 +41,8 @@ func TestHTTPConnectionHeader(t *testing.T) { StreamSettings: &internet.StreamConfig{ TransportSettings: []*internet.TransportConfig{ { - Protocol: internet.TransportProtocol_TCP, - Settings: serial.ToTypedMessage(&tcptransport.Config{ + ProtocolName: "tcp", + Settings: serial.ToTypedMessage(&tcptransport.Config{ HeaderSettings: serial.ToTypedMessage(&http.Config{}), }), }, @@ -103,8 +103,8 @@ func TestHTTPConnectionHeader(t *testing.T) { StreamSettings: &internet.StreamConfig{ TransportSettings: []*internet.TransportConfig{ { - Protocol: internet.TransportProtocol_TCP, - Settings: serial.ToTypedMessage(&tcptransport.Config{ + ProtocolName: "tcp", + Settings: serial.ToTypedMessage(&tcptransport.Config{ HeaderSettings: serial.ToTypedMessage(&http.Config{}), }), }, diff --git a/testing/scenarios/vless_test.go b/testing/scenarios/vless_test.go index f4cf58f1..87952794 100644 --- a/testing/scenarios/vless_test.go +++ b/testing/scenarios/vless_test.go @@ -148,7 +148,7 @@ func TestVlessTls(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_TCP, + ProtocolName: "tcp", SecurityType: serial.GetMessageType(&tls.Config{}), SecuritySettings: []*serial.TypedMessage{ serial.ToTypedMessage(&tls.Config{ @@ -215,11 +215,11 @@ func TestVlessTls(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_TCP, + ProtocolName: "tcp", TransportSettings: []*internet.TransportConfig{ { - Protocol: internet.TransportProtocol_TCP, - Settings: serial.ToTypedMessage(&transtcp.Config{}), + ProtocolName: "tcp", + Settings: serial.ToTypedMessage(&transtcp.Config{}), }, }, SecurityType: serial.GetMessageType(&tls.Config{}), @@ -270,7 +270,7 @@ func TestVlessXtlsVision(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_TCP, + ProtocolName: "tcp", SecurityType: serial.GetMessageType(&tls.Config{}), SecuritySettings: []*serial.TypedMessage{ serial.ToTypedMessage(&tls.Config{ @@ -339,11 +339,11 @@ func TestVlessXtlsVision(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_TCP, + ProtocolName: "tcp", TransportSettings: []*internet.TransportConfig{ { - Protocol: internet.TransportProtocol_TCP, - Settings: serial.ToTypedMessage(&transtcp.Config{}), + ProtocolName: "tcp", + Settings: serial.ToTypedMessage(&transtcp.Config{}), }, }, SecurityType: serial.GetMessageType(&tls.Config{}), @@ -399,7 +399,7 @@ func TestVlessXtlsVisionReality(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_TCP, + ProtocolName: "tcp", SecurityType: serial.GetMessageType(&reality.Config{}), SecuritySettings: []*serial.TypedMessage{ serial.ToTypedMessage(&reality.Config{ @@ -473,11 +473,11 @@ func TestVlessXtlsVisionReality(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_TCP, + ProtocolName: "tcp", TransportSettings: []*internet.TransportConfig{ { - Protocol: internet.TransportProtocol_TCP, - Settings: serial.ToTypedMessage(&transtcp.Config{}), + ProtocolName: "tcp", + Settings: serial.ToTypedMessage(&transtcp.Config{}), }, }, SecurityType: serial.GetMessageType(&reality.Config{}), diff --git a/testing/scenarios/vmess_test.go b/testing/scenarios/vmess_test.go index 07235b2c..092d25a3 100644 --- a/testing/scenarios/vmess_test.go +++ b/testing/scenarios/vmess_test.go @@ -695,7 +695,7 @@ func TestVMessKCP(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_MKCP, + ProtocolName: "mkcp", }, }), ProxySettings: serial.ToTypedMessage(&inbound.Config{ @@ -759,7 +759,7 @@ func TestVMessKCP(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_MKCP, + ProtocolName: "mkcp", }, }), }, @@ -802,11 +802,11 @@ func TestVMessKCPLarge(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_MKCP, + ProtocolName: "mkcp", TransportSettings: []*internet.TransportConfig{ { - Protocol: internet.TransportProtocol_MKCP, - Settings: serial.ToTypedMessage(&kcp.Config{ + ProtocolName: "mkcp", + Settings: serial.ToTypedMessage(&kcp.Config{ ReadBuffer: &kcp.ReadBuffer{ Size: 512 * 1024, }, @@ -885,11 +885,11 @@ func TestVMessKCPLarge(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - Protocol: internet.TransportProtocol_MKCP, + ProtocolName: "mkcp", TransportSettings: []*internet.TransportConfig{ { - Protocol: internet.TransportProtocol_MKCP, - Settings: serial.ToTypedMessage(&kcp.Config{ + ProtocolName: "mkcp", + Settings: serial.ToTypedMessage(&kcp.Config{ ReadBuffer: &kcp.ReadBuffer{ Size: 512 * 1024, }, diff --git a/transport/internet/config.go b/transport/internet/config.go index 96cf53b7..8608b872 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -28,25 +28,6 @@ var strategy = [][]byte{ const unknownProtocol = "unknown" -func transportProtocolToString(protocol TransportProtocol) string { - switch protocol { - case TransportProtocol_TCP: - return "tcp" - case TransportProtocol_UDP: - return "udp" - case TransportProtocol_HTTP: - return "http" - case TransportProtocol_MKCP: - return "mkcp" - case TransportProtocol_WebSocket: - return "websocket" - case TransportProtocol_HTTPUpgrade: - return "httpupgrade" - default: - return unknownProtocol - } -} - func RegisterProtocolConfigCreator(name string, creator ConfigCreator) error { if _, found := globalTransportConfigCreatorCache[name]; found { return errors.New("protocol ", name, " is already registered").AtError() @@ -70,23 +51,15 @@ func (c *TransportConfig) GetTypedSettings() (interface{}, error) { } func (c *TransportConfig) GetUnifiedProtocolName() string { - if len(c.ProtocolName) > 0 { - return c.ProtocolName - } - - return transportProtocolToString(c.Protocol) + return c.ProtocolName } func (c *StreamConfig) GetEffectiveProtocol() string { - if c == nil { + if c == nil || len(c.ProtocolName) == 0 { return "tcp" } - if len(c.ProtocolName) > 0 { - return c.ProtocolName - } - - return transportProtocolToString(c.Protocol) + return c.ProtocolName } func (c *StreamConfig) GetEffectiveTransportSettings() (interface{}, error) { diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 2cbe7fac..c58781fa 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc v5.28.0 // source: transport/internet/config.proto package internet @@ -21,67 +21,6 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -type TransportProtocol int32 - -const ( - TransportProtocol_TCP TransportProtocol = 0 - TransportProtocol_UDP TransportProtocol = 1 - TransportProtocol_MKCP TransportProtocol = 2 - TransportProtocol_WebSocket TransportProtocol = 3 - TransportProtocol_HTTP TransportProtocol = 4 - TransportProtocol_HTTPUpgrade TransportProtocol = 6 - TransportProtocol_SplitHTTP TransportProtocol = 7 -) - -// Enum value maps for TransportProtocol. -var ( - TransportProtocol_name = map[int32]string{ - 0: "TCP", - 1: "UDP", - 2: "MKCP", - 3: "WebSocket", - 4: "HTTP", - 6: "HTTPUpgrade", - 7: "SplitHTTP", - } - TransportProtocol_value = map[string]int32{ - "TCP": 0, - "UDP": 1, - "MKCP": 2, - "WebSocket": 3, - "HTTP": 4, - "HTTPUpgrade": 6, - "SplitHTTP": 7, - } -) - -func (x TransportProtocol) Enum() *TransportProtocol { - p := new(TransportProtocol) - *p = x - return p -} - -func (x TransportProtocol) String() string { - return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) -} - -func (TransportProtocol) Descriptor() protoreflect.EnumDescriptor { - return file_transport_internet_config_proto_enumTypes[0].Descriptor() -} - -func (TransportProtocol) Type() protoreflect.EnumType { - return &file_transport_internet_config_proto_enumTypes[0] -} - -func (x TransportProtocol) Number() protoreflect.EnumNumber { - return protoreflect.EnumNumber(x) -} - -// Deprecated: Use TransportProtocol.Descriptor instead. -func (TransportProtocol) EnumDescriptor() ([]byte, []int) { - return file_transport_internet_config_proto_rawDescGZIP(), []int{0} -} - type DomainStrategy int32 const ( @@ -139,11 +78,11 @@ func (x DomainStrategy) String() string { } func (DomainStrategy) Descriptor() protoreflect.EnumDescriptor { - return file_transport_internet_config_proto_enumTypes[1].Descriptor() + return file_transport_internet_config_proto_enumTypes[0].Descriptor() } func (DomainStrategy) Type() protoreflect.EnumType { - return &file_transport_internet_config_proto_enumTypes[1] + return &file_transport_internet_config_proto_enumTypes[0] } func (x DomainStrategy) Number() protoreflect.EnumNumber { @@ -152,7 +91,7 @@ func (x DomainStrategy) Number() protoreflect.EnumNumber { // Deprecated: Use DomainStrategy.Descriptor instead. func (DomainStrategy) EnumDescriptor() ([]byte, []int) { - return file_transport_internet_config_proto_rawDescGZIP(), []int{1} + return file_transport_internet_config_proto_rawDescGZIP(), []int{0} } type SocketConfig_TProxyMode int32 @@ -191,11 +130,11 @@ func (x SocketConfig_TProxyMode) String() string { } func (SocketConfig_TProxyMode) Descriptor() protoreflect.EnumDescriptor { - return file_transport_internet_config_proto_enumTypes[2].Descriptor() + return file_transport_internet_config_proto_enumTypes[1].Descriptor() } func (SocketConfig_TProxyMode) Type() protoreflect.EnumType { - return &file_transport_internet_config_proto_enumTypes[2] + return &file_transport_internet_config_proto_enumTypes[1] } func (x SocketConfig_TProxyMode) Number() protoreflect.EnumNumber { @@ -212,11 +151,6 @@ type TransportConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Type of network that this settings supports. - // Deprecated. Use the string form below. - // - // Deprecated: Marked as deprecated in transport/internet/config.proto. - Protocol TransportProtocol `protobuf:"varint,1,opt,name=protocol,proto3,enum=xray.transport.internet.TransportProtocol" json:"protocol,omitempty"` // Type of network that this settings supports. ProtocolName string `protobuf:"bytes,3,opt,name=protocol_name,json=protocolName,proto3" json:"protocol_name,omitempty"` // Specific settings. Must be of the transports. @@ -255,14 +189,6 @@ func (*TransportConfig) Descriptor() ([]byte, []int) { return file_transport_internet_config_proto_rawDescGZIP(), []int{0} } -// Deprecated: Marked as deprecated in transport/internet/config.proto. -func (x *TransportConfig) GetProtocol() TransportProtocol { - if x != nil { - return x.Protocol - } - return TransportProtocol_TCP -} - func (x *TransportConfig) GetProtocolName() string { if x != nil { return x.ProtocolName @@ -282,10 +208,6 @@ type StreamConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Effective network. Deprecated. Use the string form below. - // - // Deprecated: Marked as deprecated in transport/internet/config.proto. - Protocol TransportProtocol `protobuf:"varint,1,opt,name=protocol,proto3,enum=xray.transport.internet.TransportProtocol" json:"protocol,omitempty"` // Effective network. ProtocolName string `protobuf:"bytes,5,opt,name=protocol_name,json=protocolName,proto3" json:"protocol_name,omitempty"` TransportSettings []*TransportConfig `protobuf:"bytes,2,rep,name=transport_settings,json=transportSettings,proto3" json:"transport_settings,omitempty"` @@ -328,14 +250,6 @@ func (*StreamConfig) Descriptor() ([]byte, []int) { return file_transport_internet_config_proto_rawDescGZIP(), []int{1} } -// Deprecated: Marked as deprecated in transport/internet/config.proto. -func (x *StreamConfig) GetProtocol() TransportProtocol { - if x != nil { - return x.Protocol - } - return TransportProtocol_TCP -} - func (x *StreamConfig) GetProtocolName() string { if x != nil { return x.ProtocolName @@ -710,139 +624,123 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x6f, 0x12, 0x17, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x1a, 0x21, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc0, 0x01, - 0x0a, 0x0f, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x4a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x2a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x42, - 0x02, 0x18, 0x01, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x23, 0x0a, - 0x0d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x4e, 0x61, - 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, - 0x22, 0x9c, 0x03, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x4a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x2a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x42, - 0x02, 0x18, 0x01, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x23, 0x0a, - 0x0d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x4e, 0x61, - 0x6d, 0x65, 0x12, 0x57, 0x0a, 0x12, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x5f, - 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x73, - 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x0c, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x4d, 0x0a, 0x11, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x73, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, - 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x10, 0x73, - 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, - 0x4e, 0x0a, 0x0f, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, - 0x0e, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, - 0x51, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, - 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, - 0x12, 0x30, 0x0a, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, - 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, - 0x78, 0x79, 0x22, 0x61, 0x0a, 0x0d, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, - 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x70, 0x74, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x9f, 0x07, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, - 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, - 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x2e, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x06, - 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x41, 0x0a, 0x1d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, - 0x65, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x65, 0x73, 0x74, 0x5f, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, - 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, - 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x69, 0x6e, - 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, - 0x0b, 0x62, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, - 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, - 0x08, 0x62, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, - 0x65, 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, - 0x6f, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, - 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x50, 0x0a, - 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, - 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, + 0x0f, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, + 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, + 0x6e, 0x67, 0x73, 0x22, 0xd0, 0x02, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x57, 0x0a, 0x12, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, + 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, + 0x67, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x74, + 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x65, 0x63, 0x75, 0x72, + 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4d, 0x0a, 0x11, 0x73, 0x65, 0x63, 0x75, 0x72, + 0x69, 0x74, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, + 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x52, 0x10, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x4e, 0x0a, 0x0f, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, + 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x51, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x30, 0x0a, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, + 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x22, 0x61, 0x0a, 0x0d, 0x43, 0x75, 0x73, + 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, + 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, + 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, + 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x9f, 0x07, 0x0a, + 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, + 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, + 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, + 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, + 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x50, 0x72, 0x6f, 0x78, + 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x06, 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x41, 0x0a, + 0x1d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, + 0x6c, 0x5f, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x69, + 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x72, 0x74, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x62, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x72, 0x74, + 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, + 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x50, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, + 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, + 0x61, 0x6c, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x35, 0x0a, 0x17, 0x74, 0x63, 0x70, + 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x76, 0x61, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x14, 0x74, 0x63, 0x70, 0x4b, + 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, + 0x12, 0x2d, 0x0a, 0x13, 0x74, 0x63, 0x70, 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, + 0x76, 0x65, 0x5f, 0x69, 0x64, 0x6c, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, + 0x63, 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x64, 0x6c, 0x65, 0x12, + 0x25, 0x0a, 0x0e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x63, 0x70, 0x43, 0x6f, 0x6e, 0x67, + 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, + 0x61, 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x66, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0e, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x12, 0x28, 0x0a, 0x10, + 0x74, 0x63, 0x70, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x63, 0x6c, 0x61, 0x6d, 0x70, + 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x57, 0x69, 0x6e, 0x64, 0x6f, + 0x77, 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x75, 0x73, + 0x65, 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, + 0x12, 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x65, 0x67, 0x18, + 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x63, 0x70, 0x4d, 0x61, 0x78, 0x53, 0x65, 0x67, + 0x12, 0x20, 0x0a, 0x0c, 0x74, 0x63, 0x70, 0x5f, 0x6e, 0x6f, 0x5f, 0x64, 0x65, 0x6c, 0x61, 0x79, + 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x74, 0x63, 0x70, 0x4e, 0x6f, 0x44, 0x65, 0x6c, + 0x61, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x70, 0x74, 0x63, 0x70, 0x18, + 0x13, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74, 0x63, 0x70, 0x4d, 0x70, 0x74, 0x63, 0x70, 0x12, + 0x4c, 0x0a, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, + 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, - 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, - 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, 0x50, 0x72, 0x6f, - 0x78, 0x79, 0x12, 0x35, 0x0a, 0x17, 0x74, 0x63, 0x70, 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, - 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x0a, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x14, 0x74, 0x63, 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, - 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x2d, 0x0a, 0x13, 0x74, 0x63, 0x70, - 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x64, 0x6c, 0x65, - 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, 0x63, 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, - 0x6c, 0x69, 0x76, 0x65, 0x49, 0x64, 0x6c, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x63, 0x70, 0x5f, - 0x63, 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0d, 0x74, 0x63, 0x70, 0x43, 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, - 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x76, - 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x77, 0x69, 0x6e, - 0x64, 0x6f, 0x77, 0x5f, 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0e, 0x74, 0x63, 0x70, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x12, - 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, - 0x6f, 0x75, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, - 0x65, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, - 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x65, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, - 0x74, 0x63, 0x70, 0x4d, 0x61, 0x78, 0x53, 0x65, 0x67, 0x12, 0x20, 0x0a, 0x0c, 0x74, 0x63, 0x70, - 0x5f, 0x6e, 0x6f, 0x5f, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x0a, 0x74, 0x63, 0x70, 0x4e, 0x6f, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x74, - 0x63, 0x70, 0x5f, 0x6d, 0x70, 0x74, 0x63, 0x70, 0x18, 0x13, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, - 0x74, 0x63, 0x70, 0x4d, 0x70, 0x74, 0x63, 0x70, 0x12, 0x4c, 0x0a, 0x0d, 0x63, 0x75, 0x73, 0x74, - 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, - 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x52, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, - 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, - 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, - 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, - 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x68, 0x0a, 0x11, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x07, 0x0a, 0x03, - 0x54, 0x43, 0x50, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x55, 0x44, 0x50, 0x10, 0x01, 0x12, 0x08, - 0x0a, 0x04, 0x4d, 0x4b, 0x43, 0x50, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x57, 0x65, 0x62, 0x53, - 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x54, 0x54, 0x50, 0x10, - 0x04, 0x12, 0x0f, 0x0a, 0x0b, 0x48, 0x54, 0x54, 0x50, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, - 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x54, 0x54, 0x50, 0x10, - 0x07, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, - 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, - 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, - 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, - 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, - 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, - 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, - 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, - 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, - 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, 0x67, 0x0a, - 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, - 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, - 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x52, 0x0d, + 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x22, 0x2f, 0x0a, + 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, + 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, + 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0xa9, + 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, + 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, + 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, + 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, + 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, + 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, + 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, + 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, + 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, + 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, + 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, + 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, + 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, + 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -857,34 +755,31 @@ func file_transport_internet_config_proto_rawDescGZIP() []byte { return file_transport_internet_config_proto_rawDescData } -var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 3) +var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_transport_internet_config_proto_goTypes = []any{ - (TransportProtocol)(0), // 0: xray.transport.internet.TransportProtocol - (DomainStrategy)(0), // 1: xray.transport.internet.DomainStrategy - (SocketConfig_TProxyMode)(0), // 2: xray.transport.internet.SocketConfig.TProxyMode - (*TransportConfig)(nil), // 3: xray.transport.internet.TransportConfig - (*StreamConfig)(nil), // 4: xray.transport.internet.StreamConfig - (*ProxyConfig)(nil), // 5: xray.transport.internet.ProxyConfig - (*CustomSockopt)(nil), // 6: xray.transport.internet.CustomSockopt - (*SocketConfig)(nil), // 7: xray.transport.internet.SocketConfig - (*serial.TypedMessage)(nil), // 8: xray.common.serial.TypedMessage + (DomainStrategy)(0), // 0: xray.transport.internet.DomainStrategy + (SocketConfig_TProxyMode)(0), // 1: xray.transport.internet.SocketConfig.TProxyMode + (*TransportConfig)(nil), // 2: xray.transport.internet.TransportConfig + (*StreamConfig)(nil), // 3: xray.transport.internet.StreamConfig + (*ProxyConfig)(nil), // 4: xray.transport.internet.ProxyConfig + (*CustomSockopt)(nil), // 5: xray.transport.internet.CustomSockopt + (*SocketConfig)(nil), // 6: xray.transport.internet.SocketConfig + (*serial.TypedMessage)(nil), // 7: xray.common.serial.TypedMessage } var file_transport_internet_config_proto_depIdxs = []int32{ - 0, // 0: xray.transport.internet.TransportConfig.protocol:type_name -> xray.transport.internet.TransportProtocol - 8, // 1: xray.transport.internet.TransportConfig.settings:type_name -> xray.common.serial.TypedMessage - 0, // 2: xray.transport.internet.StreamConfig.protocol:type_name -> xray.transport.internet.TransportProtocol - 3, // 3: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig - 8, // 4: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage - 7, // 5: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig - 2, // 6: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode - 1, // 7: xray.transport.internet.SocketConfig.domain_strategy:type_name -> xray.transport.internet.DomainStrategy - 6, // 8: xray.transport.internet.SocketConfig.customSockopt:type_name -> xray.transport.internet.CustomSockopt - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 7, // 0: xray.transport.internet.TransportConfig.settings:type_name -> xray.common.serial.TypedMessage + 2, // 1: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig + 7, // 2: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage + 6, // 3: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig + 1, // 4: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode + 0, // 5: xray.transport.internet.SocketConfig.domain_strategy:type_name -> xray.transport.internet.DomainStrategy + 5, // 6: xray.transport.internet.SocketConfig.customSockopt:type_name -> xray.transport.internet.CustomSockopt + 7, // [7:7] is the sub-list for method output_type + 7, // [7:7] is the sub-list for method input_type + 7, // [7:7] is the sub-list for extension type_name + 7, // [7:7] is the sub-list for extension extendee + 0, // [0:7] is the sub-list for field type_name } func init() { file_transport_internet_config_proto_init() } @@ -959,7 +854,7 @@ func file_transport_internet_config_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_transport_internet_config_proto_rawDesc, - NumEnums: 3, + NumEnums: 2, NumMessages: 5, NumExtensions: 0, NumServices: 0, diff --git a/transport/internet/config.proto b/transport/internet/config.proto index cab6162c..b892deb3 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -8,16 +8,6 @@ option java_multiple_files = true; import "common/serial/typed_message.proto"; -enum TransportProtocol { - TCP = 0; - UDP = 1; - MKCP = 2; - WebSocket = 3; - HTTP = 4; - HTTPUpgrade = 6; - SplitHTTP = 7; -} - enum DomainStrategy { AS_IS = 0; USE_IP = 1; @@ -33,10 +23,6 @@ enum DomainStrategy { } message TransportConfig { - // Type of network that this settings supports. - // Deprecated. Use the string form below. - TransportProtocol protocol = 1 [ deprecated = true ]; - // Type of network that this settings supports. string protocol_name = 3; @@ -45,9 +31,6 @@ message TransportConfig { } message StreamConfig { - // Effective network. Deprecated. Use the string form below. - TransportProtocol protocol = 1 [ deprecated = true ]; - // Effective network. string protocol_name = 5; diff --git a/transport/internet/grpc/config.go b/transport/internet/grpc/config.go index aab1178e..c9903018 100644 --- a/transport/internet/grpc/config.go +++ b/transport/internet/grpc/config.go @@ -8,8 +8,6 @@ import ( "github.com/xtls/xray-core/transport/internet" ) -const protocolName = "grpc" - func init() { common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { return new(Config) diff --git a/transport/internet/grpc/encoding/encoding.go b/transport/internet/grpc/encoding/encoding.go index f8e3e368..523b90ce 100644 --- a/transport/internet/grpc/encoding/encoding.go +++ b/transport/internet/grpc/encoding/encoding.go @@ -1,3 +1 @@ package encoding - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/transport/internet/grpc/grpc.go b/transport/internet/grpc/grpc.go index 6caf155b..bcf78b0a 100644 --- a/transport/internet/grpc/grpc.go +++ b/transport/internet/grpc/grpc.go @@ -1,3 +1,3 @@ package grpc -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen +const protocolName = "grpc" diff --git a/transport/internet/headers/http/http.go b/transport/internet/headers/http/http.go index 01168808..3c1ff06c 100644 --- a/transport/internet/headers/http/http.go +++ b/transport/internet/headers/http/http.go @@ -1,7 +1,5 @@ package http -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - import ( "bufio" "bytes" diff --git a/transport/internet/http/config.go b/transport/internet/http/config.go index 2697f989..989ed106 100644 --- a/transport/internet/http/config.go +++ b/transport/internet/http/config.go @@ -6,8 +6,6 @@ import ( "github.com/xtls/xray-core/transport/internet" ) -const protocolName = "http" - func (c *Config) getHosts() []string { if len(c.Host) == 0 { return []string{"www.example.com"} diff --git a/transport/internet/http/http.go b/transport/internet/http/http.go index 3c0d015f..a6343422 100644 --- a/transport/internet/http/http.go +++ b/transport/internet/http/http.go @@ -1,3 +1,3 @@ package http -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen +const protocolName = "http" diff --git a/transport/internet/httpupgrade/httpupgrade.go b/transport/internet/httpupgrade/httpupgrade.go index e949f871..0a902398 100644 --- a/transport/internet/httpupgrade/httpupgrade.go +++ b/transport/internet/httpupgrade/httpupgrade.go @@ -1,18 +1,3 @@ package httpupgrade -import ( - "context" - - "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/common/errors" -) - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - const protocolName = "httpupgrade" - -func init() { - common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { - return nil, errors.New("httpupgrade is a transport protocol.") - })) -} diff --git a/transport/internet/internet.go b/transport/internet/internet.go index 70fab761..19529e63 100644 --- a/transport/internet/internet.go +++ b/transport/internet/internet.go @@ -5,8 +5,6 @@ import ( "strings" ) -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - func IsValidHTTPHost(request string, config string) bool { r := strings.ToLower(request) c := strings.ToLower(config) diff --git a/transport/internet/kcp/config.go b/transport/internet/kcp/config.go index 808b1d50..a0dfd51f 100644 --- a/transport/internet/kcp/config.go +++ b/transport/internet/kcp/config.go @@ -7,8 +7,6 @@ import ( "github.com/xtls/xray-core/transport/internet" ) -const protocolName = "mkcp" - // GetMTUValue returns the value of MTU settings. func (c *Config) GetMTUValue() uint32 { if c == nil || c.Mtu == nil { diff --git a/transport/internet/kcp/kcp.go b/transport/internet/kcp/kcp.go index 1a486faa..31c0633c 100644 --- a/transport/internet/kcp/kcp.go +++ b/transport/internet/kcp/kcp.go @@ -6,4 +6,4 @@ // xtaci@github for translating to Golang package kcp -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen +const protocolName = "mkcp" diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 44402f31..c2f7859c 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -36,8 +36,6 @@ import ( "golang.org/x/net/http2" ) -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - //go:linkname aesgcmPreferred github.com/refraction-networking/utls.aesgcmPreferred func aesgcmPreferred(ciphers []uint16) bool diff --git a/transport/internet/splithttp/splithttp.go b/transport/internet/splithttp/splithttp.go index 6e458616..2076e933 100644 --- a/transport/internet/splithttp/splithttp.go +++ b/transport/internet/splithttp/splithttp.go @@ -1,18 +1,3 @@ package splithttp -import ( - "context" - - "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/common/errors" -) - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - const protocolName = "splithttp" - -func init() { - common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { - return nil, errors.New("splithttp is a transport protocol.") - })) -} diff --git a/transport/internet/tagged/taggedimpl/taggedimpl.go b/transport/internet/tagged/taggedimpl/taggedimpl.go index ef2f3c02..3116922e 100644 --- a/transport/internet/tagged/taggedimpl/taggedimpl.go +++ b/transport/internet/tagged/taggedimpl/taggedimpl.go @@ -1,3 +1 @@ package taggedimpl - -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen diff --git a/transport/internet/tcp/config.go b/transport/internet/tcp/config.go index f21b63f6..e8851d0e 100644 --- a/transport/internet/tcp/config.go +++ b/transport/internet/tcp/config.go @@ -5,8 +5,6 @@ import ( "github.com/xtls/xray-core/transport/internet" ) -const protocolName = "tcp" - func init() { common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { return new(Config) diff --git a/transport/internet/tcp/tcp.go b/transport/internet/tcp/tcp.go index f9e66d84..9a86457a 100644 --- a/transport/internet/tcp/tcp.go +++ b/transport/internet/tcp/tcp.go @@ -1,3 +1,3 @@ package tcp -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen +const protocolName = "tcp" diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index 25889cb1..38b603c0 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -12,8 +12,6 @@ import ( "github.com/xtls/xray-core/common/net" ) -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - type Interface interface { net.Conn HandshakeContext(ctx context.Context) error diff --git a/transport/internet/udp/udp.go b/transport/internet/udp/udp.go index d01148b2..154bcc7e 100644 --- a/transport/internet/udp/udp.go +++ b/transport/internet/udp/udp.go @@ -1,5 +1,3 @@ package udp -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen - const protocolName = "udp" diff --git a/transport/internet/websocket/config.go b/transport/internet/websocket/config.go index 8cb4a855..af66ebbe 100644 --- a/transport/internet/websocket/config.go +++ b/transport/internet/websocket/config.go @@ -7,8 +7,6 @@ import ( "github.com/xtls/xray-core/transport/internet" ) -const protocolName = "websocket" - func (c *Config) GetNormalizedPath() string { path := c.Path if path == "" { diff --git a/transport/internet/websocket/ws.go b/transport/internet/websocket/ws.go index 85c5ffb0..f05ded37 100644 --- a/transport/internet/websocket/ws.go +++ b/transport/internet/websocket/ws.go @@ -5,4 +5,4 @@ WebSocket transport implements an HTTP(S) compliable, surveillance proof transpo */ package websocket -//go:generate go run github.com/xtls/xray-core/common/errors/errorgen +const protocolName = "websocket" From 3632e83faa70f2bdd08507c54b251ecd22092e6c Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 25 Sep 2024 21:29:41 -0400 Subject: [PATCH 553/867] Transport: Add HTTP3 to HTTP (#3819) --- infra/conf/transport_internet.go | 2 +- transport/internet/http/dialer.go | 175 +++++++++++++++++--------- transport/internet/http/http_test.go | 78 ++++++++++++ transport/internet/http/hub.go | 181 ++++++++++++++++----------- transport/internet/splithttp/hub.go | 8 +- 5 files changed, 316 insertions(+), 128 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 21cffc07..e89cef0d 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -650,7 +650,7 @@ func (p TransportProtocol) Build() (string, error) { return "mkcp", nil case "ws", "websocket": return "websocket", nil - case "h2", "http": + case "h2", "h3", "http": return "http", nil case "grpc", "gun": return "grpc", nil diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index a1421d3f..31ded010 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -9,6 +9,8 @@ import ( "sync" "time" + "github.com/quic-go/quic-go" + "github.com/quic-go/quic-go/http3" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" c "github.com/xtls/xray-core/common/ctx" @@ -24,6 +26,13 @@ import ( "golang.org/x/net/http2" ) +// defines the maximum time an idle TCP session can survive in the tunnel, so +// it should be consistent across HTTP versions and with other transports. +const connIdleTimeout = 300 * time.Second + +// consistent with quic-go +const h3KeepalivePeriod = 10 * time.Second + type dialerConf struct { net.Destination *internet.MemoryStreamConfig @@ -48,72 +57,129 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in if tlsConfigs == nil && realityConfigs == nil { return nil, errors.New("TLS or REALITY must be enabled for http transport.").AtWarning() } + isH3 := tlsConfigs != nil && (len(tlsConfigs.NextProtocol) == 1 && tlsConfigs.NextProtocol[0] == "h3") + if isH3 { + dest.Network = net.Network_UDP + } sockopt := streamSettings.SocketSettings if client, found := globalDialerMap[dialerConf{dest, streamSettings}]; found { return client, nil } - transport := &http2.Transport{ - DialTLSContext: func(hctx context.Context, string, addr string, tlsConfig *gotls.Config) (net.Conn, error) { - rawHost, rawPort, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - if len(rawPort) == 0 { - rawPort = "443" - } - port, err := net.PortFromString(rawPort) - if err != nil { - return nil, err - } - address := net.ParseAddress(rawHost) + var transport http.RoundTripper + if isH3 { + quicConfig := &quic.Config{ + MaxIdleTimeout: connIdleTimeout, - hctx = c.ContextWithID(hctx, c.IDFromContext(ctx)) - hctx = session.ContextWithOutbounds(hctx, session.OutboundsFromContext(ctx)) - hctx = session.ContextWithTimeoutOnly(hctx, true) + // these two are defaults of quic-go/http3. the default of quic-go (no + // http3) is different, so it is hardcoded here for clarity. + // https://github.com/quic-go/quic-go/blob/b8ea5c798155950fb5bbfdd06cad1939c9355878/http3/client.go#L36-L39 + MaxIncomingStreams: -1, + KeepAlivePeriod: h3KeepalivePeriod, + } + roundTripper := &http3.RoundTripper{ + QUICConfig: quicConfig, + TLSClientConfig: tlsConfigs.GetTLSConfig(tls.WithDestination(dest)), + Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { + conn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) + if err != nil { + return nil, err + } - pconn, err := internet.DialSystem(hctx, net.TCPDestination(address, port), sockopt) - if err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to " + addr) - return nil, err - } + var udpConn net.PacketConn + var udpAddr *net.UDPAddr - if realityConfigs != nil { - return reality.UClient(pconn, realityConfigs, hctx, dest) - } + switch c := conn.(type) { + case *internet.PacketConnWrapper: + var ok bool + udpConn, ok = c.Conn.(*net.UDPConn) + if !ok { + return nil, errors.New("PacketConnWrapper does not contain a UDP connection") + } + udpAddr, err = net.ResolveUDPAddr("udp", c.Dest.String()) + if err != nil { + return nil, err + } + case *net.UDPConn: + udpConn = c + udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) + if err != nil { + return nil, err + } + default: + udpConn = &internet.FakePacketConn{c} + udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) + if err != nil { + return nil, err + } + } - var cn tls.Interface - if fingerprint := tls.GetFingerprint(tlsConfigs.Fingerprint); fingerprint != nil { - cn = tls.UClient(pconn, tlsConfig, fingerprint).(*tls.UConn) - } else { - cn = tls.Client(pconn, tlsConfig).(*tls.Conn) - } - if err := cn.HandshakeContext(ctx); err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to " + addr) - return nil, err - } - if !tlsConfig.InsecureSkipVerify { - if err := cn.VerifyHostname(tlsConfig.ServerName); err != nil { + return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg) + }, + } + transport = roundTripper + } else { + transportH2 := &http2.Transport{ + DialTLSContext: func(hctx context.Context, string, addr string, tlsConfig *gotls.Config) (net.Conn, error) { + rawHost, rawPort, err := net.SplitHostPort(addr) + if err != nil { + return nil, err + } + if len(rawPort) == 0 { + rawPort = "443" + } + port, err := net.PortFromString(rawPort) + if err != nil { + return nil, err + } + address := net.ParseAddress(rawHost) + + hctx = c.ContextWithID(hctx, c.IDFromContext(ctx)) + hctx = session.ContextWithOutbounds(hctx, session.OutboundsFromContext(ctx)) + hctx = session.ContextWithTimeoutOnly(hctx, true) + + pconn, err := internet.DialSystem(hctx, net.TCPDestination(address, port), sockopt) + if err != nil { errors.LogErrorInner(ctx, err, "failed to dial to " + addr) return nil, err } - } - negotiatedProtocol := cn.NegotiatedProtocol() - if negotiatedProtocol != http2.NextProtoTLS { - return nil, errors.New("http2: unexpected ALPN protocol " + negotiatedProtocol + "; want q" + http2.NextProtoTLS).AtError() - } - return cn, nil - }, - } - - if tlsConfigs != nil { - transport.TLSClientConfig = tlsConfigs.GetTLSConfig(tls.WithDestination(dest)) - } - - if httpSettings.IdleTimeout > 0 || httpSettings.HealthCheckTimeout > 0 { - transport.ReadIdleTimeout = time.Second * time.Duration(httpSettings.IdleTimeout) - transport.PingTimeout = time.Second * time.Duration(httpSettings.HealthCheckTimeout) + + if realityConfigs != nil { + return reality.UClient(pconn, realityConfigs, hctx, dest) + } + + var cn tls.Interface + if fingerprint := tls.GetFingerprint(tlsConfigs.Fingerprint); fingerprint != nil { + cn = tls.UClient(pconn, tlsConfig, fingerprint).(*tls.UConn) + } else { + cn = tls.Client(pconn, tlsConfig).(*tls.Conn) + } + if err := cn.HandshakeContext(ctx); err != nil { + errors.LogErrorInner(ctx, err, "failed to dial to " + addr) + return nil, err + } + if !tlsConfig.InsecureSkipVerify { + if err := cn.VerifyHostname(tlsConfig.ServerName); err != nil { + errors.LogErrorInner(ctx, err, "failed to dial to " + addr) + return nil, err + } + } + negotiatedProtocol := cn.NegotiatedProtocol() + if negotiatedProtocol != http2.NextProtoTLS { + return nil, errors.New("http2: unexpected ALPN protocol " + negotiatedProtocol + "; want q" + http2.NextProtoTLS).AtError() + } + return cn, nil + }, + } + if tlsConfigs != nil { + transportH2.TLSClientConfig = tlsConfigs.GetTLSConfig(tls.WithDestination(dest)) + } + if httpSettings.IdleTimeout > 0 || httpSettings.HealthCheckTimeout > 0 { + transportH2.ReadIdleTimeout = time.Second * time.Duration(httpSettings.IdleTimeout) + transportH2.PingTimeout = time.Second * time.Duration(httpSettings.HealthCheckTimeout) + } + transport = transportH2 } client := &http.Client{ @@ -158,9 +224,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me Host: dest.NetAddr(), Path: httpSettings.getNormalizedPath(), }, - Proto: "HTTP/2", - ProtoMajor: 2, - ProtoMinor: 0, Header: httpHeaders, } // Disable any compression method from server. diff --git a/transport/internet/http/http_test.go b/transport/internet/http/http_test.go index 3639eb84..dd6c852d 100644 --- a/transport/internet/http/http_test.go +++ b/transport/internet/http/http_test.go @@ -12,6 +12,7 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol/tls/cert" "github.com/xtls/xray-core/testing/servers/tcp" + "github.com/xtls/xray-core/testing/servers/udp" "github.com/xtls/xray-core/transport/internet" . "github.com/xtls/xray-core/transport/internet/http" "github.com/xtls/xray-core/transport/internet/stat" @@ -92,3 +93,80 @@ func TestHTTPConnection(t *testing.T) { t.Error(r) } } + +func TestH3Connection(t *testing.T) { + port := udp.PickPort() + + listener, err := Listen(context.Background(), net.LocalHostIP, port, &internet.MemoryStreamConfig{ + ProtocolName: "http", + ProtocolSettings: &Config{}, + SecurityType: "tls", + SecuritySettings: &tls.Config{ + NextProtocol: []string{"h3"}, + Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("www.example.com")))}, + }, + }, func(conn stat.Connection) { + go func() { + defer conn.Close() + + b := buf.New() + defer b.Release() + + for { + if _, err := b.ReadFrom(conn); err != nil { + return + } + _, err := conn.Write(b.Bytes()) + common.Must(err) + } + }() + }) + common.Must(err) + + defer listener.Close() + + time.Sleep(time.Second) + + dctx := context.Background() + conn, err := Dial(dctx, net.TCPDestination(net.LocalHostIP, port), &internet.MemoryStreamConfig{ + ProtocolName: "http", + ProtocolSettings: &Config{}, + SecurityType: "tls", + SecuritySettings: &tls.Config{ + NextProtocol: []string{"h3"}, + ServerName: "www.example.com", + AllowInsecure: true, + }, + }) + common.Must(err) + defer conn.Close() + + const N = 1024 + b1 := make([]byte, N) + common.Must2(rand.Read(b1)) + b2 := buf.New() + + nBytes, err := conn.Write(b1) + common.Must(err) + if nBytes != N { + t.Error("write: ", nBytes) + } + + b2.Clear() + common.Must2(b2.ReadFullFrom(conn, N)) + if r := cmp.Diff(b2.Bytes(), b1); r != "" { + t.Error(r) + } + + nBytes, err = conn.Write(b1) + common.Must(err) + if nBytes != N { + t.Error("write: ", nBytes) + } + + b2.Clear() + common.Must2(b2.ReadFullFrom(conn, N)) + if r := cmp.Diff(b2.Bytes(), b1); r != "" { + t.Error(r) + } +} diff --git a/transport/internet/http/hub.go b/transport/internet/http/hub.go index 3421ae64..96fe8f62 100644 --- a/transport/internet/http/hub.go +++ b/transport/internet/http/hub.go @@ -2,11 +2,14 @@ package http import ( "context" + gotls "crypto/tls" "io" "net/http" "strings" "time" + "github.com/quic-go/quic-go" + "github.com/quic-go/quic-go/http3" goreality "github.com/xtls/reality" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" @@ -23,10 +26,12 @@ import ( ) type Listener struct { - server *http.Server - handler internet.ConnHandler - local net.Addr - config *Config + server *http.Server + h3server *http3.Server + handler internet.ConnHandler + local net.Addr + config *Config + isH3 bool } func (l *Listener) Addr() net.Addr { @@ -34,7 +39,14 @@ func (l *Listener) Addr() net.Addr { } func (l *Listener) Close() error { - return l.server.Close() + if l.h3server != nil { + if err := l.h3server.Close(); err != nil { + return err + } + } else if l.server != nil { + return l.server.Close() + } + return errors.New("listener does not have an HTTP/3 server or h2 server") } type flushWriter struct { @@ -119,43 +131,33 @@ func (l *Listener) ServeHTTP(writer http.ResponseWriter, request *http.Request) func Listen(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, handler internet.ConnHandler) (internet.Listener, error) { httpSettings := streamSettings.ProtocolSettings.(*Config) - var listener *Listener - if port == net.Port(0) { // unix - listener = &Listener{ - handler: handler, - local: &net.UnixAddr{ - Name: address.Domain(), - Net: "unix", - }, - config: httpSettings, - } - } else { // tcp - listener = &Listener{ - handler: handler, - local: &net.TCPAddr{ - IP: address.IP(), - Port: int(port), - }, - config: httpSettings, - } - } - - var server *http.Server config := tls.ConfigFromStreamSettings(streamSettings) + var tlsConfig *gotls.Config if config == nil { - h2s := &http2.Server{} - - server = &http.Server{ - Addr: serial.Concat(address, ":", port), - Handler: h2c.NewHandler(listener, h2s), - ReadHeaderTimeout: time.Second * 4, + tlsConfig = &gotls.Config{} + } else { + tlsConfig = config.GetTLSConfig() + } + isH3 := len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "h3" + listener := &Listener{ + handler: handler, + config: httpSettings, + isH3: isH3, + } + if port == net.Port(0) { // unix + listener.local = &net.UnixAddr{ + Name: address.Domain(), + Net: "unix", + } + } else if isH3 { // udp + listener.local = &net.UDPAddr{ + IP: address.IP(), + Port: int(port), } } else { - server = &http.Server{ - Addr: serial.Concat(address, ":", port), - TLSConfig: config.GetTLSConfig(tls.WithNextProto("h2")), - Handler: listener, - ReadHeaderTimeout: time.Second * 4, + listener.local = &net.TCPAddr{ + IP: address.IP(), + Port: int(port), } } @@ -163,45 +165,84 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti errors.LogWarning(ctx, "accepting PROXY protocol") } - listener.server = server - go func() { - var streamListener net.Listener - var err error - if port == net.Port(0) { // unix - streamListener, err = internet.ListenSystem(ctx, &net.UnixAddr{ - Name: address.Domain(), - Net: "unix", - }, streamSettings.SocketSettings) - if err != nil { - errors.LogErrorInner(ctx, err, "failed to listen on ", address) - return - } - } else { // tcp - streamListener, err = internet.ListenSystem(ctx, &net.TCPAddr{ - IP: address.IP(), - Port: int(port), - }, streamSettings.SocketSettings) - if err != nil { - errors.LogErrorInner(ctx, err, "failed to listen on ", address, ":", port) - return - } + if isH3 { + Conn, err := internet.ListenSystemPacket(context.Background(), listener.local, streamSettings.SocketSettings) + if err != nil { + return nil, errors.New("failed to listen UDP(for SH3) on ", address, ":", port).Base(err) } + h3listener, err := quic.ListenEarly(Conn, tlsConfig, nil) + if err != nil { + return nil, errors.New("failed to listen QUIC(for SH3) on ", address, ":", port).Base(err) + } + errors.LogInfo(ctx, "listening QUIC(for SH3) on ", address, ":", port) - if config == nil { - if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { - streamListener = goreality.NewListener(streamListener, config.GetREALITYConfig()) + listener.h3server = &http3.Server{ + Handler: listener, + } + go func() { + if err := listener.h3server.ServeListener(h3listener); err != nil { + errors.LogWarningInner(ctx, err, "failed to serve http3 for splithttp") } - err = server.Serve(streamListener) - if err != nil { - errors.LogInfoInner(ctx, err, "stopping serving H2C or REALITY H2") + }() + } else { + var server *http.Server + if config == nil { + h2s := &http2.Server{} + + server = &http.Server{ + Addr: serial.Concat(address, ":", port), + Handler: h2c.NewHandler(listener, h2s), + ReadHeaderTimeout: time.Second * 4, } } else { - err = server.ServeTLS(streamListener, "", "") - if err != nil { - errors.LogInfoInner(ctx, err, "stopping serving TLS H2") + server = &http.Server{ + Addr: serial.Concat(address, ":", port), + TLSConfig: config.GetTLSConfig(tls.WithNextProto("h2")), + Handler: listener, + ReadHeaderTimeout: time.Second * 4, } } - }() + + listener.server = server + go func() { + var streamListener net.Listener + var err error + if port == net.Port(0) { // unix + streamListener, err = internet.ListenSystem(ctx, &net.UnixAddr{ + Name: address.Domain(), + Net: "unix", + }, streamSettings.SocketSettings) + if err != nil { + errors.LogErrorInner(ctx, err, "failed to listen on ", address) + return + } + } else { // tcp + streamListener, err = internet.ListenSystem(ctx, &net.TCPAddr{ + IP: address.IP(), + Port: int(port), + }, streamSettings.SocketSettings) + if err != nil { + errors.LogErrorInner(ctx, err, "failed to listen on ", address, ":", port) + return + } + } + + if config == nil { + if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { + streamListener = goreality.NewListener(streamListener, config.GetREALITYConfig()) + } + err = server.Serve(streamListener) + if err != nil { + errors.LogInfoInner(ctx, err, "stopping serving H2C or REALITY H2") + } + } else { + err = server.ServeTLS(streamListener, "", "") + if err != nil { + errors.LogInfoInner(ctx, err, "stopping serving TLS H2") + } + } + }() + } return listener, nil } diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 423bf6e3..4545db64 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -365,7 +365,13 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet // Addr implements net.Listener.Addr(). func (ln *Listener) Addr() net.Addr { - return ln.listener.Addr() + if ln.h3listener != nil { + return ln.h3listener.Addr() + } + if ln.listener != nil { + return ln.listener.Addr() + } + return nil } // Close implements net.Listener.Close(). From d8485bd5afdec44654460b58d6a4bfb89cfc7786 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 28 Sep 2024 05:25:59 +0000 Subject: [PATCH 554/867] Transport: Add RAW as an alias of TCP (#3852) --- infra/conf/transport_internet.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index e89cef0d..19a0f7a5 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -644,7 +644,7 @@ type TransportProtocol string // Build implements Buildable. func (p TransportProtocol) Build() (string, error) { switch strings.ToLower(string(p)) { - case "tcp": + case "raw", "tcp": return "tcp", nil case "kcp", "mkcp": return "mkcp", nil @@ -783,6 +783,7 @@ type StreamConfig struct { Security string `json:"security"` TLSSettings *TLSConfig `json:"tlsSettings"` REALITYSettings *REALITYConfig `json:"realitySettings"` + RAWSettings *TCPConfig `json:"rawSettings"` TCPSettings *TCPConfig `json:"tcpSettings"` KCPSettings *KCPConfig `json:"kcpSettings"` WSSettings *WebSocketConfig `json:"wsSettings"` @@ -839,10 +840,13 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { default: return nil, errors.New(`Unknown security "` + c.Security + `".`) } + if c.TCPSettings == nil { + c.TCPSettings = c.RAWSettings + } if c.TCPSettings != nil { ts, err := c.TCPSettings.Build() if err != nil { - return nil, errors.New("Failed to build TCP config.").Base(err) + return nil, errors.New("Failed to build RAW config.").Base(err) } config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ ProtocolName: "tcp", From 697156f6f6fee139ed16c6585c73addd1b49d961 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Sun, 29 Sep 2024 03:10:42 +0800 Subject: [PATCH 555/867] SplitHTTP Config: Add capability to parse int in string format (#3855) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “100” → 100 “-1” → -1 “” → 0 --- infra/conf/common.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/infra/conf/common.go b/infra/conf/common.go index 9d31bc0a..24664859 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -252,10 +252,23 @@ type Int32Range struct { } func (v *Int32Range) UnmarshalJSON(data []byte) error { - var stringrange string + var str string var rawint int32 - if err := json.Unmarshal(data, &stringrange); err == nil { - pair := strings.SplitN(stringrange, "-", 2) + if err := json.Unmarshal(data, &str); err == nil { + // for number in string format like "114" or "-1" + if value, err := strconv.Atoi(str); err == nil { + v.From = int32(value) + v.To = int32(value) + return nil + } + // for empty "", we treat it as 0 + if str == "" { + v.From = 0 + v.To = 0 + return nil + } + // for range value, like "114-514" + pair := strings.SplitN(str, "-", 2) if len(pair) == 2 { from, err := strconv.Atoi(pair[0]) to, err2 := strconv.Atoi(pair[1]) From 3b06af882de4a73759770bbe13d219943cdf0d0c Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 30 Sep 2024 15:20:13 +0000 Subject: [PATCH 556/867] v24.9.30 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index d0a25478..00b2dd10 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 24 Version_y byte = 9 - Version_z byte = 19 + Version_z byte = 30 ) var ( From e45cef542e26d7213f53987383b90be7bd0ab2d7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 04:16:29 +0000 Subject: [PATCH 557/867] Bump google.golang.org/grpc from 1.67.0 to 1.67.1 (#3866) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.67.0 to 1.67.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.67.0...v1.67.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 272e0ae7..8f99995d 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.8.0 golang.org/x/sys v0.25.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.67.0 + google.golang.org/grpc v1.67.1 google.golang.org/protobuf v1.34.2 gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index fb73b74c..6803cbde 100644 --- a/go.sum +++ b/go.sum @@ -127,8 +127,8 @@ golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uI golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw= -google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From c7534c4e36c1bdd070572d839ff55a5ae83ad8df Mon Sep 17 00:00:00 2001 From: Nikita Korotaev <104270279+iambabyninja@users.noreply.github.com> Date: Thu, 3 Oct 2024 19:19:39 +0500 Subject: [PATCH 558/867] README.md: Add Marzneshin to Web Panel (#3873) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 016a65d4..0a177ce8 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ - Web Panel - [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [Xray-UI](https://github.com/qist/xray-ui) - [Hiddify](https://github.com/hiddify/hiddify-config) + - [Marzneshin](https://github.com/marzneshin/marzneshin) - [Marzban](https://github.com/Gozargah/Marzban) - [Libertea](https://github.com/VZiChoushaDui/Libertea) - One Click From 75729ce77902d3da2b95c53bb3c87676a6482dff Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 5 Oct 2024 00:13:46 +0000 Subject: [PATCH 559/867] REALITY config: Add `target` as an alias of `dest` https://t.me/projectXtls/364 --- infra/conf/transport_internet.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 19a0f7a5..838438a4 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -474,6 +474,7 @@ type REALITYConfig struct { Show bool `json:"show"` MasterKeyLog string `json:"masterKeyLog"` Dest json.RawMessage `json:"dest"` + Target json.RawMessage `json:"target"` Type string `json:"type"` Xver uint64 `json:"xver"` ServerNames []string `json:"serverNames"` @@ -495,6 +496,9 @@ func (c *REALITYConfig) Build() (proto.Message, error) { config.Show = c.Show config.MasterKeyLog = c.MasterKeyLog var err error + if c.Dest == nil { + c.Dest = c.Target + } if c.Dest != nil { var i uint16 var s string @@ -522,7 +526,7 @@ func (c *REALITYConfig) Build() (proto.Message, error) { } } if c.Type == "" { - return nil, errors.New(`please fill in a valid value for "dest"`) + return nil, errors.New(`please fill in a valid value for "dest" or "target"`) } if c.Xver > 2 { return nil, errors.New(`invalid PROXY protocol version, "xver" only accepts 0, 1, 2`) From c30f5d47964b50a6db0875be7a05aafbb73e4d75 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 5 Oct 2024 02:15:28 +0000 Subject: [PATCH 560/867] Lint common/errors/feature_errors.go --- common/errors/feature_errors.go | 68 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/common/errors/feature_errors.go b/common/errors/feature_errors.go index 3cacd2b9..40c0ee9b 100644 --- a/common/errors/feature_errors.go +++ b/common/errors/feature_errors.go @@ -1,34 +1,34 @@ -package errors - -import ( - "context" -) - -// PrintMigrateFeatureInfo prints a notice of the upcoming feature migration. -// Place it after the source feature related config file pharser code. -// Important note: Only use this when the target migrating feature is under construction. -// Important note: Even when the target migrating feature has finished its construction, this notice can still be used yet before announcing deprecation of the old feature. -// Do not remove this function even there is no reference to it. -func PrintMigrateFeatureInfo(sourceFeature string, targetFeature string) { - LogInfo(context.Background(), "The feature " + sourceFeature + " will be migrated to " + targetFeature + " in the future.") -} - -// PrintDeprecatedFeatureWarning prints a warning for deprecated and going to be removed feature. -// Do not remove this function even there is no reference to it. -func PrintDeprecatedFeatureWarning(feature string, migrateFeature string) { - if len(migrateFeature) > 0 { - LogWarning(context.Background(), "This feature " + feature + " is deprecated and being migrated to " + migrateFeature + ". Please update your config(s) according to release note and documentation before removal.") - } else { - LogWarning(context.Background(), "This feature " + feature + " is deprecated. Please update your config(s) according to release note and documentation before removal.") - } -} - -// PrintRemovedFeatureError prints an error message for removed feature then return an error. And after long enough time the message can also be removed, uses as an indicator. -// Do not remove this function even there is no reference to it. -func PrintRemovedFeatureError(feature string, migrateFeature string) (error) { - if len(migrateFeature) > 0 { - return New("The feature " + feature + " has been removed and migrated to " + migrateFeature + ". Please update your config(s) according to release note and documentation.") - } else { - return New("The feature " + feature + " has been removed. Please update your config(s) according to release note and documentation.") - } -} +package errors + +import ( + "context" +) + +// PrintMigrateFeatureInfo prints a notice of the upcoming feature migration. +// Place it after the source feature related config file pharser code. +// Important note: Only use this when the target migrating feature is under construction. +// Important note: Even when the target migrating feature has finished its construction, this notice can still be used yet before announcing deprecation of the old feature. +// Do not remove this function even there is no reference to it. +func PrintMigrateFeatureInfo(sourceFeature string, targetFeature string) { + LogInfo(context.Background(), "The feature "+sourceFeature+" will be migrated to "+targetFeature+" in the future.") +} + +// PrintDeprecatedFeatureWarning prints a warning for deprecated and going to be removed feature. +// Do not remove this function even there is no reference to it. +func PrintDeprecatedFeatureWarning(feature string, migrateFeature string) { + if len(migrateFeature) > 0 { + LogWarning(context.Background(), "This feature "+feature+" is deprecated and being migrated to "+migrateFeature+". Please update your config(s) according to release note and documentation before removal.") + } else { + LogWarning(context.Background(), "This feature "+feature+" is deprecated. Please update your config(s) according to release note and documentation before removal.") + } +} + +// PrintRemovedFeatureError prints an error message for removed feature then return an error. And after long enough time the message can also be removed, uses as an indicator. +// Do not remove this function even there is no reference to it. +func PrintRemovedFeatureError(feature string, migrateFeature string) error { + if len(migrateFeature) > 0 { + return New("The feature " + feature + " has been removed and migrated to " + migrateFeature + ". Please update your config(s) according to release note and documentation.") + } else { + return New("The feature " + feature + " has been removed. Please update your config(s) according to release note and documentation.") + } +} From e2b9f713848726c6310264ecd709207d5fe4ad23 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 05:20:18 +0000 Subject: [PATCH 561/867] Bump golang.org/x/net from 0.29.0 to 0.30.0 (#3889) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.29.0 to 0.30.0. - [Commits](https://github.com/golang/net/compare/v0.29.0...v0.30.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index 8f99995d..0ab223bf 100644 --- a/go.mod +++ b/go.mod @@ -22,10 +22,10 @@ require ( github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.27.0 - golang.org/x/net v0.29.0 + golang.org/x/crypto v0.28.0 + golang.org/x/net v0.30.0 golang.org/x/sync v0.8.0 - golang.org/x/sys v0.25.0 + golang.org/x/sys v0.26.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.67.1 google.golang.org/protobuf v1.34.2 @@ -51,7 +51,7 @@ require ( go.uber.org/mock v0.4.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/mod v0.18.0 // indirect - golang.org/x/text v0.18.0 // indirect + golang.org/x/text v0.19.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect diff --git a/go.sum b/go.sum index 6803cbde..630c2792 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= +golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= @@ -89,8 +89,8 @@ golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= +golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= @@ -103,14 +103,14 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= +golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From b3ab49f323bce937312b8ff3503dcf93de948c31 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 05:20:39 +0000 Subject: [PATCH 562/867] Bump google.golang.org/protobuf from 1.34.2 to 1.35.1 (#3893) Bumps google.golang.org/protobuf from 1.34.2 to 1.35.1. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0ab223bf..2ea85f90 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/sys v0.26.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.67.1 - google.golang.org/protobuf v1.34.2 + google.golang.org/protobuf v1.35.1 gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.3.0 diff --git a/go.sum b/go.sum index 630c2792..19d3bdb0 100644 --- a/go.sum +++ b/go.sum @@ -129,8 +129,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From af7232d54524bbeed19187835955c6abff7dc643 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 05:21:03 +0000 Subject: [PATCH 563/867] Bump github.com/pires/go-proxyproto from 0.7.0 to 0.8.0 (#3895) Bumps [github.com/pires/go-proxyproto](https://github.com/pires/go-proxyproto) from 0.7.0 to 0.8.0. - [Release notes](https://github.com/pires/go-proxyproto/releases) - [Commits](https://github.com/pires/go-proxyproto/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: github.com/pires/go-proxyproto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2ea85f90..7f3cba9f 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gorilla/websocket v1.5.3 github.com/miekg/dns v1.1.62 github.com/pelletier/go-toml v1.9.5 - github.com/pires/go-proxyproto v0.7.0 + github.com/pires/go-proxyproto v0.8.0 github.com/quic-go/quic-go v0.46.0 github.com/refraction-networking/utls v1.6.7 github.com/sagernet/sing v0.4.3 diff --git a/go.sum b/go.sum index 19d3bdb0..8fa32abd 100644 --- a/go.sum +++ b/go.sum @@ -42,8 +42,8 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= -github.com/pires/go-proxyproto v0.7.0 h1:IukmRewDQFWC7kfnb66CSomk2q/seBuilHBYFwyq0Hs= -github.com/pires/go-proxyproto v0.7.0/go.mod h1:Vz/1JPY/OACxWGQNIRY2BeyDmpoaWmEP40O9LbuiFR4= +github.com/pires/go-proxyproto v0.8.0 h1:5unRmEAPbHXHuLjDg01CxJWf91cw3lKHc/0xzKpXEe0= +github.com/pires/go-proxyproto v0.8.0/go.mod h1:iknsfgnH8EkjrMeMyvfKByp9TiBZCKZM0jx2xmKqnVY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= From 5164a82185c475f9ef0a04cb6d59f5181d9a4851 Mon Sep 17 00:00:00 2001 From: vnxme <46669194+vnxme@users.noreply.github.com> Date: Fri, 11 Oct 2024 18:37:01 +0300 Subject: [PATCH 564/867] Routing: Fix regexp syntax support in UserMatcher (#3900) --- app/router/condition.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/router/condition.go b/app/router/condition.go index dc806372..89da1adf 100644 --- a/app/router/condition.go +++ b/app/router/condition.go @@ -202,7 +202,7 @@ func NewUserMatcher(users []string) *UserMatcher { for _, user := range users { if len(user) > 0 { if len(user) > 7 && strings.HasPrefix(user, "regexp:") { - if re, err := regexp.Compile(user[7:]); err != nil { + if re, err := regexp.Compile(user[7:]); err == nil { patternsCopy = append(patternsCopy, re) } // Items of users slice with an invalid regexp syntax are ignored. From 8c180b9cfd89a088f90af9effa918c690fa9bb62 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Sun, 13 Oct 2024 07:22:15 +0200 Subject: [PATCH 565/867] Browser Dialer: Revert changes to event listeners (#3906) https://github.com/XTLS/Xray-core/issues/3882#issuecomment-2396167708 This does not fix the linked issue, just a random bug I found. --- transport/internet/browser_dialer/dialer.html | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/transport/internet/browser_dialer/dialer.html b/transport/internet/browser_dialer/dialer.html index 241d2102..558db627 100644 --- a/transport/internet/browser_dialer/dialer.html +++ b/transport/internet/browser_dialer/dialer.html @@ -24,7 +24,10 @@ // arraybuffer is significantly faster in chrome than default // blob, tested with chrome 123 ws.binaryType = "arraybuffer"; - ws.addEventListener("message", (event) => { + // note: this event listener is later overwritten after the + // handshake has completed. do not attempt to modernize it without + // double-checking that this continues to work + ws.onmessage = function (event) { clientIdleCount -= 1; let [method, url, protocol] = event.data.split(" "); switch (method) { @@ -134,10 +137,10 @@ }; check(); - }); - ws.addEventListener("error", (event) => { + }; + ws.onerror = function (event) { ws.close(); - }); + }; }; let checkTask = setInterval(check, 1000); From 6a70ae6408def0c5ba838567cdc175a07f3e3d47 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Mon, 14 Oct 2024 22:55:48 -0400 Subject: [PATCH 566/867] HTTP transport: Fix an issue when HTTP client start fail with 403 (#3910) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- transport/internet/http/dialer.go | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index 31ded010..d0a86e8b 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -134,21 +134,21 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return nil, err } address := net.ParseAddress(rawHost) - + hctx = c.ContextWithID(hctx, c.IDFromContext(ctx)) hctx = session.ContextWithOutbounds(hctx, session.OutboundsFromContext(ctx)) hctx = session.ContextWithTimeoutOnly(hctx, true) - + pconn, err := internet.DialSystem(hctx, net.TCPDestination(address, port), sockopt) if err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to " + addr) + errors.LogErrorInner(ctx, err, "failed to dial to "+addr) return nil, err } - + if realityConfigs != nil { return reality.UClient(pconn, realityConfigs, hctx, dest) } - + var cn tls.Interface if fingerprint := tls.GetFingerprint(tlsConfigs.Fingerprint); fingerprint != nil { cn = tls.UClient(pconn, tlsConfig, fingerprint).(*tls.UConn) @@ -156,12 +156,12 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in cn = tls.Client(pconn, tlsConfig).(*tls.Conn) } if err := cn.HandshakeContext(ctx); err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to " + addr) + errors.LogErrorInner(ctx, err, "failed to dial to "+addr) return nil, err } if !tlsConfig.InsecureSkipVerify { if err := cn.VerifyHostname(tlsConfig.ServerName); err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to " + addr) + errors.LogErrorInner(ctx, err, "failed to dial to "+addr) return nil, err } } @@ -224,7 +224,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me Host: dest.NetAddr(), Path: httpSettings.getNormalizedPath(), }, - Header: httpHeaders, + Header: httpHeaders, } // Disable any compression method from server. request.Header.Set("Accept-Encoding", "identity") @@ -232,8 +232,12 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me wrc := &WaitReadCloser{Wait: make(chan struct{})} go func() { response, err := client.Do(request) - if err != nil { - errors.LogWarningInner(ctx, err, "failed to dial to ", dest) + if err != nil || response.StatusCode != 200 { + if err != nil { + errors.LogWarningInner(ctx, err, "failed to dial to ", dest) + } else { + errors.LogWarning(ctx, "unexpected status ", response.StatusCode) + } wrc.Close() { // Abandon `client` if `client.Do(request)` failed @@ -246,11 +250,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } return } - if response.StatusCode != 200 { - errors.LogWarning(ctx, "unexpected status", response.StatusCode) - wrc.Close() - return - } wrc.Set(response.Body) }() From 19f3f709b237e04fb2f1476b9f966646fd06ae25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=81=E3=82=BB?= <123655015+chise0713@users.noreply.github.com> Date: Tue, 15 Oct 2024 11:30:29 +0800 Subject: [PATCH 567/867] WireGuard kernelTun: Check Capabilities instead of checking UID (#3871) https://github.com/XTLS/Xray-core/pull/3871#issuecomment-2412820323 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- infra/conf/wireguard.go | 19 +++++++++++++++---- proxy/wireguard/tun_default.go | 4 ++-- proxy/wireguard/tun_linux.go | 15 ++++++++++----- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/infra/conf/wireguard.go b/infra/conf/wireguard.go index d06bf689..2165a40d 100644 --- a/infra/conf/wireguard.go +++ b/infra/conf/wireguard.go @@ -4,6 +4,7 @@ import ( "context" "encoding/base64" "encoding/hex" + "fmt" "strings" "github.com/xtls/xray-core/common/errors" @@ -52,6 +53,7 @@ func (c *WireGuardPeerConfig) Build() (proto.Message, error) { type WireGuardConfig struct { IsClient bool `json:""` + KernelTun *bool `json:"kernelTun"` KernelMode *bool `json:"kernelMode"` SecretKey string `json:"secretKey"` Address []string `json:"address"` @@ -119,15 +121,24 @@ func (c *WireGuardConfig) Build() (proto.Message, error) { } config.IsClient = c.IsClient + kernelTunSupported, err := wireguard.KernelTunSupported() + if err != nil { + errors.LogWarning(context.Background(), fmt.Sprintf("Failed to check kernel TUN support: %v. This may indicate that your OS doesn't support kernel TUN or you lack the necessary permissions. Please ensure you have the required privileges.", err)) + config.KernelMode = false + return config, nil + } + if c.KernelMode == nil { + c.KernelMode = c.KernelTun + } if c.KernelMode != nil { config.KernelMode = *c.KernelMode - if config.KernelMode && !wireguard.KernelTunSupported() { - errors.LogWarning(context.Background(), "kernel mode is not supported on your OS or permission is insufficient") + if config.KernelMode && !kernelTunSupported { + errors.LogWarning(context.Background(), "kernel TUN is not supported on your OS or permission is insufficient") } } else { - config.KernelMode = wireguard.KernelTunSupported() + config.KernelMode = kernelTunSupported if config.KernelMode { - errors.LogDebug(context.Background(), "kernel mode is enabled as it's supported and permission is sufficient") + errors.LogDebug(context.Background(), "kernel TUN is enabled as it's supported and permission is sufficient") } } diff --git a/proxy/wireguard/tun_default.go b/proxy/wireguard/tun_default.go index 4d0567af..50a50944 100644 --- a/proxy/wireguard/tun_default.go +++ b/proxy/wireguard/tun_default.go @@ -11,6 +11,6 @@ func createKernelTun(localAddresses []netip.Addr, mtu int, handler promiscuousMo return nil, errors.New("not implemented") } -func KernelTunSupported() bool { - return false +func KernelTunSupported() (bool, error) { + return false, nil } diff --git a/proxy/wireguard/tun_linux.go b/proxy/wireguard/tun_linux.go index 22c638d3..b8ce6488 100644 --- a/proxy/wireguard/tun_linux.go +++ b/proxy/wireguard/tun_linux.go @@ -231,10 +231,15 @@ func createKernelTun(localAddresses []netip.Addr, mtu int, handler promiscuousMo return out, nil } -func KernelTunSupported() bool { - // run a superuser permission check to check - // if the current user has the sufficient permission - // to create a tun device. +func KernelTunSupported() (bool, error) { + var hdr unix.CapUserHeader + hdr.Version = unix.LINUX_CAPABILITY_VERSION_3 + hdr.Pid = 0 // 0 means current process - return unix.Geteuid() == 0 // 0 means root + var data unix.CapUserData + if err := unix.Capget(&hdr, &data); err != nil { + return false, fmt.Errorf("failed to get capabilities: %v", err) + } + + return (data.Effective & (1 << unix.CAP_NET_ADMIN)) != 0, nil } From 82bd5f3046e56b2d6a3b5986d659693f12022226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Tue, 15 Oct 2024 12:05:22 +0800 Subject: [PATCH 568/867] Refactor: Use struct `Int32Range` widely (#3867) https://github.com/XTLS/Xray-core/pull/3867#issuecomment-2412847316 --- infra/conf/common.go | 83 ++++++++++++++++++++++++++++------------ infra/conf/freedom.go | 89 +++++++++---------------------------------- 2 files changed, 75 insertions(+), 97 deletions(-) diff --git a/infra/conf/common.go b/infra/conf/common.go index 24664859..ccd36d3d 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -246,43 +246,76 @@ func (v *User) Build() *protocol.User { // Int32Range deserializes from "1-2" or 1, so can deserialize from both int and number. // Negative integers can be passed as sentinel values, but do not parse as ranges. +// Value will be exchanged if From > To, use .Left and .Right to get original value if need. type Int32Range struct { - From int32 - To int32 + Left int32 + Right int32 + From int32 + To int32 } func (v *Int32Range) UnmarshalJSON(data []byte) error { + defer v.ensureOrder() var str string var rawint int32 if err := json.Unmarshal(data, &str); err == nil { - // for number in string format like "114" or "-1" - if value, err := strconv.Atoi(str); err == nil { - v.From = int32(value) - v.To = int32(value) + left, right, err := ParseRangeString(str) + if err == nil { + v.Left, v.Right = int32(left), int32(right) return nil } - // for empty "", we treat it as 0 - if str == "" { - v.From = 0 - v.To = 0 - return nil - } - // for range value, like "114-514" - pair := strings.SplitN(str, "-", 2) - if len(pair) == 2 { - from, err := strconv.Atoi(pair[0]) - to, err2 := strconv.Atoi(pair[1]) - if err == nil && err2 == nil { - v.From = int32(from) - v.To = int32(to) - return nil - } - } } else if err := json.Unmarshal(data, &rawint); err == nil { - v.From = rawint - v.To = rawint + v.Left = rawint + v.Right = rawint return nil } return errors.New("Invalid integer range, expected either string of form \"1-2\" or plain integer.") } + +// ensureOrder() gives value to .From & .To and make sure .From < .To +func (r *Int32Range) ensureOrder() { + r.From, r.To = r.Left, r.Right + if r.From > r.To { + r.From, r.To = r.To, r.From + } +} + +// "-114-514" → ["-114","514"] +// "-1919--810" → ["-1919","-810"] +func splitFromSecondDash(s string) []string { + parts := strings.SplitN(s, "-", 3) + if len(parts) < 3 { + return []string{s} + } + return []string{parts[0] + "-" + parts[1], parts[2]} +} + +// Parse rang in string. Support negative number. +// eg: "114-514" "-114-514" "-1919--810" "114514" ""(return 0) +func ParseRangeString(str string) (int, int, error) { + // for number in string format like "114" or "-1" + if value, err := strconv.Atoi(str); err == nil { + return value, value, nil + } + // for empty "", we treat it as 0 + if str == "" { + return 0, 0, nil + } + // for range value, like "114-514" + var pair []string + // Process sth like "-114-514" "-1919--810" + if strings.HasPrefix(str, "-") { + pair = splitFromSecondDash(str) + } else { + pair = strings.SplitN(str, "-", 2) + } + if len(pair) == 2 { + left, err := strconv.Atoi(pair[0]) + right, err2 := strconv.Atoi(pair[1]) + if err == nil && err2 == nil { + return left, right, nil + } + } + return 0, 0, errors.New("invalid range string: ", str) +} diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 653f8815..14c09cc2 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -3,7 +3,6 @@ package conf import ( "encoding/base64" "net" - "strconv" "strings" "github.com/xtls/xray-core/common/errors" @@ -24,9 +23,9 @@ type FreedomConfig struct { } type Fragment struct { - Packets string `json:"packets"` - Length string `json:"length"` - Interval string `json:"interval"` + Packets string `json:"packets"` + Length *Int32Range `json:"length"` + Interval *Int32Range `json:"interval"` } type Noise struct { @@ -67,7 +66,6 @@ func (c *FreedomConfig) Build() (proto.Message, error) { if c.Fragment != nil { config.Fragment = new(freedom.Fragment) - var err, err2 error switch strings.ToLower(c.Fragment.Packets) { case "tlshello": @@ -80,75 +78,34 @@ func (c *FreedomConfig) Build() (proto.Message, error) { config.Fragment.PacketsTo = 0 default: // TCP Segmentation (range) - packetsFromTo := strings.Split(c.Fragment.Packets, "-") - if len(packetsFromTo) == 2 { - config.Fragment.PacketsFrom, err = strconv.ParseUint(packetsFromTo[0], 10, 64) - config.Fragment.PacketsTo, err2 = strconv.ParseUint(packetsFromTo[1], 10, 64) - } else { - config.Fragment.PacketsFrom, err = strconv.ParseUint(packetsFromTo[0], 10, 64) - config.Fragment.PacketsTo = config.Fragment.PacketsFrom - } + from, to, err := ParseRangeString(c.Fragment.Packets) if err != nil { return nil, errors.New("Invalid PacketsFrom").Base(err) } - if err2 != nil { - return nil, errors.New("Invalid PacketsTo").Base(err2) - } - if config.Fragment.PacketsFrom > config.Fragment.PacketsTo { - config.Fragment.PacketsFrom, config.Fragment.PacketsTo = config.Fragment.PacketsTo, config.Fragment.PacketsFrom - } + config.Fragment.PacketsFrom = uint64(from) + config.Fragment.PacketsTo = uint64(to) if config.Fragment.PacketsFrom == 0 { return nil, errors.New("PacketsFrom can't be 0") } } { - if c.Fragment.Length == "" { + if c.Fragment.Length == nil { return nil, errors.New("Length can't be empty") } - lengthMinMax := strings.Split(c.Fragment.Length, "-") - if len(lengthMinMax) == 2 { - config.Fragment.LengthMin, err = strconv.ParseUint(lengthMinMax[0], 10, 64) - config.Fragment.LengthMax, err2 = strconv.ParseUint(lengthMinMax[1], 10, 64) - } else { - config.Fragment.LengthMin, err = strconv.ParseUint(lengthMinMax[0], 10, 64) - config.Fragment.LengthMax = config.Fragment.LengthMin - } - if err != nil { - return nil, errors.New("Invalid LengthMin").Base(err) - } - if err2 != nil { - return nil, errors.New("Invalid LengthMax").Base(err2) - } - if config.Fragment.LengthMin > config.Fragment.LengthMax { - config.Fragment.LengthMin, config.Fragment.LengthMax = config.Fragment.LengthMax, config.Fragment.LengthMin - } + config.Fragment.LengthMin = uint64(c.Fragment.Length.From) + config.Fragment.LengthMax = uint64(c.Fragment.Length.To) if config.Fragment.LengthMin == 0 { return nil, errors.New("LengthMin can't be 0") } } { - if c.Fragment.Interval == "" { + if c.Fragment.Interval == nil { return nil, errors.New("Interval can't be empty") } - intervalMinMax := strings.Split(c.Fragment.Interval, "-") - if len(intervalMinMax) == 2 { - config.Fragment.IntervalMin, err = strconv.ParseUint(intervalMinMax[0], 10, 64) - config.Fragment.IntervalMax, err2 = strconv.ParseUint(intervalMinMax[1], 10, 64) - } else { - config.Fragment.IntervalMin, err = strconv.ParseUint(intervalMinMax[0], 10, 64) - config.Fragment.IntervalMax = config.Fragment.IntervalMin - } - if err != nil { - return nil, errors.New("Invalid IntervalMin").Base(err) - } - if err2 != nil { - return nil, errors.New("Invalid IntervalMax").Base(err2) - } - if config.Fragment.IntervalMin > config.Fragment.IntervalMax { - config.Fragment.IntervalMin, config.Fragment.IntervalMax = config.Fragment.IntervalMax, config.Fragment.IntervalMin - } + config.Fragment.IntervalMin = uint64(c.Fragment.Interval.From) + config.Fragment.IntervalMax = uint64(c.Fragment.Interval.To) } } @@ -193,29 +150,17 @@ func (c *FreedomConfig) Build() (proto.Message, error) { } func ParseNoise(noise *Noise) (*freedom.Noise, error) { - var err, err2 error + var err error NConfig := new(freedom.Noise) switch strings.ToLower(noise.Type) { case "rand": - randValue := strings.Split(noise.Packet, "-") - if len(randValue) > 2 { - return nil, errors.New("Only 2 values are allowed for rand") - } - if len(randValue) == 2 { - NConfig.LengthMin, err = strconv.ParseUint(randValue[0], 10, 64) - NConfig.LengthMax, err2 = strconv.ParseUint(randValue[1], 10, 64) - } - if len(randValue) == 1 { - NConfig.LengthMin, err = strconv.ParseUint(randValue[0], 10, 64) - NConfig.LengthMax = NConfig.LengthMin - } + min, max, err := ParseRangeString(noise.Packet) if err != nil { - return nil, errors.New("invalid value for rand LengthMin").Base(err) - } - if err2 != nil { - return nil, errors.New("invalid value for rand LengthMax").Base(err2) + return nil, errors.New("invalid value for rand Length").Base(err) } + NConfig.LengthMin = uint64(min) + NConfig.LengthMax = uint64(max) if NConfig.LengthMin > NConfig.LengthMax { NConfig.LengthMin, NConfig.LengthMax = NConfig.LengthMax, NConfig.LengthMin } From 86257531ee7469b9f4965d9fb75fd36c953891a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Tue, 15 Oct 2024 12:22:32 +0800 Subject: [PATCH 569/867] Routing: Add mutex for `Attributes` temporarily (#3908) https://github.com/XTLS/Xray-core/pull/3908#issuecomment-2412859858 --- common/session/session.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/common/session/session.go b/common/session/session.go index c926a883..deb01f8c 100644 --- a/common/session/session.go +++ b/common/session/session.go @@ -4,6 +4,7 @@ package session // import "github.com/xtls/xray-core/common/session" import ( "context" "math/rand" + "sync" c "github.com/xtls/xray-core/common/ctx" "github.com/xtls/xray-core/common/errors" @@ -65,7 +66,7 @@ type Outbound struct { Tag string // Name of the outbound proxy that handles the connection. Name string - // Conn is actually internet.Connection. May be nil. It is currently nil for outbound with proxySettings + // Conn is actually internet.Connection. May be nil. It is currently nil for outbound with proxySettings Conn net.Conn // CanSpliceCopy is a property for this connection // 1 = can, 2 = after processing protocol info should be able to, 3 = cannot @@ -91,6 +92,10 @@ type Content struct { Attributes map[string]string SkipDNSResolve bool + + mu sync.Mutex + + isLocked bool } // Sockopt is the settings for socket connection. @@ -99,8 +104,22 @@ type Sockopt struct { Mark int32 } +// Some how when using mux, there will be a same ctx between different requests +// This will cause problem as it's designed for single request, like concurrent map writes +// Add a Mutex as a temp solution + // SetAttribute attaches additional string attributes to content. func (c *Content) SetAttribute(name string, value string) { + if c.isLocked { + errors.LogError(context.Background(), "Multiple goroutines are tring to access one routing content, tring to write ", name, ":", value) + } + c.mu.Lock() + c.isLocked = true + defer func() { + c.isLocked = false + c.mu.Unlock() + }() + if c.Attributes == nil { c.Attributes = make(map[string]string) } From 897521defdfeb610ec0d7608b4f11ed55780485a Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 16 Oct 2024 03:47:41 +0000 Subject: [PATCH 570/867] XMUX: Change to non-infinity-reuse default values (#3919) --- infra/conf/transport_internet.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 838438a4..904505bf 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -243,7 +243,10 @@ type Xmux struct { func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { if input == nil { - return nil + return &splithttp.RandRangeConfig{ + From: 0, + To: 0, + } } return &splithttp.RandRangeConfig{ @@ -275,6 +278,16 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.CMaxLifetimeMs), } + if muxProtobuf.MaxConcurrency.To == 0 && + muxProtobuf.MaxConnections.To == 0 && + muxProtobuf.CMaxReuseTimes.To == 0 && + muxProtobuf.CMaxLifetimeMs.To == 0 { + muxProtobuf.MaxConcurrency.From = 16 + muxProtobuf.MaxConcurrency.To = 32 + muxProtobuf.CMaxReuseTimes.From = 64 + muxProtobuf.CMaxReuseTimes.To = 128 + } + config := &splithttp.Config{ Path: c.Path, Host: c.Host, From 47fad1fbfdcd7195b76accb1059c6e1abfafcc48 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 16 Oct 2024 04:01:04 +0000 Subject: [PATCH 571/867] Chore: Generate *.pb.go files with protoc v5.28.2 Download https://github.com/protocolbuffers/protobuf/releases/tag/v28.2 go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.35.1 go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 (Xray-core/) go run ./infra/vprotogen --- app/commander/config.pb.go | 50 +-- app/dispatcher/config.pb.go | 50 +-- app/dns/config.pb.go | 116 ++---- app/dns/fakedns/fakedns.pb.go | 50 +-- app/log/command/config.pb.go | 72 +--- app/log/command/config_grpc.pb.go | 2 +- app/log/config.pb.go | 28 +- app/metrics/config.pb.go | 28 +- app/observatory/burst/config.pb.go | 50 +-- app/observatory/command/command.pb.go | 72 +--- app/observatory/command/command_grpc.pb.go | 2 +- app/observatory/config.pb.go | 138 ++----- app/policy/config.pb.go | 182 ++-------- app/proxyman/command/command.pb.go | 336 ++++-------------- app/proxyman/command/command_grpc.pb.go | 2 +- app/proxyman/config.pb.go | 226 +++--------- app/reverse/config.pb.go | 94 +---- app/router/command/command.pb.go | 336 ++++-------------- app/router/command/command_grpc.pb.go | 2 +- app/router/config.pb.go | 270 +++----------- app/stats/command/command.pb.go | 182 ++-------- app/stats/command/command_grpc.pb.go | 2 +- app/stats/config.pb.go | 50 +-- common/log/log.pb.go | 4 +- common/net/address.pb.go | 28 +- common/net/destination.pb.go | 28 +- common/net/network.pb.go | 28 +- common/net/port.pb.go | 50 +-- common/protocol/headers.pb.go | 28 +- common/protocol/server_spec.pb.go | 28 +- common/protocol/user.pb.go | 28 +- common/serial/typed_message.pb.go | 28 +- core/config.pb.go | 72 +--- proxy/blackhole/config.pb.go | 72 +--- proxy/dns/config.pb.go | 28 +- proxy/dokodemo/config.pb.go | 28 +- proxy/freedom/config.pb.go | 94 +---- proxy/http/config.pb.go | 94 +---- proxy/loopback/config.pb.go | 28 +- proxy/shadowsocks/config.pb.go | 72 +--- proxy/shadowsocks_2022/config.pb.go | 138 ++----- proxy/socks/config.pb.go | 72 +--- proxy/trojan/config.pb.go | 94 +---- proxy/vless/account.pb.go | 28 +- proxy/vless/encoding/addons.pb.go | 28 +- proxy/vless/inbound/config.pb.go | 50 +-- proxy/vless/outbound/config.pb.go | 28 +- proxy/vmess/account.pb.go | 28 +- proxy/vmess/inbound/config.pb.go | 72 +--- proxy/vmess/outbound/config.pb.go | 28 +- proxy/wireguard/config.pb.go | 50 +-- transport/internet/config.pb.go | 116 ++---- transport/internet/grpc/config.pb.go | 28 +- transport/internet/grpc/encoding/stream.pb.go | 50 +-- .../internet/grpc/encoding/stream_grpc.pb.go | 2 +- transport/internet/headers/dns/config.pb.go | 28 +- transport/internet/headers/http/config.pb.go | 160 ++------- transport/internet/headers/noop/config.pb.go | 50 +-- transport/internet/headers/srtp/config.pb.go | 28 +- transport/internet/headers/tls/config.pb.go | 28 +- transport/internet/headers/utp/config.pb.go | 28 +- .../internet/headers/wechat/config.pb.go | 28 +- .../internet/headers/wireguard/config.pb.go | 28 +- transport/internet/http/config.pb.go | 28 +- transport/internet/httpupgrade/config.pb.go | 28 +- transport/internet/kcp/config.pb.go | 204 ++--------- transport/internet/reality/config.pb.go | 28 +- transport/internet/splithttp/config.pb.go | 72 +--- transport/internet/tcp/config.pb.go | 28 +- transport/internet/tls/config.pb.go | 50 +-- transport/internet/udp/config.pb.go | 28 +- transport/internet/websocket/config.pb.go | 28 +- 72 files changed, 930 insertions(+), 3832 deletions(-) diff --git a/app/commander/config.pb.go b/app/commander/config.pb.go index 1fb145c8..94c40413 100644 --- a/app/commander/config.pb.go +++ b/app/commander/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/commander/config.proto package commander @@ -38,11 +38,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_commander_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_commander_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -53,7 +51,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_commander_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -98,11 +96,9 @@ type ReflectionConfig struct { func (x *ReflectionConfig) Reset() { *x = ReflectionConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_commander_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_commander_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ReflectionConfig) String() string { @@ -113,7 +109,7 @@ func (*ReflectionConfig) ProtoMessage() {} func (x *ReflectionConfig) ProtoReflect() protoreflect.Message { mi := &file_app_commander_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -185,32 +181,6 @@ func file_app_commander_config_proto_init() { if File_app_commander_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_commander_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_commander_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ReflectionConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/dispatcher/config.pb.go b/app/dispatcher/config.pb.go index 9b8adb09..a196e2e1 100644 --- a/app/dispatcher/config.pb.go +++ b/app/dispatcher/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/dispatcher/config.proto package dispatcher @@ -28,11 +28,9 @@ type SessionConfig struct { func (x *SessionConfig) Reset() { *x = SessionConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_dispatcher_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_dispatcher_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SessionConfig) String() string { @@ -43,7 +41,7 @@ func (*SessionConfig) ProtoMessage() {} func (x *SessionConfig) ProtoReflect() protoreflect.Message { mi := &file_app_dispatcher_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -68,11 +66,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_dispatcher_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_dispatcher_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -83,7 +79,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_dispatcher_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -157,32 +153,6 @@ func file_app_dispatcher_config_proto_init() { if File_app_dispatcher_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_dispatcher_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*SessionConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_dispatcher_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index e2a9e6aa..05fd6099 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/dns/config.proto package dns @@ -139,11 +139,9 @@ type NameServer struct { func (x *NameServer) Reset() { *x = NameServer{} - if protoimpl.UnsafeEnabled { - mi := &file_app_dns_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_dns_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *NameServer) String() string { @@ -154,7 +152,7 @@ func (*NameServer) ProtoMessage() {} func (x *NameServer) ProtoReflect() protoreflect.Message { mi := &file_app_dns_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -241,11 +239,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_dns_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_dns_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -256,7 +252,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_dns_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -338,11 +334,9 @@ type NameServer_PriorityDomain struct { func (x *NameServer_PriorityDomain) Reset() { *x = NameServer_PriorityDomain{} - if protoimpl.UnsafeEnabled { - mi := &file_app_dns_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_dns_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *NameServer_PriorityDomain) String() string { @@ -353,7 +347,7 @@ func (*NameServer_PriorityDomain) ProtoMessage() {} func (x *NameServer_PriorityDomain) ProtoReflect() protoreflect.Message { mi := &file_app_dns_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -393,11 +387,9 @@ type NameServer_OriginalRule struct { func (x *NameServer_OriginalRule) Reset() { *x = NameServer_OriginalRule{} - if protoimpl.UnsafeEnabled { - mi := &file_app_dns_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_dns_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *NameServer_OriginalRule) String() string { @@ -408,7 +400,7 @@ func (*NameServer_OriginalRule) ProtoMessage() {} func (x *NameServer_OriginalRule) ProtoReflect() protoreflect.Message { mi := &file_app_dns_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -452,11 +444,9 @@ type Config_HostMapping struct { func (x *Config_HostMapping) Reset() { *x = Config_HostMapping{} - if protoimpl.UnsafeEnabled { - mi := &file_app_dns_config_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_dns_config_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config_HostMapping) String() string { @@ -467,7 +457,7 @@ func (*Config_HostMapping) ProtoMessage() {} func (x *Config_HostMapping) ProtoReflect() protoreflect.Message { mi := &file_app_dns_config_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -651,68 +641,6 @@ func file_app_dns_config_proto_init() { if File_app_dns_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_dns_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*NameServer); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_dns_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_dns_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*NameServer_PriorityDomain); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_dns_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*NameServer_OriginalRule); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_dns_config_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*Config_HostMapping); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/dns/fakedns/fakedns.pb.go b/app/dns/fakedns/fakedns.pb.go index a44e77b3..6160eaee 100644 --- a/app/dns/fakedns/fakedns.pb.go +++ b/app/dns/fakedns/fakedns.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/dns/fakedns/fakedns.proto package fakedns @@ -31,11 +31,9 @@ type FakeDnsPool struct { func (x *FakeDnsPool) Reset() { *x = FakeDnsPool{} - if protoimpl.UnsafeEnabled { - mi := &file_app_dns_fakedns_fakedns_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_dns_fakedns_fakedns_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *FakeDnsPool) String() string { @@ -46,7 +44,7 @@ func (*FakeDnsPool) ProtoMessage() {} func (x *FakeDnsPool) ProtoReflect() protoreflect.Message { mi := &file_app_dns_fakedns_fakedns_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -85,11 +83,9 @@ type FakeDnsPoolMulti struct { func (x *FakeDnsPoolMulti) Reset() { *x = FakeDnsPoolMulti{} - if protoimpl.UnsafeEnabled { - mi := &file_app_dns_fakedns_fakedns_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_dns_fakedns_fakedns_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *FakeDnsPoolMulti) String() string { @@ -100,7 +96,7 @@ func (*FakeDnsPoolMulti) ProtoMessage() {} func (x *FakeDnsPoolMulti) ProtoReflect() protoreflect.Message { mi := &file_app_dns_fakedns_fakedns_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -177,32 +173,6 @@ func file_app_dns_fakedns_fakedns_proto_init() { if File_app_dns_fakedns_fakedns_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_dns_fakedns_fakedns_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*FakeDnsPool); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_dns_fakedns_fakedns_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*FakeDnsPoolMulti); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/log/command/config.pb.go b/app/log/command/config.pb.go index a6fd81cd..5cb5e43c 100644 --- a/app/log/command/config.pb.go +++ b/app/log/command/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/log/command/config.proto package command @@ -28,11 +28,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_log_command_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_log_command_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -43,7 +41,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_log_command_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -66,11 +64,9 @@ type RestartLoggerRequest struct { func (x *RestartLoggerRequest) Reset() { *x = RestartLoggerRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_log_command_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_log_command_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RestartLoggerRequest) String() string { @@ -81,7 +77,7 @@ func (*RestartLoggerRequest) ProtoMessage() {} func (x *RestartLoggerRequest) ProtoReflect() protoreflect.Message { mi := &file_app_log_command_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -104,11 +100,9 @@ type RestartLoggerResponse struct { func (x *RestartLoggerResponse) Reset() { *x = RestartLoggerResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_log_command_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_log_command_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RestartLoggerResponse) String() string { @@ -119,7 +113,7 @@ func (*RestartLoggerResponse) ProtoMessage() {} func (x *RestartLoggerResponse) ProtoReflect() protoreflect.Message { mi := &file_app_log_command_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -194,44 +188,6 @@ func file_app_log_command_config_proto_init() { if File_app_log_command_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_log_command_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_log_command_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*RestartLoggerRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_log_command_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*RestartLoggerResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/log/command/config_grpc.pb.go b/app/log/command/config_grpc.pb.go index 2eb9bb66..492e998d 100644 --- a/app/log/command/config_grpc.pb.go +++ b/app/log/command/config_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.27.0 +// - protoc v5.28.2 // source: app/log/command/config.proto package command diff --git a/app/log/config.pb.go b/app/log/config.pb.go index 43197238..6a07685d 100644 --- a/app/log/config.pb.go +++ b/app/log/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/log/config.proto package log @@ -89,11 +89,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_log_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_log_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -104,7 +102,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_log_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -243,20 +241,6 @@ func file_app_log_config_proto_init() { if File_app_log_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_log_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/metrics/config.pb.go b/app/metrics/config.pb.go index 5544b24f..d62dcef9 100644 --- a/app/metrics/config.pb.go +++ b/app/metrics/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/metrics/config.proto package metrics @@ -32,11 +32,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_metrics_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_metrics_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -47,7 +45,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_metrics_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -114,20 +112,6 @@ func file_app_metrics_config_proto_init() { if File_app_metrics_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_metrics_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/observatory/burst/config.pb.go b/app/observatory/burst/config.pb.go index b38f9d8b..ffbd0689 100644 --- a/app/observatory/burst/config.pb.go +++ b/app/observatory/burst/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/observatory/burst/config.proto package burst @@ -32,11 +32,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_burst_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_burst_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -47,7 +45,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_burst_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -96,11 +94,9 @@ type HealthPingConfig struct { func (x *HealthPingConfig) Reset() { *x = HealthPingConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_burst_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_burst_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *HealthPingConfig) String() string { @@ -111,7 +107,7 @@ func (*HealthPingConfig) ProtoMessage() {} func (x *HealthPingConfig) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_burst_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -229,32 +225,6 @@ func file_app_observatory_burst_config_proto_init() { if File_app_observatory_burst_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_observatory_burst_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_observatory_burst_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*HealthPingConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/observatory/command/command.pb.go b/app/observatory/command/command.pb.go index 3b239e79..4c253081 100644 --- a/app/observatory/command/command.pb.go +++ b/app/observatory/command/command.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/observatory/command/command.proto package command @@ -29,11 +29,9 @@ type GetOutboundStatusRequest struct { func (x *GetOutboundStatusRequest) Reset() { *x = GetOutboundStatusRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_command_command_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_command_command_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetOutboundStatusRequest) String() string { @@ -44,7 +42,7 @@ func (*GetOutboundStatusRequest) ProtoMessage() {} func (x *GetOutboundStatusRequest) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_command_command_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -69,11 +67,9 @@ type GetOutboundStatusResponse struct { func (x *GetOutboundStatusResponse) Reset() { *x = GetOutboundStatusResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_command_command_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_command_command_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetOutboundStatusResponse) String() string { @@ -84,7 +80,7 @@ func (*GetOutboundStatusResponse) ProtoMessage() {} func (x *GetOutboundStatusResponse) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_command_command_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -114,11 +110,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_command_command_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_command_command_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -129,7 +123,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_command_command_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -219,44 +213,6 @@ func file_app_observatory_command_command_proto_init() { if File_app_observatory_command_command_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_observatory_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*GetOutboundStatusRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_observatory_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*GetOutboundStatusResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_observatory_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/observatory/command/command_grpc.pb.go b/app/observatory/command/command_grpc.pb.go index 18d29092..3b1e3be7 100644 --- a/app/observatory/command/command_grpc.pb.go +++ b/app/observatory/command/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.27.0 +// - protoc v5.28.2 // source: app/observatory/command/command.proto package command diff --git a/app/observatory/config.pb.go b/app/observatory/config.pb.go index a6a97d69..1e39af6c 100644 --- a/app/observatory/config.pb.go +++ b/app/observatory/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/observatory/config.proto package observatory @@ -30,11 +30,9 @@ type ObservationResult struct { func (x *ObservationResult) Reset() { *x = ObservationResult{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ObservationResult) String() string { @@ -45,7 +43,7 @@ func (*ObservationResult) ProtoMessage() {} func (x *ObservationResult) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -82,11 +80,9 @@ type HealthPingMeasurementResult struct { func (x *HealthPingMeasurementResult) Reset() { *x = HealthPingMeasurementResult{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *HealthPingMeasurementResult) String() string { @@ -97,7 +93,7 @@ func (*HealthPingMeasurementResult) ProtoMessage() {} func (x *HealthPingMeasurementResult) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -183,11 +179,9 @@ type OutboundStatus struct { func (x *OutboundStatus) Reset() { *x = OutboundStatus{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *OutboundStatus) String() string { @@ -198,7 +192,7 @@ func (*OutboundStatus) ProtoMessage() {} func (x *OutboundStatus) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -281,11 +275,9 @@ type ProbeResult struct { func (x *ProbeResult) Reset() { *x = ProbeResult{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProbeResult) String() string { @@ -296,7 +288,7 @@ func (*ProbeResult) ProtoMessage() {} func (x *ProbeResult) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -344,11 +336,9 @@ type Intensity struct { func (x *Intensity) Reset() { *x = Intensity{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_config_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_config_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Intensity) String() string { @@ -359,7 +349,7 @@ func (*Intensity) ProtoMessage() {} func (x *Intensity) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_config_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -395,11 +385,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_observatory_config_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_observatory_config_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -410,7 +398,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_observatory_config_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -559,80 +547,6 @@ func file_app_observatory_config_proto_init() { if File_app_observatory_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_observatory_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*ObservationResult); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_observatory_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*HealthPingMeasurementResult); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_observatory_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*OutboundStatus); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_observatory_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*ProbeResult); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_observatory_config_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*Intensity); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_observatory_config_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/policy/config.pb.go b/app/policy/config.pb.go index 2ebdd61f..2c8262a3 100644 --- a/app/policy/config.pb.go +++ b/app/policy/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/policy/config.proto package policy @@ -30,11 +30,9 @@ type Second struct { func (x *Second) Reset() { *x = Second{} - if protoimpl.UnsafeEnabled { - mi := &file_app_policy_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_policy_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Second) String() string { @@ -45,7 +43,7 @@ func (*Second) ProtoMessage() {} func (x *Second) ProtoReflect() protoreflect.Message { mi := &file_app_policy_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -79,11 +77,9 @@ type Policy struct { func (x *Policy) Reset() { *x = Policy{} - if protoimpl.UnsafeEnabled { - mi := &file_app_policy_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_policy_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Policy) String() string { @@ -94,7 +90,7 @@ func (*Policy) ProtoMessage() {} func (x *Policy) ProtoReflect() protoreflect.Message { mi := &file_app_policy_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -140,11 +136,9 @@ type SystemPolicy struct { func (x *SystemPolicy) Reset() { *x = SystemPolicy{} - if protoimpl.UnsafeEnabled { - mi := &file_app_policy_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_policy_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SystemPolicy) String() string { @@ -155,7 +149,7 @@ func (*SystemPolicy) ProtoMessage() {} func (x *SystemPolicy) ProtoReflect() protoreflect.Message { mi := &file_app_policy_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -188,11 +182,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_policy_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_policy_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -203,7 +195,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_policy_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -246,11 +238,9 @@ type Policy_Timeout struct { func (x *Policy_Timeout) Reset() { *x = Policy_Timeout{} - if protoimpl.UnsafeEnabled { - mi := &file_app_policy_config_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_policy_config_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Policy_Timeout) String() string { @@ -261,7 +251,7 @@ func (*Policy_Timeout) ProtoMessage() {} func (x *Policy_Timeout) ProtoReflect() protoreflect.Message { mi := &file_app_policy_config_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -315,11 +305,9 @@ type Policy_Stats struct { func (x *Policy_Stats) Reset() { *x = Policy_Stats{} - if protoimpl.UnsafeEnabled { - mi := &file_app_policy_config_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_policy_config_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Policy_Stats) String() string { @@ -330,7 +318,7 @@ func (*Policy_Stats) ProtoMessage() {} func (x *Policy_Stats) ProtoReflect() protoreflect.Message { mi := &file_app_policy_config_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -370,11 +358,9 @@ type Policy_Buffer struct { func (x *Policy_Buffer) Reset() { *x = Policy_Buffer{} - if protoimpl.UnsafeEnabled { - mi := &file_app_policy_config_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_policy_config_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Policy_Buffer) String() string { @@ -385,7 +371,7 @@ func (*Policy_Buffer) ProtoMessage() {} func (x *Policy_Buffer) ProtoReflect() protoreflect.Message { mi := &file_app_policy_config_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -420,11 +406,9 @@ type SystemPolicy_Stats struct { func (x *SystemPolicy_Stats) Reset() { *x = SystemPolicy_Stats{} - if protoimpl.UnsafeEnabled { - mi := &file_app_policy_config_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_policy_config_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SystemPolicy_Stats) String() string { @@ -435,7 +419,7 @@ func (*SystemPolicy_Stats) ProtoMessage() {} func (x *SystemPolicy_Stats) ProtoReflect() protoreflect.Message { mi := &file_app_policy_config_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -605,104 +589,6 @@ func file_app_policy_config_proto_init() { if File_app_policy_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_policy_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Second); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Policy); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*SystemPolicy); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*Policy_Timeout); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*Policy_Stats); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*Policy_Buffer); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*SystemPolicy_Stats); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index a3cb5526..32a29cc6 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/proxyman/command/command.proto package command @@ -33,11 +33,9 @@ type AddUserOperation struct { func (x *AddUserOperation) Reset() { *x = AddUserOperation{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AddUserOperation) String() string { @@ -48,7 +46,7 @@ func (*AddUserOperation) ProtoMessage() {} func (x *AddUserOperation) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -80,11 +78,9 @@ type RemoveUserOperation struct { func (x *RemoveUserOperation) Reset() { *x = RemoveUserOperation{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RemoveUserOperation) String() string { @@ -95,7 +91,7 @@ func (*RemoveUserOperation) ProtoMessage() {} func (x *RemoveUserOperation) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -127,11 +123,9 @@ type AddInboundRequest struct { func (x *AddInboundRequest) Reset() { *x = AddInboundRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AddInboundRequest) String() string { @@ -142,7 +136,7 @@ func (*AddInboundRequest) ProtoMessage() {} func (x *AddInboundRequest) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -172,11 +166,9 @@ type AddInboundResponse struct { func (x *AddInboundResponse) Reset() { *x = AddInboundResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AddInboundResponse) String() string { @@ -187,7 +179,7 @@ func (*AddInboundResponse) ProtoMessage() {} func (x *AddInboundResponse) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -212,11 +204,9 @@ type RemoveInboundRequest struct { func (x *RemoveInboundRequest) Reset() { *x = RemoveInboundRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RemoveInboundRequest) String() string { @@ -227,7 +217,7 @@ func (*RemoveInboundRequest) ProtoMessage() {} func (x *RemoveInboundRequest) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -257,11 +247,9 @@ type RemoveInboundResponse struct { func (x *RemoveInboundResponse) Reset() { *x = RemoveInboundResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RemoveInboundResponse) String() string { @@ -272,7 +260,7 @@ func (*RemoveInboundResponse) ProtoMessage() {} func (x *RemoveInboundResponse) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -298,11 +286,9 @@ type AlterInboundRequest struct { func (x *AlterInboundRequest) Reset() { *x = AlterInboundRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AlterInboundRequest) String() string { @@ -313,7 +299,7 @@ func (*AlterInboundRequest) ProtoMessage() {} func (x *AlterInboundRequest) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -350,11 +336,9 @@ type AlterInboundResponse struct { func (x *AlterInboundResponse) Reset() { *x = AlterInboundResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AlterInboundResponse) String() string { @@ -365,7 +349,7 @@ func (*AlterInboundResponse) ProtoMessage() {} func (x *AlterInboundResponse) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -390,11 +374,9 @@ type AddOutboundRequest struct { func (x *AddOutboundRequest) Reset() { *x = AddOutboundRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AddOutboundRequest) String() string { @@ -405,7 +387,7 @@ func (*AddOutboundRequest) ProtoMessage() {} func (x *AddOutboundRequest) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -435,11 +417,9 @@ type AddOutboundResponse struct { func (x *AddOutboundResponse) Reset() { *x = AddOutboundResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AddOutboundResponse) String() string { @@ -450,7 +430,7 @@ func (*AddOutboundResponse) ProtoMessage() {} func (x *AddOutboundResponse) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -475,11 +455,9 @@ type RemoveOutboundRequest struct { func (x *RemoveOutboundRequest) Reset() { *x = RemoveOutboundRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RemoveOutboundRequest) String() string { @@ -490,7 +468,7 @@ func (*RemoveOutboundRequest) ProtoMessage() {} func (x *RemoveOutboundRequest) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -520,11 +498,9 @@ type RemoveOutboundResponse struct { func (x *RemoveOutboundResponse) Reset() { *x = RemoveOutboundResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RemoveOutboundResponse) String() string { @@ -535,7 +511,7 @@ func (*RemoveOutboundResponse) ProtoMessage() {} func (x *RemoveOutboundResponse) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -561,11 +537,9 @@ type AlterOutboundRequest struct { func (x *AlterOutboundRequest) Reset() { *x = AlterOutboundRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AlterOutboundRequest) String() string { @@ -576,7 +550,7 @@ func (*AlterOutboundRequest) ProtoMessage() {} func (x *AlterOutboundRequest) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -613,11 +587,9 @@ type AlterOutboundResponse struct { func (x *AlterOutboundResponse) Reset() { *x = AlterOutboundResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AlterOutboundResponse) String() string { @@ -628,7 +600,7 @@ func (*AlterOutboundResponse) ProtoMessage() {} func (x *AlterOutboundResponse) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -651,11 +623,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_command_command_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_command_command_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -666,7 +636,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_command_command_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -857,188 +827,6 @@ func file_app_proxyman_command_command_proto_init() { if File_app_proxyman_command_command_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_proxyman_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*AddUserOperation); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*RemoveUserOperation); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*AddInboundRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*AddInboundResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*RemoveInboundRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*RemoveInboundResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*AlterInboundRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*AlterInboundResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*AddOutboundRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*AddOutboundResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[10].Exporter = func(v any, i int) any { - switch v := v.(*RemoveOutboundRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[11].Exporter = func(v any, i int) any { - switch v := v.(*RemoveOutboundResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[12].Exporter = func(v any, i int) any { - switch v := v.(*AlterOutboundRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[13].Exporter = func(v any, i int) any { - switch v := v.(*AlterOutboundResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_command_command_proto_msgTypes[14].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/proxyman/command/command_grpc.pb.go b/app/proxyman/command/command_grpc.pb.go index de11193a..4f12836b 100644 --- a/app/proxyman/command/command_grpc.pb.go +++ b/app/proxyman/command/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.27.0 +// - protoc v5.28.2 // source: app/proxyman/command/command.proto package command diff --git a/app/proxyman/config.pb.go b/app/proxyman/config.pb.go index 5ba3ac56..d644e3d1 100644 --- a/app/proxyman/config.pb.go +++ b/app/proxyman/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/proxyman/config.proto package proxyman @@ -83,11 +83,9 @@ type InboundConfig struct { func (x *InboundConfig) Reset() { *x = InboundConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *InboundConfig) String() string { @@ -98,7 +96,7 @@ func (*InboundConfig) ProtoMessage() {} func (x *InboundConfig) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -129,11 +127,9 @@ type AllocationStrategy struct { func (x *AllocationStrategy) Reset() { *x = AllocationStrategy{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllocationStrategy) String() string { @@ -144,7 +140,7 @@ func (*AllocationStrategy) ProtoMessage() {} func (x *AllocationStrategy) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -200,11 +196,9 @@ type SniffingConfig struct { func (x *SniffingConfig) Reset() { *x = SniffingConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SniffingConfig) String() string { @@ -215,7 +209,7 @@ func (*SniffingConfig) ProtoMessage() {} func (x *SniffingConfig) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -282,11 +276,9 @@ type ReceiverConfig struct { func (x *ReceiverConfig) Reset() { *x = ReceiverConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ReceiverConfig) String() string { @@ -297,7 +289,7 @@ func (*ReceiverConfig) ProtoMessage() {} func (x *ReceiverConfig) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -366,11 +358,9 @@ type InboundHandlerConfig struct { func (x *InboundHandlerConfig) Reset() { *x = InboundHandlerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_config_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_config_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *InboundHandlerConfig) String() string { @@ -381,7 +371,7 @@ func (*InboundHandlerConfig) ProtoMessage() {} func (x *InboundHandlerConfig) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_config_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -425,11 +415,9 @@ type OutboundConfig struct { func (x *OutboundConfig) Reset() { *x = OutboundConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_config_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_config_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *OutboundConfig) String() string { @@ -440,7 +428,7 @@ func (*OutboundConfig) ProtoMessage() {} func (x *OutboundConfig) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_config_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -470,11 +458,9 @@ type SenderConfig struct { func (x *SenderConfig) Reset() { *x = SenderConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_config_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_config_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SenderConfig) String() string { @@ -485,7 +471,7 @@ func (*SenderConfig) ProtoMessage() {} func (x *SenderConfig) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_config_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -552,11 +538,9 @@ type MultiplexingConfig struct { func (x *MultiplexingConfig) Reset() { *x = MultiplexingConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_config_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_config_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *MultiplexingConfig) String() string { @@ -567,7 +551,7 @@ func (*MultiplexingConfig) ProtoMessage() {} func (x *MultiplexingConfig) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_config_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -620,11 +604,9 @@ type AllocationStrategy_AllocationStrategyConcurrency struct { func (x *AllocationStrategy_AllocationStrategyConcurrency) Reset() { *x = AllocationStrategy_AllocationStrategyConcurrency{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_config_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_config_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllocationStrategy_AllocationStrategyConcurrency) String() string { @@ -635,7 +617,7 @@ func (*AllocationStrategy_AllocationStrategyConcurrency) ProtoMessage() {} func (x *AllocationStrategy_AllocationStrategyConcurrency) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_config_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -667,11 +649,9 @@ type AllocationStrategy_AllocationStrategyRefresh struct { func (x *AllocationStrategy_AllocationStrategyRefresh) Reset() { *x = AllocationStrategy_AllocationStrategyRefresh{} - if protoimpl.UnsafeEnabled { - mi := &file_app_proxyman_config_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_proxyman_config_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AllocationStrategy_AllocationStrategyRefresh) String() string { @@ -682,7 +662,7 @@ func (*AllocationStrategy_AllocationStrategyRefresh) ProtoMessage() {} func (x *AllocationStrategy_AllocationStrategyRefresh) ProtoReflect() protoreflect.Message { mi := &file_app_proxyman_config_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -898,128 +878,6 @@ func file_app_proxyman_config_proto_init() { if File_app_proxyman_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_proxyman_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*InboundConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*AllocationStrategy); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*SniffingConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*ReceiverConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_config_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*InboundHandlerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_config_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*OutboundConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_config_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*SenderConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_config_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*MultiplexingConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_config_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*AllocationStrategy_AllocationStrategyConcurrency); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_proxyman_config_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*AllocationStrategy_AllocationStrategyRefresh); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/reverse/config.pb.go b/app/reverse/config.pb.go index f2578d1f..e9865d86 100644 --- a/app/reverse/config.pb.go +++ b/app/reverse/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/reverse/config.proto package reverse @@ -77,11 +77,9 @@ type Control struct { func (x *Control) Reset() { *x = Control{} - if protoimpl.UnsafeEnabled { - mi := &file_app_reverse_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_reverse_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Control) String() string { @@ -92,7 +90,7 @@ func (*Control) ProtoMessage() {} func (x *Control) ProtoReflect() protoreflect.Message { mi := &file_app_reverse_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -132,11 +130,9 @@ type BridgeConfig struct { func (x *BridgeConfig) Reset() { *x = BridgeConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_reverse_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_reverse_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *BridgeConfig) String() string { @@ -147,7 +143,7 @@ func (*BridgeConfig) ProtoMessage() {} func (x *BridgeConfig) ProtoReflect() protoreflect.Message { mi := &file_app_reverse_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -187,11 +183,9 @@ type PortalConfig struct { func (x *PortalConfig) Reset() { *x = PortalConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_reverse_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_reverse_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PortalConfig) String() string { @@ -202,7 +196,7 @@ func (*PortalConfig) ProtoMessage() {} func (x *PortalConfig) ProtoReflect() protoreflect.Message { mi := &file_app_reverse_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -242,11 +236,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_reverse_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_reverse_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -257,7 +249,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_reverse_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -361,56 +353,6 @@ func file_app_reverse_config_proto_init() { if File_app_reverse_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_reverse_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Control); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_reverse_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*BridgeConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_reverse_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*PortalConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_reverse_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/router/command/command.pb.go b/app/router/command/command.pb.go index 4b7cde3e..6e388901 100644 --- a/app/router/command/command.pb.go +++ b/app/router/command/command.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/router/command/command.proto package command @@ -46,11 +46,9 @@ type RoutingContext struct { func (x *RoutingContext) Reset() { *x = RoutingContext{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RoutingContext) String() string { @@ -61,7 +59,7 @@ func (*RoutingContext) ProtoMessage() {} func (x *RoutingContext) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -188,11 +186,9 @@ type SubscribeRoutingStatsRequest struct { func (x *SubscribeRoutingStatsRequest) Reset() { *x = SubscribeRoutingStatsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SubscribeRoutingStatsRequest) String() string { @@ -203,7 +199,7 @@ func (*SubscribeRoutingStatsRequest) ProtoMessage() {} func (x *SubscribeRoutingStatsRequest) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -244,11 +240,9 @@ type TestRouteRequest struct { func (x *TestRouteRequest) Reset() { *x = TestRouteRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TestRouteRequest) String() string { @@ -259,7 +253,7 @@ func (*TestRouteRequest) ProtoMessage() {} func (x *TestRouteRequest) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -305,11 +299,9 @@ type PrincipleTargetInfo struct { func (x *PrincipleTargetInfo) Reset() { *x = PrincipleTargetInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PrincipleTargetInfo) String() string { @@ -320,7 +312,7 @@ func (*PrincipleTargetInfo) ProtoMessage() {} func (x *PrincipleTargetInfo) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -352,11 +344,9 @@ type OverrideInfo struct { func (x *OverrideInfo) Reset() { *x = OverrideInfo{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *OverrideInfo) String() string { @@ -367,7 +357,7 @@ func (*OverrideInfo) ProtoMessage() {} func (x *OverrideInfo) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -400,11 +390,9 @@ type BalancerMsg struct { func (x *BalancerMsg) Reset() { *x = BalancerMsg{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *BalancerMsg) String() string { @@ -415,7 +403,7 @@ func (*BalancerMsg) ProtoMessage() {} func (x *BalancerMsg) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -454,11 +442,9 @@ type GetBalancerInfoRequest struct { func (x *GetBalancerInfoRequest) Reset() { *x = GetBalancerInfoRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetBalancerInfoRequest) String() string { @@ -469,7 +455,7 @@ func (*GetBalancerInfoRequest) ProtoMessage() {} func (x *GetBalancerInfoRequest) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -501,11 +487,9 @@ type GetBalancerInfoResponse struct { func (x *GetBalancerInfoResponse) Reset() { *x = GetBalancerInfoResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetBalancerInfoResponse) String() string { @@ -516,7 +500,7 @@ func (*GetBalancerInfoResponse) ProtoMessage() {} func (x *GetBalancerInfoResponse) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -549,11 +533,9 @@ type OverrideBalancerTargetRequest struct { func (x *OverrideBalancerTargetRequest) Reset() { *x = OverrideBalancerTargetRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *OverrideBalancerTargetRequest) String() string { @@ -564,7 +546,7 @@ func (*OverrideBalancerTargetRequest) ProtoMessage() {} func (x *OverrideBalancerTargetRequest) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -601,11 +583,9 @@ type OverrideBalancerTargetResponse struct { func (x *OverrideBalancerTargetResponse) Reset() { *x = OverrideBalancerTargetResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *OverrideBalancerTargetResponse) String() string { @@ -616,7 +596,7 @@ func (*OverrideBalancerTargetResponse) ProtoMessage() {} func (x *OverrideBalancerTargetResponse) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -642,11 +622,9 @@ type AddRuleRequest struct { func (x *AddRuleRequest) Reset() { *x = AddRuleRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AddRuleRequest) String() string { @@ -657,7 +635,7 @@ func (*AddRuleRequest) ProtoMessage() {} func (x *AddRuleRequest) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -694,11 +672,9 @@ type AddRuleResponse struct { func (x *AddRuleResponse) Reset() { *x = AddRuleResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *AddRuleResponse) String() string { @@ -709,7 +685,7 @@ func (*AddRuleResponse) ProtoMessage() {} func (x *AddRuleResponse) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -734,11 +710,9 @@ type RemoveRuleRequest struct { func (x *RemoveRuleRequest) Reset() { *x = RemoveRuleRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[12] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RemoveRuleRequest) String() string { @@ -749,7 +723,7 @@ func (*RemoveRuleRequest) ProtoMessage() {} func (x *RemoveRuleRequest) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[12] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -779,11 +753,9 @@ type RemoveRuleResponse struct { func (x *RemoveRuleResponse) Reset() { *x = RemoveRuleResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[13] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RemoveRuleResponse) String() string { @@ -794,7 +766,7 @@ func (*RemoveRuleResponse) ProtoMessage() {} func (x *RemoveRuleResponse) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[13] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -817,11 +789,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_command_command_proto_msgTypes[14] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_command_command_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -832,7 +802,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_router_command_command_proto_msgTypes[14] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1071,188 +1041,6 @@ func file_app_router_command_command_proto_init() { if File_app_router_command_command_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_router_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*RoutingContext); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*SubscribeRoutingStatsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*TestRouteRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*PrincipleTargetInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*OverrideInfo); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*BalancerMsg); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*GetBalancerInfoRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*GetBalancerInfoResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*OverrideBalancerTargetRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*OverrideBalancerTargetResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[10].Exporter = func(v any, i int) any { - switch v := v.(*AddRuleRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[11].Exporter = func(v any, i int) any { - switch v := v.(*AddRuleResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[12].Exporter = func(v any, i int) any { - switch v := v.(*RemoveRuleRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[13].Exporter = func(v any, i int) any { - switch v := v.(*RemoveRuleResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_command_command_proto_msgTypes[14].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/router/command/command_grpc.pb.go b/app/router/command/command_grpc.pb.go index 018cbe06..23e03c8a 100644 --- a/app/router/command/command_grpc.pb.go +++ b/app/router/command/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.27.0 +// - protoc v5.28.2 // source: app/router/command/command.proto package command diff --git a/app/router/config.pb.go b/app/router/config.pb.go index b214d12a..ca6cc38f 100644 --- a/app/router/config.pb.go +++ b/app/router/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/router/config.proto package router @@ -151,11 +151,9 @@ type Domain struct { func (x *Domain) Reset() { *x = Domain{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Domain) String() string { @@ -166,7 +164,7 @@ func (*Domain) ProtoMessage() {} func (x *Domain) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -216,11 +214,9 @@ type CIDR struct { func (x *CIDR) Reset() { *x = CIDR{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CIDR) String() string { @@ -231,7 +227,7 @@ func (*CIDR) ProtoMessage() {} func (x *CIDR) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -272,11 +268,9 @@ type GeoIP struct { func (x *GeoIP) Reset() { *x = GeoIP{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GeoIP) String() string { @@ -287,7 +281,7 @@ func (*GeoIP) ProtoMessage() {} func (x *GeoIP) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -333,11 +327,9 @@ type GeoIPList struct { func (x *GeoIPList) Reset() { *x = GeoIPList{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GeoIPList) String() string { @@ -348,7 +340,7 @@ func (*GeoIPList) ProtoMessage() {} func (x *GeoIPList) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -381,11 +373,9 @@ type GeoSite struct { func (x *GeoSite) Reset() { *x = GeoSite{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GeoSite) String() string { @@ -396,7 +386,7 @@ func (*GeoSite) ProtoMessage() {} func (x *GeoSite) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -435,11 +425,9 @@ type GeoSiteList struct { func (x *GeoSiteList) Reset() { *x = GeoSiteList{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GeoSiteList) String() string { @@ -450,7 +438,7 @@ func (*GeoSiteList) ProtoMessage() {} func (x *GeoSiteList) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -508,11 +496,9 @@ type RoutingRule struct { func (x *RoutingRule) Reset() { *x = RoutingRule{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RoutingRule) String() string { @@ -523,7 +509,7 @@ func (*RoutingRule) ProtoMessage() {} func (x *RoutingRule) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -675,11 +661,9 @@ type BalancingRule struct { func (x *BalancingRule) Reset() { *x = BalancingRule{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *BalancingRule) String() string { @@ -690,7 +674,7 @@ func (*BalancingRule) ProtoMessage() {} func (x *BalancingRule) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -752,11 +736,9 @@ type StrategyWeight struct { func (x *StrategyWeight) Reset() { *x = StrategyWeight{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *StrategyWeight) String() string { @@ -767,7 +749,7 @@ func (*StrategyWeight) ProtoMessage() {} func (x *StrategyWeight) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -822,11 +804,9 @@ type StrategyLeastLoadConfig struct { func (x *StrategyLeastLoadConfig) Reset() { *x = StrategyLeastLoadConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *StrategyLeastLoadConfig) String() string { @@ -837,7 +817,7 @@ func (*StrategyLeastLoadConfig) ProtoMessage() {} func (x *StrategyLeastLoadConfig) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -899,11 +879,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[10] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -914,7 +892,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[10] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -965,11 +943,9 @@ type Domain_Attribute struct { func (x *Domain_Attribute) Reset() { *x = Domain_Attribute{} - if protoimpl.UnsafeEnabled { - mi := &file_app_router_config_proto_msgTypes[11] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_router_config_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Domain_Attribute) String() string { @@ -980,7 +956,7 @@ func (*Domain_Attribute) ProtoMessage() {} func (x *Domain_Attribute) ProtoReflect() protoreflect.Message { mi := &file_app_router_config_proto_msgTypes[11] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -1261,152 +1237,6 @@ func file_app_router_config_proto_init() { if File_app_router_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_router_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Domain); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*CIDR); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*GeoIP); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*GeoIPList); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*GeoSite); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*GeoSiteList); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*RoutingRule); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*BalancingRule); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*StrategyWeight); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[9].Exporter = func(v any, i int) any { - switch v := v.(*StrategyLeastLoadConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[10].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_router_config_proto_msgTypes[11].Exporter = func(v any, i int) any { - switch v := v.(*Domain_Attribute); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } file_app_router_config_proto_msgTypes[6].OneofWrappers = []any{ (*RoutingRule_Tag)(nil), (*RoutingRule_BalancingTag)(nil), diff --git a/app/stats/command/command.pb.go b/app/stats/command/command.pb.go index cbfe2aa3..af8ca346 100644 --- a/app/stats/command/command.pb.go +++ b/app/stats/command/command.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/stats/command/command.proto package command @@ -33,11 +33,9 @@ type GetStatsRequest struct { func (x *GetStatsRequest) Reset() { *x = GetStatsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_stats_command_command_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_stats_command_command_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetStatsRequest) String() string { @@ -48,7 +46,7 @@ func (*GetStatsRequest) ProtoMessage() {} func (x *GetStatsRequest) ProtoReflect() protoreflect.Message { mi := &file_app_stats_command_command_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -88,11 +86,9 @@ type Stat struct { func (x *Stat) Reset() { *x = Stat{} - if protoimpl.UnsafeEnabled { - mi := &file_app_stats_command_command_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_stats_command_command_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Stat) String() string { @@ -103,7 +99,7 @@ func (*Stat) ProtoMessage() {} func (x *Stat) ProtoReflect() protoreflect.Message { mi := &file_app_stats_command_command_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -142,11 +138,9 @@ type GetStatsResponse struct { func (x *GetStatsResponse) Reset() { *x = GetStatsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_stats_command_command_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_stats_command_command_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *GetStatsResponse) String() string { @@ -157,7 +151,7 @@ func (*GetStatsResponse) ProtoMessage() {} func (x *GetStatsResponse) ProtoReflect() protoreflect.Message { mi := &file_app_stats_command_command_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -190,11 +184,9 @@ type QueryStatsRequest struct { func (x *QueryStatsRequest) Reset() { *x = QueryStatsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_stats_command_command_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_stats_command_command_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *QueryStatsRequest) String() string { @@ -205,7 +197,7 @@ func (*QueryStatsRequest) ProtoMessage() {} func (x *QueryStatsRequest) ProtoReflect() protoreflect.Message { mi := &file_app_stats_command_command_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -244,11 +236,9 @@ type QueryStatsResponse struct { func (x *QueryStatsResponse) Reset() { *x = QueryStatsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_stats_command_command_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_stats_command_command_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *QueryStatsResponse) String() string { @@ -259,7 +249,7 @@ func (*QueryStatsResponse) ProtoMessage() {} func (x *QueryStatsResponse) ProtoReflect() protoreflect.Message { mi := &file_app_stats_command_command_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -289,11 +279,9 @@ type SysStatsRequest struct { func (x *SysStatsRequest) Reset() { *x = SysStatsRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_app_stats_command_command_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_stats_command_command_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SysStatsRequest) String() string { @@ -304,7 +292,7 @@ func (*SysStatsRequest) ProtoMessage() {} func (x *SysStatsRequest) ProtoReflect() protoreflect.Message { mi := &file_app_stats_command_command_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -338,11 +326,9 @@ type SysStatsResponse struct { func (x *SysStatsResponse) Reset() { *x = SysStatsResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_app_stats_command_command_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_stats_command_command_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SysStatsResponse) String() string { @@ -353,7 +339,7 @@ func (*SysStatsResponse) ProtoMessage() {} func (x *SysStatsResponse) ProtoReflect() protoreflect.Message { mi := &file_app_stats_command_command_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -446,11 +432,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_stats_command_command_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_stats_command_command_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -461,7 +445,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_stats_command_command_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -596,104 +580,6 @@ func file_app_stats_command_command_proto_init() { if File_app_stats_command_command_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_stats_command_command_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*GetStatsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_stats_command_command_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Stat); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_stats_command_command_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*GetStatsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_stats_command_command_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*QueryStatsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_stats_command_command_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*QueryStatsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_stats_command_command_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*SysStatsRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_stats_command_command_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*SysStatsResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_stats_command_command_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/stats/command/command_grpc.pb.go b/app/stats/command/command_grpc.pb.go index 365bfbd6..40bd6383 100644 --- a/app/stats/command/command_grpc.pb.go +++ b/app/stats/command/command_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.27.0 +// - protoc v5.28.2 // source: app/stats/command/command.proto package command diff --git a/app/stats/config.pb.go b/app/stats/config.pb.go index bfe526f2..8452c2f8 100644 --- a/app/stats/config.pb.go +++ b/app/stats/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/stats/config.proto package stats @@ -28,11 +28,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_app_stats_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_stats_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -43,7 +41,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_app_stats_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -70,11 +68,9 @@ type ChannelConfig struct { func (x *ChannelConfig) Reset() { *x = ChannelConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_app_stats_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_app_stats_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ChannelConfig) String() string { @@ -85,7 +81,7 @@ func (*ChannelConfig) ProtoMessage() {} func (x *ChannelConfig) ProtoReflect() protoreflect.Message { mi := &file_app_stats_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -172,32 +168,6 @@ func file_app_stats_config_proto_init() { if File_app_stats_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_stats_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_stats_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ChannelConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/common/log/log.pb.go b/common/log/log.pb.go index 57215685..d0e1d17a 100644 --- a/common/log/log.pb.go +++ b/common/log/log.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: common/log/log.proto package log diff --git a/common/net/address.pb.go b/common/net/address.pb.go index 973d8d3a..4ca29cbe 100644 --- a/common/net/address.pb.go +++ b/common/net/address.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: common/net/address.proto package net @@ -36,11 +36,9 @@ type IPOrDomain struct { func (x *IPOrDomain) Reset() { *x = IPOrDomain{} - if protoimpl.UnsafeEnabled { - mi := &file_common_net_address_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_net_address_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *IPOrDomain) String() string { @@ -51,7 +49,7 @@ func (*IPOrDomain) ProtoMessage() {} func (x *IPOrDomain) ProtoReflect() protoreflect.Message { mi := &file_common_net_address_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -152,20 +150,6 @@ func file_common_net_address_proto_init() { if File_common_net_address_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_common_net_address_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*IPOrDomain); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } file_common_net_address_proto_msgTypes[0].OneofWrappers = []any{ (*IPOrDomain_Ip)(nil), (*IPOrDomain_Domain)(nil), diff --git a/common/net/destination.pb.go b/common/net/destination.pb.go index c796f042..b5f27023 100644 --- a/common/net/destination.pb.go +++ b/common/net/destination.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: common/net/destination.proto package net @@ -33,11 +33,9 @@ type Endpoint struct { func (x *Endpoint) Reset() { *x = Endpoint{} - if protoimpl.UnsafeEnabled { - mi := &file_common_net_destination_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_net_destination_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Endpoint) String() string { @@ -48,7 +46,7 @@ func (*Endpoint) ProtoMessage() {} func (x *Endpoint) ProtoReflect() protoreflect.Message { mi := &file_common_net_destination_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -145,20 +143,6 @@ func file_common_net_destination_proto_init() { } file_common_net_network_proto_init() file_common_net_address_proto_init() - if !protoimpl.UnsafeEnabled { - file_common_net_destination_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Endpoint); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/common/net/network.pb.go b/common/net/network.pb.go index b75d3564..9d55b336 100644 --- a/common/net/network.pb.go +++ b/common/net/network.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: common/net/network.proto package net @@ -83,11 +83,9 @@ type NetworkList struct { func (x *NetworkList) Reset() { *x = NetworkList{} - if protoimpl.UnsafeEnabled { - mi := &file_common_net_network_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_net_network_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *NetworkList) String() string { @@ -98,7 +96,7 @@ func (*NetworkList) ProtoMessage() {} func (x *NetworkList) ProtoReflect() protoreflect.Message { mi := &file_common_net_network_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -173,20 +171,6 @@ func file_common_net_network_proto_init() { if File_common_net_network_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_common_net_network_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*NetworkList); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/common/net/port.pb.go b/common/net/port.pb.go index 70415158..d6042685 100644 --- a/common/net/port.pb.go +++ b/common/net/port.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: common/net/port.proto package net @@ -34,11 +34,9 @@ type PortRange struct { func (x *PortRange) Reset() { *x = PortRange{} - if protoimpl.UnsafeEnabled { - mi := &file_common_net_port_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_net_port_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PortRange) String() string { @@ -49,7 +47,7 @@ func (*PortRange) ProtoMessage() {} func (x *PortRange) ProtoReflect() protoreflect.Message { mi := &file_common_net_port_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -89,11 +87,9 @@ type PortList struct { func (x *PortList) Reset() { *x = PortList{} - if protoimpl.UnsafeEnabled { - mi := &file_common_net_port_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_net_port_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PortList) String() string { @@ -104,7 +100,7 @@ func (*PortList) ProtoMessage() {} func (x *PortList) ProtoReflect() protoreflect.Message { mi := &file_common_net_port_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -177,32 +173,6 @@ func file_common_net_port_proto_init() { if File_common_net_port_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_common_net_port_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*PortRange); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_common_net_port_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*PortList); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/common/protocol/headers.pb.go b/common/protocol/headers.pb.go index f256bf2e..5dca8aa2 100644 --- a/common/protocol/headers.pb.go +++ b/common/protocol/headers.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: common/protocol/headers.proto package protocol @@ -88,11 +88,9 @@ type SecurityConfig struct { func (x *SecurityConfig) Reset() { *x = SecurityConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_common_protocol_headers_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_protocol_headers_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SecurityConfig) String() string { @@ -103,7 +101,7 @@ func (*SecurityConfig) ProtoMessage() {} func (x *SecurityConfig) ProtoReflect() protoreflect.Message { mi := &file_common_protocol_headers_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -183,20 +181,6 @@ func file_common_protocol_headers_proto_init() { if File_common_protocol_headers_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_common_protocol_headers_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*SecurityConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/common/protocol/server_spec.pb.go b/common/protocol/server_spec.pb.go index 42c7569a..f196930e 100644 --- a/common/protocol/server_spec.pb.go +++ b/common/protocol/server_spec.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: common/protocol/server_spec.proto package protocol @@ -33,11 +33,9 @@ type ServerEndpoint struct { func (x *ServerEndpoint) Reset() { *x = ServerEndpoint{} - if protoimpl.UnsafeEnabled { - mi := &file_common_protocol_server_spec_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_protocol_server_spec_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ServerEndpoint) String() string { @@ -48,7 +46,7 @@ func (*ServerEndpoint) ProtoMessage() {} func (x *ServerEndpoint) ProtoReflect() protoreflect.Message { mi := &file_common_protocol_server_spec_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -146,20 +144,6 @@ func file_common_protocol_server_spec_proto_init() { return } file_common_protocol_user_proto_init() - if !protoimpl.UnsafeEnabled { - file_common_protocol_server_spec_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*ServerEndpoint); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/common/protocol/user.pb.go b/common/protocol/user.pb.go index c97765ff..df19fbd6 100644 --- a/common/protocol/user.pb.go +++ b/common/protocol/user.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: common/protocol/user.proto package protocol @@ -36,11 +36,9 @@ type User struct { func (x *User) Reset() { *x = User{} - if protoimpl.UnsafeEnabled { - mi := &file_common_protocol_user_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_protocol_user_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *User) String() string { @@ -51,7 +49,7 @@ func (*User) ProtoMessage() {} func (x *User) ProtoReflect() protoreflect.Message { mi := &file_common_protocol_user_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -142,20 +140,6 @@ func file_common_protocol_user_proto_init() { if File_common_protocol_user_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_common_protocol_user_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*User); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/common/serial/typed_message.pb.go b/common/serial/typed_message.pb.go index 361f16c7..b0466529 100644 --- a/common/serial/typed_message.pb.go +++ b/common/serial/typed_message.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: common/serial/typed_message.proto package serial @@ -34,11 +34,9 @@ type TypedMessage struct { func (x *TypedMessage) Reset() { *x = TypedMessage{} - if protoimpl.UnsafeEnabled { - mi := &file_common_serial_typed_message_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_common_serial_typed_message_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TypedMessage) String() string { @@ -49,7 +47,7 @@ func (*TypedMessage) ProtoMessage() {} func (x *TypedMessage) ProtoReflect() protoreflect.Message { mi := &file_common_serial_typed_message_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -126,20 +124,6 @@ func file_common_serial_typed_message_proto_init() { if File_common_serial_typed_message_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_common_serial_typed_message_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*TypedMessage); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/core/config.pb.go b/core/config.pb.go index ba952da5..d80cc4d4 100644 --- a/core/config.pb.go +++ b/core/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: core/config.proto package core @@ -45,11 +45,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_core_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -60,7 +58,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_core_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -120,11 +118,9 @@ type InboundHandlerConfig struct { func (x *InboundHandlerConfig) Reset() { *x = InboundHandlerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_core_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *InboundHandlerConfig) String() string { @@ -135,7 +131,7 @@ func (*InboundHandlerConfig) ProtoMessage() {} func (x *InboundHandlerConfig) ProtoReflect() protoreflect.Message { mi := &file_core_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -191,11 +187,9 @@ type OutboundHandlerConfig struct { func (x *OutboundHandlerConfig) Reset() { *x = OutboundHandlerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_core_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_core_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *OutboundHandlerConfig) String() string { @@ -206,7 +200,7 @@ func (*OutboundHandlerConfig) ProtoMessage() {} func (x *OutboundHandlerConfig) ProtoReflect() protoreflect.Message { mi := &file_core_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -353,44 +347,6 @@ func file_core_config_proto_init() { if File_core_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_core_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*InboundHandlerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_core_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*OutboundHandlerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/blackhole/config.pb.go b/proxy/blackhole/config.pb.go index d9ebaeab..cc1c0640 100644 --- a/proxy/blackhole/config.pb.go +++ b/proxy/blackhole/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/blackhole/config.proto package blackhole @@ -29,11 +29,9 @@ type NoneResponse struct { func (x *NoneResponse) Reset() { *x = NoneResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_blackhole_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_blackhole_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *NoneResponse) String() string { @@ -44,7 +42,7 @@ func (*NoneResponse) ProtoMessage() {} func (x *NoneResponse) ProtoReflect() protoreflect.Message { mi := &file_proxy_blackhole_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -67,11 +65,9 @@ type HTTPResponse struct { func (x *HTTPResponse) Reset() { *x = HTTPResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_blackhole_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_blackhole_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *HTTPResponse) String() string { @@ -82,7 +78,7 @@ func (*HTTPResponse) ProtoMessage() {} func (x *HTTPResponse) ProtoReflect() protoreflect.Message { mi := &file_proxy_blackhole_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -107,11 +103,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_blackhole_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_blackhole_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -122,7 +116,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_proxy_blackhole_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -201,44 +195,6 @@ func file_proxy_blackhole_config_proto_init() { if File_proxy_blackhole_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_blackhole_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*NoneResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_blackhole_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*HTTPResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_blackhole_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/dns/config.pb.go b/proxy/dns/config.pb.go index e9927632..22f4cbfc 100644 --- a/proxy/dns/config.pb.go +++ b/proxy/dns/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/dns/config.proto package dns @@ -36,11 +36,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_dns_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_dns_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -51,7 +49,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_proxy_dns_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -150,20 +148,6 @@ func file_proxy_dns_config_proto_init() { if File_proxy_dns_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_dns_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/dokodemo/config.pb.go b/proxy/dokodemo/config.pb.go index 985b7f1f..b30c123e 100644 --- a/proxy/dokodemo/config.pb.go +++ b/proxy/dokodemo/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/dokodemo/config.proto package dokodemo @@ -36,11 +36,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_dokodemo_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_dokodemo_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -51,7 +49,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_proxy_dokodemo_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -165,20 +163,6 @@ func file_proxy_dokodemo_config_proto_init() { if File_proxy_dokodemo_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_dokodemo_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 56fb1a6e..03ce6a02 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/freedom/config.proto package freedom @@ -104,11 +104,9 @@ type DestinationOverride struct { func (x *DestinationOverride) Reset() { *x = DestinationOverride{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_freedom_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_freedom_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DestinationOverride) String() string { @@ -119,7 +117,7 @@ func (*DestinationOverride) ProtoMessage() {} func (x *DestinationOverride) ProtoReflect() protoreflect.Message { mi := &file_proxy_freedom_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -156,11 +154,9 @@ type Fragment struct { func (x *Fragment) Reset() { *x = Fragment{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_freedom_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_freedom_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Fragment) String() string { @@ -171,7 +167,7 @@ func (*Fragment) ProtoMessage() {} func (x *Fragment) ProtoReflect() protoreflect.Message { mi := &file_proxy_freedom_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -242,11 +238,9 @@ type Noise struct { func (x *Noise) Reset() { *x = Noise{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_freedom_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_freedom_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Noise) String() string { @@ -257,7 +251,7 @@ func (*Noise) ProtoMessage() {} func (x *Noise) ProtoReflect() protoreflect.Message { mi := &file_proxy_freedom_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -322,11 +316,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_freedom_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_freedom_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -337,7 +329,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_proxy_freedom_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -513,56 +505,6 @@ func file_proxy_freedom_config_proto_init() { if File_proxy_freedom_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_freedom_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*DestinationOverride); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_freedom_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Fragment); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_freedom_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*Noise); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_freedom_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/http/config.pb.go b/proxy/http/config.pb.go index bbcddffb..03e03441 100644 --- a/proxy/http/config.pb.go +++ b/proxy/http/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/http/config.proto package http @@ -32,11 +32,9 @@ type Account struct { func (x *Account) Reset() { *x = Account{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_http_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_http_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Account) String() string { @@ -47,7 +45,7 @@ func (*Account) ProtoMessage() {} func (x *Account) ProtoReflect() protoreflect.Message { mi := &file_proxy_http_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -89,11 +87,9 @@ type ServerConfig struct { func (x *ServerConfig) Reset() { *x = ServerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_http_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_http_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ServerConfig) String() string { @@ -104,7 +100,7 @@ func (*ServerConfig) ProtoMessage() {} func (x *ServerConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_http_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -151,11 +147,9 @@ type Header struct { func (x *Header) Reset() { *x = Header{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_http_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_http_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Header) String() string { @@ -166,7 +160,7 @@ func (*Header) ProtoMessage() {} func (x *Header) ProtoReflect() protoreflect.Message { mi := &file_proxy_http_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -208,11 +202,9 @@ type ClientConfig struct { func (x *ClientConfig) Reset() { *x = ClientConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_http_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_http_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ClientConfig) String() string { @@ -223,7 +215,7 @@ func (*ClientConfig) ProtoMessage() {} func (x *ClientConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_http_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -334,56 +326,6 @@ func file_proxy_http_config_proto_init() { if File_proxy_http_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_http_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Account); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_http_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ServerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_http_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*Header); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_http_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*ClientConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/loopback/config.pb.go b/proxy/loopback/config.pb.go index 22482623..29612918 100644 --- a/proxy/loopback/config.pb.go +++ b/proxy/loopback/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/loopback/config.proto package loopback @@ -30,11 +30,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_loopback_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_loopback_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -45,7 +43,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_proxy_loopback_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -114,20 +112,6 @@ func file_proxy_loopback_config_proto_init() { if File_proxy_loopback_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_loopback_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/shadowsocks/config.pb.go b/proxy/shadowsocks/config.pb.go index d2f96de7..56cddb67 100644 --- a/proxy/shadowsocks/config.pb.go +++ b/proxy/shadowsocks/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/shadowsocks/config.proto package shadowsocks @@ -92,11 +92,9 @@ type Account struct { func (x *Account) Reset() { *x = Account{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_shadowsocks_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_shadowsocks_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Account) String() string { @@ -107,7 +105,7 @@ func (*Account) ProtoMessage() {} func (x *Account) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -154,11 +152,9 @@ type ServerConfig struct { func (x *ServerConfig) Reset() { *x = ServerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_shadowsocks_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_shadowsocks_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ServerConfig) String() string { @@ -169,7 +165,7 @@ func (*ServerConfig) ProtoMessage() {} func (x *ServerConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -208,11 +204,9 @@ type ClientConfig struct { func (x *ClientConfig) Reset() { *x = ClientConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_shadowsocks_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_shadowsocks_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ClientConfig) String() string { @@ -223,7 +217,7 @@ func (*ClientConfig) ProtoMessage() {} func (x *ClientConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -335,44 +329,6 @@ func file_proxy_shadowsocks_config_proto_init() { if File_proxy_shadowsocks_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_shadowsocks_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Account); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_shadowsocks_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ServerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_shadowsocks_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*ClientConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/shadowsocks_2022/config.pb.go b/proxy/shadowsocks_2022/config.pb.go index b65be80a..b47438ea 100644 --- a/proxy/shadowsocks_2022/config.pb.go +++ b/proxy/shadowsocks_2022/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/shadowsocks_2022/config.proto package shadowsocks_2022 @@ -35,11 +35,9 @@ type ServerConfig struct { func (x *ServerConfig) Reset() { *x = ServerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ServerConfig) String() string { @@ -50,7 +48,7 @@ func (*ServerConfig) ProtoMessage() {} func (x *ServerConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -113,11 +111,9 @@ type MultiUserServerConfig struct { func (x *MultiUserServerConfig) Reset() { *x = MultiUserServerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *MultiUserServerConfig) String() string { @@ -128,7 +124,7 @@ func (*MultiUserServerConfig) ProtoMessage() {} func (x *MultiUserServerConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -185,11 +181,9 @@ type RelayDestination struct { func (x *RelayDestination) Reset() { *x = RelayDestination{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RelayDestination) String() string { @@ -200,7 +194,7 @@ func (*RelayDestination) ProtoMessage() {} func (x *RelayDestination) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -263,11 +257,9 @@ type RelayServerConfig struct { func (x *RelayServerConfig) Reset() { *x = RelayServerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RelayServerConfig) String() string { @@ -278,7 +270,7 @@ func (*RelayServerConfig) ProtoMessage() {} func (x *RelayServerConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -333,11 +325,9 @@ type User struct { func (x *User) Reset() { *x = User{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *User) String() string { @@ -348,7 +338,7 @@ func (*User) ProtoMessage() {} func (x *User) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -399,11 +389,9 @@ type ClientConfig struct { func (x *ClientConfig) Reset() { *x = ClientConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ClientConfig) String() string { @@ -414,7 +402,7 @@ func (*ClientConfig) ProtoMessage() {} func (x *ClientConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -596,80 +584,6 @@ func file_proxy_shadowsocks_2022_config_proto_init() { if File_proxy_shadowsocks_2022_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_shadowsocks_2022_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*ServerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_shadowsocks_2022_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*MultiUserServerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_shadowsocks_2022_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*RelayDestination); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_shadowsocks_2022_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*RelayServerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_shadowsocks_2022_config_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*User); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_shadowsocks_2022_config_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*ClientConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/socks/config.pb.go b/proxy/socks/config.pb.go index e1bd9872..ee94d0bc 100644 --- a/proxy/socks/config.pb.go +++ b/proxy/socks/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/socks/config.proto package socks @@ -83,11 +83,9 @@ type Account struct { func (x *Account) Reset() { *x = Account{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_socks_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_socks_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Account) String() string { @@ -98,7 +96,7 @@ func (*Account) ProtoMessage() {} func (x *Account) ProtoReflect() protoreflect.Message { mi := &file_proxy_socks_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -142,11 +140,9 @@ type ServerConfig struct { func (x *ServerConfig) Reset() { *x = ServerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_socks_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_socks_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ServerConfig) String() string { @@ -157,7 +153,7 @@ func (*ServerConfig) ProtoMessage() {} func (x *ServerConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_socks_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -219,11 +215,9 @@ type ClientConfig struct { func (x *ClientConfig) Reset() { *x = ClientConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_socks_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_socks_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ClientConfig) String() string { @@ -234,7 +228,7 @@ func (*ClientConfig) ProtoMessage() {} func (x *ClientConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_socks_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -346,44 +340,6 @@ func file_proxy_socks_config_proto_init() { if File_proxy_socks_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_socks_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Account); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_socks_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ServerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_socks_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*ClientConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/trojan/config.pb.go b/proxy/trojan/config.pb.go index 073e6792..dd555ea4 100644 --- a/proxy/trojan/config.pb.go +++ b/proxy/trojan/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/trojan/config.proto package trojan @@ -31,11 +31,9 @@ type Account struct { func (x *Account) Reset() { *x = Account{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_trojan_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_trojan_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Account) String() string { @@ -46,7 +44,7 @@ func (*Account) ProtoMessage() {} func (x *Account) ProtoReflect() protoreflect.Message { mi := &file_proxy_trojan_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -83,11 +81,9 @@ type Fallback struct { func (x *Fallback) Reset() { *x = Fallback{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_trojan_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_trojan_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Fallback) String() string { @@ -98,7 +94,7 @@ func (*Fallback) ProtoMessage() {} func (x *Fallback) ProtoReflect() protoreflect.Message { mi := &file_proxy_trojan_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -165,11 +161,9 @@ type ClientConfig struct { func (x *ClientConfig) Reset() { *x = ClientConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_trojan_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_trojan_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ClientConfig) String() string { @@ -180,7 +174,7 @@ func (*ClientConfig) ProtoMessage() {} func (x *ClientConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_trojan_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -213,11 +207,9 @@ type ServerConfig struct { func (x *ServerConfig) Reset() { *x = ServerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_trojan_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_trojan_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ServerConfig) String() string { @@ -228,7 +220,7 @@ func (*ServerConfig) ProtoMessage() {} func (x *ServerConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_trojan_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -336,56 +328,6 @@ func file_proxy_trojan_config_proto_init() { if File_proxy_trojan_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_trojan_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Account); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_trojan_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Fallback); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_trojan_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*ClientConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_trojan_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*ServerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/vless/account.pb.go b/proxy/vless/account.pb.go index 78854359..fd5d4518 100644 --- a/proxy/vless/account.pb.go +++ b/proxy/vless/account.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/vless/account.proto package vless @@ -35,11 +35,9 @@ type Account struct { func (x *Account) Reset() { *x = Account{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_vless_account_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_vless_account_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Account) String() string { @@ -50,7 +48,7 @@ func (*Account) ProtoMessage() {} func (x *Account) ProtoReflect() protoreflect.Message { mi := &file_proxy_vless_account_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -134,20 +132,6 @@ func file_proxy_vless_account_proto_init() { if File_proxy_vless_account_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_vless_account_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Account); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/vless/encoding/addons.pb.go b/proxy/vless/encoding/addons.pb.go index f093dda4..2f518841 100644 --- a/proxy/vless/encoding/addons.pb.go +++ b/proxy/vless/encoding/addons.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/vless/encoding/addons.proto package encoding @@ -31,11 +31,9 @@ type Addons struct { func (x *Addons) Reset() { *x = Addons{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_vless_encoding_addons_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_vless_encoding_addons_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Addons) String() string { @@ -46,7 +44,7 @@ func (*Addons) ProtoMessage() {} func (x *Addons) ProtoReflect() protoreflect.Message { mi := &file_proxy_vless_encoding_addons_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -124,20 +122,6 @@ func file_proxy_vless_encoding_addons_proto_init() { if File_proxy_vless_encoding_addons_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_vless_encoding_addons_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Addons); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/vless/inbound/config.pb.go b/proxy/vless/inbound/config.pb.go index 66adee6f..907a3f7f 100644 --- a/proxy/vless/inbound/config.pb.go +++ b/proxy/vless/inbound/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/vless/inbound/config.proto package inbound @@ -36,11 +36,9 @@ type Fallback struct { func (x *Fallback) Reset() { *x = Fallback{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_vless_inbound_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_vless_inbound_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Fallback) String() string { @@ -51,7 +49,7 @@ func (*Fallback) ProtoMessage() {} func (x *Fallback) ProtoReflect() protoreflect.Message { mi := &file_proxy_vless_inbound_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -122,11 +120,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_vless_inbound_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_vless_inbound_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -137,7 +133,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_proxy_vless_inbound_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -243,32 +239,6 @@ func file_proxy_vless_inbound_config_proto_init() { if File_proxy_vless_inbound_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_vless_inbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Fallback); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_vless_inbound_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/vless/outbound/config.pb.go b/proxy/vless/outbound/config.pb.go index 4df54775..76d2f768 100644 --- a/proxy/vless/outbound/config.pb.go +++ b/proxy/vless/outbound/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/vless/outbound/config.proto package outbound @@ -31,11 +31,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_vless_outbound_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_vless_outbound_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -46,7 +44,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_proxy_vless_outbound_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -122,20 +120,6 @@ func file_proxy_vless_outbound_config_proto_init() { if File_proxy_vless_outbound_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_vless_outbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/vmess/account.pb.go b/proxy/vmess/account.pb.go index 8e406071..44a8f73a 100644 --- a/proxy/vmess/account.pb.go +++ b/proxy/vmess/account.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/vmess/account.proto package vmess @@ -37,11 +37,9 @@ type Account struct { func (x *Account) Reset() { *x = Account{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_vmess_account_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_vmess_account_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Account) String() string { @@ -52,7 +50,7 @@ func (*Account) ProtoMessage() {} func (x *Account) ProtoReflect() protoreflect.Message { mi := &file_proxy_vmess_account_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -144,20 +142,6 @@ func file_proxy_vmess_account_proto_init() { if File_proxy_vmess_account_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_vmess_account_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Account); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/vmess/inbound/config.pb.go b/proxy/vmess/inbound/config.pb.go index 43457e69..4aa259e8 100644 --- a/proxy/vmess/inbound/config.pb.go +++ b/proxy/vmess/inbound/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/vmess/inbound/config.proto package inbound @@ -31,11 +31,9 @@ type DetourConfig struct { func (x *DetourConfig) Reset() { *x = DetourConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_vmess_inbound_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_vmess_inbound_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DetourConfig) String() string { @@ -46,7 +44,7 @@ func (*DetourConfig) ProtoMessage() {} func (x *DetourConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_vmess_inbound_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -78,11 +76,9 @@ type DefaultConfig struct { func (x *DefaultConfig) Reset() { *x = DefaultConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_vmess_inbound_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_vmess_inbound_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DefaultConfig) String() string { @@ -93,7 +89,7 @@ func (*DefaultConfig) ProtoMessage() {} func (x *DefaultConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_vmess_inbound_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -127,11 +123,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_vmess_inbound_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_vmess_inbound_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -142,7 +136,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_proxy_vmess_inbound_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -248,44 +242,6 @@ func file_proxy_vmess_inbound_config_proto_init() { if File_proxy_vmess_inbound_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_vmess_inbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*DetourConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_vmess_inbound_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*DefaultConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_vmess_inbound_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/vmess/outbound/config.pb.go b/proxy/vmess/outbound/config.pb.go index b1840d1d..0bc4d925 100644 --- a/proxy/vmess/outbound/config.pb.go +++ b/proxy/vmess/outbound/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/vmess/outbound/config.proto package outbound @@ -31,11 +31,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_vmess_outbound_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_vmess_outbound_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -46,7 +44,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_proxy_vmess_outbound_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -123,20 +121,6 @@ func file_proxy_vmess_outbound_config_proto_init() { if File_proxy_vmess_outbound_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_vmess_outbound_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/proxy/wireguard/config.pb.go b/proxy/wireguard/config.pb.go index fb0d6582..3d90c953 100644 --- a/proxy/wireguard/config.pb.go +++ b/proxy/wireguard/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: proxy/wireguard/config.proto package wireguard @@ -89,11 +89,9 @@ type PeerConfig struct { func (x *PeerConfig) Reset() { *x = PeerConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_wireguard_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_wireguard_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PeerConfig) String() string { @@ -104,7 +102,7 @@ func (*PeerConfig) ProtoMessage() {} func (x *PeerConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_wireguard_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -172,11 +170,9 @@ type DeviceConfig struct { func (x *DeviceConfig) Reset() { *x = DeviceConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_proxy_wireguard_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_proxy_wireguard_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DeviceConfig) String() string { @@ -187,7 +183,7 @@ func (*DeviceConfig) ProtoMessage() {} func (x *DeviceConfig) ProtoReflect() protoreflect.Message { mi := &file_proxy_wireguard_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -354,32 +350,6 @@ func file_proxy_wireguard_config_proto_init() { if File_proxy_wireguard_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_proxy_wireguard_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*PeerConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_proxy_wireguard_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*DeviceConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index c58781fa..1989851c 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/config.proto package internet @@ -159,11 +159,9 @@ type TransportConfig struct { func (x *TransportConfig) Reset() { *x = TransportConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TransportConfig) String() string { @@ -174,7 +172,7 @@ func (*TransportConfig) ProtoMessage() {} func (x *TransportConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -220,11 +218,9 @@ type StreamConfig struct { func (x *StreamConfig) Reset() { *x = StreamConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *StreamConfig) String() string { @@ -235,7 +231,7 @@ func (*StreamConfig) ProtoMessage() {} func (x *StreamConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -296,11 +292,9 @@ type ProxyConfig struct { func (x *ProxyConfig) Reset() { *x = ProxyConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ProxyConfig) String() string { @@ -311,7 +305,7 @@ func (*ProxyConfig) ProtoMessage() {} func (x *ProxyConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -353,11 +347,9 @@ type CustomSockopt struct { func (x *CustomSockopt) Reset() { *x = CustomSockopt{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CustomSockopt) String() string { @@ -368,7 +360,7 @@ func (*CustomSockopt) ProtoMessage() {} func (x *CustomSockopt) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -446,11 +438,9 @@ type SocketConfig struct { func (x *SocketConfig) Reset() { *x = SocketConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_config_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_config_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *SocketConfig) String() string { @@ -461,7 +451,7 @@ func (*SocketConfig) ProtoMessage() {} func (x *SocketConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_config_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -787,68 +777,6 @@ func file_transport_internet_config_proto_init() { if File_transport_internet_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*TransportConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*StreamConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*ProxyConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*CustomSockopt); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_config_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*SocketConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/grpc/config.pb.go b/transport/internet/grpc/config.pb.go index b86858e3..f6aecf47 100644 --- a/transport/internet/grpc/config.pb.go +++ b/transport/internet/grpc/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/grpc/config.proto package grpc @@ -37,11 +37,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_grpc_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_grpc_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -52,7 +50,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_grpc_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -186,20 +184,6 @@ func file_transport_internet_grpc_config_proto_init() { if File_transport_internet_grpc_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_grpc_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/grpc/encoding/stream.pb.go b/transport/internet/grpc/encoding/stream.pb.go index 3c872f9b..ad069a1c 100644 --- a/transport/internet/grpc/encoding/stream.pb.go +++ b/transport/internet/grpc/encoding/stream.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/grpc/encoding/stream.proto package encoding @@ -30,11 +30,9 @@ type Hunk struct { func (x *Hunk) Reset() { *x = Hunk{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_grpc_encoding_stream_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_grpc_encoding_stream_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Hunk) String() string { @@ -45,7 +43,7 @@ func (*Hunk) ProtoMessage() {} func (x *Hunk) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_grpc_encoding_stream_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -77,11 +75,9 @@ type MultiHunk struct { func (x *MultiHunk) Reset() { *x = MultiHunk{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_grpc_encoding_stream_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_grpc_encoding_stream_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *MultiHunk) String() string { @@ -92,7 +88,7 @@ func (*MultiHunk) ProtoMessage() {} func (x *MultiHunk) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_grpc_encoding_stream_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -182,32 +178,6 @@ func file_transport_internet_grpc_encoding_stream_proto_init() { if File_transport_internet_grpc_encoding_stream_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_grpc_encoding_stream_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Hunk); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_grpc_encoding_stream_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*MultiHunk); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/grpc/encoding/stream_grpc.pb.go b/transport/internet/grpc/encoding/stream_grpc.pb.go index d96d7490..1fe11524 100644 --- a/transport/internet/grpc/encoding/stream_grpc.pb.go +++ b/transport/internet/grpc/encoding/stream_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.27.0 +// - protoc v5.28.2 // source: transport/internet/grpc/encoding/stream.proto package encoding diff --git a/transport/internet/headers/dns/config.pb.go b/transport/internet/headers/dns/config.pb.go index 137f7676..ee522b1f 100644 --- a/transport/internet/headers/dns/config.pb.go +++ b/transport/internet/headers/dns/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/headers/dns/config.proto package dns @@ -30,11 +30,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_dns_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_dns_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -45,7 +43,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_dns_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -118,20 +116,6 @@ func file_transport_internet_headers_dns_config_proto_init() { if File_transport_internet_headers_dns_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_dns_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/headers/http/config.pb.go b/transport/internet/headers/http/config.pb.go index 0dbaa753..49a0caa5 100644 --- a/transport/internet/headers/http/config.pb.go +++ b/transport/internet/headers/http/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/headers/http/config.proto package http @@ -34,11 +34,9 @@ type Header struct { func (x *Header) Reset() { *x = Header{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_http_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_http_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Header) String() string { @@ -49,7 +47,7 @@ func (*Header) ProtoMessage() {} func (x *Header) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_http_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -89,11 +87,9 @@ type Version struct { func (x *Version) Reset() { *x = Version{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_http_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_http_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Version) String() string { @@ -104,7 +100,7 @@ func (*Version) ProtoMessage() {} func (x *Version) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_http_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -137,11 +133,9 @@ type Method struct { func (x *Method) Reset() { *x = Method{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_http_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_http_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Method) String() string { @@ -152,7 +146,7 @@ func (*Method) ProtoMessage() {} func (x *Method) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_http_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -190,11 +184,9 @@ type RequestConfig struct { func (x *RequestConfig) Reset() { *x = RequestConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_http_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_http_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RequestConfig) String() string { @@ -205,7 +197,7 @@ func (*RequestConfig) ProtoMessage() {} func (x *RequestConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_http_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -261,11 +253,9 @@ type Status struct { func (x *Status) Reset() { *x = Status{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_http_config_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_http_config_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Status) String() string { @@ -276,7 +266,7 @@ func (*Status) ProtoMessage() {} func (x *Status) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_http_config_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -317,11 +307,9 @@ type ResponseConfig struct { func (x *ResponseConfig) Reset() { *x = ResponseConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_http_config_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_http_config_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ResponseConfig) String() string { @@ -332,7 +320,7 @@ func (*ResponseConfig) ProtoMessage() {} func (x *ResponseConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_http_config_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -383,11 +371,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_http_config_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_http_config_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -398,7 +384,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_http_config_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -542,92 +528,6 @@ func file_transport_internet_headers_http_config_proto_init() { if File_transport_internet_headers_http_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_http_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Header); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_headers_http_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Version); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_headers_http_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*Method); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_headers_http_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*RequestConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_headers_http_config_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*Status); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_headers_http_config_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*ResponseConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_headers_http_config_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/headers/noop/config.pb.go b/transport/internet/headers/noop/config.pb.go index e750b66e..f1756060 100644 --- a/transport/internet/headers/noop/config.pb.go +++ b/transport/internet/headers/noop/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/headers/noop/config.proto package noop @@ -28,11 +28,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_noop_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_noop_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -43,7 +41,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_noop_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -66,11 +64,9 @@ type ConnectionConfig struct { func (x *ConnectionConfig) Reset() { *x = ConnectionConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_noop_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_noop_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ConnectionConfig) String() string { @@ -81,7 +77,7 @@ func (*ConnectionConfig) ProtoMessage() {} func (x *ConnectionConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_noop_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -148,32 +144,6 @@ func file_transport_internet_headers_noop_config_proto_init() { if File_transport_internet_headers_noop_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_noop_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_headers_noop_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*ConnectionConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/headers/srtp/config.pb.go b/transport/internet/headers/srtp/config.pb.go index 5c77a15c..81728497 100644 --- a/transport/internet/headers/srtp/config.pb.go +++ b/transport/internet/headers/srtp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/headers/srtp/config.proto package srtp @@ -35,11 +35,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_srtp_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_srtp_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -50,7 +48,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_srtp_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -168,20 +166,6 @@ func file_transport_internet_headers_srtp_config_proto_init() { if File_transport_internet_headers_srtp_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_srtp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/headers/tls/config.pb.go b/transport/internet/headers/tls/config.pb.go index f5564c4e..c67ee426 100644 --- a/transport/internet/headers/tls/config.pb.go +++ b/transport/internet/headers/tls/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/headers/tls/config.proto package tls @@ -28,11 +28,9 @@ type PacketConfig struct { func (x *PacketConfig) Reset() { *x = PacketConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_tls_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_tls_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *PacketConfig) String() string { @@ -43,7 +41,7 @@ func (*PacketConfig) ProtoMessage() {} func (x *PacketConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_tls_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -108,20 +106,6 @@ func file_transport_internet_headers_tls_config_proto_init() { if File_transport_internet_headers_tls_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_tls_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*PacketConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/headers/utp/config.pb.go b/transport/internet/headers/utp/config.pb.go index 913dc318..b0ffa60c 100644 --- a/transport/internet/headers/utp/config.pb.go +++ b/transport/internet/headers/utp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/headers/utp/config.proto package utp @@ -30,11 +30,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_utp_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_utp_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -45,7 +43,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_utp_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -118,20 +116,6 @@ func file_transport_internet_headers_utp_config_proto_init() { if File_transport_internet_headers_utp_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_utp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/headers/wechat/config.pb.go b/transport/internet/headers/wechat/config.pb.go index 65384f4a..48970394 100644 --- a/transport/internet/headers/wechat/config.pb.go +++ b/transport/internet/headers/wechat/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/headers/wechat/config.proto package wechat @@ -28,11 +28,9 @@ type VideoConfig struct { func (x *VideoConfig) Reset() { *x = VideoConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_wechat_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_wechat_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *VideoConfig) String() string { @@ -43,7 +41,7 @@ func (*VideoConfig) ProtoMessage() {} func (x *VideoConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_wechat_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -109,20 +107,6 @@ func file_transport_internet_headers_wechat_config_proto_init() { if File_transport_internet_headers_wechat_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_wechat_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*VideoConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/headers/wireguard/config.pb.go b/transport/internet/headers/wireguard/config.pb.go index ca459bfa..3746c1aa 100644 --- a/transport/internet/headers/wireguard/config.pb.go +++ b/transport/internet/headers/wireguard/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/headers/wireguard/config.proto package wireguard @@ -28,11 +28,9 @@ type WireguardConfig struct { func (x *WireguardConfig) Reset() { *x = WireguardConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_headers_wireguard_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_headers_wireguard_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *WireguardConfig) String() string { @@ -43,7 +41,7 @@ func (*WireguardConfig) ProtoMessage() {} func (x *WireguardConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_headers_wireguard_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -110,20 +108,6 @@ func file_transport_internet_headers_wireguard_config_proto_init() { if File_transport_internet_headers_wireguard_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_headers_wireguard_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*WireguardConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/http/config.pb.go b/transport/internet/http/config.pb.go index fcd4f77e..c3e9b89f 100644 --- a/transport/internet/http/config.pb.go +++ b/transport/internet/http/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/http/config.proto package http @@ -36,11 +36,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_http_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_http_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -51,7 +49,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_http_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -174,20 +172,6 @@ func file_transport_internet_http_config_proto_init() { if File_transport_internet_http_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_http_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/httpupgrade/config.pb.go b/transport/internet/httpupgrade/config.pb.go index be06ce79..72baaf8b 100644 --- a/transport/internet/httpupgrade/config.pb.go +++ b/transport/internet/httpupgrade/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/httpupgrade/config.proto package httpupgrade @@ -34,11 +34,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_httpupgrade_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_httpupgrade_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -49,7 +47,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_httpupgrade_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -166,20 +164,6 @@ func file_transport_internet_httpupgrade_config_proto_init() { if File_transport_internet_httpupgrade_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_httpupgrade_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/kcp/config.pb.go b/transport/internet/kcp/config.pb.go index ff711185..0d2a9697 100644 --- a/transport/internet/kcp/config.pb.go +++ b/transport/internet/kcp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/kcp/config.proto package kcp @@ -32,11 +32,9 @@ type MTU struct { func (x *MTU) Reset() { *x = MTU{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_kcp_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_kcp_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *MTU) String() string { @@ -47,7 +45,7 @@ func (*MTU) ProtoMessage() {} func (x *MTU) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_kcp_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -80,11 +78,9 @@ type TTI struct { func (x *TTI) Reset() { *x = TTI{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_kcp_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_kcp_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *TTI) String() string { @@ -95,7 +91,7 @@ func (*TTI) ProtoMessage() {} func (x *TTI) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_kcp_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -128,11 +124,9 @@ type UplinkCapacity struct { func (x *UplinkCapacity) Reset() { *x = UplinkCapacity{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_kcp_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_kcp_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *UplinkCapacity) String() string { @@ -143,7 +137,7 @@ func (*UplinkCapacity) ProtoMessage() {} func (x *UplinkCapacity) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_kcp_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -176,11 +170,9 @@ type DownlinkCapacity struct { func (x *DownlinkCapacity) Reset() { *x = DownlinkCapacity{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_kcp_config_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_kcp_config_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *DownlinkCapacity) String() string { @@ -191,7 +183,7 @@ func (*DownlinkCapacity) ProtoMessage() {} func (x *DownlinkCapacity) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_kcp_config_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -224,11 +216,9 @@ type WriteBuffer struct { func (x *WriteBuffer) Reset() { *x = WriteBuffer{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_kcp_config_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_kcp_config_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *WriteBuffer) String() string { @@ -239,7 +229,7 @@ func (*WriteBuffer) ProtoMessage() {} func (x *WriteBuffer) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_kcp_config_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -272,11 +262,9 @@ type ReadBuffer struct { func (x *ReadBuffer) Reset() { *x = ReadBuffer{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_kcp_config_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_kcp_config_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ReadBuffer) String() string { @@ -287,7 +275,7 @@ func (*ReadBuffer) ProtoMessage() {} func (x *ReadBuffer) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_kcp_config_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -319,11 +307,9 @@ type ConnectionReuse struct { func (x *ConnectionReuse) Reset() { *x = ConnectionReuse{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_kcp_config_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_kcp_config_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *ConnectionReuse) String() string { @@ -334,7 +320,7 @@ func (*ConnectionReuse) ProtoMessage() {} func (x *ConnectionReuse) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_kcp_config_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -367,11 +353,9 @@ type EncryptionSeed struct { func (x *EncryptionSeed) Reset() { *x = EncryptionSeed{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_kcp_config_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_kcp_config_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EncryptionSeed) String() string { @@ -382,7 +366,7 @@ func (*EncryptionSeed) ProtoMessage() {} func (x *EncryptionSeed) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_kcp_config_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -422,11 +406,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_kcp_config_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_kcp_config_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -437,7 +419,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_kcp_config_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -637,116 +619,6 @@ func file_transport_internet_kcp_config_proto_init() { if File_transport_internet_kcp_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_kcp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*MTU); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_kcp_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*TTI); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_kcp_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*UplinkCapacity); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_kcp_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*DownlinkCapacity); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_kcp_config_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*WriteBuffer); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_kcp_config_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*ReadBuffer); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_kcp_config_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*ConnectionReuse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_kcp_config_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*EncryptionSeed); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_kcp_config_proto_msgTypes[8].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/reality/config.pb.go b/transport/internet/reality/config.pb.go index 06d314d4..81038552 100644 --- a/transport/internet/reality/config.pb.go +++ b/transport/internet/reality/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/reality/config.proto package reality @@ -46,11 +46,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_reality_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_reality_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -61,7 +59,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_reality_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -275,20 +273,6 @@ func file_transport_internet_reality_config_proto_init() { if File_transport_internet_reality_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_reality_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 6bd6a9dd..db09180d 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/splithttp/config.proto package splithttp @@ -38,11 +38,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_splithttp_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_splithttp_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -53,7 +51,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_splithttp_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -142,11 +140,9 @@ type RandRangeConfig struct { func (x *RandRangeConfig) Reset() { *x = RandRangeConfig{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_splithttp_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_splithttp_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *RandRangeConfig) String() string { @@ -157,7 +153,7 @@ func (*RandRangeConfig) ProtoMessage() {} func (x *RandRangeConfig) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_splithttp_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -199,11 +195,9 @@ type Multiplexing struct { func (x *Multiplexing) Reset() { *x = Multiplexing{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Multiplexing) String() string { @@ -214,7 +208,7 @@ func (*Multiplexing) ProtoMessage() {} func (x *Multiplexing) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -389,44 +383,6 @@ func file_transport_internet_splithttp_config_proto_init() { if File_transport_internet_splithttp_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_splithttp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_splithttp_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*RandRangeConfig); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_splithttp_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*Multiplexing); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/tcp/config.pb.go b/transport/internet/tcp/config.pb.go index df7d3ad1..e4deb0e8 100644 --- a/transport/internet/tcp/config.pb.go +++ b/transport/internet/tcp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/tcp/config.proto package tcp @@ -32,11 +32,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_tcp_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_tcp_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -47,7 +45,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_tcp_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -136,20 +134,6 @@ func file_transport_internet_tcp_config_proto_init() { if File_transport_internet_tcp_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_tcp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index 14bb90ab..cec2eefd 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.28.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/tls/config.proto package tls @@ -91,11 +91,9 @@ type Certificate struct { func (x *Certificate) Reset() { *x = Certificate{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_tls_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_tls_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Certificate) String() string { @@ -106,7 +104,7 @@ func (*Certificate) ProtoMessage() {} func (x *Certificate) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_tls_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -219,11 +217,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_tls_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_tls_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -234,7 +230,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_tls_config_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -466,32 +462,6 @@ func file_transport_internet_tls_config_proto_init() { if File_transport_internet_tls_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_tls_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Certificate); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_transport_internet_tls_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/udp/config.pb.go b/transport/internet/udp/config.pb.go index 12c10070..d9d11a4f 100644 --- a/transport/internet/udp/config.pb.go +++ b/transport/internet/udp/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/udp/config.proto package udp @@ -28,11 +28,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_udp_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_udp_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -43,7 +41,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_udp_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -105,20 +103,6 @@ func file_transport_internet_udp_config_proto_init() { if File_transport_internet_udp_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_udp_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/transport/internet/websocket/config.pb.go b/transport/internet/websocket/config.pb.go index 3b1103f7..518cf6e8 100644 --- a/transport/internet/websocket/config.pb.go +++ b/transport/internet/websocket/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v5.27.0 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: transport/internet/websocket/config.proto package websocket @@ -34,11 +34,9 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - if protoimpl.UnsafeEnabled { - mi := &file_transport_internet_websocket_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_transport_internet_websocket_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *Config) String() string { @@ -49,7 +47,7 @@ func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { mi := &file_transport_internet_websocket_config_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -165,20 +163,6 @@ func file_transport_internet_websocket_config_proto_init() { if File_transport_internet_websocket_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_transport_internet_websocket_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ From 25c7bc0c8260df899775dd2d8e55b609087ed27f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 16 Oct 2024 04:07:51 +0000 Subject: [PATCH 572/867] v24.10.16 --- core/core.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/core.go b/core/core.go index 00b2dd10..ecefc296 100644 --- a/core/core.go +++ b/core/core.go @@ -18,8 +18,8 @@ import ( var ( Version_x byte = 24 - Version_y byte = 9 - Version_z byte = 30 + Version_y byte = 10 + Version_z byte = 16 ) var ( From b0272c172afbf39124e5c92df7ea1145164da7df Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 17 Oct 2024 08:43:34 -0400 Subject: [PATCH 573/867] README.md: Add wulabing/xray_docker to Docker --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0a177ce8..b3d2f2e6 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ - Docker - [ghcr.io/xtls/xray-core](https://ghcr.io/xtls/xray-core) (**Official**) - [teddysun/xray](https://hub.docker.com/r/teddysun/xray) + - [wulabing/xray_docker](https://github.com/wulabing/xray_docker) - Web Panel - [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [Xray-UI](https://github.com/qist/xray-ui) - [Hiddify](https://github.com/hiddify/hiddify-config) From 9bdf72d658cc3bd168374d2997b93299603c87af Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 18 Oct 2024 00:10:09 +0000 Subject: [PATCH 574/867] WireGuard config: Replace `kernelMode` with `noKernelTun` https://github.com/XTLS/Xray-core/pull/3871#issuecomment-2420770309 --- infra/conf/wireguard.go | 26 ++------------------ infra/conf/wireguard_test.go | 4 +-- proxy/wireguard/config.go | 21 +++++++++++++--- proxy/wireguard/config.pb.go | 38 ++++++++++++++--------------- proxy/wireguard/config.proto | 2 +- testing/scenarios/wireguard_test.go | 32 ++++++++++++------------ 6 files changed, 58 insertions(+), 65 deletions(-) diff --git a/infra/conf/wireguard.go b/infra/conf/wireguard.go index 2165a40d..9952101a 100644 --- a/infra/conf/wireguard.go +++ b/infra/conf/wireguard.go @@ -1,10 +1,8 @@ package conf import ( - "context" "encoding/base64" "encoding/hex" - "fmt" "strings" "github.com/xtls/xray-core/common/errors" @@ -53,8 +51,7 @@ func (c *WireGuardPeerConfig) Build() (proto.Message, error) { type WireGuardConfig struct { IsClient bool `json:""` - KernelTun *bool `json:"kernelTun"` - KernelMode *bool `json:"kernelMode"` + NoKernelTun bool `json:"noKernelTun"` SecretKey string `json:"secretKey"` Address []string `json:"address"` Peers []*WireGuardPeerConfig `json:"peers"` @@ -121,26 +118,7 @@ func (c *WireGuardConfig) Build() (proto.Message, error) { } config.IsClient = c.IsClient - kernelTunSupported, err := wireguard.KernelTunSupported() - if err != nil { - errors.LogWarning(context.Background(), fmt.Sprintf("Failed to check kernel TUN support: %v. This may indicate that your OS doesn't support kernel TUN or you lack the necessary permissions. Please ensure you have the required privileges.", err)) - config.KernelMode = false - return config, nil - } - if c.KernelMode == nil { - c.KernelMode = c.KernelTun - } - if c.KernelMode != nil { - config.KernelMode = *c.KernelMode - if config.KernelMode && !kernelTunSupported { - errors.LogWarning(context.Background(), "kernel TUN is not supported on your OS or permission is insufficient") - } - } else { - config.KernelMode = kernelTunSupported - if config.KernelMode { - errors.LogDebug(context.Background(), "kernel TUN is enabled as it's supported and permission is sufficient") - } - } + config.NoKernelTun = c.NoKernelTun return config, nil } diff --git a/infra/conf/wireguard_test.go b/infra/conf/wireguard_test.go index 57951105..c4c24c44 100644 --- a/infra/conf/wireguard_test.go +++ b/infra/conf/wireguard_test.go @@ -26,7 +26,7 @@ func TestWireGuardConfig(t *testing.T) { "mtu": 1300, "workers": 2, "domainStrategy": "ForceIPv6v4", - "kernelMode": false + "noKernelTun": false }`, Parser: loadJSON(creator), Output: &wireguard.DeviceConfig{ @@ -45,7 +45,7 @@ func TestWireGuardConfig(t *testing.T) { Mtu: 1300, NumWorkers: 2, DomainStrategy: wireguard.DeviceConfig_FORCE_IP64, - KernelMode: false, + NoKernelTun: false, }, }, }) diff --git a/proxy/wireguard/config.go b/proxy/wireguard/config.go index 2a316cdd..8995f35e 100644 --- a/proxy/wireguard/config.go +++ b/proxy/wireguard/config.go @@ -1,5 +1,11 @@ package wireguard +import ( + "context" + + "github.com/xtls/xray-core/common/errors" +) + func (c *DeviceConfig) preferIP4() bool { return c.DomainStrategy == DeviceConfig_FORCE_IP || c.DomainStrategy == DeviceConfig_FORCE_IP4 || @@ -25,8 +31,17 @@ func (c *DeviceConfig) fallbackIP6() bool { } func (c *DeviceConfig) createTun() tunCreator { - if c.KernelMode { - return createKernelTun + if c.NoKernelTun { + return createGVisorTun } - return createGVisorTun + kernelTunSupported, err := KernelTunSupported() + if err != nil { + errors.LogWarning(context.Background(), "Using gVisor TUN. Failed to check kernel TUN support:", err) + return createGVisorTun + } + if !kernelTunSupported { + errors.LogWarning(context.Background(), "Using gVisor TUN. Kernel TUN is not supported on your OS, or your permission is insufficient.)") + return createGVisorTun + } + return createKernelTun } diff --git a/proxy/wireguard/config.pb.go b/proxy/wireguard/config.pb.go index 3d90c953..17f1a174 100644 --- a/proxy/wireguard/config.pb.go +++ b/proxy/wireguard/config.pb.go @@ -165,7 +165,7 @@ type DeviceConfig struct { Reserved []byte `protobuf:"bytes,6,opt,name=reserved,proto3" json:"reserved,omitempty"` DomainStrategy DeviceConfig_DomainStrategy `protobuf:"varint,7,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.proxy.wireguard.DeviceConfig_DomainStrategy" json:"domain_strategy,omitempty"` IsClient bool `protobuf:"varint,8,opt,name=is_client,json=isClient,proto3" json:"is_client,omitempty"` - KernelMode bool `protobuf:"varint,9,opt,name=kernel_mode,json=kernelMode,proto3" json:"kernel_mode,omitempty"` + NoKernelTun bool `protobuf:"varint,9,opt,name=no_kernel_tun,json=noKernelTun,proto3" json:"no_kernel_tun,omitempty"` } func (x *DeviceConfig) Reset() { @@ -254,9 +254,9 @@ func (x *DeviceConfig) GetIsClient() bool { return false } -func (x *DeviceConfig) GetKernelMode() bool { +func (x *DeviceConfig) GetNoKernelTun() bool { if x != nil { - return x.KernelMode + return x.NoKernelTun } return false } @@ -278,7 +278,7 @@ var file_proxy_wireguard_config_proto_rawDesc = []byte{ 0x76, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x6b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x64, 0x5f, 0x69, 0x70, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x65, - 0x64, 0x49, 0x70, 0x73, 0x22, 0xc8, 0x03, 0x0a, 0x0c, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x43, + 0x64, 0x49, 0x70, 0x73, 0x22, 0xcb, 0x03, 0x0a, 0x0c, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, @@ -299,21 +299,21 @@ var file_proxy_wireguard_config_proto_rawDesc = []byte{ 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x12, 0x1f, 0x0a, 0x0b, 0x6b, 0x65, 0x72, 0x6e, 0x65, 0x6c, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6b, 0x65, 0x72, 0x6e, 0x65, 0x6c, 0x4d, 0x6f, 0x64, - 0x65, 0x22, 0x5c, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, - 0x65, 0x67, 0x79, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, - 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x01, - 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x12, - 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x03, 0x12, - 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x04, 0x42, - 0x5e, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x2e, 0x77, 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0x50, 0x01, 0x5a, 0x29, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, - 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x77, - 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0xaa, 0x02, 0x14, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x57, 0x69, 0x72, 0x65, 0x47, 0x75, 0x61, 0x72, 0x64, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x22, 0x0a, 0x0d, 0x6e, 0x6f, 0x5f, 0x6b, 0x65, 0x72, 0x6e, 0x65, 0x6c, 0x5f, 0x74, 0x75, + 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x4b, 0x65, 0x72, 0x6e, 0x65, + 0x6c, 0x54, 0x75, 0x6e, 0x22, 0x5c, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, + 0x49, 0x50, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, + 0x34, 0x10, 0x01, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, + 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, + 0x10, 0x03, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, + 0x10, 0x04, 0x42, 0x5e, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x77, 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0x50, 0x01, + 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x2f, 0x77, 0x69, 0x72, 0x65, 0x67, 0x75, 0x61, 0x72, 0x64, 0xaa, 0x02, 0x14, 0x58, 0x72, + 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x57, 0x69, 0x72, 0x65, 0x47, 0x75, 0x61, + 0x72, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proxy/wireguard/config.proto b/proxy/wireguard/config.proto index e7fd66f4..aa05b822 100644 --- a/proxy/wireguard/config.proto +++ b/proxy/wireguard/config.proto @@ -30,5 +30,5 @@ message DeviceConfig { bytes reserved = 6; DomainStrategy domain_strategy = 7; bool is_client = 8; - bool kernel_mode = 9; + bool no_kernel_tun = 9; } \ No newline at end of file diff --git a/testing/scenarios/wireguard_test.go b/testing/scenarios/wireguard_test.go index 0609ec77..deaee114 100644 --- a/testing/scenarios/wireguard_test.go +++ b/testing/scenarios/wireguard_test.go @@ -48,13 +48,13 @@ func TestWireguard(t *testing.T) { Listen: net.NewIPOrDomain(net.LocalHostIP), }), ProxySettings: serial.ToTypedMessage(&wireguard.DeviceConfig{ - IsClient: false, - KernelMode: false, - Endpoint: []string{"10.0.0.1"}, - Mtu: 1420, - SecretKey: serverPrivate, + IsClient: false, + NoKernelTun: false, + Endpoint: []string{"10.0.0.1"}, + Mtu: 1420, + SecretKey: serverPrivate, Peers: []*wireguard.PeerConfig{{ - PublicKey: serverPublic, + PublicKey: serverPublic, AllowedIps: []string{"0.0.0.0/0", "::0/0"}, }}, }), @@ -82,8 +82,8 @@ func TestWireguard(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}, }), }, @@ -91,14 +91,14 @@ func TestWireguard(t *testing.T) { Outbound: []*core.OutboundHandlerConfig{ { ProxySettings: serial.ToTypedMessage(&wireguard.DeviceConfig{ - IsClient: true, - KernelMode: false, - Endpoint: []string{"10.0.0.2"}, - Mtu: 1420, - SecretKey: clientPrivate, + IsClient: true, + NoKernelTun: false, + Endpoint: []string{"10.0.0.2"}, + Mtu: 1420, + SecretKey: clientPrivate, Peers: []*wireguard.PeerConfig{{ - Endpoint: "127.0.0.1:" + serverPort.String(), - PublicKey: clientPublic, + Endpoint: "127.0.0.1:" + serverPort.String(), + PublicKey: clientPublic, AllowedIps: []string{"0.0.0.0/0", "::0/0"}, }}, }), @@ -119,4 +119,4 @@ func TestWireguard(t *testing.T) { // if err := errg.Wait(); err != nil { // t.Error(err) // } -} \ No newline at end of file +} From 8809cbda817006f8d33c4c9993014d146f7e1138 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 18 Oct 2024 01:03:44 +0000 Subject: [PATCH 575/867] Transport: Remove GUN (an alias of gRPC) --- infra/conf/transport_internet.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 904505bf..075f6047 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -669,7 +669,7 @@ func (p TransportProtocol) Build() (string, error) { return "websocket", nil case "h2", "h3", "http": return "http", nil - case "grpc", "gun": + case "grpc": return "grpc", nil case "httpupgrade": return "httpupgrade", nil @@ -807,7 +807,6 @@ type StreamConfig struct { HTTPSettings *HTTPConfig `json:"httpSettings"` SocketSettings *SocketConfig `json:"sockopt"` GRPCConfig *GRPCConfig `json:"grpcSettings"` - GUNConfig *GRPCConfig `json:"gunSettings"` HTTPUPGRADESettings *HttpUpgradeConfig `json:"httpupgradeSettings"` SplitHTTPSettings *SplitHTTPConfig `json:"splithttpSettings"` } @@ -900,9 +899,6 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { Settings: serial.ToTypedMessage(ts), }) } - if c.GRPCConfig == nil { - c.GRPCConfig = c.GUNConfig - } if c.GRPCConfig != nil { gs, err := c.GRPCConfig.Build() if err != nil { From e4939dc1dbf8ca6bfd5279bc37a8a779d4cb774a Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 18 Oct 2024 02:18:06 +0000 Subject: [PATCH 576/867] Config: Prefer newer alias (REALITY `target`, RAW) --- infra/conf/transport_internet.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 075f6047..096e9ab8 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -484,10 +484,10 @@ func (c *TLSConfig) Build() (proto.Message, error) { } type REALITYConfig struct { - Show bool `json:"show"` MasterKeyLog string `json:"masterKeyLog"` - Dest json.RawMessage `json:"dest"` + Show bool `json:"show"` Target json.RawMessage `json:"target"` + Dest json.RawMessage `json:"dest"` Type string `json:"type"` Xver uint64 `json:"xver"` ServerNames []string `json:"serverNames"` @@ -506,10 +506,10 @@ type REALITYConfig struct { func (c *REALITYConfig) Build() (proto.Message, error) { config := new(reality.Config) - config.Show = c.Show config.MasterKeyLog = c.MasterKeyLog + config.Show = c.Show var err error - if c.Dest == nil { + if c.Target != nil { c.Dest = c.Target } if c.Dest != nil { @@ -539,7 +539,7 @@ func (c *REALITYConfig) Build() (proto.Message, error) { } } if c.Type == "" { - return nil, errors.New(`please fill in a valid value for "dest" or "target"`) + return nil, errors.New(`please fill in a valid value for "target"`) } if c.Xver > 2 { return nil, errors.New(`invalid PROXY protocol version, "xver" only accepts 0, 1, 2`) @@ -856,7 +856,7 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { default: return nil, errors.New(`Unknown security "` + c.Security + `".`) } - if c.TCPSettings == nil { + if c.RAWSettings != nil { c.TCPSettings = c.RAWSettings } if c.TCPSettings != nil { From 94338c94e93ba4296042c295708808a79ff53bc8 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 24 Oct 2024 02:06:31 +0000 Subject: [PATCH 577/867] README.md: Only list secure web panels (#3884) * README.md: Only list secure web panels * List Marzban * List Xray-UI * List Hiddify * Add warning * Update warning --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b3d2f2e6..3466fea7 100644 --- a/README.md +++ b/README.md @@ -33,12 +33,10 @@ - [ghcr.io/xtls/xray-core](https://ghcr.io/xtls/xray-core) (**Official**) - [teddysun/xray](https://hub.docker.com/r/teddysun/xray) - [wulabing/xray_docker](https://github.com/wulabing/xray_docker) -- Web Panel - - [3X-UI](https://github.com/MHSanaei/3x-ui), [X-UI](https://github.com/alireza0/x-ui), [Xray-UI](https://github.com/qist/xray-ui) - - [Hiddify](https://github.com/hiddify/hiddify-config) - - [Marzneshin](https://github.com/marzneshin/marzneshin) +- Web Panel - **Warning: These panels are verified to support HTTPS or SSH port forwarding only. Please DO NOT use plain HTTP panels like 3X-UI, as they are believed to be bought by Iran GFW and your data security will be dangerous. If you are already using 3X-UI, please switch to the following panels.** - [Marzban](https://github.com/Gozargah/Marzban) - - [Libertea](https://github.com/VZiChoushaDui/Libertea) + - [Xray-UI](https://github.com/qist/xray-ui) + - [Hiddify](https://github.com/hiddify/Hiddify-Manager) - One Click - [Xray-REALITY](https://github.com/zxcvos/Xray-script), [xray-reality](https://github.com/sajjaddg/xray-reality), [reality-ezpz](https://github.com/aleskxyz/reality-ezpz) - [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [XTool](https://github.com/LordPenguin666/XTool) From cf182b0482a40d05d2b8e3bbba0d6230200c8aac Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 27 Oct 2024 00:39:20 +0000 Subject: [PATCH 578/867] README.md: Update WARNING for Web Panel https://github.com/XTLS/Xray-core/pull/3884#issuecomment-2439606000 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3466fea7..bf974d13 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ - [ghcr.io/xtls/xray-core](https://ghcr.io/xtls/xray-core) (**Official**) - [teddysun/xray](https://hub.docker.com/r/teddysun/xray) - [wulabing/xray_docker](https://github.com/wulabing/xray_docker) -- Web Panel - **Warning: These panels are verified to support HTTPS or SSH port forwarding only. Please DO NOT use plain HTTP panels like 3X-UI, as they are believed to be bought by Iran GFW and your data security will be dangerous. If you are already using 3X-UI, please switch to the following panels.** +- Web Panel - **WARNING: Please DO NOT USE plain HTTP panels like 3X-UI**, as they are believed to be bribed by Iran GFW for supporting plain HTTP by default and refused to change (https://github.com/XTLS/Xray-core/pull/3884#issuecomment-2439595331), which has already put many users' data security in danger in the past few years. **If you are already using 3X-UI, please switch to the following panels, which are verified to support HTTPS and SSH port forwarding only:** - [Marzban](https://github.com/Gozargah/Marzban) - [Xray-UI](https://github.com/qist/xray-ui) - [Hiddify](https://github.com/hiddify/Hiddify-Manager) From ceb6eac8e70e6ae53277e66254c68c2d91d2a4c9 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 30 Oct 2024 02:20:55 +0000 Subject: [PATCH 579/867] WireGuard createTun: Add more logs --- proxy/wireguard/config.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proxy/wireguard/config.go b/proxy/wireguard/config.go index 8995f35e..e8a6630f 100644 --- a/proxy/wireguard/config.go +++ b/proxy/wireguard/config.go @@ -32,6 +32,7 @@ func (c *DeviceConfig) fallbackIP6() bool { func (c *DeviceConfig) createTun() tunCreator { if c.NoKernelTun { + errors.LogWarning(context.Background(), "Using gVisor TUN.") return createGVisorTun } kernelTunSupported, err := KernelTunSupported() @@ -40,8 +41,9 @@ func (c *DeviceConfig) createTun() tunCreator { return createGVisorTun } if !kernelTunSupported { - errors.LogWarning(context.Background(), "Using gVisor TUN. Kernel TUN is not supported on your OS, or your permission is insufficient.)") + errors.LogWarning(context.Background(), "Using gVisor TUN. Kernel TUN is not supported on your OS, or your permission is insufficient.") return createGVisorTun } + errors.LogWarning(context.Background(), "Using kernel TUN.") return createKernelTun } From 9f8bb476339240bba0d0e4c13b0b5e6a492fb37b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Wed, 30 Oct 2024 10:26:43 +0800 Subject: [PATCH 580/867] Fix: Apply mutex when visiting Attributes as well (#3921) https://github.com/XTLS/Xray-core/pull/3921#issuecomment-2445689462 --- common/protocol/http/sniff.go | 2 +- common/session/session.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/common/protocol/http/sniff.go b/common/protocol/http/sniff.go index e85a0792..40968294 100644 --- a/common/protocol/http/sniff.go +++ b/common/protocol/http/sniff.go @@ -63,7 +63,7 @@ func SniffHTTP(b []byte, c context.Context) (*SniffHeader, error) { ShouldSniffAttr := true // If content.Attributes have information, that means it comes from HTTP inbound PlainHTTP mode. // It will set attributes, so skip it. - if content == nil || len(content.Attributes) != 0 { + if content == nil || content.AttributeLen() != 0 { ShouldSniffAttr = false } if err := beginWithHTTPMethod(b); err != nil { diff --git a/common/session/session.go b/common/session/session.go index deb01f8c..4573b216 100644 --- a/common/session/session.go +++ b/common/session/session.go @@ -128,8 +128,24 @@ func (c *Content) SetAttribute(name string, value string) { // Attribute retrieves additional string attributes from content. func (c *Content) Attribute(name string) string { + c.mu.Lock() + c.isLocked = true + defer func() { + c.isLocked = false + c.mu.Unlock() + }() if c.Attributes == nil { return "" } return c.Attributes[name] } + +func (c *Content) AttributeLen() int { + c.mu.Lock() + c.isLocked = true + defer func() { + c.isLocked = false + c.mu.Unlock() + }() + return len(c.Attributes) +} \ No newline at end of file From e733148c0bf78f6298cf08045297e783568b80c9 Mon Sep 17 00:00:00 2001 From: mmmray <142015632+mmmray@users.noreply.github.com> Date: Wed, 30 Oct 2024 03:31:05 +0100 Subject: [PATCH 581/867] REALITY: Unblock SplitHTTP transport (#3816) https://github.com/XTLS/Xray-core/pull/3816#issuecomment-2445694775 --- infra/conf/transport_internet.go | 4 ++-- transport/internet/splithttp/dialer.go | 26 ++++++++++++++++++++++---- transport/internet/splithttp/hub.go | 6 ++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 096e9ab8..dcb640aa 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -838,8 +838,8 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { config.SecuritySettings = append(config.SecuritySettings, tm) config.SecurityType = tm.Type case "reality": - if config.ProtocolName != "tcp" && config.ProtocolName != "http" && config.ProtocolName != "grpc" { - return nil, errors.New("REALITY only supports TCP, H2 and gRPC for now.") + if config.ProtocolName != "tcp" && config.ProtocolName != "http" && config.ProtocolName != "grpc" && config.ProtocolName != "splithttp" { + return nil, errors.New("REALITY only supports TCP, H2, gRPC and SplitHTTP for now.") } if c.REALITYSettings == nil { return nil, errors.New(`REALITY: Empty "realitySettings".`) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 60f8c628..89f3b631 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -19,6 +19,7 @@ import ( "github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/browser_dialer" + "github.com/xtls/xray-core/transport/internet/reality" "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" "github.com/xtls/xray-core/transport/pipe" @@ -46,7 +47,9 @@ var ( ) func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (DialerClient, *muxResource) { - if browser_dialer.HasBrowserDialer() { + realityConfig := reality.ConfigFromStreamSettings(streamSettings) + + if browser_dialer.HasBrowserDialer() && realityConfig != nil { return &BrowserDialerClient{}, nil } @@ -80,8 +83,18 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStreamConfig) DialerClient { tlsConfig := tls.ConfigFromStreamSettings(streamSettings) - isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") - isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3") + realityConfig := reality.ConfigFromStreamSettings(streamSettings) + + isH2 := false + isH3 := false + + if tlsConfig != nil { + isH2 = !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") + isH3 = len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3" + } else if realityConfig != nil { + isH2 = true + isH3 = false + } if isH3 { dest.Network = net.Network_UDP @@ -101,6 +114,10 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea return nil, err } + if realityConfig != nil { + return reality.UClient(conn, realityConfig, ctxInner, dest) + } + if gotlsConfig != nil { if fingerprint := tls.GetFingerprint(tlsConfig.Fingerprint); fingerprint != nil { conn = tls.UClient(conn, gotlsConfig, fingerprint) @@ -215,12 +232,13 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me transportConfiguration := streamSettings.ProtocolSettings.(*Config) tlsConfig := tls.ConfigFromStreamSettings(streamSettings) + realityConfig := reality.ConfigFromStreamSettings(streamSettings) scMaxConcurrentPosts := transportConfiguration.GetNormalizedScMaxConcurrentPosts() scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes() scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs() - if tlsConfig != nil { + if tlsConfig != nil || realityConfig != nil { requestURL.Scheme = "https" } else { requestURL.Scheme = "http" diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 4545db64..b7244f10 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -13,12 +13,14 @@ import ( "github.com/quic-go/quic-go" "github.com/quic-go/quic-go/http3" + goreality "github.com/xtls/reality" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" http_proto "github.com/xtls/xray-core/common/protocol/http" "github.com/xtls/xray-core/common/signal/done" "github.com/xtls/xray-core/transport/internet" + "github.com/xtls/xray-core/transport/internet/reality" "github.com/xtls/xray-core/transport/internet/stat" v2tls "github.com/xtls/xray-core/transport/internet/tls" "golang.org/x/net/http2" @@ -344,6 +346,10 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet } } + if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { + listener = goreality.NewListener(listener, config.GetREALITYConfig()) + } + // h2cHandler can handle both plaintext HTTP/1.1 and h2c h2cHandler := h2c.NewHandler(handler, &http2.Server{}) l.listener = listener From b30e05d1bc9ab59efa17280ebd3730a2024e3041 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 31 Oct 2024 07:31:19 +0000 Subject: [PATCH 582/867] XHTTP: The real upload / download splitting (#3955) * SplitHTTP client: Add real upload / download splitting * Transport: Add XHTTP as an alias of SplitHTTP * XHTTP config: Use `downloadSettings` instead --- infra/conf/transport_internet.go | 23 +- transport/internet/config.pb.go | 279 ++++++++++++---------- transport/internet/config.proto | 4 + transport/internet/splithttp/config.pb.go | 194 ++++++++------- transport/internet/splithttp/config.proto | 3 + transport/internet/splithttp/dialer.go | 33 ++- 6 files changed, 317 insertions(+), 219 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index dcb640aa..c81123a3 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -232,6 +232,7 @@ type SplitHTTPConfig struct { NoSSEHeader bool `json:"noSSEHeader"` XPaddingBytes *Int32Range `json:"xPaddingBytes"` Xmux Xmux `json:"xmux"` + DownloadSettings *StreamConfig `json:"downloadSettings"` } type Xmux struct { @@ -299,6 +300,12 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), Xmux: &muxProtobuf, } + var err error + if c.DownloadSettings != nil { + if config.DownloadSettings, err = c.DownloadSettings.Build(); err != nil { + return nil, errors.New(`Failed to build "downloadSettings".`).Base(err) + } + } return config, nil } @@ -673,7 +680,7 @@ func (p TransportProtocol) Build() (string, error) { return "grpc", nil case "httpupgrade": return "httpupgrade", nil - case "splithttp": + case "xhttp", "splithttp": return "splithttp", nil default: return "", errors.New("Config: unknown transport protocol: ", p) @@ -796,6 +803,8 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { } type StreamConfig struct { + Address *Address `json:"address"` + Port uint16 `json:"port"` Network *TransportProtocol `json:"network"` Security string `json:"security"` TLSSettings *TLSConfig `json:"tlsSettings"` @@ -808,14 +817,19 @@ type StreamConfig struct { SocketSettings *SocketConfig `json:"sockopt"` GRPCConfig *GRPCConfig `json:"grpcSettings"` HTTPUPGRADESettings *HttpUpgradeConfig `json:"httpupgradeSettings"` + XHTTPSettings *SplitHTTPConfig `json:"xhttpSettings"` SplitHTTPSettings *SplitHTTPConfig `json:"splithttpSettings"` } // Build implements Buildable. func (c *StreamConfig) Build() (*internet.StreamConfig, error) { config := &internet.StreamConfig{ + Port: uint32(c.Port), ProtocolName: "tcp", } + if c.Address != nil { + config.Address = c.Address.Build() + } if c.Network != nil { protocol, err := c.Network.Build() if err != nil { @@ -839,7 +853,7 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { config.SecurityType = tm.Type case "reality": if config.ProtocolName != "tcp" && config.ProtocolName != "http" && config.ProtocolName != "grpc" && config.ProtocolName != "splithttp" { - return nil, errors.New("REALITY only supports TCP, H2, gRPC and SplitHTTP for now.") + return nil, errors.New("REALITY only supports RAW, H2, gRPC and XHTTP for now.") } if c.REALITYSettings == nil { return nil, errors.New(`REALITY: Empty "realitySettings".`) @@ -919,10 +933,13 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { Settings: serial.ToTypedMessage(hs), }) } + if c.XHTTPSettings != nil { + c.SplitHTTPSettings = c.XHTTPSettings + } if c.SplitHTTPSettings != nil { hs, err := c.SplitHTTPSettings.Build() if err != nil { - return nil, errors.New("Failed to build SplitHTTP config.").Base(err) + return nil, errors.New("Failed to build XHTTP config.").Base(err) } config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ ProtocolName: "splithttp", diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 1989851c..98e408e9 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -7,6 +7,7 @@ package internet import ( + net "github.com/xtls/xray-core/common/net" serial "github.com/xtls/xray-core/common/serial" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -206,6 +207,8 @@ type StreamConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + Address *net.IPOrDomain `protobuf:"bytes,8,opt,name=address,proto3" json:"address,omitempty"` + Port uint32 `protobuf:"varint,9,opt,name=port,proto3" json:"port,omitempty"` // Effective network. ProtocolName string `protobuf:"bytes,5,opt,name=protocol_name,json=protocolName,proto3" json:"protocol_name,omitempty"` TransportSettings []*TransportConfig `protobuf:"bytes,2,rep,name=transport_settings,json=transportSettings,proto3" json:"transport_settings,omitempty"` @@ -246,6 +249,20 @@ func (*StreamConfig) Descriptor() ([]byte, []int) { return file_transport_internet_config_proto_rawDescGZIP(), []int{1} } +func (x *StreamConfig) GetAddress() *net.IPOrDomain { + if x != nil { + return x.Address + } + return nil +} + +func (x *StreamConfig) GetPort() uint32 { + if x != nil { + return x.Port + } + return 0 +} + func (x *StreamConfig) GetProtocolName() string { if x != nil { return x.ProtocolName @@ -614,123 +631,129 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x6f, 0x12, 0x17, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x1a, 0x21, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x64, 0x5f, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, - 0x0f, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, - 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x3c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, - 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, + 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x74, 0x0a, 0x0f, 0x54, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x3c, 0x0a, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, + 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x9b, 0x03, + 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, + 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, + 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x09, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0c, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x57, + 0x0a, 0x12, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x53, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x65, 0x63, 0x75, 0x72, + 0x69, 0x74, 0x79, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4d, 0x0a, 0x11, + 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, - 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x08, 0x73, 0x65, 0x74, 0x74, 0x69, - 0x6e, 0x67, 0x73, 0x22, 0xd0, 0x02, 0x0a, 0x0c, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x23, 0x0a, 0x0d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x57, 0x0a, 0x12, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, - 0x11, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x5f, 0x74, - 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x65, 0x63, 0x75, 0x72, - 0x69, 0x74, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4d, 0x0a, 0x11, 0x73, 0x65, 0x63, 0x75, 0x72, - 0x69, 0x74, 0x79, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, - 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, - 0x73, 0x61, 0x67, 0x65, 0x52, 0x10, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x4e, 0x0a, 0x0f, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, - 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x51, 0x0a, 0x0b, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x30, 0x0a, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, - 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x22, 0x61, 0x0a, 0x0d, 0x43, 0x75, 0x73, - 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, - 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, - 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, - 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0x9f, 0x07, 0x0a, - 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, - 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, - 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, - 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, - 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x50, 0x72, 0x6f, 0x78, - 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x06, 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x41, 0x0a, - 0x1d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, - 0x6c, 0x5f, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x69, - 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x72, 0x74, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x62, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x72, 0x74, - 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x50, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, - 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, - 0x61, 0x6c, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x35, 0x0a, 0x17, 0x74, 0x63, 0x70, - 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x76, 0x61, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x14, 0x74, 0x63, 0x70, 0x4b, - 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, - 0x12, 0x2d, 0x0a, 0x13, 0x74, 0x63, 0x70, 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, - 0x76, 0x65, 0x5f, 0x69, 0x64, 0x6c, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, - 0x63, 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x64, 0x6c, 0x65, 0x12, - 0x25, 0x0a, 0x0e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x63, 0x70, 0x43, 0x6f, 0x6e, 0x67, - 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, - 0x61, 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x66, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0e, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x12, 0x28, 0x0a, 0x10, - 0x74, 0x63, 0x70, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x63, 0x6c, 0x61, 0x6d, 0x70, - 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x57, 0x69, 0x6e, 0x64, 0x6f, - 0x77, 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x75, 0x73, - 0x65, 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, - 0x12, 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x65, 0x67, 0x18, - 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x63, 0x70, 0x4d, 0x61, 0x78, 0x53, 0x65, 0x67, - 0x12, 0x20, 0x0a, 0x0c, 0x74, 0x63, 0x70, 0x5f, 0x6e, 0x6f, 0x5f, 0x64, 0x65, 0x6c, 0x61, 0x79, - 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x74, 0x63, 0x70, 0x4e, 0x6f, 0x44, 0x65, 0x6c, - 0x61, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x70, 0x74, 0x63, 0x70, 0x18, - 0x13, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74, 0x63, 0x70, 0x4d, 0x70, 0x74, 0x63, 0x70, 0x12, - 0x4c, 0x0a, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, - 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x52, 0x0d, - 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x22, 0x2f, 0x0a, - 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, - 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, - 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0xa9, - 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, - 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, - 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, - 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, - 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, - 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, - 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, - 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, - 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, - 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, - 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, - 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, - 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x10, 0x73, 0x65, 0x63, 0x75, 0x72, + 0x69, 0x74, 0x79, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x4e, 0x0a, 0x0f, 0x73, + 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x5f, 0x73, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, + 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x73, 0x6f, 0x63, + 0x6b, 0x65, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x51, 0x0a, 0x0b, 0x50, + 0x72, 0x6f, 0x78, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, + 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x30, 0x0a, 0x13, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, + 0x6f, 0x78, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x22, 0x61, + 0x0a, 0x0d, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x12, + 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x22, 0x9f, 0x07, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x06, 0x74, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x12, 0x41, 0x0a, 0x1d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x6f, 0x72, + 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, 0x65, 0x63, 0x65, 0x69, + 0x76, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x73, 0x74, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x69, 0x6e, + 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x69, 0x6e, 0x64, + 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x62, 0x69, 0x6e, + 0x64, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, + 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x50, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, + 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x44, 0x6f, 0x6d, + 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, + 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x64, + 0x69, 0x61, 0x6c, 0x65, 0x72, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x35, + 0x0a, 0x17, 0x74, 0x63, 0x70, 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, + 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x14, 0x74, 0x63, 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, + 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x2d, 0x0a, 0x13, 0x74, 0x63, 0x70, 0x5f, 0x6b, 0x65, 0x65, + 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x64, 0x6c, 0x65, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x10, 0x74, 0x63, 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, + 0x49, 0x64, 0x6c, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x67, + 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x63, + 0x70, 0x43, 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x36, 0x6f, + 0x6e, 0x6c, 0x79, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, + 0x79, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, + 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, + 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, 0x74, + 0x63, 0x70, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, + 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, 0x72, 0x54, 0x69, + 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x61, 0x78, + 0x5f, 0x73, 0x65, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x63, 0x70, 0x4d, + 0x61, 0x78, 0x53, 0x65, 0x67, 0x12, 0x20, 0x0a, 0x0c, 0x74, 0x63, 0x70, 0x5f, 0x6e, 0x6f, 0x5f, + 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x74, 0x63, 0x70, + 0x4e, 0x6f, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x63, 0x70, 0x5f, 0x6d, + 0x70, 0x74, 0x63, 0x70, 0x18, 0x13, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74, 0x63, 0x70, 0x4d, + 0x70, 0x74, 0x63, 0x70, 0x12, 0x4c, 0x0a, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, + 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, + 0x6f, 0x70, 0x74, 0x52, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, + 0x70, 0x74, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, + 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, + 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, + 0x74, 0x10, 0x02, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, + 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, + 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, + 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, + 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, + 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, + 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, + 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, + 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, + 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, + 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, + 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, + 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -756,20 +779,22 @@ var file_transport_internet_config_proto_goTypes = []any{ (*CustomSockopt)(nil), // 5: xray.transport.internet.CustomSockopt (*SocketConfig)(nil), // 6: xray.transport.internet.SocketConfig (*serial.TypedMessage)(nil), // 7: xray.common.serial.TypedMessage + (*net.IPOrDomain)(nil), // 8: xray.common.net.IPOrDomain } var file_transport_internet_config_proto_depIdxs = []int32{ 7, // 0: xray.transport.internet.TransportConfig.settings:type_name -> xray.common.serial.TypedMessage - 2, // 1: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig - 7, // 2: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage - 6, // 3: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig - 1, // 4: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode - 0, // 5: xray.transport.internet.SocketConfig.domain_strategy:type_name -> xray.transport.internet.DomainStrategy - 5, // 6: xray.transport.internet.SocketConfig.customSockopt:type_name -> xray.transport.internet.CustomSockopt - 7, // [7:7] is the sub-list for method output_type - 7, // [7:7] is the sub-list for method input_type - 7, // [7:7] is the sub-list for extension type_name - 7, // [7:7] is the sub-list for extension extendee - 0, // [0:7] is the sub-list for field type_name + 8, // 1: xray.transport.internet.StreamConfig.address:type_name -> xray.common.net.IPOrDomain + 2, // 2: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig + 7, // 3: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage + 6, // 4: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig + 1, // 5: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode + 0, // 6: xray.transport.internet.SocketConfig.domain_strategy:type_name -> xray.transport.internet.DomainStrategy + 5, // 7: xray.transport.internet.SocketConfig.customSockopt:type_name -> xray.transport.internet.CustomSockopt + 8, // [8:8] is the sub-list for method output_type + 8, // [8:8] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_transport_internet_config_proto_init() } diff --git a/transport/internet/config.proto b/transport/internet/config.proto index b892deb3..008e33c6 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -7,6 +7,7 @@ option java_package = "com.xray.transport.internet"; option java_multiple_files = true; import "common/serial/typed_message.proto"; +import "common/net/address.proto"; enum DomainStrategy { AS_IS = 0; @@ -31,6 +32,9 @@ message TransportConfig { } message StreamConfig { + xray.common.net.IPOrDomain address = 8; + uint32 port = 9; + // Effective network. string protocol_name = 5; diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index db09180d..f3f80831 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -7,6 +7,7 @@ package splithttp import ( + internet "github.com/xtls/xray-core/transport/internet" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -25,15 +26,16 @@ type Config struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - Header map[string]string `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - ScMaxConcurrentPosts *RandRangeConfig `protobuf:"bytes,4,opt,name=scMaxConcurrentPosts,proto3" json:"scMaxConcurrentPosts,omitempty"` - ScMaxEachPostBytes *RandRangeConfig `protobuf:"bytes,5,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` - ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` - NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` - XPaddingBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` - Xmux *Multiplexing `protobuf:"bytes,9,opt,name=xmux,proto3" json:"xmux,omitempty"` + Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` + Header map[string]string `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + ScMaxConcurrentPosts *RandRangeConfig `protobuf:"bytes,4,opt,name=scMaxConcurrentPosts,proto3" json:"scMaxConcurrentPosts,omitempty"` + ScMaxEachPostBytes *RandRangeConfig `protobuf:"bytes,5,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` + ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` + NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` + XPaddingBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` + Xmux *Multiplexing `protobuf:"bytes,9,opt,name=xmux,proto3" json:"xmux,omitempty"` + DownloadSettings *internet.StreamConfig `protobuf:"bytes,10,opt,name=downloadSettings,proto3" json:"downloadSettings,omitempty"` } func (x *Config) Reset() { @@ -129,6 +131,13 @@ func (x *Config) GetXmux() *Multiplexing { return nil } +func (x *Config) GetDownloadSettings() *internet.StreamConfig { + if x != nil { + return x.DownloadSettings + } + return nil +} + type RandRangeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -258,87 +267,94 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x22, 0xaf, - 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x35, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, - 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x12, 0x66, 0x0a, 0x14, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x1a, 0x1f, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x82, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, + 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, + 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, + 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, + 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x12, 0x66, 0x0a, 0x14, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, + 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x52, 0x14, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, + 0x72, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x62, 0x0a, 0x12, 0x73, 0x63, 0x4d, + 0x61, 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, + 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, + 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, + 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x66, 0x0a, + 0x14, 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, + 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, + 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, + 0x14, 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, + 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, + 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, 0x53, + 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, + 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x14, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x62, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, - 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, + 0x69, 0x67, 0x52, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, + 0x73, 0x12, 0x43, 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, + 0x74, 0x74, 0x70, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, + 0x52, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x12, 0x51, 0x0a, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, + 0x61, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, + 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, + 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, + 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, + 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, 0x0a, 0x0c, + 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, 0x0a, 0x0e, + 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, - 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x45, - 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x66, 0x0a, 0x14, - 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, - 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, - 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x14, - 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, - 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, - 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, - 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x52, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, - 0x12, 0x43, 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, - 0x74, 0x70, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, - 0x04, 0x78, 0x6d, 0x75, 0x78, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, - 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, - 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, - 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, + 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, + 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, - 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, + 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, + 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, + 0x4d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, - 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, - 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, - 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, - 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, - 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, - 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, 0x01, 0x0a, + 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, + 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, + 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, + 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -355,10 +371,11 @@ func file_transport_internet_splithttp_config_proto_rawDescGZIP() []byte { var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_transport_internet_splithttp_config_proto_goTypes = []any{ - (*Config)(nil), // 0: xray.transport.internet.splithttp.Config - (*RandRangeConfig)(nil), // 1: xray.transport.internet.splithttp.RandRangeConfig - (*Multiplexing)(nil), // 2: xray.transport.internet.splithttp.Multiplexing - nil, // 3: xray.transport.internet.splithttp.Config.HeaderEntry + (*Config)(nil), // 0: xray.transport.internet.splithttp.Config + (*RandRangeConfig)(nil), // 1: xray.transport.internet.splithttp.RandRangeConfig + (*Multiplexing)(nil), // 2: xray.transport.internet.splithttp.Multiplexing + nil, // 3: xray.transport.internet.splithttp.Config.HeaderEntry + (*internet.StreamConfig)(nil), // 4: xray.transport.internet.StreamConfig } var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 3, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry @@ -367,15 +384,16 @@ var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 1, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 4: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 2, // 5: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.Multiplexing - 1, // 6: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 7: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 8: xray.transport.internet.splithttp.Multiplexing.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 9: xray.transport.internet.splithttp.Multiplexing.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 10, // [10:10] is the sub-list for method output_type - 10, // [10:10] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name + 4, // 6: xray.transport.internet.splithttp.Config.downloadSettings:type_name -> xray.transport.internet.StreamConfig + 1, // 7: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 8: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 9: xray.transport.internet.splithttp.Multiplexing.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 10: xray.transport.internet.splithttp.Multiplexing.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_transport_internet_splithttp_config_proto_init() } diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 249f1e93..384ae605 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -6,6 +6,8 @@ option go_package = "github.com/xtls/xray-core/transport/internet/splithttp"; option java_package = "com.xray.transport.internet.splithttp"; option java_multiple_files = true; +import "transport/internet/config.proto"; + message Config { string host = 1; string path = 2; @@ -16,6 +18,7 @@ message Config { bool noSSEHeader = 7; RandRangeConfig xPaddingBytes = 8; Multiplexing xmux = 9; + xray.transport.internet.StreamConfig downloadSettings = 10; } message RandRangeConfig { diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 89f3b631..c43783ec 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -254,6 +254,30 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me httpClient, muxResource := getHTTPClient(ctx, dest, streamSettings) + var httpClient2 DialerClient + var requestURL2 url.URL + if transportConfiguration.DownloadSettings != nil { + dest2 := net.Destination{ + Address: transportConfiguration.DownloadSettings.Address.AsAddress(), // just panic + Port: net.Port(transportConfiguration.DownloadSettings.Port), + Network: net.Network_TCP, + } + memory2 := common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings)).(*internet.MemoryStreamConfig) + httpClient2, _ = getHTTPClient(ctx, dest2, memory2) // no multiplex + if tls.ConfigFromStreamSettings(memory2) != nil || reality.ConfigFromStreamSettings(memory2) != nil { + requestURL2.Scheme = "https" + } else { + requestURL2.Scheme = "http" + } + config2 := memory2.ProtocolSettings.(*Config) + requestURL2.Host = config2.Host + if requestURL2.Host == "" { + requestURL2.Host = dest2.NetAddr() + } + requestURL2.Path = requestURL.Path // the same + requestURL2.RawQuery = config2.GetNormalizedQuery() + } + maxUploadSize := scMaxEachPostBytes.roll() // WithSizeLimit(0) will still allow single bytes to pass, and a lot of // code relies on this behavior. Subtract 1 so that together with @@ -321,7 +345,14 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } }() - reader, remoteAddr, localAddr, err := httpClient.OpenDownload(context.WithoutCancel(ctx), requestURL.String()) + httpClient3 := httpClient + requestURL3 := requestURL + if httpClient2 != nil { + httpClient3 = httpClient2 + requestURL3 = requestURL2 + } + + reader, remoteAddr, localAddr, err := httpClient3.OpenDownload(context.WithoutCancel(ctx), requestURL3.String()) if err != nil { return nil, err } From 4ec5c78c3453ddcf0c9015c15a34c677218717a1 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 31 Oct 2024 07:58:31 +0000 Subject: [PATCH 583/867] v24.10.31 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index ecefc296..8f2950c5 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 24 Version_y byte = 10 - Version_z byte = 16 + Version_z byte = 31 ) var ( From b7aacd3245450f5ecfaae76417feaa9d3e8559d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 1 Nov 2024 22:20:04 +0800 Subject: [PATCH 584/867] Wireguard inbound: Do not use kernel TUN (#3960) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- proxy/wireguard/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/proxy/wireguard/config.go b/proxy/wireguard/config.go index e8a6630f..cbaa670b 100644 --- a/proxy/wireguard/config.go +++ b/proxy/wireguard/config.go @@ -31,8 +31,13 @@ func (c *DeviceConfig) fallbackIP6() bool { } func (c *DeviceConfig) createTun() tunCreator { + if !c.IsClient { + // See tun_linux.go createKernelTun() + errors.LogWarning(context.Background(), "Using gVisor TUN. WG inbound doesn't support kernel TUN yet.") + return createGVisorTun + } if c.NoKernelTun { - errors.LogWarning(context.Background(), "Using gVisor TUN.") + errors.LogWarning(context.Background(), "Using gVisor TUN. NoKernelTun is set to true.") return createGVisorTun } kernelTunSupported, err := KernelTunSupported() From 85a1c337090dc8f7d2cd5d8ac200946574bcdc70 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sun, 3 Nov 2024 00:25:23 -0400 Subject: [PATCH 585/867] API: Add new Get Inbound User (#3644) * Add GetInboundUser in proto * Add get user logic for all existing inbounds * Add inbounduser command * Add option to get all users * Fix shadowsocks2022 config * Fix init users in shadowsocks2022 * Fix copy * Add inbound user count command This api costs much less than get inbound user, could be useful in some case * Update from latest main --- app/proxyman/command/command.go | 41 ++ app/proxyman/command/command.pb.go | 445 ++++++++++++++------ app/proxyman/command/command.proto | 17 + app/proxyman/command/command_grpc.pb.go | 88 +++- common/protocol/account.go | 3 + common/protocol/user.go | 16 +- core/proto.go | 4 +- infra/conf/shadowsocks.go | 10 +- main/commands/all/api/api.go | 2 + main/commands/all/api/inbound_user.go | 50 +++ main/commands/all/api/inbound_user_count.go | 45 ++ proxy/http/config.go | 6 + proxy/proxy.go | 9 + proxy/shadowsocks/config.go | 17 +- proxy/shadowsocks/server.go | 15 + proxy/shadowsocks/validator.go | 34 ++ proxy/shadowsocks_2022/config.go | 14 +- proxy/shadowsocks_2022/config.pb.go | 182 ++++---- proxy/shadowsocks_2022/config.proto | 7 +- proxy/shadowsocks_2022/inbound_multi.go | 92 ++-- proxy/socks/config.go | 10 +- proxy/trojan/config.go | 9 +- proxy/trojan/server.go | 15 + proxy/trojan/validator.go | 30 ++ proxy/vless/account.go | 10 + proxy/vless/inbound/inbound.go | 15 + proxy/vless/validator.go | 32 ++ proxy/vmess/account.go | 16 + proxy/vmess/inbound/inbound.go | 27 +- proxy/vmess/validator.go | 14 + 30 files changed, 982 insertions(+), 293 deletions(-) create mode 100644 main/commands/all/api/inbound_user.go create mode 100644 main/commands/all/api/inbound_user_count.go diff --git a/app/proxyman/command/command.go b/app/proxyman/command/command.go index 4554f32b..3c7824d2 100644 --- a/app/proxyman/command/command.go +++ b/app/proxyman/command/command.go @@ -5,6 +5,7 @@ import ( "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/inbound" "github.com/xtls/xray-core/features/outbound" @@ -98,6 +99,46 @@ func (s *handlerServer) AlterInbound(ctx context.Context, request *AlterInboundR return &AlterInboundResponse{}, operation.ApplyInbound(ctx, handler) } +func (s *handlerServer) GetInboundUsers(ctx context.Context, request *GetInboundUserRequest) (*GetInboundUserResponse, error) { + handler, err := s.ihm.GetHandler(ctx, request.Tag) + if err != nil { + return nil, errors.New("failed to get handler: ", request.Tag).Base(err) + } + p, err := getInbound(handler) + if err != nil { + return nil, err + } + um, ok := p.(proxy.UserManager) + if !ok { + return nil, errors.New("proxy is not a UserManager") + } + if len(request.Email) > 0 { + return &GetInboundUserResponse{Users: []*protocol.User{protocol.ToProtoUser(um.GetUser(ctx, request.Email))}}, nil + } + var result = make([]*protocol.User, 0, 100) + users := um.GetUsers(ctx) + for _, u := range users { + result = append(result, protocol.ToProtoUser(u)) + } + return &GetInboundUserResponse{Users: result}, nil +} + +func (s *handlerServer) GetInboundUsersCount(ctx context.Context, request *GetInboundUserRequest) (*GetInboundUsersCountResponse, error) { + handler, err := s.ihm.GetHandler(ctx, request.Tag) + if err != nil { + return nil, errors.New("failed to get handler: ", request.Tag).Base(err) + } + p, err := getInbound(handler) + if err != nil { + return nil, err + } + um, ok := p.(proxy.UserManager) + if !ok { + return nil, errors.New("proxy is not a UserManager") + } + return &GetInboundUsersCountResponse{Count: um.GetUsersCount(ctx)}, nil +} + func (s *handlerServer) AddOutbound(ctx context.Context, request *AddOutboundRequest) (*AddOutboundResponse, error) { if err := core.AddOutboundHandler(s.s, request.Outbound); err != nil { return nil, err diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index 32a29cc6..a98da103 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -364,6 +364,149 @@ func (*AlterInboundResponse) Descriptor() ([]byte, []int) { return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{7} } +type GetInboundUserRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` + Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` +} + +func (x *GetInboundUserRequest) Reset() { + *x = GetInboundUserRequest{} + mi := &file_app_proxyman_command_command_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInboundUserRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInboundUserRequest) ProtoMessage() {} + +func (x *GetInboundUserRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_proxyman_command_command_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInboundUserRequest.ProtoReflect.Descriptor instead. +func (*GetInboundUserRequest) Descriptor() ([]byte, []int) { + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{8} +} + +func (x *GetInboundUserRequest) GetTag() string { + if x != nil { + return x.Tag + } + return "" +} + +func (x *GetInboundUserRequest) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +type GetInboundUserResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Users []*protocol.User `protobuf:"bytes,1,rep,name=users,proto3" json:"users,omitempty"` +} + +func (x *GetInboundUserResponse) Reset() { + *x = GetInboundUserResponse{} + mi := &file_app_proxyman_command_command_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInboundUserResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInboundUserResponse) ProtoMessage() {} + +func (x *GetInboundUserResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_proxyman_command_command_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInboundUserResponse.ProtoReflect.Descriptor instead. +func (*GetInboundUserResponse) Descriptor() ([]byte, []int) { + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{9} +} + +func (x *GetInboundUserResponse) GetUsers() []*protocol.User { + if x != nil { + return x.Users + } + return nil +} + +type GetInboundUsersCountResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` +} + +func (x *GetInboundUsersCountResponse) Reset() { + *x = GetInboundUsersCountResponse{} + mi := &file_app_proxyman_command_command_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetInboundUsersCountResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetInboundUsersCountResponse) ProtoMessage() {} + +func (x *GetInboundUsersCountResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_proxyman_command_command_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetInboundUsersCountResponse.ProtoReflect.Descriptor instead. +func (*GetInboundUsersCountResponse) Descriptor() ([]byte, []int) { + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{10} +} + +func (x *GetInboundUsersCountResponse) GetCount() int64 { + if x != nil { + return x.Count + } + return 0 +} + type AddOutboundRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -374,7 +517,7 @@ type AddOutboundRequest struct { func (x *AddOutboundRequest) Reset() { *x = AddOutboundRequest{} - mi := &file_app_proxyman_command_command_proto_msgTypes[8] + mi := &file_app_proxyman_command_command_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -386,7 +529,7 @@ func (x *AddOutboundRequest) String() string { func (*AddOutboundRequest) ProtoMessage() {} func (x *AddOutboundRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[8] + mi := &file_app_proxyman_command_command_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -399,7 +542,7 @@ func (x *AddOutboundRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AddOutboundRequest.ProtoReflect.Descriptor instead. func (*AddOutboundRequest) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{8} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{11} } func (x *AddOutboundRequest) GetOutbound() *core.OutboundHandlerConfig { @@ -417,7 +560,7 @@ type AddOutboundResponse struct { func (x *AddOutboundResponse) Reset() { *x = AddOutboundResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[9] + mi := &file_app_proxyman_command_command_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -429,7 +572,7 @@ func (x *AddOutboundResponse) String() string { func (*AddOutboundResponse) ProtoMessage() {} func (x *AddOutboundResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[9] + mi := &file_app_proxyman_command_command_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -442,7 +585,7 @@ func (x *AddOutboundResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AddOutboundResponse.ProtoReflect.Descriptor instead. func (*AddOutboundResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{9} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{12} } type RemoveOutboundRequest struct { @@ -455,7 +598,7 @@ type RemoveOutboundRequest struct { func (x *RemoveOutboundRequest) Reset() { *x = RemoveOutboundRequest{} - mi := &file_app_proxyman_command_command_proto_msgTypes[10] + mi := &file_app_proxyman_command_command_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -467,7 +610,7 @@ func (x *RemoveOutboundRequest) String() string { func (*RemoveOutboundRequest) ProtoMessage() {} func (x *RemoveOutboundRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[10] + mi := &file_app_proxyman_command_command_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -480,7 +623,7 @@ func (x *RemoveOutboundRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveOutboundRequest.ProtoReflect.Descriptor instead. func (*RemoveOutboundRequest) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{10} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{13} } func (x *RemoveOutboundRequest) GetTag() string { @@ -498,7 +641,7 @@ type RemoveOutboundResponse struct { func (x *RemoveOutboundResponse) Reset() { *x = RemoveOutboundResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[11] + mi := &file_app_proxyman_command_command_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -510,7 +653,7 @@ func (x *RemoveOutboundResponse) String() string { func (*RemoveOutboundResponse) ProtoMessage() {} func (x *RemoveOutboundResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[11] + mi := &file_app_proxyman_command_command_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -523,7 +666,7 @@ func (x *RemoveOutboundResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveOutboundResponse.ProtoReflect.Descriptor instead. func (*RemoveOutboundResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{11} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{14} } type AlterOutboundRequest struct { @@ -537,7 +680,7 @@ type AlterOutboundRequest struct { func (x *AlterOutboundRequest) Reset() { *x = AlterOutboundRequest{} - mi := &file_app_proxyman_command_command_proto_msgTypes[12] + mi := &file_app_proxyman_command_command_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -549,7 +692,7 @@ func (x *AlterOutboundRequest) String() string { func (*AlterOutboundRequest) ProtoMessage() {} func (x *AlterOutboundRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[12] + mi := &file_app_proxyman_command_command_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -562,7 +705,7 @@ func (x *AlterOutboundRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AlterOutboundRequest.ProtoReflect.Descriptor instead. func (*AlterOutboundRequest) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{12} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{15} } func (x *AlterOutboundRequest) GetTag() string { @@ -587,7 +730,7 @@ type AlterOutboundResponse struct { func (x *AlterOutboundResponse) Reset() { *x = AlterOutboundResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[13] + mi := &file_app_proxyman_command_command_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -599,7 +742,7 @@ func (x *AlterOutboundResponse) String() string { func (*AlterOutboundResponse) ProtoMessage() {} func (x *AlterOutboundResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[13] + mi := &file_app_proxyman_command_command_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -612,7 +755,7 @@ func (x *AlterOutboundResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AlterOutboundResponse.ProtoReflect.Descriptor instead. func (*AlterOutboundResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{13} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{16} } type Config struct { @@ -623,7 +766,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - mi := &file_app_proxyman_command_command_proto_msgTypes[14] + mi := &file_app_proxyman_command_command_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -635,7 +778,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[14] + mi := &file_app_proxyman_command_command_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -648,7 +791,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{14} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{17} } var File_app_proxyman_command_command_proto protoreflect.FileDescriptor @@ -688,79 +831,107 @@ var file_app_proxyman_command_command_proto_rawDesc = []byte{ 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x16, 0x0a, 0x14, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x52, 0x0a, 0x12, - 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, - 0x2e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, - 0x22, 0x15, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, - 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, - 0x61, 0x67, 0x22, 0x18, 0x0a, 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x68, 0x0a, 0x14, - 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x3e, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, - 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, 0x6f, 0x70, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x17, 0x0a, 0x15, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, + 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3f, 0x0a, 0x15, + 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x4a, 0x0a, + 0x16, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x22, 0x34, 0x0a, 0x1c, 0x47, 0x65, 0x74, + 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0x52, 0x0a, 0x12, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, + 0x6f, 0x72, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, + 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, + 0x75, 0x6e, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x15, 0x52, 0x65, + 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x18, 0x0a, 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xc5, 0x05, 0x0a, 0x0e, 0x48, 0x61, - 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x0a, - 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2c, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, - 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, 0x0a, 0x0d, 0x52, 0x65, 0x6d, - 0x6f, 0x76, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2f, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x49, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x78, 0x72, + 0x68, 0x0a, 0x14, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x3e, 0x0a, 0x09, 0x6f, 0x70, 0x65, + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, + 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, + 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x17, 0x0a, 0x15, 0x41, 0x6c, 0x74, + 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xc5, 0x07, 0x0a, + 0x0e, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, + 0x6b, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2c, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, + 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x49, 0x6e, - 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x71, 0x0a, 0x0c, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, - 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, - 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, 0x0a, 0x0d, + 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2f, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, + 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, + 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, + 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x71, 0x0a, 0x0c, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x12, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, + 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, + 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x78, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, + 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x83, 0x01, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, + 0x65, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x37, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6e, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x2e, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, + 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x77, 0x0a, 0x0e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, + 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, + 0x0a, 0x0d, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, - 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x6e, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, - 0x64, 0x12, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, - 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, - 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x77, 0x0a, 0x0e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, - 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, 0x0a, 0x0d, 0x41, - 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2f, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, - 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, - 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, - 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x6d, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, - 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, - 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2f, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x19, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, - 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, + 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x42, 0x6d, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, + 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2f, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x19, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, + 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -775,51 +946,59 @@ func file_app_proxyman_command_command_proto_rawDescGZIP() []byte { return file_app_proxyman_command_command_proto_rawDescData } -var file_app_proxyman_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_app_proxyman_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 18) var file_app_proxyman_command_command_proto_goTypes = []any{ - (*AddUserOperation)(nil), // 0: xray.app.proxyman.command.AddUserOperation - (*RemoveUserOperation)(nil), // 1: xray.app.proxyman.command.RemoveUserOperation - (*AddInboundRequest)(nil), // 2: xray.app.proxyman.command.AddInboundRequest - (*AddInboundResponse)(nil), // 3: xray.app.proxyman.command.AddInboundResponse - (*RemoveInboundRequest)(nil), // 4: xray.app.proxyman.command.RemoveInboundRequest - (*RemoveInboundResponse)(nil), // 5: xray.app.proxyman.command.RemoveInboundResponse - (*AlterInboundRequest)(nil), // 6: xray.app.proxyman.command.AlterInboundRequest - (*AlterInboundResponse)(nil), // 7: xray.app.proxyman.command.AlterInboundResponse - (*AddOutboundRequest)(nil), // 8: xray.app.proxyman.command.AddOutboundRequest - (*AddOutboundResponse)(nil), // 9: xray.app.proxyman.command.AddOutboundResponse - (*RemoveOutboundRequest)(nil), // 10: xray.app.proxyman.command.RemoveOutboundRequest - (*RemoveOutboundResponse)(nil), // 11: xray.app.proxyman.command.RemoveOutboundResponse - (*AlterOutboundRequest)(nil), // 12: xray.app.proxyman.command.AlterOutboundRequest - (*AlterOutboundResponse)(nil), // 13: xray.app.proxyman.command.AlterOutboundResponse - (*Config)(nil), // 14: xray.app.proxyman.command.Config - (*protocol.User)(nil), // 15: xray.common.protocol.User - (*core.InboundHandlerConfig)(nil), // 16: xray.core.InboundHandlerConfig - (*serial.TypedMessage)(nil), // 17: xray.common.serial.TypedMessage - (*core.OutboundHandlerConfig)(nil), // 18: xray.core.OutboundHandlerConfig + (*AddUserOperation)(nil), // 0: xray.app.proxyman.command.AddUserOperation + (*RemoveUserOperation)(nil), // 1: xray.app.proxyman.command.RemoveUserOperation + (*AddInboundRequest)(nil), // 2: xray.app.proxyman.command.AddInboundRequest + (*AddInboundResponse)(nil), // 3: xray.app.proxyman.command.AddInboundResponse + (*RemoveInboundRequest)(nil), // 4: xray.app.proxyman.command.RemoveInboundRequest + (*RemoveInboundResponse)(nil), // 5: xray.app.proxyman.command.RemoveInboundResponse + (*AlterInboundRequest)(nil), // 6: xray.app.proxyman.command.AlterInboundRequest + (*AlterInboundResponse)(nil), // 7: xray.app.proxyman.command.AlterInboundResponse + (*GetInboundUserRequest)(nil), // 8: xray.app.proxyman.command.GetInboundUserRequest + (*GetInboundUserResponse)(nil), // 9: xray.app.proxyman.command.GetInboundUserResponse + (*GetInboundUsersCountResponse)(nil), // 10: xray.app.proxyman.command.GetInboundUsersCountResponse + (*AddOutboundRequest)(nil), // 11: xray.app.proxyman.command.AddOutboundRequest + (*AddOutboundResponse)(nil), // 12: xray.app.proxyman.command.AddOutboundResponse + (*RemoveOutboundRequest)(nil), // 13: xray.app.proxyman.command.RemoveOutboundRequest + (*RemoveOutboundResponse)(nil), // 14: xray.app.proxyman.command.RemoveOutboundResponse + (*AlterOutboundRequest)(nil), // 15: xray.app.proxyman.command.AlterOutboundRequest + (*AlterOutboundResponse)(nil), // 16: xray.app.proxyman.command.AlterOutboundResponse + (*Config)(nil), // 17: xray.app.proxyman.command.Config + (*protocol.User)(nil), // 18: xray.common.protocol.User + (*core.InboundHandlerConfig)(nil), // 19: xray.core.InboundHandlerConfig + (*serial.TypedMessage)(nil), // 20: xray.common.serial.TypedMessage + (*core.OutboundHandlerConfig)(nil), // 21: xray.core.OutboundHandlerConfig } var file_app_proxyman_command_command_proto_depIdxs = []int32{ - 15, // 0: xray.app.proxyman.command.AddUserOperation.user:type_name -> xray.common.protocol.User - 16, // 1: xray.app.proxyman.command.AddInboundRequest.inbound:type_name -> xray.core.InboundHandlerConfig - 17, // 2: xray.app.proxyman.command.AlterInboundRequest.operation:type_name -> xray.common.serial.TypedMessage - 18, // 3: xray.app.proxyman.command.AddOutboundRequest.outbound:type_name -> xray.core.OutboundHandlerConfig - 17, // 4: xray.app.proxyman.command.AlterOutboundRequest.operation:type_name -> xray.common.serial.TypedMessage - 2, // 5: xray.app.proxyman.command.HandlerService.AddInbound:input_type -> xray.app.proxyman.command.AddInboundRequest - 4, // 6: xray.app.proxyman.command.HandlerService.RemoveInbound:input_type -> xray.app.proxyman.command.RemoveInboundRequest - 6, // 7: xray.app.proxyman.command.HandlerService.AlterInbound:input_type -> xray.app.proxyman.command.AlterInboundRequest - 8, // 8: xray.app.proxyman.command.HandlerService.AddOutbound:input_type -> xray.app.proxyman.command.AddOutboundRequest - 10, // 9: xray.app.proxyman.command.HandlerService.RemoveOutbound:input_type -> xray.app.proxyman.command.RemoveOutboundRequest - 12, // 10: xray.app.proxyman.command.HandlerService.AlterOutbound:input_type -> xray.app.proxyman.command.AlterOutboundRequest - 3, // 11: xray.app.proxyman.command.HandlerService.AddInbound:output_type -> xray.app.proxyman.command.AddInboundResponse - 5, // 12: xray.app.proxyman.command.HandlerService.RemoveInbound:output_type -> xray.app.proxyman.command.RemoveInboundResponse - 7, // 13: xray.app.proxyman.command.HandlerService.AlterInbound:output_type -> xray.app.proxyman.command.AlterInboundResponse - 9, // 14: xray.app.proxyman.command.HandlerService.AddOutbound:output_type -> xray.app.proxyman.command.AddOutboundResponse - 11, // 15: xray.app.proxyman.command.HandlerService.RemoveOutbound:output_type -> xray.app.proxyman.command.RemoveOutboundResponse - 13, // 16: xray.app.proxyman.command.HandlerService.AlterOutbound:output_type -> xray.app.proxyman.command.AlterOutboundResponse - 11, // [11:17] is the sub-list for method output_type - 5, // [5:11] is the sub-list for method input_type - 5, // [5:5] is the sub-list for extension type_name - 5, // [5:5] is the sub-list for extension extendee - 0, // [0:5] is the sub-list for field type_name + 18, // 0: xray.app.proxyman.command.AddUserOperation.user:type_name -> xray.common.protocol.User + 19, // 1: xray.app.proxyman.command.AddInboundRequest.inbound:type_name -> xray.core.InboundHandlerConfig + 20, // 2: xray.app.proxyman.command.AlterInboundRequest.operation:type_name -> xray.common.serial.TypedMessage + 18, // 3: xray.app.proxyman.command.GetInboundUserResponse.users:type_name -> xray.common.protocol.User + 21, // 4: xray.app.proxyman.command.AddOutboundRequest.outbound:type_name -> xray.core.OutboundHandlerConfig + 20, // 5: xray.app.proxyman.command.AlterOutboundRequest.operation:type_name -> xray.common.serial.TypedMessage + 2, // 6: xray.app.proxyman.command.HandlerService.AddInbound:input_type -> xray.app.proxyman.command.AddInboundRequest + 4, // 7: xray.app.proxyman.command.HandlerService.RemoveInbound:input_type -> xray.app.proxyman.command.RemoveInboundRequest + 6, // 8: xray.app.proxyman.command.HandlerService.AlterInbound:input_type -> xray.app.proxyman.command.AlterInboundRequest + 8, // 9: xray.app.proxyman.command.HandlerService.GetInboundUsers:input_type -> xray.app.proxyman.command.GetInboundUserRequest + 8, // 10: xray.app.proxyman.command.HandlerService.GetInboundUsersCount:input_type -> xray.app.proxyman.command.GetInboundUserRequest + 11, // 11: xray.app.proxyman.command.HandlerService.AddOutbound:input_type -> xray.app.proxyman.command.AddOutboundRequest + 13, // 12: xray.app.proxyman.command.HandlerService.RemoveOutbound:input_type -> xray.app.proxyman.command.RemoveOutboundRequest + 15, // 13: xray.app.proxyman.command.HandlerService.AlterOutbound:input_type -> xray.app.proxyman.command.AlterOutboundRequest + 3, // 14: xray.app.proxyman.command.HandlerService.AddInbound:output_type -> xray.app.proxyman.command.AddInboundResponse + 5, // 15: xray.app.proxyman.command.HandlerService.RemoveInbound:output_type -> xray.app.proxyman.command.RemoveInboundResponse + 7, // 16: xray.app.proxyman.command.HandlerService.AlterInbound:output_type -> xray.app.proxyman.command.AlterInboundResponse + 9, // 17: xray.app.proxyman.command.HandlerService.GetInboundUsers:output_type -> xray.app.proxyman.command.GetInboundUserResponse + 10, // 18: xray.app.proxyman.command.HandlerService.GetInboundUsersCount:output_type -> xray.app.proxyman.command.GetInboundUsersCountResponse + 12, // 19: xray.app.proxyman.command.HandlerService.AddOutbound:output_type -> xray.app.proxyman.command.AddOutboundResponse + 14, // 20: xray.app.proxyman.command.HandlerService.RemoveOutbound:output_type -> xray.app.proxyman.command.RemoveOutboundResponse + 16, // 21: xray.app.proxyman.command.HandlerService.AlterOutbound:output_type -> xray.app.proxyman.command.AlterOutboundResponse + 14, // [14:22] is the sub-list for method output_type + 6, // [6:14] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_app_proxyman_command_command_proto_init() } @@ -833,7 +1012,7 @@ func file_app_proxyman_command_command_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_proxyman_command_command_proto_rawDesc, NumEnums: 0, - NumMessages: 15, + NumMessages: 18, NumExtensions: 0, NumServices: 1, }, diff --git a/app/proxyman/command/command.proto b/app/proxyman/command/command.proto index 5a09bd88..9a2d0142 100644 --- a/app/proxyman/command/command.proto +++ b/app/proxyman/command/command.proto @@ -37,6 +37,19 @@ message AlterInboundRequest { message AlterInboundResponse {} +message GetInboundUserRequest { + string tag = 1; + string email = 2; +} + +message GetInboundUserResponse { + repeated xray.common.protocol.User users = 1; +} + +message GetInboundUsersCountResponse { + int64 count = 1; +} + message AddOutboundRequest { core.OutboundHandlerConfig outbound = 1; } @@ -63,6 +76,10 @@ service HandlerService { rpc AlterInbound(AlterInboundRequest) returns (AlterInboundResponse) {} + rpc GetInboundUsers(GetInboundUserRequest) returns (GetInboundUserResponse) {} + + rpc GetInboundUsersCount(GetInboundUserRequest) returns (GetInboundUsersCountResponse) {} + rpc AddOutbound(AddOutboundRequest) returns (AddOutboundResponse) {} rpc RemoveOutbound(RemoveOutboundRequest) returns (RemoveOutboundResponse) {} diff --git a/app/proxyman/command/command_grpc.pb.go b/app/proxyman/command/command_grpc.pb.go index 4f12836b..7abbae8e 100644 --- a/app/proxyman/command/command_grpc.pb.go +++ b/app/proxyman/command/command_grpc.pb.go @@ -19,12 +19,14 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - HandlerService_AddInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddInbound" - HandlerService_RemoveInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveInbound" - HandlerService_AlterInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterInbound" - HandlerService_AddOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddOutbound" - HandlerService_RemoveOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveOutbound" - HandlerService_AlterOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterOutbound" + HandlerService_AddInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddInbound" + HandlerService_RemoveInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveInbound" + HandlerService_AlterInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterInbound" + HandlerService_GetInboundUsers_FullMethodName = "/xray.app.proxyman.command.HandlerService/GetInboundUsers" + HandlerService_GetInboundUsersCount_FullMethodName = "/xray.app.proxyman.command.HandlerService/GetInboundUsersCount" + HandlerService_AddOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddOutbound" + HandlerService_RemoveOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveOutbound" + HandlerService_AlterOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterOutbound" ) // HandlerServiceClient is the client API for HandlerService service. @@ -34,6 +36,8 @@ type HandlerServiceClient interface { AddInbound(ctx context.Context, in *AddInboundRequest, opts ...grpc.CallOption) (*AddInboundResponse, error) RemoveInbound(ctx context.Context, in *RemoveInboundRequest, opts ...grpc.CallOption) (*RemoveInboundResponse, error) AlterInbound(ctx context.Context, in *AlterInboundRequest, opts ...grpc.CallOption) (*AlterInboundResponse, error) + GetInboundUsers(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUserResponse, error) + GetInboundUsersCount(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUsersCountResponse, error) AddOutbound(ctx context.Context, in *AddOutboundRequest, opts ...grpc.CallOption) (*AddOutboundResponse, error) RemoveOutbound(ctx context.Context, in *RemoveOutboundRequest, opts ...grpc.CallOption) (*RemoveOutboundResponse, error) AlterOutbound(ctx context.Context, in *AlterOutboundRequest, opts ...grpc.CallOption) (*AlterOutboundResponse, error) @@ -77,6 +81,26 @@ func (c *handlerServiceClient) AlterInbound(ctx context.Context, in *AlterInboun return out, nil } +func (c *handlerServiceClient) GetInboundUsers(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUserResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetInboundUserResponse) + err := c.cc.Invoke(ctx, HandlerService_GetInboundUsers_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *handlerServiceClient) GetInboundUsersCount(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUsersCountResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetInboundUsersCountResponse) + err := c.cc.Invoke(ctx, HandlerService_GetInboundUsersCount_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *handlerServiceClient) AddOutbound(ctx context.Context, in *AddOutboundRequest, opts ...grpc.CallOption) (*AddOutboundResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(AddOutboundResponse) @@ -114,6 +138,8 @@ type HandlerServiceServer interface { AddInbound(context.Context, *AddInboundRequest) (*AddInboundResponse, error) RemoveInbound(context.Context, *RemoveInboundRequest) (*RemoveInboundResponse, error) AlterInbound(context.Context, *AlterInboundRequest) (*AlterInboundResponse, error) + GetInboundUsers(context.Context, *GetInboundUserRequest) (*GetInboundUserResponse, error) + GetInboundUsersCount(context.Context, *GetInboundUserRequest) (*GetInboundUsersCountResponse, error) AddOutbound(context.Context, *AddOutboundRequest) (*AddOutboundResponse, error) RemoveOutbound(context.Context, *RemoveOutboundRequest) (*RemoveOutboundResponse, error) AlterOutbound(context.Context, *AlterOutboundRequest) (*AlterOutboundResponse, error) @@ -136,6 +162,12 @@ func (UnimplementedHandlerServiceServer) RemoveInbound(context.Context, *RemoveI func (UnimplementedHandlerServiceServer) AlterInbound(context.Context, *AlterInboundRequest) (*AlterInboundResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AlterInbound not implemented") } +func (UnimplementedHandlerServiceServer) GetInboundUsers(context.Context, *GetInboundUserRequest) (*GetInboundUserResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetInboundUsers not implemented") +} +func (UnimplementedHandlerServiceServer) GetInboundUsersCount(context.Context, *GetInboundUserRequest) (*GetInboundUsersCountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetInboundUsersCount not implemented") +} func (UnimplementedHandlerServiceServer) AddOutbound(context.Context, *AddOutboundRequest) (*AddOutboundResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddOutbound not implemented") } @@ -220,6 +252,42 @@ func _HandlerService_AlterInbound_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _HandlerService_GetInboundUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetInboundUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HandlerServiceServer).GetInboundUsers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HandlerService_GetInboundUsers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HandlerServiceServer).GetInboundUsers(ctx, req.(*GetInboundUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _HandlerService_GetInboundUsersCount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetInboundUserRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HandlerServiceServer).GetInboundUsersCount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HandlerService_GetInboundUsersCount_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HandlerServiceServer).GetInboundUsersCount(ctx, req.(*GetInboundUserRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _HandlerService_AddOutbound_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(AddOutboundRequest) if err := dec(in); err != nil { @@ -293,6 +361,14 @@ var HandlerService_ServiceDesc = grpc.ServiceDesc{ MethodName: "AlterInbound", Handler: _HandlerService_AlterInbound_Handler, }, + { + MethodName: "GetInboundUsers", + Handler: _HandlerService_GetInboundUsers_Handler, + }, + { + MethodName: "GetInboundUsersCount", + Handler: _HandlerService_GetInboundUsersCount_Handler, + }, { MethodName: "AddOutbound", Handler: _HandlerService_AddOutbound_Handler, diff --git a/common/protocol/account.go b/common/protocol/account.go index 7793974a..75568817 100644 --- a/common/protocol/account.go +++ b/common/protocol/account.go @@ -1,8 +1,11 @@ package protocol +import "google.golang.org/protobuf/proto" + // Account is a user identity used for authentication. type Account interface { Equals(Account) bool + ToProto() proto.Message } // AsAccount is an object can be converted into account. diff --git a/common/protocol/user.go b/common/protocol/user.go index d6e3a131..2986eb19 100644 --- a/common/protocol/user.go +++ b/common/protocol/user.go @@ -1,6 +1,9 @@ package protocol -import "github.com/xtls/xray-core/common/errors" +import ( + "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/common/serial" +) func (u *User) GetTypedAccount() (Account, error) { if u.GetAccount() == nil { @@ -32,6 +35,17 @@ func (u *User) ToMemoryUser() (*MemoryUser, error) { }, nil } +func ToProtoUser(mu *MemoryUser) *User { + if mu == nil { + return nil + } + return &User{ + Account: serial.ToTypedMessage(mu.Account.ToProto()), + Email: mu.Email, + Level: mu.Level, + } +} + // MemoryUser is a parsed form of User, to reduce number of parsing of Account proto. type MemoryUser struct { // Account is the parsed account of the protocol. diff --git a/core/proto.go b/core/proto.go index b85d99d8..030365cc 100644 --- a/core/proto.go +++ b/core/proto.go @@ -1,5 +1,5 @@ package core -//go:generate go install -v google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2 -//go:generate go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 +//go:generate go install -v google.golang.org/protobuf/cmd/protoc-gen-go@latest +//go:generate go install -v google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest //go:generate go run ../infra/vprotogen/main.go -pwd ./.. diff --git a/infra/conf/shadowsocks.go b/infra/conf/shadowsocks.go index 1bd6462c..f12040a6 100644 --- a/infra/conf/shadowsocks.go +++ b/infra/conf/shadowsocks.go @@ -126,9 +126,13 @@ func buildShadowsocks2022(v *ShadowsocksServerConfig) (proto.Message, error) { if user.Cipher != "" { return nil, errors.New("shadowsocks 2022 (multi-user): users must have empty method") } - config.Users = append(config.Users, &shadowsocks_2022.User{ - Key: user.Password, - Email: user.Email, + account := &shadowsocks_2022.Account{ + Key: user.Password, + } + config.Users = append(config.Users, &protocol.User{ + Email: user.Email, + Level: uint32(user.Level), + Account: serial.ToTypedMessage(account), }) } return config, nil diff --git a/main/commands/all/api/api.go b/main/commands/all/api/api.go index ea43d107..5e21884b 100644 --- a/main/commands/all/api/api.go +++ b/main/commands/all/api/api.go @@ -21,6 +21,8 @@ var CmdAPI = &base.Command{ cmdAddOutbounds, cmdRemoveInbounds, cmdRemoveOutbounds, + cmdInboundUser, + cmdInboundUserCount, cmdAddRules, cmdRemoveRules, cmdSourceIpBlock, diff --git a/main/commands/all/api/inbound_user.go b/main/commands/all/api/inbound_user.go new file mode 100644 index 00000000..6ffa4ebb --- /dev/null +++ b/main/commands/all/api/inbound_user.go @@ -0,0 +1,50 @@ +package api + +import ( + handlerService "github.com/xtls/xray-core/app/proxyman/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdInboundUser = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api inbounduser [--server=127.0.0.1:8080] -tag=tag [-email=email]", + Short: "Get Inbound User", + Long: ` +Get User info from an inbound. +Arguments: + -s, -server + The API server address. Default 127.0.0.1:8080 + -t, -timeout + Timeout seconds to call API. Default 3 + -tag + Inbound tag + -email + User email. If email is not given, will get all users +Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -tag="tag name" -email="xray@love.com" +`, + Run: executeInboundUser, +} + +func executeInboundUser(cmd *base.Command, args []string) { + setSharedFlags(cmd) + var tag string + var email string + cmd.Flag.StringVar(&tag, "tag", "", "") + cmd.Flag.StringVar(&email, "email", "", "") + cmd.Flag.Parse(args) + + conn, ctx, close := dialAPIServer() + defer close() + + client := handlerService.NewHandlerServiceClient(conn) + r := &handlerService.GetInboundUserRequest{ + Tag: tag, + Email: email, + } + resp, err := client.GetInboundUsers(ctx, r) + if err != nil { + base.Fatalf("failed to get inbound user: %s", err) + } + showJSONResponse(resp) +} diff --git a/main/commands/all/api/inbound_user_count.go b/main/commands/all/api/inbound_user_count.go new file mode 100644 index 00000000..18cab7e8 --- /dev/null +++ b/main/commands/all/api/inbound_user_count.go @@ -0,0 +1,45 @@ +package api + +import ( + handlerService "github.com/xtls/xray-core/app/proxyman/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdInboundUserCount = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api inboundusercount [--server=127.0.0.1:8080] -tag=tag", + Short: "Get Inbound User Count", + Long: ` +Get User count from an inbound. +Arguments: + -s, -server + The API server address. Default 127.0.0.1:8080 + -t, -timeout + Timeout seconds to call API. Default 3 + -tag + Inbound tag +Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -tag="tag name" +`, + Run: executeInboundUserCount, +} + +func executeInboundUserCount(cmd *base.Command, args []string) { + setSharedFlags(cmd) + var tag string + cmd.Flag.StringVar(&tag, "tag", "", "") + cmd.Flag.Parse(args) + + conn, ctx, close := dialAPIServer() + defer close() + + client := handlerService.NewHandlerServiceClient(conn) + r := &handlerService.GetInboundUserRequest{ + Tag: tag, + } + resp, err := client.GetInboundUsersCount(ctx, r) + if err != nil { + base.Fatalf("failed to get inbound user count: %s", err) + } + showJSONResponse(resp) +} diff --git a/proxy/http/config.go b/proxy/http/config.go index 00ce0795..a41bb010 100644 --- a/proxy/http/config.go +++ b/proxy/http/config.go @@ -1,6 +1,8 @@ package http import ( + "google.golang.org/protobuf/proto" + "github.com/xtls/xray-core/common/protocol" ) @@ -11,6 +13,10 @@ func (a *Account) Equals(another protocol.Account) bool { return false } +func (a *Account) ToProto() proto.Message { + return a +} + func (a *Account) AsAccount() (protocol.Account, error) { return a, nil } diff --git a/proxy/proxy.go b/proxy/proxy.go index b507cc39..868c8dfc 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -78,6 +78,15 @@ type UserManager interface { // RemoveUser removes a user by email. RemoveUser(context.Context, string) error + + // Get user by email. + GetUser(context.Context, string) *protocol.MemoryUser + + // Get all users. + GetUsers(context.Context) []*protocol.MemoryUser + + // Get users count. + GetUsersCount(context.Context) int64 } type GetInbound interface { diff --git a/proxy/shadowsocks/config.go b/proxy/shadowsocks/config.go index 396e59be..e2d812ab 100644 --- a/proxy/shadowsocks/config.go +++ b/proxy/shadowsocks/config.go @@ -6,6 +6,7 @@ import ( "crypto/cipher" "crypto/md5" "crypto/sha1" + "google.golang.org/protobuf/proto" "io" "github.com/xtls/xray-core/common" @@ -20,8 +21,10 @@ import ( // MemoryAccount is an account type converted from Account. type MemoryAccount struct { - Cipher Cipher - Key []byte + Cipher Cipher + CipherType CipherType + Key []byte + Password string replayFilter antireplay.GeneralizedReplayFilter } @@ -36,6 +39,14 @@ func (a *MemoryAccount) Equals(another protocol.Account) bool { return false } +func (a *MemoryAccount) ToProto() proto.Message { + return &Account{ + CipherType: a.CipherType, + Password: a.Password, + IvCheck: a.replayFilter != nil, + } +} + func (a *MemoryAccount) CheckIV(iv []byte) error { if a.replayFilter == nil { return nil @@ -107,7 +118,9 @@ func (a *Account) AsAccount() (protocol.Account, error) { } return &MemoryAccount{ Cipher: Cipher, + CipherType: a.CipherType, Key: passwordToCipherKey([]byte(a.Password), Cipher.KeySize()), + Password: a.Password, replayFilter: func() antireplay.GeneralizedReplayFilter { if a.IvCheck { return antireplay.NewBloomRing() diff --git a/proxy/shadowsocks/server.go b/proxy/shadowsocks/server.go index e6135a45..356868e4 100644 --- a/proxy/shadowsocks/server.go +++ b/proxy/shadowsocks/server.go @@ -63,6 +63,21 @@ func (s *Server) RemoveUser(ctx context.Context, e string) error { return s.validator.Del(e) } +// GetUser implements proxy.UserManager.GetUser(). +func (s *Server) GetUser(ctx context.Context, email string) *protocol.MemoryUser { + return s.validator.GetByEmail(email) +} + +// GetUsers implements proxy.UserManager.GetUsers(). +func (s *Server) GetUsers(ctx context.Context) []*protocol.MemoryUser { + return s.validator.GetAll() +} + +// GetUsersCount implements proxy.UserManager.GetUsersCount(). +func (s *Server) GetUsersCount(context.Context) int64 { + return s.validator.GetCount() +} + func (s *Server) Network() []net.Network { list := s.config.Network if len(list) == 0 { diff --git a/proxy/shadowsocks/validator.go b/proxy/shadowsocks/validator.go index ae92a8dc..84e59dc1 100644 --- a/proxy/shadowsocks/validator.go +++ b/proxy/shadowsocks/validator.go @@ -74,6 +74,40 @@ func (v *Validator) Del(email string) error { return nil } +// GetByEmail Get a Shadowsocks user with a non-empty Email. +func (v *Validator) GetByEmail(email string) *protocol.MemoryUser { + if email == "" { + return nil + } + + v.Lock() + defer v.Unlock() + + email = strings.ToLower(email) + for _, u := range v.users { + if strings.EqualFold(u.Email, email) { + return u + } + } + return nil +} + +// GetAll get all users +func (v *Validator) GetAll() []*protocol.MemoryUser { + v.Lock() + defer v.Unlock() + dst := make([]*protocol.MemoryUser, len(v.users)) + copy(dst, v.users) + return dst +} + +// GetCount get users count +func (v *Validator) GetCount() int64 { + v.Lock() + defer v.Unlock() + return int64(len(v.users)) +} + // Get a Shadowsocks user. func (v *Validator) Get(bs []byte, command protocol.RequestCommand) (u *protocol.MemoryUser, aead cipher.AEAD, ret []byte, ivLen int32, err error) { v.RLock() diff --git a/proxy/shadowsocks_2022/config.go b/proxy/shadowsocks_2022/config.go index 8a66406c..3678cd58 100644 --- a/proxy/shadowsocks_2022/config.go +++ b/proxy/shadowsocks_2022/config.go @@ -1,22 +1,20 @@ package shadowsocks_2022 import ( + "google.golang.org/protobuf/proto" + "github.com/xtls/xray-core/common/protocol" ) // MemoryAccount is an account type converted from Account. type MemoryAccount struct { Key string - Email string - Level int32 } // AsAccount implements protocol.AsAccount. -func (u *User) AsAccount() (protocol.Account, error) { +func (u *Account) AsAccount() (protocol.Account, error) { return &MemoryAccount{ Key: u.GetKey(), - Email: u.GetEmail(), - Level: u.GetLevel(), }, nil } @@ -27,3 +25,9 @@ func (a *MemoryAccount) Equals(another protocol.Account) bool { } return false } + +func (a *MemoryAccount) ToProto() proto.Message { + return &Account{ + Key: a.Key, + } +} diff --git a/proxy/shadowsocks_2022/config.pb.go b/proxy/shadowsocks_2022/config.pb.go index b47438ea..f2f78ad6 100644 --- a/proxy/shadowsocks_2022/config.pb.go +++ b/proxy/shadowsocks_2022/config.pb.go @@ -8,6 +8,7 @@ package shadowsocks_2022 import ( net "github.com/xtls/xray-core/common/net" + protocol "github.com/xtls/xray-core/common/protocol" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -103,10 +104,10 @@ type MultiUserServerConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` - Users []*User `protobuf:"bytes,3,rep,name=users,proto3" json:"users,omitempty"` - Network []net.Network `protobuf:"varint,4,rep,packed,name=network,proto3,enum=xray.common.net.Network" json:"network,omitempty"` + Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Users []*protocol.User `protobuf:"bytes,3,rep,name=users,proto3" json:"users,omitempty"` + Network []net.Network `protobuf:"varint,4,rep,packed,name=network,proto3,enum=xray.common.net.Network" json:"network,omitempty"` } func (x *MultiUserServerConfig) Reset() { @@ -153,7 +154,7 @@ func (x *MultiUserServerConfig) GetKey() string { return "" } -func (x *MultiUserServerConfig) GetUsers() []*User { +func (x *MultiUserServerConfig) GetUsers() []*protocol.User { if x != nil { return x.Users } @@ -313,30 +314,28 @@ func (x *RelayServerConfig) GetNetwork() []net.Network { return nil } -type User struct { +type Account struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` - Level int32 `protobuf:"varint,3,opt,name=level,proto3" json:"level,omitempty"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` } -func (x *User) Reset() { - *x = User{} +func (x *Account) Reset() { + *x = Account{} mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *User) String() string { +func (x *Account) String() string { return protoimpl.X.MessageStringOf(x) } -func (*User) ProtoMessage() {} +func (*Account) ProtoMessage() {} -func (x *User) ProtoReflect() protoreflect.Message { +func (x *Account) ProtoReflect() protoreflect.Message { mi := &file_proxy_shadowsocks_2022_config_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -348,32 +347,18 @@ func (x *User) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use User.ProtoReflect.Descriptor instead. -func (*User) Descriptor() ([]byte, []int) { +// Deprecated: Use Account.ProtoReflect.Descriptor instead. +func (*Account) Descriptor() ([]byte, []int) { return file_proxy_shadowsocks_2022_config_proto_rawDescGZIP(), []int{4} } -func (x *User) GetKey() string { +func (x *Account) GetKey() string { if x != nil { return x.Key } return "" } -func (x *User) GetEmail() string { - if x != nil { - return x.Email - } - return "" -} - -func (x *User) GetLevel() int32 { - if x != nil { - return x.Level - } - return 0 -} - type ClientConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -469,76 +454,74 @@ var file_proxy_shadowsocks_2022_config_proto_rawDesc = []byte{ 0x32, 0x32, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x98, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x98, 0x01, 0x0a, 0x0c, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, + 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, + 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, + 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x32, 0x0a, 0x07, 0x6e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, + 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0xa7, 0x01, + 0x0a, 0x15, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x32, 0x0a, - 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, - 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, - 0x6b, 0x22, 0xae, 0x01, 0x0a, 0x15, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x55, 0x73, 0x65, 0x72, 0x53, + 0x79, 0x12, 0x30, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, + 0x65, 0x72, 0x73, 0x12, 0x32, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x04, + 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, + 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0x9b, 0x01, 0x0a, 0x10, 0x52, 0x65, 0x6c, 0x61, + 0x79, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x35, + 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, + 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, + 0x69, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, + 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, + 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x22, 0xc4, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x37, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, - 0x32, 0x32, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x12, 0x32, - 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0e, 0x32, - 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, - 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, - 0x72, 0x6b, 0x22, 0x9b, 0x01, 0x0a, 0x10, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x44, 0x65, 0x73, 0x74, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x35, 0x0a, 0x07, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, 0x4f, - 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, - 0x70, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, - 0x76, 0x65, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, - 0x22, 0xc4, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, - 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x51, 0x0a, 0x0c, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x5f, - 0x32, 0x30, 0x32, 0x32, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x73, 0x12, 0x32, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x04, - 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x52, 0x07, - 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0x44, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, - 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, - 0x79, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x22, 0xd6, 0x01, - 0x0a, 0x0c, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, - 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, - 0x74, 0x2e, 0x49, 0x50, 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, - 0x68, 0x6f, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, - 0x64, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x20, 0x0a, 0x0c, 0x75, 0x64, 0x70, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x5f, - 0x74, 0x63, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x75, 0x64, 0x70, 0x4f, 0x76, - 0x65, 0x72, 0x54, 0x63, 0x70, 0x12, 0x2f, 0x0a, 0x14, 0x75, 0x64, 0x70, 0x5f, 0x6f, 0x76, 0x65, - 0x72, 0x5f, 0x74, 0x63, 0x70, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x11, 0x75, 0x64, 0x70, 0x4f, 0x76, 0x65, 0x72, 0x54, 0x63, 0x70, 0x56, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x72, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x51, 0x0a, 0x0c, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, - 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x68, 0x61, - 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0xaa, 0x02, 0x1a, - 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x68, 0x61, 0x64, 0x6f, - 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0x2e, 0x52, 0x65, 0x6c, 0x61, 0x79, 0x44, + 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x64, 0x65, 0x73, 0x74, + 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x32, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x4e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x22, 0x1b, 0x0a, 0x07, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0xd6, 0x01, 0x0a, 0x0c, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x35, 0x0a, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x49, 0x50, + 0x4f, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x20, 0x0a, 0x0c, 0x75, 0x64, 0x70, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x5f, 0x74, 0x63, 0x70, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x75, 0x64, 0x70, 0x4f, 0x76, 0x65, 0x72, 0x54, 0x63, + 0x70, 0x12, 0x2f, 0x0a, 0x14, 0x75, 0x64, 0x70, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x5f, 0x74, 0x63, + 0x70, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, + 0x11, 0x75, 0x64, 0x70, 0x4f, 0x76, 0x65, 0x72, 0x54, 0x63, 0x70, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x42, 0x72, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, 0x6b, 0x73, + 0x5f, 0x32, 0x30, 0x32, 0x32, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, + 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x73, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, + 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x32, 0x30, 0x32, 0x32, 0xaa, 0x02, 0x1a, 0x58, 0x72, 0x61, 0x79, + 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x53, 0x68, 0x61, 0x64, 0x6f, 0x77, 0x73, 0x6f, 0x63, + 0x6b, 0x73, 0x32, 0x30, 0x32, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -559,19 +542,20 @@ var file_proxy_shadowsocks_2022_config_proto_goTypes = []any{ (*MultiUserServerConfig)(nil), // 1: xray.proxy.shadowsocks_2022.MultiUserServerConfig (*RelayDestination)(nil), // 2: xray.proxy.shadowsocks_2022.RelayDestination (*RelayServerConfig)(nil), // 3: xray.proxy.shadowsocks_2022.RelayServerConfig - (*User)(nil), // 4: xray.proxy.shadowsocks_2022.User + (*Account)(nil), // 4: xray.proxy.shadowsocks_2022.Account (*ClientConfig)(nil), // 5: xray.proxy.shadowsocks_2022.ClientConfig (net.Network)(0), // 6: xray.common.net.Network - (*net.IPOrDomain)(nil), // 7: xray.common.net.IPOrDomain + (*protocol.User)(nil), // 7: xray.common.protocol.User + (*net.IPOrDomain)(nil), // 8: xray.common.net.IPOrDomain } var file_proxy_shadowsocks_2022_config_proto_depIdxs = []int32{ 6, // 0: xray.proxy.shadowsocks_2022.ServerConfig.network:type_name -> xray.common.net.Network - 4, // 1: xray.proxy.shadowsocks_2022.MultiUserServerConfig.users:type_name -> xray.proxy.shadowsocks_2022.User + 7, // 1: xray.proxy.shadowsocks_2022.MultiUserServerConfig.users:type_name -> xray.common.protocol.User 6, // 2: xray.proxy.shadowsocks_2022.MultiUserServerConfig.network:type_name -> xray.common.net.Network - 7, // 3: xray.proxy.shadowsocks_2022.RelayDestination.address:type_name -> xray.common.net.IPOrDomain + 8, // 3: xray.proxy.shadowsocks_2022.RelayDestination.address:type_name -> xray.common.net.IPOrDomain 2, // 4: xray.proxy.shadowsocks_2022.RelayServerConfig.destinations:type_name -> xray.proxy.shadowsocks_2022.RelayDestination 6, // 5: xray.proxy.shadowsocks_2022.RelayServerConfig.network:type_name -> xray.common.net.Network - 7, // 6: xray.proxy.shadowsocks_2022.ClientConfig.address:type_name -> xray.common.net.IPOrDomain + 8, // 6: xray.proxy.shadowsocks_2022.ClientConfig.address:type_name -> xray.common.net.IPOrDomain 7, // [7:7] is the sub-list for method output_type 7, // [7:7] is the sub-list for method input_type 7, // [7:7] is the sub-list for extension type_name diff --git a/proxy/shadowsocks_2022/config.proto b/proxy/shadowsocks_2022/config.proto index 60540991..14006648 100644 --- a/proxy/shadowsocks_2022/config.proto +++ b/proxy/shadowsocks_2022/config.proto @@ -8,6 +8,7 @@ option java_multiple_files = true; import "common/net/network.proto"; import "common/net/address.proto"; +import "common/protocol/user.proto"; message ServerConfig { string method = 1; @@ -20,7 +21,7 @@ message ServerConfig { message MultiUserServerConfig { string method = 1; string key = 2; - repeated User users = 3; + repeated xray.common.protocol.User users = 3; repeated xray.common.net.Network network = 4; } @@ -39,10 +40,8 @@ message RelayServerConfig { repeated xray.common.net.Network network = 4; } -message User { +message Account { string key = 1; - string email = 2; - int32 level = 3; } message ClientConfig { diff --git a/proxy/shadowsocks_2022/inbound_multi.go b/proxy/shadowsocks_2022/inbound_multi.go index 8cb2d65e..20b85139 100644 --- a/proxy/shadowsocks_2022/inbound_multi.go +++ b/proxy/shadowsocks_2022/inbound_multi.go @@ -37,7 +37,7 @@ func init() { type MultiUserInbound struct { sync.Mutex networks []net.Network - users []*User + users []*protocol.MemoryUser service *shadowaead_2022.MultiService[int] } @@ -49,9 +49,22 @@ func NewMultiServer(ctx context.Context, config *MultiUserServerConfig) (*MultiU net.Network_UDP, } } + memUsers := []*protocol.MemoryUser{} + for i, user := range config.Users { + if user.Email == "" { + u := uuid.New() + user.Email = "unnamed-user-" + strconv.Itoa(i) + "-" + u.String() + } + u, err := user.ToMemoryUser() + if err != nil { + return nil, errors.New("failed to get shadowsocks user").Base(err).AtError() + } + memUsers = append(memUsers, u) + } + inbound := &MultiUserInbound{ networks: networks, - users: config.Users, + users: memUsers, } if config.Key == "" { return nil, errors.New("missing key") @@ -64,16 +77,9 @@ func NewMultiServer(ctx context.Context, config *MultiUserServerConfig) (*MultiU if err != nil { return nil, errors.New("create service").Base(err) } - - for i, user := range config.Users { - if user.Email == "" { - u := uuid.New() - user.Email = "unnamed-user-" + strconv.Itoa(i) + "-" + u.String() - } - } err = service.UpdateUsersWithPasswords( - C.MapIndexed(config.Users, func(index int, it *User) int { return index }), - C.Map(config.Users, func(it *User) string { return it.Key }), + C.MapIndexed(memUsers, func(index int, it *protocol.MemoryUser) int { return index }), + C.Map(memUsers, func(it *protocol.MemoryUser) string { return it.Account.(*MemoryAccount).Key }), ) if err != nil { return nil, errors.New("create service").Base(err) @@ -88,25 +94,20 @@ func (i *MultiUserInbound) AddUser(ctx context.Context, u *protocol.MemoryUser) i.Lock() defer i.Unlock() - account := u.Account.(*MemoryAccount) - if account.Email != "" { + if u.Email != "" { for idx := range i.users { - if i.users[idx].Email == account.Email { - return errors.New("User ", account.Email, " already exists.") + if i.users[idx].Email == u.Email { + return errors.New("User ", u.Email, " already exists.") } } } - i.users = append(i.users, &User{ - Key: account.Key, - Email: account.Email, - Level: account.Level, - }) + i.users = append(i.users, u) // sync to multi service // Considering implements shadowsocks2022 in xray-core may have better performance. i.service.UpdateUsersWithPasswords( - C.MapIndexed(i.users, func(index int, it *User) int { return index }), - C.Map(i.users, func(it *User) string { return it.Key }), + C.MapIndexed(i.users, func(index int, it *protocol.MemoryUser) int { return index }), + C.Map(i.users, func(it *protocol.MemoryUser) string { return it.Account.(*MemoryAccount).Key }), ) return nil @@ -142,13 +143,46 @@ func (i *MultiUserInbound) RemoveUser(ctx context.Context, email string) error { // sync to multi service // Considering implements shadowsocks2022 in xray-core may have better performance. i.service.UpdateUsersWithPasswords( - C.MapIndexed(i.users, func(index int, it *User) int { return index }), - C.Map(i.users, func(it *User) string { return it.Key }), + C.MapIndexed(i.users, func(index int, it *protocol.MemoryUser) int { return index }), + C.Map(i.users, func(it *protocol.MemoryUser) string { return it.Account.(*MemoryAccount).Key }), ) return nil } +// GetUser implements proxy.UserManager.GetUser(). +func (i *MultiUserInbound) GetUser(ctx context.Context, email string) *protocol.MemoryUser { + if email == "" { + return nil + } + + i.Lock() + defer i.Unlock() + + for _, u := range i.users { + if strings.EqualFold(u.Email, email) { + return u + } + } + return nil +} + +// GetUsers implements proxy.UserManager.GetUsers(). +func (i *MultiUserInbound) GetUsers(ctx context.Context) []*protocol.MemoryUser { + i.Lock() + defer i.Unlock() + dst := make([]*protocol.MemoryUser, len(i.users)) + copy(dst, i.users) + return dst +} + +// GetUsersCount implements proxy.UserManager.GetUsersCount(). +func (i *MultiUserInbound) GetUsersCount(context.Context) int64 { + i.Lock() + defer i.Unlock() + return int64(len(i.users)) +} + func (i *MultiUserInbound) Network() []net.Network { return i.networks } @@ -194,10 +228,7 @@ func (i *MultiUserInbound) NewConnection(ctx context.Context, conn net.Conn, met inbound := session.InboundFromContext(ctx) userInt, _ := A.UserFromContext[int](ctx) user := i.users[userInt] - inbound.User = &protocol.MemoryUser{ - Email: user.Email, - Level: uint32(user.Level), - } + inbound.User = user ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{ From: metadata.Source, To: metadata.Destination, @@ -222,10 +253,7 @@ func (i *MultiUserInbound) NewPacketConnection(ctx context.Context, conn N.Packe inbound := session.InboundFromContext(ctx) userInt, _ := A.UserFromContext[int](ctx) user := i.users[userInt] - inbound.User = &protocol.MemoryUser{ - Email: user.Email, - Level: uint32(user.Level), - } + inbound.User = user ctx = log.ContextWithAccessMessage(ctx, &log.AccessMessage{ From: metadata.Source, To: metadata.Destination, diff --git a/proxy/socks/config.go b/proxy/socks/config.go index 3b162abe..e8aa328a 100644 --- a/proxy/socks/config.go +++ b/proxy/socks/config.go @@ -1,6 +1,10 @@ package socks -import "github.com/xtls/xray-core/common/protocol" +import ( + "google.golang.org/protobuf/proto" + + "github.com/xtls/xray-core/common/protocol" +) func (a *Account) Equals(another protocol.Account) bool { if account, ok := another.(*Account); ok { @@ -9,6 +13,10 @@ func (a *Account) Equals(another protocol.Account) bool { return false } +func (a *Account) ToProto() proto.Message { + return a +} + func (a *Account) AsAccount() (protocol.Account, error) { return a, nil } diff --git a/proxy/trojan/config.go b/proxy/trojan/config.go index a02dfe98..b7591996 100644 --- a/proxy/trojan/config.go +++ b/proxy/trojan/config.go @@ -3,7 +3,8 @@ package trojan import ( "crypto/sha256" "encoding/hex" - fmt "fmt" + "fmt" + "google.golang.org/protobuf/proto" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/protocol" @@ -33,6 +34,12 @@ func (a *MemoryAccount) Equals(another protocol.Account) bool { return false } +func (a *MemoryAccount) ToProto() proto.Message { + return &Account{ + Password: a.Password, + } +} + func hexSha224(password string) []byte { buf := make([]byte, 56) hash := sha256.New224() diff --git a/proxy/trojan/server.go b/proxy/trojan/server.go index 6110eec0..20ac1fd1 100644 --- a/proxy/trojan/server.go +++ b/proxy/trojan/server.go @@ -125,6 +125,21 @@ func (s *Server) RemoveUser(ctx context.Context, e string) error { return s.validator.Del(e) } +// GetUser implements proxy.UserManager.GetUser(). +func (s *Server) GetUser(ctx context.Context, email string) *protocol.MemoryUser { + return s.validator.GetByEmail(email) +} + +// GetUsers implements proxy.UserManager.GetUsers(). +func (s *Server) GetUsers(ctx context.Context) []*protocol.MemoryUser { + return s.validator.GetAll() +} + +// GetUsersCount implements proxy.UserManager.GetUsersCount(). +func (s *Server) GetUsersCount(context.Context) int64 { + return s.validator.GetCount() +} + // Network implements proxy.Inbound.Network(). func (s *Server) Network() []net.Network { return []net.Network{net.Network_TCP, net.Network_UNIX} diff --git a/proxy/trojan/validator.go b/proxy/trojan/validator.go index 4ffe41a1..fb3499fa 100644 --- a/proxy/trojan/validator.go +++ b/proxy/trojan/validator.go @@ -50,3 +50,33 @@ func (v *Validator) Get(hash string) *protocol.MemoryUser { } return nil } + + +// Get a trojan user with hashed key, nil if user doesn't exist. +func (v *Validator) GetByEmail(email string) *protocol.MemoryUser { + u, _ := v.email.Load(email) + if u != nil { + return u.(*protocol.MemoryUser) + } + return nil +} + +// Get all users +func (v *Validator) GetAll() []*protocol.MemoryUser { + var u = make([]*protocol.MemoryUser, 0, 100) + v.email.Range(func(key, value interface{}) bool { + u = append(u, value.(*protocol.MemoryUser)) + return true + }) + return u +} + +// Get users count +func (v *Validator) GetCount() int64 { + var c int64 = 0 + v.email.Range(func(key, value interface{}) bool { + c++ + return true + }) + return c +} diff --git a/proxy/vless/account.go b/proxy/vless/account.go index 5349a3bd..798b93f4 100644 --- a/proxy/vless/account.go +++ b/proxy/vless/account.go @@ -1,6 +1,8 @@ package vless import ( + "google.golang.org/protobuf/proto" + "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/uuid" @@ -37,3 +39,11 @@ func (a *MemoryAccount) Equals(account protocol.Account) bool { } return a.ID.Equals(vlessAccount.ID) } + +func (a *MemoryAccount) ToProto() proto.Message { + return &Account{ + Id: a.ID.String(), + Flow: a.Flow, + Encryption: a.Encryption, + } +} diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index f443007d..48849eb2 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -172,6 +172,21 @@ func (h *Handler) RemoveUser(ctx context.Context, e string) error { return h.validator.Del(e) } +// GetUser implements proxy.UserManager.GetUser(). +func (h *Handler) GetUser(ctx context.Context, email string) *protocol.MemoryUser { + return h.validator.GetByEmail(email) +} + +// GetUsers implements proxy.UserManager.GetUsers(). +func (h *Handler) GetUsers(ctx context.Context) []*protocol.MemoryUser { + return h.validator.GetAll() +} + +// GetUsersCount implements proxy.UserManager.GetUsersCount(). +func (h *Handler) GetUsersCount(context.Context) int64 { + return h.validator.GetCount() +} + // Network implements proxy.Inbound.Network(). func (*Handler) Network() []net.Network { return []net.Network{net.Network_TCP, net.Network_UNIX} diff --git a/proxy/vless/validator.go b/proxy/vless/validator.go index 596cb62f..ddac6cbb 100644 --- a/proxy/vless/validator.go +++ b/proxy/vless/validator.go @@ -13,6 +13,9 @@ type Validator interface { Get(id uuid.UUID) *protocol.MemoryUser Add(u *protocol.MemoryUser) error Del(email string) error + GetByEmail(email string) *protocol.MemoryUser + GetAll() []*protocol.MemoryUser + GetCount() int64 } // MemoryValidator stores valid VLESS users. @@ -57,3 +60,32 @@ func (v *MemoryValidator) Get(id uuid.UUID) *protocol.MemoryUser { } return nil } + +// Get a VLESS user with email, nil if user doesn't exist. +func (v *MemoryValidator) GetByEmail(email string) *protocol.MemoryUser { + u, _ := v.email.Load(email) + if u != nil { + return u.(*protocol.MemoryUser) + } + return nil +} + +// Get all users +func (v *MemoryValidator) GetAll() []*protocol.MemoryUser { + var u = make([]*protocol.MemoryUser, 0, 100) + v.email.Range(func(key, value interface{}) bool { + u = append(u, value.(*protocol.MemoryUser)) + return true + }) + return u +} + +// Get users count +func (v *MemoryValidator) GetCount() int64 { + var c int64 = 0 + v.email.Range(func(key, value interface{}) bool { + c++ + return true + }) + return c +} diff --git a/proxy/vmess/account.go b/proxy/vmess/account.go index 5ece7a57..d063f9f5 100644 --- a/proxy/vmess/account.go +++ b/proxy/vmess/account.go @@ -1,6 +1,7 @@ package vmess import ( + "google.golang.org/protobuf/proto" "strings" "github.com/xtls/xray-core/common/errors" @@ -28,6 +29,21 @@ func (a *MemoryAccount) Equals(account protocol.Account) bool { return a.ID.Equals(vmessAccount.ID) } +func (a *MemoryAccount) ToProto() proto.Message { + var test = "" + if a.AuthenticatedLengthExperiment { + test = "AuthenticatedLength|" + } + if a.NoTerminationSignal { + test = test + "NoTerminationSignal" + } + return &Account{ + Id: a.ID.String(), + TestsEnabled: test, + SecuritySettings: &protocol.SecurityConfig{Type: a.Security}, + } +} + // AsAccount implements protocol.Account. func (a *Account) AsAccount() (protocol.Account, error) { id, err := uuid.ParseString(a.Id) diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index 3102414d..28b560d8 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -56,7 +56,7 @@ func (v *userByEmail) Add(u *protocol.MemoryUser) bool { return v.addNoLock(u) } -func (v *userByEmail) Get(email string) (*protocol.MemoryUser, bool) { +func (v *userByEmail) GetOrGenerate(email string) (*protocol.MemoryUser, bool) { email = strings.ToLower(email) v.Lock() @@ -80,6 +80,13 @@ func (v *userByEmail) Get(email string) (*protocol.MemoryUser, bool) { return user, found } +func (v *userByEmail) Get(email string) *protocol.MemoryUser { + email = strings.ToLower(email) + v.Lock() + defer v.Unlock() + return v.cache[email] +} + func (v *userByEmail) Remove(email string) bool { email = strings.ToLower(email) @@ -141,14 +148,26 @@ func (*Handler) Network() []net.Network { return []net.Network{net.Network_TCP, net.Network_UNIX} } -func (h *Handler) GetUser(email string) *protocol.MemoryUser { - user, existing := h.usersByEmail.Get(email) +func (h *Handler) GetOrGenerateUser(email string) *protocol.MemoryUser { + user, existing := h.usersByEmail.GetOrGenerate(email) if !existing { h.clients.Add(user) } return user } +func (h *Handler) GetUser(ctx context.Context, email string) *protocol.MemoryUser { + return h.usersByEmail.Get(email) +} + +func (h *Handler) GetUsers(ctx context.Context) []*protocol.MemoryUser { + return h.clients.GetUsers() +} + +func (h *Handler) GetUsersCount(context.Context) int64 { + return h.clients.GetCount() +} + func (h *Handler) AddUser(ctx context.Context, user *protocol.MemoryUser) error { if len(user.Email) > 0 && !h.usersByEmail.Add(user) { return errors.New("User ", user.Email, " already exists.") @@ -321,7 +340,7 @@ func (h *Handler) generateCommand(ctx context.Context, request *protocol.Request } errors.LogDebug(ctx, "pick detour handler for port ", port, " for ", availableMin, " minutes.") - user := inboundHandler.GetUser(request.User.Email) + user := inboundHandler.GetOrGenerateUser(request.User.Email) if user == nil { return nil } diff --git a/proxy/vmess/validator.go b/proxy/vmess/validator.go index 43ced006..b3a82f30 100644 --- a/proxy/vmess/validator.go +++ b/proxy/vmess/validator.go @@ -56,6 +56,20 @@ func (v *TimedUserValidator) Add(u *protocol.MemoryUser) error { return nil } +func (v *TimedUserValidator) GetUsers() []*protocol.MemoryUser { + v.Lock() + defer v.Unlock() + dst := make([]*protocol.MemoryUser, len(v.users)) + copy(dst, v.users) + return dst +} + +func (v *TimedUserValidator) GetCount() int64 { + v.Lock() + defer v.Unlock() + return int64(len(v.users)) +} + func (v *TimedUserValidator) GetAEAD(userHash []byte) (*protocol.MemoryUser, bool, error) { v.RLock() defer v.RUnlock() From e3276df725dc7be3f808c35e76438d81a736feed Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 3 Nov 2024 07:25:41 +0000 Subject: [PATCH 586/867] XHTTP client: Enable XMUX for download in U-D-S (#3965) --- transport/internet/memory_settings.go | 1 + transport/internet/splithttp/dialer.go | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/transport/internet/memory_settings.go b/transport/internet/memory_settings.go index e1625f37..5add530c 100644 --- a/transport/internet/memory_settings.go +++ b/transport/internet/memory_settings.go @@ -7,6 +7,7 @@ type MemoryStreamConfig struct { SecurityType string SecuritySettings interface{} SocketSettings *SocketConfig + DownloadSettings *MemoryStreamConfig } // ToMemoryStreamConfig converts a StreamConfig to MemoryStreamConfig. It returns a default non-nil MemoryStreamConfig for nil input. diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index c43783ec..43ba0a46 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -252,18 +252,24 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestURL.Path = transportConfiguration.GetNormalizedPath() + sessionIdUuid.String() requestURL.RawQuery = transportConfiguration.GetNormalizedQuery() - httpClient, muxResource := getHTTPClient(ctx, dest, streamSettings) + httpClient, muxRes := getHTTPClient(ctx, dest, streamSettings) var httpClient2 DialerClient + var muxRes2 *muxResource var requestURL2 url.URL if transportConfiguration.DownloadSettings != nil { + globalDialerAccess.Lock() + if streamSettings.DownloadSettings == nil { + streamSettings.DownloadSettings = common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings)).(*internet.MemoryStreamConfig) + } + globalDialerAccess.Unlock() + memory2 := streamSettings.DownloadSettings dest2 := net.Destination{ Address: transportConfiguration.DownloadSettings.Address.AsAddress(), // just panic Port: net.Port(transportConfiguration.DownloadSettings.Port), Network: net.Network_TCP, } - memory2 := common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings)).(*internet.MemoryStreamConfig) - httpClient2, _ = getHTTPClient(ctx, dest2, memory2) // no multiplex + httpClient2, muxRes2 = getHTTPClient(ctx, dest2, memory2) if tls.ConfigFromStreamSettings(memory2) != nil || reality.ConfigFromStreamSettings(memory2) != nil { requestURL2.Scheme = "https" } else { @@ -284,13 +290,19 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me // uploadWriter wrapper, exact size limits can be enforced uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1)) - if muxResource != nil { - muxResource.OpenRequests.Add(1) + if muxRes != nil { + muxRes.OpenRequests.Add(1) + } + if muxRes2 != nil { + muxRes2.OpenRequests.Add(1) } go func() { - if muxResource != nil { - defer muxResource.OpenRequests.Add(-1) + if muxRes != nil { + defer muxRes.OpenRequests.Add(-1) + } + if muxRes2 != nil { + defer muxRes2.OpenRequests.Add(-1) } requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll())) From 2c72864935f87779b849906d039fd2767fb14849 Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Sun, 3 Nov 2024 17:44:15 +0400 Subject: [PATCH 587/867] API: Add user online stats (#3637) * add statsUserOnline bool to policy * add OnlineMap struct to stats * apply UserOnline functionality to dispatcher * add statsonline api command * fix comments * Update app/stats/online_map.go Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> * improve AddIP * regenerate pb --------- Co-authored-by: mmmray <142015632+mmmray@users.noreply.github.com> --- app/dispatcher/default.go | 12 ++ app/policy/config.go | 1 + app/policy/config.pb.go | 192 ++++++++++++++----- app/policy/config.proto | 1 + app/stats/command/command.go | 14 ++ app/stats/command/command.pb.go | 253 +++++++++++++------------- app/stats/command/command.proto | 1 + app/stats/command/command_grpc.pb.go | 50 ++++- app/stats/online_map.go | 80 ++++++++ app/stats/stats.go | 51 +++++- features/policy/policy.go | 3 + features/stats/stats.go | 44 +++++ infra/conf/policy.go | 2 + main/commands/all/api/api.go | 1 + main/commands/all/api/stats_online.go | 47 +++++ 15 files changed, 575 insertions(+), 177 deletions(-) create mode 100644 app/stats/online_map.go create mode 100644 main/commands/all/api/stats_online.go diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 4eb39d75..42fca674 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -181,6 +181,18 @@ func (d *DefaultDispatcher) getLink(ctx context.Context) (*transport.Link, *tran } } } + + if p.Stats.UserOnline { + name := "user>>>" + user.Email + ">>>online" + if om, _ := stats.GetOrRegisterOnlineMap(d.stats, name); om != nil { + sessionInbounds := session.InboundFromContext(ctx) + userIP := sessionInbounds.Source.Address.String() + om.AddIP(userIP) + // log Online user with ips + // errors.LogDebug(ctx, "user>>>" + user.Email + ">>>online", om.Count(), om.List()) + + } + } } return inboundLink, outboundLink diff --git a/app/policy/config.go b/app/policy/config.go index 267307b7..9e5ee1c2 100644 --- a/app/policy/config.go +++ b/app/policy/config.go @@ -73,6 +73,7 @@ func (p *Policy) ToCorePolicy() policy.Session { if p.Stats != nil { cp.Stats.UserUplink = p.Stats.UserUplink cp.Stats.UserDownlink = p.Stats.UserDownlink + cp.Stats.UserOnline = p.Stats.UserOnline } if p.Buffer != nil { cp.Buffer.PerConnection = p.Buffer.Connection diff --git a/app/policy/config.pb.go b/app/policy/config.pb.go index 2c8262a3..46e6f3d4 100644 --- a/app/policy/config.pb.go +++ b/app/policy/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 -// protoc v5.28.2 +// protoc-gen-go v1.34.2 +// protoc v4.25.3 // source: app/policy/config.proto package policy @@ -301,6 +301,7 @@ type Policy_Stats struct { UserUplink bool `protobuf:"varint,1,opt,name=user_uplink,json=userUplink,proto3" json:"user_uplink,omitempty"` UserDownlink bool `protobuf:"varint,2,opt,name=user_downlink,json=userDownlink,proto3" json:"user_downlink,omitempty"` + UserOnline bool `protobuf:"varint,3,opt,name=user_online,json=userOnline,proto3" json:"user_online,omitempty"` } func (x *Policy_Stats) Reset() { @@ -347,6 +348,13 @@ func (x *Policy_Stats) GetUserDownlink() bool { return false } +func (x *Policy_Stats) GetUserOnline() bool { + if x != nil { + return x.UserOnline + } + return false +} + type Policy_Buffer struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -469,7 +477,7 @@ var file_app_policy_config_proto_rawDesc = []byte{ 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0f, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0x1e, 0x0a, 0x06, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xa6, 0x04, 0x0a, 0x06, 0x50, + 0x01, 0x28, 0x0d, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xc7, 0x04, 0x0a, 0x06, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x39, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, @@ -496,49 +504,51 @@ var file_app_policy_config_proto_rawDesc = []byte{ 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x52, 0x0c, 0x64, 0x6f, - 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x4f, 0x6e, 0x6c, 0x79, 0x1a, 0x4d, 0x0a, 0x05, 0x53, 0x74, + 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x4f, 0x6e, 0x6c, 0x79, 0x1a, 0x6e, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x75, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x23, 0x0a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x75, 0x73, 0x65, - 0x72, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x1a, 0x28, 0x0a, 0x06, 0x42, 0x75, 0x66, - 0x66, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x22, 0xfb, 0x01, 0x0a, 0x0c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x12, 0x39, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x6f, 0x6c, 0x69, - 0x63, 0x79, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x1a, - 0xaf, 0x01, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x75, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0d, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, - 0x12, 0x29, 0x0a, 0x10, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x64, 0x6f, 0x77, 0x6e, - 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x69, 0x6e, 0x62, 0x6f, - 0x75, 0x6e, 0x64, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x27, 0x0a, 0x0f, 0x6f, - 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x75, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x70, - 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, - 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, - 0x6b, 0x22, 0xcc, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x38, 0x0a, 0x05, - 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x35, 0x0a, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x51, 0x0a, - 0x0a, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, - 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2d, 0x0a, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, - 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, - 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0xaa, - 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x1f, 0x0a, 0x0b, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x6f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, + 0x75, 0x73, 0x65, 0x72, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x1a, 0x28, 0x0a, 0x06, 0x42, 0x75, + 0x66, 0x66, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xfb, 0x01, 0x0a, 0x0c, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x39, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x50, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x73, + 0x1a, 0xaf, 0x01, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x69, 0x6e, + 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x75, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0d, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x70, 0x6c, 0x69, 0x6e, + 0x6b, 0x12, 0x29, 0x0a, 0x10, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x64, 0x6f, 0x77, + 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x69, 0x6e, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x27, 0x0a, 0x0f, + 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x75, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, + 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x12, 0x2b, 0x0a, 0x11, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x10, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x69, + 0x6e, 0x6b, 0x22, 0xcc, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x38, 0x0a, + 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x35, 0x0a, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, + 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x1a, 0x51, + 0x0a, 0x0a, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x2d, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x2e, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x42, 0x4f, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x50, 0x01, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0xaa, 0x02, 0x0f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -589,6 +599,104 @@ func file_app_policy_config_proto_init() { if File_app_policy_config_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_app_policy_config_proto_msgTypes[0].Exporter = func(v any, i int) any { + switch v := v.(*Second); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[1].Exporter = func(v any, i int) any { + switch v := v.(*Policy); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[2].Exporter = func(v any, i int) any { + switch v := v.(*SystemPolicy); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[3].Exporter = func(v any, i int) any { + switch v := v.(*Config); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[4].Exporter = func(v any, i int) any { + switch v := v.(*Policy_Timeout); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[5].Exporter = func(v any, i int) any { + switch v := v.(*Policy_Stats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[6].Exporter = func(v any, i int) any { + switch v := v.(*Policy_Buffer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_app_policy_config_proto_msgTypes[7].Exporter = func(v any, i int) any { + switch v := v.(*SystemPolicy_Stats); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/policy/config.proto b/app/policy/config.proto index e5f29547..eefcc17f 100644 --- a/app/policy/config.proto +++ b/app/policy/config.proto @@ -22,6 +22,7 @@ message Policy { message Stats { bool user_uplink = 1; bool user_downlink = 2; + bool user_online = 3; } message Buffer { diff --git a/app/stats/command/command.go b/app/stats/command/command.go index b2cc196c..e4926bab 100644 --- a/app/stats/command/command.go +++ b/app/stats/command/command.go @@ -46,6 +46,20 @@ func (s *statsServer) GetStats(ctx context.Context, request *GetStatsRequest) (* }, nil } +func (s *statsServer) GetStatsOnline(ctx context.Context, request *GetStatsRequest) (*GetStatsResponse, error) { + c := s.stats.GetOnlineMap(request.Name) + if c == nil { + return nil, errors.New(request.Name, " not found.") + } + value := int64(c.Count()) + return &GetStatsResponse{ + Stat: &Stat{ + Name: request.Name, + Value: value, + }, + }, nil +} + func (s *statsServer) QueryStats(ctx context.Context, request *QueryStatsRequest) (*QueryStatsResponse, error) { matcher, err := strmatcher.Substr.New(request.Pattern) if err != nil { diff --git a/app/stats/command/command.pb.go b/app/stats/command/command.pb.go index af8ca346..3ea15017 100644 --- a/app/stats/command/command.pb.go +++ b/app/stats/command/command.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 -// protoc v5.28.2 -// source: app/stats/command/command.proto +// protoc v5.28.3 +// source: command.proto package command @@ -33,7 +33,7 @@ type GetStatsRequest struct { func (x *GetStatsRequest) Reset() { *x = GetStatsRequest{} - mi := &file_app_stats_command_command_proto_msgTypes[0] + mi := &file_command_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -45,7 +45,7 @@ func (x *GetStatsRequest) String() string { func (*GetStatsRequest) ProtoMessage() {} func (x *GetStatsRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[0] + mi := &file_command_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -58,7 +58,7 @@ func (x *GetStatsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetStatsRequest.ProtoReflect.Descriptor instead. func (*GetStatsRequest) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{0} + return file_command_proto_rawDescGZIP(), []int{0} } func (x *GetStatsRequest) GetName() string { @@ -86,7 +86,7 @@ type Stat struct { func (x *Stat) Reset() { *x = Stat{} - mi := &file_app_stats_command_command_proto_msgTypes[1] + mi := &file_command_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -98,7 +98,7 @@ func (x *Stat) String() string { func (*Stat) ProtoMessage() {} func (x *Stat) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[1] + mi := &file_command_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -111,7 +111,7 @@ func (x *Stat) ProtoReflect() protoreflect.Message { // Deprecated: Use Stat.ProtoReflect.Descriptor instead. func (*Stat) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{1} + return file_command_proto_rawDescGZIP(), []int{1} } func (x *Stat) GetName() string { @@ -138,7 +138,7 @@ type GetStatsResponse struct { func (x *GetStatsResponse) Reset() { *x = GetStatsResponse{} - mi := &file_app_stats_command_command_proto_msgTypes[2] + mi := &file_command_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -150,7 +150,7 @@ func (x *GetStatsResponse) String() string { func (*GetStatsResponse) ProtoMessage() {} func (x *GetStatsResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[2] + mi := &file_command_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -163,7 +163,7 @@ func (x *GetStatsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetStatsResponse.ProtoReflect.Descriptor instead. func (*GetStatsResponse) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{2} + return file_command_proto_rawDescGZIP(), []int{2} } func (x *GetStatsResponse) GetStat() *Stat { @@ -184,7 +184,7 @@ type QueryStatsRequest struct { func (x *QueryStatsRequest) Reset() { *x = QueryStatsRequest{} - mi := &file_app_stats_command_command_proto_msgTypes[3] + mi := &file_command_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -196,7 +196,7 @@ func (x *QueryStatsRequest) String() string { func (*QueryStatsRequest) ProtoMessage() {} func (x *QueryStatsRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[3] + mi := &file_command_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -209,7 +209,7 @@ func (x *QueryStatsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use QueryStatsRequest.ProtoReflect.Descriptor instead. func (*QueryStatsRequest) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{3} + return file_command_proto_rawDescGZIP(), []int{3} } func (x *QueryStatsRequest) GetPattern() string { @@ -236,7 +236,7 @@ type QueryStatsResponse struct { func (x *QueryStatsResponse) Reset() { *x = QueryStatsResponse{} - mi := &file_app_stats_command_command_proto_msgTypes[4] + mi := &file_command_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -248,7 +248,7 @@ func (x *QueryStatsResponse) String() string { func (*QueryStatsResponse) ProtoMessage() {} func (x *QueryStatsResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[4] + mi := &file_command_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -261,7 +261,7 @@ func (x *QueryStatsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use QueryStatsResponse.ProtoReflect.Descriptor instead. func (*QueryStatsResponse) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{4} + return file_command_proto_rawDescGZIP(), []int{4} } func (x *QueryStatsResponse) GetStat() []*Stat { @@ -279,7 +279,7 @@ type SysStatsRequest struct { func (x *SysStatsRequest) Reset() { *x = SysStatsRequest{} - mi := &file_app_stats_command_command_proto_msgTypes[5] + mi := &file_command_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -291,7 +291,7 @@ func (x *SysStatsRequest) String() string { func (*SysStatsRequest) ProtoMessage() {} func (x *SysStatsRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[5] + mi := &file_command_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -304,7 +304,7 @@ func (x *SysStatsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SysStatsRequest.ProtoReflect.Descriptor instead. func (*SysStatsRequest) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{5} + return file_command_proto_rawDescGZIP(), []int{5} } type SysStatsResponse struct { @@ -326,7 +326,7 @@ type SysStatsResponse struct { func (x *SysStatsResponse) Reset() { *x = SysStatsResponse{} - mi := &file_app_stats_command_command_proto_msgTypes[6] + mi := &file_command_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -338,7 +338,7 @@ func (x *SysStatsResponse) String() string { func (*SysStatsResponse) ProtoMessage() {} func (x *SysStatsResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[6] + mi := &file_command_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -351,7 +351,7 @@ func (x *SysStatsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SysStatsResponse.ProtoReflect.Descriptor instead. func (*SysStatsResponse) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{6} + return file_command_proto_rawDescGZIP(), []int{6} } func (x *SysStatsResponse) GetNumGoroutine() uint32 { @@ -432,7 +432,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - mi := &file_app_stats_command_command_proto_msgTypes[7] + mi := &file_command_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -444,7 +444,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[7] + mi := &file_command_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -457,99 +457,104 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{7} + return file_command_proto_rawDescGZIP(), []int{7} } -var File_app_stats_command_command_proto protoreflect.FileDescriptor +var File_command_proto protoreflect.FileDescriptor -var file_app_stats_command_command_proto_rawDesc = []byte{ - 0x0a, 0x1f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x16, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, - 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0x3b, 0x0a, 0x0f, 0x47, 0x65, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, +var file_command_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x16, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0x3b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x74, + 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, + 0x0a, 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, + 0x65, 0x73, 0x65, 0x74, 0x22, 0x30, 0x0a, 0x04, 0x53, 0x74, 0x61, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x22, 0x30, 0x0a, 0x04, 0x53, 0x74, 0x61, 0x74, 0x12, 0x12, - 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x44, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, - 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, - 0x73, 0x74, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x43, - 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x14, 0x0a, - 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, - 0x73, 0x65, 0x74, 0x22, 0x46, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x74, 0x61, - 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, - 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x11, 0x0a, 0x0f, 0x53, - 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa2, - 0x02, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, 0x72, 0x6f, 0x75, 0x74, - 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, - 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, 0x12, 0x14, 0x0a, - 0x05, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x41, 0x6c, - 0x6c, 0x6f, 0x63, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, 0x6c, 0x6f, - 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, - 0x6c, 0x6f, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x79, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x03, 0x53, 0x79, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x12, - 0x14, 0x0a, 0x05, 0x46, 0x72, 0x65, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, - 0x46, 0x72, 0x65, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x4c, 0x69, 0x76, 0x65, 0x4f, 0x62, 0x6a, - 0x65, 0x63, 0x74, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x4c, 0x69, 0x76, 0x65, - 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x61, 0x75, 0x73, 0x65, - 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x50, - 0x61, 0x75, 0x73, 0x65, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x55, - 0x70, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x70, 0x74, - 0x69, 0x6d, 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xba, 0x02, - 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, - 0x0a, 0x08, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, - 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x65, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x29, 0x2e, + 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x44, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x74, + 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x43, 0x0a, 0x11, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, + 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x73, 0x65, + 0x74, 0x22, 0x46, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x74, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, + 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x11, 0x0a, 0x0f, 0x53, 0x79, 0x73, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa2, 0x02, 0x0a, + 0x10, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, 0x72, 0x6f, + 0x75, 0x74, 0x69, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, 0x12, 0x14, 0x0a, 0x05, 0x41, + 0x6c, 0x6c, 0x6f, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x41, 0x6c, 0x6c, 0x6f, + 0x63, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, 0x6c, 0x6f, + 0x63, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x79, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, + 0x53, 0x79, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x12, 0x14, 0x0a, + 0x05, 0x46, 0x72, 0x65, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x46, 0x72, + 0x65, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x4c, 0x69, 0x76, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, + 0x74, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x4c, 0x69, 0x76, 0x65, 0x4f, 0x62, + 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x61, 0x75, 0x73, 0x65, 0x54, 0x6f, + 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x50, 0x61, 0x75, + 0x73, 0x65, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x70, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x70, 0x74, 0x69, 0x6d, + 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xa1, 0x03, 0x0a, 0x0c, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x08, + 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, + 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, + 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, + 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x12, + 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x12, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, + 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x62, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x53, 0x79, 0x73, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, - 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x64, 0x0a, 0x1a, 0x63, 0x6f, - 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, - 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2f, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x16, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, - 0x70, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x62, 0x0a, 0x0b, 0x47, + 0x65, 0x74, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, + 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0x64, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, + 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, + 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, + 0x74, 0x61, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x16, 0x58, + 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_app_stats_command_command_proto_rawDescOnce sync.Once - file_app_stats_command_command_proto_rawDescData = file_app_stats_command_command_proto_rawDesc + file_command_proto_rawDescOnce sync.Once + file_command_proto_rawDescData = file_command_proto_rawDesc ) -func file_app_stats_command_command_proto_rawDescGZIP() []byte { - file_app_stats_command_command_proto_rawDescOnce.Do(func() { - file_app_stats_command_command_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_stats_command_command_proto_rawDescData) +func file_command_proto_rawDescGZIP() []byte { + file_command_proto_rawDescOnce.Do(func() { + file_command_proto_rawDescData = protoimpl.X.CompressGZIP(file_command_proto_rawDescData) }) - return file_app_stats_command_command_proto_rawDescData + return file_command_proto_rawDescData } -var file_app_stats_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_app_stats_command_command_proto_goTypes = []any{ +var file_command_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_command_proto_goTypes = []any{ (*GetStatsRequest)(nil), // 0: xray.app.stats.command.GetStatsRequest (*Stat)(nil), // 1: xray.app.stats.command.Stat (*GetStatsResponse)(nil), // 2: xray.app.stats.command.GetStatsResponse @@ -559,43 +564,45 @@ var file_app_stats_command_command_proto_goTypes = []any{ (*SysStatsResponse)(nil), // 6: xray.app.stats.command.SysStatsResponse (*Config)(nil), // 7: xray.app.stats.command.Config } -var file_app_stats_command_command_proto_depIdxs = []int32{ +var file_command_proto_depIdxs = []int32{ 1, // 0: xray.app.stats.command.GetStatsResponse.stat:type_name -> xray.app.stats.command.Stat 1, // 1: xray.app.stats.command.QueryStatsResponse.stat:type_name -> xray.app.stats.command.Stat 0, // 2: xray.app.stats.command.StatsService.GetStats:input_type -> xray.app.stats.command.GetStatsRequest - 3, // 3: xray.app.stats.command.StatsService.QueryStats:input_type -> xray.app.stats.command.QueryStatsRequest - 5, // 4: xray.app.stats.command.StatsService.GetSysStats:input_type -> xray.app.stats.command.SysStatsRequest - 2, // 5: xray.app.stats.command.StatsService.GetStats:output_type -> xray.app.stats.command.GetStatsResponse - 4, // 6: xray.app.stats.command.StatsService.QueryStats:output_type -> xray.app.stats.command.QueryStatsResponse - 6, // 7: xray.app.stats.command.StatsService.GetSysStats:output_type -> xray.app.stats.command.SysStatsResponse - 5, // [5:8] is the sub-list for method output_type - 2, // [2:5] is the sub-list for method input_type + 0, // 3: xray.app.stats.command.StatsService.GetStatsOnline:input_type -> xray.app.stats.command.GetStatsRequest + 3, // 4: xray.app.stats.command.StatsService.QueryStats:input_type -> xray.app.stats.command.QueryStatsRequest + 5, // 5: xray.app.stats.command.StatsService.GetSysStats:input_type -> xray.app.stats.command.SysStatsRequest + 2, // 6: xray.app.stats.command.StatsService.GetStats:output_type -> xray.app.stats.command.GetStatsResponse + 2, // 7: xray.app.stats.command.StatsService.GetStatsOnline:output_type -> xray.app.stats.command.GetStatsResponse + 4, // 8: xray.app.stats.command.StatsService.QueryStats:output_type -> xray.app.stats.command.QueryStatsResponse + 6, // 9: xray.app.stats.command.StatsService.GetSysStats:output_type -> xray.app.stats.command.SysStatsResponse + 6, // [6:10] is the sub-list for method output_type + 2, // [2:6] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name 2, // [2:2] is the sub-list for extension extendee 0, // [0:2] is the sub-list for field type_name } -func init() { file_app_stats_command_command_proto_init() } -func file_app_stats_command_command_proto_init() { - if File_app_stats_command_command_proto != nil { +func init() { file_command_proto_init() } +func file_command_proto_init() { + if File_command_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_app_stats_command_command_proto_rawDesc, + RawDescriptor: file_command_proto_rawDesc, NumEnums: 0, NumMessages: 8, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_app_stats_command_command_proto_goTypes, - DependencyIndexes: file_app_stats_command_command_proto_depIdxs, - MessageInfos: file_app_stats_command_command_proto_msgTypes, + GoTypes: file_command_proto_goTypes, + DependencyIndexes: file_command_proto_depIdxs, + MessageInfos: file_command_proto_msgTypes, }.Build() - File_app_stats_command_command_proto = out.File - file_app_stats_command_command_proto_rawDesc = nil - file_app_stats_command_command_proto_goTypes = nil - file_app_stats_command_command_proto_depIdxs = nil + File_command_proto = out.File + file_command_proto_rawDesc = nil + file_command_proto_goTypes = nil + file_command_proto_depIdxs = nil } diff --git a/app/stats/command/command.proto b/app/stats/command/command.proto index bd1f9781..1d2ed867 100644 --- a/app/stats/command/command.proto +++ b/app/stats/command/command.proto @@ -48,6 +48,7 @@ message SysStatsResponse { service StatsService { rpc GetStats(GetStatsRequest) returns (GetStatsResponse) {} + rpc GetStatsOnline(GetStatsRequest) returns (GetStatsResponse) {} rpc QueryStats(QueryStatsRequest) returns (QueryStatsResponse) {} rpc GetSysStats(SysStatsRequest) returns (SysStatsResponse) {} } diff --git a/app/stats/command/command_grpc.pb.go b/app/stats/command/command_grpc.pb.go index 40bd6383..e9431453 100644 --- a/app/stats/command/command_grpc.pb.go +++ b/app/stats/command/command_grpc.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.28.2 -// source: app/stats/command/command.proto +// - protoc v5.28.3 +// source: command.proto package command @@ -19,9 +19,10 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - StatsService_GetStats_FullMethodName = "/xray.app.stats.command.StatsService/GetStats" - StatsService_QueryStats_FullMethodName = "/xray.app.stats.command.StatsService/QueryStats" - StatsService_GetSysStats_FullMethodName = "/xray.app.stats.command.StatsService/GetSysStats" + StatsService_GetStats_FullMethodName = "/xray.app.stats.command.StatsService/GetStats" + StatsService_GetStatsOnline_FullMethodName = "/xray.app.stats.command.StatsService/GetStatsOnline" + StatsService_QueryStats_FullMethodName = "/xray.app.stats.command.StatsService/QueryStats" + StatsService_GetSysStats_FullMethodName = "/xray.app.stats.command.StatsService/GetSysStats" ) // StatsServiceClient is the client API for StatsService service. @@ -29,6 +30,7 @@ const ( // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type StatsServiceClient interface { GetStats(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) + GetStatsOnline(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) QueryStats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) GetSysStats(ctx context.Context, in *SysStatsRequest, opts ...grpc.CallOption) (*SysStatsResponse, error) } @@ -51,6 +53,16 @@ func (c *statsServiceClient) GetStats(ctx context.Context, in *GetStatsRequest, return out, nil } +func (c *statsServiceClient) GetStatsOnline(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetStatsResponse) + err := c.cc.Invoke(ctx, StatsService_GetStatsOnline_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *statsServiceClient) QueryStats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(QueryStatsResponse) @@ -76,6 +88,7 @@ func (c *statsServiceClient) GetSysStats(ctx context.Context, in *SysStatsReques // for forward compatibility. type StatsServiceServer interface { GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error) + GetStatsOnline(context.Context, *GetStatsRequest) (*GetStatsResponse, error) QueryStats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error) GetSysStats(context.Context, *SysStatsRequest) (*SysStatsResponse, error) mustEmbedUnimplementedStatsServiceServer() @@ -91,6 +104,9 @@ type UnimplementedStatsServiceServer struct{} func (UnimplementedStatsServiceServer) GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetStats not implemented") } +func (UnimplementedStatsServiceServer) GetStatsOnline(context.Context, *GetStatsRequest) (*GetStatsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetStatsOnline not implemented") +} func (UnimplementedStatsServiceServer) QueryStats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryStats not implemented") } @@ -136,6 +152,24 @@ func _StatsService_GetStats_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _StatsService_GetStatsOnline_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetStatsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StatsServiceServer).GetStatsOnline(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: StatsService_GetStatsOnline_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StatsServiceServer).GetStatsOnline(ctx, req.(*GetStatsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _StatsService_QueryStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryStatsRequest) if err := dec(in); err != nil { @@ -183,6 +217,10 @@ var StatsService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetStats", Handler: _StatsService_GetStats_Handler, }, + { + MethodName: "GetStatsOnline", + Handler: _StatsService_GetStatsOnline_Handler, + }, { MethodName: "QueryStats", Handler: _StatsService_QueryStats_Handler, @@ -193,5 +231,5 @@ var StatsService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "app/stats/command/command.proto", + Metadata: "command.proto", } diff --git a/app/stats/online_map.go b/app/stats/online_map.go new file mode 100644 index 00000000..0ba2b924 --- /dev/null +++ b/app/stats/online_map.go @@ -0,0 +1,80 @@ +package stats + +import ( + "sync" + "time" +) + +// OnlineMap is an implementation of stats.OnlineMap. +type OnlineMap struct { + value int + ipList map[string]time.Time + access sync.RWMutex + lastCleanup time.Time + cleanupPeriod time.Duration +} + +// NewOnlineMap creates a new instance of OnlineMap. +func NewOnlineMap() *OnlineMap { + return &OnlineMap{ + ipList: make(map[string]time.Time), + lastCleanup: time.Now(), + cleanupPeriod: 10 * time.Second, + } +} + +// Count implements stats.OnlineMap. +func (c *OnlineMap) Count() int { + return c.value +} + +// List implements stats.OnlineMap. +func (c *OnlineMap) List() []string { + return c.GetKeys() +} + +// AddIP implements stats.OnlineMap. +func (c *OnlineMap) AddIP(ip string) { + list := c.ipList + + if ip == "127.0.0.1" { + return + } + if _, ok := list[ip]; !ok { + c.access.Lock() + list[ip] = time.Now() + c.access.Unlock() + } + if time.Since(c.lastCleanup) > c.cleanupPeriod { + list = c.RemoveExpiredIPs(list) + c.lastCleanup = time.Now() + } + + c.value = len(list) + c.ipList = list +} + +func (c *OnlineMap) GetKeys() []string { + c.access.RLock() + defer c.access.RUnlock() + + keys := []string{} + for k := range c.ipList { + keys = append(keys, k) + } + return keys +} + +func (c *OnlineMap) RemoveExpiredIPs(list map[string]time.Time) map[string]time.Time { + c.access.Lock() + defer c.access.Unlock() + + now := time.Now() + for k, t := range list { + diff := now.Sub(t) + if diff.Seconds() > 20 { + delete(list, k) + } + } + return list +} diff --git a/app/stats/stats.go b/app/stats/stats.go index 5e9d0b59..5451c5e6 100644 --- a/app/stats/stats.go +++ b/app/stats/stats.go @@ -11,17 +11,19 @@ import ( // Manager is an implementation of stats.Manager. type Manager struct { - access sync.RWMutex - counters map[string]*Counter - channels map[string]*Channel - running bool + access sync.RWMutex + counters map[string]*Counter + onlineMap map[string]*OnlineMap + channels map[string]*Channel + running bool } // NewManager creates an instance of Statistics Manager. func NewManager(ctx context.Context, config *Config) (*Manager, error) { m := &Manager{ - counters: make(map[string]*Counter), - channels: make(map[string]*Channel), + counters: make(map[string]*Counter), + onlineMap: make(map[string]*OnlineMap), + channels: make(map[string]*Channel), } return m, nil @@ -81,6 +83,43 @@ func (m *Manager) VisitCounters(visitor func(string, stats.Counter) bool) { } } +// RegisterOnlineMap implements stats.Manager. +func (m *Manager) RegisterOnlineMap(name string) (stats.OnlineMap, error) { + m.access.Lock() + defer m.access.Unlock() + + if _, found := m.onlineMap[name]; found { + return nil, errors.New("onlineMap ", name, " already registered.") + } + errors.LogDebug(context.Background(), "create new onlineMap ", name) + om := NewOnlineMap() + m.onlineMap[name] = om + return om, nil +} + +// UnregisterOnlineMap implements stats.Manager. +func (m *Manager) UnregisterOnlineMap(name string) error { + m.access.Lock() + defer m.access.Unlock() + + if _, found := m.onlineMap[name]; found { + errors.LogDebug(context.Background(), "remove onlineMap ", name) + delete(m.onlineMap, name) + } + return nil +} + +// GetOnlineMap implements stats.Manager. +func (m *Manager) GetOnlineMap(name string) stats.OnlineMap { + m.access.RLock() + defer m.access.RUnlock() + + if om, found := m.onlineMap[name]; found { + return om + } + return nil +} + // RegisterChannel implements stats.Manager. func (m *Manager) RegisterChannel(name string) (stats.Channel, error) { m.access.Lock() diff --git a/features/policy/policy.go b/features/policy/policy.go index 4d3f7ecf..d6fd20d0 100644 --- a/features/policy/policy.go +++ b/features/policy/policy.go @@ -27,6 +27,8 @@ type Stats struct { UserUplink bool // Whether or not to enable stat counter for user downlink traffic. UserDownlink bool + // Whether or not to enable online map for user. + UserOnline bool } // Buffer contains settings for internal buffer. @@ -123,6 +125,7 @@ func SessionDefault() Session { Stats: Stats{ UserUplink: false, UserDownlink: false, + UserOnline: false, }, Buffer: defaultBufferPolicy(), } diff --git a/features/stats/stats.go b/features/stats/stats.go index 010dd767..de343a82 100644 --- a/features/stats/stats.go +++ b/features/stats/stats.go @@ -20,6 +20,18 @@ type Counter interface { Add(int64) int64 } +// OnlineMap is the interface for stats. +// +// xray:api:stable +type OnlineMap interface { + // Count is the current value of the OnlineMap. + Count() int + // AddIP adds a ip to the current OnlineMap. + AddIP(string) + // List is the current OnlineMap ip list. + List() []string +} + // Channel is the interface for stats channel. // // xray:api:stable @@ -70,6 +82,13 @@ type Manager interface { // GetCounter returns a counter by its identifier. GetCounter(string) Counter + // RegisterOnlineMap registers a new onlinemap to the manager. The identifier string must not be empty, and unique among other onlinemaps. + RegisterOnlineMap(string) (OnlineMap, error) + // UnregisterOnlineMap unregisters a onlinemap from the manager by its identifier. + UnregisterOnlineMap(string) error + // GetOnlineMap returns a onlinemap by its identifier. + GetOnlineMap(string) OnlineMap + // RegisterChannel registers a new channel to the manager. The identifier string must not be empty, and unique among other channels. RegisterChannel(string) (Channel, error) // UnregisterChannel unregisters a channel from the manager by its identifier. @@ -88,6 +107,16 @@ func GetOrRegisterCounter(m Manager, name string) (Counter, error) { return m.RegisterCounter(name) } +// GetOrRegisterOnlineMap tries to get the OnlineMap first. If not exist, it then tries to create a new onlinemap. +func GetOrRegisterOnlineMap(m Manager, name string) (OnlineMap, error) { + onlineMap := m.GetOnlineMap(name) + if onlineMap != nil { + return onlineMap, nil + } + + return m.RegisterOnlineMap(name) +} + // GetOrRegisterChannel tries to get the StatChannel first. If not exist, it then tries to create a new channel. func GetOrRegisterChannel(m Manager, name string) (Channel, error) { channel := m.GetChannel(name) @@ -128,6 +157,21 @@ func (NoopManager) GetCounter(string) Counter { return nil } +// RegisterOnlineMap implements Manager. +func (NoopManager) RegisterOnlineMap(string) (OnlineMap, error) { + return nil, errors.New("not implemented") +} + +// UnregisterOnlineMap implements Manager. +func (NoopManager) UnregisterOnlineMap(string) error { + return nil +} + +// GetOnlineMap implements Manager. +func (NoopManager) GetOnlineMap(string) OnlineMap { + return nil +} + // RegisterChannel implements Manager. func (NoopManager) RegisterChannel(string) (Channel, error) { return nil, errors.New("not implemented") diff --git a/infra/conf/policy.go b/infra/conf/policy.go index 5fbf01e6..1182766c 100644 --- a/infra/conf/policy.go +++ b/infra/conf/policy.go @@ -11,6 +11,7 @@ type Policy struct { DownlinkOnly *uint32 `json:"downlinkOnly"` StatsUserUplink bool `json:"statsUserUplink"` StatsUserDownlink bool `json:"statsUserDownlink"` + StatsUserOnline bool `json:"statsUserOnline"` BufferSize *int32 `json:"bufferSize"` } @@ -34,6 +35,7 @@ func (t *Policy) Build() (*policy.Policy, error) { Stats: &policy.Policy_Stats{ UserUplink: t.StatsUserUplink, UserDownlink: t.StatsUserDownlink, + UserOnline: t.StatsUserOnline, }, } diff --git a/main/commands/all/api/api.go b/main/commands/all/api/api.go index 5e21884b..329450c9 100644 --- a/main/commands/all/api/api.go +++ b/main/commands/all/api/api.go @@ -26,5 +26,6 @@ var CmdAPI = &base.Command{ cmdAddRules, cmdRemoveRules, cmdSourceIpBlock, + cmdOnlineStats, }, } diff --git a/main/commands/all/api/stats_online.go b/main/commands/all/api/stats_online.go new file mode 100644 index 00000000..93592807 --- /dev/null +++ b/main/commands/all/api/stats_online.go @@ -0,0 +1,47 @@ +package api + +import ( + statsService "github.com/xtls/xray-core/app/stats/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdOnlineStats = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api statsonline [--server=127.0.0.1:8080] [-name '']", + Short: "Get online user", + Long: ` +Get statistics from Xray. +Arguments: + -s, -server + The API server address. Default 127.0.0.1:8080 + -t, -timeout + Timeout seconds to call API. Default 3 + -email + email of the user. + -reset + Reset the counter to fetching its value. +Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -email "user1@test.com" +`, + Run: executeOnlineStats, +} + +func executeOnlineStats(cmd *base.Command, args []string) { + setSharedFlags(cmd) + email := cmd.Flag.String("email", "", "") + cmd.Flag.Parse(args) + statName := "user>>>" + *email + ">>>online" + conn, ctx, close := dialAPIServer() + defer close() + + client := statsService.NewStatsServiceClient(conn) + r := &statsService.GetStatsRequest{ + Name: statName, + Reset_: false, + } + resp, err := client.GetStatsOnline(ctx, r) + if err != nil { + base.Fatalf("failed to get stats: %s", err) + } + showJSONResponse(resp) +} From 9fbb6fbb3b8eb81223c34da3baa1ff1e913a348f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 4 Nov 2024 05:00:18 +0000 Subject: [PATCH 588/867] XHTTP client: Move `dest2` into `MemoryStreamConfig` as well --- transport/internet/memory_settings.go | 10 ++++++++++ transport/internet/splithttp/dialer.go | 9 ++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/transport/internet/memory_settings.go b/transport/internet/memory_settings.go index 5add530c..a46fc297 100644 --- a/transport/internet/memory_settings.go +++ b/transport/internet/memory_settings.go @@ -1,7 +1,10 @@ package internet +import "github.com/xtls/xray-core/common/net" + // MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce the number of Protobuf parsings. type MemoryStreamConfig struct { + Destination *net.Destination ProtocolName string ProtocolSettings interface{} SecurityType string @@ -23,6 +26,13 @@ func ToMemoryStreamConfig(s *StreamConfig) (*MemoryStreamConfig, error) { } if s != nil { + if s.Address != nil { + mss.Destination = &net.Destination{ + Address: s.Address.AsAddress(), + Port: net.Port(s.Port), + Network: net.Network_TCP, + } + } mss.SocketSettings = s.SocketSettings } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 43ba0a46..ea935198 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -264,12 +264,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } globalDialerAccess.Unlock() memory2 := streamSettings.DownloadSettings - dest2 := net.Destination{ - Address: transportConfiguration.DownloadSettings.Address.AsAddress(), // just panic - Port: net.Port(transportConfiguration.DownloadSettings.Port), - Network: net.Network_TCP, - } - httpClient2, muxRes2 = getHTTPClient(ctx, dest2, memory2) + httpClient2, muxRes2 = getHTTPClient(ctx, *memory2.Destination, memory2) // just panic if tls.ConfigFromStreamSettings(memory2) != nil || reality.ConfigFromStreamSettings(memory2) != nil { requestURL2.Scheme = "https" } else { @@ -278,7 +273,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me config2 := memory2.ProtocolSettings.(*Config) requestURL2.Host = config2.Host if requestURL2.Host == "" { - requestURL2.Host = dest2.NetAddr() + requestURL2.Host = memory2.Destination.NetAddr() } requestURL2.Path = requestURL.Path // the same requestURL2.RawQuery = config2.GetNormalizedQuery() From ccc4b7b2cf93a06273f738350aa81e5ef1ec3212 Mon Sep 17 00:00:00 2001 From: tcpdumppy <847462026@qq.com> Date: Mon, 4 Nov 2024 23:36:42 +0800 Subject: [PATCH 589/867] Test: Fix incorrect output format (#3968) --- app/dns/dnscommon_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dns/dnscommon_test.go b/app/dns/dnscommon_test.go index 6530d1a0..d11f8632 100644 --- a/app/dns/dnscommon_test.go +++ b/app/dns/dnscommon_test.go @@ -88,7 +88,7 @@ func Test_parseResponse(t *testing.T) { got.Expire = time.Time{} } if cmp.Diff(got, tt.want) != "" { - t.Errorf(cmp.Diff(got, tt.want)) + t.Error(cmp.Diff(got, tt.want)) // t.Errorf("handleResponse() = %#v, want %#v", got, tt.want) } }) From 057e6284b287d9ae6042633e4d8f21eb71641ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Mon, 4 Nov 2024 23:39:04 +0800 Subject: [PATCH 590/867] UDS: prevent crash when proxy udp (#3967) * net: Prevent nil pointer err in NetAddr() * Fix dsworker saddr problem --- app/proxyman/inbound/worker.go | 3 ++- common/net/destination.go | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index a14a338f..14df725d 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -464,7 +464,8 @@ func (w *dsWorker) callback(conn stat.Connection) { } } ctx = session.ContextWithInbound(ctx, &session.Inbound{ - Source: net.DestinationFromAddr(conn.RemoteAddr()), + // Unix have no source addr, so we use gateway as source for log. + Source: net.UnixDestination(w.address), Gateway: net.UnixDestination(w.address), Tag: w.tag, Conn: conn, diff --git a/common/net/destination.go b/common/net/destination.go index 90f8298b..952dcc6b 100644 --- a/common/net/destination.go +++ b/common/net/destination.go @@ -89,10 +89,12 @@ func UnixDestination(address Address) Destination { // NetAddr returns the network address in this Destination in string form. func (d Destination) NetAddr() string { addr := "" - if d.Network == Network_TCP || d.Network == Network_UDP { - addr = d.Address.String() + ":" + d.Port.String() - } else if d.Network == Network_UNIX { - addr = d.Address.String() + if d.Address != nil { + if d.Network == Network_TCP || d.Network == Network_UDP { + addr = d.Address.String() + ":" + d.Port.String() + } else if d.Network == Network_UNIX { + addr = d.Address.String() + } } return addr } From afc7ec55062c14ae69fc67b148155faae1c31548 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 5 Nov 2024 00:50:45 +0000 Subject: [PATCH 591/867] v24.11.5 --- core/core.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/core.go b/core/core.go index 8f2950c5..3d3305e5 100644 --- a/core/core.go +++ b/core/core.go @@ -18,8 +18,8 @@ import ( var ( Version_x byte = 24 - Version_y byte = 10 - Version_z byte = 31 + Version_y byte = 11 + Version_z byte = 5 ) var ( From 71cfea8aae9802ca0e7e5d35aba2948445dfe34c Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Wed, 6 Nov 2024 17:27:06 +0300 Subject: [PATCH 592/867] Chore: Fix some spelling errors (#3976) --- app/log/log.go | 4 ++-- app/observatory/burst/ping.go | 2 +- app/proxyman/inbound/inbound.go | 2 +- app/proxyman/outbound/handler.go | 2 +- common/protocol/user.go | 2 +- core/config.go | 2 +- core/xray.go | 4 ++-- infra/conf/transport_internet.go | 4 ++-- proxy/blackhole/config.go | 2 +- transport/internet/memory_settings.go | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/log/log.go b/app/log/log.go index 90de99e2..da69d3b6 100644 --- a/app/log/log.go +++ b/app/log/log.go @@ -31,8 +31,8 @@ func New(ctx context.Context, config *Config) (*Instance, error) { } log.RegisterHandler(g) - // Start logger instantly on initialization - // Other modules would log during initialization + // start logger now, + // then other modules will be able to log during initialization if err := g.startInternal(); err != nil { return nil, err } diff --git a/app/observatory/burst/ping.go b/app/observatory/burst/ping.go index ccc0af68..de1465b9 100644 --- a/app/observatory/burst/ping.go +++ b/app/observatory/burst/ping.go @@ -52,7 +52,7 @@ func newHTTPClient(ctxv context.Context, handler string, timeout time.Duration) // MeasureDelay returns the delay time of the request to dest func (s *pingClient) MeasureDelay() (time.Duration, error) { if s.httpClient == nil { - panic("pingClient no initialized") + panic("pingClient not initialized") } req, err := http.NewRequest(http.MethodHead, s.destination, nil) if err != nil { diff --git a/app/proxyman/inbound/inbound.go b/app/proxyman/inbound/inbound.go index fc0c16a4..cc6aa9d8 100644 --- a/app/proxyman/inbound/inbound.go +++ b/app/proxyman/inbound/inbound.go @@ -13,7 +13,7 @@ import ( "github.com/xtls/xray-core/features/inbound" ) -// Manager is to manage all inbound handlers. +// Manager manages all inbound handlers. type Manager struct { access sync.RWMutex untaggedHandler []inbound.Handler diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 47d7d6bf..404ac30e 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -54,7 +54,7 @@ func getStatCounter(v *core.Instance, tag string) (stats.Counter, stats.Counter) return uplinkCounter, downlinkCounter } -// Handler is an implements of outbound.Handler. +// Handler implements outbound.Handler. type Handler struct { tag string senderSettings *proxyman.SenderConfig diff --git a/common/protocol/user.go b/common/protocol/user.go index 2986eb19..230c4b6d 100644 --- a/common/protocol/user.go +++ b/common/protocol/user.go @@ -7,7 +7,7 @@ import ( func (u *User) GetTypedAccount() (Account, error) { if u.GetAccount() == nil { - return nil, errors.New("Account missing").AtWarning() + return nil, errors.New("Account is missing").AtWarning() } rawAccount, err := u.Account.GetInstance() diff --git a/core/config.go b/core/config.go index e101c920..4390766d 100644 --- a/core/config.go +++ b/core/config.go @@ -30,7 +30,7 @@ type ConfigLoader func(input interface{}) (*Config, error) // ConfigBuilder is a builder to build core.Config from filenames and formats type ConfigBuilder func(files []*ConfigSource) (*Config, error) -// ConfigsMerger merge multiple json configs into on config +// ConfigsMerger merges multiple json configs into a single one type ConfigsMerger func(files []*ConfigSource) (string, error) var ( diff --git a/core/xray.go b/core/xray.go index 09d35d9f..0e1f0830 100644 --- a/core/xray.go +++ b/core/xray.go @@ -87,7 +87,7 @@ func (r *resolution) resolve(allFeatures []features.Feature) (bool, error) { return true, err } -// Instance combines all functionalities in Xray. +// Instance combines all Xray features. type Instance struct { access sync.Mutex features []features.Feature @@ -228,7 +228,7 @@ func initInstanceWithConfig(config *Config, server *Instance) (bool, error) { ) if server.featureResolutions != nil { - return true, errors.New("not all dependency are resolved.") + return true, errors.New("not all dependencies are resolved.") } if err := addInboundHandlers(server, config.Inbound); err != nil { diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index c81123a3..ed1ea072 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -568,7 +568,7 @@ func (c *REALITYConfig) Build() (proto.Message, error) { return nil, errors.New(`invalid "minClientVer": `, c.MinClientVer) } if u, err = strconv.ParseUint(s, 10, 8); err != nil { - return nil, errors.New(`"minClientVer[`, i, `]" should be lesser than 256`) + return nil, errors.New(`"minClientVer[`, i, `]" should be less than 256`) } else { config.MinClientVer[i] = byte(u) } @@ -582,7 +582,7 @@ func (c *REALITYConfig) Build() (proto.Message, error) { return nil, errors.New(`invalid "maxClientVer": `, c.MaxClientVer) } if u, err = strconv.ParseUint(s, 10, 8); err != nil { - return nil, errors.New(`"maxClientVer[`, i, `]" should be lesser than 256`) + return nil, errors.New(`"maxClientVer[`, i, `]" should be less than 256`) } else { config.MaxClientVer[i] = byte(u) } diff --git a/proxy/blackhole/config.go b/proxy/blackhole/config.go index b0f8e60c..e4a16684 100644 --- a/proxy/blackhole/config.go +++ b/proxy/blackhole/config.go @@ -17,7 +17,7 @@ Content-Length: 0 // ResponseConfig is the configuration for blackhole responses. type ResponseConfig interface { - // WriteTo writes predefined response to the give buffer. + // WriteTo writes a predefined response to the specified buffer. WriteTo(buf.Writer) int32 } diff --git a/transport/internet/memory_settings.go b/transport/internet/memory_settings.go index a46fc297..f1331353 100644 --- a/transport/internet/memory_settings.go +++ b/transport/internet/memory_settings.go @@ -2,7 +2,7 @@ package internet import "github.com/xtls/xray-core/common/net" -// MemoryStreamConfig is a parsed form of StreamConfig. This is used to reduce the number of Protobuf parsings. +// MemoryStreamConfig is a parsed form of StreamConfig. It is used to reduce the number of Protobuf parses. type MemoryStreamConfig struct { Destination *net.Destination ProtocolName string From 6877ca5201c945d6c59b184c1ccb33f5ab1cc93a Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 7 Nov 2024 03:50:28 +0000 Subject: [PATCH 593/867] XHTTP client: Allow different paths in U-D-S (#3977) --- transport/internet/splithttp/dialer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index ea935198..1c5300f3 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -275,7 +275,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if requestURL2.Host == "" { requestURL2.Host = memory2.Destination.NetAddr() } - requestURL2.Path = requestURL.Path // the same + requestURL2.Path = config2.GetNormalizedPath() + sessionIdUuid.String() requestURL2.RawQuery = config2.GetNormalizedQuery() } From b98f29bf3e0e981dcb1d55eb9b2d663c1b5366bf Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Thu, 7 Nov 2024 19:00:04 +0300 Subject: [PATCH 594/867] Chore: Fix some comments (#3979) --- transport/internet/config.pb.go | 6 +++--- transport/internet/config.proto | 6 +++--- transport/internet/kcp/config.pb.go | 4 +++- transport/internet/kcp/config.proto | 4 +++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 98e408e9..2cd58fe1 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -152,9 +152,9 @@ type TransportConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // Type of network that this settings supports. + // Transport protocol name. ProtocolName string `protobuf:"bytes,3,opt,name=protocol_name,json=protocolName,proto3" json:"protocol_name,omitempty"` - // Specific settings. Must be of the transports. + // Specific transport protocol settings. Settings *serial.TypedMessage `protobuf:"bytes,2,opt,name=settings,proto3" json:"settings,omitempty"` } @@ -214,7 +214,7 @@ type StreamConfig struct { TransportSettings []*TransportConfig `protobuf:"bytes,2,rep,name=transport_settings,json=transportSettings,proto3" json:"transport_settings,omitempty"` // Type of security. Must be a message name of the settings proto. SecurityType string `protobuf:"bytes,3,opt,name=security_type,json=securityType,proto3" json:"security_type,omitempty"` - // Settings for transport security. For now the only choice is TLS. + // Transport security settings. They can be either TLS or REALITY. SecuritySettings []*serial.TypedMessage `protobuf:"bytes,4,rep,name=security_settings,json=securitySettings,proto3" json:"security_settings,omitempty"` SocketSettings *SocketConfig `protobuf:"bytes,6,opt,name=socket_settings,json=socketSettings,proto3" json:"socket_settings,omitempty"` } diff --git a/transport/internet/config.proto b/transport/internet/config.proto index 008e33c6..61812644 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -24,10 +24,10 @@ enum DomainStrategy { } message TransportConfig { - // Type of network that this settings supports. + // Transport protocol name. string protocol_name = 3; - // Specific settings. Must be of the transports. + // Specific transport protocol settings. xray.common.serial.TypedMessage settings = 2; } @@ -43,7 +43,7 @@ message StreamConfig { // Type of security. Must be a message name of the settings proto. string security_type = 3; - // Settings for transport security. For now the only choice is TLS. + // Transport security settings. They can be either TLS or REALITY. repeated xray.common.serial.TypedMessage security_settings = 4; SocketConfig socket_settings = 6; diff --git a/transport/internet/kcp/config.pb.go b/transport/internet/kcp/config.pb.go index 0d2a9697..506a2dcd 100644 --- a/transport/internet/kcp/config.pb.go +++ b/transport/internet/kcp/config.pb.go @@ -342,7 +342,9 @@ func (x *ConnectionReuse) GetEnable() bool { return false } -// Maximum Transmission Unit, in bytes. +// Pre-shared secret between client and server. It is used for traffic obfuscation. +// Note that if seed is absent in the config, the traffic will still be obfuscated, +// but by a predefined algorithm. type EncryptionSeed struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache diff --git a/transport/internet/kcp/config.proto b/transport/internet/kcp/config.proto index a9806e6f..8690f09f 100644 --- a/transport/internet/kcp/config.proto +++ b/transport/internet/kcp/config.proto @@ -42,7 +42,9 @@ message ConnectionReuse { bool enable = 1; } -// Maximum Transmission Unit, in bytes. +// Pre-shared secret between client and server. It is used for traffic obfuscation. +// Note that if seed is absent in the config, the traffic will still be obfuscated, +// but by a predefined algorithm. message EncryptionSeed { string seed = 1; } From 8cd3f5448dbf52347452a8ff2a4d284ab423859b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:25:09 -0500 Subject: [PATCH 595/867] Bump github.com/sagernet/sing from 0.4.3 to 0.5.0 (#3971) Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.4.3 to 0.5.0. - [Commits](https://github.com/sagernet/sing/compare/v0.4.3...v0.5.0) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7f3cba9f..72e8ac67 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/pires/go-proxyproto v0.8.0 github.com/quic-go/quic-go v0.46.0 github.com/refraction-networking/utls v1.6.7 - github.com/sagernet/sing v0.4.3 + github.com/sagernet/sing v0.5.0 github.com/sagernet/sing-shadowsocks v0.2.7 github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index 8fa32abd..2a52d965 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= -github.com/sagernet/sing v0.4.3 h1:Ty/NAiNnVd6844k7ujlL5lkzydhcTH5Psc432jXA4Y8= -github.com/sagernet/sing v0.4.3/go.mod h1:ieZHA/+Y9YZfXs2I3WtuwgyCZ6GPsIR7HdKb1SdEnls= +github.com/sagernet/sing v0.5.0 h1:soo2wVwLcieKWWKIksFNK6CCAojUgAppqQVwyRYGkEM= +github.com/sagernet/sing v0.5.0/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8= github.com/sagernet/sing-shadowsocks v0.2.7/go.mod h1:0rIKJZBR65Qi0zwdKezt4s57y/Tl1ofkaq6NlkzVuyE= github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 h1:emzAzMZ1L9iaKCTxdy3Em8Wv4ChIAGnfiz18Cda70g4= From 6cb58d93159801ec483753be7b5c4784e62f18e9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:25:47 -0500 Subject: [PATCH 596/867] Bump golang.org/x/sync from 0.8.0 to 0.9.0 (#3985) Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.8.0 to 0.9.0. - [Commits](https://github.com/golang/sync/compare/v0.8.0...v0.9.0) --- updated-dependencies: - dependency-name: golang.org/x/sync dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 72e8ac67..967061b2 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.28.0 golang.org/x/net v0.30.0 - golang.org/x/sync v0.8.0 + golang.org/x/sync v0.9.0 golang.org/x/sys v0.26.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.67.1 diff --git a/go.sum b/go.sum index 2a52d965..ed38dddd 100644 --- a/go.sum +++ b/go.sum @@ -93,8 +93,8 @@ golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= From 5af750b3366aac9353bd98a0b0bfb2a350dca51d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:29:35 -0500 Subject: [PATCH 597/867] Bump golang.org/x/crypto from 0.28.0 to 0.29.0 (#3986) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.28.0 to 0.29.0. - [Commits](https://github.com/golang/crypto/compare/v0.28.0...v0.29.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 967061b2..b4a9870f 100644 --- a/go.mod +++ b/go.mod @@ -22,10 +22,10 @@ require ( github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.28.0 + golang.org/x/crypto v0.29.0 golang.org/x/net v0.30.0 golang.org/x/sync v0.9.0 - golang.org/x/sys v0.26.0 + golang.org/x/sys v0.27.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.67.1 google.golang.org/protobuf v1.35.1 @@ -51,7 +51,7 @@ require ( go.uber.org/mock v0.4.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/mod v0.18.0 // indirect - golang.org/x/text v0.19.0 // indirect + golang.org/x/text v0.20.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect diff --git a/go.sum b/go.sum index ed38dddd..777fe98a 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= -golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= @@ -103,14 +103,14 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM= -golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 94c02f090e1a1a5ca6f48177dfce7cdca2c77541 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 10:29:50 -0500 Subject: [PATCH 598/867] Bump golang.org/x/sys from 0.26.0 to 0.27.0 (#3987) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.26.0 to 0.27.0. - [Commits](https://github.com/golang/sys/compare/v0.26.0...v0.27.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From bc4bf3d38f7b95c9b4bf58edbdc1219bac90094f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 9 Nov 2024 11:05:41 +0000 Subject: [PATCH 599/867] XHTTP: Add "stream-up" mode for client & server (#3994) --- infra/conf/transport_internet.go | 10 +++ .../internet/splithttp/browser_client.go | 4 + transport/internet/splithttp/client.go | 12 +++ transport/internet/splithttp/config.pb.go | 73 +++++++++------- transport/internet/splithttp/config.proto | 1 + transport/internet/splithttp/dialer.go | 84 ++++++++++--------- transport/internet/splithttp/hub.go | 33 ++++++-- transport/internet/splithttp/upload_queue.go | 24 ++++++ 8 files changed, 164 insertions(+), 77 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index ed1ea072..f5a36328 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -233,6 +233,7 @@ type SplitHTTPConfig struct { XPaddingBytes *Int32Range `json:"xPaddingBytes"` Xmux Xmux `json:"xmux"` DownloadSettings *StreamConfig `json:"downloadSettings"` + Mode string `json:"mode"` } type Xmux struct { @@ -289,6 +290,14 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { muxProtobuf.CMaxReuseTimes.To = 128 } + switch c.Mode { + case "": + c.Mode = "auto" + case "auto", "packet-up", "stream-up": + default: + return nil, errors.New("unsupported mode: " + c.Mode) + } + config := &splithttp.Config{ Path: c.Path, Host: c.Host, @@ -299,6 +308,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { NoSSEHeader: c.NoSSEHeader, XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), Xmux: &muxProtobuf, + Mode: c.Mode, } var err error if c.DownloadSettings != nil { diff --git a/transport/internet/splithttp/browser_client.go b/transport/internet/splithttp/browser_client.go index 8a23682e..14ecaaf1 100644 --- a/transport/internet/splithttp/browser_client.go +++ b/transport/internet/splithttp/browser_client.go @@ -14,6 +14,10 @@ import ( // has no fields because everything is global state :O) type BrowserDialerClient struct{} +func (c *BrowserDialerClient) OpenUpload(ctx context.Context, baseURL string) io.WriteCloser { + panic("not implemented yet") +} + func (c *BrowserDialerClient) OpenDownload(ctx context.Context, baseURL string) (io.ReadCloser, gonet.Addr, gonet.Addr, error) { conn, err := browser_dialer.DialGet(baseURL) dummyAddr := &gonet.IPAddr{} diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index 3f278aa7..e5866b55 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -25,6 +25,10 @@ type DialerClient interface { // (ctx, baseURL) -> (downloadReader, remoteAddr, localAddr) // baseURL already contains sessionId OpenDownload(context.Context, string) (io.ReadCloser, net.Addr, net.Addr, error) + + // (ctx, baseURL) -> uploadWriter + // baseURL already contains sessionId + OpenUpload(context.Context, string) io.WriteCloser } // implements splithttp.DialerClient in terms of direct network connections @@ -38,6 +42,14 @@ type DefaultDialerClient struct { dialUploadConn func(ctxInner context.Context) (net.Conn, error) } +func (c *DefaultDialerClient) OpenUpload(ctx context.Context, baseURL string) io.WriteCloser { + reader, writer := io.Pipe() + req, _ := http.NewRequestWithContext(ctx, "POST", baseURL, reader) + req.Header = c.transportConfig.GetRequestHeader() + go c.client.Do(req) + return writer +} + func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) (io.ReadCloser, gonet.Addr, gonet.Addr, error) { var remoteAddr gonet.Addr var localAddr gonet.Addr diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index f3f80831..f2d1ab4f 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -36,6 +36,7 @@ type Config struct { XPaddingBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` Xmux *Multiplexing `protobuf:"bytes,9,opt,name=xmux,proto3" json:"xmux,omitempty"` DownloadSettings *internet.StreamConfig `protobuf:"bytes,10,opt,name=downloadSettings,proto3" json:"downloadSettings,omitempty"` + Mode string `protobuf:"bytes,11,opt,name=mode,proto3" json:"mode,omitempty"` } func (x *Config) Reset() { @@ -138,6 +139,13 @@ func (x *Config) GetDownloadSettings() *internet.StreamConfig { return nil } +func (x *Config) GetMode() string { + if x != nil { + return x.Mode + } + return "" +} + type RandRangeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -270,7 +278,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x1a, 0x1f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x82, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, + 0x96, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, @@ -314,47 +322,48 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, - 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, - 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, - 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, 0x0a, 0x0c, - 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, 0x0a, 0x0e, - 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, + 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, + 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x1a, 0x39, 0x0a, + 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, + 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, + 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, + 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, + 0xfe, 0x02, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, + 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, + 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, + 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, + 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, - 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, - 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, + 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, - 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, + 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, - 0x4d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, - 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, - 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, 0x01, 0x0a, - 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, - 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, - 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, - 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, - 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, + 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, + 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, + 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, + 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 384ae605..b5894620 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -19,6 +19,7 @@ message Config { RandRangeConfig xPaddingBytes = 8; Multiplexing xmux = 9; xray.transport.internet.StreamConfig downloadSettings = 10; + string mode = 11; } message RandRangeConfig { diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 1c5300f3..a63d3253 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -254,9 +254,9 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me httpClient, muxRes := getHTTPClient(ctx, dest, streamSettings) - var httpClient2 DialerClient + httpClient2 := httpClient + requestURL2 := requestURL var muxRes2 *muxResource - var requestURL2 url.URL if transportConfiguration.DownloadSettings != nil { globalDialerAccess.Lock() if streamSettings.DownloadSettings == nil { @@ -279,11 +279,10 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestURL2.RawQuery = config2.GetNormalizedQuery() } - maxUploadSize := scMaxEachPostBytes.roll() - // WithSizeLimit(0) will still allow single bytes to pass, and a lot of - // code relies on this behavior. Subtract 1 so that together with - // uploadWriter wrapper, exact size limits can be enforced - uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1)) + reader, remoteAddr, localAddr, err := httpClient2.OpenDownload(context.WithoutCancel(ctx), requestURL2.String()) + if err != nil { + return nil, err + } if muxRes != nil { muxRes.OpenRequests.Add(1) @@ -291,15 +290,48 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if muxRes2 != nil { muxRes2.OpenRequests.Add(1) } + closed := false + + conn := splitConn{ + writer: nil, + reader: reader, + remoteAddr: remoteAddr, + localAddr: localAddr, + onClose: func() { + if closed { + return + } + closed = true + if muxRes != nil { + muxRes.OpenRequests.Add(-1) + } + if muxRes2 != nil { + muxRes2.OpenRequests.Add(-1) + } + }, + } + + mode := transportConfiguration.Mode + if mode == "auto" && realityConfig != nil { + mode = "stream-up" + } + if mode == "stream-up" { + conn.writer = httpClient.OpenUpload(ctx, requestURL.String()) + return stat.Connection(&conn), nil + } + + maxUploadSize := scMaxEachPostBytes.roll() + // WithSizeLimit(0) will still allow single bytes to pass, and a lot of + // code relies on this behavior. Subtract 1 so that together with + // uploadWriter wrapper, exact size limits can be enforced + uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1)) + + conn.writer = uploadWriter{ + uploadPipeWriter, + maxUploadSize, + } go func() { - if muxRes != nil { - defer muxRes.OpenRequests.Add(-1) - } - if muxRes2 != nil { - defer muxRes2.OpenRequests.Add(-1) - } - requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll())) var requestCounter int64 @@ -352,30 +384,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } }() - httpClient3 := httpClient - requestURL3 := requestURL - if httpClient2 != nil { - httpClient3 = httpClient2 - requestURL3 = requestURL2 - } - - reader, remoteAddr, localAddr, err := httpClient3.OpenDownload(context.WithoutCancel(ctx), requestURL3.String()) - if err != nil { - return nil, err - } - - writer := uploadWriter{ - uploadPipeWriter, - maxUploadSize, - } - - conn := splitConn{ - writer: writer, - reader: reader, - remoteAddr: remoteAddr, - localAddr: localAddr, - } - return stat.Connection(&conn), nil } diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index b7244f10..58113f02 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -100,6 +100,8 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req return } + h.config.WriteResponseHeader(writer) + sessionId := "" subpath := strings.Split(request.URL.Path[len(h.path):], "/") if len(subpath) > 0 { @@ -134,7 +136,26 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } if seq == "" { - errors.LogInfo(context.Background(), "no seq on request:", request.URL.Path) + if h.config.Mode == "packet-up" { + errors.LogInfo(context.Background(), "stream-up mode is not allowed") + writer.WriteHeader(http.StatusBadRequest) + return + } + err = currentSession.uploadQueue.Push(Packet{ + Reader: request.Body, + }) + if err != nil { + errors.LogInfoInner(context.Background(), err, "failed to upload (PushReader)") + writer.WriteHeader(http.StatusConflict) + } else { + writer.WriteHeader(http.StatusOK) + <-request.Context().Done() + } + return + } + + if h.config.Mode == "stream-up" { + errors.LogInfo(context.Background(), "packet-up mode is not allowed") writer.WriteHeader(http.StatusBadRequest) return } @@ -148,14 +169,14 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } if err != nil { - errors.LogInfoInner(context.Background(), err, "failed to upload") + errors.LogInfoInner(context.Background(), err, "failed to upload (ReadAll)") writer.WriteHeader(http.StatusInternalServerError) return } seqInt, err := strconv.ParseUint(seq, 10, 64) if err != nil { - errors.LogInfoInner(context.Background(), err, "failed to upload") + errors.LogInfoInner(context.Background(), err, "failed to upload (ParseUint)") writer.WriteHeader(http.StatusInternalServerError) return } @@ -166,12 +187,11 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req }) if err != nil { - errors.LogInfoInner(context.Background(), err, "failed to upload") + errors.LogInfoInner(context.Background(), err, "failed to upload (PushPayload)") writer.WriteHeader(http.StatusInternalServerError) return } - h.config.WriteResponseHeader(writer) writer.WriteHeader(http.StatusOK) } else if request.Method == "GET" { responseFlusher, ok := writer.(http.Flusher) @@ -195,8 +215,6 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req writer.Header().Set("Content-Type", "text/event-stream") } - h.config.WriteResponseHeader(writer) - writer.WriteHeader(http.StatusOK) responseFlusher.Flush() @@ -223,6 +241,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req conn.Close() } else { + errors.LogInfo(context.Background(), "unsupported method: ", request.Method) writer.WriteHeader(http.StatusMethodNotAllowed) } } diff --git a/transport/internet/splithttp/upload_queue.go b/transport/internet/splithttp/upload_queue.go index 9ac38f8b..f8dd87b0 100644 --- a/transport/internet/splithttp/upload_queue.go +++ b/transport/internet/splithttp/upload_queue.go @@ -6,17 +6,20 @@ package splithttp import ( "container/heap" "io" + "runtime" "sync" "github.com/xtls/xray-core/common/errors" ) type Packet struct { + Reader io.ReadCloser Payload []byte Seq uint64 } type uploadQueue struct { + reader io.ReadCloser pushedPackets chan Packet writeCloseMutex sync.Mutex heap uploadHeap @@ -39,7 +42,16 @@ func (h *uploadQueue) Push(p Packet) error { h.writeCloseMutex.Lock() defer h.writeCloseMutex.Unlock() + runtime.Gosched() + if h.reader != nil && p.Reader != nil { + p.Reader.Close() + return errors.New("h.reader already exists") + } + if h.closed { + if p.Reader != nil { + p.Reader.Close() + } return errors.New("splithttp packet queue closed") } @@ -55,10 +67,18 @@ func (h *uploadQueue) Close() error { h.closed = true close(h.pushedPackets) } + runtime.Gosched() + if h.reader != nil { + return h.reader.Close() + } return nil } func (h *uploadQueue) Read(b []byte) (int, error) { + if h.reader != nil { + return h.reader.Read(b) + } + if h.closed { return 0, io.EOF } @@ -68,6 +88,10 @@ func (h *uploadQueue) Read(b []byte) (int, error) { if !more { return 0, io.EOF } + if packet.Reader != nil { + h.reader = packet.Reader + return h.reader.Read(b) + } heap.Push(&h.heap, packet) } From 83bab5dd907af9d0d281a97f36d240bfb0df8c2c Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Sat, 9 Nov 2024 14:16:11 +0300 Subject: [PATCH 600/867] Chore: Run gofmt (#3990) --- app/dispatcher/fakednssniffer.go | 2 +- app/proxyman/outbound/handler.go | 2 +- app/router/strategy_leastload_test.go | 110 ++++++++++++------------ app/router/strategy_random.go | 2 +- common/buf/buffer.go | 2 +- common/ctx/context.go | 2 +- common/protocol/user.go | 4 +- common/reflect/marshal.go | 12 +-- common/session/session.go | 2 +- common/singbridge/dialer.go | 4 +- core/xray_test.go | 4 +- features/routing/session/context.go | 2 +- infra/conf/dns_proxy.go | 2 +- infra/conf/dokodemo.go | 10 +-- infra/conf/observatory.go | 2 +- infra/conf/router.go | 6 +- infra/conf/router_strategy.go | 10 +-- infra/conf/xray.go | 2 +- main/commands/all/api/inbound_user.go | 2 +- main/commands/all/api/shared.go | 2 +- proxy/blackhole/blackhole.go | 4 +- proxy/dns/dns.go | 2 +- proxy/proxy.go | 2 +- proxy/shadowsocks/config.go | 12 +-- proxy/shadowsocks/protocol.go | 2 +- proxy/shadowsocks_2022/config.go | 4 +- proxy/shadowsocks_2022/inbound_multi.go | 2 +- proxy/socks/client.go | 2 +- proxy/trojan/server.go | 10 +-- proxy/trojan/validator.go | 1 - proxy/vless/account.go | 4 +- proxy/vmess/account.go | 4 +- proxy/wireguard/client.go | 2 +- testing/scenarios/command_test.go | 12 +-- testing/scenarios/dokodemo_test.go | 8 +- testing/scenarios/feature_test.go | 28 +++--- testing/scenarios/policy_test.go | 8 +- testing/scenarios/reverse_test.go | 16 ++-- testing/scenarios/socks_test.go | 24 +++--- testing/scenarios/tls_test.go | 54 ++++++------ testing/scenarios/transport_test.go | 8 +- testing/scenarios/vless_test.go | 42 ++++----- testing/scenarios/vmess_test.go | 68 +++++++-------- transport/internet/grpc/dial.go | 4 +- transport/internet/grpc/hub.go | 2 +- transport/internet/http/http_test.go | 4 +- transport/internet/http/hub.go | 14 +-- transport/internet/tls/config.go | 6 +- transport/pipe/impl.go | 10 +-- transport/pipe/writer.go | 2 +- 50 files changed, 272 insertions(+), 273 deletions(-) diff --git a/app/dispatcher/fakednssniffer.go b/app/dispatcher/fakednssniffer.go index f7486d1d..bed90877 100644 --- a/app/dispatcher/fakednssniffer.go +++ b/app/dispatcher/fakednssniffer.go @@ -28,7 +28,7 @@ func newFakeDNSSniffer(ctx context.Context) (protocolSnifferWithMetadata, error) } return protocolSnifferWithMetadata{protocolSniffer: func(ctx context.Context, bytes []byte) (SniffResult, error) { outbounds := session.OutboundsFromContext(ctx) - ob := outbounds[len(outbounds) - 1] + ob := outbounds[len(outbounds)-1] if ob.Target.Network == net.Network_TCP || ob.Target.Network == net.Network_UDP { domainFromFakeDNS := fakeDNSEngine.GetDomainFromFakeDNS(ob.Target.Address) if domainFromFakeDNS != "" { diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 404ac30e..df7d52a4 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -11,8 +11,8 @@ import ( "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/mux" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net/cnc" diff --git a/app/router/strategy_leastload_test.go b/app/router/strategy_leastload_test.go index be95140d..832e0a87 100644 --- a/app/router/strategy_leastload_test.go +++ b/app/router/strategy_leastload_test.go @@ -7,64 +7,64 @@ import ( /* Split into multiple package, need to be tested separately -func TestSelectLeastLoad(t *testing.T) { - settings := &StrategyLeastLoadConfig{ - HealthCheck: &HealthPingConfig{ - SamplingCount: 10, - }, - Expected: 1, - MaxRTT: int64(time.Millisecond * time.Duration(800)), + func TestSelectLeastLoad(t *testing.T) { + settings := &StrategyLeastLoadConfig{ + HealthCheck: &HealthPingConfig{ + SamplingCount: 10, + }, + Expected: 1, + MaxRTT: int64(time.Millisecond * time.Duration(800)), + } + strategy := NewLeastLoadStrategy(settings) + // std 40 + strategy.PutResult("a", time.Millisecond*time.Duration(60)) + strategy.PutResult("a", time.Millisecond*time.Duration(140)) + strategy.PutResult("a", time.Millisecond*time.Duration(60)) + strategy.PutResult("a", time.Millisecond*time.Duration(140)) + // std 60 + strategy.PutResult("b", time.Millisecond*time.Duration(40)) + strategy.PutResult("b", time.Millisecond*time.Duration(160)) + strategy.PutResult("b", time.Millisecond*time.Duration(40)) + strategy.PutResult("b", time.Millisecond*time.Duration(160)) + // std 0, but >MaxRTT + strategy.PutResult("c", time.Millisecond*time.Duration(1000)) + strategy.PutResult("c", time.Millisecond*time.Duration(1000)) + strategy.PutResult("c", time.Millisecond*time.Duration(1000)) + strategy.PutResult("c", time.Millisecond*time.Duration(1000)) + expected := "a" + actual := strategy.SelectAndPick([]string{"a", "b", "c", "untested"}) + if actual != expected { + t.Errorf("expected: %v, actual: %v", expected, actual) + } } - strategy := NewLeastLoadStrategy(settings) - // std 40 - strategy.PutResult("a", time.Millisecond*time.Duration(60)) - strategy.PutResult("a", time.Millisecond*time.Duration(140)) - strategy.PutResult("a", time.Millisecond*time.Duration(60)) - strategy.PutResult("a", time.Millisecond*time.Duration(140)) - // std 60 - strategy.PutResult("b", time.Millisecond*time.Duration(40)) - strategy.PutResult("b", time.Millisecond*time.Duration(160)) - strategy.PutResult("b", time.Millisecond*time.Duration(40)) - strategy.PutResult("b", time.Millisecond*time.Duration(160)) - // std 0, but >MaxRTT - strategy.PutResult("c", time.Millisecond*time.Duration(1000)) - strategy.PutResult("c", time.Millisecond*time.Duration(1000)) - strategy.PutResult("c", time.Millisecond*time.Duration(1000)) - strategy.PutResult("c", time.Millisecond*time.Duration(1000)) - expected := "a" - actual := strategy.SelectAndPick([]string{"a", "b", "c", "untested"}) - if actual != expected { - t.Errorf("expected: %v, actual: %v", expected, actual) - } -} -func TestSelectLeastLoadWithCost(t *testing.T) { - settings := &StrategyLeastLoadConfig{ - HealthCheck: &HealthPingConfig{ - SamplingCount: 10, - }, - Costs: []*StrategyWeight{ - {Match: "a", Value: 9}, - }, - Expected: 1, + func TestSelectLeastLoadWithCost(t *testing.T) { + settings := &StrategyLeastLoadConfig{ + HealthCheck: &HealthPingConfig{ + SamplingCount: 10, + }, + Costs: []*StrategyWeight{ + {Match: "a", Value: 9}, + }, + Expected: 1, + } + strategy := NewLeastLoadStrategy(settings, nil) + // std 40, std+c 120 + strategy.PutResult("a", time.Millisecond*time.Duration(60)) + strategy.PutResult("a", time.Millisecond*time.Duration(140)) + strategy.PutResult("a", time.Millisecond*time.Duration(60)) + strategy.PutResult("a", time.Millisecond*time.Duration(140)) + // std 60 + strategy.PutResult("b", time.Millisecond*time.Duration(40)) + strategy.PutResult("b", time.Millisecond*time.Duration(160)) + strategy.PutResult("b", time.Millisecond*time.Duration(40)) + strategy.PutResult("b", time.Millisecond*time.Duration(160)) + expected := "b" + actual := strategy.SelectAndPick([]string{"a", "b", "untested"}) + if actual != expected { + t.Errorf("expected: %v, actual: %v", expected, actual) + } } - strategy := NewLeastLoadStrategy(settings, nil) - // std 40, std+c 120 - strategy.PutResult("a", time.Millisecond*time.Duration(60)) - strategy.PutResult("a", time.Millisecond*time.Duration(140)) - strategy.PutResult("a", time.Millisecond*time.Duration(60)) - strategy.PutResult("a", time.Millisecond*time.Duration(140)) - // std 60 - strategy.PutResult("b", time.Millisecond*time.Duration(40)) - strategy.PutResult("b", time.Millisecond*time.Duration(160)) - strategy.PutResult("b", time.Millisecond*time.Duration(40)) - strategy.PutResult("b", time.Millisecond*time.Duration(160)) - expected := "b" - actual := strategy.SelectAndPick([]string{"a", "b", "untested"}) - if actual != expected { - t.Errorf("expected: %v, actual: %v", expected, actual) - } -} */ func TestSelectLeastExpected(t *testing.T) { strategy := &LeastLoadStrategy{ diff --git a/app/router/strategy_random.go b/app/router/strategy_random.go index 2609e347..ed82ff9d 100644 --- a/app/router/strategy_random.go +++ b/app/router/strategy_random.go @@ -11,7 +11,7 @@ import ( ) // RandomStrategy represents a random balancing strategy -type RandomStrategy struct{ +type RandomStrategy struct { FallbackTag string ctx context.Context diff --git a/common/buf/buffer.go b/common/buf/buffer.go index 15d4d4a5..63779586 100644 --- a/common/buf/buffer.go +++ b/common/buf/buffer.go @@ -218,7 +218,7 @@ func (b *Buffer) Cap() int32 { // NewWithSize creates a Buffer with 0 length and capacity with at least the given size. func NewWithSize(size int32) *Buffer { return &Buffer{ - v: bytespool.Alloc(size), + v: bytespool.Alloc(size), } } diff --git a/common/ctx/context.go b/common/ctx/context.go index 94a57902..25144f5f 100644 --- a/common/ctx/context.go +++ b/common/ctx/context.go @@ -7,7 +7,7 @@ type SessionKey int // ID of a session. type ID uint32 -const( +const ( idSessionKey SessionKey = 0 ) diff --git a/common/protocol/user.go b/common/protocol/user.go index 230c4b6d..75e8e654 100644 --- a/common/protocol/user.go +++ b/common/protocol/user.go @@ -41,8 +41,8 @@ func ToProtoUser(mu *MemoryUser) *User { } return &User{ Account: serial.ToTypedMessage(mu.Account.ToProto()), - Email: mu.Email, - Level: mu.Level, + Email: mu.Email, + Level: mu.Level, } } diff --git a/common/reflect/marshal.go b/common/reflect/marshal.go index 6d9798cc..42f47385 100644 --- a/common/reflect/marshal.go +++ b/common/reflect/marshal.go @@ -22,12 +22,12 @@ func MarshalToJson(v interface{}, insertTypeInfo bool) (string, bool) { } func JSONMarshalWithoutEscape(t interface{}) ([]byte, error) { - buffer := &bytes.Buffer{} - encoder := json.NewEncoder(buffer) - encoder.SetIndent("", " ") - encoder.SetEscapeHTML(false) - err := encoder.Encode(t) - return buffer.Bytes(), err + buffer := &bytes.Buffer{} + encoder := json.NewEncoder(buffer) + encoder.SetIndent("", " ") + encoder.SetEscapeHTML(false) + err := encoder.Encode(t) + return buffer.Bytes(), err } func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool, insertTypeInfo bool) interface{} { diff --git a/common/session/session.go b/common/session/session.go index 4573b216..cad15400 100644 --- a/common/session/session.go +++ b/common/session/session.go @@ -148,4 +148,4 @@ func (c *Content) AttributeLen() int { c.mu.Unlock() }() return len(c.Attributes) -} \ No newline at end of file +} diff --git a/common/singbridge/dialer.go b/common/singbridge/dialer.go index 6be83036..a6b32199 100644 --- a/common/singbridge/dialer.go +++ b/common/singbridge/dialer.go @@ -48,9 +48,9 @@ func (d *XrayOutboundDialer) DialContext(ctx context.Context, network string, de outbounds = []*session.Outbound{{}} ctx = session.ContextWithOutbounds(ctx, outbounds) } - ob := outbounds[len(outbounds) - 1] + ob := outbounds[len(outbounds)-1] ob.Target = ToDestination(destination, ToNetwork(network)) - + opts := []pipe.Option{pipe.WithSizeLimit(64 * 1024)} uplinkReader, uplinkWriter := pipe.New(opts...) downlinkReader, downlinkWriter := pipe.New(opts...) diff --git a/core/xray_test.go b/core/xray_test.go index eea0a408..43d021ef 100644 --- a/core/xray_test.go +++ b/core/xray_test.go @@ -54,8 +54,8 @@ func TestXrayClose(t *testing.T) { Listen: net.NewIPOrDomain(net.LocalHostIP), }), ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(net.LocalHostIP), - Port: uint32(0), + Address: net.NewIPOrDomain(net.LocalHostIP), + Port: uint32(0), Networks: []net.Network{net.Network_TCP}, }), }, diff --git a/features/routing/session/context.go b/features/routing/session/context.go index 3c9764b3..f87066a0 100644 --- a/features/routing/session/context.go +++ b/features/routing/session/context.go @@ -125,7 +125,7 @@ func (ctx *Context) GetSkipDNSResolve() bool { // AsRoutingContext creates a context from context.context with session info. func AsRoutingContext(ctx context.Context) routing.Context { outbounds := session.OutboundsFromContext(ctx) - ob := outbounds[len(outbounds) - 1] + ob := outbounds[len(outbounds)-1] return &Context{ Inbound: session.InboundFromContext(ctx), Outbound: ob, diff --git a/infra/conf/dns_proxy.go b/infra/conf/dns_proxy.go index cb135584..3425f22e 100644 --- a/infra/conf/dns_proxy.go +++ b/infra/conf/dns_proxy.go @@ -13,7 +13,7 @@ type DNSOutboundConfig struct { Port uint16 `json:"port"` UserLevel uint32 `json:"userLevel"` NonIPQuery string `json:"nonIPQuery"` - BlockTypes []int32 `json:"blockTypes"` + BlockTypes []int32 `json:"blockTypes"` } func (c *DNSOutboundConfig) Build() (proto.Message, error) { diff --git a/infra/conf/dokodemo.go b/infra/conf/dokodemo.go index e0f76733..2086cb5a 100644 --- a/infra/conf/dokodemo.go +++ b/infra/conf/dokodemo.go @@ -6,11 +6,11 @@ import ( ) type DokodemoConfig struct { - Host *Address `json:"address"` - PortValue uint16 `json:"port"` - NetworkList *NetworkList `json:"network"` - Redirect bool `json:"followRedirect"` - UserLevel uint32 `json:"userLevel"` + Host *Address `json:"address"` + PortValue uint16 `json:"port"` + NetworkList *NetworkList `json:"network"` + Redirect bool `json:"followRedirect"` + UserLevel uint32 `json:"userLevel"` } func (v *DokodemoConfig) Build() (proto.Message, error) { diff --git a/infra/conf/observatory.go b/infra/conf/observatory.go index 24c37a69..1ae403db 100644 --- a/infra/conf/observatory.go +++ b/infra/conf/observatory.go @@ -2,7 +2,7 @@ package conf import ( "google.golang.org/protobuf/proto" - + "github.com/xtls/xray-core/app/observatory" "github.com/xtls/xray-core/app/observatory/burst" "github.com/xtls/xray-core/infra/conf/cfgcommon/duration" diff --git a/infra/conf/router.go b/infra/conf/router.go index 69198d6a..2065f96b 100644 --- a/infra/conf/router.go +++ b/infra/conf/router.go @@ -71,9 +71,9 @@ func (r *BalancingRule) Build() (*router.BalancingRule, error) { } type RouterConfig struct { - RuleList []json.RawMessage `json:"rules"` - DomainStrategy *string `json:"domainStrategy"` - Balancers []*BalancingRule `json:"balancers"` + RuleList []json.RawMessage `json:"rules"` + DomainStrategy *string `json:"domainStrategy"` + Balancers []*BalancingRule `json:"balancers"` DomainMatcher string `json:"domainMatcher"` } diff --git a/infra/conf/router_strategy.go b/infra/conf/router_strategy.go index 4d0f647a..98bcc8d1 100644 --- a/infra/conf/router_strategy.go +++ b/infra/conf/router_strategy.go @@ -2,9 +2,9 @@ package conf import ( "google.golang.org/protobuf/proto" - - "github.com/xtls/xray-core/app/router" + "github.com/xtls/xray-core/app/observatory/burst" + "github.com/xtls/xray-core/app/router" "github.com/xtls/xray-core/infra/conf/cfgcommon/duration" ) @@ -46,10 +46,10 @@ type strategyLeastLoadConfig struct { // healthCheckSettings holds settings for health Checker type healthCheckSettings struct { - Destination string `json:"destination"` - Connectivity string `json:"connectivity"` + Destination string `json:"destination"` + Connectivity string `json:"connectivity"` Interval duration.Duration `json:"interval"` - SamplingCount int `json:"sampling"` + SamplingCount int `json:"sampling"` Timeout duration.Duration `json:"timeout"` } diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 0b5c60e6..ee9e6dfd 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -363,7 +363,7 @@ func (c *StatsConfig) Build() (*stats.Config, error) { type Config struct { // Deprecated: Global transport config is no longer used // left for returning error - Transport map[string]json.RawMessage `json:"transport"` + Transport map[string]json.RawMessage `json:"transport"` LogConfig *LogConfig `json:"log"` RouterConfig *RouterConfig `json:"routing"` diff --git a/main/commands/all/api/inbound_user.go b/main/commands/all/api/inbound_user.go index 6ffa4ebb..7a443183 100644 --- a/main/commands/all/api/inbound_user.go +++ b/main/commands/all/api/inbound_user.go @@ -39,7 +39,7 @@ func executeInboundUser(cmd *base.Command, args []string) { client := handlerService.NewHandlerServiceClient(conn) r := &handlerService.GetInboundUserRequest{ - Tag: tag, + Tag: tag, Email: email, } resp, err := client.GetInboundUsers(ctx, r) diff --git a/main/commands/all/api/shared.go b/main/commands/all/api/shared.go index 870ef5fc..f9d18265 100644 --- a/main/commands/all/api/shared.go +++ b/main/commands/all/api/shared.go @@ -15,8 +15,8 @@ import ( "google.golang.org/grpc/credentials/insecure" "github.com/xtls/xray-core/common/buf" - "github.com/xtls/xray-core/main/commands/base" creflect "github.com/xtls/xray-core/common/reflect" + "github.com/xtls/xray-core/main/commands/base" "google.golang.org/grpc" "google.golang.org/protobuf/proto" ) diff --git a/proxy/blackhole/blackhole.go b/proxy/blackhole/blackhole.go index ea3049ad..998666cb 100644 --- a/proxy/blackhole/blackhole.go +++ b/proxy/blackhole/blackhole.go @@ -30,9 +30,9 @@ func New(ctx context.Context, config *Config) (*Handler, error) { // Process implements OutboundHandler.Dispatch(). func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer internet.Dialer) error { outbounds := session.OutboundsFromContext(ctx) - ob := outbounds[len(outbounds) - 1] + ob := outbounds[len(outbounds)-1] ob.Name = "blackhole" - + nBytes := h.response.WriteTo(link.Writer) if nBytes > 0 { // Sleep a little here to make sure the response is sent to client. diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index eeaa4c4c..ed063197 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -49,7 +49,7 @@ type Handler struct { server net.Destination timeout time.Duration nonIPQuery string - blockTypes []int32 + blockTypes []int32 } func (h *Handler) Init(config *Config, dnsClient dns.Client, policyManager policy.Manager) error { diff --git a/proxy/proxy.go b/proxy/proxy.go index 868c8dfc..1e4c69f5 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -78,7 +78,7 @@ type UserManager interface { // RemoveUser removes a user by email. RemoveUser(context.Context, string) error - + // Get user by email. GetUser(context.Context, string) *protocol.MemoryUser diff --git a/proxy/shadowsocks/config.go b/proxy/shadowsocks/config.go index e2d812ab..a6d2ef87 100644 --- a/proxy/shadowsocks/config.go +++ b/proxy/shadowsocks/config.go @@ -22,7 +22,7 @@ import ( // MemoryAccount is an account type converted from Account. type MemoryAccount struct { Cipher Cipher - CipherType CipherType + CipherType CipherType Key []byte Password string @@ -42,8 +42,8 @@ func (a *MemoryAccount) Equals(another protocol.Account) bool { func (a *MemoryAccount) ToProto() proto.Message { return &Account{ CipherType: a.CipherType, - Password: a.Password, - IvCheck: a.replayFilter != nil, + Password: a.Password, + IvCheck: a.replayFilter != nil, } } @@ -117,10 +117,10 @@ func (a *Account) AsAccount() (protocol.Account, error) { return nil, errors.New("failed to get cipher").Base(err) } return &MemoryAccount{ - Cipher: Cipher, + Cipher: Cipher, CipherType: a.CipherType, - Key: passwordToCipherKey([]byte(a.Password), Cipher.KeySize()), - Password: a.Password, + Key: passwordToCipherKey([]byte(a.Password), Cipher.KeySize()), + Password: a.Password, replayFilter: func() antireplay.GeneralizedReplayFilter { if a.IvCheck { return antireplay.NewBloomRing() diff --git a/proxy/shadowsocks/protocol.go b/proxy/shadowsocks/protocol.go index 00855c73..c992f619 100644 --- a/proxy/shadowsocks/protocol.go +++ b/proxy/shadowsocks/protocol.go @@ -10,9 +10,9 @@ import ( "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" - "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/crypto" "github.com/xtls/xray-core/common/drain" + "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" ) diff --git a/proxy/shadowsocks_2022/config.go b/proxy/shadowsocks_2022/config.go index 3678cd58..9ddd2cf8 100644 --- a/proxy/shadowsocks_2022/config.go +++ b/proxy/shadowsocks_2022/config.go @@ -8,13 +8,13 @@ import ( // MemoryAccount is an account type converted from Account. type MemoryAccount struct { - Key string + Key string } // AsAccount implements protocol.AsAccount. func (u *Account) AsAccount() (protocol.Account, error) { return &MemoryAccount{ - Key: u.GetKey(), + Key: u.GetKey(), }, nil } diff --git a/proxy/shadowsocks_2022/inbound_multi.go b/proxy/shadowsocks_2022/inbound_multi.go index 20b85139..4bfa086a 100644 --- a/proxy/shadowsocks_2022/inbound_multi.go +++ b/proxy/shadowsocks_2022/inbound_multi.go @@ -155,7 +155,7 @@ func (i *MultiUserInbound) GetUser(ctx context.Context, email string) *protocol. if email == "" { return nil } - + i.Lock() defer i.Unlock() diff --git a/proxy/socks/client.go b/proxy/socks/client.go index e5af3161..2ed5740a 100644 --- a/proxy/socks/client.go +++ b/proxy/socks/client.go @@ -45,7 +45,7 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Client, error) { serverPicker: protocol.NewRoundRobinServerPicker(serverList), policyManager: v.GetFeature(policy.ManagerType()).(policy.Manager), } - + return c, nil } diff --git a/proxy/trojan/server.go b/proxy/trojan/server.go index 20ac1fd1..44662ac3 100644 --- a/proxy/trojan/server.go +++ b/proxy/trojan/server.go @@ -361,14 +361,14 @@ func (s *Server) fallback(ctx context.Context, err error, sessionPolicy policy.S cs := tlsConn.ConnectionState() name = cs.ServerName alpn = cs.NegotiatedProtocol - errors.LogInfo(ctx, "realName = " + name) - errors.LogInfo(ctx, "realAlpn = " + alpn) + errors.LogInfo(ctx, "realName = "+name) + errors.LogInfo(ctx, "realAlpn = "+alpn) } else if realityConn, ok := iConn.(*reality.Conn); ok { cs := realityConn.ConnectionState() name = cs.ServerName alpn = cs.NegotiatedProtocol - errors.LogInfo(ctx, "realName = " + name) - errors.LogInfo(ctx, "realAlpn = " + alpn) + errors.LogInfo(ctx, "realName = "+name) + errors.LogInfo(ctx, "realAlpn = "+alpn) } name = strings.ToLower(name) alpn = strings.ToLower(alpn) @@ -418,7 +418,7 @@ func (s *Server) fallback(ctx context.Context, err error, sessionPolicy policy.S } if k == '?' || k == ' ' { path = string(firstBytes[i:j]) - errors.LogInfo(ctx, "realPath = " + path) + errors.LogInfo(ctx, "realPath = "+path) if pfb[path] == nil { path = "" } diff --git a/proxy/trojan/validator.go b/proxy/trojan/validator.go index fb3499fa..bfe53812 100644 --- a/proxy/trojan/validator.go +++ b/proxy/trojan/validator.go @@ -51,7 +51,6 @@ func (v *Validator) Get(hash string) *protocol.MemoryUser { return nil } - // Get a trojan user with hashed key, nil if user doesn't exist. func (v *Validator) GetByEmail(email string) *protocol.MemoryUser { u, _ := v.email.Load(email) diff --git a/proxy/vless/account.go b/proxy/vless/account.go index 798b93f4..c22cfe16 100644 --- a/proxy/vless/account.go +++ b/proxy/vless/account.go @@ -42,8 +42,8 @@ func (a *MemoryAccount) Equals(account protocol.Account) bool { func (a *MemoryAccount) ToProto() proto.Message { return &Account{ - Id: a.ID.String(), - Flow: a.Flow, + Id: a.ID.String(), + Flow: a.Flow, Encryption: a.Encryption, } } diff --git a/proxy/vmess/account.go b/proxy/vmess/account.go index d063f9f5..df8ba52b 100644 --- a/proxy/vmess/account.go +++ b/proxy/vmess/account.go @@ -38,8 +38,8 @@ func (a *MemoryAccount) ToProto() proto.Message { test = test + "NoTerminationSignal" } return &Account{ - Id: a.ID.String(), - TestsEnabled: test, + Id: a.ID.String(), + TestsEnabled: test, SecuritySettings: &protocol.SecurityConfig{Type: a.Security}, } } diff --git a/proxy/wireguard/client.go b/proxy/wireguard/client.go index 1bb594b7..c26cbf4d 100644 --- a/proxy/wireguard/client.go +++ b/proxy/wireguard/client.go @@ -29,8 +29,8 @@ import ( "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" - "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/dice" + "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/log" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol" diff --git a/testing/scenarios/command_test.go b/testing/scenarios/command_test.go index b20d6f10..037255a9 100644 --- a/testing/scenarios/command_test.go +++ b/testing/scenarios/command_test.go @@ -303,8 +303,8 @@ func TestCommanderAddRemoveUser(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}, }), }, @@ -458,8 +458,8 @@ func TestCommanderStats(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}, }), }, @@ -480,8 +480,8 @@ func TestCommanderStats(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/dokodemo_test.go b/testing/scenarios/dokodemo_test.go index d6b69823..f74fb4bd 100644 --- a/testing/scenarios/dokodemo_test.go +++ b/testing/scenarios/dokodemo_test.go @@ -85,8 +85,8 @@ func TestDokodemoTCP(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}, }), }, @@ -181,8 +181,8 @@ func TestDokodemoUDP(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}, }), }, diff --git a/testing/scenarios/feature_test.go b/testing/scenarios/feature_test.go index 5dd08ec4..6fe0d850 100644 --- a/testing/scenarios/feature_test.go +++ b/testing/scenarios/feature_test.go @@ -53,8 +53,8 @@ func TestPassiveConnection(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}, }), }, @@ -161,8 +161,8 @@ func TestProxy(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}, }), }, @@ -299,8 +299,8 @@ func TestProxyOverKCP(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}, }), }, @@ -386,8 +386,8 @@ func TestBlackhole(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}, }), }, @@ -397,8 +397,8 @@ func TestBlackhole(t *testing.T) { Listen: net.NewIPOrDomain(net.LocalHostIP), }), ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(dest2.Address), - Port: uint32(dest2.Port), + Address: net.NewIPOrDomain(dest2.Address), + Port: uint32(dest2.Port), Networks: []net.Network{net.Network_TCP}, }), }, @@ -512,8 +512,8 @@ func TestUDPConnection(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}, }), }, @@ -556,8 +556,8 @@ func TestDomainSniffing(t *testing.T) { }, }), ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(net.LocalHostIP), - Port: 443, + Address: net.NewIPOrDomain(net.LocalHostIP), + Port: 443, Networks: []net.Network{net.Network_TCP}, }), }, diff --git a/testing/scenarios/policy_test.go b/testing/scenarios/policy_test.go index 773e6bcf..1e8aafea 100644 --- a/testing/scenarios/policy_test.go +++ b/testing/scenarios/policy_test.go @@ -110,8 +110,8 @@ func TestVMessClosing(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}, }), }, @@ -214,8 +214,8 @@ func TestZeroBuffer(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/reverse_test.go b/testing/scenarios/reverse_test.go index 197f6d1f..faaa402e 100644 --- a/testing/scenarios/reverse_test.go +++ b/testing/scenarios/reverse_test.go @@ -76,8 +76,8 @@ func TestReverseProxy(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}, }), }, @@ -141,8 +141,8 @@ func TestReverseProxy(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}, }), }, @@ -255,8 +255,8 @@ func TestReverseProxyLongRunning(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}, }), }, @@ -334,8 +334,8 @@ func TestReverseProxyLongRunning(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/socks_test.go b/testing/scenarios/socks_test.go index 13e6f869..83ebebc3 100644 --- a/testing/scenarios/socks_test.go +++ b/testing/scenarios/socks_test.go @@ -64,8 +64,8 @@ func TestSocksBridgeTCP(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}, }), }, @@ -143,8 +143,8 @@ func TestSocksWithHttpRequest(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}, }), }, @@ -213,8 +213,8 @@ func TestSocksBridageUDP(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}, }), }, @@ -247,8 +247,8 @@ func TestSocksBridageUDP(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}, }), }, @@ -328,8 +328,8 @@ func TestSocksBridageUDPWithRouting(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}, }), }, @@ -366,8 +366,8 @@ func TestSocksBridageUDPWithRouting(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}, }), }, diff --git a/testing/scenarios/tls_test.go b/testing/scenarios/tls_test.go index f1955877..ffe43300 100644 --- a/testing/scenarios/tls_test.go +++ b/testing/scenarios/tls_test.go @@ -81,8 +81,8 @@ func TestSimpleTLSConnection(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}, }), }, @@ -196,8 +196,8 @@ func TestAutoIssuingCertificate(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}, }), }, @@ -301,8 +301,8 @@ func TestTLSOverKCP(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}, }), }, @@ -401,8 +401,8 @@ func TestTLSOverWebSocket(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}, }), }, @@ -426,7 +426,7 @@ func TestTLSOverWebSocket(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - ProtocolName: "websocket", + ProtocolName: "websocket", TransportSettings: []*internet.TransportConfig{ { ProtocolName: "websocket", @@ -475,11 +475,11 @@ func TestHTTP2(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - ProtocolName: "http", + ProtocolName: "http", TransportSettings: []*internet.TransportConfig{ { ProtocolName: "http", - Settings: serial.ToTypedMessage(&http.Config{ + Settings: serial.ToTypedMessage(&http.Config{ Host: []string{"example.com"}, Path: "/testpath", }), @@ -520,8 +520,8 @@ func TestHTTP2(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}, }), }, @@ -545,11 +545,11 @@ func TestHTTP2(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - ProtocolName: "http", + ProtocolName: "http", TransportSettings: []*internet.TransportConfig{ { ProtocolName: "http", - Settings: serial.ToTypedMessage(&http.Config{ + Settings: serial.ToTypedMessage(&http.Config{ Host: []string{"example.com"}, Path: "/testpath", }), @@ -639,8 +639,8 @@ func TestGRPC(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}, }), }, @@ -755,8 +755,8 @@ func TestGRPCMultiMode(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}, }), }, @@ -866,8 +866,8 @@ func TestSimpleTLSConnectionPinned(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}, }), }, @@ -968,8 +968,8 @@ func TestSimpleTLSConnectionPinnedWrongCert(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}, }), }, @@ -1069,8 +1069,8 @@ func TestUTLSConnectionPinned(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}, }), }, @@ -1172,8 +1172,8 @@ func TestUTLSConnectionPinnedWrongCert(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/transport_test.go b/testing/scenarios/transport_test.go index e6ece892..bb16deee 100644 --- a/testing/scenarios/transport_test.go +++ b/testing/scenarios/transport_test.go @@ -42,7 +42,7 @@ func TestHTTPConnectionHeader(t *testing.T) { TransportSettings: []*internet.TransportConfig{ { ProtocolName: "tcp", - Settings: serial.ToTypedMessage(&tcptransport.Config{ + Settings: serial.ToTypedMessage(&tcptransport.Config{ HeaderSettings: serial.ToTypedMessage(&http.Config{}), }), }, @@ -76,8 +76,8 @@ func TestHTTPConnectionHeader(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}, }), }, @@ -104,7 +104,7 @@ func TestHTTPConnectionHeader(t *testing.T) { TransportSettings: []*internet.TransportConfig{ { ProtocolName: "tcp", - Settings: serial.ToTypedMessage(&tcptransport.Config{ + Settings: serial.ToTypedMessage(&tcptransport.Config{ HeaderSettings: serial.ToTypedMessage(&http.Config{}), }), }, diff --git a/testing/scenarios/vless_test.go b/testing/scenarios/vless_test.go index 87952794..dcac17ea 100644 --- a/testing/scenarios/vless_test.go +++ b/testing/scenarios/vless_test.go @@ -85,8 +85,8 @@ func TestVless(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}, }), }, @@ -190,8 +190,8 @@ func TestVlessTls(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}, }), }, @@ -215,7 +215,7 @@ func TestVlessTls(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - ProtocolName: "tcp", + ProtocolName: "tcp", TransportSettings: []*internet.TransportConfig{ { ProtocolName: "tcp", @@ -313,8 +313,8 @@ func TestVlessXtlsVision(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}, }), }, @@ -339,7 +339,7 @@ func TestVlessXtlsVision(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - ProtocolName: "tcp", + ProtocolName: "tcp", TransportSettings: []*internet.TransportConfig{ { ProtocolName: "tcp", @@ -403,12 +403,12 @@ func TestVlessXtlsVisionReality(t *testing.T) { SecurityType: serial.GetMessageType(&reality.Config{}), SecuritySettings: []*serial.TypedMessage{ serial.ToTypedMessage(&reality.Config{ - Show: true, - Dest: "www.google.com:443", // use google for now, may fail in some region + Show: true, + Dest: "www.google.com:443", // use google for now, may fail in some region ServerNames: []string{"www.google.com"}, - PrivateKey: privateKey, - ShortIds: shortIds, - Type: "tcp", + PrivateKey: privateKey, + ShortIds: shortIds, + Type: "tcp", }), }, }, @@ -447,8 +447,8 @@ func TestVlessXtlsVisionReality(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}, }), }, @@ -473,7 +473,7 @@ func TestVlessXtlsVisionReality(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - ProtocolName: "tcp", + ProtocolName: "tcp", TransportSettings: []*internet.TransportConfig{ { ProtocolName: "tcp", @@ -483,12 +483,12 @@ func TestVlessXtlsVisionReality(t *testing.T) { SecurityType: serial.GetMessageType(&reality.Config{}), SecuritySettings: []*serial.TypedMessage{ serial.ToTypedMessage(&reality.Config{ - Show: true, + Show: true, Fingerprint: "chrome", - ServerName: "www.google.com", - PublicKey: publicKey, - ShortId: shortIds[0], - SpiderX: "/", + ServerName: "www.google.com", + PublicKey: publicKey, + ShortId: shortIds[0], + SpiderX: "/", }), }, }, diff --git a/testing/scenarios/vmess_test.go b/testing/scenarios/vmess_test.go index 092d25a3..dbffe0d6 100644 --- a/testing/scenarios/vmess_test.go +++ b/testing/scenarios/vmess_test.go @@ -71,8 +71,8 @@ func TestVMessDynamicPort(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}, }), }, @@ -131,8 +131,8 @@ func TestVMessDynamicPort(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}, }), }, @@ -223,8 +223,8 @@ func TestVMessGCM(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}, }), }, @@ -325,8 +325,8 @@ func TestVMessGCMReadv(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}, }), }, @@ -430,8 +430,8 @@ func TestVMessGCMUDP(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}, }), }, @@ -529,8 +529,8 @@ func TestVMessChacha20(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}, }), }, @@ -629,8 +629,8 @@ func TestVMessNone(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}, }), }, @@ -731,8 +731,8 @@ func TestVMessKCP(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}, }), }, @@ -802,11 +802,11 @@ func TestVMessKCPLarge(t *testing.T) { PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, Listen: net.NewIPOrDomain(net.LocalHostIP), StreamSettings: &internet.StreamConfig{ - ProtocolName: "mkcp", + ProtocolName: "mkcp", TransportSettings: []*internet.TransportConfig{ { ProtocolName: "mkcp", - Settings: serial.ToTypedMessage(&kcp.Config{ + Settings: serial.ToTypedMessage(&kcp.Config{ ReadBuffer: &kcp.ReadBuffer{ Size: 512 * 1024, }, @@ -857,8 +857,8 @@ func TestVMessKCPLarge(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}, }), }, @@ -885,11 +885,11 @@ func TestVMessKCPLarge(t *testing.T) { }), SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ StreamSettings: &internet.StreamConfig{ - ProtocolName: "mkcp", + ProtocolName: "mkcp", TransportSettings: []*internet.TransportConfig{ { ProtocolName: "mkcp", - Settings: serial.ToTypedMessage(&kcp.Config{ + Settings: serial.ToTypedMessage(&kcp.Config{ ReadBuffer: &kcp.ReadBuffer{ Size: 512 * 1024, }, @@ -984,8 +984,8 @@ func TestVMessGCMMux(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}, }), }, @@ -1100,8 +1100,8 @@ func TestVMessGCMMuxUDP(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}, }), }, @@ -1111,8 +1111,8 @@ func TestVMessGCMMuxUDP(t *testing.T) { Listen: net.NewIPOrDomain(net.LocalHostIP), }), ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(udpDest.Address), - Port: uint32(udpDest.Port), + Address: net.NewIPOrDomain(udpDest.Address), + Port: uint32(udpDest.Port), Networks: []net.Network{net.Network_UDP}, }), }, @@ -1224,8 +1224,8 @@ func TestVMessZero(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}, }), }, @@ -1323,8 +1323,8 @@ func TestVMessGCMLengthAuth(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}, }), }, @@ -1427,8 +1427,8 @@ func TestVMessGCMLengthAuthPlusNoTerminationSignal(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/transport/internet/grpc/dial.go b/transport/internet/grpc/dial.go index 24ae8ad0..b8740dae 100644 --- a/transport/internet/grpc/dial.go +++ b/transport/internet/grpc/dial.go @@ -56,7 +56,7 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne } client := encoding.NewGRPCServiceClient(conn) if grpcSettings.MultiMode { - errors.LogDebug(ctx, "using gRPC multi mode service name: `" + grpcSettings.getServiceName() + "` stream name: `" + grpcSettings.getTunMultiStreamName() + "`") + errors.LogDebug(ctx, "using gRPC multi mode service name: `"+grpcSettings.getServiceName()+"` stream name: `"+grpcSettings.getTunMultiStreamName()+"`") grpcService, err := client.(encoding.GRPCServiceClientX).TunMultiCustomName(ctx, grpcSettings.getServiceName(), grpcSettings.getTunMultiStreamName()) if err != nil { return nil, errors.New("Cannot dial gRPC").Base(err) @@ -64,7 +64,7 @@ func dialgRPC(ctx context.Context, dest net.Destination, streamSettings *interne return encoding.NewMultiHunkConn(grpcService, nil), nil } - errors.LogDebug(ctx, "using gRPC tun mode service name: `" + grpcSettings.getServiceName() + "` stream name: `" + grpcSettings.getTunStreamName() + "`") + errors.LogDebug(ctx, "using gRPC tun mode service name: `"+grpcSettings.getServiceName()+"` stream name: `"+grpcSettings.getTunStreamName()+"`") grpcService, err := client.(encoding.GRPCServiceClientX).TunCustomName(ctx, grpcSettings.getServiceName(), grpcSettings.getTunStreamName()) if err != nil { return nil, errors.New("Cannot dial gRPC").Base(err) diff --git a/transport/internet/grpc/hub.go b/transport/internet/grpc/hub.go index b07c3b75..ae8788fa 100644 --- a/transport/internet/grpc/hub.go +++ b/transport/internet/grpc/hub.go @@ -120,7 +120,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, settings *i } } - errors.LogDebug(ctx, "gRPC listen for service name `" + grpcSettings.getServiceName() + "` tun `" + grpcSettings.getTunStreamName() + "` multi tun `" + grpcSettings.getTunMultiStreamName() + "`") + errors.LogDebug(ctx, "gRPC listen for service name `"+grpcSettings.getServiceName()+"` tun `"+grpcSettings.getTunStreamName()+"` multi tun `"+grpcSettings.getTunMultiStreamName()+"`") encoding.RegisterGRPCServiceServerX(s, listener, grpcSettings.getServiceName(), grpcSettings.getTunStreamName(), grpcSettings.getTunMultiStreamName()) if config := reality.ConfigFromStreamSettings(settings); config != nil { diff --git a/transport/internet/http/http_test.go b/transport/internet/http/http_test.go index dd6c852d..1b3afa80 100644 --- a/transport/internet/http/http_test.go +++ b/transport/internet/http/http_test.go @@ -103,7 +103,7 @@ func TestH3Connection(t *testing.T) { SecurityType: "tls", SecuritySettings: &tls.Config{ NextProtocol: []string{"h3"}, - Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("www.example.com")))}, + Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("www.example.com")))}, }, }, func(conn stat.Connection) { go func() { @@ -133,7 +133,7 @@ func TestH3Connection(t *testing.T) { ProtocolSettings: &Config{}, SecurityType: "tls", SecuritySettings: &tls.Config{ - NextProtocol: []string{"h3"}, + NextProtocol: []string{"h3"}, ServerName: "www.example.com", AllowInsecure: true, }, diff --git a/transport/internet/http/hub.go b/transport/internet/http/hub.go index 96fe8f62..1fac2b73 100644 --- a/transport/internet/http/hub.go +++ b/transport/internet/http/hub.go @@ -141,8 +141,8 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti isH3 := len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "h3" listener := &Listener{ handler: handler, - config: httpSettings, - isH3: isH3, + config: httpSettings, + isH3: isH3, } if port == net.Port(0) { // unix listener.local = &net.UnixAddr{ @@ -168,7 +168,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti if isH3 { Conn, err := internet.ListenSystemPacket(context.Background(), listener.local, streamSettings.SocketSettings) if err != nil { - return nil, errors.New("failed to listen UDP(for SH3) on ", address, ":", port).Base(err) + return nil, errors.New("failed to listen UDP(for SH3) on ", address, ":", port).Base(err) } h3listener, err := quic.ListenEarly(Conn, tlsConfig, nil) if err != nil { @@ -188,7 +188,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti var server *http.Server if config == nil { h2s := &http2.Server{} - + server = &http.Server{ Addr: serial.Concat(address, ":", port), Handler: h2c.NewHandler(listener, h2s), @@ -202,7 +202,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti ReadHeaderTimeout: time.Second * 4, } } - + listener.server = server go func() { var streamListener net.Listener @@ -226,7 +226,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti return } } - + if config == nil { if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { streamListener = goreality.NewListener(streamListener, config.GetREALITYConfig()) @@ -241,7 +241,7 @@ func Listen(ctx context.Context, address net.Address, port net.Port, streamSetti errors.LogInfoInner(ctx, err, "stopping serving TLS H2") } } - }() + }() } return listener, nil diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index b6c55c00..75648c4b 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -1,6 +1,7 @@ package tls import ( + "bytes" "context" "crypto/hmac" "crypto/tls" @@ -10,7 +11,6 @@ import ( "strings" "sync" "time" - "bytes" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" @@ -70,7 +70,7 @@ func (c *Config) BuildCertificates() []*tls.Certificate { continue } index := len(certs) - 1 - setupOcspTicker(entry, func(isReloaded, isOcspstapling bool){ + setupOcspTicker(entry, func(isReloaded, isOcspstapling bool) { cert := certs[index] if isReloaded { if newKeyPair := getX509KeyPair(); newKeyPair != nil { @@ -162,7 +162,7 @@ func (c *Config) getCustomCA() []*Certificate { for _, certificate := range c.Certificate { if certificate.Usage == Certificate_AUTHORITY_ISSUE { certs = append(certs, certificate) - setupOcspTicker(certificate, func(isReloaded, isOcspstapling bool){ }) + setupOcspTicker(certificate, func(isReloaded, isOcspstapling bool) {}) } } return certs diff --git a/transport/pipe/impl.go b/transport/pipe/impl.go index 8bf58a34..4a30dbbb 100644 --- a/transport/pipe/impl.go +++ b/transport/pipe/impl.go @@ -47,11 +47,11 @@ var ( ) func (p *pipe) Len() int32 { - data := p.data - if data == nil { - return 0 - } - return data.Len() + data := p.data + if data == nil { + return 0 + } + return data.Len() } func (p *pipe) getState(forRead bool) error { diff --git a/transport/pipe/writer.go b/transport/pipe/writer.go index 0a192ca0..4ba26ccc 100644 --- a/transport/pipe/writer.go +++ b/transport/pipe/writer.go @@ -20,7 +20,7 @@ func (w *Writer) Close() error { } func (w *Writer) Len() int32 { - return w.pipe.Len() + return w.pipe.Len() } // Interrupt implements common.Interruptible. From bd0841a75b40e77220a408f4988c988252836ef9 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 11 Nov 2024 02:50:39 +0000 Subject: [PATCH 601/867] XHTTP config: Add "extra" for sharing extra fields (#4000) --- infra/conf/transport_internet.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index f5a36328..d58763d1 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -234,6 +234,7 @@ type SplitHTTPConfig struct { Xmux Xmux `json:"xmux"` DownloadSettings *StreamConfig `json:"downloadSettings"` Mode string `json:"mode"` + Extra json.RawMessage `json:"extra"` } type Xmux struct { @@ -259,6 +260,18 @@ func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { // Build implements Buildable. func (c *SplitHTTPConfig) Build() (proto.Message, error) { + if c.Extra != nil { + var extra SplitHTTPConfig + if err := json.Unmarshal(c.Extra, &extra); err != nil { + return nil, errors.New(`Failed to unmarshal "extra".`).Base(err) + } + extra.Host = c.Host + extra.Path = c.Path + extra.Mode = c.Mode + extra.Extra = c.Extra + c = &extra + } + // If http host is not set in the Host field, but in headers field, we add it to Host Field here. // If we don't do that, http host will be overwritten as address. // Host priority: Host field > headers field > address. @@ -312,6 +325,9 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { } var err error if c.DownloadSettings != nil { + if c.Extra != nil { + c.DownloadSettings.SocketSettings = nil + } if config.DownloadSettings, err = c.DownloadSettings.Build(); err != nil { return nil, errors.New(`Failed to build "downloadSettings".`).Base(err) } From 480748403a9fa766a7003dd29fcbb281f133805c Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 11 Nov 2024 03:27:30 +0000 Subject: [PATCH 602/867] Chore: Fix versions in some *.pb.go files https://github.com/XTLS/Xray-core/commit/47fad1fbfdcd7195b76accb1059c6e1abfafcc48 --- app/policy/config.pb.go | 102 +---------- app/stats/command/command.pb.go | 243 ++++++++++++++------------- app/stats/command/command_grpc.pb.go | 6 +- 3 files changed, 127 insertions(+), 224 deletions(-) diff --git a/app/policy/config.pb.go b/app/policy/config.pb.go index 46e6f3d4..bfa83a3b 100644 --- a/app/policy/config.pb.go +++ b/app/policy/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 -// protoc v4.25.3 +// protoc-gen-go v1.35.1 +// protoc v5.28.2 // source: app/policy/config.proto package policy @@ -599,104 +599,6 @@ func file_app_policy_config_proto_init() { if File_app_policy_config_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_app_policy_config_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*Second); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*Policy); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*SystemPolicy); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*Config); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*Policy_Timeout); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*Policy_Stats); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[6].Exporter = func(v any, i int) any { - switch v := v.(*Policy_Buffer); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_app_policy_config_proto_msgTypes[7].Exporter = func(v any, i int) any { - switch v := v.(*SystemPolicy_Stats); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ diff --git a/app/stats/command/command.pb.go b/app/stats/command/command.pb.go index 3ea15017..c9566834 100644 --- a/app/stats/command/command.pb.go +++ b/app/stats/command/command.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 -// protoc v5.28.3 -// source: command.proto +// protoc v5.28.2 +// source: app/stats/command/command.proto package command @@ -33,7 +33,7 @@ type GetStatsRequest struct { func (x *GetStatsRequest) Reset() { *x = GetStatsRequest{} - mi := &file_command_proto_msgTypes[0] + mi := &file_app_stats_command_command_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -45,7 +45,7 @@ func (x *GetStatsRequest) String() string { func (*GetStatsRequest) ProtoMessage() {} func (x *GetStatsRequest) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[0] + mi := &file_app_stats_command_command_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -58,7 +58,7 @@ func (x *GetStatsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetStatsRequest.ProtoReflect.Descriptor instead. func (*GetStatsRequest) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{0} + return file_app_stats_command_command_proto_rawDescGZIP(), []int{0} } func (x *GetStatsRequest) GetName() string { @@ -86,7 +86,7 @@ type Stat struct { func (x *Stat) Reset() { *x = Stat{} - mi := &file_command_proto_msgTypes[1] + mi := &file_app_stats_command_command_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -98,7 +98,7 @@ func (x *Stat) String() string { func (*Stat) ProtoMessage() {} func (x *Stat) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[1] + mi := &file_app_stats_command_command_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -111,7 +111,7 @@ func (x *Stat) ProtoReflect() protoreflect.Message { // Deprecated: Use Stat.ProtoReflect.Descriptor instead. func (*Stat) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{1} + return file_app_stats_command_command_proto_rawDescGZIP(), []int{1} } func (x *Stat) GetName() string { @@ -138,7 +138,7 @@ type GetStatsResponse struct { func (x *GetStatsResponse) Reset() { *x = GetStatsResponse{} - mi := &file_command_proto_msgTypes[2] + mi := &file_app_stats_command_command_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -150,7 +150,7 @@ func (x *GetStatsResponse) String() string { func (*GetStatsResponse) ProtoMessage() {} func (x *GetStatsResponse) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[2] + mi := &file_app_stats_command_command_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -163,7 +163,7 @@ func (x *GetStatsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetStatsResponse.ProtoReflect.Descriptor instead. func (*GetStatsResponse) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{2} + return file_app_stats_command_command_proto_rawDescGZIP(), []int{2} } func (x *GetStatsResponse) GetStat() *Stat { @@ -184,7 +184,7 @@ type QueryStatsRequest struct { func (x *QueryStatsRequest) Reset() { *x = QueryStatsRequest{} - mi := &file_command_proto_msgTypes[3] + mi := &file_app_stats_command_command_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -196,7 +196,7 @@ func (x *QueryStatsRequest) String() string { func (*QueryStatsRequest) ProtoMessage() {} func (x *QueryStatsRequest) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[3] + mi := &file_app_stats_command_command_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -209,7 +209,7 @@ func (x *QueryStatsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use QueryStatsRequest.ProtoReflect.Descriptor instead. func (*QueryStatsRequest) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{3} + return file_app_stats_command_command_proto_rawDescGZIP(), []int{3} } func (x *QueryStatsRequest) GetPattern() string { @@ -236,7 +236,7 @@ type QueryStatsResponse struct { func (x *QueryStatsResponse) Reset() { *x = QueryStatsResponse{} - mi := &file_command_proto_msgTypes[4] + mi := &file_app_stats_command_command_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -248,7 +248,7 @@ func (x *QueryStatsResponse) String() string { func (*QueryStatsResponse) ProtoMessage() {} func (x *QueryStatsResponse) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[4] + mi := &file_app_stats_command_command_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -261,7 +261,7 @@ func (x *QueryStatsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use QueryStatsResponse.ProtoReflect.Descriptor instead. func (*QueryStatsResponse) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{4} + return file_app_stats_command_command_proto_rawDescGZIP(), []int{4} } func (x *QueryStatsResponse) GetStat() []*Stat { @@ -279,7 +279,7 @@ type SysStatsRequest struct { func (x *SysStatsRequest) Reset() { *x = SysStatsRequest{} - mi := &file_command_proto_msgTypes[5] + mi := &file_app_stats_command_command_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -291,7 +291,7 @@ func (x *SysStatsRequest) String() string { func (*SysStatsRequest) ProtoMessage() {} func (x *SysStatsRequest) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[5] + mi := &file_app_stats_command_command_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -304,7 +304,7 @@ func (x *SysStatsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SysStatsRequest.ProtoReflect.Descriptor instead. func (*SysStatsRequest) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{5} + return file_app_stats_command_command_proto_rawDescGZIP(), []int{5} } type SysStatsResponse struct { @@ -326,7 +326,7 @@ type SysStatsResponse struct { func (x *SysStatsResponse) Reset() { *x = SysStatsResponse{} - mi := &file_command_proto_msgTypes[6] + mi := &file_app_stats_command_command_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -338,7 +338,7 @@ func (x *SysStatsResponse) String() string { func (*SysStatsResponse) ProtoMessage() {} func (x *SysStatsResponse) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[6] + mi := &file_app_stats_command_command_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -351,7 +351,7 @@ func (x *SysStatsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use SysStatsResponse.ProtoReflect.Descriptor instead. func (*SysStatsResponse) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{6} + return file_app_stats_command_command_proto_rawDescGZIP(), []int{6} } func (x *SysStatsResponse) GetNumGoroutine() uint32 { @@ -432,7 +432,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - mi := &file_command_proto_msgTypes[7] + mi := &file_app_stats_command_command_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -444,7 +444,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_command_proto_msgTypes[7] + mi := &file_app_stats_command_command_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -457,104 +457,105 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_command_proto_rawDescGZIP(), []int{7} + return file_app_stats_command_command_proto_rawDescGZIP(), []int{7} } -var File_command_proto protoreflect.FileDescriptor +var File_app_stats_command_command_proto protoreflect.FileDescriptor -var file_command_proto_rawDesc = []byte{ - 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x16, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0x3b, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, 0x74, - 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, - 0x65, 0x73, 0x65, 0x74, 0x22, 0x30, 0x0a, 0x04, 0x53, 0x74, 0x61, 0x74, 0x12, 0x12, 0x0a, 0x04, +var file_app_stats_command_command_proto_rawDesc = []byte{ + 0x0a, 0x1f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x12, 0x16, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, + 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x22, 0x3b, 0x0a, 0x0f, 0x47, 0x65, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x44, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, - 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x74, - 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x43, 0x0a, 0x11, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x72, - 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, 0x73, 0x65, - 0x74, 0x22, 0x46, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x74, 0x61, 0x74, 0x18, - 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, - 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x11, 0x0a, 0x0f, 0x53, 0x79, 0x73, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa2, 0x02, 0x0a, - 0x10, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, 0x72, 0x6f, - 0x75, 0x74, 0x69, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, 0x12, 0x14, 0x0a, 0x05, 0x41, - 0x6c, 0x6c, 0x6f, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x41, 0x6c, 0x6c, 0x6f, - 0x63, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, 0x6c, 0x6f, - 0x63, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x79, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, - 0x53, 0x79, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x12, 0x14, 0x0a, - 0x05, 0x46, 0x72, 0x65, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x46, 0x72, - 0x65, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x4c, 0x69, 0x76, 0x65, 0x4f, 0x62, 0x6a, 0x65, 0x63, - 0x74, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x4c, 0x69, 0x76, 0x65, 0x4f, 0x62, - 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x61, 0x75, 0x73, 0x65, 0x54, 0x6f, - 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x50, 0x61, 0x75, - 0x73, 0x65, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x70, 0x74, - 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x70, 0x74, 0x69, 0x6d, - 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xa1, 0x03, 0x0a, 0x0c, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x08, - 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, - 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, - 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, - 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x12, - 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, - 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, - 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, - 0x74, 0x73, 0x12, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, - 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, - 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, - 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x62, 0x0a, 0x0b, 0x47, - 0x65, 0x74, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, + 0x12, 0x14, 0x0a, 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x22, 0x30, 0x0a, 0x04, 0x53, 0x74, 0x61, 0x74, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x44, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x53, + 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, + 0x73, 0x74, 0x61, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x43, + 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x14, 0x0a, + 0x05, 0x72, 0x65, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x72, 0x65, + 0x73, 0x65, 0x74, 0x22, 0x46, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x73, 0x74, 0x61, + 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x52, 0x04, 0x73, 0x74, 0x61, 0x74, 0x22, 0x11, 0x0a, 0x0f, 0x53, + 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xa2, + 0x02, 0x0a, 0x10, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, 0x72, 0x6f, 0x75, 0x74, + 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x4e, 0x75, 0x6d, 0x47, 0x6f, + 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x05, 0x4e, 0x75, 0x6d, 0x47, 0x43, 0x12, 0x14, 0x0a, + 0x05, 0x41, 0x6c, 0x6c, 0x6f, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x41, 0x6c, + 0x6c, 0x6f, 0x63, 0x12, 0x1e, 0x0a, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, 0x6c, 0x6f, + 0x63, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x41, 0x6c, + 0x6c, 0x6f, 0x63, 0x12, 0x10, 0x0a, 0x03, 0x53, 0x79, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x03, 0x53, 0x79, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x4d, 0x61, 0x6c, 0x6c, 0x6f, 0x63, 0x73, 0x12, + 0x14, 0x0a, 0x05, 0x46, 0x72, 0x65, 0x65, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, + 0x46, 0x72, 0x65, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x4c, 0x69, 0x76, 0x65, 0x4f, 0x62, 0x6a, + 0x65, 0x63, 0x74, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x4c, 0x69, 0x76, 0x65, + 0x4f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x50, 0x61, 0x75, 0x73, 0x65, + 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x50, + 0x61, 0x75, 0x73, 0x65, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x55, + 0x70, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x70, 0x74, + 0x69, 0x6d, 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xa1, 0x03, + 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, + 0x0a, 0x08, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, - 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, - 0x64, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, - 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, - 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, - 0x74, 0x61, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x16, 0x58, - 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x65, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, + 0x65, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, + 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, + 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, + 0x74, 0x61, 0x74, 0x73, 0x12, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x2a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, + 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x62, 0x0a, + 0x0b, 0x47, 0x65, 0x74, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, + 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x42, 0x64, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, + 0x01, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, + 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, + 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, + 0x16, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x2e, + 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_command_proto_rawDescOnce sync.Once - file_command_proto_rawDescData = file_command_proto_rawDesc + file_app_stats_command_command_proto_rawDescOnce sync.Once + file_app_stats_command_command_proto_rawDescData = file_app_stats_command_command_proto_rawDesc ) -func file_command_proto_rawDescGZIP() []byte { - file_command_proto_rawDescOnce.Do(func() { - file_command_proto_rawDescData = protoimpl.X.CompressGZIP(file_command_proto_rawDescData) +func file_app_stats_command_command_proto_rawDescGZIP() []byte { + file_app_stats_command_command_proto_rawDescOnce.Do(func() { + file_app_stats_command_command_proto_rawDescData = protoimpl.X.CompressGZIP(file_app_stats_command_command_proto_rawDescData) }) - return file_command_proto_rawDescData + return file_app_stats_command_command_proto_rawDescData } -var file_command_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_command_proto_goTypes = []any{ +var file_app_stats_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_app_stats_command_command_proto_goTypes = []any{ (*GetStatsRequest)(nil), // 0: xray.app.stats.command.GetStatsRequest (*Stat)(nil), // 1: xray.app.stats.command.Stat (*GetStatsResponse)(nil), // 2: xray.app.stats.command.GetStatsResponse @@ -564,7 +565,7 @@ var file_command_proto_goTypes = []any{ (*SysStatsResponse)(nil), // 6: xray.app.stats.command.SysStatsResponse (*Config)(nil), // 7: xray.app.stats.command.Config } -var file_command_proto_depIdxs = []int32{ +var file_app_stats_command_command_proto_depIdxs = []int32{ 1, // 0: xray.app.stats.command.GetStatsResponse.stat:type_name -> xray.app.stats.command.Stat 1, // 1: xray.app.stats.command.QueryStatsResponse.stat:type_name -> xray.app.stats.command.Stat 0, // 2: xray.app.stats.command.StatsService.GetStats:input_type -> xray.app.stats.command.GetStatsRequest @@ -582,27 +583,27 @@ var file_command_proto_depIdxs = []int32{ 0, // [0:2] is the sub-list for field type_name } -func init() { file_command_proto_init() } -func file_command_proto_init() { - if File_command_proto != nil { +func init() { file_app_stats_command_command_proto_init() } +func file_app_stats_command_command_proto_init() { + if File_app_stats_command_command_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_command_proto_rawDesc, + RawDescriptor: file_app_stats_command_command_proto_rawDesc, NumEnums: 0, NumMessages: 8, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_command_proto_goTypes, - DependencyIndexes: file_command_proto_depIdxs, - MessageInfos: file_command_proto_msgTypes, + GoTypes: file_app_stats_command_command_proto_goTypes, + DependencyIndexes: file_app_stats_command_command_proto_depIdxs, + MessageInfos: file_app_stats_command_command_proto_msgTypes, }.Build() - File_command_proto = out.File - file_command_proto_rawDesc = nil - file_command_proto_goTypes = nil - file_command_proto_depIdxs = nil + File_app_stats_command_command_proto = out.File + file_app_stats_command_command_proto_rawDesc = nil + file_app_stats_command_command_proto_goTypes = nil + file_app_stats_command_command_proto_depIdxs = nil } diff --git a/app/stats/command/command_grpc.pb.go b/app/stats/command/command_grpc.pb.go index e9431453..d0bdc60b 100644 --- a/app/stats/command/command_grpc.pb.go +++ b/app/stats/command/command_grpc.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 -// - protoc v5.28.3 -// source: command.proto +// - protoc v5.28.2 +// source: app/stats/command/command.proto package command @@ -231,5 +231,5 @@ var StatsService_ServiceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "command.proto", + Metadata: "app/stats/command/command.proto", } From 1ffb8a92cd38c7ee2e8909f5dec6f5832d3bf520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Mon, 11 Nov 2024 12:20:54 +0800 Subject: [PATCH 603/867] Sniff: Prevent crash on QUIC sniffer panic (#3978) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- common/protocol/quic/sniff.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/common/protocol/quic/sniff.go b/common/protocol/quic/sniff.go index 8719a085..779e291b 100644 --- a/common/protocol/quic/sniff.go +++ b/common/protocol/quic/sniff.go @@ -1,6 +1,7 @@ package quic import ( + "context" "crypto" "crypto/aes" "crypto/tls" @@ -46,7 +47,18 @@ var ( errNotQuicInitial = errors.New("not initial packet") ) -func SniffQUIC(b []byte) (*SniffHeader, error) { +func SniffQUIC(b []byte) (resultReturn *SniffHeader, errorReturn error) { + // In extremely rare cases, this sniffer may cause slice error + // and we set recover() here to prevent crash. + // TODO: Thoroughly fix this panic + defer func() { + if r := recover(); r != nil { + errors.LogError(context.Background(), "Failed to sniff QUIC: ", r) + resultReturn = nil + errorReturn = common.ErrNoClue + } + }() + // Crypto data separated across packets cryptoLen := 0 cryptoData := bytespool.Alloc(int32(len(b))) From 571777483ba4626c0430aefcab96b34bdc1f844e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Mon, 11 Nov 2024 12:21:28 +0800 Subject: [PATCH 604/867] TLS: Add CurvePreferences (to enable kyber768) (#3991) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- infra/conf/transport_internet.go | 4 ++++ transport/internet/tls/config.go | 24 ++++++++++++++++++++++ transport/internet/tls/config.pb.go | 32 ++++++++++++++++++++--------- transport/internet/tls/config.proto | 3 +++ 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index d58763d1..ca8f3fef 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -456,6 +456,7 @@ type TLSConfig struct { RejectUnknownSNI bool `json:"rejectUnknownSni"` PinnedPeerCertificateChainSha256 *[]string `json:"pinnedPeerCertificateChainSha256"` PinnedPeerCertificatePublicKeySha256 *[]string `json:"pinnedPeerCertificatePublicKeySha256"` + CurvePreferences *StringList `json:"curvePreferences"` MasterKeyLog string `json:"masterKeyLog"` } @@ -478,6 +479,9 @@ func (c *TLSConfig) Build() (proto.Message, error) { if c.ALPN != nil && len(*c.ALPN) > 0 { config.NextProtocol = []string(*c.ALPN) } + if c.CurvePreferences != nil && len(*c.CurvePreferences) > 0 { + config.CurvePreferences = []string(*c.CurvePreferences) + } config.EnableSessionResumption = c.EnableSessionResumption config.DisableSystemRoot = c.DisableSystemRoot config.MinVersion = c.MinVersion diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 75648c4b..2ecabffb 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -344,6 +344,10 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { config.ServerName = sn } + if len(c.CurvePreferences) > 0 { + config.CurvePreferences = ParseCurveName(c.CurvePreferences) + } + if len(config.NextProtos) == 0 { config.NextProtos = []string{"h2", "http/1.1"} } @@ -429,3 +433,23 @@ func ConfigFromStreamSettings(settings *internet.MemoryStreamConfig) *Config { } return config } + +func ParseCurveName(curveNames []string) []tls.CurveID { + curveMap := map[string]tls.CurveID{ + "curvep256": tls.CurveP256, + "curvep384": tls.CurveP384, + "curvep521": tls.CurveP521, + "x25519": tls.X25519, + "x25519kyber768draft00": 0x6399, + } + + var curveIDs []tls.CurveID + for _, name := range curveNames { + if curveID, ok := curveMap[strings.ToLower(name)]; ok { + curveIDs = append(curveIDs, curveID) + } else { + errors.LogWarning(context.Background(), "unsupported curve name: "+name) + } + } + return curveIDs +} diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index cec2eefd..1c16e697 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -213,6 +213,8 @@ type Config struct { // @Critical PinnedPeerCertificatePublicKeySha256 [][]byte `protobuf:"bytes,14,rep,name=pinned_peer_certificate_public_key_sha256,json=pinnedPeerCertificatePublicKeySha256,proto3" json:"pinned_peer_certificate_public_key_sha256,omitempty"` MasterKeyLog string `protobuf:"bytes,15,opt,name=master_key_log,json=masterKeyLog,proto3" json:"master_key_log,omitempty"` + // Lists of string as CurvePreferences values. + CurvePreferences []string `protobuf:"bytes,16,rep,name=curve_preferences,json=curvePreferences,proto3" json:"curve_preferences,omitempty"` } func (x *Config) Reset() { @@ -343,6 +345,13 @@ func (x *Config) GetMasterKeyLog() string { return "" } +func (x *Config) GetCurvePreferences() []string { + if x != nil { + return x.CurvePreferences + } + return nil +} + var File_transport_internet_tls_config_proto protoreflect.FileDescriptor var file_transport_internet_tls_config_proto_rawDesc = []byte{ @@ -374,7 +383,7 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x4e, 0x43, 0x49, 0x50, 0x48, 0x45, 0x52, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, - 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xb3, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, + 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xe0, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x49, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x63, 0x65, @@ -417,15 +426,18 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x65, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x53, 0x68, 0x61, 0x32, 0x35, 0x36, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, 0x42, 0x73, - 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, - 0x73, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, - 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, 0x12, 0x2b, + 0x0a, 0x11, 0x63, 0x75, 0x72, 0x76, 0x65, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, + 0x63, 0x65, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x63, 0x75, 0x72, 0x76, 0x65, + 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x42, 0x73, 0x0a, 0x1f, 0x63, + 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x50, 0x01, + 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x74, + 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x6c, 0x73, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/tls/config.proto b/transport/internet/tls/config.proto index 526bc0dd..0fc1d01d 100644 --- a/transport/internet/tls/config.proto +++ b/transport/internet/tls/config.proto @@ -84,4 +84,7 @@ message Config { repeated bytes pinned_peer_certificate_public_key_sha256 = 14; string master_key_log = 15; + + // Lists of string as CurvePreferences values. + repeated string curve_preferences = 16; } From 85b3c2328fb553324dfbd1d9c87665549e8a45e1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 04:21:50 +0000 Subject: [PATCH 605/867] Bump golang.org/x/net from 0.30.0 to 0.31.0 (#3999) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.30.0 to 0.31.0. - [Commits](https://github.com/golang/net/compare/v0.30.0...v0.31.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b4a9870f..c149b23f 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.29.0 - golang.org/x/net v0.30.0 + golang.org/x/net v0.31.0 golang.org/x/sync v0.9.0 golang.org/x/sys v0.27.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index 777fe98a..75b45600 100644 --- a/go.sum +++ b/go.sum @@ -89,8 +89,8 @@ golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4= -golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= From 0df2446f824dd657717d29ef99b8b47cf50b2364 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 11 Nov 2024 04:22:33 +0000 Subject: [PATCH 606/867] v24.11.11 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 3d3305e5..93ca2d9c 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 24 Version_y byte = 11 - Version_z byte = 5 + Version_z byte = 11 ) var ( From 44b1dd0e674347691c62a13d227edf0d36b7e290 Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Mon, 11 Nov 2024 22:43:57 +0300 Subject: [PATCH 607/867] Test: Change address for DNS over QUIC tests (#4002) dns.adguard.com can be blocked in some places --- app/dns/nameserver_quic_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/dns/nameserver_quic_test.go b/app/dns/nameserver_quic_test.go index ef50d7d9..0088aa33 100644 --- a/app/dns/nameserver_quic_test.go +++ b/app/dns/nameserver_quic_test.go @@ -14,7 +14,7 @@ import ( ) func TestQUICNameServer(t *testing.T) { - url, err := url.Parse("quic://dns.adguard.com") + url, err := url.Parse("quic://dns.adguard-dns.com") common.Must(err) s, err := NewQUICNameServer(url, QueryStrategy_USE_IP) common.Must(err) @@ -42,7 +42,7 @@ func TestQUICNameServer(t *testing.T) { } func TestQUICNameServerWithIPv4Override(t *testing.T) { - url, err := url.Parse("quic://dns.adguard.com") + url, err := url.Parse("quic://dns.adguard-dns.com") common.Must(err) s, err := NewQUICNameServer(url, QueryStrategy_USE_IP4) common.Must(err) @@ -65,7 +65,7 @@ func TestQUICNameServerWithIPv4Override(t *testing.T) { } func TestQUICNameServerWithIPv6Override(t *testing.T) { - url, err := url.Parse("quic://dns.adguard.com") + url, err := url.Parse("quic://dns.adguard-dns.com") common.Must(err) s, err := NewQUICNameServer(url, QueryStrategy_USE_IP6) common.Must(err) From 1a238cbb7d213433942dcc6268274e0638805e23 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 12 Nov 2024 06:42:52 +0000 Subject: [PATCH 608/867] REALITY client: Log invalid connections at warning level Closes https://github.com/XTLS/Xray-core/issues/4001 --- transport/internet/reality/reality.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index c2f7859c..a65507c6 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -255,7 +255,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati // Do not close the connection }() time.Sleep(time.Duration(randBetween(config.SpiderY[8], config.SpiderY[9])) * time.Millisecond) // return - return nil, errors.New("REALITY: processed invalid connection") + return nil, errors.New("REALITY: processed invalid connection").AtWarning() } return uConn, nil } From 48ac662298283f15e116c84143289976b57e5bd1 Mon Sep 17 00:00:00 2001 From: lxsq <98205617+lxsq@users.noreply.github.com> Date: Tue, 12 Nov 2024 23:41:42 +0800 Subject: [PATCH 609/867] Update Dockerfile to Use Multiple Config Files (#4010) --- .github/docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index 31139529..c32bb844 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -22,7 +22,7 @@ VOLUME /etc/xray ARG TZ=Asia/Shanghai ENV TZ=$TZ ENTRYPOINT [ "/usr/bin/xray" ] -CMD [ "-config", "/etc/xray/config.json" ] +CMD [ "-confdir", "/etc/xray/" ] ARG flavor=v2fly COPY --from=build --chmod=644 /$flavor /usr/share/xray From 7b4a686b7401ede2263b8cbf6136c720b6953e39 Mon Sep 17 00:00:00 2001 From: pinglanlu Date: Tue, 12 Nov 2024 23:44:41 +0800 Subject: [PATCH 610/867] Chore: Use a more direct and less error-prone return value (#4008) Signed-off-by: pinglanlu --- proxy/vmess/validator.go | 2 +- transport/internet/tls/config_other.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/vmess/validator.go b/proxy/vmess/validator.go index b3a82f30..bfffadcf 100644 --- a/proxy/vmess/validator.go +++ b/proxy/vmess/validator.go @@ -81,7 +81,7 @@ func (v *TimedUserValidator) GetAEAD(userHash []byte) (*protocol.MemoryUser, boo if err != nil { return nil, false, err } - return userd.(*protocol.MemoryUser), true, err + return userd.(*protocol.MemoryUser), true, nil } func (v *TimedUserValidator) Remove(email string) bool { diff --git a/transport/internet/tls/config_other.go b/transport/internet/tls/config_other.go index daaf39c7..efd18c93 100644 --- a/transport/internet/tls/config_other.go +++ b/transport/internet/tls/config_other.go @@ -51,5 +51,5 @@ func (c *Config) getCertPool() (*x509.CertPool, error) { return nil, errors.New("append cert to root").AtWarning().Base(err) } } - return pool, err + return pool, nil } From 83ae38497b0e36f868720b2b2bacf362d72cd1f0 Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Wed, 13 Nov 2024 18:41:54 +0300 Subject: [PATCH 611/867] Chore: Drop dead code in test (#4012) --- infra/conf/dns_test.go | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/infra/conf/dns_test.go b/infra/conf/dns_test.go index 1c370cd9..d28c2041 100644 --- a/infra/conf/dns_test.go +++ b/infra/conf/dns_test.go @@ -7,7 +7,6 @@ import ( "testing" "github.com/xtls/xray-core/app/dns" - "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/platform" @@ -24,32 +23,11 @@ func init() { common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "resources", "geoip.dat"))) } - geositeFilePath := filepath.Join(wd, "geosite.dat") os.Setenv("xray.location.asset", wd) - geositeFile, err := os.OpenFile(geositeFilePath, os.O_CREATE|os.O_WRONLY, 0o600) - common.Must(err) - defer geositeFile.Close() - - list := &router.GeoSiteList{ - Entry: []*router.GeoSite{ - { - CountryCode: "TEST", - Domain: []*router.Domain{ - {Type: router.Domain_Full, Value: "example.com"}, - }, - }, - }, - } - - listBytes, err := proto.Marshal(list) - common.Must(err) - common.Must2(geositeFile.Write(listBytes)) } func TestDNSConfigParsing(t *testing.T) { - geositePath := platform.GetAssetLocation("geosite.dat") defer func() { - os.Remove(geositePath) os.Unsetenv("xray.location.asset") }() From 17825b25f25380de45ab1678be979cf4e7dde5ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 14 Nov 2024 08:13:27 +0800 Subject: [PATCH 612/867] WireGuard kernelTun: Fix multi-outbounds not work (#4015) Fixes https://github.com/XTLS/Xray-core/issues/2817 --- proxy/wireguard/tun_linux.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/proxy/wireguard/tun_linux.go b/proxy/wireguard/tun_linux.go index b8ce6488..7a46138a 100644 --- a/proxy/wireguard/tun_linux.go +++ b/proxy/wireguard/tun_linux.go @@ -4,16 +4,18 @@ package wireguard import ( "context" - "errors" + goerrors "errors" "fmt" "net" "net/netip" "os" + "sync" "golang.org/x/sys/unix" "github.com/sagernet/sing/common/control" "github.com/vishvananda/netlink" + "github.com/xtls/xray-core/common/errors" wgtun "golang.zx2c4.com/wireguard/tun" ) @@ -27,6 +29,23 @@ type deviceNet struct { rules []*netlink.Rule } +var ( + tableIndex int = 10230 + mu sync.Mutex +) + +func allocateIPv6TableIndex() int { + mu.Lock() + defer mu.Unlock() + + if tableIndex > 10230 { + errors.LogInfo(context.Background(), "allocate new ipv6 table index: ", tableIndex) + } + currentIndex := tableIndex + tableIndex++ + return currentIndex +} + func newDeviceNet(interfaceName string) *deviceNet { var dialer net.Dialer bindControl := control.BindToInterface(control.NewDefaultInterfaceFinder(), interfaceName, -1) @@ -68,7 +87,7 @@ func (d *deviceNet) Close() (err error) { if len(errs) == 0 { return nil } - return errors.Join(errs...) + return goerrors.Join(errs...) } func createKernelTun(localAddresses []netip.Addr, mtu int, handler promiscuousModeHandler) (t Tunnel, err error) { @@ -138,7 +157,7 @@ func createKernelTun(localAddresses []netip.Addr, mtu int, handler promiscuousMo } } - ipv6TableIndex := 1023 + ipv6TableIndex := allocateIPv6TableIndex() if v6 != nil { r := &netlink.Route{Table: ipv6TableIndex} for { From ec1fd008c469ade7899d9b1a1721b16de4e21bb3 Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:04:17 +0300 Subject: [PATCH 613/867] Chore: Refactor infra/conf.TestToCidrList() (#4017) --- infra/conf/dns_test.go | 20 ------------------ infra/conf/router_test.go | 44 ++++++++++++++++++++++++++++++--------- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/infra/conf/dns_test.go b/infra/conf/dns_test.go index d28c2041..5d423884 100644 --- a/infra/conf/dns_test.go +++ b/infra/conf/dns_test.go @@ -2,35 +2,15 @@ package conf_test import ( "encoding/json" - "os" - "path/filepath" "testing" "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/common/platform" - "github.com/xtls/xray-core/common/platform/filesystem" . "github.com/xtls/xray-core/infra/conf" "google.golang.org/protobuf/proto" ) -func init() { - wd, err := os.Getwd() - common.Must(err) - - if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) { - common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "resources", "geoip.dat"))) - } - - os.Setenv("xray.location.asset", wd) -} - func TestDNSConfigParsing(t *testing.T) { - defer func() { - os.Unsetenv("xray.location.asset") - }() - parserCreator := func() func(string) (proto.Message, error) { return func(s string) (proto.Message, error) { config := new(DNSConfig) diff --git a/infra/conf/router_test.go b/infra/conf/router_test.go index 340b871c..35c68c68 100644 --- a/infra/conf/router_test.go +++ b/infra/conf/router_test.go @@ -2,6 +2,7 @@ package conf_test import ( "encoding/json" + "fmt" "os" "path/filepath" "testing" @@ -18,21 +19,44 @@ import ( "google.golang.org/protobuf/proto" ) -func init() { - wd, err := os.Getwd() - common.Must(err) - - if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) { - common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "resources", "geoip.dat"))) +func getAssetPath(file string) (string, error) { + path := platform.GetAssetLocation(file) + _, err := os.Stat(path) + if os.IsNotExist(err) { + path := filepath.Join("..", "..", "resources", file) + _, err := os.Stat(path) + if os.IsNotExist(err) { + return "", fmt.Errorf("can't find %s in standard asset locations or {project_root}/resources", file) + } + if err != nil { + return "", fmt.Errorf("can't stat %s: %v", path, err) + } + return path, nil + } + if err != nil { + return "", fmt.Errorf("can't stat %s: %v", path, err) } - os.Setenv("xray.location.asset", wd) + return path, nil } func TestToCidrList(t *testing.T) { - t.Log(os.Getenv("xray.location.asset")) + tempDir, err := os.MkdirTemp("", "test-") + if err != nil { + t.Fatalf("can't create temp dir: %v", err) + } + defer os.RemoveAll(tempDir) - common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoiptestrouter.dat"), "geoip.dat")) + geoipPath, err := getAssetPath("geoip.dat") + if err != nil { + t.Fatal(err) + } + + common.Must(filesystem.CopyFile(filepath.Join(tempDir, "geoip.dat"), geoipPath)) + common.Must(filesystem.CopyFile(filepath.Join(tempDir, "geoiptestrouter.dat"), geoipPath)) + + os.Setenv("xray.location.asset", tempDir) + defer os.Unsetenv("xray.location.asset") ips := StringList([]string{ "geoip:us", @@ -44,7 +68,7 @@ func TestToCidrList(t *testing.T) { "ext-ip:geoiptestrouter.dat:!ca", }) - _, err := ToCidrList(ips) + _, err = ToCidrList(ips) if err != nil { t.Fatalf("Failed to parse geoip list, got %s", err) } From 2d7b0e8cd4f1fc6ec840891dbc03b4e781d0a5ad Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 17 Nov 2024 06:03:25 +0000 Subject: [PATCH 614/867] XHTTP client: Fix upload issue in "packet-up" mode inherited from SplitHTTP Fixes https://github.com/XTLS/Xray-core/issues/3972 --- transport/internet/splithttp/dialer.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index a63d3253..d2e89eb4 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -324,7 +324,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me // WithSizeLimit(0) will still allow single bytes to pass, and a lot of // code relies on this behavior. Subtract 1 so that together with // uploadWriter wrapper, exact size limits can be enforced - uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1)) + // uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1)) + uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - buf.Size)) conn.writer = uploadWriter{ uploadPipeWriter, @@ -400,10 +401,12 @@ type uploadWriter struct { } func (w uploadWriter) Write(b []byte) (int, error) { - capacity := int(w.maxLen - w.Len()) - if capacity > 0 && capacity < len(b) { - b = b[:capacity] - } + /* + capacity := int(w.maxLen - w.Len()) + if capacity > 0 && capacity < len(b) { + b = b[:capacity] + } + */ buffer := buf.New() n, err := buffer.Write(b) From 1f570d9cefb750b9f1d3730ce21a7c6341e1bd6f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 18 Nov 2024 04:53:21 +0000 Subject: [PATCH 615/867] XHTTP test: Fix Test_maxUpload https://github.com/XTLS/Xray-core/pull/3260#issuecomment-2481946715 --- transport/internet/splithttp/splithttp_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index b01727e0..c349f8f5 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -424,8 +424,8 @@ func Test_maxUpload(t *testing.T) { ProtocolSettings: &Config{ Path: "/sh", ScMaxEachPostBytes: &RandRangeConfig{ - From: 100, - To: 100, + From: 10000, + To: 10000, }, }, } @@ -434,7 +434,7 @@ func Test_maxUpload(t *testing.T) { listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { go func(c stat.Connection) { defer c.Close() - var b [1024]byte + var b [10240]byte c.SetReadDeadline(time.Now().Add(2 * time.Second)) n, err := c.Read(b[:]) if err != nil { @@ -452,11 +452,11 @@ func Test_maxUpload(t *testing.T) { conn, err := Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), listenPort), streamSettings) // send a slightly too large upload - var upload [101]byte + var upload [10001]byte _, err = conn.Write(upload[:]) common.Must(err) - var b [1024]byte + var b [10240]byte n, _ := io.ReadFull(conn, b[:]) fmt.Println("string is", n) if string(b[:n]) != "Response" { @@ -464,7 +464,7 @@ func Test_maxUpload(t *testing.T) { } common.Must(conn.Close()) - if uploadSize > 100 || uploadSize == 0 { + if uploadSize > 10000 || uploadSize == 0 { t.Error("incorrect upload size: ", uploadSize) } From 5a96ef632d65b8e68c4f337e0f918a55d1925396 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 05:08:03 +0000 Subject: [PATCH 616/867] Bump google.golang.org/protobuf from 1.35.1 to 1.35.2 (#4018) Bumps google.golang.org/protobuf from 1.35.1 to 1.35.2. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c149b23f..f81174d7 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/sys v0.27.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.67.1 - google.golang.org/protobuf v1.35.1 + google.golang.org/protobuf v1.35.2 gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.3.0 diff --git a/go.sum b/go.sum index 75b45600..d94428a8 100644 --- a/go.sum +++ b/go.sum @@ -129,8 +129,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 55e045d0982c01d78b0c5beb2ac747ca847f8d05 Mon Sep 17 00:00:00 2001 From: yiguous <147401898+yiguous@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:18:47 +0800 Subject: [PATCH 617/867] Config: Correctly marshal `Address` to JSON (#4021) --- infra/conf/common.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/infra/conf/common.go b/infra/conf/common.go index ccd36d3d..fd6e732a 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -42,6 +42,10 @@ type Address struct { net.Address } +func (v Address) MarshalJSON() ([]byte, error) { + return json.Marshal(v.Address.String()) +} + func (v *Address) UnmarshalJSON(data []byte) error { var rawStr string if err := json.Unmarshal(data, &rawStr); err != nil { From 7d3d6b05e38d610a30152013cb1090172f62c282 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 03:19:34 +0000 Subject: [PATCH 618/867] Bump github.com/sagernet/sing from 0.5.0 to 0.5.1 (#4026) Bumps [github.com/sagernet/sing](https://github.com/sagernet/sing) from 0.5.0 to 0.5.1. - [Commits](https://github.com/sagernet/sing/compare/v0.5.0...v0.5.1) --- updated-dependencies: - dependency-name: github.com/sagernet/sing dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f81174d7..c93cbb75 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/pires/go-proxyproto v0.8.0 github.com/quic-go/quic-go v0.46.0 github.com/refraction-networking/utls v1.6.7 - github.com/sagernet/sing v0.5.0 + github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index d94428a8..fbad852b 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= -github.com/sagernet/sing v0.5.0 h1:soo2wVwLcieKWWKIksFNK6CCAojUgAppqQVwyRYGkEM= -github.com/sagernet/sing v0.5.0/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= +github.com/sagernet/sing v0.5.1 h1:mhL/MZVq0TjuvHcpYcFtmSD1BFOxZ/+8ofbNZcg1k1Y= +github.com/sagernet/sing v0.5.1/go.mod h1:ARkL0gM13/Iv5VCZmci/NuoOlePoIsW0m7BWfln/Hak= github.com/sagernet/sing-shadowsocks v0.2.7 h1:zaopR1tbHEw5Nk6FAkM05wCslV6ahVegEZaKMv9ipx8= github.com/sagernet/sing-shadowsocks v0.2.7/go.mod h1:0rIKJZBR65Qi0zwdKezt4s57y/Tl1ofkaq6NlkzVuyE= github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 h1:emzAzMZ1L9iaKCTxdy3Em8Wv4ChIAGnfiz18Cda70g4= From 59e5d24280812ce39674348878f96bef64cf32b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Wed, 20 Nov 2024 13:00:40 +0800 Subject: [PATCH 619/867] WireGuard inbound: Fix leaking session information between requests (#4030) Fixes https://github.com/XTLS/Xray-core/issues/3948 https://github.com/XTLS/Xray-core/issues/4025 --- proxy/wireguard/server.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/proxy/wireguard/server.go b/proxy/wireguard/server.go index 77aa4985..8ab84fe4 100644 --- a/proxy/wireguard/server.go +++ b/proxy/wireguard/server.go @@ -144,15 +144,20 @@ func (s *Server) forwardConnection(dest net.Destination, conn net.Conn) { Reason: "", }) - if s.info.inboundTag != nil { - ctx = session.ContextWithInbound(ctx, s.info.inboundTag) - } - if s.info.outboundTag != nil { - ctx = session.ContextWithOutbounds(ctx, []*session.Outbound{s.info.outboundTag}) - } - if s.info.contentTag != nil { - ctx = session.ContextWithContent(ctx, s.info.contentTag) - } + // what's this? + // Session information should not be shared between different connections + // why reuse them in server level? This will cause incorrect destoverride and unexpected routing behavior. + // Disable it temporarily. Maybe s.info should be removed. + + // if s.info.inboundTag != nil { + // ctx = session.ContextWithInbound(ctx, s.info.inboundTag) + // } + // if s.info.outboundTag != nil { + // ctx = session.ContextWithOutbounds(ctx, []*session.Outbound{s.info.outboundTag}) + // } + // if s.info.contentTag != nil { + // ctx = session.ContextWithContent(ctx, s.info.contentTag) + // } link, err := s.info.dispatcher.Dispatch(ctx, dest) if err != nil { From 6ba0dbafd7106d08146488d62398a807504f3f8d Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Wed, 20 Nov 2024 08:03:39 +0300 Subject: [PATCH 620/867] Test: Delete temporary file afterwards (#4028) --- common/log/logger_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/common/log/logger_test.go b/common/log/logger_test.go index 1c7f06e2..6a664e08 100644 --- a/common/log/logger_test.go +++ b/common/log/logger_test.go @@ -16,6 +16,7 @@ func TestFileLogger(t *testing.T) { common.Must(err) path := f.Name() common.Must(f.Close()) + defer os.Remove(path) creator, err := CreateFileLogWriter(path) common.Must(err) From 0a252ac15d34e7c23a1d3807a89bfca51cbb559b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 21 Nov 2024 13:42:19 +0800 Subject: [PATCH 621/867] HTTP transport: Use dest as Host if not set (#4038) --- transport/internet/http/config.go | 2 +- transport/internet/http/dialer.go | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/transport/internet/http/config.go b/transport/internet/http/config.go index 989ed106..1cd7d058 100644 --- a/transport/internet/http/config.go +++ b/transport/internet/http/config.go @@ -8,7 +8,7 @@ import ( func (c *Config) getHosts() []string { if len(c.Host) == 0 { - return []string{"www.example.com"} + return []string{""} } return c.Host } diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go index d0a86e8b..42a9f9b3 100644 --- a/transport/internet/http/dialer.go +++ b/transport/internet/http/dialer.go @@ -215,9 +215,16 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } } + Host := httpSettings.getRandomHost() + if Host == "" && net.ParseAddress(dest.NetAddr()).Family().IsDomain() { + Host = dest.Address.String() + } else if Host == "" { + Host = "www.example.com" + } + request := &http.Request{ Method: httpMethod, - Host: httpSettings.getRandomHost(), + Host: Host, Body: breader, URL: &url.URL{ Scheme: "https", From 817fa72874adc5a6da0f24c2ca7ba3832304813d Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 21 Nov 2024 05:45:49 +0000 Subject: [PATCH 622/867] XHTTP client: Add gRPC header to "stream-up" mode by default (#4042) ""Breaking"": Client uses "stream-up" mode by default when using **TLS H2** or REALITY --- infra/conf/transport_internet.go | 2 + transport/internet/splithttp/client.go | 3 + transport/internet/splithttp/config.pb.go | 89 +++++++++++++---------- transport/internet/splithttp/config.proto | 1 + transport/internet/splithttp/dialer.go | 8 +- 5 files changed, 62 insertions(+), 41 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index ca8f3fef..83deadbf 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -235,6 +235,7 @@ type SplitHTTPConfig struct { DownloadSettings *StreamConfig `json:"downloadSettings"` Mode string `json:"mode"` Extra json.RawMessage `json:"extra"` + NoGRPCHeader bool `json:"noGRPCHeader"` } type Xmux struct { @@ -322,6 +323,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), Xmux: &muxProtobuf, Mode: c.Mode, + NoGRPCHeader: c.NoGRPCHeader, } var err error if c.DownloadSettings != nil { diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index e5866b55..77b88fa4 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -46,6 +46,9 @@ func (c *DefaultDialerClient) OpenUpload(ctx context.Context, baseURL string) io reader, writer := io.Pipe() req, _ := http.NewRequestWithContext(ctx, "POST", baseURL, reader) req.Header = c.transportConfig.GetRequestHeader() + if !c.transportConfig.NoGRPCHeader { + req.Header.Set("Content-Type", "application/grpc") + } go c.client.Do(req) return writer } diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index f2d1ab4f..0ab85fd9 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -37,6 +37,7 @@ type Config struct { Xmux *Multiplexing `protobuf:"bytes,9,opt,name=xmux,proto3" json:"xmux,omitempty"` DownloadSettings *internet.StreamConfig `protobuf:"bytes,10,opt,name=downloadSettings,proto3" json:"downloadSettings,omitempty"` Mode string `protobuf:"bytes,11,opt,name=mode,proto3" json:"mode,omitempty"` + NoGRPCHeader bool `protobuf:"varint,12,opt,name=noGRPCHeader,proto3" json:"noGRPCHeader,omitempty"` } func (x *Config) Reset() { @@ -146,6 +147,13 @@ func (x *Config) GetMode() string { return "" } +func (x *Config) GetNoGRPCHeader() bool { + if x != nil { + return x.NoGRPCHeader + } + return false +} + type RandRangeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -278,7 +286,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x1a, 0x1f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x96, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, + 0xba, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, @@ -323,47 +331,50 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, - 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x1a, 0x39, 0x0a, - 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, - 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, - 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, - 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, - 0xfe, 0x02, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, - 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, - 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, - 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, - 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, - 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, - 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, - 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, - 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, - 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, - 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, + 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x22, 0x0a, + 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, + 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, + 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, + 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, + 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, - 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, - 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, - 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, - 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, + 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, + 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, + 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, + 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, + 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, + 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, + 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, + 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, + 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, + 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index b5894620..f6b10164 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -20,6 +20,7 @@ message Config { Multiplexing xmux = 9; xray.transport.internet.StreamConfig downloadSettings = 10; string mode = 11; + bool noGRPCHeader = 12; } message RandRangeConfig { diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index d2e89eb4..6a4484de 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -312,9 +312,13 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } mode := transportConfiguration.Mode - if mode == "auto" && realityConfig != nil { - mode = "stream-up" + if mode == "auto" { + mode = "packet-up" + if (tlsConfig != nil && len(tlsConfig.NextProtocol) != 1) || realityConfig != nil { + mode = "stream-up" + } } + errors.LogInfo(ctx, "XHTTP is using mode: "+mode) if mode == "stream-up" { conn.writer = httpClient.OpenUpload(ctx, requestURL.String()) return stat.Connection(&conn), nil From 513f18bf531ef5f92464c2affefed0db4f28280b Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 21 Nov 2024 05:47:07 +0000 Subject: [PATCH 623/867] v24.11.21 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 93ca2d9c..dabdee9d 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 24 Version_y byte = 11 - Version_z byte = 11 + Version_z byte = 21 ) var ( From 384d07999c369a15dae3c8fd85f4cf4d7c2f631b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 24 Nov 2024 22:37:28 -0500 Subject: [PATCH 624/867] Bump github.com/stretchr/testify from 1.9.0 to 1.10.0 (#4060) Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.9.0 to 1.10.0. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.9.0...v1.10.0) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c93cbb75..facbf223 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d diff --git a/go.sum b/go.sum index fbad852b..576197f4 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 h1:emzAzMZ1 github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF8gHIiADmOVOV5LS43gt3ONnlEl3xkwI= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQdrZk= From 034a485afe7a2521785547bbd7ced451bd2b1efd Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Mon, 25 Nov 2024 06:53:31 +0300 Subject: [PATCH 625/867] Chore: Refactor tests in app/router (#4019) --- app/router/condition_geoip_test.go | 35 +++++++++++++++++++++--------- app/router/condition_test.go | 22 +++++-------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/app/router/condition_geoip_test.go b/app/router/condition_geoip_test.go index 63bd222e..07f40b83 100644 --- a/app/router/condition_geoip_test.go +++ b/app/router/condition_geoip_test.go @@ -1,6 +1,7 @@ package router_test import ( + "fmt" "os" "path/filepath" "testing" @@ -13,16 +14,25 @@ import ( "google.golang.org/protobuf/proto" ) -func init() { - wd, err := os.Getwd() - common.Must(err) +func getAssetPath(file string) (string, error) { + path := platform.GetAssetLocation(file) + _, err := os.Stat(path) + if os.IsNotExist(err) { + path := filepath.Join("..", "..", "resources", file) + _, err := os.Stat(path) + if os.IsNotExist(err) { + return "", fmt.Errorf("can't find %s in standard asset locations or {project_root}/resources", file) + } + if err != nil { + return "", fmt.Errorf("can't stat %s: %v", path, err) + } + return path, nil + } + if err != nil { + return "", fmt.Errorf("can't stat %s: %v", path, err) + } - if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) { - common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "resources", "geoip.dat"))) - } - if _, err := os.Stat(platform.GetAssetLocation("geosite.dat")); err != nil && os.IsNotExist(err) { - common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "resources", "geosite.dat"))) - } + return path, nil } func TestGeoIPMatcherContainer(t *testing.T) { @@ -217,10 +227,15 @@ func TestGeoIPMatcher6US(t *testing.T) { } func loadGeoIP(country string) ([]*router.CIDR, error) { - geoipBytes, err := filesystem.ReadAsset("geoip.dat") + path, err := getAssetPath("geoip.dat") if err != nil { return nil, err } + geoipBytes, err := filesystem.ReadFile(path) + if err != nil { + return nil, err + } + var geoipList router.GeoIPList if err := proto.Unmarshal(geoipBytes, &geoipList); err != nil { return nil, err diff --git a/app/router/condition_test.go b/app/router/condition_test.go index 75ee86dd..97d05db9 100644 --- a/app/router/condition_test.go +++ b/app/router/condition_test.go @@ -1,8 +1,6 @@ package router_test import ( - "os" - "path/filepath" "strconv" "testing" @@ -10,7 +8,6 @@ import ( "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/common/platform" "github.com/xtls/xray-core/common/platform/filesystem" "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/protocol/http" @@ -20,18 +17,6 @@ import ( "google.golang.org/protobuf/proto" ) -func init() { - wd, err := os.Getwd() - common.Must(err) - - if _, err := os.Stat(platform.GetAssetLocation("geoip.dat")); err != nil && os.IsNotExist(err) { - common.Must(filesystem.CopyFile(platform.GetAssetLocation("geoip.dat"), filepath.Join(wd, "..", "..", "release", "config", "geoip.dat"))) - } - if _, err := os.Stat(platform.GetAssetLocation("geosite.dat")); err != nil && os.IsNotExist(err) { - common.Must(filesystem.CopyFile(platform.GetAssetLocation("geosite.dat"), filepath.Join(wd, "..", "..", "release", "config", "geosite.dat"))) - } -} - func withBackground() routing.Context { return &routing_session.Context{} } @@ -316,10 +301,15 @@ func TestRoutingRule(t *testing.T) { } func loadGeoSite(country string) ([]*Domain, error) { - geositeBytes, err := filesystem.ReadAsset("geosite.dat") + path, err := getAssetPath("geosite.dat") if err != nil { return nil, err } + geositeBytes, err := filesystem.ReadFile(path) + if err != nil { + return nil, err + } + var geositeList GeoSiteList if err := proto.Unmarshal(geositeBytes, &geositeList); err != nil { return nil, err From ce8c415d43f674b96cb7cb47e28c5fd275f74254 Mon Sep 17 00:00:00 2001 From: zonescape <44441590+zonescape@users.noreply.github.com> Date: Mon, 25 Nov 2024 07:00:00 +0300 Subject: [PATCH 626/867] Test: Remove temporary directory afterwards (#4045) --- testing/scenarios/common.go | 2 ++ testing/scenarios/main_test.go | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 testing/scenarios/main_test.go diff --git a/testing/scenarios/common.go b/testing/scenarios/common.go index 8d629c59..dc54105a 100644 --- a/testing/scenarios/common.go +++ b/testing/scenarios/common.go @@ -96,6 +96,7 @@ func InitializeServerConfig(config *core.Config) (*exec.Cmd, error) { var ( testBinaryPath string + testBinaryCleanFn func() testBinaryPathGen sync.Once ) @@ -108,6 +109,7 @@ func genTestBinaryPath() { return err } tempDir = dir + testBinaryCleanFn = func() { os.RemoveAll(dir) } return nil })) file := filepath.Join(tempDir, "xray.test") diff --git a/testing/scenarios/main_test.go b/testing/scenarios/main_test.go new file mode 100644 index 00000000..269081c6 --- /dev/null +++ b/testing/scenarios/main_test.go @@ -0,0 +1,12 @@ +package scenarios + +import ( + "testing" +) + +func TestMain(m *testing.M) { + genTestBinaryPath() + defer testBinaryCleanFn() + + m.Run() +} From d8934cf83946e88210b6bb95d793bc06e12b6db8 Mon Sep 17 00:00:00 2001 From: Aleksandr Date: Mon, 25 Nov 2024 17:16:29 +0100 Subject: [PATCH 627/867] Chore: Improved log messaging (#4050) * update log messages * Update inbound.go --- proxy/vless/inbound/inbound.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index 48849eb2..a2415a44 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -491,12 +491,12 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s rawInput = (*bytes.Buffer)(unsafe.Pointer(p + r.Offset)) } } else { - return errors.New(account.ID.String() + " is not able to use " + requestAddons.Flow).AtWarning() + return errors.New("account " + account.ID.String() + " is not able to use the flow " + requestAddons.Flow).AtWarning() } case "": inbound.CanSpliceCopy = 3 if account.Flow == vless.XRV && (request.Command == protocol.RequestCommandTCP || isMuxAndNotXUDP(request, first)) { - return errors.New(account.ID.String() + " is not able to use \"\". Note that the pure TLS proxy has certain TLS in TLS characters.").AtWarning() + return errors.New("account " + account.ID.String() + " is rejected since the client flow is empty. Note that the pure TLS proxy has certain TLS in TLS characters.").AtWarning() } default: return errors.New("unknown request flow " + requestAddons.Flow).AtWarning() From f7bd98b13c739303a46a6d15d8e0d482123384df Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 27 Nov 2024 20:19:18 +0000 Subject: [PATCH 628/867] XHTTP: Add "stream-one" mode for client & server (#4071) ""Breaking"": Client uses "stream-one" mode by default when using **REALITY** ("stream-up" if "downloadSettings" exists) --- infra/conf/transport_internet.go | 7 +- .../internet/splithttp/browser_client.go | 4 ++ transport/internet/splithttp/client.go | 65 +++++++++++++++++++ transport/internet/splithttp/dialer.go | 42 ++++++++---- transport/internet/splithttp/hub.go | 48 ++++++++++---- 5 files changed, 141 insertions(+), 25 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 83deadbf..a87a6ecb 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -307,7 +307,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { switch c.Mode { case "": c.Mode = "auto" - case "auto", "packet-up", "stream-up": + case "auto", "packet-up", "stream-up", "stream-one": default: return nil, errors.New("unsupported mode: " + c.Mode) } @@ -327,6 +327,9 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { } var err error if c.DownloadSettings != nil { + if c.Mode == "stream-one" { + return nil, errors.New(`Can not use "downloadSettings" in "stream-one" mode.`) + } if c.Extra != nil { c.DownloadSettings.SocketSettings = nil } @@ -707,8 +710,10 @@ func (p TransportProtocol) Build() (string, error) { case "ws", "websocket": return "websocket", nil case "h2", "h3", "http": + errors.PrintDeprecatedFeatureWarning("HTTP transport", "XHTTP transport") return "http", nil case "grpc": + errors.PrintMigrateFeatureInfo("gRPC transport", "XHTTP transport") return "grpc", nil case "httpupgrade": return "httpupgrade", nil diff --git a/transport/internet/splithttp/browser_client.go b/transport/internet/splithttp/browser_client.go index 14ecaaf1..d56ba139 100644 --- a/transport/internet/splithttp/browser_client.go +++ b/transport/internet/splithttp/browser_client.go @@ -14,6 +14,10 @@ import ( // has no fields because everything is global state :O) type BrowserDialerClient struct{} +func (c *BrowserDialerClient) Open(ctx context.Context, pureURL string) (io.WriteCloser, io.ReadCloser) { + panic("not implemented yet") +} + func (c *BrowserDialerClient) OpenUpload(ctx context.Context, baseURL string) io.WriteCloser { panic("not implemented yet") } diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index 77b88fa4..baeac3ca 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -29,6 +29,10 @@ type DialerClient interface { // (ctx, baseURL) -> uploadWriter // baseURL already contains sessionId OpenUpload(context.Context, string) io.WriteCloser + + // (ctx, pureURL) -> (uploadWriter, downloadReader) + // pureURL can not contain sessionId + Open(context.Context, string) (io.WriteCloser, io.ReadCloser) } // implements splithttp.DialerClient in terms of direct network connections @@ -42,6 +46,30 @@ type DefaultDialerClient struct { dialUploadConn func(ctxInner context.Context) (net.Conn, error) } +func (c *DefaultDialerClient) Open(ctx context.Context, pureURL string) (io.WriteCloser, io.ReadCloser) { + reader, writer := io.Pipe() + req, _ := http.NewRequestWithContext(ctx, "POST", pureURL, reader) + req.Header = c.transportConfig.GetRequestHeader() + if !c.transportConfig.NoGRPCHeader { + req.Header.Set("Content-Type", "application/grpc") + } + wrc := &WaitReadCloser{Wait: make(chan struct{})} + go func() { + response, err := c.client.Do(req) + if err != nil || response.StatusCode != 200 { + if err != nil { + errors.LogInfoInner(ctx, err, "failed to open ", pureURL) + } else { + errors.LogInfo(ctx, "unexpected status ", response.StatusCode) + } + wrc.Close() + return + } + wrc.Set(response.Body) + }() + return writer, wrc +} + func (c *DefaultDialerClient) OpenUpload(ctx context.Context, baseURL string) io.WriteCloser { reader, writer := io.Pipe() req, _ := http.NewRequestWithContext(ctx, "POST", baseURL, reader) @@ -226,3 +254,40 @@ func (c downloadBody) Close() error { c.cancel() return nil } + +type WaitReadCloser struct { + Wait chan struct{} + io.ReadCloser +} + +func (w *WaitReadCloser) Set(rc io.ReadCloser) { + w.ReadCloser = rc + defer func() { + if recover() != nil { + rc.Close() + } + }() + close(w.Wait) +} + +func (w *WaitReadCloser) Read(b []byte) (int, error) { + if w.ReadCloser == nil { + if <-w.Wait; w.ReadCloser == nil { + return 0, io.ErrClosedPipe + } + } + return w.ReadCloser.Read(b) +} + +func (w *WaitReadCloser) Close() error { + if w.ReadCloser != nil { + return w.ReadCloser.Close() + } + defer func() { + if recover() != nil && w.ReadCloser != nil { + w.ReadCloser.Close() + } + }() + close(w.Wait) + return nil +} diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 6a4484de..df83bd92 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -3,6 +3,7 @@ package splithttp import ( "context" gotls "crypto/tls" + "io" "net/http" "net/url" "strconv" @@ -279,9 +280,33 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestURL2.RawQuery = config2.GetNormalizedQuery() } - reader, remoteAddr, localAddr, err := httpClient2.OpenDownload(context.WithoutCancel(ctx), requestURL2.String()) - if err != nil { - return nil, err + mode := transportConfiguration.Mode + if mode == "" || mode == "auto" { + mode = "packet-up" + if (tlsConfig != nil && (len(tlsConfig.NextProtocol) != 1 || tlsConfig.NextProtocol[0] == "h2")) || realityConfig != nil { + mode = "stream-up" + } + if realityConfig != nil && transportConfiguration.DownloadSettings == nil { + mode = "stream-one" + } + } + errors.LogInfo(ctx, "XHTTP is using mode: "+mode) + + var writer io.WriteCloser + var reader io.ReadCloser + var remoteAddr, localAddr net.Addr + var err error + + if mode == "stream-one" { + requestURL.Path = transportConfiguration.GetNormalizedPath() + writer, reader = httpClient.Open(context.WithoutCancel(ctx), requestURL.String()) + remoteAddr = &net.TCPAddr{} + localAddr = &net.TCPAddr{} + } else { + reader, remoteAddr, localAddr, err = httpClient2.OpenDownload(context.WithoutCancel(ctx), requestURL2.String()) + if err != nil { + return nil, err + } } if muxRes != nil { @@ -293,7 +318,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me closed := false conn := splitConn{ - writer: nil, + writer: writer, reader: reader, remoteAddr: remoteAddr, localAddr: localAddr, @@ -311,14 +336,9 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me }, } - mode := transportConfiguration.Mode - if mode == "auto" { - mode = "packet-up" - if (tlsConfig != nil && len(tlsConfig.NextProtocol) != 1) || realityConfig != nil { - mode = "stream-up" - } + if mode == "stream-one" { + return stat.Connection(&conn), nil } - errors.LogInfo(ctx, "XHTTP is using mode: "+mode) if mode == "stream-up" { conn.writer = httpClient.OpenUpload(ctx, requestURL.String()) return stat.Connection(&conn), nil diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 58113f02..f1002018 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -102,14 +102,22 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req h.config.WriteResponseHeader(writer) + validRange := h.config.GetNormalizedXPaddingBytes() + x_padding := int32(len(request.URL.Query().Get("x_padding"))) + if validRange.To > 0 && (x_padding < validRange.From || x_padding > validRange.To) { + errors.LogInfo(context.Background(), "invalid x_padding length:", x_padding) + writer.WriteHeader(http.StatusBadRequest) + return + } + sessionId := "" subpath := strings.Split(request.URL.Path[len(h.path):], "/") if len(subpath) > 0 { sessionId = subpath[0] } - if sessionId == "" { - errors.LogInfo(context.Background(), "no sessionid on request:", request.URL.Path) + if sessionId == "" && h.config.Mode != "" && h.config.Mode != "auto" && h.config.Mode != "stream-one" && h.config.Mode != "stream-up" { + errors.LogInfo(context.Background(), "stream-one mode is not allowed") writer.WriteHeader(http.StatusBadRequest) return } @@ -126,17 +134,20 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } } - currentSession := h.upsertSession(sessionId) + var currentSession *httpSession + if sessionId != "" { + currentSession = h.upsertSession(sessionId) + } scMaxEachPostBytes := int(h.ln.config.GetNormalizedScMaxEachPostBytes().To) - if request.Method == "POST" { + if request.Method == "POST" && sessionId != "" { seq := "" if len(subpath) > 1 { seq = subpath[1] } if seq == "" { - if h.config.Mode == "packet-up" { + if h.config.Mode != "" && h.config.Mode != "auto" && h.config.Mode != "stream-up" { errors.LogInfo(context.Background(), "stream-up mode is not allowed") writer.WriteHeader(http.StatusBadRequest) return @@ -148,13 +159,16 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req errors.LogInfoInner(context.Background(), err, "failed to upload (PushReader)") writer.WriteHeader(http.StatusConflict) } else { + if request.Header.Get("Content-Type") == "application/grpc" { + writer.Header().Set("Content-Type", "application/grpc") + } writer.WriteHeader(http.StatusOK) <-request.Context().Done() } return } - if h.config.Mode == "stream-up" { + if h.config.Mode != "" && h.config.Mode != "auto" && h.config.Mode != "packet-up" { errors.LogInfo(context.Background(), "packet-up mode is not allowed") writer.WriteHeader(http.StatusBadRequest) return @@ -193,16 +207,18 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } writer.WriteHeader(http.StatusOK) - } else if request.Method == "GET" { + } else if request.Method == "GET" || sessionId == "" { responseFlusher, ok := writer.(http.Flusher) if !ok { panic("expected http.ResponseWriter to be an http.Flusher") } - // after GET is done, the connection is finished. disable automatic - // session reaping, and handle it in defer - currentSession.isFullyConnected.Close() - defer h.sessions.Delete(sessionId) + if sessionId != "" { + // after GET is done, the connection is finished. disable automatic + // session reaping, and handle it in defer + currentSession.isFullyConnected.Close() + defer h.sessions.Delete(sessionId) + } // magic header instructs nginx + apache to not buffer response body writer.Header().Set("X-Accel-Buffering", "no") @@ -210,7 +226,10 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req // Should be able to prevent overloading the cache, or stop CDNs from // teeing the response stream into their cache, causing slowdowns. writer.Header().Set("Cache-Control", "no-store") - if !h.config.NoSSEHeader { + + if request.Header.Get("Content-Type") == "application/grpc" { + writer.Header().Set("Content-Type", "application/grpc") + } else if !h.config.NoSSEHeader { // magic header to make the HTTP middle box consider this as SSE to disable buffer writer.Header().Set("Content-Type", "text/event-stream") } @@ -227,9 +246,12 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req downloadDone: downloadDone, responseFlusher: responseFlusher, }, - reader: currentSession.uploadQueue, + reader: request.Body, remoteAddr: remoteAddr, } + if sessionId != "" { + conn.reader = currentSession.uploadQueue + } h.ln.addConn(stat.Connection(&conn)) From c87cf8ff52270d98e92637150b404d9073f8d341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 29 Nov 2024 08:57:45 +0800 Subject: [PATCH 629/867] XHTTP config: Add `keepAlivePeriod` for client (#4075) Closes https://github.com/XTLS/Xray-core/issues/4053 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- infra/conf/transport_internet.go | 2 + transport/internet/splithttp/config.pb.go | 92 +++++++++++++---------- transport/internet/splithttp/config.proto | 1 + transport/internet/splithttp/dialer.go | 24 ++++-- 4 files changed, 73 insertions(+), 46 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index a87a6ecb..c1b06ea7 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -236,6 +236,7 @@ type SplitHTTPConfig struct { Mode string `json:"mode"` Extra json.RawMessage `json:"extra"` NoGRPCHeader bool `json:"noGRPCHeader"` + KeepAlivePeriod int64 `json:"keepAlivePeriod"` } type Xmux struct { @@ -324,6 +325,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { Xmux: &muxProtobuf, Mode: c.Mode, NoGRPCHeader: c.NoGRPCHeader, + KeepAlivePeriod: c.KeepAlivePeriod, } var err error if c.DownloadSettings != nil { diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 0ab85fd9..ad1d3ca9 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -38,6 +38,7 @@ type Config struct { DownloadSettings *internet.StreamConfig `protobuf:"bytes,10,opt,name=downloadSettings,proto3" json:"downloadSettings,omitempty"` Mode string `protobuf:"bytes,11,opt,name=mode,proto3" json:"mode,omitempty"` NoGRPCHeader bool `protobuf:"varint,12,opt,name=noGRPCHeader,proto3" json:"noGRPCHeader,omitempty"` + KeepAlivePeriod int64 `protobuf:"varint,13,opt,name=keepAlivePeriod,proto3" json:"keepAlivePeriod,omitempty"` } func (x *Config) Reset() { @@ -154,6 +155,13 @@ func (x *Config) GetNoGRPCHeader() bool { return false } +func (x *Config) GetKeepAlivePeriod() int64 { + if x != nil { + return x.KeepAlivePeriod + } + return 0 +} + type RandRangeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -286,7 +294,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x1a, 0x1f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0xba, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, + 0xe4, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, @@ -334,47 +342,49 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, - 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, - 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, - 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, - 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, - 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, - 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, - 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, - 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, - 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, - 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, - 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, - 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, - 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, - 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, + 0x72, 0x12, 0x28, 0x0a, 0x0f, 0x6b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, + 0x72, 0x69, 0x6f, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6b, 0x65, 0x65, 0x70, + 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, + 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, + 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, + 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, + 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, + 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, + 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, + 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, + 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, + 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, + 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, + 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, + 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, - 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, + 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, + 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, + 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, + 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, + 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index f6b10164..78b77b49 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -21,6 +21,7 @@ message Config { xray.transport.internet.StreamConfig downloadSettings = 10; string mode = 11; bool noGRPCHeader = 12; + int64 keepAlivePeriod = 13; } message RandRangeConfig { diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index df83bd92..4036dfc2 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -32,10 +32,10 @@ import ( const connIdleTimeout = 300 * time.Second // consistent with quic-go -const h3KeepalivePeriod = 10 * time.Second +const quicgoH3KeepAlivePeriod = 10 * time.Second // consistent with chrome -const h2KeepalivePeriod = 45 * time.Second +const chromeH2KeepAlivePeriod = 45 * time.Second type dialerConf struct { net.Destination @@ -133,9 +133,17 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea return conn, nil } + keepAlivePeriod := time.Duration(streamSettings.ProtocolSettings.(*Config).KeepAlivePeriod) * time.Second + var transport http.RoundTripper if isH3 { + if keepAlivePeriod == 0 { + keepAlivePeriod = quicgoH3KeepAlivePeriod + } + if keepAlivePeriod < 0 { + keepAlivePeriod = 0 + } quicConfig := &quic.Config{ MaxIdleTimeout: connIdleTimeout, @@ -143,7 +151,7 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea // http3) is different, so it is hardcoded here for clarity. // https://github.com/quic-go/quic-go/blob/b8ea5c798155950fb5bbfdd06cad1939c9355878/http3/client.go#L36-L39 MaxIncomingStreams: -1, - KeepAlivePeriod: h3KeepalivePeriod, + KeepAlivePeriod: keepAlivePeriod, } transport = &http3.RoundTripper{ QUICConfig: quicConfig, @@ -186,12 +194,18 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea }, } } else if isH2 { + if keepAlivePeriod == 0 { + keepAlivePeriod = chromeH2KeepAlivePeriod + } + if keepAlivePeriod < 0 { + keepAlivePeriod = 0 + } transport = &http2.Transport{ DialTLSContext: func(ctxInner context.Context, network string, addr string, cfg *gotls.Config) (net.Conn, error) { return dialContext(ctxInner) }, IdleConnTimeout: connIdleTimeout, - ReadIdleTimeout: h2KeepalivePeriod, + ReadIdleTimeout: keepAlivePeriod, } } else { httpDialContext := func(ctxInner context.Context, network string, addr string) (net.Conn, error) { @@ -202,7 +216,7 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea DialTLSContext: httpDialContext, DialContext: httpDialContext, IdleConnTimeout: connIdleTimeout, - // chunked transfer download with keepalives is buggy with + // chunked transfer download with KeepAlives is buggy with // http.Client and our custom dial context. DisableKeepAlives: true, } From 4f6f12616ccf0a715397b1dfcec4ce1c996fb96f Mon Sep 17 00:00:00 2001 From: hr567 Date: Fri, 29 Nov 2024 10:08:08 +0800 Subject: [PATCH 630/867] WebSocket config: Add `heartbeatPeriod` for client & server (#4065) https://github.com/XTLS/Xray-core/pull/4065#issuecomment-2502627154 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- infra/conf/transport_internet.go | 2 + .../internet/splithttp/browser_client.go | 2 +- transport/internet/websocket/config.pb.go | 41 ++++++++++++------- transport/internet/websocket/config.proto | 1 + transport/internet/websocket/connection.go | 13 +++++- transport/internet/websocket/dialer.go | 4 +- transport/internet/websocket/hub.go | 2 +- 7 files changed, 45 insertions(+), 20 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index c1b06ea7..428ba353 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -149,6 +149,7 @@ type WebSocketConfig struct { Path string `json:"path"` Headers map[string]string `json:"headers"` AcceptProxyProtocol bool `json:"acceptProxyProtocol"` + HeartbeatPeriod uint32 `json:"heartbeatPeriod"` } // Build implements Buildable. @@ -178,6 +179,7 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { Header: c.Headers, AcceptProxyProtocol: c.AcceptProxyProtocol, Ed: ed, + HeartbeatPeriod: c.HeartbeatPeriod, } return config, nil } diff --git a/transport/internet/splithttp/browser_client.go b/transport/internet/splithttp/browser_client.go index d56ba139..a0a584a9 100644 --- a/transport/internet/splithttp/browser_client.go +++ b/transport/internet/splithttp/browser_client.go @@ -29,7 +29,7 @@ func (c *BrowserDialerClient) OpenDownload(ctx context.Context, baseURL string) return nil, dummyAddr, dummyAddr, err } - return websocket.NewConnection(conn, dummyAddr, nil), conn.RemoteAddr(), conn.LocalAddr(), nil + return websocket.NewConnection(conn, dummyAddr, nil, 0), conn.RemoteAddr(), conn.LocalAddr(), nil } func (c *BrowserDialerClient) SendUploadRequest(ctx context.Context, url string, payload io.ReadWriteCloser, contentLength int64) error { diff --git a/transport/internet/websocket/config.pb.go b/transport/internet/websocket/config.pb.go index 518cf6e8..ff6a3868 100644 --- a/transport/internet/websocket/config.pb.go +++ b/transport/internet/websocket/config.pb.go @@ -30,6 +30,7 @@ type Config struct { Header map[string]string `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` AcceptProxyProtocol bool `protobuf:"varint,4,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` Ed uint32 `protobuf:"varint,5,opt,name=ed,proto3" json:"ed,omitempty"` + HeartbeatPeriod uint32 `protobuf:"varint,6,opt,name=heartbeatPeriod,proto3" json:"heartbeatPeriod,omitempty"` } func (x *Config) Reset() { @@ -97,6 +98,13 @@ func (x *Config) GetEd() uint32 { return 0 } +func (x *Config) GetHeartbeatPeriod() uint32 { + if x != nil { + return x.HeartbeatPeriod + } + return 0 +} + var File_transport_internet_websocket_config_proto protoreflect.FileDescriptor var file_transport_internet_websocket_config_proto_rawDesc = []byte{ @@ -104,8 +112,8 @@ var file_transport_internet_websocket_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x21, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x22, 0xfe, - 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x22, 0xa8, + 0x02, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, 0x28, @@ -117,19 +125,22 @@ var file_transport_internet_websocket_config_proto_rawDesc = []byte{ 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, - 0x52, 0x02, 0x65, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, - 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, - 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, - 0x6b, 0x65, 0x74, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x57, 0x65, - 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x52, 0x02, 0x65, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x68, 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, + 0x74, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x68, + 0x65, 0x61, 0x72, 0x74, 0x62, 0x65, 0x61, 0x74, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x1a, 0x39, + 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, + 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, + 0x6b, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, + 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x65, 0x74, 0x2f, 0x77, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0xaa, 0x02, 0x21, + 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x57, 0x65, 0x62, 0x73, 0x6f, 0x63, 0x6b, 0x65, + 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/websocket/config.proto b/transport/internet/websocket/config.proto index 6c6ce7dd..0ae73075 100644 --- a/transport/internet/websocket/config.proto +++ b/transport/internet/websocket/config.proto @@ -12,4 +12,5 @@ message Config { map header = 3; bool accept_proxy_protocol = 4; uint32 ed = 5; + uint32 heartbeatPeriod = 6; } diff --git a/transport/internet/websocket/connection.go b/transport/internet/websocket/connection.go index 3ccead47..26082fc6 100644 --- a/transport/internet/websocket/connection.go +++ b/transport/internet/websocket/connection.go @@ -22,7 +22,18 @@ type connection struct { remoteAddr net.Addr } -func NewConnection(conn *websocket.Conn, remoteAddr net.Addr, extraReader io.Reader) *connection { +func NewConnection(conn *websocket.Conn, remoteAddr net.Addr, extraReader io.Reader, heartbeatPeriod uint32) *connection { + if heartbeatPeriod != 0 { + go func() { + for { + time.Sleep(time.Duration(heartbeatPeriod) * time.Second) + if err := conn.WriteControl(websocket.PingMessage, []byte{}, time.Time{}); err != nil { + break + } + } + }() + } + return &connection{ conn: conn, remoteAddr: remoteAddr, diff --git a/transport/internet/websocket/dialer.go b/transport/internet/websocket/dialer.go index aa15c1a6..0659c7de 100644 --- a/transport/internet/websocket/dialer.go +++ b/transport/internet/websocket/dialer.go @@ -99,7 +99,7 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in return nil, err } - return NewConnection(conn, conn.RemoteAddr(), nil), nil + return NewConnection(conn, conn.RemoteAddr(), nil, wsSettings.HeartbeatPeriod), nil } header := wsSettings.GetRequestHeader() @@ -117,7 +117,7 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in return nil, errors.New("failed to dial to (", uri, "): ", reason).Base(err) } - return NewConnection(conn, conn.RemoteAddr(), nil), nil + return NewConnection(conn, conn.RemoteAddr(), nil, wsSettings.HeartbeatPeriod), nil } type delayDialConn struct { diff --git a/transport/internet/websocket/hub.go b/transport/internet/websocket/hub.go index 6e07d9a0..feefe2af 100644 --- a/transport/internet/websocket/hub.go +++ b/transport/internet/websocket/hub.go @@ -73,7 +73,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } } - h.ln.addConn(NewConnection(conn, remoteAddr, extraReader)) + h.ln.addConn(NewConnection(conn, remoteAddr, extraReader, h.ln.config.HeartbeatPeriod)) } type Listener struct { From 98a72b6fb49bcc403c4cae1ff529b9def43e6ad8 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 30 Nov 2024 04:16:35 +0000 Subject: [PATCH 631/867] v24.11.30 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 2 +- transport/internet/splithttp/hub.go | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/core/core.go b/core/core.go index dabdee9d..ac469065 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 24 Version_y byte = 11 - Version_z byte = 21 + Version_z byte = 30 ) var ( diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index f1002018..17e1deef 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -159,9 +159,6 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req errors.LogInfoInner(context.Background(), err, "failed to upload (PushReader)") writer.WriteHeader(http.StatusConflict) } else { - if request.Header.Get("Content-Type") == "application/grpc" { - writer.Header().Set("Content-Type", "application/grpc") - } writer.WriteHeader(http.StatusOK) <-request.Context().Done() } @@ -227,9 +224,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req // teeing the response stream into their cache, causing slowdowns. writer.Header().Set("Cache-Control", "no-store") - if request.Header.Get("Content-Type") == "application/grpc" { - writer.Header().Set("Content-Type", "application/grpc") - } else if !h.config.NoSSEHeader { + if !h.config.NoSSEHeader { // magic header to make the HTTP middle box consider this as SSE to disable buffer writer.Header().Set("Content-Type", "text/event-stream") } From ae62a0fb526f2faa0aa8b3fbce5a566187059090 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 2 Dec 2024 09:56:16 +0000 Subject: [PATCH 632/867] Transport: Remove HTTP Migrated to XHTTP "stream-one" mode. --- infra/conf/transport_internet.go | 181 ++++++---------- main/distro/all/all.go | 1 - testing/scenarios/tls_test.go | 123 ----------- transport/internet/http/config.go | 48 ----- transport/internet/http/config.pb.go | 193 ----------------- transport/internet/http/config.proto | 18 -- transport/internet/http/dialer.go | 311 --------------------------- transport/internet/http/http.go | 3 - transport/internet/http/http_test.go | 172 --------------- transport/internet/http/hub.go | 252 ---------------------- 10 files changed, 63 insertions(+), 1239 deletions(-) delete mode 100644 transport/internet/http/config.go delete mode 100644 transport/internet/http/config.pb.go delete mode 100644 transport/internet/http/config.proto delete mode 100644 transport/internet/http/dialer.go delete mode 100644 transport/internet/http/http.go delete mode 100644 transport/internet/http/http_test.go delete mode 100644 transport/internet/http/hub.go diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 428ba353..c62acee7 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -16,8 +16,6 @@ import ( "github.com/xtls/xray-core/common/platform/filesystem" "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/transport/internet" - httpheader "github.com/xtls/xray-core/transport/internet/headers/http" - "github.com/xtls/xray-core/transport/internet/http" "github.com/xtls/xray-core/transport/internet/httpupgrade" "github.com/xtls/xray-core/transport/internet/kcp" "github.com/xtls/xray-core/transport/internet/reality" @@ -344,51 +342,6 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { return config, nil } -type HTTPConfig struct { - Host *StringList `json:"host"` - Path string `json:"path"` - ReadIdleTimeout int32 `json:"read_idle_timeout"` - HealthCheckTimeout int32 `json:"health_check_timeout"` - Method string `json:"method"` - Headers map[string]*StringList `json:"headers"` -} - -// Build implements Buildable. -func (c *HTTPConfig) Build() (proto.Message, error) { - if c.ReadIdleTimeout <= 0 { - c.ReadIdleTimeout = 0 - } - if c.HealthCheckTimeout <= 0 { - c.HealthCheckTimeout = 0 - } - config := &http.Config{ - Path: c.Path, - IdleTimeout: c.ReadIdleTimeout, - HealthCheckTimeout: c.HealthCheckTimeout, - } - if c.Host != nil { - config.Host = []string(*c.Host) - } - if c.Method != "" { - config.Method = c.Method - } - if len(c.Headers) > 0 { - config.Header = make([]*httpheader.Header, 0, len(c.Headers)) - headerNames := sortMapKeys(c.Headers) - for _, key := range headerNames { - value := c.Headers[key] - if value == nil { - return nil, errors.New("empty HTTP header value: " + key).AtError() - } - config.Header = append(config.Header, &httpheader.Header{ - Name: key, - Value: append([]string(nil), (*value)...), - }) - } - } - return config, nil -} - func readFileOrString(f string, s []string) ([]byte, error) { if len(f) > 0 { return filesystem.ReadFile(f) @@ -709,20 +662,23 @@ func (p TransportProtocol) Build() (string, error) { switch strings.ToLower(string(p)) { case "raw", "tcp": return "tcp", nil - case "kcp", "mkcp": - return "mkcp", nil - case "ws", "websocket": - return "websocket", nil - case "h2", "h3", "http": - errors.PrintDeprecatedFeatureWarning("HTTP transport", "XHTTP transport") - return "http", nil - case "grpc": - errors.PrintMigrateFeatureInfo("gRPC transport", "XHTTP transport") - return "grpc", nil - case "httpupgrade": - return "httpupgrade", nil case "xhttp", "splithttp": return "splithttp", nil + case "kcp", "mkcp": + return "mkcp", nil + case "grpc": + errors.PrintDeprecatedFeatureWarning("gRPC transport (with unnecessary costs, etc.)", "XHTTP stream-up H2") + return "grpc", nil + case "ws", "websocket": + errors.PrintDeprecatedFeatureWarning("WebSocket transport (with ALPN http/1.1, etc.)", "XHTTP H2 & H3") + return "websocket", nil + case "httpupgrade": + errors.PrintDeprecatedFeatureWarning("HTTPUpgrade transport (with ALPN http/1.1, etc.)", "XHTTP H2 & H3") + return "httpupgrade", nil + case "h2", "h3", "http": + return "", errors.PrintRemovedFeatureError("HTTP transport (without header padding, etc.)", "XHTTP stream-one H2 & H3") + case "quic": + return "", errors.PrintRemovedFeatureError("QUIC transport (without web service, etc.)", "XHTTP stream-one H3") default: return "", errors.New("Config: unknown transport protocol: ", p) } @@ -852,14 +808,13 @@ type StreamConfig struct { REALITYSettings *REALITYConfig `json:"realitySettings"` RAWSettings *TCPConfig `json:"rawSettings"` TCPSettings *TCPConfig `json:"tcpSettings"` - KCPSettings *KCPConfig `json:"kcpSettings"` - WSSettings *WebSocketConfig `json:"wsSettings"` - HTTPSettings *HTTPConfig `json:"httpSettings"` - SocketSettings *SocketConfig `json:"sockopt"` - GRPCConfig *GRPCConfig `json:"grpcSettings"` - HTTPUPGRADESettings *HttpUpgradeConfig `json:"httpupgradeSettings"` XHTTPSettings *SplitHTTPConfig `json:"xhttpSettings"` SplitHTTPSettings *SplitHTTPConfig `json:"splithttpSettings"` + KCPSettings *KCPConfig `json:"kcpSettings"` + GRPCSettings *GRPCConfig `json:"grpcSettings"` + WSSettings *WebSocketConfig `json:"wsSettings"` + HTTPUPGRADESettings *HttpUpgradeConfig `json:"httpupgradeSettings"` + SocketSettings *SocketConfig `json:"sockopt"` } // Build implements Buildable. @@ -893,8 +848,8 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { config.SecuritySettings = append(config.SecuritySettings, tm) config.SecurityType = tm.Type case "reality": - if config.ProtocolName != "tcp" && config.ProtocolName != "http" && config.ProtocolName != "grpc" && config.ProtocolName != "splithttp" { - return nil, errors.New("REALITY only supports RAW, H2, gRPC and XHTTP for now.") + if config.ProtocolName != "tcp" && config.ProtocolName != "splithttp" && config.ProtocolName != "grpc" { + return nil, errors.New("REALITY only supports RAW, XHTTP and gRPC for now.") } if c.REALITYSettings == nil { return nil, errors.New(`REALITY: Empty "realitySettings".`) @@ -924,56 +879,6 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { Settings: serial.ToTypedMessage(ts), }) } - if c.KCPSettings != nil { - ts, err := c.KCPSettings.Build() - if err != nil { - return nil, errors.New("Failed to build mKCP config.").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "mkcp", - Settings: serial.ToTypedMessage(ts), - }) - } - if c.WSSettings != nil { - ts, err := c.WSSettings.Build() - if err != nil { - return nil, errors.New("Failed to build WebSocket config.").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "websocket", - Settings: serial.ToTypedMessage(ts), - }) - } - if c.HTTPSettings != nil { - ts, err := c.HTTPSettings.Build() - if err != nil { - return nil, errors.New("Failed to build HTTP config.").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "http", - Settings: serial.ToTypedMessage(ts), - }) - } - if c.GRPCConfig != nil { - gs, err := c.GRPCConfig.Build() - if err != nil { - return nil, errors.New("Failed to build gRPC config.").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "grpc", - Settings: serial.ToTypedMessage(gs), - }) - } - if c.HTTPUPGRADESettings != nil { - hs, err := c.HTTPUPGRADESettings.Build() - if err != nil { - return nil, errors.New("Failed to build HttpUpgrade config.").Base(err) - } - config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ - ProtocolName: "httpupgrade", - Settings: serial.ToTypedMessage(hs), - }) - } if c.XHTTPSettings != nil { c.SplitHTTPSettings = c.XHTTPSettings } @@ -987,10 +892,50 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) { Settings: serial.ToTypedMessage(hs), }) } + if c.KCPSettings != nil { + ts, err := c.KCPSettings.Build() + if err != nil { + return nil, errors.New("Failed to build mKCP config.").Base(err) + } + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ + ProtocolName: "mkcp", + Settings: serial.ToTypedMessage(ts), + }) + } + if c.GRPCSettings != nil { + gs, err := c.GRPCSettings.Build() + if err != nil { + return nil, errors.New("Failed to build gRPC config.").Base(err) + } + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ + ProtocolName: "grpc", + Settings: serial.ToTypedMessage(gs), + }) + } + if c.WSSettings != nil { + ts, err := c.WSSettings.Build() + if err != nil { + return nil, errors.New("Failed to build WebSocket config.").Base(err) + } + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ + ProtocolName: "websocket", + Settings: serial.ToTypedMessage(ts), + }) + } + if c.HTTPUPGRADESettings != nil { + hs, err := c.HTTPUPGRADESettings.Build() + if err != nil { + return nil, errors.New("Failed to build HTTPUpgrade config.").Base(err) + } + config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{ + ProtocolName: "httpupgrade", + Settings: serial.ToTypedMessage(hs), + }) + } if c.SocketSettings != nil { ss, err := c.SocketSettings.Build() if err != nil { - return nil, errors.New("Failed to build sockopt").Base(err) + return nil, errors.New("Failed to build sockopt.").Base(err) } config.SocketSettings = ss } diff --git a/main/distro/all/all.go b/main/distro/all/all.go index 4e9ac3c0..198abb3f 100644 --- a/main/distro/all/all.go +++ b/main/distro/all/all.go @@ -51,7 +51,6 @@ import ( // Transports _ "github.com/xtls/xray-core/transport/internet/grpc" - _ "github.com/xtls/xray-core/transport/internet/http" _ "github.com/xtls/xray-core/transport/internet/httpupgrade" _ "github.com/xtls/xray-core/transport/internet/kcp" _ "github.com/xtls/xray-core/transport/internet/reality" diff --git a/testing/scenarios/tls_test.go b/testing/scenarios/tls_test.go index ffe43300..a8abccd7 100644 --- a/testing/scenarios/tls_test.go +++ b/testing/scenarios/tls_test.go @@ -23,7 +23,6 @@ import ( "github.com/xtls/xray-core/testing/servers/udp" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/grpc" - "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" @@ -458,128 +457,6 @@ func TestTLSOverWebSocket(t *testing.T) { } } -func TestHTTP2(t *testing.T) { - tcpServer := tcp.Server{ - MsgProcessor: xor, - } - dest, err := tcpServer.Start() - common.Must(err) - defer tcpServer.Close() - - userID := protocol.NewID(uuid.New()) - serverPort := tcp.PickPort() - serverConfig := &core.Config{ - Inbound: []*core.InboundHandlerConfig{ - { - ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ - PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(serverPort)}}, - Listen: net.NewIPOrDomain(net.LocalHostIP), - StreamSettings: &internet.StreamConfig{ - ProtocolName: "http", - TransportSettings: []*internet.TransportConfig{ - { - ProtocolName: "http", - Settings: serial.ToTypedMessage(&http.Config{ - Host: []string{"example.com"}, - Path: "/testpath", - }), - }, - }, - SecurityType: serial.GetMessageType(&tls.Config{}), - SecuritySettings: []*serial.TypedMessage{ - serial.ToTypedMessage(&tls.Config{ - Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil))}, - }), - }, - }, - }), - ProxySettings: serial.ToTypedMessage(&inbound.Config{ - User: []*protocol.User{ - { - Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - }), - }, - }, - }), - }, - }, - Outbound: []*core.OutboundHandlerConfig{ - { - ProxySettings: serial.ToTypedMessage(&freedom.Config{}), - }, - }, - } - - clientPort := tcp.PickPort() - clientConfig := &core.Config{ - Inbound: []*core.InboundHandlerConfig{ - { - ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ - PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, - Listen: net.NewIPOrDomain(net.LocalHostIP), - }), - ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ - Address: net.NewIPOrDomain(dest.Address), - Port: uint32(dest.Port), - Networks: []net.Network{net.Network_TCP}, - }), - }, - }, - Outbound: []*core.OutboundHandlerConfig{ - { - ProxySettings: serial.ToTypedMessage(&outbound.Config{ - Receiver: []*protocol.ServerEndpoint{ - { - Address: net.NewIPOrDomain(net.LocalHostIP), - Port: uint32(serverPort), - User: []*protocol.User{ - { - Account: serial.ToTypedMessage(&vmess.Account{ - Id: userID.String(), - }), - }, - }, - }, - }, - }), - SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{ - StreamSettings: &internet.StreamConfig{ - ProtocolName: "http", - TransportSettings: []*internet.TransportConfig{ - { - ProtocolName: "http", - Settings: serial.ToTypedMessage(&http.Config{ - Host: []string{"example.com"}, - Path: "/testpath", - }), - }, - }, - SecurityType: serial.GetMessageType(&tls.Config{}), - SecuritySettings: []*serial.TypedMessage{ - serial.ToTypedMessage(&tls.Config{ - AllowInsecure: true, - }), - }, - }, - }), - }, - }, - } - - servers, err := InitializeServerConfigs(serverConfig, clientConfig) - common.Must(err) - defer CloseAllServers(servers) - - var errg errgroup.Group - for i := 0; i < 10; i++ { - errg.Go(testTCPConn(clientPort, 1024*1024, time.Second*40)) - } - if err := errg.Wait(); err != nil { - t.Error(err) - } -} - func TestGRPC(t *testing.T) { tcpServer := tcp.Server{ MsgProcessor: xor, diff --git a/transport/internet/http/config.go b/transport/internet/http/config.go deleted file mode 100644 index 1cd7d058..00000000 --- a/transport/internet/http/config.go +++ /dev/null @@ -1,48 +0,0 @@ -package http - -import ( - "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/common/dice" - "github.com/xtls/xray-core/transport/internet" -) - -func (c *Config) getHosts() []string { - if len(c.Host) == 0 { - return []string{""} - } - return c.Host -} - -func (c *Config) isValidHost(host string) bool { - if len(c.Host) == 0 { - return true - } - hosts := c.getHosts() - for _, h := range hosts { - if internet.IsValidHTTPHost(host, h) { - return true - } - } - return false -} - -func (c *Config) getRandomHost() string { - hosts := c.getHosts() - return hosts[dice.Roll(len(hosts))] -} - -func (c *Config) getNormalizedPath() string { - if c.Path == "" { - return "/" - } - if c.Path[0] != '/' { - return "/" + c.Path - } - return c.Path -} - -func init() { - common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { - return new(Config) - })) -} diff --git a/transport/internet/http/config.pb.go b/transport/internet/http/config.pb.go deleted file mode 100644 index c3e9b89f..00000000 --- a/transport/internet/http/config.pb.go +++ /dev/null @@ -1,193 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.35.1 -// protoc v5.28.2 -// source: transport/internet/http/config.proto - -package http - -import ( - http "github.com/xtls/xray-core/transport/internet/headers/http" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type Config struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Host []string `protobuf:"bytes,1,rep,name=host,proto3" json:"host,omitempty"` - Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - IdleTimeout int32 `protobuf:"varint,3,opt,name=idle_timeout,json=idleTimeout,proto3" json:"idle_timeout,omitempty"` - HealthCheckTimeout int32 `protobuf:"varint,4,opt,name=health_check_timeout,json=healthCheckTimeout,proto3" json:"health_check_timeout,omitempty"` - Method string `protobuf:"bytes,5,opt,name=method,proto3" json:"method,omitempty"` - Header []*http.Header `protobuf:"bytes,6,rep,name=header,proto3" json:"header,omitempty"` -} - -func (x *Config) Reset() { - *x = Config{} - mi := &file_transport_internet_http_config_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Config) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Config) ProtoMessage() {} - -func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_transport_internet_http_config_proto_msgTypes[0] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Config.ProtoReflect.Descriptor instead. -func (*Config) Descriptor() ([]byte, []int) { - return file_transport_internet_http_config_proto_rawDescGZIP(), []int{0} -} - -func (x *Config) GetHost() []string { - if x != nil { - return x.Host - } - return nil -} - -func (x *Config) GetPath() string { - if x != nil { - return x.Path - } - return "" -} - -func (x *Config) GetIdleTimeout() int32 { - if x != nil { - return x.IdleTimeout - } - return 0 -} - -func (x *Config) GetHealthCheckTimeout() int32 { - if x != nil { - return x.HealthCheckTimeout - } - return 0 -} - -func (x *Config) GetMethod() string { - if x != nil { - return x.Method - } - return "" -} - -func (x *Config) GetHeader() []*http.Header { - if x != nil { - return x.Header - } - return nil -} - -var File_transport_internet_http_config_proto protoreflect.FileDescriptor - -var file_transport_internet_http_config_proto_rawDesc = []byte{ - 0x0a, 0x24, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1c, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, - 0x68, 0x74, 0x74, 0x70, 0x1a, 0x2c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, - 0x2f, 0x68, 0x74, 0x74, 0x70, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0xe3, 0x01, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, - 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, - 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x64, 0x6c, 0x65, 0x5f, 0x74, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x69, 0x64, 0x6c, - 0x65, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x30, 0x0a, 0x14, 0x68, 0x65, 0x61, 0x6c, - 0x74, 0x68, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x12, 0x68, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, - 0x65, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, - 0x74, 0x68, 0x6f, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x12, 0x44, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x73, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x42, 0x76, 0x0a, 0x20, 0x63, 0x6f, 0x6d, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x31, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, - 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x68, 0x74, 0x74, - 0x70, 0xaa, 0x02, 0x1c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x48, 0x74, 0x74, 0x70, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_transport_internet_http_config_proto_rawDescOnce sync.Once - file_transport_internet_http_config_proto_rawDescData = file_transport_internet_http_config_proto_rawDesc -) - -func file_transport_internet_http_config_proto_rawDescGZIP() []byte { - file_transport_internet_http_config_proto_rawDescOnce.Do(func() { - file_transport_internet_http_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_transport_internet_http_config_proto_rawDescData) - }) - return file_transport_internet_http_config_proto_rawDescData -} - -var file_transport_internet_http_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_transport_internet_http_config_proto_goTypes = []any{ - (*Config)(nil), // 0: xray.transport.internet.http.Config - (*http.Header)(nil), // 1: xray.transport.internet.headers.http.Header -} -var file_transport_internet_http_config_proto_depIdxs = []int32{ - 1, // 0: xray.transport.internet.http.Config.header:type_name -> xray.transport.internet.headers.http.Header - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_transport_internet_http_config_proto_init() } -func file_transport_internet_http_config_proto_init() { - if File_transport_internet_http_config_proto != nil { - return - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_transport_internet_http_config_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_transport_internet_http_config_proto_goTypes, - DependencyIndexes: file_transport_internet_http_config_proto_depIdxs, - MessageInfos: file_transport_internet_http_config_proto_msgTypes, - }.Build() - File_transport_internet_http_config_proto = out.File - file_transport_internet_http_config_proto_rawDesc = nil - file_transport_internet_http_config_proto_goTypes = nil - file_transport_internet_http_config_proto_depIdxs = nil -} diff --git a/transport/internet/http/config.proto b/transport/internet/http/config.proto deleted file mode 100644 index 82f5cbeb..00000000 --- a/transport/internet/http/config.proto +++ /dev/null @@ -1,18 +0,0 @@ -syntax = "proto3"; - -package xray.transport.internet.http; -option csharp_namespace = "Xray.Transport.Internet.Http"; -option go_package = "github.com/xtls/xray-core/transport/internet/http"; -option java_package = "com.xray.transport.internet.http"; -option java_multiple_files = true; - -import "transport/internet/headers/http/config.proto"; - -message Config { - repeated string host = 1; - string path = 2; - int32 idle_timeout = 3; - int32 health_check_timeout = 4; - string method = 5; - repeated xray.transport.internet.headers.http.Header header = 6; -} diff --git a/transport/internet/http/dialer.go b/transport/internet/http/dialer.go deleted file mode 100644 index 42a9f9b3..00000000 --- a/transport/internet/http/dialer.go +++ /dev/null @@ -1,311 +0,0 @@ -package http - -import ( - "context" - gotls "crypto/tls" - "io" - "net/http" - "net/url" - "sync" - "time" - - "github.com/quic-go/quic-go" - "github.com/quic-go/quic-go/http3" - "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/common/buf" - c "github.com/xtls/xray-core/common/ctx" - "github.com/xtls/xray-core/common/errors" - "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/transport/internet" - "github.com/xtls/xray-core/transport/internet/reality" - "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" -) - -// defines the maximum time an idle TCP session can survive in the tunnel, so -// it should be consistent across HTTP versions and with other transports. -const connIdleTimeout = 300 * time.Second - -// consistent with quic-go -const h3KeepalivePeriod = 10 * time.Second - -type dialerConf struct { - net.Destination - *internet.MemoryStreamConfig -} - -var ( - globalDialerMap map[dialerConf]*http.Client - globalDialerAccess sync.Mutex -) - -func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (*http.Client, error) { - globalDialerAccess.Lock() - defer globalDialerAccess.Unlock() - - if globalDialerMap == nil { - globalDialerMap = make(map[dialerConf]*http.Client) - } - - httpSettings := streamSettings.ProtocolSettings.(*Config) - tlsConfigs := tls.ConfigFromStreamSettings(streamSettings) - realityConfigs := reality.ConfigFromStreamSettings(streamSettings) - if tlsConfigs == nil && realityConfigs == nil { - return nil, errors.New("TLS or REALITY must be enabled for http transport.").AtWarning() - } - isH3 := tlsConfigs != nil && (len(tlsConfigs.NextProtocol) == 1 && tlsConfigs.NextProtocol[0] == "h3") - if isH3 { - dest.Network = net.Network_UDP - } - sockopt := streamSettings.SocketSettings - - if client, found := globalDialerMap[dialerConf{dest, streamSettings}]; found { - return client, nil - } - - var transport http.RoundTripper - if isH3 { - quicConfig := &quic.Config{ - MaxIdleTimeout: connIdleTimeout, - - // these two are defaults of quic-go/http3. the default of quic-go (no - // http3) is different, so it is hardcoded here for clarity. - // https://github.com/quic-go/quic-go/blob/b8ea5c798155950fb5bbfdd06cad1939c9355878/http3/client.go#L36-L39 - MaxIncomingStreams: -1, - KeepAlivePeriod: h3KeepalivePeriod, - } - roundTripper := &http3.RoundTripper{ - QUICConfig: quicConfig, - TLSClientConfig: tlsConfigs.GetTLSConfig(tls.WithDestination(dest)), - Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { - conn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) - if err != nil { - return nil, err - } - - var udpConn net.PacketConn - var udpAddr *net.UDPAddr - - switch c := conn.(type) { - case *internet.PacketConnWrapper: - var ok bool - udpConn, ok = c.Conn.(*net.UDPConn) - if !ok { - return nil, errors.New("PacketConnWrapper does not contain a UDP connection") - } - udpAddr, err = net.ResolveUDPAddr("udp", c.Dest.String()) - if err != nil { - return nil, err - } - case *net.UDPConn: - udpConn = c - udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) - if err != nil { - return nil, err - } - default: - udpConn = &internet.FakePacketConn{c} - udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) - if err != nil { - return nil, err - } - } - - return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg) - }, - } - transport = roundTripper - } else { - transportH2 := &http2.Transport{ - DialTLSContext: func(hctx context.Context, string, addr string, tlsConfig *gotls.Config) (net.Conn, error) { - rawHost, rawPort, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - if len(rawPort) == 0 { - rawPort = "443" - } - port, err := net.PortFromString(rawPort) - if err != nil { - return nil, err - } - address := net.ParseAddress(rawHost) - - hctx = c.ContextWithID(hctx, c.IDFromContext(ctx)) - hctx = session.ContextWithOutbounds(hctx, session.OutboundsFromContext(ctx)) - hctx = session.ContextWithTimeoutOnly(hctx, true) - - pconn, err := internet.DialSystem(hctx, net.TCPDestination(address, port), sockopt) - if err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to "+addr) - return nil, err - } - - if realityConfigs != nil { - return reality.UClient(pconn, realityConfigs, hctx, dest) - } - - var cn tls.Interface - if fingerprint := tls.GetFingerprint(tlsConfigs.Fingerprint); fingerprint != nil { - cn = tls.UClient(pconn, tlsConfig, fingerprint).(*tls.UConn) - } else { - cn = tls.Client(pconn, tlsConfig).(*tls.Conn) - } - if err := cn.HandshakeContext(ctx); err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to "+addr) - return nil, err - } - if !tlsConfig.InsecureSkipVerify { - if err := cn.VerifyHostname(tlsConfig.ServerName); err != nil { - errors.LogErrorInner(ctx, err, "failed to dial to "+addr) - return nil, err - } - } - negotiatedProtocol := cn.NegotiatedProtocol() - if negotiatedProtocol != http2.NextProtoTLS { - return nil, errors.New("http2: unexpected ALPN protocol " + negotiatedProtocol + "; want q" + http2.NextProtoTLS).AtError() - } - return cn, nil - }, - } - if tlsConfigs != nil { - transportH2.TLSClientConfig = tlsConfigs.GetTLSConfig(tls.WithDestination(dest)) - } - if httpSettings.IdleTimeout > 0 || httpSettings.HealthCheckTimeout > 0 { - transportH2.ReadIdleTimeout = time.Second * time.Duration(httpSettings.IdleTimeout) - transportH2.PingTimeout = time.Second * time.Duration(httpSettings.HealthCheckTimeout) - } - transport = transportH2 - } - - client := &http.Client{ - Transport: transport, - } - - globalDialerMap[dialerConf{dest, streamSettings}] = client - return client, nil -} - -// Dial dials a new TCP connection to the given destination. -func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) { - httpSettings := streamSettings.ProtocolSettings.(*Config) - client, err := getHTTPClient(ctx, dest, streamSettings) - if err != nil { - return nil, err - } - - opts := pipe.OptionsFromContext(ctx) - preader, pwriter := pipe.New(opts...) - breader := &buf.BufferedReader{Reader: preader} - - httpMethod := "PUT" - if httpSettings.Method != "" { - httpMethod = httpSettings.Method - } - - httpHeaders := make(http.Header) - - for _, httpHeader := range httpSettings.Header { - for _, httpHeaderValue := range httpHeader.Value { - httpHeaders.Set(httpHeader.Name, httpHeaderValue) - } - } - - Host := httpSettings.getRandomHost() - if Host == "" && net.ParseAddress(dest.NetAddr()).Family().IsDomain() { - Host = dest.Address.String() - } else if Host == "" { - Host = "www.example.com" - } - - request := &http.Request{ - Method: httpMethod, - Host: Host, - Body: breader, - URL: &url.URL{ - Scheme: "https", - Host: dest.NetAddr(), - Path: httpSettings.getNormalizedPath(), - }, - Header: httpHeaders, - } - // Disable any compression method from server. - request.Header.Set("Accept-Encoding", "identity") - - wrc := &WaitReadCloser{Wait: make(chan struct{})} - go func() { - response, err := client.Do(request) - if err != nil || response.StatusCode != 200 { - if err != nil { - errors.LogWarningInner(ctx, err, "failed to dial to ", dest) - } else { - errors.LogWarning(ctx, "unexpected status ", response.StatusCode) - } - wrc.Close() - { - // Abandon `client` if `client.Do(request)` failed - // See https://github.com/golang/go/issues/30702 - globalDialerAccess.Lock() - if globalDialerMap[dialerConf{dest, streamSettings}] == client { - delete(globalDialerMap, dialerConf{dest, streamSettings}) - } - globalDialerAccess.Unlock() - } - return - } - wrc.Set(response.Body) - }() - - bwriter := buf.NewBufferedWriter(pwriter) - common.Must(bwriter.SetBuffered(false)) - return cnc.NewConnection( - cnc.ConnectionOutput(wrc), - cnc.ConnectionInput(bwriter), - cnc.ConnectionOnClose(common.ChainedClosable{breader, bwriter, wrc}), - ), nil -} - -func init() { - common.Must(internet.RegisterTransportDialer(protocolName, Dial)) -} - -type WaitReadCloser struct { - Wait chan struct{} - io.ReadCloser -} - -func (w *WaitReadCloser) Set(rc io.ReadCloser) { - w.ReadCloser = rc - defer func() { - if recover() != nil { - rc.Close() - } - }() - close(w.Wait) -} - -func (w *WaitReadCloser) Read(b []byte) (int, error) { - if w.ReadCloser == nil { - if <-w.Wait; w.ReadCloser == nil { - return 0, io.ErrClosedPipe - } - } - return w.ReadCloser.Read(b) -} - -func (w *WaitReadCloser) Close() error { - if w.ReadCloser != nil { - return w.ReadCloser.Close() - } - defer func() { - if recover() != nil && w.ReadCloser != nil { - w.ReadCloser.Close() - } - }() - close(w.Wait) - return nil -} diff --git a/transport/internet/http/http.go b/transport/internet/http/http.go deleted file mode 100644 index a6343422..00000000 --- a/transport/internet/http/http.go +++ /dev/null @@ -1,3 +0,0 @@ -package http - -const protocolName = "http" diff --git a/transport/internet/http/http_test.go b/transport/internet/http/http_test.go deleted file mode 100644 index 1b3afa80..00000000 --- a/transport/internet/http/http_test.go +++ /dev/null @@ -1,172 +0,0 @@ -package http_test - -import ( - "context" - "crypto/rand" - "testing" - "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" - "github.com/xtls/xray-core/common/protocol/tls/cert" - "github.com/xtls/xray-core/testing/servers/tcp" - "github.com/xtls/xray-core/testing/servers/udp" - "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" -) - -func TestHTTPConnection(t *testing.T) { - port := tcp.PickPort() - - listener, err := Listen(context.Background(), net.LocalHostIP, port, &internet.MemoryStreamConfig{ - ProtocolName: "http", - ProtocolSettings: &Config{}, - SecurityType: "tls", - SecuritySettings: &tls.Config{ - Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("www.example.com")))}, - }, - }, func(conn stat.Connection) { - go func() { - defer conn.Close() - - b := buf.New() - defer b.Release() - - for { - if _, err := b.ReadFrom(conn); err != nil { - return - } - _, err := conn.Write(b.Bytes()) - common.Must(err) - } - }() - }) - common.Must(err) - - defer listener.Close() - - time.Sleep(time.Second) - - dctx := context.Background() - conn, err := Dial(dctx, net.TCPDestination(net.LocalHostIP, port), &internet.MemoryStreamConfig{ - ProtocolName: "http", - ProtocolSettings: &Config{}, - SecurityType: "tls", - SecuritySettings: &tls.Config{ - ServerName: "www.example.com", - AllowInsecure: true, - }, - }) - common.Must(err) - defer conn.Close() - - const N = 1024 - b1 := make([]byte, N) - common.Must2(rand.Read(b1)) - b2 := buf.New() - - nBytes, err := conn.Write(b1) - common.Must(err) - if nBytes != N { - t.Error("write: ", nBytes) - } - - b2.Clear() - common.Must2(b2.ReadFullFrom(conn, N)) - if r := cmp.Diff(b2.Bytes(), b1); r != "" { - t.Error(r) - } - - nBytes, err = conn.Write(b1) - common.Must(err) - if nBytes != N { - t.Error("write: ", nBytes) - } - - b2.Clear() - common.Must2(b2.ReadFullFrom(conn, N)) - if r := cmp.Diff(b2.Bytes(), b1); r != "" { - t.Error(r) - } -} - -func TestH3Connection(t *testing.T) { - port := udp.PickPort() - - listener, err := Listen(context.Background(), net.LocalHostIP, port, &internet.MemoryStreamConfig{ - ProtocolName: "http", - ProtocolSettings: &Config{}, - SecurityType: "tls", - SecuritySettings: &tls.Config{ - NextProtocol: []string{"h3"}, - Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("www.example.com")))}, - }, - }, func(conn stat.Connection) { - go func() { - defer conn.Close() - - b := buf.New() - defer b.Release() - - for { - if _, err := b.ReadFrom(conn); err != nil { - return - } - _, err := conn.Write(b.Bytes()) - common.Must(err) - } - }() - }) - common.Must(err) - - defer listener.Close() - - time.Sleep(time.Second) - - dctx := context.Background() - conn, err := Dial(dctx, net.TCPDestination(net.LocalHostIP, port), &internet.MemoryStreamConfig{ - ProtocolName: "http", - ProtocolSettings: &Config{}, - SecurityType: "tls", - SecuritySettings: &tls.Config{ - NextProtocol: []string{"h3"}, - ServerName: "www.example.com", - AllowInsecure: true, - }, - }) - common.Must(err) - defer conn.Close() - - const N = 1024 - b1 := make([]byte, N) - common.Must2(rand.Read(b1)) - b2 := buf.New() - - nBytes, err := conn.Write(b1) - common.Must(err) - if nBytes != N { - t.Error("write: ", nBytes) - } - - b2.Clear() - common.Must2(b2.ReadFullFrom(conn, N)) - if r := cmp.Diff(b2.Bytes(), b1); r != "" { - t.Error(r) - } - - nBytes, err = conn.Write(b1) - common.Must(err) - if nBytes != N { - t.Error("write: ", nBytes) - } - - b2.Clear() - common.Must2(b2.ReadFullFrom(conn, N)) - if r := cmp.Diff(b2.Bytes(), b1); r != "" { - t.Error(r) - } -} diff --git a/transport/internet/http/hub.go b/transport/internet/http/hub.go deleted file mode 100644 index 1fac2b73..00000000 --- a/transport/internet/http/hub.go +++ /dev/null @@ -1,252 +0,0 @@ -package http - -import ( - "context" - gotls "crypto/tls" - "io" - "net/http" - "strings" - "time" - - "github.com/quic-go/quic-go" - "github.com/quic-go/quic-go/http3" - goreality "github.com/xtls/reality" - "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/common/net/cnc" - http_proto "github.com/xtls/xray-core/common/protocol/http" - "github.com/xtls/xray-core/common/serial" - "github.com/xtls/xray-core/common/signal/done" - "github.com/xtls/xray-core/transport/internet" - "github.com/xtls/xray-core/transport/internet/reality" - "github.com/xtls/xray-core/transport/internet/tls" - "golang.org/x/net/http2" - "golang.org/x/net/http2/h2c" -) - -type Listener struct { - server *http.Server - h3server *http3.Server - handler internet.ConnHandler - local net.Addr - config *Config - isH3 bool -} - -func (l *Listener) Addr() net.Addr { - return l.local -} - -func (l *Listener) Close() error { - if l.h3server != nil { - if err := l.h3server.Close(); err != nil { - return err - } - } else if l.server != nil { - return l.server.Close() - } - return errors.New("listener does not have an HTTP/3 server or h2 server") -} - -type flushWriter struct { - w io.Writer - d *done.Instance -} - -func (fw flushWriter) Write(p []byte) (n int, err error) { - if fw.d.Done() { - return 0, io.ErrClosedPipe - } - - defer func() { - if recover() != nil { - fw.d.Close() - err = io.ErrClosedPipe - } - }() - - n, err = fw.w.Write(p) - if f, ok := fw.w.(http.Flusher); ok && err == nil { - f.Flush() - } - return -} - -func (l *Listener) ServeHTTP(writer http.ResponseWriter, request *http.Request) { - host := request.Host - if !l.config.isValidHost(host) { - writer.WriteHeader(404) - return - } - path := l.config.getNormalizedPath() - if !strings.HasPrefix(request.URL.Path, path) { - writer.WriteHeader(404) - return - } - - writer.Header().Set("Cache-Control", "no-store") - - for _, httpHeader := range l.config.Header { - for _, httpHeaderValue := range httpHeader.Value { - writer.Header().Set(httpHeader.Name, httpHeaderValue) - } - } - - writer.WriteHeader(200) - if f, ok := writer.(http.Flusher); ok { - f.Flush() - } - - remoteAddr := l.Addr() - dest, err := net.ParseDestination(request.RemoteAddr) - if err != nil { - errors.LogInfoInner(context.Background(), err, "failed to parse request remote addr: ", request.RemoteAddr) - } else { - remoteAddr = &net.TCPAddr{ - IP: dest.Address.IP(), - Port: int(dest.Port), - } - } - - forwardedAddress := http_proto.ParseXForwardedFor(request.Header) - if len(forwardedAddress) > 0 && forwardedAddress[0].Family().IsIP() { - remoteAddr = &net.TCPAddr{ - IP: forwardedAddress[0].IP(), - Port: 0, - } - } - - done := done.New() - conn := cnc.NewConnection( - cnc.ConnectionOutput(request.Body), - cnc.ConnectionInput(flushWriter{w: writer, d: done}), - cnc.ConnectionOnClose(common.ChainedClosable{done, request.Body}), - cnc.ConnectionLocalAddr(l.Addr()), - cnc.ConnectionRemoteAddr(remoteAddr), - ) - l.handler(conn) - <-done.Wait() -} - -func Listen(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, handler internet.ConnHandler) (internet.Listener, error) { - httpSettings := streamSettings.ProtocolSettings.(*Config) - config := tls.ConfigFromStreamSettings(streamSettings) - var tlsConfig *gotls.Config - if config == nil { - tlsConfig = &gotls.Config{} - } else { - tlsConfig = config.GetTLSConfig() - } - isH3 := len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "h3" - listener := &Listener{ - handler: handler, - config: httpSettings, - isH3: isH3, - } - if port == net.Port(0) { // unix - listener.local = &net.UnixAddr{ - Name: address.Domain(), - Net: "unix", - } - } else if isH3 { // udp - listener.local = &net.UDPAddr{ - IP: address.IP(), - Port: int(port), - } - } else { - listener.local = &net.TCPAddr{ - IP: address.IP(), - Port: int(port), - } - } - - if streamSettings.SocketSettings != nil && streamSettings.SocketSettings.AcceptProxyProtocol { - errors.LogWarning(ctx, "accepting PROXY protocol") - } - - if isH3 { - Conn, err := internet.ListenSystemPacket(context.Background(), listener.local, streamSettings.SocketSettings) - if err != nil { - return nil, errors.New("failed to listen UDP(for SH3) on ", address, ":", port).Base(err) - } - h3listener, err := quic.ListenEarly(Conn, tlsConfig, nil) - if err != nil { - return nil, errors.New("failed to listen QUIC(for SH3) on ", address, ":", port).Base(err) - } - errors.LogInfo(ctx, "listening QUIC(for SH3) on ", address, ":", port) - - listener.h3server = &http3.Server{ - Handler: listener, - } - go func() { - if err := listener.h3server.ServeListener(h3listener); err != nil { - errors.LogWarningInner(ctx, err, "failed to serve http3 for splithttp") - } - }() - } else { - var server *http.Server - if config == nil { - h2s := &http2.Server{} - - server = &http.Server{ - Addr: serial.Concat(address, ":", port), - Handler: h2c.NewHandler(listener, h2s), - ReadHeaderTimeout: time.Second * 4, - } - } else { - server = &http.Server{ - Addr: serial.Concat(address, ":", port), - TLSConfig: config.GetTLSConfig(tls.WithNextProto("h2")), - Handler: listener, - ReadHeaderTimeout: time.Second * 4, - } - } - - listener.server = server - go func() { - var streamListener net.Listener - var err error - if port == net.Port(0) { // unix - streamListener, err = internet.ListenSystem(ctx, &net.UnixAddr{ - Name: address.Domain(), - Net: "unix", - }, streamSettings.SocketSettings) - if err != nil { - errors.LogErrorInner(ctx, err, "failed to listen on ", address) - return - } - } else { // tcp - streamListener, err = internet.ListenSystem(ctx, &net.TCPAddr{ - IP: address.IP(), - Port: int(port), - }, streamSettings.SocketSettings) - if err != nil { - errors.LogErrorInner(ctx, err, "failed to listen on ", address, ":", port) - return - } - } - - if config == nil { - if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { - streamListener = goreality.NewListener(streamListener, config.GetREALITYConfig()) - } - err = server.Serve(streamListener) - if err != nil { - errors.LogInfoInner(ctx, err, "stopping serving H2C or REALITY H2") - } - } else { - err = server.ServeTLS(streamListener, "", "") - if err != nil { - errors.LogInfoInner(ctx, err, "stopping serving TLS H2") - } - } - }() - } - - return listener, nil -} - -func init() { - common.Must(internet.RegisterTransportListener(protocolName, Listen)) -} From 3e7002d24c4ede6158fd4267914553bb98348c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 6 Dec 2024 22:10:50 +0800 Subject: [PATCH 633/867] WireGuard inbound: Add missing inbound session information back (#4126) Fixes https://github.com/XTLS/Xray-core/issues/4121 --- proxy/wireguard/server.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/proxy/wireguard/server.go b/proxy/wireguard/server.go index 8ab84fe4..bdf27568 100644 --- a/proxy/wireguard/server.go +++ b/proxy/wireguard/server.go @@ -144,14 +144,15 @@ func (s *Server) forwardConnection(dest net.Destination, conn net.Conn) { Reason: "", }) + if s.info.inboundTag != nil { + ctx = session.ContextWithInbound(ctx, s.info.inboundTag) + } + // what's this? // Session information should not be shared between different connections // why reuse them in server level? This will cause incorrect destoverride and unexpected routing behavior. // Disable it temporarily. Maybe s.info should be removed. - // if s.info.inboundTag != nil { - // ctx = session.ContextWithInbound(ctx, s.info.inboundTag) - // } // if s.info.outboundTag != nil { // ctx = session.ContextWithOutbounds(ctx, []*session.Outbound{s.info.outboundTag}) // } From 34141c940e70f1c509a90ac97662710aa26fdd94 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 23:55:10 +0000 Subject: [PATCH 634/867] Bump golang.org/x/net from 0.31.0 to 0.32.0 (#4110) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.31.0 to 0.32.0. - [Commits](https://github.com/golang/net/compare/v0.31.0...v0.32.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index facbf223..1d8631a7 100644 --- a/go.mod +++ b/go.mod @@ -22,10 +22,10 @@ require ( github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.29.0 - golang.org/x/net v0.31.0 - golang.org/x/sync v0.9.0 - golang.org/x/sys v0.27.0 + golang.org/x/crypto v0.30.0 + golang.org/x/net v0.32.0 + golang.org/x/sync v0.10.0 + golang.org/x/sys v0.28.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.67.1 google.golang.org/protobuf v1.35.2 @@ -51,7 +51,7 @@ require ( go.uber.org/mock v0.4.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/mod v0.18.0 // indirect - golang.org/x/text v0.20.0 // indirect + golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect diff --git a/go.sum b/go.sum index 576197f4..28d4a47d 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= -golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= @@ -89,12 +89,12 @@ golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= -golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -103,14 +103,14 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= -golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= -golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 46d8d9ef02f61ac22c629a3fc7373b20c13c2608 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 7 Dec 2024 04:45:45 +0000 Subject: [PATCH 635/867] XHTTP server: Forbid Mux.Cool except pure XUDP (#4128) https://github.com/XTLS/Xray-core/discussions/4113#discussioncomment-11491701 --- app/proxyman/inbound/inbound.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/proxyman/inbound/inbound.go b/app/proxyman/inbound/inbound.go index cc6aa9d8..2148f423 100644 --- a/app/proxyman/inbound/inbound.go +++ b/app/proxyman/inbound/inbound.go @@ -7,6 +7,7 @@ import ( "github.com/xtls/xray-core/app/proxyman" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/core" @@ -158,6 +159,9 @@ func NewHandler(ctx context.Context, config *core.InboundHandlerConfig) (inbound Mark: streamSettings.SocketSettings.Mark, }) } + if streamSettings != nil && streamSettings.ProtocolName == "splithttp" { + ctx = session.ContextWithAllowedNetwork(ctx, net.Network_UDP) + } allocStrategy := receiverSettings.AllocationStrategy if allocStrategy == nil || allocStrategy.Type == proxyman.AllocationStrategy_Always { From 9cb6816383ddc6580f5a0c38a8f8df2aacf9397b Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 7 Dec 2024 14:43:38 +0000 Subject: [PATCH 636/867] README.md: Update Donation & NFTs --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bf974d13..570237e4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ ## Donation & NFTs -[Announcement of NFTs by Project X](https://github.com/XTLS/Xray-core/discussions/3633) +- **ETH/USDT/USDC: `0xDc3Fe44F0f25D13CACb1C4896CD0D321df3146Ee`** +- **Project X NFT: [Announcement of NFTs by Project X](https://github.com/XTLS/Xray-core/discussions/3633)** +- **REALITY NFT: [XHTTP: Beyond REALITY](https://github.com/XTLS/Xray-core/discussions/4113)** ## License From a2b773135a860f63e990874c551b099dfc888471 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 11 Dec 2024 00:58:14 +0000 Subject: [PATCH 637/867] XHTTP, WS, HU: Forbid "host" in `headers`, read `serverName` instead (#4142) WebSocket's config files should be updated ASAP. --- common/reflect/marshal_test.go | 4 +-- infra/conf/transport_internet.go | 40 ++++++++++-------------- infra/conf/xray_test.go | 7 +---- transport/internet/httpupgrade/dialer.go | 16 +++++++--- transport/internet/splithttp/dialer.go | 23 +++++++++++--- transport/internet/websocket/config.go | 1 - transport/internet/websocket/dialer.go | 15 +++++++-- 7 files changed, 61 insertions(+), 45 deletions(-) diff --git a/common/reflect/marshal_test.go b/common/reflect/marshal_test.go index 359abae0..82194279 100644 --- a/common/reflect/marshal_test.go +++ b/common/reflect/marshal_test.go @@ -204,9 +204,7 @@ func getConfig() string { "security": "none", "wsSettings": { "path": "/?ed=2048", - "headers": { - "Host": "bing.com" - } + "host": "bing.com" } } } diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index c62acee7..c4937ba5 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -163,13 +163,13 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { path = u.String() } } - // If http host is not set in the Host field, but in headers field, we add it to Host Field here. - // If we don't do that, http host will be overwritten as address. - // Host priority: Host field > headers field > address. - if c.Host == "" && c.Headers["host"] != "" { - c.Host = c.Headers["host"] - } else if c.Host == "" && c.Headers["Host"] != "" { - c.Host = c.Headers["Host"] + // Priority (client): host > serverName > address + for k, v := range c.Headers { + errors.PrintDeprecatedFeatureWarning(`"host" in "headers"`, `independent "host"`) + if c.Host == "" { + c.Host = v + } + delete(c.Headers, k) } config := &websocket.Config{ Path: path, @@ -202,15 +202,11 @@ func (c *HttpUpgradeConfig) Build() (proto.Message, error) { path = u.String() } } - // If http host is not set in the Host field, but in headers field, we add it to Host Field here. - // If we don't do that, http host will be overwritten as address. - // Host priority: Host field > headers field > address. - if c.Host == "" && c.Headers["host"] != "" { - c.Host = c.Headers["host"] - delete(c.Headers, "host") - } else if c.Host == "" && c.Headers["Host"] != "" { - c.Host = c.Headers["Host"] - delete(c.Headers, "Host") + // Priority (client): host > serverName > address + for k := range c.Headers { + if strings.ToLower(k) == "host" { + return nil, errors.New(`"headers" can't contain "host"`) + } } config := &httpupgrade.Config{ Path: path, @@ -274,13 +270,11 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { c = &extra } - // If http host is not set in the Host field, but in headers field, we add it to Host Field here. - // If we don't do that, http host will be overwritten as address. - // Host priority: Host field > headers field > address. - if c.Host == "" && c.Headers["host"] != "" { - c.Host = c.Headers["host"] - } else if c.Host == "" && c.Headers["Host"] != "" { - c.Host = c.Headers["Host"] + // Priority (client): host > serverName > address + for k := range c.Headers { + if strings.ToLower(k) == "host" { + return nil, errors.New(`"headers" can't contain "host"`) + } } if c.Xmux.MaxConnections != nil && c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency != nil && c.Xmux.MaxConcurrency.To > 0 { diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index d225dbf9..1c0fff8d 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -48,9 +48,7 @@ func TestXrayConfig(t *testing.T) { "streamSettings": { "network": "ws", "wsSettings": { - "headers": { - "host": "example.domain" - }, + "host": "example.domain", "path": "" }, "tlsSettings": { @@ -139,9 +137,6 @@ func TestXrayConfig(t *testing.T) { ProtocolName: "websocket", Settings: serial.ToTypedMessage(&websocket.Config{ Host: "example.domain", - Header: map[string]string{ - "host": "example.domain", - }, }), }, }, diff --git a/transport/internet/httpupgrade/dialer.go b/transport/internet/httpupgrade/dialer.go index 013f4f28..c10bd97e 100644 --- a/transport/internet/httpupgrade/dialer.go +++ b/transport/internet/httpupgrade/dialer.go @@ -53,9 +53,10 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings * var conn net.Conn var requestURL url.URL - if config := tls.ConfigFromStreamSettings(streamSettings); config != nil { - tlsConfig := config.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("http/1.1")) - if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil { + tConfig := tls.ConfigFromStreamSettings(streamSettings) + if tConfig != nil { + tlsConfig := tConfig.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("http/1.1")) + if fingerprint := tls.GetFingerprint(tConfig.Fingerprint); fingerprint != nil { conn = tls.UClient(pconn, tlsConfig, fingerprint) if err := conn.(*tls.UConn).WebsocketHandshakeContext(ctx); err != nil { return nil, err @@ -69,12 +70,17 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings * requestURL.Scheme = "http" } - requestURL.Host = dest.NetAddr() + requestURL.Host = transportConfiguration.Host + if requestURL.Host == "" && tConfig != nil { + requestURL.Host = tConfig.ServerName + } + if requestURL.Host == "" { + requestURL.Host = dest.Address.String() + } requestURL.Path = transportConfiguration.GetNormalizedPath() req := &http.Request{ Method: http.MethodGet, URL: &requestURL, - Host: transportConfiguration.Host, Header: make(http.Header), } for key, value := range transportConfiguration.Header { diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 4036dfc2..8fa87501 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -259,8 +259,14 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestURL.Scheme = "http" } requestURL.Host = transportConfiguration.Host + if requestURL.Host == "" && tlsConfig != nil { + requestURL.Host = tlsConfig.ServerName + } + if requestURL.Host == "" && realityConfig != nil { + requestURL.Host = realityConfig.ServerName + } if requestURL.Host == "" { - requestURL.Host = dest.NetAddr() + requestURL.Host = dest.Address.String() } sessionIdUuid := uuid.New() @@ -279,16 +285,25 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } globalDialerAccess.Unlock() memory2 := streamSettings.DownloadSettings - httpClient2, muxRes2 = getHTTPClient(ctx, *memory2.Destination, memory2) // just panic - if tls.ConfigFromStreamSettings(memory2) != nil || reality.ConfigFromStreamSettings(memory2) != nil { + dest2 := *memory2.Destination // just panic + httpClient2, muxRes2 = getHTTPClient(ctx, dest2, memory2) + tlsConfig2 := tls.ConfigFromStreamSettings(memory2) + realityConfig2 := reality.ConfigFromStreamSettings(memory2) + if tlsConfig2 != nil || realityConfig2 != nil { requestURL2.Scheme = "https" } else { requestURL2.Scheme = "http" } config2 := memory2.ProtocolSettings.(*Config) requestURL2.Host = config2.Host + if requestURL2.Host == "" && tlsConfig2 != nil { + requestURL2.Host = tlsConfig2.ServerName + } + if requestURL2.Host == "" && realityConfig2 != nil { + requestURL2.Host = realityConfig2.ServerName + } if requestURL2.Host == "" { - requestURL2.Host = memory2.Destination.NetAddr() + requestURL2.Host = dest2.Address.String() } requestURL2.Path = config2.GetNormalizedPath() + sessionIdUuid.String() requestURL2.RawQuery = config2.GetNormalizedQuery() diff --git a/transport/internet/websocket/config.go b/transport/internet/websocket/config.go index af66ebbe..4f2c0a14 100644 --- a/transport/internet/websocket/config.go +++ b/transport/internet/websocket/config.go @@ -23,7 +23,6 @@ func (c *Config) GetRequestHeader() http.Header { for k, v := range c.Header { header.Add(k, v) } - header.Set("Host", c.Host) return header } diff --git a/transport/internet/websocket/dialer.go b/transport/internet/websocket/dialer.go index 0659c7de..60330fd7 100644 --- a/transport/internet/websocket/dialer.go +++ b/transport/internet/websocket/dialer.go @@ -58,11 +58,12 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in protocol := "ws" - if config := tls.ConfigFromStreamSettings(streamSettings); config != nil { + tConfig := tls.ConfigFromStreamSettings(streamSettings) + if tConfig != nil { protocol = "wss" - tlsConfig := config.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("http/1.1")) + tlsConfig := tConfig.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("http/1.1")) dialer.TLSClientConfig = tlsConfig - if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil { + if fingerprint := tls.GetFingerprint(tConfig.Fingerprint); fingerprint != nil { dialer.NetDialTLSContext = func(_ context.Context, _, addr string) (gonet.Conn, error) { // Like the NetDial in the dialer pconn, err := internet.DialSystem(ctx, dest, streamSettings.SocketSettings) @@ -103,6 +104,14 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in } header := wsSettings.GetRequestHeader() + // See dialer.DialContext() + header.Set("Host", wsSettings.Host) + if header.Get("Host") == "" && tConfig != nil { + header.Set("Host", tConfig.ServerName) + } + if header.Get("Host") == "" { + header.Set("Host", dest.Address.String()) + } if ed != nil { // RawURLEncoding is support by both V2Ray/V2Fly and XRay. header.Set("Sec-WebSocket-Protocol", base64.RawURLEncoding.EncodeToString(ed)) From 0e2304c403bf2c032d204e45b76e8b61423ae244 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Tue, 10 Dec 2024 20:07:52 -0500 Subject: [PATCH 638/867] Core: Fix memory leaks with RequireFeatures() (#4095) Fixes https://github.com/XTLS/Xray-core/issues/4054 Fixes https://github.com/XTLS/Xray-core/issues/3338 Fixes https://github.com/XTLS/Xray-core/issues/3221 --- app/dispatcher/default.go | 2 +- app/dns/nameserver.go | 10 ++++-- app/dns/nameserver_fakedns.go | 12 +++---- app/observatory/burst/burstobserver.go | 7 ++-- app/observatory/burst/healthping.go | 6 +++- app/observatory/burst/ping.go | 9 ++--- app/observatory/observer.go | 9 +++-- app/router/balancing.go | 12 +++---- app/router/strategy_leastload.go | 14 ++++---- app/router/strategy_leastping.go | 13 ++++--- app/router/strategy_random.go | 12 +++---- core/xray.go | 37 ++++++++++++++++++++ proxy/dns/dns.go | 2 +- transport/internet/tagged/tagged.go | 3 +- transport/internet/tagged/taggedimpl/impl.go | 9 +---- 15 files changed, 98 insertions(+), 59 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 42fca674..dbf58dad 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -106,7 +106,7 @@ func init() { common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { d := new(DefaultDispatcher) if err := core.RequireFeatures(ctx, func(om outbound.Manager, router routing.Router, pm policy.Manager, sm stats.Manager, dc dns.Client) error { - core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { + core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { // FakeDNSEngine is optional d.fdns = fdns }) return d.Init(config.(*Config), om, router, pm, sm, dc) diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index f3ce2778..ecba9aff 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -35,7 +35,7 @@ type Client struct { var errExpectedIPNonMatch = errors.New("expectIPs not match") // NewServer creates a name server object according to the network destination url. -func NewServer(dest net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) (Server, error) { +func NewServer(dest net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy, fd dns.FakeDNSEngine) (Server, error) { if address := dest.Address; address.Family().IsDomain() { u, err := url.Parse(address.Domain()) if err != nil { @@ -55,7 +55,7 @@ func NewServer(dest net.Destination, dispatcher routing.Dispatcher, queryStrateg case strings.EqualFold(u.Scheme, "tcp+local"): // DNS-over-TCP Local mode return NewTCPLocalNameServer(u, queryStrategy) case strings.EqualFold(u.String(), "fakedns"): - return NewFakeDNSServer(), nil + return NewFakeDNSServer(fd), nil } } if dest.Network == net.Network_Unknown { @@ -78,9 +78,13 @@ func NewClient( ) (*Client, error) { client := &Client{} + var fd dns.FakeDNSEngine err := core.RequireFeatures(ctx, func(dispatcher routing.Dispatcher) error { + core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { // FakeDNSEngine is optional + fd = fdns + }) // Create a new server for each client for now - server, err := NewServer(ns.Address.AsDestination(), dispatcher, ns.GetQueryStrategy()) + server, err := NewServer(ns.Address.AsDestination(), dispatcher, ns.GetQueryStrategy(), fd) if err != nil { return errors.New("failed to create nameserver").Base(err).AtWarning() } diff --git a/app/dns/nameserver_fakedns.go b/app/dns/nameserver_fakedns.go index 531417da..ae7a1a7d 100644 --- a/app/dns/nameserver_fakedns.go +++ b/app/dns/nameserver_fakedns.go @@ -5,7 +5,6 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" - "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/dns" ) @@ -13,8 +12,8 @@ type FakeDNSServer struct { fakeDNSEngine dns.FakeDNSEngine } -func NewFakeDNSServer() *FakeDNSServer { - return &FakeDNSServer{} +func NewFakeDNSServer(fd dns.FakeDNSEngine) *FakeDNSServer { + return &FakeDNSServer{fakeDNSEngine: fd} } func (FakeDNSServer) Name() string { @@ -23,12 +22,9 @@ func (FakeDNSServer) Name() string { func (f *FakeDNSServer) QueryIP(ctx context.Context, domain string, _ net.IP, opt dns.IPOption, _ bool) ([]net.IP, error) { if f.fakeDNSEngine == nil { - if err := core.RequireFeatures(ctx, func(fd dns.FakeDNSEngine) { - f.fakeDNSEngine = fd - }); err != nil { - return nil, errors.New("Unable to locate a fake DNS Engine").Base(err).AtError() - } + return nil, errors.New("Unable to locate a fake DNS Engine").AtError() } + var ips []net.Address if fkr0, ok := f.fakeDNSEngine.(dns.FakeDNSEngineRev0); ok { ips = fkr0.GetFakeIPForDomain3(domain, opt.IPv4Enable, opt.IPv6Enable) diff --git a/app/observatory/burst/burstobserver.go b/app/observatory/burst/burstobserver.go index f2204c00..472351cc 100644 --- a/app/observatory/burst/burstobserver.go +++ b/app/observatory/burst/burstobserver.go @@ -12,6 +12,7 @@ import ( "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/features/routing" "google.golang.org/protobuf/proto" ) @@ -88,13 +89,15 @@ func (o *Observer) Close() error { func New(ctx context.Context, config *Config) (*Observer, error) { var outboundManager outbound.Manager - err := core.RequireFeatures(ctx, func(om outbound.Manager) { + var dispatcher routing.Dispatcher + err := core.RequireFeatures(ctx, func(om outbound.Manager, rd routing.Dispatcher) { outboundManager = om + dispatcher = rd }) if err != nil { return nil, errors.New("Cannot get depended features").Base(err) } - hp := NewHealthPing(ctx, config.PingConfig) + hp := NewHealthPing(ctx, dispatcher, config.PingConfig) return &Observer{ config: config, ctx: ctx, diff --git a/app/observatory/burst/healthping.go b/app/observatory/burst/healthping.go index cd4d5fc0..f0842602 100644 --- a/app/observatory/burst/healthping.go +++ b/app/observatory/burst/healthping.go @@ -9,6 +9,7 @@ import ( "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/features/routing" ) // HealthPingSettings holds settings for health Checker @@ -23,6 +24,7 @@ type HealthPingSettings struct { // HealthPing is the health checker for balancers type HealthPing struct { ctx context.Context + dispatcher routing.Dispatcher access sync.Mutex ticker *time.Ticker tickerClose chan struct{} @@ -32,7 +34,7 @@ type HealthPing struct { } // NewHealthPing creates a new HealthPing with settings -func NewHealthPing(ctx context.Context, config *HealthPingConfig) *HealthPing { +func NewHealthPing(ctx context.Context, dispatcher routing.Dispatcher, config *HealthPingConfig) *HealthPing { settings := &HealthPingSettings{} if config != nil { settings = &HealthPingSettings{ @@ -65,6 +67,7 @@ func NewHealthPing(ctx context.Context, config *HealthPingConfig) *HealthPing { } return &HealthPing{ ctx: ctx, + dispatcher: dispatcher, Settings: settings, Results: nil, } @@ -149,6 +152,7 @@ func (h *HealthPing) doCheck(tags []string, duration time.Duration, rounds int) handler := tag client := newPingClient( h.ctx, + h.dispatcher, h.Settings.Destination, h.Settings.Timeout, handler, diff --git a/app/observatory/burst/ping.go b/app/observatory/burst/ping.go index de1465b9..5ea1433a 100644 --- a/app/observatory/burst/ping.go +++ b/app/observatory/burst/ping.go @@ -6,6 +6,7 @@ import ( "time" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport/internet/tagged" ) @@ -14,10 +15,10 @@ type pingClient struct { httpClient *http.Client } -func newPingClient(ctx context.Context, destination string, timeout time.Duration, handler string) *pingClient { +func newPingClient(ctx context.Context, dispatcher routing.Dispatcher, destination string, timeout time.Duration, handler string) *pingClient { return &pingClient{ destination: destination, - httpClient: newHTTPClient(ctx, handler, timeout), + httpClient: newHTTPClient(ctx, dispatcher, handler, timeout), } } @@ -28,7 +29,7 @@ func newDirectPingClient(destination string, timeout time.Duration) *pingClient } } -func newHTTPClient(ctxv context.Context, handler string, timeout time.Duration) *http.Client { +func newHTTPClient(ctxv context.Context, dispatcher routing.Dispatcher, handler string, timeout time.Duration) *http.Client { tr := &http.Transport{ DisableKeepAlives: true, DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { @@ -36,7 +37,7 @@ func newHTTPClient(ctxv context.Context, handler string, timeout time.Duration) if err != nil { return nil, err } - return tagged.Dialer(ctxv, dest, handler) + return tagged.Dialer(ctxv, dispatcher, dest, handler) }, } return &http.Client{ diff --git a/app/observatory/observer.go b/app/observatory/observer.go index f29856db..657396f6 100644 --- a/app/observatory/observer.go +++ b/app/observatory/observer.go @@ -18,6 +18,7 @@ import ( "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/features/routing" "github.com/xtls/xray-core/transport/internet/tagged" "google.golang.org/protobuf/proto" ) @@ -32,6 +33,7 @@ type Observer struct { finished *done.Instance ohm outbound.Manager + dispatcher routing.Dispatcher } func (o *Observer) GetObservation(ctx context.Context) (proto.Message, error) { @@ -131,7 +133,7 @@ func (o *Observer) probe(outbound string) ProbeResult { return errors.New("cannot understand address").Base(err) } trackedCtx := session.TrackedConnectionError(o.ctx, errorCollectorForRequest) - conn, err := tagged.Dialer(trackedCtx, dest, outbound) + conn, err := tagged.Dialer(trackedCtx, o.dispatcher, dest, outbound) if err != nil { return errors.New("cannot dial remote address ", dest).Base(err) } @@ -215,8 +217,10 @@ func (o *Observer) findStatusLocationLockHolderOnly(outbound string) int { func New(ctx context.Context, config *Config) (*Observer, error) { var outboundManager outbound.Manager - err := core.RequireFeatures(ctx, func(om outbound.Manager) { + var dispatcher routing.Dispatcher + err := core.RequireFeatures(ctx, func(om outbound.Manager, rd routing.Dispatcher) { outboundManager = om + dispatcher = rd }) if err != nil { return nil, errors.New("Cannot get depended features").Base(err) @@ -225,6 +229,7 @@ func New(ctx context.Context, config *Config) (*Observer, error) { config: config, ctx: ctx, ohm: outboundManager, + dispatcher: dispatcher, }, nil } diff --git a/app/router/balancing.go b/app/router/balancing.go index 14f8e21f..7d8bb022 100644 --- a/app/router/balancing.go +++ b/app/router/balancing.go @@ -5,7 +5,6 @@ import ( sync "sync" "github.com/xtls/xray-core/app/observatory" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/extension" @@ -31,6 +30,11 @@ type RoundRobinStrategy struct { func (s *RoundRobinStrategy) InjectContext(ctx context.Context) { s.ctx = ctx + if len(s.FallbackTag) > 0 { + core.RequireFeaturesAsync(s.ctx, func(observatory extension.Observatory) { + s.observatory = observatory + }) + } } func (s *RoundRobinStrategy) GetPrincipleTarget(strings []string) []string { @@ -38,12 +42,6 @@ func (s *RoundRobinStrategy) GetPrincipleTarget(strings []string) []string { } func (s *RoundRobinStrategy) PickOutbound(tags []string) string { - if len(s.FallbackTag) > 0 && s.observatory == nil { - common.Must(core.RequireFeatures(s.ctx, func(observatory extension.Observatory) error { - s.observatory = observatory - return nil - })) - } if s.observatory != nil { observeReport, err := s.observatory.GetObservation(s.ctx) if err == nil { diff --git a/app/router/strategy_leastload.go b/app/router/strategy_leastload.go index bfdfd878..a4ef1c12 100644 --- a/app/router/strategy_leastload.go +++ b/app/router/strategy_leastload.go @@ -7,7 +7,6 @@ import ( "time" "github.com/xtls/xray-core/app/observatory" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/core" @@ -58,8 +57,11 @@ type node struct { RTTDeviationCost time.Duration } -func (l *LeastLoadStrategy) InjectContext(ctx context.Context) { - l.ctx = ctx +func (s *LeastLoadStrategy) InjectContext(ctx context.Context) { + s.ctx = ctx + core.RequireFeaturesAsync(s.ctx, func(observatory extension.Observatory) { + s.observer = observatory + }) } func (s *LeastLoadStrategy) PickOutbound(candidates []string) string { @@ -136,10 +138,8 @@ func (s *LeastLoadStrategy) selectLeastLoad(nodes []*node) []*node { func (s *LeastLoadStrategy) getNodes(candidates []string, maxRTT time.Duration) []*node { if s.observer == nil { - common.Must(core.RequireFeatures(s.ctx, func(observatory extension.Observatory) error { - s.observer = observatory - return nil - })) + errors.LogError(s.ctx, "observer is nil") + return make([]*node, 0) } observeResult, err := s.observer.GetObservation(s.ctx) if err != nil { diff --git a/app/router/strategy_leastping.go b/app/router/strategy_leastping.go index 28efe386..b13d1a7d 100644 --- a/app/router/strategy_leastping.go +++ b/app/router/strategy_leastping.go @@ -4,7 +4,6 @@ import ( "context" "github.com/xtls/xray-core/app/observatory" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/extension" @@ -21,19 +20,19 @@ func (l *LeastPingStrategy) GetPrincipleTarget(strings []string) []string { func (l *LeastPingStrategy) InjectContext(ctx context.Context) { l.ctx = ctx + core.RequireFeaturesAsync(l.ctx, func(observatory extension.Observatory) { + l.observatory = observatory + }) } func (l *LeastPingStrategy) PickOutbound(strings []string) string { if l.observatory == nil { - common.Must(core.RequireFeatures(l.ctx, func(observatory extension.Observatory) error { - l.observatory = observatory - return nil - })) + errors.LogError(l.ctx, "observer is nil") + return "" } - observeReport, err := l.observatory.GetObservation(l.ctx) if err != nil { - errors.LogInfoInner(l.ctx, err, "cannot get observe report") + errors.LogInfoInner(l.ctx, err, "cannot get observer report") return "" } outboundsList := outboundList(strings) diff --git a/app/router/strategy_random.go b/app/router/strategy_random.go index ed82ff9d..9f4cdd77 100644 --- a/app/router/strategy_random.go +++ b/app/router/strategy_random.go @@ -4,7 +4,6 @@ import ( "context" "github.com/xtls/xray-core/app/observatory" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/extension" @@ -20,6 +19,11 @@ type RandomStrategy struct { func (s *RandomStrategy) InjectContext(ctx context.Context) { s.ctx = ctx + if len(s.FallbackTag) > 0 { + core.RequireFeaturesAsync(s.ctx, func(observatory extension.Observatory) { + s.observatory = observatory + }) + } } func (s *RandomStrategy) GetPrincipleTarget(strings []string) []string { @@ -27,12 +31,6 @@ func (s *RandomStrategy) GetPrincipleTarget(strings []string) []string { } func (s *RandomStrategy) PickOutbound(candidates []string) string { - if len(s.FallbackTag) > 0 && s.observatory == nil { - common.Must(core.RequireFeatures(s.ctx, func(observatory extension.Observatory) error { - s.observatory = observatory - return nil - })) - } if s.observatory != nil { observeReport, err := s.observatory.GetObservation(s.ctx) if err == nil { diff --git a/core/xray.go b/core/xray.go index 0e1f0830..5ab10603 100644 --- a/core/xray.go +++ b/core/xray.go @@ -4,6 +4,7 @@ import ( "context" "reflect" "sync" + "time" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" @@ -156,6 +157,12 @@ func RequireFeatures(ctx context.Context, callback interface{}) error { return v.RequireFeatures(callback) } +// RequireFeaturesAsync registers a callback, which will be called when all dependent features are registered. The order of app init doesn't matter +func RequireFeaturesAsync(ctx context.Context, callback interface{}) { + v := MustFromContext(ctx) + v.RequireFeaturesAsync(callback) +} + // New returns a new Xray instance based on given configuration. // The instance is not started at this point. // To ensure Xray instance works properly, the config must contain one Dispatcher, one InboundHandlerManager and one OutboundHandlerManager. Other features are optional. @@ -290,6 +297,36 @@ func (s *Instance) RequireFeatures(callback interface{}) error { return nil } +// RequireFeaturesAsync registers a callback, which will be called when all dependent features are registered. The order of app init doesn't matter +func (s *Instance) RequireFeaturesAsync(callback interface{}) { + callbackType := reflect.TypeOf(callback) + if callbackType.Kind() != reflect.Func { + panic("not a function") + } + + var featureTypes []reflect.Type + for i := 0; i < callbackType.NumIn(); i++ { + featureTypes = append(featureTypes, reflect.PtrTo(callbackType.In(i))) + } + + r := resolution{ + deps: featureTypes, + callback: callback, + } + go func() { + var finished = false + for i := 0; !finished; i++ { + if i > 100000 { + errors.LogError(s.ctx, "RequireFeaturesAsync failed after count ", i) + break; + } + finished, _ = r.resolve(s.features) + time.Sleep(time.Millisecond) + } + s.featureResolutions = append(s.featureResolutions, r) + }() +} + // AddFeature registers a feature into current Instance. func (s *Instance) AddFeature(feature features.Feature) error { s.features = append(s.features, feature) diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index ed063197..790c80c1 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -27,7 +27,7 @@ func init() { common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { h := new(Handler) if err := core.RequireFeatures(ctx, func(dnsClient dns.Client, policyManager policy.Manager) error { - core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { + core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { // FakeDNSEngine is optional h.fdns = fdns }) return h.Init(config.(*Config), dnsClient, policyManager) diff --git a/transport/internet/tagged/tagged.go b/transport/internet/tagged/tagged.go index 430f9640..2cd9dcd2 100644 --- a/transport/internet/tagged/tagged.go +++ b/transport/internet/tagged/tagged.go @@ -4,8 +4,9 @@ import ( "context" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/features/routing" ) -type DialFunc func(ctx context.Context, dest net.Destination, tag string) (net.Conn, error) +type DialFunc func(ctx context.Context, dispatcher routing.Dispatcher, dest net.Destination, tag string) (net.Conn, error) var Dialer DialFunc diff --git a/transport/internet/tagged/taggedimpl/impl.go b/transport/internet/tagged/taggedimpl/impl.go index 29caec7c..2a773401 100644 --- a/transport/internet/tagged/taggedimpl/impl.go +++ b/transport/internet/tagged/taggedimpl/impl.go @@ -12,17 +12,10 @@ import ( "github.com/xtls/xray-core/transport/internet/tagged" ) -func DialTaggedOutbound(ctx context.Context, dest net.Destination, tag string) (net.Conn, error) { - var dispatcher routing.Dispatcher +func DialTaggedOutbound(ctx context.Context, dispatcher routing.Dispatcher, dest net.Destination, tag string) (net.Conn, error) { if core.FromContext(ctx) == nil { return nil, errors.New("Instance context variable is not in context, dial denied. ") } - if err := core.RequireFeatures(ctx, func(dispatcherInstance routing.Dispatcher) { - dispatcher = dispatcherInstance - }); err != nil { - return nil, errors.New("Required Feature dispatcher not resolved").Base(err) - } - content := new(session.Content) content.SkipDNSResolve = true From 6be3c35db8ba9b01d9fa83a5d429694362abd8b8 Mon Sep 17 00:00:00 2001 From: Andi <36215014+ChengenH@users.noreply.github.com> Date: Wed, 11 Dec 2024 09:37:05 +0800 Subject: [PATCH 639/867] Chore: "io/ioutil" -> "io" (#4143) Signed-off-by: ChengenH --- transport/internet/splithttp/browser_client.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/transport/internet/splithttp/browser_client.go b/transport/internet/splithttp/browser_client.go index a0a584a9..427ed470 100644 --- a/transport/internet/splithttp/browser_client.go +++ b/transport/internet/splithttp/browser_client.go @@ -3,7 +3,6 @@ package splithttp import ( "context" "io" - "io/ioutil" gonet "net" "github.com/xtls/xray-core/transport/internet/browser_dialer" @@ -33,7 +32,7 @@ func (c *BrowserDialerClient) OpenDownload(ctx context.Context, baseURL string) } func (c *BrowserDialerClient) SendUploadRequest(ctx context.Context, url string, payload io.ReadWriteCloser, contentLength int64) error { - bytes, err := ioutil.ReadAll(payload) + bytes, err := io.ReadAll(payload) if err != nil { return err } From 8cd9a743764a9ee13f745edd0a17aedcc33a9c63 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:05:39 +0000 Subject: [PATCH 640/867] XHTTP client: Refactor "packet-up" mode, chasing "stream-up" (#4150) * Add wroteRequest (waiting for new quic-go) * Use XTLS/quic-go instead * Client doesn't need `scMaxConcurrentPosts` anymore * GotConn is available in H3 * `scMaxConcurrentPosts` -> `scMaxBufferedPosts` (server only, 30 by default) Fixes https://github.com/XTLS/Xray-core/issues/4100 --- go.mod | 2 + go.sum | 4 +- infra/conf/transport_internet.go | 105 ++++--- transport/internet/splithttp/client.go | 11 +- transport/internet/splithttp/config.go | 13 +- transport/internet/splithttp/config.pb.go | 262 +++++++++--------- transport/internet/splithttp/config.proto | 20 +- transport/internet/splithttp/dialer.go | 64 +++-- transport/internet/splithttp/hub.go | 2 +- .../internet/splithttp/splithttp_test.go | 2 +- 10 files changed, 235 insertions(+), 250 deletions(-) diff --git a/go.mod b/go.mod index 1d8631a7..1ef6c840 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/xtls/xray-core go 1.21.4 +replace github.com/quic-go/quic-go v0.46.0 => github.com/xtls/quic-go v0.46.2 + require ( github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 github.com/cloudflare/circl v1.4.0 diff --git a/go.sum b/go.sum index 28d4a47d..3740d8ef 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/quic-go v0.46.0 h1:uuwLClEEyk1DNvchH8uCByQVjo3yKL9opKulExNDs7Y= -github.com/quic-go/quic-go v0.46.0/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= @@ -70,6 +68,8 @@ github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQ github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= +github.com/xtls/quic-go v0.46.2 h1:bzUnZIQIH8SyqYGR6fAXzEvZauA+32J/2w2AtnEFa1o= +github.com/xtls/quic-go v0.46.2/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index c4937ba5..7669c016 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -221,35 +221,28 @@ func (c *HttpUpgradeConfig) Build() (proto.Message, error) { type SplitHTTPConfig struct { Host string `json:"host"` Path string `json:"path"` + Mode string `json:"mode"` Headers map[string]string `json:"headers"` - ScMaxConcurrentPosts *Int32Range `json:"scMaxConcurrentPosts"` - ScMaxEachPostBytes *Int32Range `json:"scMaxEachPostBytes"` - ScMinPostsIntervalMs *Int32Range `json:"scMinPostsIntervalMs"` + XPaddingBytes Int32Range `json:"xPaddingBytes"` + NoGRPCHeader bool `json:"noGRPCHeader"` NoSSEHeader bool `json:"noSSEHeader"` - XPaddingBytes *Int32Range `json:"xPaddingBytes"` + ScMaxEachPostBytes Int32Range `json:"scMaxEachPostBytes"` + ScMinPostsIntervalMs Int32Range `json:"scMinPostsIntervalMs"` + ScMaxBufferedPosts int64 `json:"scMaxConcurrentPosts"` + KeepAlivePeriod int64 `json:"keepAlivePeriod"` Xmux Xmux `json:"xmux"` DownloadSettings *StreamConfig `json:"downloadSettings"` - Mode string `json:"mode"` Extra json.RawMessage `json:"extra"` - NoGRPCHeader bool `json:"noGRPCHeader"` - KeepAlivePeriod int64 `json:"keepAlivePeriod"` } type Xmux struct { - MaxConcurrency *Int32Range `json:"maxConcurrency"` - MaxConnections *Int32Range `json:"maxConnections"` - CMaxReuseTimes *Int32Range `json:"cMaxReuseTimes"` - CMaxLifetimeMs *Int32Range `json:"cMaxLifetimeMs"` + MaxConcurrency Int32Range `json:"maxConcurrency"` + MaxConnections Int32Range `json:"maxConnections"` + CMaxReuseTimes Int32Range `json:"cMaxReuseTimes"` + CMaxLifetimeMs Int32Range `json:"cMaxLifetimeMs"` } -func splithttpNewRandRangeConfig(input *Int32Range) *splithttp.RandRangeConfig { - if input == nil { - return &splithttp.RandRangeConfig{ - From: 0, - To: 0, - } - } - +func splithttpNewRandRangeConfig(input Int32Range) *splithttp.RandRangeConfig { return &splithttp.RandRangeConfig{ From: input.From, To: input.To, @@ -270,35 +263,6 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { c = &extra } - // Priority (client): host > serverName > address - for k := range c.Headers { - if strings.ToLower(k) == "host" { - return nil, errors.New(`"headers" can't contain "host"`) - } - } - - if c.Xmux.MaxConnections != nil && c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency != nil && c.Xmux.MaxConcurrency.To > 0 { - return nil, errors.New("maxConnections cannot be specified together with maxConcurrency") - } - - // Multiplexing config - muxProtobuf := splithttp.Multiplexing{ - MaxConcurrency: splithttpNewRandRangeConfig(c.Xmux.MaxConcurrency), - MaxConnections: splithttpNewRandRangeConfig(c.Xmux.MaxConnections), - CMaxReuseTimes: splithttpNewRandRangeConfig(c.Xmux.CMaxReuseTimes), - CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.CMaxLifetimeMs), - } - - if muxProtobuf.MaxConcurrency.To == 0 && - muxProtobuf.MaxConnections.To == 0 && - muxProtobuf.CMaxReuseTimes.To == 0 && - muxProtobuf.CMaxLifetimeMs.To == 0 { - muxProtobuf.MaxConcurrency.From = 16 - muxProtobuf.MaxConcurrency.To = 32 - muxProtobuf.CMaxReuseTimes.From = 64 - muxProtobuf.CMaxReuseTimes.To = 128 - } - switch c.Mode { case "": c.Mode = "auto" @@ -307,21 +271,46 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { return nil, errors.New("unsupported mode: " + c.Mode) } + // Priority (client): host > serverName > address + for k := range c.Headers { + if strings.ToLower(k) == "host" { + return nil, errors.New(`"headers" can't contain "host"`) + } + } + + if c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency.To > 0 { + return nil, errors.New("maxConnections cannot be specified together with maxConcurrency") + } + if c.Xmux.MaxConcurrency.To == 0 && + c.Xmux.MaxConnections.To == 0 && + c.Xmux.CMaxReuseTimes.To == 0 && + c.Xmux.CMaxLifetimeMs.To == 0 { + c.Xmux.MaxConcurrency.From = 16 + c.Xmux.MaxConcurrency.To = 32 + c.Xmux.CMaxReuseTimes.From = 64 + c.Xmux.CMaxReuseTimes.To = 128 + } + config := &splithttp.Config{ - Path: c.Path, Host: c.Host, - Header: c.Headers, - ScMaxConcurrentPosts: splithttpNewRandRangeConfig(c.ScMaxConcurrentPosts), + Path: c.Path, + Mode: c.Mode, + Headers: c.Headers, + XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), + NoGRPCHeader: c.NoGRPCHeader, + NoSSEHeader: c.NoSSEHeader, ScMaxEachPostBytes: splithttpNewRandRangeConfig(c.ScMaxEachPostBytes), ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs), - NoSSEHeader: c.NoSSEHeader, - XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), - Xmux: &muxProtobuf, - Mode: c.Mode, - NoGRPCHeader: c.NoGRPCHeader, + ScMaxBufferedPosts: c.ScMaxBufferedPosts, KeepAlivePeriod: c.KeepAlivePeriod, + Xmux: &splithttp.Multiplexing{ + MaxConcurrency: splithttpNewRandRangeConfig(c.Xmux.MaxConcurrency), + MaxConnections: splithttpNewRandRangeConfig(c.Xmux.MaxConnections), + CMaxReuseTimes: splithttpNewRandRangeConfig(c.Xmux.CMaxReuseTimes), + CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.CMaxLifetimeMs), + }, } - var err error + if c.DownloadSettings != nil { if c.Mode == "stream-one" { return nil, errors.New(`Can not use "downloadSettings" in "stream-one" mode.`) @@ -329,10 +318,12 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { if c.Extra != nil { c.DownloadSettings.SocketSettings = nil } + var err error if config.DownloadSettings, err = c.DownloadSettings.Build(); err != nil { return nil, errors.New(`Failed to build "downloadSettings".`).Base(err) } } + return config, nil } diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index baeac3ca..35aad1ec 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -141,14 +141,7 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) gotDownResponse.Close() }() - if !c.isH3 { - // in quic-go, sometimes gotConn is never closed for the lifetime of - // the entire connection, and the download locks up - // https://github.com/quic-go/quic-go/issues/3342 - // for other HTTP versions, we want to block Dial until we know the - // remote address of the server, for logging purposes - <-gotConn.Wait() - } + <-gotConn.Wait() lazyDownload := &LazyReader{ CreateReader: func() (io.Reader, error) { @@ -172,7 +165,7 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) } func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, payload io.ReadWriteCloser, contentLength int64) error { - req, err := http.NewRequest("POST", url, payload) + req, err := http.NewRequestWithContext(ctx, "POST", url, payload) if err != nil { return err } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index eb32adf7..ca3f25af 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -47,7 +47,7 @@ func (c *Config) GetNormalizedQuery() string { func (c *Config) GetRequestHeader() http.Header { header := http.Header{} - for k, v := range c.Header { + for k, v := range c.Headers { header.Add(k, v) } @@ -64,15 +64,12 @@ func (c *Config) WriteResponseHeader(writer http.ResponseWriter) { } } -func (c *Config) GetNormalizedScMaxConcurrentPosts() RandRangeConfig { - if c.ScMaxConcurrentPosts == nil || c.ScMaxConcurrentPosts.To == 0 { - return RandRangeConfig{ - From: 100, - To: 100, - } +func (c *Config) GetNormalizedScMaxBufferedPosts() int { + if c.ScMaxBufferedPosts == 0 { + return 30 } - return *c.ScMaxConcurrentPosts + return int(c.ScMaxBufferedPosts) } func (c *Config) GetNormalizedScMaxEachPostBytes() RandRangeConfig { diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index ad1d3ca9..7d745d53 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -28,17 +28,17 @@ type Config struct { Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` - Header map[string]string `protobuf:"bytes,3,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - ScMaxConcurrentPosts *RandRangeConfig `protobuf:"bytes,4,opt,name=scMaxConcurrentPosts,proto3" json:"scMaxConcurrentPosts,omitempty"` - ScMaxEachPostBytes *RandRangeConfig `protobuf:"bytes,5,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` - ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,6,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` + Mode string `protobuf:"bytes,3,opt,name=mode,proto3" json:"mode,omitempty"` + Headers map[string]string `protobuf:"bytes,4,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + XPaddingBytes *RandRangeConfig `protobuf:"bytes,5,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` + NoGRPCHeader bool `protobuf:"varint,6,opt,name=noGRPCHeader,proto3" json:"noGRPCHeader,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` - XPaddingBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` - Xmux *Multiplexing `protobuf:"bytes,9,opt,name=xmux,proto3" json:"xmux,omitempty"` - DownloadSettings *internet.StreamConfig `protobuf:"bytes,10,opt,name=downloadSettings,proto3" json:"downloadSettings,omitempty"` - Mode string `protobuf:"bytes,11,opt,name=mode,proto3" json:"mode,omitempty"` - NoGRPCHeader bool `protobuf:"varint,12,opt,name=noGRPCHeader,proto3" json:"noGRPCHeader,omitempty"` - KeepAlivePeriod int64 `protobuf:"varint,13,opt,name=keepAlivePeriod,proto3" json:"keepAlivePeriod,omitempty"` + ScMaxEachPostBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` + ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,9,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` + ScMaxBufferedPosts int64 `protobuf:"varint,10,opt,name=scMaxBufferedPosts,proto3" json:"scMaxBufferedPosts,omitempty"` + KeepAlivePeriod int64 `protobuf:"varint,11,opt,name=keepAlivePeriod,proto3" json:"keepAlivePeriod,omitempty"` + Xmux *Multiplexing `protobuf:"bytes,12,opt,name=xmux,proto3" json:"xmux,omitempty"` + DownloadSettings *internet.StreamConfig `protobuf:"bytes,13,opt,name=downloadSettings,proto3" json:"downloadSettings,omitempty"` } func (x *Config) Reset() { @@ -85,20 +85,41 @@ func (x *Config) GetPath() string { return "" } -func (x *Config) GetHeader() map[string]string { +func (x *Config) GetMode() string { if x != nil { - return x.Header + return x.Mode + } + return "" +} + +func (x *Config) GetHeaders() map[string]string { + if x != nil { + return x.Headers } return nil } -func (x *Config) GetScMaxConcurrentPosts() *RandRangeConfig { +func (x *Config) GetXPaddingBytes() *RandRangeConfig { if x != nil { - return x.ScMaxConcurrentPosts + return x.XPaddingBytes } return nil } +func (x *Config) GetNoGRPCHeader() bool { + if x != nil { + return x.NoGRPCHeader + } + return false +} + +func (x *Config) GetNoSSEHeader() bool { + if x != nil { + return x.NoSSEHeader + } + return false +} + func (x *Config) GetScMaxEachPostBytes() *RandRangeConfig { if x != nil { return x.ScMaxEachPostBytes @@ -113,18 +134,18 @@ func (x *Config) GetScMinPostsIntervalMs() *RandRangeConfig { return nil } -func (x *Config) GetNoSSEHeader() bool { +func (x *Config) GetScMaxBufferedPosts() int64 { if x != nil { - return x.NoSSEHeader + return x.ScMaxBufferedPosts } - return false + return 0 } -func (x *Config) GetXPaddingBytes() *RandRangeConfig { +func (x *Config) GetKeepAlivePeriod() int64 { if x != nil { - return x.XPaddingBytes + return x.KeepAlivePeriod } - return nil + return 0 } func (x *Config) GetXmux() *Multiplexing { @@ -141,27 +162,6 @@ func (x *Config) GetDownloadSettings() *internet.StreamConfig { return nil } -func (x *Config) GetMode() string { - if x != nil { - return x.Mode - } - return "" -} - -func (x *Config) GetNoGRPCHeader() bool { - if x != nil { - return x.NoGRPCHeader - } - return false -} - -func (x *Config) GetKeepAlivePeriod() int64 { - if x != nil { - return x.KeepAlivePeriod - } - return 0 -} - type RandRangeConfig struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -294,97 +294,94 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x1a, 0x1f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0xe4, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, + 0xb0, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x12, 0x4d, 0x0a, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x35, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, - 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x12, 0x66, 0x0a, 0x14, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x50, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, + 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x58, 0x0a, 0x0d, 0x78, 0x50, 0x61, 0x64, + 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x14, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x74, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x62, 0x0a, 0x12, 0x73, 0x63, 0x4d, - 0x61, 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, - 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, - 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, - 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x66, 0x0a, - 0x14, 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, - 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, - 0x14, 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, - 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, 0x53, - 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x58, 0x0a, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, - 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, - 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, - 0x73, 0x12, 0x43, 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, - 0x74, 0x74, 0x70, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, - 0x52, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x12, 0x51, 0x0a, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, - 0x61, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, - 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, - 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, - 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x22, 0x0a, - 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x0c, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x12, 0x28, 0x0a, 0x0f, 0x6b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, - 0x72, 0x69, 0x6f, 0x64, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6b, 0x65, 0x65, 0x70, - 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x1a, 0x39, 0x0a, 0x0b, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, - 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, - 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, - 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, - 0x0a, 0x0c, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, - 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, - 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, - 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, - 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x66, 0x69, 0x67, 0x52, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, + 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, + 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x62, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, + 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, + 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x45, + 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x66, 0x0a, 0x14, + 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, + 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, + 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x14, + 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, + 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x2e, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, + 0x66, 0x65, 0x72, 0x65, 0x64, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x65, 0x64, 0x50, + 0x6f, 0x73, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x6b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, + 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6b, + 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x43, + 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, + 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x78, + 0x6d, 0x75, 0x78, 0x12, 0x51, 0x0a, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x53, + 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, + 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, 0x0a, 0x0c, 0x4d, 0x75, + 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, + 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, - 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, + 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, + 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, - 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, - 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, + 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, - 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, - 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, - 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, - 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, - 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, + 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, + 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, + 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, + 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, + 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, + 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, + 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, + 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -404,26 +401,25 @@ var file_transport_internet_splithttp_config_proto_goTypes = []any{ (*Config)(nil), // 0: xray.transport.internet.splithttp.Config (*RandRangeConfig)(nil), // 1: xray.transport.internet.splithttp.RandRangeConfig (*Multiplexing)(nil), // 2: xray.transport.internet.splithttp.Multiplexing - nil, // 3: xray.transport.internet.splithttp.Config.HeaderEntry + nil, // 3: xray.transport.internet.splithttp.Config.HeadersEntry (*internet.StreamConfig)(nil), // 4: xray.transport.internet.StreamConfig } var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ - 3, // 0: xray.transport.internet.splithttp.Config.header:type_name -> xray.transport.internet.splithttp.Config.HeaderEntry - 1, // 1: xray.transport.internet.splithttp.Config.scMaxConcurrentPosts:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 3, // 0: xray.transport.internet.splithttp.Config.headers:type_name -> xray.transport.internet.splithttp.Config.HeadersEntry + 1, // 1: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig 1, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 4: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 2, // 5: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.Multiplexing - 4, // 6: xray.transport.internet.splithttp.Config.downloadSettings:type_name -> xray.transport.internet.StreamConfig - 1, // 7: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 8: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 9: xray.transport.internet.splithttp.Multiplexing.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 10: xray.transport.internet.splithttp.Multiplexing.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 2, // 4: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.Multiplexing + 4, // 5: xray.transport.internet.splithttp.Config.downloadSettings:type_name -> xray.transport.internet.StreamConfig + 1, // 6: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 7: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 8: xray.transport.internet.splithttp.Multiplexing.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 1, // 9: xray.transport.internet.splithttp.Multiplexing.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_transport_internet_splithttp_config_proto_init() } diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 78b77b49..655fdf3f 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -11,17 +11,17 @@ import "transport/internet/config.proto"; message Config { string host = 1; string path = 2; - map header = 3; - RandRangeConfig scMaxConcurrentPosts = 4; - RandRangeConfig scMaxEachPostBytes = 5; - RandRangeConfig scMinPostsIntervalMs = 6; + string mode = 3; + map headers = 4; + RandRangeConfig xPaddingBytes = 5; + bool noGRPCHeader = 6; bool noSSEHeader = 7; - RandRangeConfig xPaddingBytes = 8; - Multiplexing xmux = 9; - xray.transport.internet.StreamConfig downloadSettings = 10; - string mode = 11; - bool noGRPCHeader = 12; - int64 keepAlivePeriod = 13; + RandRangeConfig scMaxEachPostBytes = 8; + RandRangeConfig scMinPostsIntervalMs = 9; + int64 scMaxBufferedPosts = 10; + int64 keepAlivePeriod = 11; + Multiplexing xmux = 12; + xray.transport.internet.StreamConfig downloadSettings = 13; } message RandRangeConfig { diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 8fa87501..4f9ee01e 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -5,6 +5,7 @@ import ( gotls "crypto/tls" "io" "net/http" + "net/http/httptrace" "net/url" "strconv" "sync" @@ -16,7 +17,7 @@ import ( "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" - "github.com/xtls/xray-core/common/signal/semaphore" + "github.com/xtls/xray-core/common/signal/done" "github.com/xtls/xray-core/common/uuid" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/browser_dialer" @@ -249,7 +250,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me tlsConfig := tls.ConfigFromStreamSettings(streamSettings) realityConfig := reality.ConfigFromStreamSettings(streamSettings) - scMaxConcurrentPosts := transportConfiguration.GetNormalizedScMaxConcurrentPosts() scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes() scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs() @@ -386,54 +386,60 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } go func() { - requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll())) - var requestCounter int64 + var seq int64 + var lastWrite time.Time - lastWrite := time.Now() - - // by offloading the uploads into a buffered pipe, multiple conn.Write - // calls get automatically batched together into larger POST requests. - // without batching, bandwidth is extremely limited. for { + wroteRequest := done.New() + + ctx := httptrace.WithClientTrace(ctx, &httptrace.ClientTrace{ + WroteRequest: func(httptrace.WroteRequestInfo) { + wroteRequest.Close() + }, + }) + + // this intentionally makes a shallow-copy of the struct so we + // can reassign Path (potentially concurrently) + url := requestURL + url.Path += "/" + strconv.FormatInt(seq, 10) + // reassign query to get different padding + url.RawQuery = transportConfiguration.GetNormalizedQuery() + + seq += 1 + + if scMinPostsIntervalMs.From > 0 { + sleep := time.Duration(scMinPostsIntervalMs.roll())*time.Millisecond - time.Since(lastWrite) + if sleep > 0 { + time.Sleep(sleep) + } + } + + // by offloading the uploads into a buffered pipe, multiple conn.Write + // calls get automatically batched together into larger POST requests. + // without batching, bandwidth is extremely limited. chunk, err := uploadPipeReader.ReadMultiBuffer() if err != nil { break } - <-requestsLimiter.Wait() - - seq := requestCounter - requestCounter += 1 + lastWrite = time.Now() go func() { - defer requestsLimiter.Signal() - - // this intentionally makes a shallow-copy of the struct so we - // can reassign Path (potentially concurrently) - url := requestURL - url.Path += "/" + strconv.FormatInt(seq, 10) - // reassign query to get different padding - url.RawQuery = transportConfiguration.GetNormalizedQuery() - err := httpClient.SendUploadRequest( context.WithoutCancel(ctx), url.String(), &buf.MultiBufferContainer{MultiBuffer: chunk}, int64(chunk.Len()), ) + wroteRequest.Close() if err != nil { errors.LogInfoInner(ctx, err, "failed to send upload") uploadPipeReader.Interrupt() } }() - if scMinPostsIntervalMs.From > 0 { - roll := time.Duration(scMinPostsIntervalMs.roll()) * time.Millisecond - if time.Since(lastWrite) < roll { - time.Sleep(roll) - } - - lastWrite = time.Now() + if _, ok := httpClient.(*DefaultDialerClient); ok { + <-wroteRequest.Wait() } } }() diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 17e1deef..5fef37d9 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -78,7 +78,7 @@ func (h *requestHandler) upsertSession(sessionId string) *httpSession { } s := &httpSession{ - uploadQueue: NewUploadQueue(int(h.ln.config.GetNormalizedScMaxConcurrentPosts().To)), + uploadQueue: NewUploadQueue(h.ln.config.GetNormalizedScMaxBufferedPosts()), isFullyConnected: done.New(), } diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index c349f8f5..8f32f7d3 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -109,7 +109,7 @@ func TestDialWithRemoteAddr(t *testing.T) { conn, err := Dial(context.Background(), net.TCPDestination(net.DomainAddress("localhost"), listenPort), &internet.MemoryStreamConfig{ ProtocolName: "splithttp", - ProtocolSettings: &Config{Path: "sh", Header: map[string]string{"X-Forwarded-For": "1.1.1.1"}}, + ProtocolSettings: &Config{Path: "sh", Headers: map[string]string{"X-Forwarded-For": "1.1.1.1"}}, }) common.Must(err) From 743435d6e6feb1d5144ce004c35a11afa0d768bf Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 12 Dec 2024 06:56:05 +0000 Subject: [PATCH 641/867] Core: Fix startup error when `dns` exists but `fakedns` doesn't Fixes https://github.com/XTLS/Xray-core/issues/4155 --- app/dns/nameserver.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index ecba9aff..de6e1686 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -35,7 +35,7 @@ type Client struct { var errExpectedIPNonMatch = errors.New("expectIPs not match") // NewServer creates a name server object according to the network destination url. -func NewServer(dest net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy, fd dns.FakeDNSEngine) (Server, error) { +func NewServer(ctx context.Context, dest net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) (Server, error) { if address := dest.Address; address.Family().IsDomain() { u, err := url.Parse(address.Domain()) if err != nil { @@ -55,6 +55,10 @@ func NewServer(dest net.Destination, dispatcher routing.Dispatcher, queryStrateg case strings.EqualFold(u.Scheme, "tcp+local"): // DNS-over-TCP Local mode return NewTCPLocalNameServer(u, queryStrategy) case strings.EqualFold(u.String(), "fakedns"): + var fd dns.FakeDNSEngine + core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { // FakeDNSEngine is optional + fd = fdns + }) return NewFakeDNSServer(fd), nil } } @@ -78,13 +82,9 @@ func NewClient( ) (*Client, error) { client := &Client{} - var fd dns.FakeDNSEngine err := core.RequireFeatures(ctx, func(dispatcher routing.Dispatcher) error { - core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { // FakeDNSEngine is optional - fd = fdns - }) // Create a new server for each client for now - server, err := NewServer(ns.Address.AsDestination(), dispatcher, ns.GetQueryStrategy(), fd) + server, err := NewServer(ctx, ns.Address.AsDestination(), dispatcher, ns.GetQueryStrategy()) if err != nil { return errors.New("failed to create nameserver").Base(err).AtWarning() } From 7463561856f75ed42564e8a6fad722c6bafc74a6 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 12 Dec 2024 12:19:18 +0000 Subject: [PATCH 642/867] XHTTP client: Add decideHTTPVersion() and more logs https://github.com/XTLS/Xray-core/pull/4150#issuecomment-2537981368 --- transport/internet/splithttp/client.go | 5 +- transport/internet/splithttp/dialer.go | 99 +++++++++++--------- transport/internet/splithttp/hub.go | 18 ++-- transport/internet/splithttp/upload_queue.go | 2 +- 4 files changed, 69 insertions(+), 55 deletions(-) diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index 35aad1ec..925d3b0d 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -39,8 +39,7 @@ type DialerClient interface { type DefaultDialerClient struct { transportConfig *Config client *http.Client - isH2 bool - isH3 bool + httpVersion string // pool of net.Conn, created using dialUploadConn uploadRawPool *sync.Pool dialUploadConn func(ctxInner context.Context) (net.Conn, error) @@ -172,7 +171,7 @@ func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, req.ContentLength = contentLength req.Header = c.transportConfig.GetRequestHeader() - if c.isH2 || c.isH3 { + if c.httpVersion != "1.1" { resp, err := c.client.Do(req) if err != nil { return err diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 4f9ee01e..cd0abc85 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -3,6 +3,7 @@ package splithttp import ( "context" gotls "crypto/tls" + "fmt" "io" "net/http" "net/http/httptrace" @@ -83,23 +84,32 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in return res.Resource.(DialerClient), res } +func decideHTTPVersion(tlsConfig *tls.Config, realityConfig *reality.Config) string { + if realityConfig != nil { + return "2" + } + if tlsConfig == nil { + return "1.1" + } + if len(tlsConfig.NextProtocol) != 1 { + return "2" + } + if tlsConfig.NextProtocol[0] == "http/1.1" { + return "1.1" + } + if tlsConfig.NextProtocol[0] == "h3" { + return "3" + } + return "2" +} + func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStreamConfig) DialerClient { tlsConfig := tls.ConfigFromStreamSettings(streamSettings) realityConfig := reality.ConfigFromStreamSettings(streamSettings) - isH2 := false - isH3 := false - - if tlsConfig != nil { - isH2 = !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1") - isH3 = len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3" - } else if realityConfig != nil { - isH2 = true - isH3 = false - } - - if isH3 { - dest.Network = net.Network_UDP + httpVersion := decideHTTPVersion(tlsConfig, realityConfig) + if httpVersion == "3" { + dest.Network = net.Network_UDP // better to keep this line } var gotlsConfig *gotls.Config @@ -138,7 +148,7 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea var transport http.RoundTripper - if isH3 { + if httpVersion == "3" { if keepAlivePeriod == 0 { keepAlivePeriod = quicgoH3KeepAlivePeriod } @@ -194,7 +204,7 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea return quic.DialEarly(ctx, udpConn, udpAddr, tlsCfg, cfg) }, } - } else if isH2 { + } else if httpVersion == "2" { if keepAlivePeriod == 0 { keepAlivePeriod = chromeH2KeepAlivePeriod } @@ -228,8 +238,7 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea client: &http.Client{ Transport: transport, }, - isH2: isH2, - isH3: isH3, + httpVersion: httpVersion, uploadRawPool: &sync.Pool{}, dialUploadConn: dialContext, } @@ -242,16 +251,16 @@ func init() { } func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) { - errors.LogInfo(ctx, "dialing splithttp to ", dest) - - var requestURL url.URL - - transportConfiguration := streamSettings.ProtocolSettings.(*Config) tlsConfig := tls.ConfigFromStreamSettings(streamSettings) realityConfig := reality.ConfigFromStreamSettings(streamSettings) - scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes() - scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs() + httpVersion := decideHTTPVersion(tlsConfig, realityConfig) + if httpVersion == "3" { + dest.Network = net.Network_UDP + } + + transportConfiguration := streamSettings.ProtocolSettings.(*Config) + var requestURL url.URL if tlsConfig != nil || realityConfig != nil { requestURL.Scheme = "https" @@ -275,8 +284,21 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me httpClient, muxRes := getHTTPClient(ctx, dest, streamSettings) - httpClient2 := httpClient + mode := transportConfiguration.Mode + if mode == "" || mode == "auto" { + mode = "packet-up" + if httpVersion == "2" { + mode = "stream-up" + } + if realityConfig != nil && transportConfiguration.DownloadSettings == nil { + mode = "stream-one" + } + } + + errors.LogInfo(ctx, fmt.Sprintf("XHTTP is dialing to %s, mode %s, HTTP version %s, host %s", dest, mode, httpVersion, requestURL.Host)) + requestURL2 := requestURL + httpClient2 := httpClient var muxRes2 *muxResource if transportConfiguration.DownloadSettings != nil { globalDialerAccess.Lock() @@ -286,9 +308,12 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me globalDialerAccess.Unlock() memory2 := streamSettings.DownloadSettings dest2 := *memory2.Destination // just panic - httpClient2, muxRes2 = getHTTPClient(ctx, dest2, memory2) tlsConfig2 := tls.ConfigFromStreamSettings(memory2) realityConfig2 := reality.ConfigFromStreamSettings(memory2) + httpVersion2 := decideHTTPVersion(tlsConfig2, realityConfig2) + if httpVersion2 == "3" { + dest2.Network = net.Network_UDP + } if tlsConfig2 != nil || realityConfig2 != nil { requestURL2.Scheme = "https" } else { @@ -307,20 +332,10 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } requestURL2.Path = config2.GetNormalizedPath() + sessionIdUuid.String() requestURL2.RawQuery = config2.GetNormalizedQuery() + httpClient2, muxRes2 = getHTTPClient(ctx, dest2, memory2) + errors.LogInfo(ctx, fmt.Sprintf("XHTTP is downloading from %s, mode %s, HTTP version %s, host %s", dest2, "stream-down", httpVersion2, requestURL2.Host)) } - mode := transportConfiguration.Mode - if mode == "" || mode == "auto" { - mode = "packet-up" - if (tlsConfig != nil && (len(tlsConfig.NextProtocol) != 1 || tlsConfig.NextProtocol[0] == "h2")) || realityConfig != nil { - mode = "stream-up" - } - if realityConfig != nil && transportConfiguration.DownloadSettings == nil { - mode = "stream-one" - } - } - errors.LogInfo(ctx, "XHTTP is using mode: "+mode) - var writer io.WriteCloser var reader io.ReadCloser var remoteAddr, localAddr net.Addr @@ -373,6 +388,9 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me return stat.Connection(&conn), nil } + scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes() + scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs() + maxUploadSize := scMaxEachPostBytes.roll() // WithSizeLimit(0) will still allow single bytes to pass, and a lot of // code relies on this behavior. Subtract 1 so that together with @@ -408,10 +426,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me seq += 1 if scMinPostsIntervalMs.From > 0 { - sleep := time.Duration(scMinPostsIntervalMs.roll())*time.Millisecond - time.Since(lastWrite) - if sleep > 0 { - time.Sleep(sleep) - } + time.Sleep(time.Duration(scMinPostsIntervalMs.roll())*time.Millisecond - time.Since(lastWrite)) } // by offloading the uploads into a buffered pipe, multiple conn.Write diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 5fef37d9..1df029dd 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -333,30 +333,30 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet Net: "unix", }, streamSettings.SocketSettings) if err != nil { - return nil, errors.New("failed to listen unix domain socket(for SH) on ", address).Base(err) + return nil, errors.New("failed to listen UNIX domain socket for XHTTP on ", address).Base(err) } - errors.LogInfo(ctx, "listening unix domain socket(for SH) on ", address) + errors.LogInfo(ctx, "listening UNIX domain socket for XHTTP on ", address) } else if l.isH3 { // quic Conn, err := internet.ListenSystemPacket(context.Background(), &net.UDPAddr{ IP: address.IP(), Port: int(port), }, streamSettings.SocketSettings) if err != nil { - return nil, errors.New("failed to listen UDP(for SH3) on ", address, ":", port).Base(err) + return nil, errors.New("failed to listen UDP for XHTTP/3 on ", address, ":", port).Base(err) } h3listener, err := quic.ListenEarly(Conn, tlsConfig, nil) if err != nil { - return nil, errors.New("failed to listen QUIC(for SH3) on ", address, ":", port).Base(err) + return nil, errors.New("failed to listen QUIC for XHTTP/3 on ", address, ":", port).Base(err) } l.h3listener = h3listener - errors.LogInfo(ctx, "listening QUIC(for SH3) on ", address, ":", port) + errors.LogInfo(ctx, "listening QUIC for XHTTP/3 on ", address, ":", port) l.h3server = &http3.Server{ Handler: handler, } go func() { if err := l.h3server.ServeListener(l.h3listener); err != nil { - errors.LogWarningInner(ctx, err, "failed to serve http3 for splithttp") + errors.LogWarningInner(ctx, err, "failed to serve HTTP/3 for XHTTP/3") } }() } else { // tcp @@ -369,9 +369,9 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet Port: int(port), }, streamSettings.SocketSettings) if err != nil { - return nil, errors.New("failed to listen TCP(for SH) on ", address, ":", port).Base(err) + return nil, errors.New("failed to listen TCP for XHTTP on ", address, ":", port).Base(err) } - errors.LogInfo(ctx, "listening TCP(for SH) on ", address, ":", port) + errors.LogInfo(ctx, "listening TCP for XHTTP on ", address, ":", port) } // tcp/unix (h1/h2) @@ -397,7 +397,7 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet go func() { if err := l.server.Serve(l.listener); err != nil { - errors.LogWarningInner(ctx, err, "failed to serve http for splithttp") + errors.LogWarningInner(ctx, err, "failed to serve HTTP for XHTTP") } }() } diff --git a/transport/internet/splithttp/upload_queue.go b/transport/internet/splithttp/upload_queue.go index f8dd87b0..382e381e 100644 --- a/transport/internet/splithttp/upload_queue.go +++ b/transport/internet/splithttp/upload_queue.go @@ -52,7 +52,7 @@ func (h *uploadQueue) Push(p Packet) error { if p.Reader != nil { p.Reader.Close() } - return errors.New("splithttp packet queue closed") + return errors.New("packet queue closed") } h.pushedPackets <- p From 73e0d4a666dd80e63b15f9194b91fb0ecfc6c6d1 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 15 Dec 2024 05:43:10 +0000 Subject: [PATCH 643/867] XHTTP XMUX: Add `hMaxRequestTimes` and `hKeepAlivePeriod` (#4163) Fixes https://github.com/XTLS/Xray-core/discussions/4113#discussioncomment-11492833 --- infra/conf/transport_internet.go | 47 +- .../internet/splithttp/browser_client.go | 4 + transport/internet/splithttp/client.go | 22 +- transport/internet/splithttp/config.go | 47 +- transport/internet/splithttp/config.pb.go | 499 +++++++++--------- transport/internet/splithttp/config.proto | 37 +- transport/internet/splithttp/dialer.go | 73 ++- transport/internet/splithttp/mux.go | 148 +++--- transport/internet/splithttp/mux_test.go | 66 +-- .../internet/splithttp/splithttp_test.go | 2 +- 10 files changed, 515 insertions(+), 430 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 7669c016..08f5768e 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -228,22 +228,23 @@ type SplitHTTPConfig struct { NoSSEHeader bool `json:"noSSEHeader"` ScMaxEachPostBytes Int32Range `json:"scMaxEachPostBytes"` ScMinPostsIntervalMs Int32Range `json:"scMinPostsIntervalMs"` - ScMaxBufferedPosts int64 `json:"scMaxConcurrentPosts"` - KeepAlivePeriod int64 `json:"keepAlivePeriod"` - Xmux Xmux `json:"xmux"` + ScMaxBufferedPosts int64 `json:"scMaxBufferedPosts"` + Xmux XmuxConfig `json:"xmux"` DownloadSettings *StreamConfig `json:"downloadSettings"` Extra json.RawMessage `json:"extra"` } -type Xmux struct { - MaxConcurrency Int32Range `json:"maxConcurrency"` - MaxConnections Int32Range `json:"maxConnections"` - CMaxReuseTimes Int32Range `json:"cMaxReuseTimes"` - CMaxLifetimeMs Int32Range `json:"cMaxLifetimeMs"` +type XmuxConfig struct { + MaxConcurrency Int32Range `json:"maxConcurrency"` + MaxConnections Int32Range `json:"maxConnections"` + CMaxReuseTimes Int32Range `json:"cMaxReuseTimes"` + CMaxLifetimeMs Int32Range `json:"cMaxLifetimeMs"` + HMaxRequestTimes Int32Range `json:"hMaxRequestTimes"` + HKeepAlivePeriod int64 `json:"hKeepAlivePeriod"` } -func splithttpNewRandRangeConfig(input Int32Range) *splithttp.RandRangeConfig { - return &splithttp.RandRangeConfig{ +func newRangeConfig(input Int32Range) *splithttp.RangeConfig { + return &splithttp.RangeConfig{ From: input.From, To: input.To, } @@ -281,14 +282,13 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { if c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency.To > 0 { return nil, errors.New("maxConnections cannot be specified together with maxConcurrency") } - if c.Xmux.MaxConcurrency.To == 0 && - c.Xmux.MaxConnections.To == 0 && - c.Xmux.CMaxReuseTimes.To == 0 && - c.Xmux.CMaxLifetimeMs.To == 0 { + if c.Xmux == (XmuxConfig{}) { c.Xmux.MaxConcurrency.From = 16 c.Xmux.MaxConcurrency.To = 32 c.Xmux.CMaxReuseTimes.From = 64 c.Xmux.CMaxReuseTimes.To = 128 + c.Xmux.HMaxRequestTimes.From = 800 + c.Xmux.HMaxRequestTimes.To = 900 } config := &splithttp.Config{ @@ -296,18 +296,19 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { Path: c.Path, Mode: c.Mode, Headers: c.Headers, - XPaddingBytes: splithttpNewRandRangeConfig(c.XPaddingBytes), + XPaddingBytes: newRangeConfig(c.XPaddingBytes), NoGRPCHeader: c.NoGRPCHeader, NoSSEHeader: c.NoSSEHeader, - ScMaxEachPostBytes: splithttpNewRandRangeConfig(c.ScMaxEachPostBytes), - ScMinPostsIntervalMs: splithttpNewRandRangeConfig(c.ScMinPostsIntervalMs), + ScMaxEachPostBytes: newRangeConfig(c.ScMaxEachPostBytes), + ScMinPostsIntervalMs: newRangeConfig(c.ScMinPostsIntervalMs), ScMaxBufferedPosts: c.ScMaxBufferedPosts, - KeepAlivePeriod: c.KeepAlivePeriod, - Xmux: &splithttp.Multiplexing{ - MaxConcurrency: splithttpNewRandRangeConfig(c.Xmux.MaxConcurrency), - MaxConnections: splithttpNewRandRangeConfig(c.Xmux.MaxConnections), - CMaxReuseTimes: splithttpNewRandRangeConfig(c.Xmux.CMaxReuseTimes), - CMaxLifetimeMs: splithttpNewRandRangeConfig(c.Xmux.CMaxLifetimeMs), + Xmux: &splithttp.XmuxConfig{ + MaxConcurrency: newRangeConfig(c.Xmux.MaxConcurrency), + MaxConnections: newRangeConfig(c.Xmux.MaxConnections), + CMaxReuseTimes: newRangeConfig(c.Xmux.CMaxReuseTimes), + CMaxLifetimeMs: newRangeConfig(c.Xmux.CMaxLifetimeMs), + HMaxRequestTimes: newRangeConfig(c.Xmux.HMaxRequestTimes), + HKeepAlivePeriod: c.Xmux.HKeepAlivePeriod, }, } diff --git a/transport/internet/splithttp/browser_client.go b/transport/internet/splithttp/browser_client.go index 427ed470..1b5f6d6b 100644 --- a/transport/internet/splithttp/browser_client.go +++ b/transport/internet/splithttp/browser_client.go @@ -13,6 +13,10 @@ import ( // has no fields because everything is global state :O) type BrowserDialerClient struct{} +func (c *BrowserDialerClient) IsClosed() bool { + panic("not implemented yet") +} + func (c *BrowserDialerClient) Open(ctx context.Context, pureURL string) (io.WriteCloser, io.ReadCloser) { panic("not implemented yet") } diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index 925d3b0d..3baea6f0 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -18,6 +18,8 @@ import ( // interface to abstract between use of browser dialer, vs net/http type DialerClient interface { + IsClosed() bool + // (ctx, baseURL, payload) -> err // baseURL already contains sessionId and seq SendUploadRequest(context.Context, string, io.ReadWriteCloser, int64) error @@ -39,12 +41,17 @@ type DialerClient interface { type DefaultDialerClient struct { transportConfig *Config client *http.Client + closed bool httpVersion string // pool of net.Conn, created using dialUploadConn uploadRawPool *sync.Pool dialUploadConn func(ctxInner context.Context) (net.Conn, error) } +func (c *DefaultDialerClient) IsClosed() bool { + return c.closed +} + func (c *DefaultDialerClient) Open(ctx context.Context, pureURL string) (io.WriteCloser, io.ReadCloser) { reader, writer := io.Pipe() req, _ := http.NewRequestWithContext(ctx, "POST", pureURL, reader) @@ -59,6 +66,8 @@ func (c *DefaultDialerClient) Open(ctx context.Context, pureURL string) (io.Writ if err != nil { errors.LogInfoInner(ctx, err, "failed to open ", pureURL) } else { + // c.closed = true + response.Body.Close() errors.LogInfo(ctx, "unexpected status ", response.StatusCode) } wrc.Close() @@ -76,7 +85,14 @@ func (c *DefaultDialerClient) OpenUpload(ctx context.Context, baseURL string) io if !c.transportConfig.NoGRPCHeader { req.Header.Set("Content-Type", "application/grpc") } - go c.client.Do(req) + go func() { + if resp, err := c.client.Do(req); err == nil { + if resp.StatusCode != 200 { + // c.closed = true + } + resp.Body.Close() + } + }() return writer } @@ -130,6 +146,7 @@ func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) } if response.StatusCode != 200 { + // c.closed = true response.Body.Close() errors.LogInfo(ctx, "invalid status code on download:", response.Status) gotDownResponse.Close() @@ -180,6 +197,7 @@ func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, defer resp.Body.Close() if resp.StatusCode != 200 { + // c.closed = true return errors.New("bad status code:", resp.Status) } } else { @@ -214,6 +232,8 @@ func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, return fmt.Errorf("error while reading response: %s", err.Error()) } if resp.StatusCode != 200 { + // c.closed = true + // resp.Body.Close() // I'm not sure return fmt.Errorf("got non-200 error response code: %d", resp.StatusCode) } } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index ca3f25af..804bbd7e 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -37,7 +37,7 @@ func (c *Config) GetNormalizedQuery() string { query += "&" } - paddingLen := c.GetNormalizedXPaddingBytes().roll() + paddingLen := c.GetNormalizedXPaddingBytes().rand() if paddingLen > 0 { query += "x_padding=" + strings.Repeat("0", int(paddingLen)) } @@ -58,7 +58,7 @@ func (c *Config) WriteResponseHeader(writer http.ResponseWriter) { // CORS headers for the browser dialer writer.Header().Set("Access-Control-Allow-Origin", "*") writer.Header().Set("Access-Control-Allow-Methods", "GET, POST") - paddingLen := c.GetNormalizedXPaddingBytes().roll() + paddingLen := c.GetNormalizedXPaddingBytes().rand() if paddingLen > 0 { writer.Header().Set("X-Padding", strings.Repeat("0", int(paddingLen))) } @@ -72,9 +72,9 @@ func (c *Config) GetNormalizedScMaxBufferedPosts() int { return int(c.ScMaxBufferedPosts) } -func (c *Config) GetNormalizedScMaxEachPostBytes() RandRangeConfig { +func (c *Config) GetNormalizedScMaxEachPostBytes() RangeConfig { if c.ScMaxEachPostBytes == nil || c.ScMaxEachPostBytes.To == 0 { - return RandRangeConfig{ + return RangeConfig{ From: 1000000, To: 1000000, } @@ -83,9 +83,9 @@ func (c *Config) GetNormalizedScMaxEachPostBytes() RandRangeConfig { return *c.ScMaxEachPostBytes } -func (c *Config) GetNormalizedScMinPostsIntervalMs() RandRangeConfig { +func (c *Config) GetNormalizedScMinPostsIntervalMs() RangeConfig { if c.ScMinPostsIntervalMs == nil || c.ScMinPostsIntervalMs.To == 0 { - return RandRangeConfig{ + return RangeConfig{ From: 30, To: 30, } @@ -94,9 +94,9 @@ func (c *Config) GetNormalizedScMinPostsIntervalMs() RandRangeConfig { return *c.ScMinPostsIntervalMs } -func (c *Config) GetNormalizedXPaddingBytes() RandRangeConfig { +func (c *Config) GetNormalizedXPaddingBytes() RangeConfig { if c.XPaddingBytes == nil || c.XPaddingBytes.To == 0 { - return RandRangeConfig{ + return RangeConfig{ From: 100, To: 1000, } @@ -105,9 +105,20 @@ func (c *Config) GetNormalizedXPaddingBytes() RandRangeConfig { return *c.XPaddingBytes } -func (m *Multiplexing) GetNormalizedCMaxReuseTimes() RandRangeConfig { +func (m *XmuxConfig) GetNormalizedCMaxRequestTimes() RangeConfig { + if m.HMaxRequestTimes == nil { + return RangeConfig{ + From: 0, + To: 0, + } + } + + return *m.HMaxRequestTimes +} + +func (m *XmuxConfig) GetNormalizedCMaxReuseTimes() RangeConfig { if m.CMaxReuseTimes == nil { - return RandRangeConfig{ + return RangeConfig{ From: 0, To: 0, } @@ -116,9 +127,9 @@ func (m *Multiplexing) GetNormalizedCMaxReuseTimes() RandRangeConfig { return *m.CMaxReuseTimes } -func (m *Multiplexing) GetNormalizedCMaxLifetimeMs() RandRangeConfig { - if m.CMaxLifetimeMs == nil || m.CMaxLifetimeMs.To == 0 { - return RandRangeConfig{ +func (m *XmuxConfig) GetNormalizedCMaxLifetimeMs() RangeConfig { + if m.CMaxLifetimeMs == nil { + return RangeConfig{ From: 0, To: 0, } @@ -126,9 +137,9 @@ func (m *Multiplexing) GetNormalizedCMaxLifetimeMs() RandRangeConfig { return *m.CMaxLifetimeMs } -func (m *Multiplexing) GetNormalizedMaxConnections() RandRangeConfig { +func (m *XmuxConfig) GetNormalizedMaxConnections() RangeConfig { if m.MaxConnections == nil { - return RandRangeConfig{ + return RangeConfig{ From: 0, To: 0, } @@ -137,9 +148,9 @@ func (m *Multiplexing) GetNormalizedMaxConnections() RandRangeConfig { return *m.MaxConnections } -func (m *Multiplexing) GetNormalizedMaxConcurrency() RandRangeConfig { +func (m *XmuxConfig) GetNormalizedMaxConcurrency() RangeConfig { if m.MaxConcurrency == nil { - return RandRangeConfig{ + return RangeConfig{ From: 0, To: 0, } @@ -154,7 +165,7 @@ func init() { })) } -func (c RandRangeConfig) roll() int32 { +func (c RangeConfig) rand() int32 { if c.From == c.To { return c.From } diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 7d745d53..2dd953d0 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -21,6 +21,144 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type RangeConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + From int32 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"` + To int32 `protobuf:"varint,2,opt,name=to,proto3" json:"to,omitempty"` +} + +func (x *RangeConfig) Reset() { + *x = RangeConfig{} + mi := &file_transport_internet_splithttp_config_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RangeConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RangeConfig) ProtoMessage() {} + +func (x *RangeConfig) ProtoReflect() protoreflect.Message { + mi := &file_transport_internet_splithttp_config_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RangeConfig.ProtoReflect.Descriptor instead. +func (*RangeConfig) Descriptor() ([]byte, []int) { + return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{0} +} + +func (x *RangeConfig) GetFrom() int32 { + if x != nil { + return x.From + } + return 0 +} + +func (x *RangeConfig) GetTo() int32 { + if x != nil { + return x.To + } + return 0 +} + +type XmuxConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + MaxConcurrency *RangeConfig `protobuf:"bytes,1,opt,name=maxConcurrency,proto3" json:"maxConcurrency,omitempty"` + MaxConnections *RangeConfig `protobuf:"bytes,2,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` + CMaxReuseTimes *RangeConfig `protobuf:"bytes,3,opt,name=cMaxReuseTimes,proto3" json:"cMaxReuseTimes,omitempty"` + CMaxLifetimeMs *RangeConfig `protobuf:"bytes,4,opt,name=cMaxLifetimeMs,proto3" json:"cMaxLifetimeMs,omitempty"` + HMaxRequestTimes *RangeConfig `protobuf:"bytes,5,opt,name=hMaxRequestTimes,proto3" json:"hMaxRequestTimes,omitempty"` + HKeepAlivePeriod int64 `protobuf:"varint,6,opt,name=hKeepAlivePeriod,proto3" json:"hKeepAlivePeriod,omitempty"` +} + +func (x *XmuxConfig) Reset() { + *x = XmuxConfig{} + mi := &file_transport_internet_splithttp_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *XmuxConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*XmuxConfig) ProtoMessage() {} + +func (x *XmuxConfig) ProtoReflect() protoreflect.Message { + mi := &file_transport_internet_splithttp_config_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use XmuxConfig.ProtoReflect.Descriptor instead. +func (*XmuxConfig) Descriptor() ([]byte, []int) { + return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{1} +} + +func (x *XmuxConfig) GetMaxConcurrency() *RangeConfig { + if x != nil { + return x.MaxConcurrency + } + return nil +} + +func (x *XmuxConfig) GetMaxConnections() *RangeConfig { + if x != nil { + return x.MaxConnections + } + return nil +} + +func (x *XmuxConfig) GetCMaxReuseTimes() *RangeConfig { + if x != nil { + return x.CMaxReuseTimes + } + return nil +} + +func (x *XmuxConfig) GetCMaxLifetimeMs() *RangeConfig { + if x != nil { + return x.CMaxLifetimeMs + } + return nil +} + +func (x *XmuxConfig) GetHMaxRequestTimes() *RangeConfig { + if x != nil { + return x.HMaxRequestTimes + } + return nil +} + +func (x *XmuxConfig) GetHKeepAlivePeriod() int64 { + if x != nil { + return x.HKeepAlivePeriod + } + return 0 +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -30,20 +168,19 @@ type Config struct { Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` Mode string `protobuf:"bytes,3,opt,name=mode,proto3" json:"mode,omitempty"` Headers map[string]string `protobuf:"bytes,4,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` - XPaddingBytes *RandRangeConfig `protobuf:"bytes,5,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` + XPaddingBytes *RangeConfig `protobuf:"bytes,5,opt,name=xPaddingBytes,proto3" json:"xPaddingBytes,omitempty"` NoGRPCHeader bool `protobuf:"varint,6,opt,name=noGRPCHeader,proto3" json:"noGRPCHeader,omitempty"` NoSSEHeader bool `protobuf:"varint,7,opt,name=noSSEHeader,proto3" json:"noSSEHeader,omitempty"` - ScMaxEachPostBytes *RandRangeConfig `protobuf:"bytes,8,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` - ScMinPostsIntervalMs *RandRangeConfig `protobuf:"bytes,9,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` + ScMaxEachPostBytes *RangeConfig `protobuf:"bytes,8,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` + ScMinPostsIntervalMs *RangeConfig `protobuf:"bytes,9,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` ScMaxBufferedPosts int64 `protobuf:"varint,10,opt,name=scMaxBufferedPosts,proto3" json:"scMaxBufferedPosts,omitempty"` - KeepAlivePeriod int64 `protobuf:"varint,11,opt,name=keepAlivePeriod,proto3" json:"keepAlivePeriod,omitempty"` - Xmux *Multiplexing `protobuf:"bytes,12,opt,name=xmux,proto3" json:"xmux,omitempty"` - DownloadSettings *internet.StreamConfig `protobuf:"bytes,13,opt,name=downloadSettings,proto3" json:"downloadSettings,omitempty"` + Xmux *XmuxConfig `protobuf:"bytes,11,opt,name=xmux,proto3" json:"xmux,omitempty"` + DownloadSettings *internet.StreamConfig `protobuf:"bytes,12,opt,name=downloadSettings,proto3" json:"downloadSettings,omitempty"` } func (x *Config) Reset() { *x = Config{} - mi := &file_transport_internet_splithttp_config_proto_msgTypes[0] + mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -55,7 +192,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_transport_internet_splithttp_config_proto_msgTypes[0] + mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -68,7 +205,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{0} + return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} } func (x *Config) GetHost() string { @@ -99,7 +236,7 @@ func (x *Config) GetHeaders() map[string]string { return nil } -func (x *Config) GetXPaddingBytes() *RandRangeConfig { +func (x *Config) GetXPaddingBytes() *RangeConfig { if x != nil { return x.XPaddingBytes } @@ -120,14 +257,14 @@ func (x *Config) GetNoSSEHeader() bool { return false } -func (x *Config) GetScMaxEachPostBytes() *RandRangeConfig { +func (x *Config) GetScMaxEachPostBytes() *RangeConfig { if x != nil { return x.ScMaxEachPostBytes } return nil } -func (x *Config) GetScMinPostsIntervalMs() *RandRangeConfig { +func (x *Config) GetScMinPostsIntervalMs() *RangeConfig { if x != nil { return x.ScMinPostsIntervalMs } @@ -141,14 +278,7 @@ func (x *Config) GetScMaxBufferedPosts() int64 { return 0 } -func (x *Config) GetKeepAlivePeriod() int64 { - if x != nil { - return x.KeepAlivePeriod - } - return 0 -} - -func (x *Config) GetXmux() *Multiplexing { +func (x *Config) GetXmux() *XmuxConfig { if x != nil { return x.Xmux } @@ -162,128 +292,6 @@ func (x *Config) GetDownloadSettings() *internet.StreamConfig { return nil } -type RandRangeConfig struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - From int32 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"` - To int32 `protobuf:"varint,2,opt,name=to,proto3" json:"to,omitempty"` -} - -func (x *RandRangeConfig) Reset() { - *x = RandRangeConfig{} - mi := &file_transport_internet_splithttp_config_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *RandRangeConfig) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*RandRangeConfig) ProtoMessage() {} - -func (x *RandRangeConfig) ProtoReflect() protoreflect.Message { - mi := &file_transport_internet_splithttp_config_proto_msgTypes[1] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use RandRangeConfig.ProtoReflect.Descriptor instead. -func (*RandRangeConfig) Descriptor() ([]byte, []int) { - return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{1} -} - -func (x *RandRangeConfig) GetFrom() int32 { - if x != nil { - return x.From - } - return 0 -} - -func (x *RandRangeConfig) GetTo() int32 { - if x != nil { - return x.To - } - return 0 -} - -type Multiplexing struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - MaxConcurrency *RandRangeConfig `protobuf:"bytes,1,opt,name=maxConcurrency,proto3" json:"maxConcurrency,omitempty"` - MaxConnections *RandRangeConfig `protobuf:"bytes,2,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` - CMaxReuseTimes *RandRangeConfig `protobuf:"bytes,3,opt,name=cMaxReuseTimes,proto3" json:"cMaxReuseTimes,omitempty"` - CMaxLifetimeMs *RandRangeConfig `protobuf:"bytes,4,opt,name=cMaxLifetimeMs,proto3" json:"cMaxLifetimeMs,omitempty"` -} - -func (x *Multiplexing) Reset() { - *x = Multiplexing{} - mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) -} - -func (x *Multiplexing) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Multiplexing) ProtoMessage() {} - -func (x *Multiplexing) ProtoReflect() protoreflect.Message { - mi := &file_transport_internet_splithttp_config_proto_msgTypes[2] - if x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Multiplexing.ProtoReflect.Descriptor instead. -func (*Multiplexing) Descriptor() ([]byte, []int) { - return file_transport_internet_splithttp_config_proto_rawDescGZIP(), []int{2} -} - -func (x *Multiplexing) GetMaxConcurrency() *RandRangeConfig { - if x != nil { - return x.MaxConcurrency - } - return nil -} - -func (x *Multiplexing) GetMaxConnections() *RandRangeConfig { - if x != nil { - return x.MaxConnections - } - return nil -} - -func (x *Multiplexing) GetCMaxReuseTimes() *RandRangeConfig { - if x != nil { - return x.CMaxReuseTimes - } - return nil -} - -func (x *Multiplexing) GetCMaxLifetimeMs() *RandRangeConfig { - if x != nil { - return x.CMaxLifetimeMs - } - return nil -} - var File_transport_internet_splithttp_config_proto protoreflect.FileDescriptor var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ @@ -294,94 +302,98 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x1a, 0x1f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0xb0, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, - 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, - 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, - 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x50, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x58, 0x0a, 0x0d, 0x78, 0x50, 0x61, 0x64, - 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, - 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, - 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, - 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, - 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x62, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, - 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, - 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x45, - 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x66, 0x0a, 0x14, - 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, - 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, + 0x31, 0x0a, 0x0b, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, + 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, + 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, + 0x74, 0x6f, 0x22, 0xf4, 0x03, 0x0a, 0x0a, 0x58, 0x6d, 0x75, 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x56, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, + 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, + 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, + 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x56, 0x0a, 0x0e, 0x6d, 0x61, 0x78, + 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, + 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x73, 0x12, 0x56, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, + 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, + 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, + 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x56, 0x0a, 0x0e, 0x63, 0x4d, 0x61, + 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, + 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, + 0x73, 0x12, 0x5a, 0x0a, 0x10, 0x68, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, + 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x68, 0x4d, 0x61, + 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x2a, 0x0a, + 0x10, 0x68, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, + 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x68, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, + 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x22, 0xf8, 0x05, 0x0a, 0x06, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, + 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, + 0x12, 0x50, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x36, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, + 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, + 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, + 0x72, 0x73, 0x12, 0x54, 0x0a, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, + 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, + 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, + 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x6f, 0x47, 0x52, + 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, + 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, + 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x5e, + 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, + 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, - 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x14, - 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, - 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x2e, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, - 0x66, 0x65, 0x72, 0x65, 0x64, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x65, 0x64, 0x50, - 0x6f, 0x73, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x6b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, - 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x6b, - 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x43, - 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2f, 0x2e, 0x78, + 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, + 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x62, + 0x0a, 0x14, 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, + 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, - 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x52, 0x04, 0x78, - 0x6d, 0x75, 0x78, 0x12, 0x51, 0x0a, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x53, - 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, - 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x22, 0x35, 0x0a, 0x0f, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x74, 0x6f, 0x22, 0xfe, 0x02, 0x0a, 0x0c, 0x4d, 0x75, - 0x6c, 0x74, 0x69, 0x70, 0x6c, 0x65, 0x78, 0x69, 0x6e, 0x67, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, - 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, - 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, - 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x5a, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, - 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, - 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x52, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x12, 0x5a, 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, - 0x61, 0x6e, 0x64, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, - 0x63, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, - 0x0a, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x64, 0x52, - 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, - 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, - 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x14, 0x73, 0x63, + 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, + 0x4d, 0x73, 0x12, 0x2e, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, 0x66, 0x65, + 0x72, 0x65, 0x64, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x12, + 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x65, 0x64, 0x50, 0x6f, 0x73, + 0x74, 0x73, 0x12, 0x41, 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, - 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, - 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, - 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, - 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x68, 0x74, 0x74, 0x70, 0x2e, 0x58, 0x6d, 0x75, 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, + 0x04, 0x78, 0x6d, 0x75, 0x78, 0x12, 0x51, 0x0a, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, + 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, + 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x3a, 0x02, 0x38, 0x01, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, + 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, + 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -398,28 +410,29 @@ func file_transport_internet_splithttp_config_proto_rawDescGZIP() []byte { var file_transport_internet_splithttp_config_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_transport_internet_splithttp_config_proto_goTypes = []any{ - (*Config)(nil), // 0: xray.transport.internet.splithttp.Config - (*RandRangeConfig)(nil), // 1: xray.transport.internet.splithttp.RandRangeConfig - (*Multiplexing)(nil), // 2: xray.transport.internet.splithttp.Multiplexing + (*RangeConfig)(nil), // 0: xray.transport.internet.splithttp.RangeConfig + (*XmuxConfig)(nil), // 1: xray.transport.internet.splithttp.XmuxConfig + (*Config)(nil), // 2: xray.transport.internet.splithttp.Config nil, // 3: xray.transport.internet.splithttp.Config.HeadersEntry (*internet.StreamConfig)(nil), // 4: xray.transport.internet.StreamConfig } var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ - 3, // 0: xray.transport.internet.splithttp.Config.headers:type_name -> xray.transport.internet.splithttp.Config.HeadersEntry - 1, // 1: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 2: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 3: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 2, // 4: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.Multiplexing - 4, // 5: xray.transport.internet.splithttp.Config.downloadSettings:type_name -> xray.transport.internet.StreamConfig - 1, // 6: xray.transport.internet.splithttp.Multiplexing.maxConcurrency:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 7: xray.transport.internet.splithttp.Multiplexing.maxConnections:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 8: xray.transport.internet.splithttp.Multiplexing.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 1, // 9: xray.transport.internet.splithttp.Multiplexing.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RandRangeConfig - 10, // [10:10] is the sub-list for method output_type - 10, // [10:10] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name + 0, // 0: xray.transport.internet.splithttp.XmuxConfig.maxConcurrency:type_name -> xray.transport.internet.splithttp.RangeConfig + 0, // 1: xray.transport.internet.splithttp.XmuxConfig.maxConnections:type_name -> xray.transport.internet.splithttp.RangeConfig + 0, // 2: xray.transport.internet.splithttp.XmuxConfig.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RangeConfig + 0, // 3: xray.transport.internet.splithttp.XmuxConfig.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RangeConfig + 0, // 4: xray.transport.internet.splithttp.XmuxConfig.hMaxRequestTimes:type_name -> xray.transport.internet.splithttp.RangeConfig + 3, // 5: xray.transport.internet.splithttp.Config.headers:type_name -> xray.transport.internet.splithttp.Config.HeadersEntry + 0, // 6: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RangeConfig + 0, // 7: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RangeConfig + 0, // 8: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RangeConfig + 1, // 9: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.XmuxConfig + 4, // 10: xray.transport.internet.splithttp.Config.downloadSettings:type_name -> xray.transport.internet.StreamConfig + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_transport_internet_splithttp_config_proto_init() } diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 655fdf3f..08677266 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -8,30 +8,31 @@ option java_multiple_files = true; import "transport/internet/config.proto"; +message RangeConfig { + int32 from = 1; + int32 to = 2; +} + +message XmuxConfig { + RangeConfig maxConcurrency = 1; + RangeConfig maxConnections = 2; + RangeConfig cMaxReuseTimes = 3; + RangeConfig cMaxLifetimeMs = 4; + RangeConfig hMaxRequestTimes = 5; + int64 hKeepAlivePeriod = 6; +} + message Config { string host = 1; string path = 2; string mode = 3; map headers = 4; - RandRangeConfig xPaddingBytes = 5; + RangeConfig xPaddingBytes = 5; bool noGRPCHeader = 6; bool noSSEHeader = 7; - RandRangeConfig scMaxEachPostBytes = 8; - RandRangeConfig scMinPostsIntervalMs = 9; + RangeConfig scMaxEachPostBytes = 8; + RangeConfig scMinPostsIntervalMs = 9; int64 scMaxBufferedPosts = 10; - int64 keepAlivePeriod = 11; - Multiplexing xmux = 12; - xray.transport.internet.StreamConfig downloadSettings = 13; -} - -message RandRangeConfig { - int32 from = 1; - int32 to = 2; -} - -message Multiplexing { - RandRangeConfig maxConcurrency = 1; - RandRangeConfig maxConnections = 2; - RandRangeConfig cMaxReuseTimes = 3; - RandRangeConfig cMaxLifetimeMs = 4; + XmuxConfig xmux = 11; + xray.transport.internet.StreamConfig downloadSettings = 12; } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index cd0abc85..973b8a9c 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -10,6 +10,7 @@ import ( "net/url" "strconv" "sync" + "sync/atomic" "time" "github.com/quic-go/quic-go" @@ -45,11 +46,11 @@ type dialerConf struct { } var ( - globalDialerMap map[dialerConf]*muxManager + globalDialerMap map[dialerConf]*XmuxManager globalDialerAccess sync.Mutex ) -func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (DialerClient, *muxResource) { +func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (DialerClient, *XmuxClient) { realityConfig := reality.ConfigFromStreamSettings(streamSettings) if browser_dialer.HasBrowserDialer() && realityConfig != nil { @@ -60,28 +61,28 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in defer globalDialerAccess.Unlock() if globalDialerMap == nil { - globalDialerMap = make(map[dialerConf]*muxManager) + globalDialerMap = make(map[dialerConf]*XmuxManager) } key := dialerConf{dest, streamSettings} - muxManager, found := globalDialerMap[key] + xmuxManager, found := globalDialerMap[key] if !found { transportConfig := streamSettings.ProtocolSettings.(*Config) - var mux Multiplexing + var xmuxConfig XmuxConfig if transportConfig.Xmux != nil { - mux = *transportConfig.Xmux + xmuxConfig = *transportConfig.Xmux } - muxManager = NewMuxManager(mux, func() interface{} { + xmuxManager = NewXmuxManager(xmuxConfig, func() XmuxConn { return createHTTPClient(dest, streamSettings) }) - globalDialerMap[key] = muxManager + globalDialerMap[key] = xmuxManager } - res := muxManager.GetResource(ctx) - return res.Resource.(DialerClient), res + xmuxClient := xmuxManager.GetXmuxClient(ctx) + return xmuxClient.XmuxConn.(DialerClient), xmuxClient } func decideHTTPVersion(tlsConfig *tls.Config, realityConfig *reality.Config) string { @@ -144,7 +145,10 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea return conn, nil } - keepAlivePeriod := time.Duration(streamSettings.ProtocolSettings.(*Config).KeepAlivePeriod) * time.Second + var keepAlivePeriod time.Duration + if streamSettings.ProtocolSettings.(*Config).Xmux != nil { + keepAlivePeriod = time.Duration(streamSettings.ProtocolSettings.(*Config).Xmux.HKeepAlivePeriod) * time.Second + } var transport http.RoundTripper @@ -282,7 +286,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestURL.Path = transportConfiguration.GetNormalizedPath() + sessionIdUuid.String() requestURL.RawQuery = transportConfiguration.GetNormalizedQuery() - httpClient, muxRes := getHTTPClient(ctx, dest, streamSettings) + httpClient, xmuxClient := getHTTPClient(ctx, dest, streamSettings) mode := transportConfiguration.Mode if mode == "" || mode == "auto" { @@ -299,7 +303,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me requestURL2 := requestURL httpClient2 := httpClient - var muxRes2 *muxResource + xmuxClient2 := xmuxClient if transportConfiguration.DownloadSettings != nil { globalDialerAccess.Lock() if streamSettings.DownloadSettings == nil { @@ -332,7 +336,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } requestURL2.Path = config2.GetNormalizedPath() + sessionIdUuid.String() requestURL2.RawQuery = config2.GetNormalizedQuery() - httpClient2, muxRes2 = getHTTPClient(ctx, dest2, memory2) + httpClient2, xmuxClient2 = getHTTPClient(ctx, dest2, memory2) errors.LogInfo(ctx, fmt.Sprintf("XHTTP is downloading from %s, mode %s, HTTP version %s, host %s", dest2, "stream-down", httpVersion2, requestURL2.Host)) } @@ -343,23 +347,29 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if mode == "stream-one" { requestURL.Path = transportConfiguration.GetNormalizedPath() + if xmuxClient != nil { + xmuxClient.LeftRequests.Add(-1) + } writer, reader = httpClient.Open(context.WithoutCancel(ctx), requestURL.String()) remoteAddr = &net.TCPAddr{} localAddr = &net.TCPAddr{} } else { + if xmuxClient2 != nil { + xmuxClient2.LeftRequests.Add(-1) + } reader, remoteAddr, localAddr, err = httpClient2.OpenDownload(context.WithoutCancel(ctx), requestURL2.String()) if err != nil { return nil, err } } - if muxRes != nil { - muxRes.OpenRequests.Add(1) + if xmuxClient != nil { + xmuxClient.OpenUsage.Add(1) } - if muxRes2 != nil { - muxRes2.OpenRequests.Add(1) + if xmuxClient2 != nil && xmuxClient2 != xmuxClient { + xmuxClient2.OpenUsage.Add(1) } - closed := false + var once atomic.Int32 conn := splitConn{ writer: writer, @@ -367,23 +377,28 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me remoteAddr: remoteAddr, localAddr: localAddr, onClose: func() { - if closed { + if once.Add(-1) < 0 { return } - closed = true - if muxRes != nil { - muxRes.OpenRequests.Add(-1) + if xmuxClient != nil { + xmuxClient.OpenUsage.Add(-1) } - if muxRes2 != nil { - muxRes2.OpenRequests.Add(-1) + if xmuxClient2 != nil && xmuxClient2 != xmuxClient { + xmuxClient2.OpenUsage.Add(-1) } }, } if mode == "stream-one" { + if xmuxClient != nil { + xmuxClient.LeftRequests.Add(-1) + } return stat.Connection(&conn), nil } if mode == "stream-up" { + if xmuxClient != nil { + xmuxClient.LeftRequests.Add(-1) + } conn.writer = httpClient.OpenUpload(ctx, requestURL.String()) return stat.Connection(&conn), nil } @@ -391,7 +406,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes() scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs() - maxUploadSize := scMaxEachPostBytes.roll() + maxUploadSize := scMaxEachPostBytes.rand() // WithSizeLimit(0) will still allow single bytes to pass, and a lot of // code relies on this behavior. Subtract 1 so that together with // uploadWriter wrapper, exact size limits can be enforced @@ -426,7 +441,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me seq += 1 if scMinPostsIntervalMs.From > 0 { - time.Sleep(time.Duration(scMinPostsIntervalMs.roll())*time.Millisecond - time.Since(lastWrite)) + time.Sleep(time.Duration(scMinPostsIntervalMs.rand())*time.Millisecond - time.Since(lastWrite)) } // by offloading the uploads into a buffered pipe, multiple conn.Write @@ -439,6 +454,10 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me lastWrite = time.Now() + if xmuxClient != nil && xmuxClient.LeftRequests.Add(-1) <= 0 { + httpClient, xmuxClient = getHTTPClient(ctx, dest, streamSettings) + } + go func() { err := httpClient.SendUploadRequest( context.WithoutCancel(ctx), diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go index 83ab25b0..e658c006 100644 --- a/transport/internet/splithttp/mux.go +++ b/transport/internet/splithttp/mux.go @@ -2,101 +2,113 @@ package splithttp import ( "context" - "math/rand" + "crypto/rand" + "math" + "math/big" "sync/atomic" "time" "github.com/xtls/xray-core/common/errors" ) -type muxResource struct { - Resource interface{} - OpenRequests atomic.Int32 +type XmuxConn interface { + IsClosed() bool +} + +type XmuxClient struct { + XmuxConn XmuxConn + OpenUsage atomic.Int32 leftUsage int32 expirationTime time.Time + LeftRequests atomic.Int32 } -type muxManager struct { - newResourceFn func() interface{} - config Multiplexing - concurrency int32 - connections int32 - instances []*muxResource +type XmuxManager struct { + xmuxConfig XmuxConfig + concurrency int32 + connections int32 + newConnFunc func() XmuxConn + xmuxClients []*XmuxClient } -func NewMuxManager(config Multiplexing, newResource func() interface{}) *muxManager { - return &muxManager{ - config: config, - concurrency: config.GetNormalizedMaxConcurrency().roll(), - connections: config.GetNormalizedMaxConnections().roll(), - newResourceFn: newResource, - instances: make([]*muxResource, 0), +func NewXmuxManager(xmuxConfig XmuxConfig, newConnFunc func() XmuxConn) *XmuxManager { + return &XmuxManager{ + xmuxConfig: xmuxConfig, + concurrency: xmuxConfig.GetNormalizedMaxConcurrency().rand(), + connections: xmuxConfig.GetNormalizedMaxConnections().rand(), + newConnFunc: newConnFunc, + xmuxClients: make([]*XmuxClient, 0), } } -func (m *muxManager) GetResource(ctx context.Context) *muxResource { - m.removeExpiredConnections(ctx) +func (m *XmuxManager) newXmuxClient() *XmuxClient { + xmuxClient := &XmuxClient{ + XmuxConn: m.newConnFunc(), + leftUsage: -1, + expirationTime: time.UnixMilli(0), + } + if x := m.xmuxConfig.GetNormalizedCMaxReuseTimes().rand(); x > 0 { + xmuxClient.leftUsage = x - 1 + } + if x := m.xmuxConfig.GetNormalizedCMaxLifetimeMs().rand(); x > 0 { + xmuxClient.expirationTime = time.Now().Add(time.Duration(x) * time.Millisecond) + } + xmuxClient.LeftRequests.Store(math.MaxInt32) + if x := m.xmuxConfig.GetNormalizedCMaxRequestTimes().rand(); x > 0 { + xmuxClient.LeftRequests.Store(x) + } + m.xmuxClients = append(m.xmuxClients, xmuxClient) + return xmuxClient +} - if m.connections > 0 && len(m.instances) < int(m.connections) { - errors.LogDebug(ctx, "xmux: creating client, connections=", len(m.instances)) - return m.newResource() +func (m *XmuxManager) GetXmuxClient(ctx context.Context) *XmuxClient { // when locking + for i := 0; i < len(m.xmuxClients); { + xmuxClient := m.xmuxClients[i] + if xmuxClient.XmuxConn.IsClosed() || + xmuxClient.leftUsage == 0 || + (xmuxClient.expirationTime != time.UnixMilli(0) && time.Now().After(xmuxClient.expirationTime)) || + xmuxClient.LeftRequests.Load() <= 0 { + errors.LogDebug(ctx, "XMUX: removing xmuxClient, IsClosed() = ", xmuxClient.XmuxConn.IsClosed(), + ", OpenUsage = ", xmuxClient.OpenUsage.Load(), + ", leftUsage = ", xmuxClient.leftUsage, + ", expirationTime = ", xmuxClient.expirationTime, + ", LeftRequests = ", xmuxClient.LeftRequests.Load()) + m.xmuxClients = append(m.xmuxClients[:i], m.xmuxClients[i+1:]...) + } else { + i++ + } } - if len(m.instances) == 0 { - errors.LogDebug(ctx, "xmux: creating client because instances is empty, connections=", len(m.instances)) - return m.newResource() + if len(m.xmuxClients) == 0 { + errors.LogDebug(ctx, "XMUX: creating xmuxClient because xmuxClients is empty") + return m.newXmuxClient() } - clients := make([]*muxResource, 0) + if m.connections > 0 && len(m.xmuxClients) < int(m.connections) { + errors.LogDebug(ctx, "XMUX: creating xmuxClient because maxConnections was not hit, xmuxClients = ", len(m.xmuxClients)) + return m.newXmuxClient() + } + + xmuxClients := make([]*XmuxClient, 0) if m.concurrency > 0 { - for _, client := range m.instances { - openRequests := client.OpenRequests.Load() - if openRequests < m.concurrency { - clients = append(clients, client) + for _, xmuxClient := range m.xmuxClients { + if xmuxClient.OpenUsage.Load() < m.concurrency { + xmuxClients = append(xmuxClients, xmuxClient) } } } else { - clients = m.instances + xmuxClients = m.xmuxClients } - if len(clients) == 0 { - errors.LogDebug(ctx, "xmux: creating client because concurrency was hit, total clients=", len(m.instances)) - return m.newResource() + if len(xmuxClients) == 0 { + errors.LogDebug(ctx, "XMUX: creating xmuxClient because maxConcurrency was hit, xmuxClients = ", len(m.xmuxClients)) + return m.newXmuxClient() } - client := clients[rand.Intn(len(clients))] - if client.leftUsage > 0 { - client.leftUsage -= 1 - } - return client -} - -func (m *muxManager) newResource() *muxResource { - leftUsage := int32(-1) - if x := m.config.GetNormalizedCMaxReuseTimes().roll(); x > 0 { - leftUsage = x - 1 - } - expirationTime := time.UnixMilli(0) - if x := m.config.GetNormalizedCMaxLifetimeMs().roll(); x > 0 { - expirationTime = time.Now().Add(time.Duration(x) * time.Millisecond) - } - - client := &muxResource{ - Resource: m.newResourceFn(), - leftUsage: leftUsage, - expirationTime: expirationTime, - } - m.instances = append(m.instances, client) - return client -} - -func (m *muxManager) removeExpiredConnections(ctx context.Context) { - for i := 0; i < len(m.instances); i++ { - client := m.instances[i] - if client.leftUsage == 0 || (client.expirationTime != time.UnixMilli(0) && time.Now().After(client.expirationTime)) { - errors.LogDebug(ctx, "xmux: removing client, leftUsage = ", client.leftUsage, ", expirationTime = ", client.expirationTime) - m.instances = append(m.instances[:i], m.instances[i+1:]...) - i-- - } + i, _ := rand.Int(rand.Reader, big.NewInt(int64(len(xmuxClients)))) + xmuxClient := xmuxClients[i.Int64()] + if xmuxClient.leftUsage > 0 { + xmuxClient.leftUsage -= 1 } + return xmuxClient } diff --git a/transport/internet/splithttp/mux_test.go b/transport/internet/splithttp/mux_test.go index e59eff0e..835d07f0 100644 --- a/transport/internet/splithttp/mux_test.go +++ b/transport/internet/splithttp/mux_test.go @@ -9,80 +9,84 @@ import ( type fakeRoundTripper struct{} +func (f *fakeRoundTripper) IsClosed() bool { + return false +} + func TestMaxConnections(t *testing.T) { - config := Multiplexing{ - MaxConnections: &RandRangeConfig{From: 4, To: 4}, + xmuxConfig := XmuxConfig{ + MaxConnections: &RangeConfig{From: 4, To: 4}, } - mux := NewMuxManager(config, func() interface{} { + xmuxManager := NewXmuxManager(xmuxConfig, func() XmuxConn { return &fakeRoundTripper{} }) - clients := make(map[interface{}]struct{}) + xmuxClients := make(map[interface{}]struct{}) for i := 0; i < 8; i++ { - clients[mux.GetResource(context.Background())] = struct{}{} + xmuxClients[xmuxManager.GetXmuxClient(context.Background())] = struct{}{} } - if len(clients) != 4 { - t.Error("did not get 4 distinct clients, got ", len(clients)) + if len(xmuxClients) != 4 { + t.Error("did not get 4 distinct clients, got ", len(xmuxClients)) } } func TestCMaxReuseTimes(t *testing.T) { - config := Multiplexing{ - CMaxReuseTimes: &RandRangeConfig{From: 2, To: 2}, + xmuxConfig := XmuxConfig{ + CMaxReuseTimes: &RangeConfig{From: 2, To: 2}, } - mux := NewMuxManager(config, func() interface{} { + xmuxManager := NewXmuxManager(xmuxConfig, func() XmuxConn { return &fakeRoundTripper{} }) - clients := make(map[interface{}]struct{}) + xmuxClients := make(map[interface{}]struct{}) for i := 0; i < 64; i++ { - clients[mux.GetResource(context.Background())] = struct{}{} + xmuxClients[xmuxManager.GetXmuxClient(context.Background())] = struct{}{} } - if len(clients) != 32 { - t.Error("did not get 32 distinct clients, got ", len(clients)) + if len(xmuxClients) != 32 { + t.Error("did not get 32 distinct clients, got ", len(xmuxClients)) } } func TestMaxConcurrency(t *testing.T) { - config := Multiplexing{ - MaxConcurrency: &RandRangeConfig{From: 2, To: 2}, + xmuxConfig := XmuxConfig{ + MaxConcurrency: &RangeConfig{From: 2, To: 2}, } - mux := NewMuxManager(config, func() interface{} { + xmuxManager := NewXmuxManager(xmuxConfig, func() XmuxConn { return &fakeRoundTripper{} }) - clients := make(map[interface{}]struct{}) + xmuxClients := make(map[interface{}]struct{}) for i := 0; i < 64; i++ { - client := mux.GetResource(context.Background()) - client.OpenRequests.Add(1) - clients[client] = struct{}{} + xmuxClient := xmuxManager.GetXmuxClient(context.Background()) + xmuxClient.OpenUsage.Add(1) + xmuxClients[xmuxClient] = struct{}{} } - if len(clients) != 32 { - t.Error("did not get 32 distinct clients, got ", len(clients)) + if len(xmuxClients) != 32 { + t.Error("did not get 32 distinct clients, got ", len(xmuxClients)) } } func TestDefault(t *testing.T) { - config := Multiplexing{} + xmuxConfig := XmuxConfig{} - mux := NewMuxManager(config, func() interface{} { + xmuxManager := NewXmuxManager(xmuxConfig, func() XmuxConn { return &fakeRoundTripper{} }) - clients := make(map[interface{}]struct{}) + xmuxClients := make(map[interface{}]struct{}) for i := 0; i < 64; i++ { - client := mux.GetResource(context.Background()) - client.OpenRequests.Add(1) - clients[client] = struct{}{} + xmuxClient := xmuxManager.GetXmuxClient(context.Background()) + xmuxClient.OpenUsage.Add(1) + xmuxClients[xmuxClient] = struct{}{} } - if len(clients) != 1 { - t.Error("did not get 1 distinct clients, got ", len(clients)) + if len(xmuxClients) != 1 { + t.Error("did not get 1 distinct clients, got ", len(xmuxClients)) } } diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index 8f32f7d3..20043b4a 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -423,7 +423,7 @@ func Test_maxUpload(t *testing.T) { ProtocolName: "splithttp", ProtocolSettings: &Config{ Path: "/sh", - ScMaxEachPostBytes: &RandRangeConfig{ + ScMaxEachPostBytes: &RangeConfig{ From: 10000, To: 10000, }, From 7d0a80b501d430542ae851043de3da4d68335325 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 15 Dec 2024 12:36:19 +0000 Subject: [PATCH 644/867] v24.12.15 --- core/core.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/core.go b/core/core.go index ac469065..94f8b637 100644 --- a/core/core.go +++ b/core/core.go @@ -18,8 +18,8 @@ import ( var ( Version_x byte = 24 - Version_y byte = 11 - Version_z byte = 30 + Version_y byte = 12 + Version_z byte = 15 ) var ( From 5836afc41f780a48fba99460f30f7b6d1295c70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=90=E7=90=85=E5=BD=A9=E5=B1=B1=E6=B0=B4=E4=BD=A9?= =?UTF-8?q?=E5=A5=87=E7=AB=A5=E8=BD=A6=E6=B8=B8=E6=98=A5=E9=A9=AC=E8=B9=84?= =?UTF-8?q?=E6=9D=AF?= Date: Tue, 17 Dec 2024 16:53:16 +0800 Subject: [PATCH 645/867] WebSocket config: Fix `headers` (#4177) Fixes https://github.com/XTLS/Xray-core/issues/4176 --- infra/conf/transport_internet.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 08f5768e..1731695d 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -165,11 +165,13 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { } // Priority (client): host > serverName > address for k, v := range c.Headers { - errors.PrintDeprecatedFeatureWarning(`"host" in "headers"`, `independent "host"`) - if c.Host == "" { - c.Host = v + if strings.ToLower(k) == "host"{ + errors.PrintDeprecatedFeatureWarning(`"host" in "headers"`, `independent "host"`) + if c.Host == "" { + c.Host = v + } + delete(c.Headers, k) } - delete(c.Headers, k) } config := &websocket.Config{ Path: path, From 96fb680d45c6b356cadf67bcabe29ad5e1a2f6a5 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:02:51 +0000 Subject: [PATCH 646/867] REALITY, TLS config: Set "chrome" as the default fingerprint Other VLESS implementations should follow this change. --- infra/conf/transport_internet.go | 16 +++++++--------- transport/internet/tls/tls.go | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 1731695d..e19c145c 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -165,7 +165,7 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { } // Priority (client): host > serverName > address for k, v := range c.Headers { - if strings.ToLower(k) == "host"{ + if strings.ToLower(k) == "host" { errors.PrintDeprecatedFeatureWarning(`"host" in "headers"`, `independent "host"`) if c.Host == "" { c.Host = v @@ -438,7 +438,7 @@ func (c *TLSConfig) Build() (proto.Message, error) { config.MaxVersion = c.MaxVersion config.CipherSuites = c.CipherSuites config.Fingerprint = strings.ToLower(c.Fingerprint) - if config.Fingerprint != "" && tls.GetFingerprint(config.Fingerprint) == nil { + if config.Fingerprint != "unsafe" && tls.GetFingerprint(config.Fingerprint) == nil { return nil, errors.New(`unknown fingerprint: `, config.Fingerprint) } config.RejectUnknownSni = c.RejectUnknownSNI @@ -584,15 +584,13 @@ func (c *REALITYConfig) Build() (proto.Message, error) { config.ServerNames = c.ServerNames config.MaxTimeDiff = c.MaxTimeDiff } else { - if c.Fingerprint == "" { - return nil, errors.New(`empty "fingerprint"`) - } - if config.Fingerprint = strings.ToLower(c.Fingerprint); tls.GetFingerprint(config.Fingerprint) == nil { - return nil, errors.New(`unknown "fingerprint": `, config.Fingerprint) - } - if config.Fingerprint == "hellogolang" { + config.Fingerprint = strings.ToLower(c.Fingerprint) + if config.Fingerprint == "unsafe" || config.Fingerprint == "hellogolang" { return nil, errors.New(`invalid "fingerprint": `, config.Fingerprint) } + if tls.GetFingerprint(config.Fingerprint) == nil { + return nil, errors.New(`unknown "fingerprint": `, config.Fingerprint) + } if len(c.ServerNames) != 0 { return nil, errors.New(`non-empty "serverNames", please use "serverName" instead`) } diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index 38b603c0..4b8fa486 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -165,7 +165,7 @@ func init() { func GetFingerprint(name string) (fingerprint *utls.ClientHelloID) { if name == "" { - return + return &utls.HelloChrome_Auto } if fingerprint = PresetFingerprints[name]; fingerprint != nil { return @@ -191,6 +191,7 @@ var PresetFingerprints = map[string]*utls.ClientHelloID{ "qq": &utls.HelloQQ_Auto, "random": nil, "randomized": nil, + "unsafe": nil, } var ModernFingerprints = map[string]*utls.ClientHelloID{ From 9dbdf92c2728070e3e58008598880eb2e9f79188 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:22:29 +0000 Subject: [PATCH 647/867] XHTTP `downloadSettings`: Inherit `sockopt` if its own doesn't exist (e.g., in `extra`) If you want `downloadSettings` to use its own `sockopt`, make sure that `extra` doesn't exist. --- transport/internet/splithttp/dialer.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 973b8a9c..86c395d0 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -308,6 +308,9 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me globalDialerAccess.Lock() if streamSettings.DownloadSettings == nil { streamSettings.DownloadSettings = common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings)).(*internet.MemoryStreamConfig) + if streamSettings.DownloadSettings.SocketSettings == nil { + streamSettings.DownloadSettings.SocketSettings = streamSettings.SocketSettings + } } globalDialerAccess.Unlock() memory2 := streamSettings.DownloadSettings From a168f5360ea796cdab94fae95843368596395bf1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:32:11 +0000 Subject: [PATCH 648/867] Bump golang.org/x/crypto from 0.30.0 to 0.31.0 (#4156) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.30.0 to 0.31.0. - [Commits](https://github.com/golang/crypto/compare/v0.30.0...v0.31.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1ef6c840..68ec9bb7 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.30.0 + golang.org/x/crypto v0.31.0 golang.org/x/net v0.32.0 golang.org/x/sync v0.10.0 golang.org/x/sys v0.28.0 diff --git a/go.sum b/go.sum index 3740d8ef..d886eb9f 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= -golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= From 15318976f67a8dc60663f51b78f0bf73c931f7cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:43:48 +0000 Subject: [PATCH 649/867] Bump google.golang.org/protobuf from 1.35.2 to 1.36.0 (#4175) Bumps google.golang.org/protobuf from 1.35.2 to 1.36.0. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 68ec9bb7..187758d7 100644 --- a/go.mod +++ b/go.mod @@ -30,7 +30,7 @@ require ( golang.org/x/sys v0.28.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.67.1 - google.golang.org/protobuf v1.35.2 + google.golang.org/protobuf v1.36.0 gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.3.0 diff --git a/go.sum b/go.sum index d886eb9f..20b0e91e 100644 --- a/go.sum +++ b/go.sum @@ -129,8 +129,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= -google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= -google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ= +google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From ff8b66aacb0fdfd52c050fd62d73368545ebcd58 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:25:34 +0000 Subject: [PATCH 650/867] XHTTP client: `scMaxEachPostBytes` should be bigger than buf.Size (8192) To avoid no size limit. --- transport/internet/splithttp/dialer.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 86c395d0..cc792a1f 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -409,6 +409,10 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes() scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs() + if scMaxEachPostBytes.From <= buf.Size { + panic("`scMaxEachPostBytes` should be bigger than " + strconv.Itoa(buf.Size)) + } + maxUploadSize := scMaxEachPostBytes.rand() // WithSizeLimit(0) will still allow single bytes to pass, and a lot of // code relies on this behavior. Subtract 1 so that together with From cab2fdefd321203043af6b8ea9d7be762e9fc15a Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 18 Dec 2024 13:39:35 +0000 Subject: [PATCH 651/867] v24.12.18 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 94f8b637..cc3dcb6b 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 24 Version_y byte = 12 - Version_z byte = 15 + Version_z byte = 18 ) var ( From 1410b6335ba81aaa20f6cf460ec640501b968cef Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 20 Dec 2024 06:19:10 +0000 Subject: [PATCH 652/867] XHTTP XMUX: Fix OpenUsage never gets reduced Introduced in https://github.com/XTLS/Xray-core/pull/4163 --- transport/internet/splithttp/dialer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index cc792a1f..c0189d58 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -372,7 +372,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if xmuxClient2 != nil && xmuxClient2 != xmuxClient { xmuxClient2.OpenUsage.Add(1) } - var once atomic.Int32 + var closed atomic.Int32 conn := splitConn{ writer: writer, @@ -380,7 +380,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me remoteAddr: remoteAddr, localAddr: localAddr, onClose: func() { - if once.Add(-1) < 0 { + if closed.Add(1) > 1 { return } if xmuxClient != nil { From 53b04d560b0a4d3aaed62eb30aaa971bdccf2de6 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 20 Dec 2024 07:19:41 +0000 Subject: [PATCH 653/867] XHTTP client: Make H3 httptrace work on v2rayNG Introduced in https://github.com/XTLS/Xray-core/pull/4150 --- app/dns/nameserver_quic.go | 2 +- common/protocol/quic/sniff.go | 2 +- go.mod | 4 +--- go.sum | 4 ++-- transport/internet/splithttp/dialer.go | 4 ++-- transport/internet/splithttp/hub.go | 4 ++-- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 435cd0a3..5bb8df1d 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -9,7 +9,7 @@ import ( "sync/atomic" "time" - "github.com/quic-go/quic-go" + "github.com/xtls/quic-go" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" diff --git a/common/protocol/quic/sniff.go b/common/protocol/quic/sniff.go index 779e291b..855ef9f7 100644 --- a/common/protocol/quic/sniff.go +++ b/common/protocol/quic/sniff.go @@ -8,7 +8,7 @@ import ( "encoding/binary" "io" - "github.com/quic-go/quic-go/quicvarint" + "github.com/xtls/quic-go/quicvarint" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/bytespool" diff --git a/go.mod b/go.mod index 187758d7..ab084d32 100644 --- a/go.mod +++ b/go.mod @@ -2,8 +2,6 @@ module github.com/xtls/xray-core go 1.21.4 -replace github.com/quic-go/quic-go v0.46.0 => github.com/xtls/quic-go v0.46.2 - require ( github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 github.com/cloudflare/circl v1.4.0 @@ -14,7 +12,6 @@ require ( github.com/miekg/dns v1.1.62 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.0 - github.com/quic-go/quic-go v0.46.0 github.com/refraction-networking/utls v1.6.7 github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 @@ -22,6 +19,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.0 + github.com/xtls/quic-go v0.46.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.31.0 diff --git a/go.sum b/go.sum index 20b0e91e..87db06b4 100644 --- a/go.sum +++ b/go.sum @@ -68,8 +68,8 @@ github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQ github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/quic-go v0.46.2 h1:bzUnZIQIH8SyqYGR6fAXzEvZauA+32J/2w2AtnEFa1o= -github.com/xtls/quic-go v0.46.2/go.mod h1:1dLehS7TIR64+vxGR70GDcatWTOtMX2PUtnKsjbTurI= +github.com/xtls/quic-go v0.46.0 h1:yfv6h+/+iOeFhFnmJiwlZgnJjr4fPb4N4rQelffbs1U= +github.com/xtls/quic-go v0.46.0/go.mod h1:mN9lAuc8Vt7eHvnQkDIH5+uHh+DcLmTBma9rLqk/rPY= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index c0189d58..aed499c8 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -13,8 +13,8 @@ import ( "sync/atomic" "time" - "github.com/quic-go/quic-go" - "github.com/quic-go/quic-go/http3" + "github.com/xtls/quic-go" + "github.com/xtls/quic-go/http3" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 1df029dd..b7c5098b 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -11,8 +11,8 @@ import ( "sync" "time" - "github.com/quic-go/quic-go" - "github.com/quic-go/quic-go/http3" + "github.com/xtls/quic-go" + "github.com/xtls/quic-go/http3" goreality "github.com/xtls/reality" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" From db934f083218dddf40811e8f716074de2c280160 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 20 Dec 2024 14:35:33 +0000 Subject: [PATCH 654/867] XHTTP client: Merge Open* into OpenStream(), and more https://github.com/XTLS/Xray-core/issues/4148#issuecomment-2557066988 --- go.mod | 2 +- go.sum | 4 +- .../internet/splithttp/browser_client.go | 18 +- transport/internet/splithttp/client.go | 172 ++++-------------- transport/internet/splithttp/dialer.go | 44 ++--- transport/internet/splithttp/lazy_reader.go | 47 ----- 6 files changed, 61 insertions(+), 226 deletions(-) delete mode 100644 transport/internet/splithttp/lazy_reader.go diff --git a/go.mod b/go.mod index ab084d32..3302a075 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.0 - github.com/xtls/quic-go v0.46.0 + github.com/xtls/quic-go v0.0.0-20241220091641-6f5777d1c087 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.31.0 diff --git a/go.sum b/go.sum index 87db06b4..9728dfca 100644 --- a/go.sum +++ b/go.sum @@ -68,8 +68,8 @@ github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQ github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/quic-go v0.46.0 h1:yfv6h+/+iOeFhFnmJiwlZgnJjr4fPb4N4rQelffbs1U= -github.com/xtls/quic-go v0.46.0/go.mod h1:mN9lAuc8Vt7eHvnQkDIH5+uHh+DcLmTBma9rLqk/rPY= +github.com/xtls/quic-go v0.0.0-20241220091641-6f5777d1c087 h1:kKPg/cJPSKnE50VXVBskDYYSBkl4X3sMCIbTy+XKNGk= +github.com/xtls/quic-go v0.0.0-20241220091641-6f5777d1c087/go.mod h1:mN9lAuc8Vt7eHvnQkDIH5+uHh+DcLmTBma9rLqk/rPY= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= diff --git a/transport/internet/splithttp/browser_client.go b/transport/internet/splithttp/browser_client.go index 1b5f6d6b..d5d3d942 100644 --- a/transport/internet/splithttp/browser_client.go +++ b/transport/internet/splithttp/browser_client.go @@ -17,16 +17,12 @@ func (c *BrowserDialerClient) IsClosed() bool { panic("not implemented yet") } -func (c *BrowserDialerClient) Open(ctx context.Context, pureURL string) (io.WriteCloser, io.ReadCloser) { - panic("not implemented yet") -} +func (c *BrowserDialerClient) OpenStream(ctx context.Context, url string, body io.Reader, uploadOnly bool) (io.ReadCloser, gonet.Addr, gonet.Addr, error) { + if body != nil { + panic("not implemented yet") + } -func (c *BrowserDialerClient) OpenUpload(ctx context.Context, baseURL string) io.WriteCloser { - panic("not implemented yet") -} - -func (c *BrowserDialerClient) OpenDownload(ctx context.Context, baseURL string) (io.ReadCloser, gonet.Addr, gonet.Addr, error) { - conn, err := browser_dialer.DialGet(baseURL) + conn, err := browser_dialer.DialGet(url) dummyAddr := &gonet.IPAddr{} if err != nil { return nil, dummyAddr, dummyAddr, err @@ -35,8 +31,8 @@ func (c *BrowserDialerClient) OpenDownload(ctx context.Context, baseURL string) return websocket.NewConnection(conn, dummyAddr, nil, 0), conn.RemoteAddr(), conn.LocalAddr(), nil } -func (c *BrowserDialerClient) SendUploadRequest(ctx context.Context, url string, payload io.ReadWriteCloser, contentLength int64) error { - bytes, err := io.ReadAll(payload) +func (c *BrowserDialerClient) PostPacket(ctx context.Context, url string, body io.Reader, contentLength int64) error { + bytes, err := io.ReadAll(body) if err != nil { return err } diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index 3baea6f0..c6cfee55 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -20,21 +20,11 @@ import ( type DialerClient interface { IsClosed() bool - // (ctx, baseURL, payload) -> err - // baseURL already contains sessionId and seq - SendUploadRequest(context.Context, string, io.ReadWriteCloser, int64) error + // ctx, url, body, uploadOnly + OpenStream(context.Context, string, io.Reader, bool) (io.ReadCloser, net.Addr, net.Addr, error) - // (ctx, baseURL) -> (downloadReader, remoteAddr, localAddr) - // baseURL already contains sessionId - OpenDownload(context.Context, string) (io.ReadCloser, net.Addr, net.Addr, error) - - // (ctx, baseURL) -> uploadWriter - // baseURL already contains sessionId - OpenUpload(context.Context, string) io.WriteCloser - - // (ctx, pureURL) -> (uploadWriter, downloadReader) - // pureURL can not contain sessionId - Open(context.Context, string) (io.WriteCloser, io.ReadCloser) + // ctx, url, body, contentLength + PostPacket(context.Context, string, io.Reader, int64) error } // implements splithttp.DialerClient in terms of direct network connections @@ -52,136 +42,56 @@ func (c *DefaultDialerClient) IsClosed() bool { return c.closed } -func (c *DefaultDialerClient) Open(ctx context.Context, pureURL string) (io.WriteCloser, io.ReadCloser) { - reader, writer := io.Pipe() - req, _ := http.NewRequestWithContext(ctx, "POST", pureURL, reader) - req.Header = c.transportConfig.GetRequestHeader() - if !c.transportConfig.NoGRPCHeader { - req.Header.Set("Content-Type", "application/grpc") - } - wrc := &WaitReadCloser{Wait: make(chan struct{})} - go func() { - response, err := c.client.Do(req) - if err != nil || response.StatusCode != 200 { - if err != nil { - errors.LogInfoInner(ctx, err, "failed to open ", pureURL) - } else { - // c.closed = true - response.Body.Close() - errors.LogInfo(ctx, "unexpected status ", response.StatusCode) - } - wrc.Close() - return - } - wrc.Set(response.Body) - }() - return writer, wrc -} - -func (c *DefaultDialerClient) OpenUpload(ctx context.Context, baseURL string) io.WriteCloser { - reader, writer := io.Pipe() - req, _ := http.NewRequestWithContext(ctx, "POST", baseURL, reader) - req.Header = c.transportConfig.GetRequestHeader() - if !c.transportConfig.NoGRPCHeader { - req.Header.Set("Content-Type", "application/grpc") - } - go func() { - if resp, err := c.client.Do(req); err == nil { - if resp.StatusCode != 200 { - // c.closed = true - } - resp.Body.Close() - } - }() - return writer -} - -func (c *DefaultDialerClient) OpenDownload(ctx context.Context, baseURL string) (io.ReadCloser, gonet.Addr, gonet.Addr, error) { - var remoteAddr gonet.Addr - var localAddr gonet.Addr +func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, body io.Reader, uploadOnly bool) (wrc io.ReadCloser, remoteAddr, localAddr gonet.Addr, err error) { // this is done when the TCP/UDP connection to the server was established, // and we can unblock the Dial function and print correct net addresses in // logs gotConn := done.New() + ctx = httptrace.WithClientTrace(ctx, &httptrace.ClientTrace{ + GotConn: func(connInfo httptrace.GotConnInfo) { + remoteAddr = connInfo.Conn.RemoteAddr() + localAddr = connInfo.Conn.LocalAddr() + gotConn.Close() + }, + }) - var downResponse io.ReadCloser - gotDownResponse := done.New() - - ctx, ctxCancel := context.WithCancel(ctx) + method := "GET" + if body != nil { + method = "POST" + } + req, _ := http.NewRequestWithContext(ctx, method, url, body) + req.Header = c.transportConfig.GetRequestHeader() + if method == "POST" && !c.transportConfig.NoGRPCHeader { + req.Header.Set("Content-Type", "application/grpc") + } + wrc = &WaitReadCloser{Wait: make(chan struct{})} go func() { - trace := &httptrace.ClientTrace{ - GotConn: func(connInfo httptrace.GotConnInfo) { - remoteAddr = connInfo.Conn.RemoteAddr() - localAddr = connInfo.Conn.LocalAddr() - gotConn.Close() - }, - } - - // in case we hit an error, we want to unblock this part - defer gotConn.Close() - - ctx = httptrace.WithClientTrace(ctx, trace) - - req, err := http.NewRequestWithContext( - ctx, - "GET", - baseURL, - nil, - ) + resp, err := c.client.Do(req) if err != nil { - errors.LogInfoInner(ctx, err, "failed to construct download http request") - gotDownResponse.Close() + errors.LogInfoInner(ctx, err, "failed to "+method+" "+url) + gotConn.Close() + wrc.Close() return } - - req.Header = c.transportConfig.GetRequestHeader() - - response, err := c.client.Do(req) - gotConn.Close() - if err != nil { - errors.LogInfoInner(ctx, err, "failed to send download http request") - gotDownResponse.Close() - return - } - - if response.StatusCode != 200 { + if resp.StatusCode != 200 && !uploadOnly { // c.closed = true - response.Body.Close() - errors.LogInfo(ctx, "invalid status code on download:", response.Status) - gotDownResponse.Close() + errors.LogInfo(ctx, "unexpected status ", resp.StatusCode) + } + if resp.StatusCode != 200 || uploadOnly { + resp.Body.Close() + wrc.Close() return } - - downResponse = response.Body - gotDownResponse.Close() + wrc.(*WaitReadCloser).Set(resp.Body) }() <-gotConn.Wait() - - lazyDownload := &LazyReader{ - CreateReader: func() (io.Reader, error) { - <-gotDownResponse.Wait() - if downResponse == nil { - return nil, errors.New("downResponse failed") - } - return downResponse, nil - }, - } - - // workaround for https://github.com/quic-go/quic-go/issues/2143 -- - // always cancel request context so that Close cancels any Read. - // Should then match the behavior of http2 and http1. - reader := downloadBody{ - lazyDownload, - ctxCancel, - } - - return reader, remoteAddr, localAddr, nil + return } -func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, payload io.ReadWriteCloser, contentLength int64) error { - req, err := http.NewRequestWithContext(ctx, "POST", url, payload) +func (c *DefaultDialerClient) PostPacket(ctx context.Context, url string, body io.Reader, contentLength int64) error { + req, err := http.NewRequestWithContext(ctx, "POST", url, body) if err != nil { return err } @@ -257,16 +167,6 @@ func (c *DefaultDialerClient) SendUploadRequest(ctx context.Context, url string, return nil } -type downloadBody struct { - io.Reader - cancel context.CancelFunc -} - -func (c downloadBody) Close() error { - c.cancel() - return nil -} - type WaitReadCloser struct { Wait chan struct{} io.ReadCloser diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index aed499c8..d1b3ef09 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -343,29 +343,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me errors.LogInfo(ctx, fmt.Sprintf("XHTTP is downloading from %s, mode %s, HTTP version %s, host %s", dest2, "stream-down", httpVersion2, requestURL2.Host)) } - var writer io.WriteCloser - var reader io.ReadCloser - var remoteAddr, localAddr net.Addr - var err error - - if mode == "stream-one" { - requestURL.Path = transportConfiguration.GetNormalizedPath() - if xmuxClient != nil { - xmuxClient.LeftRequests.Add(-1) - } - writer, reader = httpClient.Open(context.WithoutCancel(ctx), requestURL.String()) - remoteAddr = &net.TCPAddr{} - localAddr = &net.TCPAddr{} - } else { - if xmuxClient2 != nil { - xmuxClient2.LeftRequests.Add(-1) - } - reader, remoteAddr, localAddr, err = httpClient2.OpenDownload(context.WithoutCancel(ctx), requestURL2.String()) - if err != nil { - return nil, err - } - } - if xmuxClient != nil { xmuxClient.OpenUsage.Add(1) } @@ -374,11 +351,9 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } var closed atomic.Int32 + reader, writer := io.Pipe() conn := splitConn{ - writer: writer, - reader: reader, - remoteAddr: remoteAddr, - localAddr: localAddr, + writer: writer, onClose: func() { if closed.Add(1) > 1 { return @@ -393,16 +368,27 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } if mode == "stream-one" { + requestURL.Path = transportConfiguration.GetNormalizedPath() if xmuxClient != nil { xmuxClient.LeftRequests.Add(-1) } + conn.reader, conn.remoteAddr, conn.localAddr, _ = httpClient.OpenStream(context.WithoutCancel(ctx), requestURL.String(), reader, false) return stat.Connection(&conn), nil + } else { // stream-down + var err error + if xmuxClient2 != nil { + xmuxClient2.LeftRequests.Add(-1) + } + conn.reader, conn.remoteAddr, conn.localAddr, err = httpClient2.OpenStream(context.WithoutCancel(ctx), requestURL2.String(), nil, false) + if err != nil { // browser dialer only + return nil, err + } } if mode == "stream-up" { if xmuxClient != nil { xmuxClient.LeftRequests.Add(-1) } - conn.writer = httpClient.OpenUpload(ctx, requestURL.String()) + httpClient.OpenStream(ctx, requestURL.String(), reader, true) return stat.Connection(&conn), nil } @@ -466,7 +452,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } go func() { - err := httpClient.SendUploadRequest( + err := httpClient.PostPacket( context.WithoutCancel(ctx), url.String(), &buf.MultiBufferContainer{MultiBuffer: chunk}, diff --git a/transport/internet/splithttp/lazy_reader.go b/transport/internet/splithttp/lazy_reader.go deleted file mode 100644 index 35d1f436..00000000 --- a/transport/internet/splithttp/lazy_reader.go +++ /dev/null @@ -1,47 +0,0 @@ -package splithttp - -import ( - "io" - "sync" -) - -// Close is intentionally not supported by LazyReader because it's not clear -// how CreateReader should be aborted in case of Close. It's best to wrap -// LazyReader in another struct that handles Close correctly, or better, stop -// using LazyReader entirely. -type LazyReader struct { - readerSync sync.Mutex - CreateReader func() (io.Reader, error) - reader io.Reader - readerError error -} - -func (r *LazyReader) getReader() (io.Reader, error) { - r.readerSync.Lock() - defer r.readerSync.Unlock() - if r.reader != nil { - return r.reader, nil - } - - if r.readerError != nil { - return nil, r.readerError - } - - reader, err := r.CreateReader() - if err != nil { - r.readerError = err - return nil, err - } - - r.reader = reader - return reader, nil -} - -func (r *LazyReader) Read(b []byte) (int, error) { - reader, err := r.getReader() - if err != nil { - return 0, err - } - n, err := reader.Read(b) - return n, err -} From 868799ef043e876338411e150c94cbf922b0bd50 Mon Sep 17 00:00:00 2001 From: maoxikun <106460972+maoxikun@users.noreply.github.com> Date: Sun, 22 Dec 2024 17:19:09 +0800 Subject: [PATCH 655/867] DNS: Always use a DNS Message ID of 0 for DoH and DoQ (#4193) Co-authored-by: dyhkwong <50692134+dyhkwong@users.noreply.github.com> --- app/dns/nameserver_doh.go | 4 +--- app/dns/nameserver_quic.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index bc160135..7c25bb8d 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -8,7 +8,6 @@ import ( "net/http" "net/url" "sync" - "sync/atomic" "time" "github.com/xtls/xray-core/common" @@ -35,7 +34,6 @@ type DoHNameServer struct { ips map[string]*record pub *pubsub.Service cleanup *task.Periodic - reqID uint32 httpClient *http.Client dohURL string name string @@ -222,7 +220,7 @@ func (s *DoHNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) { } func (s *DoHNameServer) newReqID() uint16 { - return uint16(atomic.AddUint32(&s.reqID, 1)) + return 0 } func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption) { diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 5bb8df1d..0691fac9 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -6,7 +6,6 @@ import ( "encoding/binary" "net/url" "sync" - "sync/atomic" "time" "github.com/xtls/quic-go" @@ -37,7 +36,6 @@ type QUICNameServer struct { ips map[string]*record pub *pubsub.Service cleanup *task.Periodic - reqID uint32 name string destination *net.Destination connection quic.Connection @@ -156,7 +154,7 @@ func (s *QUICNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) { } func (s *QUICNameServer) newReqID() uint16 { - return uint16(atomic.AddUint32(&s.reqID, 1)) + return 0 } func (s *QUICNameServer) sendQuery(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption) { From d54d20abea8409135beff9cba4b7db40ae98d367 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 22 Dec 2024 09:21:06 +0000 Subject: [PATCH 656/867] Bump golang.org/x/net from 0.32.0 to 0.33.0 (#4182) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.32.0 to 0.33.0. - [Commits](https://github.com/golang/net/compare/v0.32.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3302a075..211f69bb 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.31.0 - golang.org/x/net v0.32.0 + golang.org/x/net v0.33.0 golang.org/x/sync v0.10.0 golang.org/x/sys v0.28.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index 9728dfca..6bc49961 100644 --- a/go.sum +++ b/go.sum @@ -89,8 +89,8 @@ golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= From b287d6419b23dba458a6bb133337473f8ddee825 Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 24 Dec 2024 13:17:00 +0800 Subject: [PATCH 657/867] chore: use errors.New to replace fmt.Errorf with no parameters (#4204) Signed-off-by: RiceChuan --- common/common.go | 6 +++--- infra/vformat/main.go | 7 ++++--- infra/vprotogen/main.go | 11 ++++++----- main/commands/all/api/shared.go | 3 ++- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/common/common.go b/common/common.go index c00371be..a09f6fbe 100644 --- a/common/common.go +++ b/common/common.go @@ -38,7 +38,7 @@ func Error2(v interface{}, err error) error { func envFile() (string, error) { if file := os.Getenv("GOENV"); file != "" { if file == "off" { - return "", fmt.Errorf("GOENV=off") + return "", errors.New("GOENV=off") } return file, nil } @@ -47,7 +47,7 @@ func envFile() (string, error) { return "", err } if dir == "" { - return "", fmt.Errorf("missing user-config dir") + return "", errors.New("missing user-config dir") } return filepath.Join(dir, "go", "env"), nil } @@ -60,7 +60,7 @@ func GetRuntimeEnv(key string) (string, error) { return "", err } if file == "" { - return "", fmt.Errorf("missing runtime env file") + return "", errors.New("missing runtime env file") } var data []byte var runtimeEnv string diff --git a/infra/vformat/main.go b/infra/vformat/main.go index e676f08a..84c63a42 100644 --- a/infra/vformat/main.go +++ b/infra/vformat/main.go @@ -1,6 +1,7 @@ package main import ( + "errors" "flag" "fmt" "go/build" @@ -18,7 +19,7 @@ var directory = flag.String("pwd", "", "Working directory of Xray vformat.") func envFile() (string, error) { if file := os.Getenv("GOENV"); file != "" { if file == "off" { - return "", fmt.Errorf("GOENV=off") + return "", errors.New("GOENV=off") } return file, nil } @@ -27,7 +28,7 @@ func envFile() (string, error) { return "", err } if dir == "" { - return "", fmt.Errorf("missing user-config dir") + return "", errors.New("missing user-config dir") } return filepath.Join(dir, "go", "env"), nil } @@ -40,7 +41,7 @@ func GetRuntimeEnv(key string) (string, error) { return "", err } if file == "" { - return "", fmt.Errorf("missing runtime env file") + return "", errors.New("missing runtime env file") } var data []byte var runtimeEnv string diff --git a/infra/vprotogen/main.go b/infra/vprotogen/main.go index f62ae4ae..f5a4152a 100644 --- a/infra/vprotogen/main.go +++ b/infra/vprotogen/main.go @@ -1,6 +1,7 @@ package main import ( + "errors" "flag" "fmt" "go/build" @@ -22,7 +23,7 @@ var directory = flag.String("pwd", "", "Working directory of Xray vprotogen.") func envFile() (string, error) { if file := os.Getenv("GOENV"); file != "" { if file == "off" { - return "", fmt.Errorf("GOENV=off") + return "", errors.New("GOENV=off") } return file, nil } @@ -31,7 +32,7 @@ func envFile() (string, error) { return "", err } if dir == "" { - return "", fmt.Errorf("missing user-config dir") + return "", errors.New("missing user-config dir") } return filepath.Join(dir, "go", "env"), nil } @@ -44,7 +45,7 @@ func GetRuntimeEnv(key string) (string, error) { return "", err } if file == "" { - return "", fmt.Errorf("missing runtime env file") + return "", errors.New("missing runtime env file") } var data []byte var runtimeEnv string @@ -101,12 +102,12 @@ Download %s v%s or later from https://github.com/protocolbuffers/protobuf/releas func getProjectProtocVersion(url string) (string, error) { resp, err := http.Get(url) if err != nil { - return "", fmt.Errorf("can not get the version of protobuf used in xray project") + return "", errors.New("can not get the version of protobuf used in xray project") } defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil { - return "", fmt.Errorf("can not read from body") + return "", errors.New("can not read from body") } versionRegexp := regexp.MustCompile(`\/\/\s*protoc\s*v\d+\.(\d+\.\d+)`) matched := versionRegexp.FindStringSubmatch(string(body)) diff --git a/main/commands/all/api/shared.go b/main/commands/all/api/shared.go index f9d18265..79f4171a 100644 --- a/main/commands/all/api/shared.go +++ b/main/commands/all/api/shared.go @@ -3,6 +3,7 @@ package api import ( "bytes" "context" + "errors" "fmt" "io" "net/http" @@ -101,7 +102,7 @@ func fetchHTTPContent(target string) ([]byte, error) { content, err := buf.ReadAllToBytes(resp.Body) if err != nil { - return nil, fmt.Errorf("failed to read HTTP response") + return nil, errors.New("failed to read HTTP response") } return content, nil From a7909f8671bbc813c1e10a22ac4d3d5505e90368 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Dec 2024 13:03:17 +0000 Subject: [PATCH 658/867] Bump google.golang.org/protobuf from 1.36.0 to 1.36.1 (#4203) Bumps google.golang.org/protobuf from 1.36.0 to 1.36.1. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 211f69bb..37358157 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/sys v0.28.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.67.1 - google.golang.org/protobuf v1.36.0 + google.golang.org/protobuf v1.36.1 gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.3.0 diff --git a/go.sum b/go.sum index 6bc49961..885ac2fe 100644 --- a/go.sum +++ b/go.sum @@ -129,8 +129,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= -google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ= -google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 42aea01fb5b3c583852a4d44cca0b6c57be9039d Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 26 Dec 2024 07:55:12 -0500 Subject: [PATCH 659/867] Core: Add mutex to injection resolution (#4206) * Revert "Add RequireFeaturesAsync() that works regardless order of app init" * Add mutex to injection resolution - Turns out we already support async DI resolution regardless of feature ordering Previous code contain a race condition causing some resolution is lost - Note that the new mutex cover s.pendingResolutions and s.features but must not cover callbackResolution() due to deadlock - Refactor some method names and simplify code * Add OptionalFeatures injection For example OptionalFeatures() is useful for fakedns module --- app/dispatcher/default.go | 2 +- app/dns/nameserver.go | 2 +- app/observatory/command/command.go | 2 +- app/proxyman/command/command.go | 2 +- app/router/balancing.go | 6 +- app/router/command/command.go | 2 +- app/router/strategy_leastload.go | 6 +- app/router/strategy_leastping.go | 6 +- app/router/strategy_random.go | 6 +- core/xray.go | 162 +++++++++++++++-------------- core/xray_test.go | 2 +- proxy/dns/dns.go | 2 +- 12 files changed, 107 insertions(+), 93 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index dbf58dad..7bc58056 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -106,7 +106,7 @@ func init() { common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { d := new(DefaultDispatcher) if err := core.RequireFeatures(ctx, func(om outbound.Manager, router routing.Router, pm policy.Manager, sm stats.Manager, dc dns.Client) error { - core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { // FakeDNSEngine is optional + core.OptionalFeatures(ctx, func(fdns dns.FakeDNSEngine) { d.fdns = fdns }) return d.Init(config.(*Config), om, router, pm, sm, dc) diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index de6e1686..9c2668d9 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -56,7 +56,7 @@ func NewServer(ctx context.Context, dest net.Destination, dispatcher routing.Dis return NewTCPLocalNameServer(u, queryStrategy) case strings.EqualFold(u.String(), "fakedns"): var fd dns.FakeDNSEngine - core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { // FakeDNSEngine is optional + core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { fd = fdns }) return NewFakeDNSServer(fd), nil diff --git a/app/observatory/command/command.go b/app/observatory/command/command.go index aab85e80..f9bb58e3 100644 --- a/app/observatory/command/command.go +++ b/app/observatory/command/command.go @@ -38,7 +38,7 @@ func init() { sv := &service{v: s} err := s.RequireFeatures(func(Observatory extension.Observatory) { sv.observatory = Observatory - }) + }, false) if err != nil { return nil, err } diff --git a/app/proxyman/command/command.go b/app/proxyman/command/command.go index 3c7824d2..ef710521 100644 --- a/app/proxyman/command/command.go +++ b/app/proxyman/command/command.go @@ -177,7 +177,7 @@ func (s *service) Register(server *grpc.Server) { common.Must(s.v.RequireFeatures(func(im inbound.Manager, om outbound.Manager) { hs.ihm = im hs.ohm = om - })) + }, false)) RegisterHandlerServiceServer(server, hs) // For compatibility purposes diff --git a/app/router/balancing.go b/app/router/balancing.go index 7d8bb022..5f8cb1c2 100644 --- a/app/router/balancing.go +++ b/app/router/balancing.go @@ -5,6 +5,7 @@ import ( sync "sync" "github.com/xtls/xray-core/app/observatory" + "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/extension" @@ -31,9 +32,10 @@ type RoundRobinStrategy struct { func (s *RoundRobinStrategy) InjectContext(ctx context.Context) { s.ctx = ctx if len(s.FallbackTag) > 0 { - core.RequireFeaturesAsync(s.ctx, func(observatory extension.Observatory) { + common.Must(core.RequireFeatures(s.ctx, func(observatory extension.Observatory) error { s.observatory = observatory - }) + return nil + })) } } diff --git a/app/router/command/command.go b/app/router/command/command.go index baf76b8b..fd9caa22 100644 --- a/app/router/command/command.go +++ b/app/router/command/command.go @@ -135,7 +135,7 @@ func (s *service) Register(server *grpc.Server) { vCoreDesc := RoutingService_ServiceDesc vCoreDesc.ServiceName = "v2ray.core.app.router.command.RoutingService" server.RegisterService(&vCoreDesc, rs) - })) + }, false)) } func init() { diff --git a/app/router/strategy_leastload.go b/app/router/strategy_leastload.go index a4ef1c12..1bf3cbc0 100644 --- a/app/router/strategy_leastload.go +++ b/app/router/strategy_leastload.go @@ -7,6 +7,7 @@ import ( "time" "github.com/xtls/xray-core/app/observatory" + "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/core" @@ -59,9 +60,10 @@ type node struct { func (s *LeastLoadStrategy) InjectContext(ctx context.Context) { s.ctx = ctx - core.RequireFeaturesAsync(s.ctx, func(observatory extension.Observatory) { + common.Must(core.RequireFeatures(s.ctx, func(observatory extension.Observatory) error { s.observer = observatory - }) + return nil + })) } func (s *LeastLoadStrategy) PickOutbound(candidates []string) string { diff --git a/app/router/strategy_leastping.go b/app/router/strategy_leastping.go index b13d1a7d..ada3492d 100644 --- a/app/router/strategy_leastping.go +++ b/app/router/strategy_leastping.go @@ -4,6 +4,7 @@ import ( "context" "github.com/xtls/xray-core/app/observatory" + "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/extension" @@ -20,9 +21,10 @@ func (l *LeastPingStrategy) GetPrincipleTarget(strings []string) []string { func (l *LeastPingStrategy) InjectContext(ctx context.Context) { l.ctx = ctx - core.RequireFeaturesAsync(l.ctx, func(observatory extension.Observatory) { + common.Must(core.RequireFeatures(l.ctx, func(observatory extension.Observatory) error { l.observatory = observatory - }) + return nil + })) } func (l *LeastPingStrategy) PickOutbound(strings []string) string { diff --git a/app/router/strategy_random.go b/app/router/strategy_random.go index 9f4cdd77..ea9b7add 100644 --- a/app/router/strategy_random.go +++ b/app/router/strategy_random.go @@ -4,6 +4,7 @@ import ( "context" "github.com/xtls/xray-core/app/observatory" + "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/extension" @@ -20,9 +21,10 @@ type RandomStrategy struct { func (s *RandomStrategy) InjectContext(ctx context.Context) { s.ctx = ctx if len(s.FallbackTag) > 0 { - core.RequireFeaturesAsync(s.ctx, func(observatory extension.Observatory) { + common.Must(core.RequireFeatures(s.ctx, func(observatory extension.Observatory) error { s.observatory = observatory - }) + return nil + })) } } diff --git a/core/xray.go b/core/xray.go index 5ab10603..f6ccc27d 100644 --- a/core/xray.go +++ b/core/xray.go @@ -4,7 +4,6 @@ import ( "context" "reflect" "sync" - "time" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" @@ -45,22 +44,13 @@ func getFeature(allFeatures []features.Feature, t reflect.Type) features.Feature return nil } -func (r *resolution) resolve(allFeatures []features.Feature) (bool, error) { - var fs []features.Feature - for _, d := range r.deps { - f := getFeature(allFeatures, d) - if f == nil { - return false, nil - } - fs = append(fs, f) - } - +func (r *resolution) callbackResolution(allFeatures []features.Feature) error { callback := reflect.ValueOf(r.callback) var input []reflect.Value callbackType := callback.Type() for i := 0; i < callbackType.NumIn(); i++ { pt := callbackType.In(i) - for _, f := range fs { + for _, f := range allFeatures { if reflect.TypeOf(f).AssignableTo(pt) { input = append(input, reflect.ValueOf(f)) break @@ -85,15 +75,17 @@ func (r *resolution) resolve(allFeatures []features.Feature) (bool, error) { } } - return true, err + return err } // Instance combines all Xray features. type Instance struct { - access sync.Mutex - features []features.Feature - featureResolutions []resolution - running bool + statusLock sync.Mutex + features []features.Feature + pendingResolutions []resolution + pendingOptionalResolutions []resolution + running bool + resolveLock sync.Mutex ctx context.Context } @@ -154,13 +146,14 @@ func addOutboundHandlers(server *Instance, configs []*OutboundHandlerConfig) err // See Instance.RequireFeatures for more information. func RequireFeatures(ctx context.Context, callback interface{}) error { v := MustFromContext(ctx) - return v.RequireFeatures(callback) + return v.RequireFeatures(callback, false) } -// RequireFeaturesAsync registers a callback, which will be called when all dependent features are registered. The order of app init doesn't matter -func RequireFeaturesAsync(ctx context.Context, callback interface{}) { +// OptionalFeatures is a helper function to aquire features from Instance in context. +// See Instance.RequireFeatures for more information. +func OptionalFeatures(ctx context.Context, callback interface{}) error { v := MustFromContext(ctx) - v.RequireFeaturesAsync(callback) + return v.RequireFeatures(callback, true) } // New returns a new Xray instance based on given configuration. @@ -234,9 +227,12 @@ func initInstanceWithConfig(config *Config, server *Instance) (bool, error) { }(), ) - if server.featureResolutions != nil { + server.resolveLock.Lock() + if server.pendingResolutions != nil { + server.resolveLock.Unlock() return true, errors.New("not all dependencies are resolved.") } + server.resolveLock.Unlock() if err := addInboundHandlers(server, config.Inbound); err != nil { return true, err @@ -255,8 +251,8 @@ func (s *Instance) Type() interface{} { // Close shutdown the Xray instance. func (s *Instance) Close() error { - s.access.Lock() - defer s.access.Unlock() + s.statusLock.Lock() + defer s.statusLock.Unlock() s.running = false @@ -275,7 +271,7 @@ func (s *Instance) Close() error { // RequireFeatures registers a callback, which will be called when all dependent features are registered. // The callback must be a func(). All its parameters must be features.Feature. -func (s *Instance) RequireFeatures(callback interface{}) error { +func (s *Instance) RequireFeatures(callback interface{}, optional bool) error { callbackType := reflect.TypeOf(callback) if callbackType.Kind() != reflect.Func { panic("not a function") @@ -290,47 +286,32 @@ func (s *Instance) RequireFeatures(callback interface{}) error { deps: featureTypes, callback: callback, } - if finished, err := r.resolve(s.features); finished { - return err - } - s.featureResolutions = append(s.featureResolutions, r) - return nil -} -// RequireFeaturesAsync registers a callback, which will be called when all dependent features are registered. The order of app init doesn't matter -func (s *Instance) RequireFeaturesAsync(callback interface{}) { - callbackType := reflect.TypeOf(callback) - if callbackType.Kind() != reflect.Func { - panic("not a function") - } - - var featureTypes []reflect.Type - for i := 0; i < callbackType.NumIn(); i++ { - featureTypes = append(featureTypes, reflect.PtrTo(callbackType.In(i))) - } - - r := resolution{ - deps: featureTypes, - callback: callback, - } - go func() { - var finished = false - for i := 0; !finished; i++ { - if i > 100000 { - errors.LogError(s.ctx, "RequireFeaturesAsync failed after count ", i) - break; - } - finished, _ = r.resolve(s.features) - time.Sleep(time.Millisecond) + s.resolveLock.Lock() + foundAll := true + for _, d := range r.deps { + f := getFeature(s.features, d) + if f == nil { + foundAll = false + break } - s.featureResolutions = append(s.featureResolutions, r) - }() + } + if foundAll { + s.resolveLock.Unlock() + return r.callbackResolution(s.features) + } else { + if optional { + s.pendingOptionalResolutions = append(s.pendingOptionalResolutions, r) + } else { + s.pendingResolutions = append(s.pendingResolutions, r) + } + s.resolveLock.Unlock() + return nil + } } // AddFeature registers a feature into current Instance. func (s *Instance) AddFeature(feature features.Feature) error { - s.features = append(s.features, feature) - if s.running { if err := feature.Start(); err != nil { errors.LogInfoInner(s.ctx, err, "failed to start feature") @@ -338,27 +319,52 @@ func (s *Instance) AddFeature(feature features.Feature) error { return nil } - if s.featureResolutions == nil { - return nil - } + s.resolveLock.Lock() + s.features = append(s.features, feature) - var pendingResolutions []resolution - for _, r := range s.featureResolutions { - finished, err := r.resolve(s.features) - if finished && err != nil { - return err + var availableResolution []resolution + var pending []resolution + for _, r := range s.pendingResolutions { + foundAll := true + for _, d := range r.deps { + f := getFeature(s.features, d) + if f == nil { + foundAll = false + break + } } - if !finished { - pendingResolutions = append(pendingResolutions, r) + if foundAll { + availableResolution = append(availableResolution, r) + } else { + pending = append(pending, r) } } - if len(pendingResolutions) == 0 { - s.featureResolutions = nil - } else if len(pendingResolutions) < len(s.featureResolutions) { - s.featureResolutions = pendingResolutions - } + s.pendingResolutions = pending - return nil + var pendingOptional []resolution + for _, r := range s.pendingOptionalResolutions { + foundAll := true + for _, d := range r.deps { + f := getFeature(s.features, d) + if f == nil { + foundAll = false + break + } + } + if foundAll { + availableResolution = append(availableResolution, r) + } else { + pendingOptional = append(pendingOptional, r) + } + } + s.pendingOptionalResolutions = pendingOptional + s.resolveLock.Unlock() + + var err error + for _, r := range availableResolution { + err = r.callbackResolution(s.features) // only return the last error for now + } + return err } // GetFeature returns a feature of the given type, or nil if such feature is not registered. @@ -371,8 +377,8 @@ func (s *Instance) GetFeature(featureType interface{}) features.Feature { // // xray:api:stable func (s *Instance) Start() error { - s.access.Lock() - defer s.access.Unlock() + s.statusLock.Lock() + defer s.statusLock.Unlock() s.running = true for _, f := range s.features { diff --git a/core/xray_test.go b/core/xray_test.go index 43d021ef..f4cb11ab 100644 --- a/core/xray_test.go +++ b/core/xray_test.go @@ -30,7 +30,7 @@ func TestXrayDependency(t *testing.T) { t.Error("expected dns client fulfilled, but actually nil") } wait <- true - }) + }, false) instance.AddFeature(localdns.New()) <-wait } diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index 790c80c1..b7a3264a 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -27,7 +27,7 @@ func init() { common.Must(common.RegisterConfig((*Config)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { h := new(Handler) if err := core.RequireFeatures(ctx, func(dnsClient dns.Client, policyManager policy.Manager) error { - core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { // FakeDNSEngine is optional + core.OptionalFeatures(ctx, func(fdns dns.FakeDNSEngine) { h.fdns = fdns }) return h.Init(config.(*Config), dnsClient, policyManager) From a8559a1b465909ef4d7ce222361c316bcaaa7f4f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 28 Dec 2024 04:06:49 +0000 Subject: [PATCH 660/867] Dokodemo TPROXY: Interrupt UDP download if upload timeouts https://github.com/XTLS/Xray-core/issues/4194#issuecomment-2564156340 Fixes https://github.com/XTLS/Xray-core/issues/4194 --- proxy/dokodemo/dokodemo.go | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index bbeab18f..6522f071 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -2,6 +2,7 @@ package dokodemo import ( "context" + "runtime" "sync/atomic" "github.com/xtls/xray-core/common" @@ -147,10 +148,6 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st return nil } - tproxyRequest := func() error { - return nil - } - var writer buf.Writer if network == net.Network_TCP { writer = buf.NewWriter(conn) @@ -180,7 +177,12 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st return err } writer = NewPacketWriter(pConn, &dest, mark, back) - defer writer.(*PacketWriter).Close() + defer func() { + runtime.Gosched() + common.Interrupt(link.Reader) // maybe duplicated + runtime.Gosched() + writer.(*PacketWriter).Close() // close fake UDP conns + }() /* sockopt := &internet.SocketConfig{ Tproxy: internet.SocketConfig_TProxy, @@ -219,17 +221,24 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st responseDone := func() error { defer timer.SetTimeout(plcy.Timeouts.UplinkOnly) + if network == net.Network_UDP && destinationOverridden { + buf.Copy(link.Reader, writer) // respect upload's timeout + return nil + } + if err := buf.Copy(link.Reader, writer, buf.UpdateActivity(timer)); err != nil { return errors.New("failed to transport response").Base(err) } return nil } - if err := task.Run(ctx, task.OnSuccess(func() error { - return task.Run(ctx, requestDone, tproxyRequest) - }, task.Close(link.Writer)), responseDone); err != nil { - common.Interrupt(link.Reader) + if err := task.Run(ctx, + task.OnSuccess(func() error { return task.Run(ctx, requestDone) }, task.Close(link.Writer)), + responseDone); err != nil { + runtime.Gosched() common.Interrupt(link.Writer) + runtime.Gosched() + common.Interrupt(link.Reader) return errors.New("connection ends").Base(err) } From ff4331a7a86bb2e4341713fbfb20270bb1b17c20 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 28 Dec 2024 08:20:59 +0000 Subject: [PATCH 661/867] XHTTP XMUX: Increase the default value for `cMaxReuseTimes` "64-128" -> "256-512" --- infra/conf/transport_internet.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index e19c145c..49f84e49 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -287,8 +287,8 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { if c.Xmux == (XmuxConfig{}) { c.Xmux.MaxConcurrency.From = 16 c.Xmux.MaxConcurrency.To = 32 - c.Xmux.CMaxReuseTimes.From = 64 - c.Xmux.CMaxReuseTimes.To = 128 + c.Xmux.CMaxReuseTimes.From = 256 + c.Xmux.CMaxReuseTimes.To = 512 c.Xmux.HMaxRequestTimes.From = 800 c.Xmux.HMaxRequestTimes.To = 900 } From 93f72db9fd21d7c6d006d0137e74efdd242b8171 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 28 Dec 2024 13:57:23 +0000 Subject: [PATCH 662/867] v24.12.28 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index cc3dcb6b..751cbe47 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 24 Version_y byte = 12 - Version_z byte = 18 + Version_z byte = 28 ) var ( From 4ce65fc74c4c50919b10b3faff9725f75bba5d73 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 31 Dec 2024 10:00:19 +0000 Subject: [PATCH 663/867] XHTTP XMUX: `cMaxLifetimeMs` -> `hMaxReusableSecs`, Refactor default values "xmux": { "maxConcurrency": "16-32", "maxConnections": 0, "cMaxReuseTimes": 0, "hMaxRequestTimes": "600-900", "hMaxReusableSecs": "1800-3000", "hKeepAlivePeriod": 0 } Fixes https://github.com/XTLS/Xray-core/discussions/4113#discussioncomment-11685057 --- infra/conf/transport_internet.go | 10 +- transport/internet/splithttp/config.go | 77 ++++++----- transport/internet/splithttp/config.pb.go | 160 +++++++++++----------- transport/internet/splithttp/config.proto | 4 +- transport/internet/splithttp/dialer.go | 3 +- transport/internet/splithttp/mux.go | 31 ++--- 6 files changed, 143 insertions(+), 142 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 49f84e49..275841a3 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -240,8 +240,8 @@ type XmuxConfig struct { MaxConcurrency Int32Range `json:"maxConcurrency"` MaxConnections Int32Range `json:"maxConnections"` CMaxReuseTimes Int32Range `json:"cMaxReuseTimes"` - CMaxLifetimeMs Int32Range `json:"cMaxLifetimeMs"` HMaxRequestTimes Int32Range `json:"hMaxRequestTimes"` + HMaxReusableSecs Int32Range `json:"hMaxReusableSecs"` HKeepAlivePeriod int64 `json:"hKeepAlivePeriod"` } @@ -287,10 +287,10 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { if c.Xmux == (XmuxConfig{}) { c.Xmux.MaxConcurrency.From = 16 c.Xmux.MaxConcurrency.To = 32 - c.Xmux.CMaxReuseTimes.From = 256 - c.Xmux.CMaxReuseTimes.To = 512 - c.Xmux.HMaxRequestTimes.From = 800 + c.Xmux.HMaxRequestTimes.From = 600 c.Xmux.HMaxRequestTimes.To = 900 + c.Xmux.HMaxReusableSecs.From = 1800 + c.Xmux.HMaxReusableSecs.To = 3000 } config := &splithttp.Config{ @@ -308,8 +308,8 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { MaxConcurrency: newRangeConfig(c.Xmux.MaxConcurrency), MaxConnections: newRangeConfig(c.Xmux.MaxConnections), CMaxReuseTimes: newRangeConfig(c.Xmux.CMaxReuseTimes), - CMaxLifetimeMs: newRangeConfig(c.Xmux.CMaxLifetimeMs), HMaxRequestTimes: newRangeConfig(c.Xmux.HMaxRequestTimes), + HMaxReusableSecs: newRangeConfig(c.Xmux.HMaxReusableSecs), HKeepAlivePeriod: c.Xmux.HKeepAlivePeriod, }, } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 804bbd7e..190cb633 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -64,12 +64,15 @@ func (c *Config) WriteResponseHeader(writer http.ResponseWriter) { } } -func (c *Config) GetNormalizedScMaxBufferedPosts() int { - if c.ScMaxBufferedPosts == 0 { - return 30 +func (c *Config) GetNormalizedXPaddingBytes() RangeConfig { + if c.XPaddingBytes == nil || c.XPaddingBytes.To == 0 { + return RangeConfig{ + From: 100, + To: 1000, + } } - return int(c.ScMaxBufferedPosts) + return *c.XPaddingBytes } func (c *Config) GetNormalizedScMaxEachPostBytes() RangeConfig { @@ -94,47 +97,23 @@ func (c *Config) GetNormalizedScMinPostsIntervalMs() RangeConfig { return *c.ScMinPostsIntervalMs } -func (c *Config) GetNormalizedXPaddingBytes() RangeConfig { - if c.XPaddingBytes == nil || c.XPaddingBytes.To == 0 { - return RangeConfig{ - From: 100, - To: 1000, - } +func (c *Config) GetNormalizedScMaxBufferedPosts() int { + if c.ScMaxBufferedPosts == 0 { + return 30 } - return *c.XPaddingBytes + return int(c.ScMaxBufferedPosts) } -func (m *XmuxConfig) GetNormalizedCMaxRequestTimes() RangeConfig { - if m.HMaxRequestTimes == nil { +func (m *XmuxConfig) GetNormalizedMaxConcurrency() RangeConfig { + if m.MaxConcurrency == nil { return RangeConfig{ From: 0, To: 0, } } - return *m.HMaxRequestTimes -} - -func (m *XmuxConfig) GetNormalizedCMaxReuseTimes() RangeConfig { - if m.CMaxReuseTimes == nil { - return RangeConfig{ - From: 0, - To: 0, - } - } - - return *m.CMaxReuseTimes -} - -func (m *XmuxConfig) GetNormalizedCMaxLifetimeMs() RangeConfig { - if m.CMaxLifetimeMs == nil { - return RangeConfig{ - From: 0, - To: 0, - } - } - return *m.CMaxLifetimeMs + return *m.MaxConcurrency } func (m *XmuxConfig) GetNormalizedMaxConnections() RangeConfig { @@ -148,15 +127,37 @@ func (m *XmuxConfig) GetNormalizedMaxConnections() RangeConfig { return *m.MaxConnections } -func (m *XmuxConfig) GetNormalizedMaxConcurrency() RangeConfig { - if m.MaxConcurrency == nil { +func (m *XmuxConfig) GetNormalizedCMaxReuseTimes() RangeConfig { + if m.CMaxReuseTimes == nil { return RangeConfig{ From: 0, To: 0, } } - return *m.MaxConcurrency + return *m.CMaxReuseTimes +} + +func (m *XmuxConfig) GetNormalizedHMaxRequestTimes() RangeConfig { + if m.HMaxRequestTimes == nil { + return RangeConfig{ + From: 0, + To: 0, + } + } + + return *m.HMaxRequestTimes +} + +func (m *XmuxConfig) GetNormalizedHMaxReusableSecs() RangeConfig { + if m.HMaxReusableSecs == nil { + return RangeConfig{ + From: 0, + To: 0, + } + } + + return *m.HMaxReusableSecs } func init() { diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 2dd953d0..139ba1bc 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -82,8 +82,8 @@ type XmuxConfig struct { MaxConcurrency *RangeConfig `protobuf:"bytes,1,opt,name=maxConcurrency,proto3" json:"maxConcurrency,omitempty"` MaxConnections *RangeConfig `protobuf:"bytes,2,opt,name=maxConnections,proto3" json:"maxConnections,omitempty"` CMaxReuseTimes *RangeConfig `protobuf:"bytes,3,opt,name=cMaxReuseTimes,proto3" json:"cMaxReuseTimes,omitempty"` - CMaxLifetimeMs *RangeConfig `protobuf:"bytes,4,opt,name=cMaxLifetimeMs,proto3" json:"cMaxLifetimeMs,omitempty"` - HMaxRequestTimes *RangeConfig `protobuf:"bytes,5,opt,name=hMaxRequestTimes,proto3" json:"hMaxRequestTimes,omitempty"` + HMaxRequestTimes *RangeConfig `protobuf:"bytes,4,opt,name=hMaxRequestTimes,proto3" json:"hMaxRequestTimes,omitempty"` + HMaxReusableSecs *RangeConfig `protobuf:"bytes,5,opt,name=hMaxReusableSecs,proto3" json:"hMaxReusableSecs,omitempty"` HKeepAlivePeriod int64 `protobuf:"varint,6,opt,name=hKeepAlivePeriod,proto3" json:"hKeepAlivePeriod,omitempty"` } @@ -138,16 +138,16 @@ func (x *XmuxConfig) GetCMaxReuseTimes() *RangeConfig { return nil } -func (x *XmuxConfig) GetCMaxLifetimeMs() *RangeConfig { +func (x *XmuxConfig) GetHMaxRequestTimes() *RangeConfig { if x != nil { - return x.CMaxLifetimeMs + return x.HMaxRequestTimes } return nil } -func (x *XmuxConfig) GetHMaxRequestTimes() *RangeConfig { +func (x *XmuxConfig) GetHMaxReusableSecs() *RangeConfig { if x != nil { - return x.HMaxRequestTimes + return x.HMaxReusableSecs } return nil } @@ -305,7 +305,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x31, 0x0a, 0x0b, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x72, 0x6f, 0x6d, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, - 0x74, 0x6f, 0x22, 0xf4, 0x03, 0x0a, 0x0a, 0x58, 0x6d, 0x75, 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x74, 0x6f, 0x22, 0xf8, 0x03, 0x0a, 0x0a, 0x58, 0x6d, 0x75, 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x56, 0x0a, 0x0e, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, @@ -322,78 +322,78 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x52, - 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x56, 0x0a, 0x0e, 0x63, 0x4d, 0x61, - 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, - 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x52, 0x0e, 0x63, 0x4d, 0x61, 0x78, 0x4c, 0x69, 0x66, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x4d, - 0x73, 0x12, 0x5a, 0x0a, 0x10, 0x68, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, - 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x68, 0x4d, 0x61, - 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x2a, 0x0a, - 0x10, 0x68, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, - 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x68, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, - 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x22, 0xf8, 0x05, 0x0a, 0x06, 0x43, 0x6f, - 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, - 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, - 0x12, 0x50, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x36, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, - 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x48, 0x65, 0x61, - 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, - 0x72, 0x73, 0x12, 0x54, 0x0a, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, - 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, - 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, - 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x6e, 0x6f, 0x47, 0x52, - 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, - 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x20, 0x0a, 0x0b, - 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x5e, - 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, - 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, - 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, - 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x62, - 0x0a, 0x14, 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, - 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x14, 0x73, 0x63, - 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, - 0x4d, 0x73, 0x12, 0x2e, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, 0x66, 0x65, - 0x72, 0x65, 0x64, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x12, - 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x65, 0x64, 0x50, 0x6f, 0x73, - 0x74, 0x73, 0x12, 0x41, 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x65, 0x75, 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x10, 0x68, 0x4d, 0x61, + 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, + 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x52, 0x10, 0x68, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x5a, 0x0a, 0x10, 0x68, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, + 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, + 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, + 0x10, 0x68, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, + 0x73, 0x12, 0x2a, 0x0a, 0x10, 0x68, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, + 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x68, 0x4b, 0x65, + 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x22, 0xf8, 0x05, + 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, + 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x50, 0x0a, 0x07, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, + 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, + 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x2e, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x07, 0x68, + 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x54, 0x0a, 0x0d, 0x78, 0x50, 0x61, 0x64, 0x64, 0x69, + 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, + 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x78, + 0x50, 0x61, 0x64, 0x64, 0x69, 0x6e, 0x67, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, + 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0c, 0x6e, 0x6f, 0x47, 0x52, 0x50, 0x43, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, + 0x12, 0x20, 0x0a, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x6e, 0x6f, 0x53, 0x53, 0x45, 0x48, 0x65, 0x61, 0x64, + 0x65, 0x72, 0x12, 0x5e, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, + 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, + 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x12, + 0x73, 0x63, 0x4d, 0x61, 0x78, 0x45, 0x61, 0x63, 0x68, 0x50, 0x6f, 0x73, 0x74, 0x42, 0x79, 0x74, + 0x65, 0x73, 0x12, 0x62, 0x0a, 0x14, 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, - 0x68, 0x74, 0x74, 0x70, 0x2e, 0x58, 0x6d, 0x75, 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, - 0x04, 0x78, 0x6d, 0x75, 0x78, 0x12, 0x51, 0x0a, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, - 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, - 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, - 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, - 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, - 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x52, 0x14, 0x73, 0x63, 0x4d, 0x69, 0x6e, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x49, 0x6e, 0x74, 0x65, + 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x2e, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, + 0x75, 0x66, 0x66, 0x65, 0x72, 0x65, 0x64, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x65, + 0x64, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x58, 0x6d, 0x75, 0x78, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x52, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x12, 0x51, 0x0a, 0x10, 0x64, 0x6f, 0x77, + 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x0c, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, + 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, + 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, + 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, + 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, + 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -420,8 +420,8 @@ var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 0, // 0: xray.transport.internet.splithttp.XmuxConfig.maxConcurrency:type_name -> xray.transport.internet.splithttp.RangeConfig 0, // 1: xray.transport.internet.splithttp.XmuxConfig.maxConnections:type_name -> xray.transport.internet.splithttp.RangeConfig 0, // 2: xray.transport.internet.splithttp.XmuxConfig.cMaxReuseTimes:type_name -> xray.transport.internet.splithttp.RangeConfig - 0, // 3: xray.transport.internet.splithttp.XmuxConfig.cMaxLifetimeMs:type_name -> xray.transport.internet.splithttp.RangeConfig - 0, // 4: xray.transport.internet.splithttp.XmuxConfig.hMaxRequestTimes:type_name -> xray.transport.internet.splithttp.RangeConfig + 0, // 3: xray.transport.internet.splithttp.XmuxConfig.hMaxRequestTimes:type_name -> xray.transport.internet.splithttp.RangeConfig + 0, // 4: xray.transport.internet.splithttp.XmuxConfig.hMaxReusableSecs:type_name -> xray.transport.internet.splithttp.RangeConfig 3, // 5: xray.transport.internet.splithttp.Config.headers:type_name -> xray.transport.internet.splithttp.Config.HeadersEntry 0, // 6: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RangeConfig 0, // 7: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RangeConfig diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 08677266..577d75c2 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -17,8 +17,8 @@ message XmuxConfig { RangeConfig maxConcurrency = 1; RangeConfig maxConnections = 2; RangeConfig cMaxReuseTimes = 3; - RangeConfig cMaxLifetimeMs = 4; - RangeConfig hMaxRequestTimes = 5; + RangeConfig hMaxRequestTimes = 4; + RangeConfig hMaxReusableSecs = 5; int64 hKeepAlivePeriod = 6; } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index d1b3ef09..eb722d1c 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -447,7 +447,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me lastWrite = time.Now() - if xmuxClient != nil && xmuxClient.LeftRequests.Add(-1) <= 0 { + if xmuxClient != nil && (xmuxClient.LeftRequests.Add(-1) <= 0 || + (xmuxClient.UnreusableAt != time.Time{} && lastWrite.After(xmuxClient.UnreusableAt))) { httpClient, xmuxClient = getHTTPClient(ctx, dest, streamSettings) } diff --git a/transport/internet/splithttp/mux.go b/transport/internet/splithttp/mux.go index e658c006..093ddd12 100644 --- a/transport/internet/splithttp/mux.go +++ b/transport/internet/splithttp/mux.go @@ -16,11 +16,11 @@ type XmuxConn interface { } type XmuxClient struct { - XmuxConn XmuxConn - OpenUsage atomic.Int32 - leftUsage int32 - expirationTime time.Time - LeftRequests atomic.Int32 + XmuxConn XmuxConn + OpenUsage atomic.Int32 + leftUsage int32 + LeftRequests atomic.Int32 + UnreusableAt time.Time } type XmuxManager struct { @@ -43,20 +43,19 @@ func NewXmuxManager(xmuxConfig XmuxConfig, newConnFunc func() XmuxConn) *XmuxMan func (m *XmuxManager) newXmuxClient() *XmuxClient { xmuxClient := &XmuxClient{ - XmuxConn: m.newConnFunc(), - leftUsage: -1, - expirationTime: time.UnixMilli(0), + XmuxConn: m.newConnFunc(), + leftUsage: -1, } if x := m.xmuxConfig.GetNormalizedCMaxReuseTimes().rand(); x > 0 { xmuxClient.leftUsage = x - 1 } - if x := m.xmuxConfig.GetNormalizedCMaxLifetimeMs().rand(); x > 0 { - xmuxClient.expirationTime = time.Now().Add(time.Duration(x) * time.Millisecond) - } xmuxClient.LeftRequests.Store(math.MaxInt32) - if x := m.xmuxConfig.GetNormalizedCMaxRequestTimes().rand(); x > 0 { + if x := m.xmuxConfig.GetNormalizedHMaxRequestTimes().rand(); x > 0 { xmuxClient.LeftRequests.Store(x) } + if x := m.xmuxConfig.GetNormalizedHMaxReusableSecs().rand(); x > 0 { + xmuxClient.UnreusableAt = time.Now().Add(time.Duration(x) * time.Second) + } m.xmuxClients = append(m.xmuxClients, xmuxClient) return xmuxClient } @@ -66,13 +65,13 @@ func (m *XmuxManager) GetXmuxClient(ctx context.Context) *XmuxClient { // when l xmuxClient := m.xmuxClients[i] if xmuxClient.XmuxConn.IsClosed() || xmuxClient.leftUsage == 0 || - (xmuxClient.expirationTime != time.UnixMilli(0) && time.Now().After(xmuxClient.expirationTime)) || - xmuxClient.LeftRequests.Load() <= 0 { + xmuxClient.LeftRequests.Load() <= 0 || + (xmuxClient.UnreusableAt != time.Time{} && time.Now().After(xmuxClient.UnreusableAt)) { errors.LogDebug(ctx, "XMUX: removing xmuxClient, IsClosed() = ", xmuxClient.XmuxConn.IsClosed(), ", OpenUsage = ", xmuxClient.OpenUsage.Load(), ", leftUsage = ", xmuxClient.leftUsage, - ", expirationTime = ", xmuxClient.expirationTime, - ", LeftRequests = ", xmuxClient.LeftRequests.Load()) + ", LeftRequests = ", xmuxClient.LeftRequests.Load(), + ", UnreusableAt = ", xmuxClient.UnreusableAt) m.xmuxClients = append(m.xmuxClients[:i], m.xmuxClients[i+1:]...) } else { i++ From 369d8944cf3773300eb8dad3f909957e5705fc49 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:10:17 +0000 Subject: [PATCH 664/867] Sockopt config: Add `penetrate` for XHTTP U-D-S, Remove `tcpNoDelay` Now `sockopt` can be shared via `extra`, and be replaced with upload's forcibly. Closes https://github.com/XTLS/Xray-core/issues/4227 --- infra/conf/transport_internet.go | 8 +-- transport/internet/config.pb.go | 68 +++++++++++++------------- transport/internet/config.proto | 4 +- transport/internet/sockopt_darwin.go | 6 --- transport/internet/sockopt_linux.go | 5 -- transport/internet/sockopt_windows.go | 5 -- transport/internet/splithttp/dialer.go | 2 +- 7 files changed, 39 insertions(+), 59 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 275841a3..cb546537 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -262,7 +262,6 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { extra.Host = c.Host extra.Path = c.Path extra.Mode = c.Mode - extra.Extra = c.Extra c = &extra } @@ -318,9 +317,6 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { if c.Mode == "stream-one" { return nil, errors.New(`Can not use "downloadSettings" in "stream-one" mode.`) } - if c.Extra != nil { - c.DownloadSettings.SocketSettings = nil - } var err error if config.DownloadSettings, err = c.DownloadSettings.Build(); err != nil { return nil, errors.New(`Failed to build "downloadSettings".`).Base(err) @@ -689,7 +685,7 @@ type SocketConfig struct { TCPCongestion string `json:"tcpCongestion"` TCPWindowClamp int32 `json:"tcpWindowClamp"` TCPMaxSeg int32 `json:"tcpMaxSeg"` - TcpNoDelay bool `json:"tcpNoDelay"` + Penetrate bool `json:"penetrate"` TCPUserTimeout int32 `json:"tcpUserTimeout"` V6only bool `json:"v6only"` Interface string `json:"interface"` @@ -776,7 +772,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { TcpCongestion: c.TCPCongestion, TcpWindowClamp: c.TCPWindowClamp, TcpMaxSeg: c.TCPMaxSeg, - TcpNoDelay: c.TcpNoDelay, + Penetrate: c.Penetrate, TcpUserTimeout: c.TCPUserTimeout, V6Only: c.V6only, Interface: c.Interface, diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 2cd58fe1..d74fa665 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -448,7 +448,7 @@ type SocketConfig struct { TcpWindowClamp int32 `protobuf:"varint,15,opt,name=tcp_window_clamp,json=tcpWindowClamp,proto3" json:"tcp_window_clamp,omitempty"` TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` TcpMaxSeg int32 `protobuf:"varint,17,opt,name=tcp_max_seg,json=tcpMaxSeg,proto3" json:"tcp_max_seg,omitempty"` - TcpNoDelay bool `protobuf:"varint,18,opt,name=tcp_no_delay,json=tcpNoDelay,proto3" json:"tcp_no_delay,omitempty"` + Penetrate bool `protobuf:"varint,18,opt,name=penetrate,proto3" json:"penetrate,omitempty"` TcpMptcp bool `protobuf:"varint,19,opt,name=tcp_mptcp,json=tcpMptcp,proto3" json:"tcp_mptcp,omitempty"` CustomSockopt []*CustomSockopt `protobuf:"bytes,20,rep,name=customSockopt,proto3" json:"customSockopt,omitempty"` } @@ -602,9 +602,9 @@ func (x *SocketConfig) GetTcpMaxSeg() int32 { return 0 } -func (x *SocketConfig) GetTcpNoDelay() bool { +func (x *SocketConfig) GetPenetrate() bool { if x != nil { - return x.TcpNoDelay + return x.Penetrate } return false } @@ -678,7 +678,7 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x28, 0x09, 0x52, 0x03, 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x22, 0x9f, 0x07, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, + 0x65, 0x22, 0x9b, 0x07, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, 0x6f, @@ -724,36 +724,36 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x65, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x63, 0x70, 0x4d, - 0x61, 0x78, 0x53, 0x65, 0x67, 0x12, 0x20, 0x0a, 0x0c, 0x74, 0x63, 0x70, 0x5f, 0x6e, 0x6f, 0x5f, - 0x64, 0x65, 0x6c, 0x61, 0x79, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x74, 0x63, 0x70, - 0x4e, 0x6f, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x63, 0x70, 0x5f, 0x6d, - 0x70, 0x74, 0x63, 0x70, 0x18, 0x13, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74, 0x63, 0x70, 0x4d, - 0x70, 0x74, 0x63, 0x70, 0x12, 0x4c, 0x0a, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, - 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, - 0x6f, 0x70, 0x74, 0x52, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, - 0x70, 0x74, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, - 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, - 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, - 0x74, 0x10, 0x02, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, - 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, - 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, - 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, - 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, - 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, - 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, - 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, - 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, - 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, - 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, - 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, - 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x78, 0x53, 0x65, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x65, 0x6e, 0x65, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x70, 0x65, 0x6e, 0x65, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x70, 0x74, 0x63, 0x70, + 0x18, 0x13, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74, 0x63, 0x70, 0x4d, 0x70, 0x74, 0x63, 0x70, + 0x12, 0x4c, 0x0a, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, + 0x74, 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x52, + 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x22, 0x2f, + 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, + 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, + 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, + 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, + 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, + 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, + 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, + 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, + 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, + 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, + 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, + 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, + 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, 0x67, 0x0a, 0x1b, 0x63, + 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, + 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, + 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/config.proto b/transport/internet/config.proto index 61812644..9293179e 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -103,7 +103,7 @@ message SocketConfig { string interface = 13; - bool v6only = 14; + bool v6only = 14; int32 tcp_window_clamp = 15; @@ -111,7 +111,7 @@ message SocketConfig { int32 tcp_max_seg = 17; - bool tcp_no_delay = 18; + bool penetrate = 18; bool tcp_mptcp = 19; diff --git a/transport/internet/sockopt_darwin.go b/transport/internet/sockopt_darwin.go index 82e0efbb..79e2133a 100644 --- a/transport/internet/sockopt_darwin.go +++ b/transport/internet/sockopt_darwin.go @@ -136,12 +136,6 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf return errors.New("failed to unset SO_KEEPALIVE", err) } } - - if config.TcpNoDelay { - if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_NODELAY, 1); err != nil { - return errors.New("failed to set TCP_NODELAY", err) - } - } } return nil diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index c05d7aa8..8f14fe66 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -103,11 +103,6 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf } } - if config.TcpNoDelay { - if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_NODELAY, 1); err != nil { - return errors.New("failed to set TCP_NODELAY", err) - } - } if len(config.CustomSockopt) > 0 { for _, custom := range config.CustomSockopt { var level = 0x6 // default TCP diff --git a/transport/internet/sockopt_windows.go b/transport/internet/sockopt_windows.go index c7a79bb6..ef6be945 100644 --- a/transport/internet/sockopt_windows.go +++ b/transport/internet/sockopt_windows.go @@ -61,11 +61,6 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf return errors.New("failed to unset SO_KEEPALIVE", err) } } - if config.TcpNoDelay { - if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1); err != nil { - return errors.New("failed to set TCP_NODELAY", err) - } - } } return nil diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index eb722d1c..f33bb9e4 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -308,7 +308,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me globalDialerAccess.Lock() if streamSettings.DownloadSettings == nil { streamSettings.DownloadSettings = common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings)).(*internet.MemoryStreamConfig) - if streamSettings.DownloadSettings.SocketSettings == nil { + if streamSettings.SocketSettings != nil && streamSettings.SocketSettings.Penetrate { streamSettings.DownloadSettings.SocketSettings = streamSettings.SocketSettings } } From 5af90684c44d88036b99fbd441f3ad96847992a2 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:55:16 +0000 Subject: [PATCH 665/867] Inbounds config: Add `mixed` as an alias of `socks` https://github.com/XTLS/Xray-core/pull/3682#issuecomment-2292600144 --- infra/conf/xray.go | 1 + 1 file changed, 1 insertion(+) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index ee9e6dfd..4de55bad 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -24,6 +24,7 @@ var ( "dokodemo-door": func() interface{} { return new(DokodemoConfig) }, "http": func() interface{} { return new(HTTPServerConfig) }, "shadowsocks": func() interface{} { return new(ShadowsocksServerConfig) }, + "mixed": func() interface{} { return new(SocksServerConfig) }, "socks": func() interface{} { return new(SocksServerConfig) }, "vless": func() interface{} { return new(VLessInboundConfig) }, "vmess": func() interface{} { return new(VMessInboundConfig) }, From 4be32e99b28993799a3eaab20292dca0058e9506 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 31 Dec 2024 12:12:03 +0000 Subject: [PATCH 666/867] v24.12.31 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 751cbe47..10ddd5e8 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 24 Version_y byte = 12 - Version_z byte = 28 + Version_z byte = 31 ) var ( From c8b17ad18d71b1cc38751e4f00131ddba07b9c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Wed, 1 Jan 2025 16:06:35 +0800 Subject: [PATCH 667/867] Build: Use patched newer Go version to build Windows 7 assets (#4192) https://github.com/XTLS/go-win7 --- .github/workflows/release-win7.yml | 166 +++++++++++++++++++++++++++++ .github/workflows/release.yml | 14 +-- .github/workflows/test.yml | 2 +- common/reflect/marshal.go | 47 ++++---- core/config.go | 14 ++- go.mod | 2 +- 6 files changed, 197 insertions(+), 48 deletions(-) create mode 100644 .github/workflows/release-win7.yml diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml new file mode 100644 index 00000000..18745397 --- /dev/null +++ b/.github/workflows/release-win7.yml @@ -0,0 +1,166 @@ +name: Build and Release for Windows 7 + +on: + workflow_dispatch: + release: + types: [published] + push: + branches: + - main + paths: + # - "**/*.go" + - "go.mod" + - "go.sum" + - ".github/workflows/release-win7.yml" + pull_request: + types: [opened, synchronize, reopened] + paths: + # - "**/*.go" + - "go.mod" + - "go.sum" + - ".github/workflows/release-win7.yml" + +jobs: + prepare: + runs-on: ubuntu-latest + steps: + - name: Restore Cache + uses: actions/cache/restore@v4 + with: + path: resources + key: xray-geodat- + + - name: Update Geodat + id: update + uses: nick-fields/retry@v3 + with: + timeout_minutes: 60 + retry_wait_seconds: 60 + max_attempts: 60 + command: | + [ -d 'resources' ] || mkdir resources + LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') + for i in "${LIST[@]}" + do + INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) + FILE_NAME="${INFO[2]}.dat" + echo -e "Verifying HASH key..." + HASH="$(curl -sL "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" + if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then + continue + else + echo -e "Downloading https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat..." + curl -L "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} + echo -e "Verifying HASH key..." + [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } + echo "unhit=true" >> $GITHUB_OUTPUT + fi + done + + - name: Save Cache + uses: actions/cache/save@v4 + if: ${{ steps.update.outputs.unhit }} + with: + path: resources + key: xray-geodat-${{ github.sha }}-${{ github.run_number }} + + build: + needs: prepare + permissions: + contents: write + strategy: + matrix: + include: + # BEGIN Windows 7 + - goos: windows + goarch: amd64 + assetname: win7-64 + - goos: windows + goarch: 386 + assetname: win7-32 + # END Windows 7 + fail-fast: false + + runs-on: ubuntu-latest + env: + GOOS: ${{ matrix.goos}} + GOARCH: ${{ matrix.goarch }} + CGO_ENABLED: 0 + steps: + - name: Show workflow information + run: | + _NAME=${{ matrix.assetname }} + echo "GOOS: ${{ matrix.goos }}, GOARCH: ${{ matrix.goarch }}, RELEASE_NAME: $_NAME" + echo "ASSET_NAME=$_NAME" >> $GITHUB_ENV + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + check-latest: true + + - name: Setup patched builder + run: | + GOSDK=$(go env GOROOT) + curl -O -L https://github.com/XTLS/go-win7/releases/latest/download/go-for-win7-linux-amd64.zip + rm -r $GOSDK/* + unzip ./go-for-win7-linux-amd64.zip -d $GOSDK + + - name: Checkout codebase + uses: actions/checkout@v4 + + - name: Get project dependencies + run: go mod download + + - name: Build Xray + run: | + mkdir -p build_assets + make + find . -maxdepth 1 -type f -regex './\(wxray\|xray\).exe' -exec mv {} ./build_assets/ \; + + - name: Restore Cache + uses: actions/cache/restore@v4 + with: + path: resources + key: xray-geodat- + + - name: Copy README.md & LICENSE + run: | + mv -f resources/* build_assets + cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md + cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE + + - name: Create ZIP archive + if: github.event_name == 'release' + shell: bash + run: | + pushd build_assets || exit 1 + touch -mt $(date +%Y01010000) * + zip -9vr ../Xray-${{ env.ASSET_NAME }}.zip . + popd || exit 1 + FILE=./Xray-${{ env.ASSET_NAME }}.zip + DGST=$FILE.dgst + for METHOD in {"md5","sha1","sha256","sha512"} + do + openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST + done + + - name: Change the name + run: | + mv build_assets Xray-${{ env.ASSET_NAME }} + + - name: Upload files to Artifacts + uses: actions/upload-artifact@v4 + with: + name: Xray-${{ env.ASSET_NAME }} + path: | + ./Xray-${{ env.ASSET_NAME }}/* + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + if: github.event_name == 'release' + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./Xray-${{ env.ASSET_NAME }}.zip* + tag: ${{ github.ref }} + file_glob: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77e668b4..3b706680 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,9 +78,7 @@ jobs: # Include amd64 on all platforms. goos: [windows, freebsd, openbsd, linux, darwin] goarch: [amd64, 386] - gotoolchain: [""] patch-assetname: [""] - exclude: # Exclude i386 on darwin - goarch: 386 @@ -155,16 +153,6 @@ jobs: goarch: arm goarm: 7 # END OPENBSD ARM - # BEGIN Windows 7 - - goos: windows - goarch: amd64 - gotoolchain: 1.21.4 - patch-assetname: win7-64 - - goos: windows - goarch: 386 - gotoolchain: 1.21.4 - patch-assetname: win7-32 - # END Windows 7 fail-fast: false runs-on: ubuntu-latest @@ -187,7 +175,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: ${{ matrix.gotoolchain || '1.23' }} + go-version-file: go.mod check-latest: true - name: Get project dependencies diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1e531d52..da178740 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.23' + go-version-file: go.mod check-latest: true - name: Restore Cache uses: actions/cache/restore@v4 diff --git a/common/reflect/marshal.go b/common/reflect/marshal.go index 42f47385..2b224b45 100644 --- a/common/reflect/marshal.go +++ b/common/reflect/marshal.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "reflect" + "slices" "strings" cnet "github.com/xtls/xray-core/common/net" @@ -31,9 +32,6 @@ func JSONMarshalWithoutEscape(t interface{}) ([]byte, error) { } func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool, insertTypeInfo bool) interface{} { - if v == nil { - return nil - } tmsg, err := v.GetInstance() if err != nil { return nil @@ -194,29 +192,28 @@ func marshalKnownType(v interface{}, ignoreNullValue bool, insertTypeInfo bool) } } +var valueKinds = []reflect.Kind{ + reflect.Bool, + reflect.Int, + reflect.Int8, + reflect.Int16, + reflect.Int32, + reflect.Int64, + reflect.Uint, + reflect.Uint8, + reflect.Uint16, + reflect.Uint32, + reflect.Uint64, + reflect.Uintptr, + reflect.Float32, + reflect.Float64, + reflect.Complex64, + reflect.Complex128, + reflect.String, +} + func isValueKind(kind reflect.Kind) bool { - switch kind { - case reflect.Bool, - reflect.Int, - reflect.Int8, - reflect.Int16, - reflect.Int32, - reflect.Int64, - reflect.Uint, - reflect.Uint8, - reflect.Uint16, - reflect.Uint32, - reflect.Uint64, - reflect.Uintptr, - reflect.Float32, - reflect.Float64, - reflect.Complex64, - reflect.Complex128, - reflect.String: - return true - default: - return false - } + return slices.Contains(valueKinds, kind) } func marshalInterface(v interface{}, ignoreNullValue bool, insertTypeInfo bool) interface{} { diff --git a/core/config.go b/core/config.go index 4390766d..ec9e5aa4 100644 --- a/core/config.go +++ b/core/config.go @@ -2,6 +2,7 @@ package core import ( "io" + "slices" "strings" "github.com/xtls/xray-core/common" @@ -64,14 +65,11 @@ func GetMergedConfig(args cmdarg.Arg) (string, error) { supported := []string{"json", "yaml", "toml"} for _, file := range args { format := getFormat(file) - for _, s := range supported { - if s == format { - files = append(files, &ConfigSource{ - Name: file, - Format: format, - }) - break - } + if slices.Contains(supported, format) { + files = append(files, &ConfigSource{ + Name: file, + Format: format, + }) } } return ConfigMergedFormFiles(files) diff --git a/go.mod b/go.mod index 37358157..3edb3d5b 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/xtls/xray-core -go 1.21.4 +go 1.23 require ( github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 From 1a1c49de3656c986f53e175ba0c7480fc819320b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 08:19:48 +0000 Subject: [PATCH 668/867] Bump google.golang.org/grpc from 1.67.1 to 1.69.2 (#4181) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.67.1 to 1.69.2. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.67.1...v1.69.2) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 28 ++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index 3edb3d5b..e6bad394 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.10.0 golang.org/x/sys v0.28.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.67.1 + google.golang.org/grpc v1.69.2 google.golang.org/protobuf v1.36.1 gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h12.io/socks v1.0.3 @@ -55,7 +55,7 @@ require ( golang.org/x/time v0.5.0 // indirect golang.org/x/tools v0.22.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 885ac2fe..b313c9c7 100644 --- a/go.sum +++ b/go.sum @@ -12,18 +12,24 @@ github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 h1:y7y0Oa6UawqTFP github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3A65HN+7CMjSDP/gofXL4CZt1V4= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= -github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/golang/mock v1.7.0-rc.1 h1:YojYx61/OLFsiv6Rw1Z96LpldJIy31o+UHmwAUMJ6/U= github.com/golang/mock v1.7.0-rc.1/go.mod h1:s42URUywIqd+OcERslBJvOjepvNymP31m3q8d/GkuRs= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20240528025155-186aa0362fba h1:ql1qNgCyOB7iAEk8JTNM+zJrgIbnyCKX/wdlyPufP5g= github.com/google/pprof v0.0.0-20240528025155-186aa0362fba/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364 h1:5XxdakFhqd9dnXoAZy1Mb2R/DZ6D1e+0bGC/JhucGYI= @@ -73,6 +79,16 @@ github.com/xtls/quic-go v0.0.0-20241220091641-6f5777d1c087/go.mod h1:mN9lAuc8Vt7 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= +go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= +go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= +go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= +go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= +go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= +go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc= +go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8= +go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= +go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= @@ -125,10 +141,10 @@ golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeu golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= -google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= +google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU= +google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 5178dc500aac9b656b6a2d51ea04f197d9861a1b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 1 Jan 2025 08:22:00 +0000 Subject: [PATCH 669/867] Bump github.com/cloudflare/circl from 1.4.0 to 1.5.0 (#3899) Bumps [github.com/cloudflare/circl](https://github.com/cloudflare/circl) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/cloudflare/circl/releases) - [Commits](https://github.com/cloudflare/circl/compare/v1.4.0...v1.5.0) --- updated-dependencies: - dependency-name: github.com/cloudflare/circl dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e6bad394..fd712a14 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23 require ( github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 - github.com/cloudflare/circl v1.4.0 + github.com/cloudflare/circl v1.5.0 github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.6.0 diff --git a/go.sum b/go.sum index b313c9c7..89540432 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 h1:Wo41lDOevRJS github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0/go.mod h1:FVGavL/QEBQDcBpr3fAojoK17xX5k9bicBphrOpP7uM= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= -github.com/cloudflare/circl v1.4.0 h1:BV7h5MgrktNzytKmWjpOtdYrf0lkkbF8YMlBGPhJQrY= -github.com/cloudflare/circl v1.4.0/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= +github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys= +github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 8a6a5385ff174d0cf72b923b736128a4f7020c93 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 1 Jan 2025 09:23:14 +0000 Subject: [PATCH 670/867] Upgrade quic-go to patched v0.48.2 * Change module path * Add traceWroteRequest & traceGotConn * http3: allow concurrent calls to Body.Close (https://github.com/quic-go/quic-go/pull/4798) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index fd712a14..ac0a26f3 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.0 - github.com/xtls/quic-go v0.0.0-20241220091641-6f5777d1c087 + github.com/xtls/quic-go v0.48.2 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.31.0 @@ -45,7 +45,7 @@ require ( github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/onsi/ginkgo/v2 v2.19.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/quic-go/qpack v0.4.0 // indirect + github.com/quic-go/qpack v0.5.1 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.4.0 // indirect diff --git a/go.sum b/go.sum index 89540432..933f1483 100644 --- a/go.sum +++ b/go.sum @@ -52,8 +52,8 @@ github.com/pires/go-proxyproto v0.8.0 h1:5unRmEAPbHXHuLjDg01CxJWf91cw3lKHc/0xzKp github.com/pires/go-proxyproto v0.8.0/go.mod h1:iknsfgnH8EkjrMeMyvfKByp9TiBZCKZM0jx2xmKqnVY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= -github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= +github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= +github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= @@ -74,8 +74,8 @@ github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQ github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/quic-go v0.0.0-20241220091641-6f5777d1c087 h1:kKPg/cJPSKnE50VXVBskDYYSBkl4X3sMCIbTy+XKNGk= -github.com/xtls/quic-go v0.0.0-20241220091641-6f5777d1c087/go.mod h1:mN9lAuc8Vt7eHvnQkDIH5+uHh+DcLmTBma9rLqk/rPY= +github.com/xtls/quic-go v0.48.2 h1:59Gs+E9qtc9s0uniXYDA649gNEZlMWcNpFLyp9jfkuE= +github.com/xtls/quic-go v0.48.2/go.mod h1:rcyY5J0JT+1d5pa5Y+FbCsXM7Zu79jE87ZSFOBfiH7Q= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= From 480eac7235c2b0ad3d04de1f10389ea9a54606ac Mon Sep 17 00:00:00 2001 From: yiguous <147401898+yiguous@users.noreply.github.com> Date: Wed, 1 Jan 2025 18:16:36 +0800 Subject: [PATCH 671/867] Config: Correctly marshal Int32Range to JSON (#4234) Fixes https://github.com/XTLS/libXray/issues/62 --- infra/conf/common.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/infra/conf/common.go b/infra/conf/common.go index fd6e732a..1cda2459 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -2,6 +2,7 @@ package conf import ( "encoding/json" + "fmt" "strconv" "strings" @@ -258,6 +259,18 @@ type Int32Range struct { To int32 } +func (v Int32Range) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +func (v Int32Range) String() string { + if v.Left == v.Right { + return strconv.Itoa(int(v.Left)) + } else { + return fmt.Sprintf("%d-%d", v.Left, v.Right) + } +} + func (v *Int32Range) UnmarshalJSON(data []byte) error { defer v.ensureOrder() var str string From 0658c9545b763009ee45607d2db757b01591175d Mon Sep 17 00:00:00 2001 From: GFW-knocker <123458121+GFW-knocker@users.noreply.github.com> Date: Wed, 1 Jan 2025 13:52:57 +0330 Subject: [PATCH 672/867] Freedom config: Fix noises delay (#4233) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- infra/conf/freedom.go | 20 +++----------------- proxy/freedom/freedom.go | 2 +- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 14c09cc2..693df1e3 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -161,9 +161,6 @@ func ParseNoise(noise *Noise) (*freedom.Noise, error) { } NConfig.LengthMin = uint64(min) NConfig.LengthMax = uint64(max) - if NConfig.LengthMin > NConfig.LengthMax { - NConfig.LengthMin, NConfig.LengthMax = NConfig.LengthMax, NConfig.LengthMin - } if NConfig.LengthMin == 0 { return nil, errors.New("rand lengthMin or lengthMax cannot be 0") } @@ -180,23 +177,12 @@ func ParseNoise(noise *Noise) (*freedom.Noise, error) { } default: - return nil, errors.New("Invalid packet,only rand,str,base64 are supported") + return nil, errors.New("Invalid packet, only rand/str/base64 are supported") } if noise.Delay != nil { - if noise.Delay.From != 0 && noise.Delay.To != 0 { - NConfig.DelayMin = uint64(noise.Delay.From) - NConfig.DelayMax = uint64(noise.Delay.To) - if NConfig.DelayMin > NConfig.LengthMax { - NConfig.DelayMin, NConfig.DelayMax = NConfig.LengthMax, NConfig.DelayMin - } - } else { - return nil, errors.New("DelayMin or DelayMax cannot be zero") - } - - } else { - NConfig.DelayMin = 0 - NConfig.DelayMax = 0 + NConfig.DelayMin = uint64(noise.Delay.From) + NConfig.DelayMax = uint64(noise.Delay.To) } return NConfig, nil } diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index f2d68eea..dcf012ae 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -419,7 +419,7 @@ func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { } w.Writer.WriteMultiBuffer(buf.MultiBuffer{buf.FromBytes(noise)}) - if n.DelayMin != 0 { + if n.DelayMin != 0 || n.DelayMax != 0 { time.Sleep(time.Duration(randBetween(int64(n.DelayMin), int64(n.DelayMax))) * time.Millisecond) } } From dd4ba823f50fbfee804ae0f01d3d90b949971a41 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 1 Jan 2025 11:51:32 +0000 Subject: [PATCH 673/867] Workflows: Trigger all Build & Test on all branches & files https://github.com/XTLS/Xray-core/pull/4192#issuecomment-2566960668 --- .github/workflows/release-win7.yml | 18 ++++++------------ .github/workflows/release.yml | 13 +------------ .github/workflows/test.yml | 12 ------------ 3 files changed, 7 insertions(+), 36 deletions(-) diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml index 18745397..ae1dd35b 100644 --- a/.github/workflows/release-win7.yml +++ b/.github/workflows/release-win7.yml @@ -1,24 +1,18 @@ name: Build and Release for Windows 7 +# NOTE: This Github Actions file depends on the Makefile. +# Building the correct package requires the correct binaries generated by the Makefile. To +# ensure the correct output, the Makefile must accept the appropriate input and compile the +# correct file with the correct name. If you need to modify this file, please ensure it won't +# disrupt the Makefile. + on: workflow_dispatch: release: types: [published] push: - branches: - - main - paths: - # - "**/*.go" - - "go.mod" - - "go.sum" - - ".github/workflows/release-win7.yml" pull_request: types: [opened, synchronize, reopened] - paths: - # - "**/*.go" - - "go.mod" - - "go.sum" - - ".github/workflows/release-win7.yml" jobs: prepare: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b706680..dc6fa6fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,20 +11,9 @@ on: release: types: [published] push: - branches: - - main - paths: - - "**/*.go" - - "go.mod" - - "go.sum" - - ".github/workflows/release.yml" pull_request: types: [opened, synchronize, reopened] - paths: - - "**/*.go" - - "go.mod" - - "go.sum" - - ".github/workflows/release.yml" + jobs: prepare: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index da178740..9620829a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,20 +2,8 @@ name: Test on: push: - branches: - - main - paths: - - "**/*.go" - - "go.mod" - - "go.sum" - - ".github/workflows/*.yml" pull_request: types: [opened, synchronize, reopened] - paths: - - "**/*.go" - - "go.mod" - - "go.sum" - - ".github/workflows/*.yml" jobs: test: From e80ca67feed9fb1b75566c9f91bee8809c086c05 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 1 Jan 2025 12:03:05 +0000 Subject: [PATCH 674/867] v25.1.1 Announcement of NFTs by Project X: https://github.com/XTLS/Xray-core/discussions/3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/core.go b/core/core.go index 10ddd5e8..37d2c5d0 100644 --- a/core/core.go +++ b/core/core.go @@ -17,9 +17,9 @@ import ( ) var ( - Version_x byte = 24 - Version_y byte = 12 - Version_z byte = 31 + Version_x byte = 25 + Version_y byte = 1 + Version_z byte = 1 ) var ( From 33186ca5e69c848fe610c421c0149670b4694036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 2 Jan 2025 16:21:32 +0800 Subject: [PATCH 675/867] Freedom noises: Change legacy variable name (#4238) Closes https://github.com/XTLS/Xray-core/issues/4237 --- infra/conf/freedom.go | 4 +- proxy/freedom/config.pb.go | 92 +++++++++++++++++++------------------- proxy/freedom/config.proto | 2 +- proxy/freedom/freedom.go | 4 +- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 693df1e3..ad0af360 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -167,11 +167,11 @@ func ParseNoise(noise *Noise) (*freedom.Noise, error) { case "str": //user input string - NConfig.StrNoise = []byte(strings.TrimSpace(noise.Packet)) + NConfig.Packet = []byte(strings.TrimSpace(noise.Packet)) case "base64": //user input base64 - NConfig.StrNoise, err = base64.StdEncoding.DecodeString(strings.TrimSpace(noise.Packet)) + NConfig.Packet, err = base64.StdEncoding.DecodeString(strings.TrimSpace(noise.Packet)) if err != nil { return nil, errors.New("Invalid base64 string") } diff --git a/proxy/freedom/config.pb.go b/proxy/freedom/config.pb.go index 03ce6a02..83bb15d6 100644 --- a/proxy/freedom/config.pb.go +++ b/proxy/freedom/config.pb.go @@ -233,7 +233,7 @@ type Noise struct { LengthMax uint64 `protobuf:"varint,2,opt,name=length_max,json=lengthMax,proto3" json:"length_max,omitempty"` DelayMin uint64 `protobuf:"varint,3,opt,name=delay_min,json=delayMin,proto3" json:"delay_min,omitempty"` DelayMax uint64 `protobuf:"varint,4,opt,name=delay_max,json=delayMax,proto3" json:"delay_max,omitempty"` - StrNoise []byte `protobuf:"bytes,5,opt,name=str_noise,json=strNoise,proto3" json:"str_noise,omitempty"` + Packet []byte `protobuf:"bytes,5,opt,name=packet,proto3" json:"packet,omitempty"` } func (x *Noise) Reset() { @@ -294,9 +294,9 @@ func (x *Noise) GetDelayMax() uint64 { return 0 } -func (x *Noise) GetStrNoise() []byte { +func (x *Noise) GetPacket() []byte { if x != nil { - return x.StrNoise + return x.Packet } return nil } @@ -412,7 +412,7 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x6c, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x69, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0x9c, 0x01, 0x0a, 0x05, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x61, 0x78, 0x22, 0x97, 0x01, 0x0a, 0x05, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x4d, 0x69, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x5f, 0x6d, @@ -420,49 +420,49 @@ var file_proxy_freedom_config_proto_rawDesc = []byte{ 0x4d, 0x61, 0x78, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x69, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x5f, 0x6d, 0x61, 0x78, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x61, 0x78, 0x12, 0x1b, 0x0a, - 0x09, 0x73, 0x74, 0x72, 0x5f, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x08, 0x73, 0x74, 0x72, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x22, 0x97, 0x04, 0x0a, 0x06, 0x43, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, - 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, - 0x64, 0x6f, 0x6d, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x5a, 0x0a, 0x14, 0x64, 0x65, 0x73, - 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, - 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x44, 0x65, 0x73, + 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x61, 0x78, 0x12, 0x16, 0x0a, + 0x06, 0x70, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x06, 0x70, + 0x61, 0x63, 0x6b, 0x65, 0x74, 0x22, 0x97, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x12, 0x52, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x12, 0x5a, 0x0a, 0x14, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, + 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x44, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x52, 0x13, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, - 0x52, 0x13, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x76, 0x65, - 0x72, 0x72, 0x69, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, - 0x76, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, - 0x65, 0x76, 0x65, 0x6c, 0x12, 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, - 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, - 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x31, 0x0a, 0x06, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x73, 0x18, - 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x4e, 0x6f, 0x69, 0x73, 0x65, - 0x52, 0x06, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x73, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, - 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, - 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, - 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, - 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, - 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, - 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, - 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, - 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, - 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, - 0x36, 0x34, 0x10, 0x0a, 0x42, 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x50, 0x01, - 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, - 0x79, 0x2f, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, - 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, + 0x38, 0x0a, 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, + 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x46, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x08, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, + 0x12, 0x31, 0x0a, 0x06, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2e, 0x66, 0x72, + 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x2e, 0x4e, 0x6f, 0x69, 0x73, 0x65, 0x52, 0x06, 0x6e, 0x6f, 0x69, + 0x73, 0x65, 0x73, 0x22, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, + 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, + 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, + 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, + 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, + 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, + 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, + 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, + 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, + 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, + 0x58, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x78, + 0x79, 0x2e, 0x66, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, + 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x66, 0x72, 0x65, + 0x65, 0x64, 0x6f, 0x6d, 0xaa, 0x02, 0x12, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x50, 0x72, 0x6f, 0x78, + 0x79, 0x2e, 0x46, 0x72, 0x65, 0x65, 0x64, 0x6f, 0x6d, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/proxy/freedom/config.proto b/proxy/freedom/config.proto index 5268598b..5d05ab9e 100644 --- a/proxy/freedom/config.proto +++ b/proxy/freedom/config.proto @@ -25,7 +25,7 @@ message Noise { uint64 length_max = 2; uint64 delay_min = 3; uint64 delay_max = 4; - bytes str_noise = 5; + bytes packet = 5; } message Config { diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index dcf012ae..f1866915 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -407,8 +407,8 @@ func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { var err error for _, n := range w.noises { //User input string or base64 encoded string - if n.StrNoise != nil { - noise = n.StrNoise + if n.Packet != nil { + noise = n.Packet } else { //Random noise noise, err = GenerateRandomBytes(randBetween(int64(n.LengthMin), From ca50c9cbe6db7c641646320dc7226e00995735af Mon Sep 17 00:00:00 2001 From: GFW-knocker <123458121+GFW-knocker@users.noreply.github.com> Date: Thu, 2 Jan 2025 12:47:03 +0330 Subject: [PATCH 676/867] Freedom noises: Support "hex" as `type` & `packet` (#4239) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- infra/conf/freedom.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index ad0af360..5eb3e871 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -2,6 +2,7 @@ package conf import ( "encoding/base64" + "encoding/hex" "net" "strings" @@ -166,18 +167,25 @@ func ParseNoise(noise *Noise) (*freedom.Noise, error) { } case "str": - //user input string + // user input string NConfig.Packet = []byte(strings.TrimSpace(noise.Packet)) + case "hex": + // user input hex + NConfig.Packet, err = hex.DecodeString(noise.Packet) + if err != nil { + return nil, errors.New("Invalid hex string").Base(err) + } + case "base64": - //user input base64 + // user input base64 NConfig.Packet, err = base64.StdEncoding.DecodeString(strings.TrimSpace(noise.Packet)) if err != nil { - return nil, errors.New("Invalid base64 string") + return nil, errors.New("Invalid base64 string").Base(err) } default: - return nil, errors.New("Invalid packet, only rand/str/base64 are supported") + return nil, errors.New("Invalid packet, only rand/str/hex/base64 are supported") } if noise.Delay != nil { From 2f52aa7ed8624ec2889508451d59797e47573b8c Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 2 Jan 2025 09:45:46 +0000 Subject: [PATCH 677/867] Freedom noises: Support RawURLEncoding for "base64" In case we want to share `noises` via sharing link. --- infra/conf/freedom.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/infra/conf/freedom.go b/infra/conf/freedom.go index 5eb3e871..15f1bcff 100644 --- a/infra/conf/freedom.go +++ b/infra/conf/freedom.go @@ -153,8 +153,9 @@ func (c *FreedomConfig) Build() (proto.Message, error) { func ParseNoise(noise *Noise) (*freedom.Noise, error) { var err error NConfig := new(freedom.Noise) + noise.Packet = strings.TrimSpace(noise.Packet) - switch strings.ToLower(noise.Type) { + switch noise.Type { case "rand": min, max, err := ParseRangeString(noise.Packet) if err != nil { @@ -168,7 +169,7 @@ func ParseNoise(noise *Noise) (*freedom.Noise, error) { case "str": // user input string - NConfig.Packet = []byte(strings.TrimSpace(noise.Packet)) + NConfig.Packet = []byte(noise.Packet) case "hex": // user input hex @@ -179,7 +180,7 @@ func ParseNoise(noise *Noise) (*freedom.Noise, error) { case "base64": // user input base64 - NConfig.Packet, err = base64.StdEncoding.DecodeString(strings.TrimSpace(noise.Packet)) + NConfig.Packet, err = base64.RawURLEncoding.DecodeString(strings.NewReplacer("+", "-", "/", "_", "=", "").Replace(noise.Packet)) if err != nil { return nil, errors.New("Invalid base64 string").Base(err) } From de53a3b94e7010e3e4e9144a6d4919c52965386a Mon Sep 17 00:00:00 2001 From: Hossin Asaadi Date: Fri, 3 Jan 2025 19:20:23 +0330 Subject: [PATCH 678/867] Upgrade gVisor to a newer version (#3903) --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- proxy/wireguard/gvisortun/tun.go | 2 +- proxy/wireguard/tun.go | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index ac0a26f3..aea10b8b 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.69.2 google.golang.org/protobuf v1.36.1 - gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 + gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.3.0 ) @@ -50,10 +50,10 @@ require ( github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.4.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect - golang.org/x/mod v0.18.0 // indirect + golang.org/x/mod v0.21.0 // indirect golang.org/x/text v0.21.0 // indirect - golang.org/x/time v0.5.0 // indirect - golang.org/x/tools v0.22.0 // indirect + golang.org/x/time v0.7.0 // indirect + golang.org/x/tools v0.26.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 933f1483..e29de52b 100644 --- a/go.sum +++ b/go.sum @@ -100,8 +100,8 @@ golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ss golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= -golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -127,13 +127,13 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= +golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= -golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= +golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= +golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -156,8 +156,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489 h1:ze1vwAdliUAr68RQ5NtufWaXaOg8WUO2OACzEV+TNdE= -gvisor.dev/gvisor v0.0.0-20231202080848-1f7806d17489/go.mod h1:10sU+Uh5KKNv1+2x2A0Gvzt8FjD3ASIhorV3YsauXhk= +gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h1:P+U/06iIKPQ3DLcg+zBfSCia1luZ2msPZrJ8jYDFPs0= +gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0/go.mod h1:NQHVAzMwvZ+Qe3ElSiHmq9RUm1MdNHpUZ52fiEqvn+0= h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo= h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= diff --git a/proxy/wireguard/gvisortun/tun.go b/proxy/wireguard/gvisortun/tun.go index 9e9a0b2b..65677c48 100644 --- a/proxy/wireguard/gvisortun/tun.go +++ b/proxy/wireguard/gvisortun/tun.go @@ -157,7 +157,7 @@ func (tun *netTun) Write(buf [][]byte, offset int) (int, error) { // WriteNotify implements channel.Notification func (tun *netTun) WriteNotify() { pkt := tun.ep.Read() - if pkt.IsNil() { + if pkt == nil { return } diff --git a/proxy/wireguard/tun.go b/proxy/wireguard/tun.go index 7fd8a817..74a3b71d 100644 --- a/proxy/wireguard/tun.go +++ b/proxy/wireguard/tun.go @@ -194,7 +194,7 @@ func createGVisorTun(localAddresses []netip.Addr, mtu int, handler promiscuousMo Timeout: 15 * time.Second, }) - handler(xnet.UDPDestination(xnet.IPAddress(id.LocalAddress.AsSlice()), xnet.Port(id.LocalPort)), gonet.NewUDPConn(stack, &wq, ep)) + handler(xnet.UDPDestination(xnet.IPAddress(id.LocalAddress.AsSlice()), xnet.Port(id.LocalPort)), gonet.NewUDPConn(&wq, ep)) }(r) }) stack.SetTransportProtocolHandler(udp.ProtocolNumber, udpForwarder.HandlePacket) From aeb12d9e3ba8db46b29bf2f480322df128f036d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Sun, 5 Jan 2025 14:37:50 +0800 Subject: [PATCH 679/867] Build: Update GeoIP/GeoSite Cache per hour (#4247) --- .github/workflows/hourly-prepare.yml | 64 ++++++++++++++++++++++++++++ .github/workflows/release-win7.yml | 46 +------------------- .github/workflows/release.yml | 46 +------------------- .github/workflows/test.yml | 2 +- 4 files changed, 67 insertions(+), 91 deletions(-) create mode 100644 .github/workflows/hourly-prepare.yml diff --git a/.github/workflows/hourly-prepare.yml b/.github/workflows/hourly-prepare.yml new file mode 100644 index 00000000..d07c1ee3 --- /dev/null +++ b/.github/workflows/hourly-prepare.yml @@ -0,0 +1,64 @@ +name: Timely assets update + +# NOTE: This Github Actions is required by other actions, for preparing other packaging assets in a +# routine manner, for example: GeoIP/GeoSite. +# Currently updating: +# - Geodat (GeoIP/Geosite) + +on: + workflow_dispatch: + schedule: + # Update assets on every hour (xx:30) + - cron: '30 * * * *' + push: + # Prevent triggering update request storm + paths: + - ".github/workflows/hourly-prepare.yml" + pull_request: + # Prevent triggering update request storm + paths: + - ".github/workflows/hourly-prepare.yml" + +jobs: + geodat: + runs-on: ubuntu-latest + steps: + - name: Restore Geodat Cache + uses: actions/cache/restore@v4 + with: + path: resources + key: xray-geodat- + + - name: Update Geodat + id: update + uses: nick-fields/retry@v3 + with: + timeout_minutes: 60 + retry_wait_seconds: 60 + max_attempts: 60 + command: | + [ -d 'resources' ] || mkdir resources + LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') + for i in "${LIST[@]}" + do + INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) + FILE_NAME="${INFO[2]}.dat" + echo -e "Verifying HASH key..." + HASH="$(curl -sL "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" + if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then + continue + else + echo -e "Downloading https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat..." + curl -L "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} + echo -e "Verifying HASH key..." + [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } + echo "unhit=true" >> $GITHUB_OUTPUT + fi + done + + - name: Save Geodat Cache + uses: actions/cache/save@v4 + if: ${{ steps.update.outputs.unhit }} + with: + path: resources + key: xray-geodat-${{ github.sha }}-${{ github.run_number }} diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml index ae1dd35b..0d00634a 100644 --- a/.github/workflows/release-win7.yml +++ b/.github/workflows/release-win7.yml @@ -15,51 +15,7 @@ on: types: [opened, synchronize, reopened] jobs: - prepare: - runs-on: ubuntu-latest - steps: - - name: Restore Cache - uses: actions/cache/restore@v4 - with: - path: resources - key: xray-geodat- - - - name: Update Geodat - id: update - uses: nick-fields/retry@v3 - with: - timeout_minutes: 60 - retry_wait_seconds: 60 - max_attempts: 60 - command: | - [ -d 'resources' ] || mkdir resources - LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') - for i in "${LIST[@]}" - do - INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) - FILE_NAME="${INFO[2]}.dat" - echo -e "Verifying HASH key..." - HASH="$(curl -sL "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" - if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then - continue - else - echo -e "Downloading https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat..." - curl -L "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} - echo -e "Verifying HASH key..." - [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } - echo "unhit=true" >> $GITHUB_OUTPUT - fi - done - - - name: Save Cache - uses: actions/cache/save@v4 - if: ${{ steps.update.outputs.unhit }} - with: - path: resources - key: xray-geodat-${{ github.sha }}-${{ github.run_number }} - build: - needs: prepare permissions: contents: write strategy: @@ -112,7 +68,7 @@ jobs: make find . -maxdepth 1 -type f -regex './\(wxray\|xray\).exe' -exec mv {} ./build_assets/ \; - - name: Restore Cache + - name: Restore Geodat Cache uses: actions/cache/restore@v4 with: path: resources diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dc6fa6fe..7bc8c51d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,51 +15,7 @@ on: types: [opened, synchronize, reopened] jobs: - prepare: - runs-on: ubuntu-latest - steps: - - name: Restore Cache - uses: actions/cache/restore@v4 - with: - path: resources - key: xray-geodat- - - - name: Update Geodat - id: update - uses: nick-fields/retry@v3 - with: - timeout_minutes: 60 - retry_wait_seconds: 60 - max_attempts: 60 - command: | - [ -d 'resources' ] || mkdir resources - LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') - for i in "${LIST[@]}" - do - INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) - FILE_NAME="${INFO[2]}.dat" - echo -e "Verifying HASH key..." - HASH="$(curl -sL "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" - if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then - continue - else - echo -e "Downloading https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat..." - curl -L "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} - echo -e "Verifying HASH key..." - [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } - echo "unhit=true" >> $GITHUB_OUTPUT - fi - done - - - name: Save Cache - uses: actions/cache/save@v4 - if: ${{ steps.update.outputs.unhit }} - with: - path: resources - key: xray-geodat-${{ github.sha }}-${{ github.run_number }} - build: - needs: prepare permissions: contents: write strategy: @@ -176,7 +132,7 @@ jobs: make find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; - - name: Restore Cache + - name: Restore Geodat Cache uses: actions/cache/restore@v4 with: path: resources diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9620829a..7ef9de65 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,7 +22,7 @@ jobs: with: go-version-file: go.mod check-latest: true - - name: Restore Cache + - name: Restore Geodat Cache uses: actions/cache/restore@v4 with: path: resources From ce6c0dc690c32056bc1faabac97112d306b9f0c3 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 6 Jan 2025 14:06:11 +0000 Subject: [PATCH 680/867] XHTTP XMUX: Abandon `client` if `client.Do(req)` failed (#4253) https://github.com/XTLS/Xray-core/commit/51769fdde1ca663dcb08d942618e480bee13109f --- transport/internet/splithttp/client.go | 25 +++++++++++++++---------- transport/internet/splithttp/config.go | 5 ++++- transport/internet/splithttp/dialer.go | 6 +++--- transport/internet/splithttp/hub.go | 14 ++++++++++++++ 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index c6cfee55..23166536 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -55,11 +55,11 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, body i }, }) - method := "GET" + method := "GET" // stream-down if body != nil { - method = "POST" + method = "POST" // stream-up/one } - req, _ := http.NewRequestWithContext(ctx, method, url, body) + req, _ := http.NewRequestWithContext(context.WithoutCancel(ctx), method, url, body) req.Header = c.transportConfig.GetRequestHeader() if method == "POST" && !c.transportConfig.NoGRPCHeader { req.Header.Set("Content-Type", "application/grpc") @@ -69,17 +69,20 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, body i go func() { resp, err := c.client.Do(req) if err != nil { + if !uploadOnly { + c.closed = true + } errors.LogInfoInner(ctx, err, "failed to "+method+" "+url) gotConn.Close() wrc.Close() return } if resp.StatusCode != 200 && !uploadOnly { - // c.closed = true errors.LogInfo(ctx, "unexpected status ", resp.StatusCode) } - if resp.StatusCode != 200 || uploadOnly { - resp.Body.Close() + if resp.StatusCode != 200 || uploadOnly { // stream-up + io.Copy(io.Discard, resp.Body) + resp.Body.Close() // if it is called immediately, the upload will be interrupted also wrc.Close() return } @@ -91,7 +94,7 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, body i } func (c *DefaultDialerClient) PostPacket(ctx context.Context, url string, body io.Reader, contentLength int64) error { - req, err := http.NewRequestWithContext(ctx, "POST", url, body) + req, err := http.NewRequestWithContext(context.WithoutCancel(ctx), "POST", url, body) if err != nil { return err } @@ -101,13 +104,14 @@ func (c *DefaultDialerClient) PostPacket(ctx context.Context, url string, body i if c.httpVersion != "1.1" { resp, err := c.client.Do(req) if err != nil { + c.closed = true return err } + io.Copy(io.Discard, resp.Body) defer resp.Body.Close() if resp.StatusCode != 200 { - // c.closed = true return errors.New("bad status code:", resp.Status) } } else { @@ -139,11 +143,12 @@ func (c *DefaultDialerClient) PostPacket(ctx context.Context, url string, body i if h1UploadConn.UnreadedResponsesCount > 0 { resp, err := http.ReadResponse(h1UploadConn.RespBufReader, req) if err != nil { + c.closed = true return fmt.Errorf("error while reading response: %s", err.Error()) } + io.Copy(io.Discard, resp.Body) + defer resp.Body.Close() if resp.StatusCode != 200 { - // c.closed = true - // resp.Body.Close() // I'm not sure return fmt.Errorf("got non-200 error response code: %d", resp.StatusCode) } } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 190cb633..a76bf0e4 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/transport/internet" ) @@ -36,10 +37,11 @@ func (c *Config) GetNormalizedQuery() string { if query != "" { query += "&" } + query += "x_version=" + core.Version() paddingLen := c.GetNormalizedXPaddingBytes().rand() if paddingLen > 0 { - query += "x_padding=" + strings.Repeat("0", int(paddingLen)) + query += "&x_padding=" + strings.Repeat("0", int(paddingLen)) } return query @@ -58,6 +60,7 @@ func (c *Config) WriteResponseHeader(writer http.ResponseWriter) { // CORS headers for the browser dialer writer.Header().Set("Access-Control-Allow-Origin", "*") writer.Header().Set("Access-Control-Allow-Methods", "GET, POST") + writer.Header().Set("X-Version", core.Version()) paddingLen := c.GetNormalizedXPaddingBytes().rand() if paddingLen > 0 { writer.Header().Set("X-Padding", strings.Repeat("0", int(paddingLen))) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index f33bb9e4..22f854cd 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -372,14 +372,14 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if xmuxClient != nil { xmuxClient.LeftRequests.Add(-1) } - conn.reader, conn.remoteAddr, conn.localAddr, _ = httpClient.OpenStream(context.WithoutCancel(ctx), requestURL.String(), reader, false) + conn.reader, conn.remoteAddr, conn.localAddr, _ = httpClient.OpenStream(ctx, requestURL.String(), reader, false) return stat.Connection(&conn), nil } else { // stream-down var err error if xmuxClient2 != nil { xmuxClient2.LeftRequests.Add(-1) } - conn.reader, conn.remoteAddr, conn.localAddr, err = httpClient2.OpenStream(context.WithoutCancel(ctx), requestURL2.String(), nil, false) + conn.reader, conn.remoteAddr, conn.localAddr, err = httpClient2.OpenStream(ctx, requestURL2.String(), nil, false) if err != nil { // browser dialer only return nil, err } @@ -454,7 +454,7 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me go func() { err := httpClient.PostPacket( - context.WithoutCancel(ctx), + ctx, url.String(), &buf.MultiBufferContainer{MultiBuffer: chunk}, int64(chunk.Len()), diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index b7c5098b..0d8c20da 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -1,6 +1,7 @@ package splithttp import ( + "bytes" "context" "crypto/tls" "io" @@ -102,6 +103,12 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req h.config.WriteResponseHeader(writer) + clientVer := []int{0, 0, 0} + x_version := strings.Split(request.URL.Query().Get("x_version"), ".") + for j := 0; j < 3 && len(x_version) > j; j++ { + clientVer[j], _ = strconv.Atoi(x_version[j]) + } + validRange := h.config.GetNormalizedXPaddingBytes() x_padding := int32(len(request.URL.Query().Get("x_padding"))) if validRange.To > 0 && (x_padding < validRange.From || x_padding > validRange.To) { @@ -160,6 +167,13 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req writer.WriteHeader(http.StatusConflict) } else { writer.WriteHeader(http.StatusOK) + if request.ProtoMajor != 1 && len(clientVer) > 0 && clientVer[0] >= 25 { + paddingLen := h.config.GetNormalizedXPaddingBytes().rand() + if paddingLen > 0 { + writer.Write(bytes.Repeat([]byte{'0'}, int(paddingLen))) + } + writer.(http.Flusher).Flush() + } <-request.Context().Done() } return From 5635254ebcab4dbe818b780d287b6b7976df87e3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 02:00:22 +0000 Subject: [PATCH 681/867] Bump golang.org/x/net from 0.33.0 to 0.34.0 (#4262) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.33.0 to 0.34.0. - [Commits](https://github.com/golang/net/compare/v0.33.0...v0.34.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index aea10b8b..7a10b3e8 100644 --- a/go.mod +++ b/go.mod @@ -22,10 +22,10 @@ require ( github.com/xtls/quic-go v0.48.2 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.31.0 - golang.org/x/net v0.33.0 + golang.org/x/crypto v0.32.0 + golang.org/x/net v0.34.0 golang.org/x/sync v0.10.0 - golang.org/x/sys v0.28.0 + golang.org/x/sys v0.29.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.69.2 google.golang.org/protobuf v1.36.1 diff --git a/go.sum b/go.sum index e29de52b..05b2e4a3 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= +golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= @@ -105,8 +105,8 @@ golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= @@ -119,8 +119,8 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From ef4a3c1cae431dd84b364e5caa2bf39440c43e77 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 02:02:00 +0000 Subject: [PATCH 682/867] Bump google.golang.org/protobuf from 1.36.1 to 1.36.2 (#4268) Bumps google.golang.org/protobuf from 1.36.1 to 1.36.2. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7a10b3e8..68582130 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/sys v0.29.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.69.2 - google.golang.org/protobuf v1.36.1 + google.golang.org/protobuf v1.36.2 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.3.0 diff --git a/go.sum b/go.sum index 05b2e4a3..4df5ecd3 100644 --- a/go.sum +++ b/go.sum @@ -145,8 +145,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU= google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= -google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= -google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU= +google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 3e590a4eb13711c0cb39945a700a67caa3962a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Mon, 13 Jan 2025 03:10:39 +0800 Subject: [PATCH 683/867] Freedom: Don't use rawConn copy when using utls (#4272) --- proxy/freedom/freedom.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index f1866915..19bc15ab 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -266,6 +266,9 @@ func isTLSConn(conn stat.Connection) bool { if _, ok := conn.(*tls.Conn); ok { return true } + if _, ok := conn.(*tls.UConn); ok { + return true + } } return false } From 9b1855f7194225b7559df77a645bfb0231229dda Mon Sep 17 00:00:00 2001 From: dashangcun <907225865@qq.com> Date: Tue, 14 Jan 2025 15:56:22 +0100 Subject: [PATCH 684/867] chore: fix struct field name in comment (#4284) Signed-off-by: dashangcun <907225865@qq.com> --- features/inbound/inbound.go | 2 +- features/routing/context.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/features/inbound/inbound.go b/features/inbound/inbound.go index fd3a3db5..adcf7571 100644 --- a/features/inbound/inbound.go +++ b/features/inbound/inbound.go @@ -25,7 +25,7 @@ type Handler interface { // xray:api:stable type Manager interface { features.Feature - // GetHandlers returns an InboundHandler for the given tag. + // GetHandler returns an InboundHandler for the given tag. GetHandler(ctx context.Context, tag string) (Handler, error) // AddHandler adds the given handler into this Manager. AddHandler(ctx context.Context, handler Handler) error diff --git a/features/routing/context.go b/features/routing/context.go index e7867c32..e52e2470 100644 --- a/features/routing/context.go +++ b/features/routing/context.go @@ -11,7 +11,7 @@ type Context interface { // GetInboundTag returns the tag of the inbound the connection was from. GetInboundTag() string - // GetSourcesIPs returns the source IPs bound to the connection. + // GetSourceIPs returns the source IPs bound to the connection. GetSourceIPs() []net.IP // GetSourcePort returns the source port of the connection. From 4576f56ec82e6a4ebed482642d19b6c1fb1c5380 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 22:48:36 -0500 Subject: [PATCH 685/867] Bump google.golang.org/grpc from 1.69.2 to 1.69.4 (#4288) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.69.2 to 1.69.4. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.69.2...v1.69.4) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 68582130..876dcd1d 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.10.0 golang.org/x/sys v0.29.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.69.2 + google.golang.org/grpc v1.69.4 google.golang.org/protobuf v1.36.2 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 4df5ecd3..6757bba5 100644 --- a/go.sum +++ b/go.sum @@ -143,8 +143,8 @@ golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uI golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE= google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= -google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU= -google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= +google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A= +google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU= google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From f1ff454e670f4173d40678c3d94fbc381510c893 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 Jan 2025 13:21:31 +0000 Subject: [PATCH 686/867] Bump google.golang.org/protobuf from 1.36.2 to 1.36.3 (#4295) Bumps google.golang.org/protobuf from 1.36.2 to 1.36.3. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 876dcd1d..d2087749 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/sys v0.29.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.69.4 - google.golang.org/protobuf v1.36.2 + google.golang.org/protobuf v1.36.3 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.3.0 diff --git a/go.sum b/go.sum index 6757bba5..4283748f 100644 --- a/go.sum +++ b/go.sum @@ -145,8 +145,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A= google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= -google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU= -google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= +google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 66dd7808b69088d847617164fbcd94254f49f8e4 Mon Sep 17 00:00:00 2001 From: nobody <59990325+vrnobody@users.noreply.github.com> Date: Fri, 17 Jan 2025 18:40:36 +0800 Subject: [PATCH 687/867] Commands: Fix dumping merged config for XHTTP (#4290) Fixes https://github.com/XTLS/Xray-core/issues/4287 --- common/reflect/marshal.go | 57 ++++++---- common/reflect/marshal_test.go | 201 +++++++++++++++++++-------------- 2 files changed, 150 insertions(+), 108 deletions(-) diff --git a/common/reflect/marshal.go b/common/reflect/marshal.go index 2b224b45..127dc8e0 100644 --- a/common/reflect/marshal.go +++ b/common/reflect/marshal.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "reflect" - "slices" "strings" cnet "github.com/xtls/xray-core/common/net" @@ -32,6 +31,9 @@ func JSONMarshalWithoutEscape(t interface{}) ([]byte, error) { } func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool, insertTypeInfo bool) interface{} { + if v == nil { + return nil + } tmsg, err := v.GetInstance() if err != nil { return nil @@ -56,7 +58,9 @@ func marshalSlice(v reflect.Value, ignoreNullValue bool, insertTypeInfo bool) in } func isNullValue(f reflect.StructField, rv reflect.Value) bool { - if rv.Kind() == reflect.String && rv.Len() == 0 { + if rv.Kind() == reflect.Struct { + return false + } else if rv.Kind() == reflect.String && rv.Len() == 0 { return true } else if !isValueKind(rv.Kind()) && rv.IsNil() { return true @@ -182,6 +186,12 @@ func marshalKnownType(v interface{}, ignoreNullValue bool, insertTypeInfo bool) case *conf.PortList: cpl := v.(*conf.PortList) return serializePortList(cpl.Build()) + case conf.Int32Range: + i32rng := v.(conf.Int32Range) + if i32rng.Left == i32rng.Right { + return i32rng.Left, true + } + return i32rng.String(), true case cnet.Address: if addr := v.(cnet.Address); addr != nil { return addr.String(), true @@ -192,28 +202,29 @@ func marshalKnownType(v interface{}, ignoreNullValue bool, insertTypeInfo bool) } } -var valueKinds = []reflect.Kind{ - reflect.Bool, - reflect.Int, - reflect.Int8, - reflect.Int16, - reflect.Int32, - reflect.Int64, - reflect.Uint, - reflect.Uint8, - reflect.Uint16, - reflect.Uint32, - reflect.Uint64, - reflect.Uintptr, - reflect.Float32, - reflect.Float64, - reflect.Complex64, - reflect.Complex128, - reflect.String, -} - func isValueKind(kind reflect.Kind) bool { - return slices.Contains(valueKinds, kind) + switch kind { + case reflect.Bool, + reflect.Int, + reflect.Int8, + reflect.Int16, + reflect.Int32, + reflect.Int64, + reflect.Uint, + reflect.Uint8, + reflect.Uint16, + reflect.Uint32, + reflect.Uint64, + reflect.Uintptr, + reflect.Float32, + reflect.Float64, + reflect.Complex64, + reflect.Complex128, + reflect.String: + return true + default: + return false + } } func marshalInterface(v interface{}, ignoreNullValue bool, insertTypeInfo bool) interface{} { diff --git a/common/reflect/marshal_test.go b/common/reflect/marshal_test.go index 82194279..80df23f1 100644 --- a/common/reflect/marshal_test.go +++ b/common/reflect/marshal_test.go @@ -116,98 +116,129 @@ func TestMarshalConfigJson(t *testing.T) { "system", "inboundDownlink", "outboundUplink", + "XHTTP_IN", + "\"host\": \"bing.com\"", + "scMaxEachPostBytes", + "\"from\": 100", + "\"to\": 1000", + "\"from\": 1000000", + "\"to\": 1000000", } for _, kw := range keywords { if !strings.Contains(tc, kw) { - t.Error("marshaled config error") + t.Log("config.json:", tc) + t.Error("keyword not found:", kw) + break } } } func getConfig() string { return `{ - "log": { - "loglevel": "debug" - }, - "stats": {}, - "policy": { - "levels": { - "0": { - "statsUserUplink": true, - "statsUserDownlink": true - } - }, - "system": { - "statsInboundUplink": true, - "statsInboundDownlink": true, - "statsOutboundUplink": true, - "statsOutboundDownlink": true - } - }, - "inbounds": [ - { - "tag": "agentin", - "protocol": "http", - "port": 8080, - "listen": "127.0.0.1", - "settings": {} - }, - { - "listen": "127.0.0.1", - "port": 10085, - "protocol": "dokodemo-door", - "settings": { - "address": "127.0.0.1" - }, - "tag": "api-in" - } - ], - "api": { - "tag": "api", - "services": [ - "HandlerService", - "StatsService" - ] - }, - "routing": { - "rules": [ - { - "inboundTag": [ - "api-in" - ], - "outboundTag": "api", - "type": "field" - } - ], - "domainStrategy": "AsIs" - }, - "outbounds": [ - { - "protocol": "vless", - "settings": { - "vnext": [ - { - "address": "1.2.3.4", - "port": 1234, - "users": [ - { - "id": "4784f9b8-a879-4fec-9718-ebddefa47750", - "encryption": "none" - } - ] - } - ] - }, - "tag": "agentout", - "streamSettings": { - "network": "ws", - "security": "none", - "wsSettings": { - "path": "/?ed=2048", - "host": "bing.com" - } - } - } - ] - }` + "log": { + "loglevel": "debug" + }, + "stats": {}, + "policy": { + "levels": { + "0": { + "statsUserUplink": true, + "statsUserDownlink": true + } + }, + "system": { + "statsInboundUplink": true, + "statsInboundDownlink": true, + "statsOutboundUplink": true, + "statsOutboundDownlink": true + } + }, + "inbounds": [ + { + "tag": "agentin", + "protocol": "http", + "port": 18080, + "listen": "127.0.0.1", + "settings": {} + }, + { + "listen": "127.0.0.1", + "port": 10085, + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api-in" + } + ], + "api": { + "tag": "api", + "services": [ + "HandlerService", + "StatsService" + ] + }, + "routing": { + "rules": [ + { + "inboundTag": [ + "api-in" + ], + "outboundTag": "api", + "type": "field" + } + ], + "domainStrategy": "AsIs" + }, + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "1.2.3.4", + "port": 1234, + "users": [ + { + "id": "4784f9b8-a879-4fec-9718-ebddefa47750", + "encryption": "none" + } + ] + } + ] + }, + "tag": "XHTTP_IN", + "streamSettings": { + "network": "xhttp", + "xhttpSettings": { + "host": "bing.com", + "path": "/xhttp_client_upload", + "mode": "auto", + "extra": { + "noSSEHeader": false, + "scMaxEachPostBytes": 1000000, + "scMaxBufferedPosts": 30, + "xPaddingBytes": "100-1000" + } + }, + "sockopt": { + "tcpFastOpen": true, + "acceptProxyProtocol": false, + "tcpcongestion": "bbr", + "tcpMptcp": true + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls", + "quic" + ], + "metadataOnly": false, + "routeOnly": true + } + } + ] +}` } From 30cb22afb1c82590009d7ecfc1d6d28b071f3d6f Mon Sep 17 00:00:00 2001 From: rPDmYQ <195319688+rPDmYQ@users.noreply.github.com> Date: Fri, 17 Jan 2025 21:37:40 +0800 Subject: [PATCH 688/867] Mixed inbound: Handle immediately closing connection gracefully (#4297) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- proxy/socks/server.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 34c42ae9..472b23a0 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -2,6 +2,7 @@ package socks import ( "context" + goerrors "errors" "io" "time" @@ -78,7 +79,13 @@ func (s *Server) Process(ctx context.Context, network net.Network, conn stat.Con switch network { case net.Network_TCP: firstbyte := make([]byte, 1) - conn.Read(firstbyte) + if n, err := conn.Read(firstbyte); n == 0 { + if goerrors.Is(err, io.EOF) { + errors.LogInfo(ctx, "Connection closed immediately, likely health check connection") + return nil + } + return errors.New("failed to read from connection").Base(err) + } if firstbyte[0] != 5 && firstbyte[0] != 4 { // Check if it is Socks5/4/4a errors.LogDebug(ctx, "Not Socks request, try to parse as HTTP request") return s.httpServer.ProcessWithFirstbyte(ctx, network, conn, dispatcher, firstbyte...) From 14a6636a41f43c286b2ffb2cf7dcb0406a4c4f6b Mon Sep 17 00:00:00 2001 From: rPDmYQ <195319688+rPDmYQ@users.noreply.github.com> Date: Sat, 18 Jan 2025 20:05:19 +0800 Subject: [PATCH 689/867] XHTTP client: Move `x_padding` into `Referer` header (#4298) ""Breaking"": Update the server side first, then client --- transport/internet/browser_dialer/dialer.go | 82 ++++++++++++++++--- transport/internet/browser_dialer/dialer.html | 70 ++++++++++------ .../internet/splithttp/browser_client.go | 14 ++-- transport/internet/splithttp/config.go | 32 ++++++-- transport/internet/splithttp/dialer.go | 18 ++-- transport/internet/splithttp/hub.go | 25 ++++-- 6 files changed, 182 insertions(+), 59 deletions(-) diff --git a/transport/internet/browser_dialer/dialer.go b/transport/internet/browser_dialer/dialer.go index 3f85f6a6..1991284d 100644 --- a/transport/internet/browser_dialer/dialer.go +++ b/transport/internet/browser_dialer/dialer.go @@ -5,6 +5,7 @@ import ( "context" _ "embed" "encoding/base64" + "encoding/json" "net/http" "time" @@ -17,6 +18,12 @@ import ( //go:embed dialer.html var webpage []byte +type task struct { + Method string `json:"method"` + URL string `json:"url"` + Extra any `json:"extra,omitempty"` +} + var conns chan *websocket.Conn var upgrader = &websocket.Upgrader{ @@ -55,23 +62,69 @@ func HasBrowserDialer() bool { return conns != nil } +type webSocketExtra struct { + Protocol string `json:"protocol,omitempty"` +} + func DialWS(uri string, ed []byte) (*websocket.Conn, error) { - data := []byte("WS " + uri) - if ed != nil { - data = append(data, " "+base64.RawURLEncoding.EncodeToString(ed)...) + task := task{ + Method: "WS", + URL: uri, } - return dialRaw(data) + if ed != nil { + task.Extra = webSocketExtra{ + Protocol: base64.RawURLEncoding.EncodeToString(ed), + } + } + + return dialTask(task) } -func DialGet(uri string) (*websocket.Conn, error) { - data := []byte("GET " + uri) - return dialRaw(data) +type httpExtra struct { + Referrer string `json:"referrer,omitempty"` + Headers map[string]string `json:"headers,omitempty"` } -func DialPost(uri string, payload []byte) error { - data := []byte("POST " + uri) - conn, err := dialRaw(data) +func httpExtraFromHeaders(headers http.Header) *httpExtra { + if len(headers) == 0 { + return nil + } + + extra := httpExtra{} + if referrer := headers.Get("Referer"); referrer != "" { + extra.Referrer = referrer + headers.Del("Referer") + } + + if len(headers) > 0 { + extra.Headers = make(map[string]string) + for header := range headers { + extra.Headers[header] = headers.Get(header) + } + } + + return &extra +} + +func DialGet(uri string, headers http.Header) (*websocket.Conn, error) { + task := task{ + Method: "GET", + URL: uri, + Extra: httpExtraFromHeaders(headers), + } + + return dialTask(task) +} + +func DialPost(uri string, headers http.Header, payload []byte) error { + task := task{ + Method: "POST", + URL: uri, + Extra: httpExtraFromHeaders(headers), + } + + conn, err := dialTask(task) if err != nil { return err } @@ -90,7 +143,12 @@ func DialPost(uri string, payload []byte) error { return nil } -func dialRaw(data []byte) (*websocket.Conn, error) { +func dialTask(task task) (*websocket.Conn, error) { + data, err := json.Marshal(task) + if err != nil { + return nil, err + } + var conn *websocket.Conn for { conn = <-conns @@ -100,7 +158,7 @@ func dialRaw(data []byte) (*websocket.Conn, error) { break } } - err := CheckOK(conn) + err = CheckOK(conn) if err != nil { return nil, err } diff --git a/transport/internet/browser_dialer/dialer.html b/transport/internet/browser_dialer/dialer.html index 558db627..c62135ae 100644 --- a/transport/internet/browser_dialer/dialer.html +++ b/transport/internet/browser_dialer/dialer.html @@ -14,10 +14,28 @@ let upstreamGetCount = 0; let upstreamWsCount = 0; let upstreamPostCount = 0; + + function prepareRequestInit(extra) { + const requestInit = {}; + if (extra.referrer) { + // note: we have to strip the protocol and host part. + // Browsers disallow that, and will reset the value to current page if attempted. + const referrer = URL.parse(extra.referrer); + requestInit.referrer = referrer.pathname + referrer.search + referrer.hash; + requestInit.referrerPolicy = "unsafe-url"; + } + + if (extra.headers) { + requestInit.headers = extra.headers; + } + + return requestInit; + } + let check = function () { if (clientIdleCount > 0) { return; - }; + } clientIdleCount += 1; console.log("Prepare", url); let ws = new WebSocket(url); @@ -29,12 +47,12 @@ // double-checking that this continues to work ws.onmessage = function (event) { clientIdleCount -= 1; - let [method, url, protocol] = event.data.split(" "); - switch (method) { + let task = JSON.parse(event.data); + switch (task.method) { case "WS": { upstreamWsCount += 1; - console.log("Dial WS", url, protocol); - const wss = new WebSocket(url, protocol); + console.log("Dial WS", task.url, task.extra.protocol); + const wss = new WebSocket(task.url, task.extra.protocol); wss.binaryType = "arraybuffer"; let opened = false; ws.onmessage = function (event) { @@ -60,10 +78,12 @@ wss.close() }; break; - }; + } case "GET": { (async () => { - console.log("Dial GET", url); + const requestInit = prepareRequestInit(task.extra); + + console.log("Dial GET", task.url); ws.send("ok"); const controller = new AbortController(); @@ -83,58 +103,62 @@ ws.onclose = (event) => { try { reader && reader.cancel(); - } catch(e) {}; + } catch(e) {} try { controller.abort(); - } catch(e) {}; + } catch(e) {} }; try { upstreamGetCount += 1; - const response = await fetch(url, {signal: controller.signal}); + + requestInit.signal = controller.signal; + const response = await fetch(task.url, requestInit); const body = await response.body; reader = body.getReader(); while (true) { const { done, value } = await reader.read(); - ws.send(value); + if (value) ws.send(value); // don't send back "undefined" string when received nothing if (done) break; - }; + } } finally { upstreamGetCount -= 1; console.log("Dial GET DONE, remaining: ", upstreamGetCount); ws.close(); - }; + } })(); break; - }; + } case "POST": { upstreamPostCount += 1; - console.log("Dial POST", url); + + const requestInit = prepareRequestInit(task.extra); + requestInit.method = "POST"; + + console.log("Dial POST", task.url); ws.send("ok"); ws.onmessage = async (event) => { try { - const response = await fetch( - url, - {method: "POST", body: event.data} - ); + requestInit.body = event.data; + const response = await fetch(task.url, requestInit); if (response.ok) { ws.send("ok"); } else { console.error("bad status code"); ws.send("fail"); - }; + } } finally { upstreamPostCount -= 1; console.log("Dial POST DONE, remaining: ", upstreamPostCount); ws.close(); - }; + } }; break; - }; - }; + } + } check(); }; diff --git a/transport/internet/splithttp/browser_client.go b/transport/internet/splithttp/browser_client.go index d5d3d942..f4c9becd 100644 --- a/transport/internet/splithttp/browser_client.go +++ b/transport/internet/splithttp/browser_client.go @@ -5,13 +5,15 @@ import ( "io" gonet "net" + "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/transport/internet/browser_dialer" "github.com/xtls/xray-core/transport/internet/websocket" ) -// implements splithttp.DialerClient in terms of browser dialer -// has no fields because everything is global state :O) -type BrowserDialerClient struct{} +// BrowserDialerClient implements splithttp.DialerClient in terms of browser dialer +type BrowserDialerClient struct { + transportConfig *Config +} func (c *BrowserDialerClient) IsClosed() bool { panic("not implemented yet") @@ -19,10 +21,10 @@ func (c *BrowserDialerClient) IsClosed() bool { func (c *BrowserDialerClient) OpenStream(ctx context.Context, url string, body io.Reader, uploadOnly bool) (io.ReadCloser, gonet.Addr, gonet.Addr, error) { if body != nil { - panic("not implemented yet") + return nil, nil, nil, errors.New("bidirectional streaming for browser dialer not implemented yet") } - conn, err := browser_dialer.DialGet(url) + conn, err := browser_dialer.DialGet(url, c.transportConfig.GetRequestHeader()) dummyAddr := &gonet.IPAddr{} if err != nil { return nil, dummyAddr, dummyAddr, err @@ -37,7 +39,7 @@ func (c *BrowserDialerClient) PostPacket(ctx context.Context, url string, body i return err } - err = browser_dialer.DialPost(url, bytes) + err = browser_dialer.DialPost(url, c.transportConfig.GetRequestHeader(), bytes) if err != nil { return err } diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index a76bf0e4..5bcd4865 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "math/big" "net/http" + "net/url" "strings" "github.com/xtls/xray-core/common" @@ -11,6 +12,8 @@ import ( "github.com/xtls/xray-core/transport/internet" ) +const paddingQuery = "x_padding" + func (c *Config) GetNormalizedPath() string { pathAndQuery := strings.SplitN(c.Path, "?", 2) path := pathAndQuery[0] @@ -39,11 +42,6 @@ func (c *Config) GetNormalizedQuery() string { } query += "x_version=" + core.Version() - paddingLen := c.GetNormalizedXPaddingBytes().rand() - if paddingLen > 0 { - query += "&x_padding=" + strings.Repeat("0", int(paddingLen)) - } - return query } @@ -53,6 +51,28 @@ func (c *Config) GetRequestHeader() http.Header { header.Add(k, v) } + paddingLen := c.GetNormalizedXPaddingBytes().rand() + if paddingLen > 0 { + query, err := url.ParseQuery(c.GetNormalizedQuery()) + if err != nil { + query = url.Values{} + } + // https://www.rfc-editor.org/rfc/rfc7541.html#appendix-B + // h2's HPACK Header Compression feature employs a huffman encoding using a static table. + // 'X' is assigned an 8 bit code, so HPACK compression won't change actual padding length on the wire. + // https://www.rfc-editor.org/rfc/rfc9204.html#section-4.1.2-2 + // h3's similar QPACK feature uses the same huffman table. + query.Set(paddingQuery, strings.Repeat("X", int(paddingLen))) + + referrer := url.URL{ + Scheme: "https", // maybe http actually, but this part is not being checked + Host: c.Host, + Path: c.GetNormalizedPath(), + RawQuery: query.Encode(), + } + + header.Set("Referer", referrer.String()) + } return header } @@ -63,7 +83,7 @@ func (c *Config) WriteResponseHeader(writer http.ResponseWriter) { writer.Header().Set("X-Version", core.Version()) paddingLen := c.GetNormalizedXPaddingBytes().rand() if paddingLen > 0 { - writer.Header().Set("X-Padding", strings.Repeat("0", int(paddingLen))) + writer.Header().Set("X-Padding", strings.Repeat("X", int(paddingLen))) } } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 22f854cd..6a276e8f 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -53,8 +53,8 @@ var ( func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (DialerClient, *XmuxClient) { realityConfig := reality.ConfigFromStreamSettings(streamSettings) - if browser_dialer.HasBrowserDialer() && realityConfig != nil { - return &BrowserDialerClient{}, nil + if browser_dialer.HasBrowserDialer() && realityConfig == nil { + return &BrowserDialerClient{transportConfig: streamSettings.ProtocolSettings.(*Config)}, nil } globalDialerAccess.Lock() @@ -367,15 +367,18 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me }, } + var err error if mode == "stream-one" { requestURL.Path = transportConfiguration.GetNormalizedPath() if xmuxClient != nil { xmuxClient.LeftRequests.Add(-1) } - conn.reader, conn.remoteAddr, conn.localAddr, _ = httpClient.OpenStream(ctx, requestURL.String(), reader, false) + conn.reader, conn.remoteAddr, conn.localAddr, err = httpClient.OpenStream(ctx, requestURL.String(), reader, false) + if err != nil { // browser dialer only + return nil, err + } return stat.Connection(&conn), nil } else { // stream-down - var err error if xmuxClient2 != nil { xmuxClient2.LeftRequests.Add(-1) } @@ -388,7 +391,10 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if xmuxClient != nil { xmuxClient.LeftRequests.Add(-1) } - httpClient.OpenStream(ctx, requestURL.String(), reader, true) + _, _, _, err = httpClient.OpenStream(ctx, requestURL.String(), reader, true) + if err != nil { // browser dialer only + return nil, err + } return stat.Connection(&conn), nil } @@ -428,8 +434,6 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me // can reassign Path (potentially concurrently) url := requestURL url.Path += "/" + strconv.FormatInt(seq, 10) - // reassign query to get different padding - url.RawQuery = transportConfiguration.GetNormalizedQuery() seq += 1 diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 0d8c20da..e5465822 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -7,6 +7,7 @@ import ( "io" gonet "net" "net/http" + "net/url" "strconv" "strings" "sync" @@ -110,9 +111,23 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } validRange := h.config.GetNormalizedXPaddingBytes() - x_padding := int32(len(request.URL.Query().Get("x_padding"))) - if validRange.To > 0 && (x_padding < validRange.From || x_padding > validRange.To) { - errors.LogInfo(context.Background(), "invalid x_padding length:", x_padding) + paddingLength := -1 + + if referrerPadding := request.Header.Get("Referer"); referrerPadding != "" { + // Browser dialer cannot control the host part of referrer header, so only check the query + if referrerURL, err := url.Parse(referrerPadding); err == nil { + if query := referrerURL.Query(); query.Has(paddingQuery) { + paddingLength = len(query.Get(paddingQuery)) + } + } + } + + if paddingLength == -1 { + paddingLength = len(request.URL.Query().Get(paddingQuery)) + } + + if validRange.To > 0 && (int32(paddingLength) < validRange.From || int32(paddingLength) > validRange.To) { + errors.LogInfo(context.Background(), "invalid x_padding length:", int32(paddingLength)) writer.WriteHeader(http.StatusBadRequest) return } @@ -185,10 +200,10 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req return } - payload, err := io.ReadAll(request.Body) + payload, err := io.ReadAll(io.LimitReader(request.Body, int64(scMaxEachPostBytes)+1)) if len(payload) > scMaxEachPostBytes { - errors.LogInfo(context.Background(), "Too large upload. scMaxEachPostBytes is set to ", scMaxEachPostBytes, "but request had size ", len(payload), ". Adjust scMaxEachPostBytes on the server to be at least as large as client.") + errors.LogInfo(context.Background(), "Too large upload. scMaxEachPostBytes is set to ", scMaxEachPostBytes, "but request size exceed it. Adjust scMaxEachPostBytes on the server to be at least as large as client.") writer.WriteHeader(http.StatusRequestEntityTooLarge) return } From f4fd8b8fadaf2814d267ca633accf25b2573cc4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Sun, 19 Jan 2025 15:39:54 +0800 Subject: [PATCH 690/867] DNS: Implement queryStrategy for "localhost" (#4303) Fixes https://github.com/XTLS/Xray-core/issues/4302 --- app/dns/nameserver.go | 2 +- app/dns/nameserver_local.go | 15 +++++++++++---- app/dns/nameserver_local_test.go | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index 9c2668d9..b145f9eb 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -43,7 +43,7 @@ func NewServer(ctx context.Context, dest net.Destination, dispatcher routing.Dis } switch { case strings.EqualFold(u.String(), "localhost"): - return NewLocalNameServer(), nil + return NewLocalNameServer(queryStrategy), nil case strings.EqualFold(u.Scheme, "https"): // DOH Remote mode return NewDoHNameServer(u, dispatcher, queryStrategy) case strings.EqualFold(u.Scheme, "https+local"): // DOH Local mode diff --git a/app/dns/nameserver_local.go b/app/dns/nameserver_local.go index f204981f..14de8356 100644 --- a/app/dns/nameserver_local.go +++ b/app/dns/nameserver_local.go @@ -14,13 +14,19 @@ import ( // LocalNameServer is an wrapper over local DNS feature. type LocalNameServer struct { - client *localdns.Client + client *localdns.Client + queryStrategy QueryStrategy } const errEmptyResponse = "No address associated with hostname" // QueryIP implements Server. func (s *LocalNameServer) QueryIP(ctx context.Context, domain string, _ net.IP, option dns.IPOption, _ bool) (ips []net.IP, err error) { + option = ResolveIpOptionOverride(s.queryStrategy, option) + if !option.IPv4Enable && !option.IPv6Enable { + return nil, dns.ErrEmptyResponse + } + start := time.Now() ips, err = s.client.LookupIP(domain, option) @@ -42,14 +48,15 @@ func (s *LocalNameServer) Name() string { } // NewLocalNameServer creates localdns server object for directly lookup in system DNS. -func NewLocalNameServer() *LocalNameServer { +func NewLocalNameServer(queryStrategy QueryStrategy) *LocalNameServer { errors.LogInfo(context.Background(), "DNS: created localhost client") return &LocalNameServer{ - client: localdns.New(), + queryStrategy: queryStrategy, + client: localdns.New(), } } // NewLocalDNSClient creates localdns client object for directly lookup in system DNS. func NewLocalDNSClient() *Client { - return &Client{server: NewLocalNameServer()} + return &Client{server: NewLocalNameServer(QueryStrategy_USE_IP)} } diff --git a/app/dns/nameserver_local_test.go b/app/dns/nameserver_local_test.go index 3331a333..500962f7 100644 --- a/app/dns/nameserver_local_test.go +++ b/app/dns/nameserver_local_test.go @@ -12,7 +12,7 @@ import ( ) func TestLocalNameServer(t *testing.T) { - s := NewLocalNameServer() + s := NewLocalNameServer(QueryStrategy_USE_IP) ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) ips, err := s.QueryIP(ctx, "google.com", net.IP{}, dns.IPOption{ IPv4Enable: true, From ca9a90221348dcc555885ce6537a7cdcef5f4257 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 19 Jan 2025 13:32:07 +0000 Subject: [PATCH 691/867] XHTTP server: Add `scStreamUpServerSecs`, enabled by default (#4306) Fixes https://github.com/XTLS/Xray-core/discussions/4113#discussioncomment-11682833 --- infra/conf/transport_internet.go | 6 ++ .../internet/splithttp/browser_client.go | 4 +- transport/internet/splithttp/client.go | 8 +- transport/internet/splithttp/config.go | 62 +++++++-------- transport/internet/splithttp/config.pb.go | 79 +++++++++++-------- transport/internet/splithttp/config.proto | 5 +- transport/internet/splithttp/hub.go | 56 +++++++------ 7 files changed, 123 insertions(+), 97 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index cb546537..09412613 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -231,6 +231,7 @@ type SplitHTTPConfig struct { ScMaxEachPostBytes Int32Range `json:"scMaxEachPostBytes"` ScMinPostsIntervalMs Int32Range `json:"scMinPostsIntervalMs"` ScMaxBufferedPosts int64 `json:"scMaxBufferedPosts"` + ScStreamUpServerSecs Int32Range `json:"scStreamUpServerSecs"` Xmux XmuxConfig `json:"xmux"` DownloadSettings *StreamConfig `json:"downloadSettings"` Extra json.RawMessage `json:"extra"` @@ -280,6 +281,10 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { } } + if c.XPaddingBytes != (Int32Range{}) && (c.XPaddingBytes.From <= 0 || c.XPaddingBytes.To <= 0) { + return nil, errors.New("xPaddingBytes cannot be disabled") + } + if c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency.To > 0 { return nil, errors.New("maxConnections cannot be specified together with maxConcurrency") } @@ -303,6 +308,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { ScMaxEachPostBytes: newRangeConfig(c.ScMaxEachPostBytes), ScMinPostsIntervalMs: newRangeConfig(c.ScMinPostsIntervalMs), ScMaxBufferedPosts: c.ScMaxBufferedPosts, + ScStreamUpServerSecs: newRangeConfig(c.ScStreamUpServerSecs), Xmux: &splithttp.XmuxConfig{ MaxConcurrency: newRangeConfig(c.Xmux.MaxConcurrency), MaxConnections: newRangeConfig(c.Xmux.MaxConnections), diff --git a/transport/internet/splithttp/browser_client.go b/transport/internet/splithttp/browser_client.go index f4c9becd..e4317aa2 100644 --- a/transport/internet/splithttp/browser_client.go +++ b/transport/internet/splithttp/browser_client.go @@ -24,7 +24,7 @@ func (c *BrowserDialerClient) OpenStream(ctx context.Context, url string, body i return nil, nil, nil, errors.New("bidirectional streaming for browser dialer not implemented yet") } - conn, err := browser_dialer.DialGet(url, c.transportConfig.GetRequestHeader()) + conn, err := browser_dialer.DialGet(url, c.transportConfig.GetRequestHeader(url)) dummyAddr := &gonet.IPAddr{} if err != nil { return nil, dummyAddr, dummyAddr, err @@ -39,7 +39,7 @@ func (c *BrowserDialerClient) PostPacket(ctx context.Context, url string, body i return err } - err = browser_dialer.DialPost(url, c.transportConfig.GetRequestHeader(), bytes) + err = browser_dialer.DialPost(url, c.transportConfig.GetRequestHeader(url), bytes) if err != nil { return err } diff --git a/transport/internet/splithttp/client.go b/transport/internet/splithttp/client.go index 23166536..0f809838 100644 --- a/transport/internet/splithttp/client.go +++ b/transport/internet/splithttp/client.go @@ -60,7 +60,7 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, body i method = "POST" // stream-up/one } req, _ := http.NewRequestWithContext(context.WithoutCancel(ctx), method, url, body) - req.Header = c.transportConfig.GetRequestHeader() + req.Header = c.transportConfig.GetRequestHeader(url) if method == "POST" && !c.transportConfig.NoGRPCHeader { req.Header.Set("Content-Type", "application/grpc") } @@ -69,10 +69,10 @@ func (c *DefaultDialerClient) OpenStream(ctx context.Context, url string, body i go func() { resp, err := c.client.Do(req) if err != nil { - if !uploadOnly { + if !uploadOnly { // stream-down is enough c.closed = true + errors.LogInfoInner(ctx, err, "failed to "+method+" "+url) } - errors.LogInfoInner(ctx, err, "failed to "+method+" "+url) gotConn.Close() wrc.Close() return @@ -99,7 +99,7 @@ func (c *DefaultDialerClient) PostPacket(ctx context.Context, url string, body i return err } req.ContentLength = contentLength - req.Header = c.transportConfig.GetRequestHeader() + req.Header = c.transportConfig.GetRequestHeader(url) if c.httpVersion != "1.1" { resp, err := c.client.Do(req) diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index 5bcd4865..f160db31 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -8,12 +8,9 @@ import ( "strings" "github.com/xtls/xray-core/common" - "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/transport/internet" ) -const paddingQuery = "x_padding" - func (c *Config) GetNormalizedPath() string { pathAndQuery := strings.SplitN(c.Path, "?", 2) path := pathAndQuery[0] @@ -37,42 +34,31 @@ func (c *Config) GetNormalizedQuery() string { query = pathAndQuery[1] } - if query != "" { - query += "&" - } - query += "x_version=" + core.Version() + /* + if query != "" { + query += "&" + } + query += "x_version=" + core.Version() + */ return query } -func (c *Config) GetRequestHeader() http.Header { +func (c *Config) GetRequestHeader(rawURL string) http.Header { header := http.Header{} for k, v := range c.Headers { header.Add(k, v) } - paddingLen := c.GetNormalizedXPaddingBytes().rand() - if paddingLen > 0 { - query, err := url.ParseQuery(c.GetNormalizedQuery()) - if err != nil { - query = url.Values{} - } - // https://www.rfc-editor.org/rfc/rfc7541.html#appendix-B - // h2's HPACK Header Compression feature employs a huffman encoding using a static table. - // 'X' is assigned an 8 bit code, so HPACK compression won't change actual padding length on the wire. - // https://www.rfc-editor.org/rfc/rfc9204.html#section-4.1.2-2 - // h3's similar QPACK feature uses the same huffman table. - query.Set(paddingQuery, strings.Repeat("X", int(paddingLen))) + u, _ := url.Parse(rawURL) + // https://www.rfc-editor.org/rfc/rfc7541.html#appendix-B + // h2's HPACK Header Compression feature employs a huffman encoding using a static table. + // 'X' is assigned an 8 bit code, so HPACK compression won't change actual padding length on the wire. + // https://www.rfc-editor.org/rfc/rfc9204.html#section-4.1.2-2 + // h3's similar QPACK feature uses the same huffman table. + u.RawQuery = "x_padding=" + strings.Repeat("X", int(c.GetNormalizedXPaddingBytes().rand())) + header.Set("Referer", u.String()) - referrer := url.URL{ - Scheme: "https", // maybe http actually, but this part is not being checked - Host: c.Host, - Path: c.GetNormalizedPath(), - RawQuery: query.Encode(), - } - - header.Set("Referer", referrer.String()) - } return header } @@ -80,11 +66,8 @@ func (c *Config) WriteResponseHeader(writer http.ResponseWriter) { // CORS headers for the browser dialer writer.Header().Set("Access-Control-Allow-Origin", "*") writer.Header().Set("Access-Control-Allow-Methods", "GET, POST") - writer.Header().Set("X-Version", core.Version()) - paddingLen := c.GetNormalizedXPaddingBytes().rand() - if paddingLen > 0 { - writer.Header().Set("X-Padding", strings.Repeat("X", int(paddingLen))) - } + // writer.Header().Set("X-Version", core.Version()) + writer.Header().Set("X-Padding", strings.Repeat("X", int(c.GetNormalizedXPaddingBytes().rand()))) } func (c *Config) GetNormalizedXPaddingBytes() RangeConfig { @@ -128,6 +111,17 @@ func (c *Config) GetNormalizedScMaxBufferedPosts() int { return int(c.ScMaxBufferedPosts) } +func (c *Config) GetNormalizedScStreamUpServerSecs() RangeConfig { + if c.ScStreamUpServerSecs == nil || c.ScStreamUpServerSecs.To == 0 { + return RangeConfig{ + From: 20, + To: 80, + } + } + + return *c.ScMinPostsIntervalMs +} + func (m *XmuxConfig) GetNormalizedMaxConcurrency() RangeConfig { if m.MaxConcurrency == nil { return RangeConfig{ diff --git a/transport/internet/splithttp/config.pb.go b/transport/internet/splithttp/config.pb.go index 139ba1bc..98377722 100644 --- a/transport/internet/splithttp/config.pb.go +++ b/transport/internet/splithttp/config.pb.go @@ -174,8 +174,9 @@ type Config struct { ScMaxEachPostBytes *RangeConfig `protobuf:"bytes,8,opt,name=scMaxEachPostBytes,proto3" json:"scMaxEachPostBytes,omitempty"` ScMinPostsIntervalMs *RangeConfig `protobuf:"bytes,9,opt,name=scMinPostsIntervalMs,proto3" json:"scMinPostsIntervalMs,omitempty"` ScMaxBufferedPosts int64 `protobuf:"varint,10,opt,name=scMaxBufferedPosts,proto3" json:"scMaxBufferedPosts,omitempty"` - Xmux *XmuxConfig `protobuf:"bytes,11,opt,name=xmux,proto3" json:"xmux,omitempty"` - DownloadSettings *internet.StreamConfig `protobuf:"bytes,12,opt,name=downloadSettings,proto3" json:"downloadSettings,omitempty"` + ScStreamUpServerSecs *RangeConfig `protobuf:"bytes,11,opt,name=scStreamUpServerSecs,proto3" json:"scStreamUpServerSecs,omitempty"` + Xmux *XmuxConfig `protobuf:"bytes,12,opt,name=xmux,proto3" json:"xmux,omitempty"` + DownloadSettings *internet.StreamConfig `protobuf:"bytes,13,opt,name=downloadSettings,proto3" json:"downloadSettings,omitempty"` } func (x *Config) Reset() { @@ -278,6 +279,13 @@ func (x *Config) GetScMaxBufferedPosts() int64 { return 0 } +func (x *Config) GetScStreamUpServerSecs() *RangeConfig { + if x != nil { + return x.ScStreamUpServerSecs + } + return nil +} + func (x *Config) GetXmux() *XmuxConfig { if x != nil { return x.Xmux @@ -336,7 +344,7 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x10, 0x68, 0x4d, 0x61, 0x78, 0x52, 0x65, 0x75, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x65, 0x63, 0x73, 0x12, 0x2a, 0x0a, 0x10, 0x68, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x68, 0x4b, 0x65, - 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x22, 0xf8, 0x05, + 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x22, 0xdc, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, @@ -371,29 +379,35 @@ var file_transport_internet_splithttp_config_proto_rawDesc = []byte{ 0x72, 0x76, 0x61, 0x6c, 0x4d, 0x73, 0x12, 0x2e, 0x0a, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x65, 0x64, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x12, 0x73, 0x63, 0x4d, 0x61, 0x78, 0x42, 0x75, 0x66, 0x66, 0x65, 0x72, 0x65, - 0x64, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x41, 0x0a, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x18, 0x0b, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x64, 0x50, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x62, 0x0a, 0x14, 0x73, 0x63, 0x53, 0x74, 0x72, 0x65, + 0x61, 0x6d, 0x55, 0x70, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x65, 0x63, 0x73, 0x18, 0x0b, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, - 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x58, 0x6d, 0x75, 0x78, 0x43, 0x6f, 0x6e, - 0x66, 0x69, 0x67, 0x52, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x12, 0x51, 0x0a, 0x10, 0x64, 0x6f, 0x77, - 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x0c, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x74, - 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x64, 0x6f, 0x77, 0x6e, - 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x1a, 0x3a, 0x0a, 0x0c, - 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, - 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, - 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, - 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x85, 0x01, 0x0a, 0x25, 0x63, 0x6f, 0x6d, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, - 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0xaa, 0x02, 0x21, 0x58, - 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, 0x48, 0x74, 0x74, 0x70, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x14, 0x73, 0x63, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x55, 0x70, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x65, 0x63, 0x73, 0x12, 0x41, 0x0a, 0x04, 0x78, 0x6d, + 0x75, 0x78, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x2e, 0x58, 0x6d, 0x75, + 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x04, 0x78, 0x6d, 0x75, 0x78, 0x12, 0x51, 0x0a, + 0x10, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, + 0x73, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x2e, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, + 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, + 0x1a, 0x3a, 0x0a, 0x0c, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, + 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, + 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x85, 0x01, 0x0a, + 0x25, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x73, 0x70, 0x6c, + 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x68, 0x74, 0x74, 0x70, + 0xaa, 0x02, 0x21, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x70, 0x6c, 0x69, 0x74, + 0x48, 0x74, 0x74, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -426,13 +440,14 @@ var file_transport_internet_splithttp_config_proto_depIdxs = []int32{ 0, // 6: xray.transport.internet.splithttp.Config.xPaddingBytes:type_name -> xray.transport.internet.splithttp.RangeConfig 0, // 7: xray.transport.internet.splithttp.Config.scMaxEachPostBytes:type_name -> xray.transport.internet.splithttp.RangeConfig 0, // 8: xray.transport.internet.splithttp.Config.scMinPostsIntervalMs:type_name -> xray.transport.internet.splithttp.RangeConfig - 1, // 9: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.XmuxConfig - 4, // 10: xray.transport.internet.splithttp.Config.downloadSettings:type_name -> xray.transport.internet.StreamConfig - 11, // [11:11] is the sub-list for method output_type - 11, // [11:11] is the sub-list for method input_type - 11, // [11:11] is the sub-list for extension type_name - 11, // [11:11] is the sub-list for extension extendee - 0, // [0:11] is the sub-list for field type_name + 0, // 9: xray.transport.internet.splithttp.Config.scStreamUpServerSecs:type_name -> xray.transport.internet.splithttp.RangeConfig + 1, // 10: xray.transport.internet.splithttp.Config.xmux:type_name -> xray.transport.internet.splithttp.XmuxConfig + 4, // 11: xray.transport.internet.splithttp.Config.downloadSettings:type_name -> xray.transport.internet.StreamConfig + 12, // [12:12] is the sub-list for method output_type + 12, // [12:12] is the sub-list for method input_type + 12, // [12:12] is the sub-list for extension type_name + 12, // [12:12] is the sub-list for extension extendee + 0, // [0:12] is the sub-list for field type_name } func init() { file_transport_internet_splithttp_config_proto_init() } diff --git a/transport/internet/splithttp/config.proto b/transport/internet/splithttp/config.proto index 577d75c2..beb1d004 100644 --- a/transport/internet/splithttp/config.proto +++ b/transport/internet/splithttp/config.proto @@ -33,6 +33,7 @@ message Config { RangeConfig scMaxEachPostBytes = 8; RangeConfig scMinPostsIntervalMs = 9; int64 scMaxBufferedPosts = 10; - XmuxConfig xmux = 11; - xray.transport.internet.StreamConfig downloadSettings = 12; + RangeConfig scStreamUpServerSecs = 11; + XmuxConfig xmux = 12; + xray.transport.internet.StreamConfig downloadSettings = 13; } diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index e5465822..58aec803 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -104,29 +104,28 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req h.config.WriteResponseHeader(writer) - clientVer := []int{0, 0, 0} - x_version := strings.Split(request.URL.Query().Get("x_version"), ".") - for j := 0; j < 3 && len(x_version) > j; j++ { - clientVer[j], _ = strconv.Atoi(x_version[j]) - } + /* + clientVer := []int{0, 0, 0} + x_version := strings.Split(request.URL.Query().Get("x_version"), ".") + for j := 0; j < 3 && len(x_version) > j; j++ { + clientVer[j], _ = strconv.Atoi(x_version[j]) + } + */ validRange := h.config.GetNormalizedXPaddingBytes() - paddingLength := -1 + paddingLength := 0 - if referrerPadding := request.Header.Get("Referer"); referrerPadding != "" { - // Browser dialer cannot control the host part of referrer header, so only check the query - if referrerURL, err := url.Parse(referrerPadding); err == nil { - if query := referrerURL.Query(); query.Has(paddingQuery) { - paddingLength = len(query.Get(paddingQuery)) - } + referrer := request.Header.Get("Referer") + if referrer != "" { + if referrerURL, err := url.Parse(referrer); err == nil { + // Browser dialer cannot control the host part of referrer header, so only check the query + paddingLength = len(referrerURL.Query().Get("x_padding")) } + } else { + paddingLength = len(request.URL.Query().Get("x_padding")) } - if paddingLength == -1 { - paddingLength = len(request.URL.Query().Get(paddingQuery)) - } - - if validRange.To > 0 && (int32(paddingLength) < validRange.From || int32(paddingLength) > validRange.To) { + if int32(paddingLength) < validRange.From || int32(paddingLength) > validRange.To { errors.LogInfo(context.Background(), "invalid x_padding length:", int32(paddingLength)) writer.WriteHeader(http.StatusBadRequest) return @@ -181,13 +180,24 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req errors.LogInfoInner(context.Background(), err, "failed to upload (PushReader)") writer.WriteHeader(http.StatusConflict) } else { + writer.Header().Set("X-Accel-Buffering", "no") + writer.Header().Set("Cache-Control", "no-store") writer.WriteHeader(http.StatusOK) - if request.ProtoMajor != 1 && len(clientVer) > 0 && clientVer[0] >= 25 { - paddingLen := h.config.GetNormalizedXPaddingBytes().rand() - if paddingLen > 0 { - writer.Write(bytes.Repeat([]byte{'0'}, int(paddingLen))) - } - writer.(http.Flusher).Flush() + scStreamUpServerSecs := h.config.GetNormalizedScStreamUpServerSecs() + if referrer != "" && scStreamUpServerSecs.To > 0 { + go func() { + defer func() { + recover() + }() + for { + _, err := writer.Write(bytes.Repeat([]byte{'X'}, int(h.config.GetNormalizedXPaddingBytes().rand()))) + if err != nil { + break + } + writer.(http.Flusher).Flush() + time.Sleep(time.Duration(scStreamUpServerSecs.rand()) * time.Second) + } + }() } <-request.Context().Done() } From a0822cb4408a2448dd894e406918e9da8b4f1460 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 07:24:33 +0000 Subject: [PATCH 692/867] Bump google.golang.org/grpc from 1.69.4 to 1.70.0 (#4322) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.69.4 to 1.70.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.69.4...v1.70.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index d2087749..9491e051 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.10.0 golang.org/x/sys v0.29.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.69.4 + google.golang.org/grpc v1.70.0 google.golang.org/protobuf v1.36.3 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 @@ -55,7 +55,7 @@ require ( golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.26.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 4283748f..91fbd76a 100644 --- a/go.sum +++ b/go.sum @@ -79,16 +79,16 @@ github.com/xtls/quic-go v0.48.2/go.mod h1:rcyY5J0JT+1d5pa5Y+FbCsXM7Zu79jE87ZSFOB github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= -go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= -go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= -go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= -go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= -go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= -go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc= -go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8= -go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= -go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= +go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= +go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= +go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= +go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= +go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= +go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= +go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= +go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= @@ -141,10 +141,10 @@ golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeu golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= -google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A= -google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a h1:hgh8P4EuoxpsuKMXX/To36nOFD7vixReXgn8lPGnt+o= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= +google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ= +google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw= google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 2522cfd7becdab686d87e54c5aba6986f4ef6a9c Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 25 Jan 2025 10:51:44 +0000 Subject: [PATCH 693/867] DNS DoH: Add h2c Remote mode (with TLS `serverNameToVerify`) https://github.com/XTLS/Xray-core/issues/4313#issuecomment-2609339864 Applies https://github.com/refraction-networking/utls/pull/161 Closes https://github.com/XTLS/Xray-core/issues/4313 --- app/dns/nameserver.go | 8 ++- app/dns/nameserver_doh.go | 86 ++++++++++++++++------------- infra/conf/transport_internet.go | 5 ++ transport/internet/tls/config.go | 12 ++++ transport/internet/tls/config.pb.go | 33 +++++++---- transport/internet/tls/config.proto | 2 + transport/internet/tls/tls.go | 15 +++-- 7 files changed, 105 insertions(+), 56 deletions(-) diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index b145f9eb..89f5b25e 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -44,9 +44,11 @@ func NewServer(ctx context.Context, dest net.Destination, dispatcher routing.Dis switch { case strings.EqualFold(u.String(), "localhost"): return NewLocalNameServer(queryStrategy), nil - case strings.EqualFold(u.Scheme, "https"): // DOH Remote mode - return NewDoHNameServer(u, dispatcher, queryStrategy) - case strings.EqualFold(u.Scheme, "https+local"): // DOH Local mode + case strings.EqualFold(u.Scheme, "https"): // DNS-over-HTTPS Remote mode + return NewDoHNameServer(u, dispatcher, queryStrategy, false) + case strings.EqualFold(u.Scheme, "h2c"): // DNS-over-HTTPS h2c Remote mode + return NewDoHNameServer(u, dispatcher, queryStrategy, true) + case strings.EqualFold(u.Scheme, "https+local"): // DNS-over-HTTPS Local mode return NewDoHLocalNameServer(u, queryStrategy), nil case strings.EqualFold(u.Scheme, "quic+local"): // DNS-over-QUIC Local mode return NewQUICNameServer(u, queryStrategy) diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index 7c25bb8d..177c7561 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -3,6 +3,7 @@ package dns import ( "bytes" "context" + "crypto/tls" "fmt" "io" "net/http" @@ -23,6 +24,7 @@ import ( "github.com/xtls/xray-core/features/routing" "github.com/xtls/xray-core/transport/internet" "golang.org/x/net/dns/dnsmessage" + "golang.org/x/net/http2" ) // DoHNameServer implemented DNS over HTTPS (RFC8484) Wire Format, @@ -41,49 +43,59 @@ type DoHNameServer struct { } // NewDoHNameServer creates DOH server object for remote resolving. -func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) (*DoHNameServer, error) { - errors.LogInfo(context.Background(), "DNS: created Remote DOH client for ", url.String()) +func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, queryStrategy QueryStrategy, h2c bool) (*DoHNameServer, error) { + url.Scheme = "https" + errors.LogInfo(context.Background(), "DNS: created Remote DNS-over-HTTPS client for ", url.String(), ", with h2c ", h2c) s := baseDOHNameServer(url, "DOH", queryStrategy) s.dispatcher = dispatcher - tr := &http.Transport{ - MaxIdleConns: 30, - IdleConnTimeout: 90 * time.Second, - TLSHandshakeTimeout: 30 * time.Second, - ForceAttemptHTTP2: true, - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { - dest, err := net.ParseDestination(network + ":" + addr) - if err != nil { - return nil, err - } - link, err := s.dispatcher.Dispatch(toDnsContext(ctx, s.dohURL), dest) - select { - case <-ctx.Done(): - return nil, ctx.Err() - default: + dialContext := func(ctx context.Context, network, addr string) (net.Conn, error) { + dest, err := net.ParseDestination(network + ":" + addr) + if err != nil { + return nil, err + } + link, err := s.dispatcher.Dispatch(toDnsContext(ctx, s.dohURL), dest) + select { + case <-ctx.Done(): + return nil, ctx.Err() + default: - } - if err != nil { - return nil, err - } + } + if err != nil { + return nil, err + } - cc := common.ChainedClosable{} - if cw, ok := link.Writer.(common.Closable); ok { - cc = append(cc, cw) - } - if cr, ok := link.Reader.(common.Closable); ok { - cc = append(cc, cr) - } - return cnc.NewConnection( - cnc.ConnectionInputMulti(link.Writer), - cnc.ConnectionOutputMulti(link.Reader), - cnc.ConnectionOnClose(cc), - ), nil + cc := common.ChainedClosable{} + if cw, ok := link.Writer.(common.Closable); ok { + cc = append(cc, cw) + } + if cr, ok := link.Reader.(common.Closable); ok { + cc = append(cc, cr) + } + return cnc.NewConnection( + cnc.ConnectionInputMulti(link.Writer), + cnc.ConnectionOutputMulti(link.Reader), + cnc.ConnectionOnClose(cc), + ), nil + } + + s.httpClient = &http.Client{ + Timeout: time.Second * 180, + Transport: &http.Transport{ + MaxIdleConns: 30, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 30 * time.Second, + ForceAttemptHTTP2: true, + DialContext: dialContext, }, } - s.httpClient = &http.Client{ - Timeout: time.Second * 180, - Transport: tr, + if h2c { + s.httpClient.Transport = &http2.Transport{ + IdleConnTimeout: 90 * time.Second, + DialTLSContext: func(ctx context.Context, network, addr string, cfg *tls.Config) (net.Conn, error) { + return dialContext(ctx, network, addr) + }, + } } return s, nil @@ -118,7 +130,7 @@ func NewDoHLocalNameServer(url *url.URL, queryStrategy QueryStrategy) *DoHNameSe Timeout: time.Second * 180, Transport: tr, } - errors.LogInfo(context.Background(), "DNS: created Local DOH client for ", url.String()) + errors.LogInfo(context.Background(), "DNS: created Local DNS-over-HTTPS client for ", url.String()) return s } diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 09412613..16b659c4 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -410,6 +410,7 @@ type TLSConfig struct { PinnedPeerCertificatePublicKeySha256 *[]string `json:"pinnedPeerCertificatePublicKeySha256"` CurvePreferences *StringList `json:"curvePreferences"` MasterKeyLog string `json:"masterKeyLog"` + ServerNameToVerify string `json:"serverNameToVerify"` } // Build implements Buildable. @@ -468,6 +469,10 @@ func (c *TLSConfig) Build() (proto.Message, error) { } config.MasterKeyLog = c.MasterKeyLog + config.ServerNameToVerify = c.ServerNameToVerify + if config.ServerNameToVerify != "" && config.Fingerprint == "unsafe" { + return nil, errors.New(`serverNameToVerify only works with uTLS for now`) + } return config, nil } diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 2ecabffb..8278cafb 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "crypto/hmac" + "crypto/rand" "crypto/tls" "crypto/x509" "encoding/base64" @@ -303,6 +304,14 @@ func (c *Config) verifyPeerCert(rawCerts [][]byte, verifiedChains [][]*x509.Cert return nil } +type RandCarrier struct { + ServerNameToVerify string +} + +func (r *RandCarrier) Read(p []byte) (n int, err error) { + return rand.Read(p) +} + // GetTLSConfig converts this Config into tls.Config. func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { root, err := c.getCertPool() @@ -321,6 +330,9 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { } config := &tls.Config{ + Rand: &RandCarrier{ + ServerNameToVerify: c.ServerNameToVerify, + }, ClientSessionCache: globalSessionCache, RootCAs: root, InsecureSkipVerify: c.AllowInsecure, diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index 1c16e697..e59fe502 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -214,7 +214,8 @@ type Config struct { PinnedPeerCertificatePublicKeySha256 [][]byte `protobuf:"bytes,14,rep,name=pinned_peer_certificate_public_key_sha256,json=pinnedPeerCertificatePublicKeySha256,proto3" json:"pinned_peer_certificate_public_key_sha256,omitempty"` MasterKeyLog string `protobuf:"bytes,15,opt,name=master_key_log,json=masterKeyLog,proto3" json:"master_key_log,omitempty"` // Lists of string as CurvePreferences values. - CurvePreferences []string `protobuf:"bytes,16,rep,name=curve_preferences,json=curvePreferences,proto3" json:"curve_preferences,omitempty"` + CurvePreferences []string `protobuf:"bytes,16,rep,name=curve_preferences,json=curvePreferences,proto3" json:"curve_preferences,omitempty"` + ServerNameToVerify string `protobuf:"bytes,17,opt,name=server_name_to_verify,json=serverNameToVerify,proto3" json:"server_name_to_verify,omitempty"` } func (x *Config) Reset() { @@ -352,6 +353,13 @@ func (x *Config) GetCurvePreferences() []string { return nil } +func (x *Config) GetServerNameToVerify() string { + if x != nil { + return x.ServerNameToVerify + } + return "" +} + var File_transport_internet_tls_config_proto protoreflect.FileDescriptor var file_transport_internet_tls_config_proto_rawDesc = []byte{ @@ -383,7 +391,7 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x4e, 0x43, 0x49, 0x50, 0x48, 0x45, 0x52, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, - 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0xe0, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, + 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0x93, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x49, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x63, 0x65, @@ -429,15 +437,18 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, 0x12, 0x2b, 0x0a, 0x11, 0x63, 0x75, 0x72, 0x76, 0x65, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x63, 0x75, 0x72, 0x76, 0x65, - 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x42, 0x73, 0x0a, 0x1f, 0x63, - 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x50, 0x01, - 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, - 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, - 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x74, - 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x6c, 0x73, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x31, 0x0a, 0x15, 0x73, + 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x76, 0x65, + 0x72, 0x69, 0x66, 0x79, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x54, 0x6f, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x42, 0x73, + 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, + 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, + 0x73, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, + 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/tls/config.proto b/transport/internet/tls/config.proto index 0fc1d01d..bb2564a3 100644 --- a/transport/internet/tls/config.proto +++ b/transport/internet/tls/config.proto @@ -87,4 +87,6 @@ message Config { // Lists of string as CurvePreferences values. repeated string curve_preferences = 16; + + string server_name_to_verify = 17; } diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index 4b8fa486..e15231f4 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -134,12 +134,17 @@ func UClient(c net.Conn, config *tls.Config, fingerprint *utls.ClientHelloID) ne } func copyConfig(c *tls.Config) *utls.Config { + serverNameToVerify := "" + if r, ok := c.Rand.(*RandCarrier); ok { + serverNameToVerify = r.ServerNameToVerify + } return &utls.Config{ - RootCAs: c.RootCAs, - ServerName: c.ServerName, - InsecureSkipVerify: c.InsecureSkipVerify, - VerifyPeerCertificate: c.VerifyPeerCertificate, - KeyLogWriter: c.KeyLogWriter, + RootCAs: c.RootCAs, + ServerName: c.ServerName, + InsecureSkipVerify: c.InsecureSkipVerify, + VerifyPeerCertificate: c.VerifyPeerCertificate, + KeyLogWriter: c.KeyLogWriter, + InsecureServerNameToVerify: serverNameToVerify, } } From 740a6b0dcd06c7f357ae6f8906f5d280a1620a3c Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 25 Jan 2025 11:15:42 +0000 Subject: [PATCH 694/867] RAW: Allow setting ALPN `http/1.1` for non-REALITY uTLS https://github.com/XTLS/Xray-core/issues/4313#issuecomment-2611889517 --- transport/internet/tcp/dialer.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/transport/internet/tcp/dialer.go b/transport/internet/tcp/dialer.go index bf50ed72..19b3f6b4 100644 --- a/transport/internet/tcp/dialer.go +++ b/transport/internet/tcp/dialer.go @@ -24,8 +24,14 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me tlsConfig := config.GetTLSConfig(tls.WithDestination(dest)) if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil { conn = tls.UClient(conn, tlsConfig, fingerprint) - if err := conn.(*tls.UConn).HandshakeContext(ctx); err != nil { - return nil, err + if len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "http/1.1" { + if err := conn.(*tls.UConn).WebsocketHandshakeContext(ctx); err != nil { + return nil, err + } + } else { + if err := conn.(*tls.UConn).HandshakeContext(ctx); err != nil { + return nil, err + } } } else { conn = tls.Client(conn, tlsConfig) From 5679d717eef23f48d4f60a0a34684f46c478e053 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 25 Jan 2025 11:52:44 +0000 Subject: [PATCH 695/867] Log: Add microseconds for all kinds of logs https://github.com/XTLS/Xray-core/issues/4313#issuecomment-2613932895 --- common/log/logger.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/log/logger.go b/common/log/logger.go index d964a212..7c100aa1 100644 --- a/common/log/logger.go +++ b/common/log/logger.go @@ -146,7 +146,7 @@ func (w *fileLogWriter) Close() error { func CreateStdoutLogWriter() WriterCreator { return func() Writer { return &consoleLogWriter{ - logger: log.New(os.Stdout, "", log.Ldate|log.Ltime), + logger: log.New(os.Stdout, "", log.Ldate|log.Ltime|log.Lmicroseconds), } } } @@ -155,7 +155,7 @@ func CreateStdoutLogWriter() WriterCreator { func CreateStderrLogWriter() WriterCreator { return func() Writer { return &consoleLogWriter{ - logger: log.New(os.Stderr, "", log.Ldate|log.Ltime), + logger: log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lmicroseconds), } } } @@ -174,7 +174,7 @@ func CreateFileLogWriter(path string) (WriterCreator, error) { } return &fileLogWriter{ file: file, - logger: log.New(file, "", log.Ldate|log.Ltime), + logger: log.New(file, "", log.Ldate|log.Ltime|log.Lmicroseconds), } }, nil } From 3a7a78ff3a6c56c6c3a7fb1e8ee20979e7395383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Sun, 26 Jan 2025 19:08:36 +0800 Subject: [PATCH 696/867] UDS: Keep valid source addr (#4325) Fixes https://github.com/XTLS/Xray-core/issues/4324 --- app/proxyman/inbound/worker.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 14df725d..6ef8cca4 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -2,6 +2,7 @@ package inbound import ( "context" + "strings" "sync" "sync/atomic" "time" @@ -463,9 +464,19 @@ func (w *dsWorker) callback(conn stat.Connection) { WriteCounter: w.downlinkCounter, } } + // For most of time, unix obviously have no source addr. But if we leave it empty, it will cause panic. + // So we use gateway as source for log. + // However, there are some special situations where a valid source address might be available. + // Such as the source address parsed from X-Forwarded-For in websocket. + // In that case, we keep it. + var source net.Destination + if !strings.Contains(conn.RemoteAddr().String(), "unix") { + source = net.DestinationFromAddr(conn.RemoteAddr()) + } else { + source = net.UnixDestination(w.address) + } ctx = session.ContextWithInbound(ctx, &session.Inbound{ - // Unix have no source addr, so we use gateway as source for log. - Source: net.UnixDestination(w.address), + Source: source, Gateway: net.UnixDestination(w.address), Tag: w.tag, Conn: conn, From a7a83624c57ce7647de06528325b3222dbdff437 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 26 Jan 2025 11:47:30 +0000 Subject: [PATCH 697/867] Upgrade quic-go to official v0.49.0 https://github.com/quic-go/quic-go/releases/tag/v0.49.0 https://github.com/quic-go/quic-go/pull/4749 https://github.com/quic-go/quic-go/pull/4798 --- app/dns/nameserver_quic.go | 2 +- common/protocol/quic/sniff.go | 2 +- go.mod | 4 ++-- go.sum | 8 ++++---- transport/internet/splithttp/dialer.go | 4 ++-- transport/internet/splithttp/hub.go | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 0691fac9..997635a8 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/xtls/quic-go" + "github.com/quic-go/quic-go" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" diff --git a/common/protocol/quic/sniff.go b/common/protocol/quic/sniff.go index 855ef9f7..779e291b 100644 --- a/common/protocol/quic/sniff.go +++ b/common/protocol/quic/sniff.go @@ -8,7 +8,7 @@ import ( "encoding/binary" "io" - "github.com/xtls/quic-go/quicvarint" + "github.com/quic-go/quic-go/quicvarint" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/bytespool" diff --git a/go.mod b/go.mod index 9491e051..dd93bf5c 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/miekg/dns v1.1.62 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.0 + github.com/quic-go/quic-go v0.49.0 github.com/refraction-networking/utls v1.6.7 github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 @@ -19,7 +20,6 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.0 - github.com/xtls/quic-go v0.48.2 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.32.0 @@ -48,7 +48,7 @@ require ( github.com/quic-go/qpack v0.5.1 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect github.com/vishvananda/netns v0.0.4 // indirect - go.uber.org/mock v0.4.0 // indirect + go.uber.org/mock v0.5.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/mod v0.21.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/go.sum b/go.sum index 91fbd76a..b33ef529 100644 --- a/go.sum +++ b/go.sum @@ -54,6 +54,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= +github.com/quic-go/quic-go v0.49.0 h1:w5iJHXwHxs1QxyBv1EHKuC50GX5to8mJAxvtnttJp94= +github.com/quic-go/quic-go v0.49.0/go.mod h1:s2wDnmCdooUQBmQfpUSTCYBl1/D4FcqbULMMkASvR6s= github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= @@ -74,8 +76,6 @@ github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQ github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/quic-go v0.48.2 h1:59Gs+E9qtc9s0uniXYDA649gNEZlMWcNpFLyp9jfkuE= -github.com/xtls/quic-go v0.48.2/go.mod h1:rcyY5J0JT+1d5pa5Y+FbCsXM7Zu79jE87ZSFOBfiH7Q= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= @@ -89,8 +89,8 @@ go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiy go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU= -go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= +go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= +go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index 6a276e8f..b97c39e9 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -13,8 +13,8 @@ import ( "sync/atomic" "time" - "github.com/xtls/quic-go" - "github.com/xtls/quic-go/http3" + "github.com/quic-go/quic-go" + "github.com/quic-go/quic-go/http3" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 58aec803..a9aba350 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -13,8 +13,8 @@ import ( "sync" "time" - "github.com/xtls/quic-go" - "github.com/xtls/quic-go/http3" + "github.com/quic-go/quic-go" + "github.com/quic-go/quic-go/http3" goreality "github.com/xtls/reality" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" From 7b59379d73c338472c9dc33eaf27a8c2373289bf Mon Sep 17 00:00:00 2001 From: Sergey Kutovoy Date: Sun, 26 Jan 2025 20:59:34 +0500 Subject: [PATCH 698/867] README.md: Add xray-checker to Xray Tools (#4319) https://github.com/XTLS/Xray-core/discussions/4316 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 570237e4..033569b6 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ - [Shadowrocket](https://apps.apple.com/app/shadowrocket/id932747118) - Xray Tools - [xray-knife](https://github.com/lilendian0x00/xray-knife) + - [xray-checker](https://github.com/kutovoys/xray-checker) - Xray Wrapper - [XTLS/libXray](https://github.com/XTLS/libXray) - [xtlsapi](https://github.com/hiddify/xtlsapi) From 03131c72dbbfc13ba4ce8e1f9f65f43f3dda7372 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Mon, 27 Jan 2025 15:44:33 -0500 Subject: [PATCH 699/867] XTLS Vision: Use separate uplink/downlink flag for direct copy (#4329) Fixes https://github.com/XTLS/Xray-core/issues/4033 --- proxy/proxy.go | 32 ++++++++++++++++++++++++-------- proxy/vless/encoding/addons.go | 4 ++-- proxy/vless/encoding/encoding.go | 16 ++++++++++------ proxy/vless/inbound/inbound.go | 8 ++++---- proxy/vless/outbound/outbound.go | 8 ++++---- 5 files changed, 44 insertions(+), 24 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 1e4c69f5..a3d3fccb 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -110,7 +110,8 @@ type TrafficState struct { // reader link state WithinPaddingBuffers bool - ReaderSwitchToDirectCopy bool + DownlinkReaderDirectCopy bool + UplinkReaderDirectCopy bool RemainingCommand int32 RemainingContent int32 RemainingPadding int32 @@ -118,7 +119,8 @@ type TrafficState struct { // write link state IsPadding bool - WriterSwitchToDirectCopy bool + DownlinkWriterDirectCopy bool + UplinkWriterDirectCopy bool } func NewTrafficState(userUUID []byte) *TrafficState { @@ -131,13 +133,15 @@ func NewTrafficState(userUUID []byte) *TrafficState { Cipher: 0, RemainingServerHello: -1, WithinPaddingBuffers: true, - ReaderSwitchToDirectCopy: false, + DownlinkReaderDirectCopy: false, + UplinkReaderDirectCopy: false, RemainingCommand: -1, RemainingContent: -1, RemainingPadding: -1, CurrentCommand: 0, IsPadding: true, - WriterSwitchToDirectCopy: false, + DownlinkWriterDirectCopy: false, + UplinkWriterDirectCopy: false, } } @@ -147,13 +151,15 @@ type VisionReader struct { buf.Reader trafficState *TrafficState ctx context.Context + isUplink bool } -func NewVisionReader(reader buf.Reader, state *TrafficState, context context.Context) *VisionReader { +func NewVisionReader(reader buf.Reader, state *TrafficState, isUplink bool, context context.Context) *VisionReader { return &VisionReader{ Reader: reader, trafficState: state, ctx: context, + isUplink: isUplink, } } @@ -175,7 +181,11 @@ func (w *VisionReader) ReadMultiBuffer() (buf.MultiBuffer, error) { w.trafficState.WithinPaddingBuffers = false } else if w.trafficState.CurrentCommand == 2 { w.trafficState.WithinPaddingBuffers = false - w.trafficState.ReaderSwitchToDirectCopy = true + if w.isUplink { + w.trafficState.UplinkReaderDirectCopy = true + } else { + w.trafficState.DownlinkReaderDirectCopy = true + } } else { errors.LogInfo(w.ctx, "XtlsRead unknown command ", w.trafficState.CurrentCommand, buffer.Len()) } @@ -194,9 +204,10 @@ type VisionWriter struct { trafficState *TrafficState ctx context.Context writeOnceUserUUID []byte + isUplink bool } -func NewVisionWriter(writer buf.Writer, state *TrafficState, context context.Context) *VisionWriter { +func NewVisionWriter(writer buf.Writer, state *TrafficState, isUplink bool, context context.Context) *VisionWriter { w := make([]byte, len(state.UserUUID)) copy(w, state.UserUUID) return &VisionWriter{ @@ -204,6 +215,7 @@ func NewVisionWriter(writer buf.Writer, state *TrafficState, context context.Con trafficState: state, ctx: context, writeOnceUserUUID: w, + isUplink: isUplink, } } @@ -221,7 +233,11 @@ func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { for i, b := range mb { if w.trafficState.IsTLS && b.Len() >= 6 && bytes.Equal(TlsApplicationDataStart, b.BytesTo(3)) { if w.trafficState.EnableXtls { - w.trafficState.WriterSwitchToDirectCopy = true + if w.isUplink { + w.trafficState.UplinkWriterDirectCopy = true + } else { + w.trafficState.DownlinkWriterDirectCopy = true + } } var command byte = CommandPaddingContinue if i == len(mb)-1 { diff --git a/proxy/vless/encoding/addons.go b/proxy/vless/encoding/addons.go index 1bf1817d..4474e3c9 100644 --- a/proxy/vless/encoding/addons.go +++ b/proxy/vless/encoding/addons.go @@ -61,13 +61,13 @@ func DecodeHeaderAddons(buffer *buf.Buffer, reader io.Reader) (*Addons, error) { } // EncodeBodyAddons returns a Writer that auto-encrypt content written by caller. -func EncodeBodyAddons(writer io.Writer, request *protocol.RequestHeader, requestAddons *Addons, state *proxy.TrafficState, context context.Context) buf.Writer { +func EncodeBodyAddons(writer io.Writer, request *protocol.RequestHeader, requestAddons *Addons, state *proxy.TrafficState, isUplink bool, context context.Context) buf.Writer { if request.Command == protocol.RequestCommandUDP { return NewMultiLengthPacketWriter(writer.(buf.Writer)) } w := buf.NewWriter(writer) if requestAddons.Flow == vless.XRV { - w = proxy.NewVisionWriter(w, state, context) + w = proxy.NewVisionWriter(w, state, isUplink, context) } return w } diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index 8b067a96..3fce3290 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -172,10 +172,10 @@ func DecodeResponseHeader(reader io.Reader, request *protocol.RequestHeader) (*A } // XtlsRead filter and read xtls protocol -func XtlsRead(reader buf.Reader, writer buf.Writer, timer *signal.ActivityTimer, conn net.Conn, input *bytes.Reader, rawInput *bytes.Buffer, trafficState *proxy.TrafficState, ob *session.Outbound, ctx context.Context) error { +func XtlsRead(reader buf.Reader, writer buf.Writer, timer *signal.ActivityTimer, conn net.Conn, input *bytes.Reader, rawInput *bytes.Buffer, trafficState *proxy.TrafficState, ob *session.Outbound, isUplink bool, ctx context.Context) error { err := func() error { for { - if trafficState.ReaderSwitchToDirectCopy { + if isUplink && trafficState.UplinkReaderDirectCopy || !isUplink && trafficState.DownlinkReaderDirectCopy { var writerConn net.Conn var inTimer *signal.ActivityTimer if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Conn != nil { @@ -193,7 +193,7 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer *signal.ActivityTimer, buffer, err := reader.ReadMultiBuffer() if !buffer.IsEmpty() { timer.Update() - if trafficState.ReaderSwitchToDirectCopy { + if isUplink && trafficState.UplinkReaderDirectCopy || !isUplink && trafficState.DownlinkReaderDirectCopy { // XTLS Vision processes struct TLS Conn's input and rawInput if inputBuffer, err := buf.ReadFrom(input); err == nil { if !inputBuffer.IsEmpty() { @@ -222,12 +222,12 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer *signal.ActivityTimer, } // XtlsWrite filter and write xtls protocol -func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, trafficState *proxy.TrafficState, ob *session.Outbound, ctx context.Context) error { +func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdater, conn net.Conn, trafficState *proxy.TrafficState, ob *session.Outbound, isUplink bool, ctx context.Context) error { err := func() error { var ct stats.Counter for { buffer, err := reader.ReadMultiBuffer() - if trafficState.WriterSwitchToDirectCopy { + if isUplink && trafficState.UplinkWriterDirectCopy || !isUplink && trafficState.DownlinkWriterDirectCopy { if inbound := session.InboundFromContext(ctx); inbound != nil { if inbound.CanSpliceCopy == 2 { inbound.CanSpliceCopy = 1 @@ -239,7 +239,11 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate rawConn, _, writerCounter := proxy.UnwrapRawConn(conn) writer = buf.NewWriter(rawConn) ct = writerCounter - trafficState.WriterSwitchToDirectCopy = false + if isUplink { + trafficState.UplinkWriterDirectCopy = false + } else { + trafficState.DownlinkWriterDirectCopy = false + } } if !buffer.IsEmpty() { if ct != nil { diff --git a/proxy/vless/inbound/inbound.go b/proxy/vless/inbound/inbound.go index a2415a44..1da2e091 100644 --- a/proxy/vless/inbound/inbound.go +++ b/proxy/vless/inbound/inbound.go @@ -538,8 +538,8 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s if requestAddons.Flow == vless.XRV { ctx1 := session.ContextWithInbound(ctx, nil) // TODO enable splice - clientReader = proxy.NewVisionReader(clientReader, trafficState, ctx1) - err = encoding.XtlsRead(clientReader, serverWriter, timer, connection, input, rawInput, trafficState, nil, ctx1) + clientReader = proxy.NewVisionReader(clientReader, trafficState, true, ctx1) + err = encoding.XtlsRead(clientReader, serverWriter, timer, connection, input, rawInput, trafficState, nil, true, ctx1) } else { // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBuffer err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer)) @@ -561,7 +561,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s } // default: clientWriter := bufferWriter - clientWriter := encoding.EncodeBodyAddons(bufferWriter, request, requestAddons, trafficState, ctx) + clientWriter := encoding.EncodeBodyAddons(bufferWriter, request, requestAddons, trafficState, false, ctx) multiBuffer, err1 := serverReader.ReadMultiBuffer() if err1 != nil { return err1 // ... @@ -576,7 +576,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection s var err error if requestAddons.Flow == vless.XRV { - err = encoding.XtlsWrite(serverReader, clientWriter, timer, connection, trafficState, nil, ctx) + err = encoding.XtlsWrite(serverReader, clientWriter, timer, connection, trafficState, nil, false, ctx) } else { // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBuffer err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer)) diff --git a/proxy/vless/outbound/outbound.go b/proxy/vless/outbound/outbound.go index ed9e07dc..e1a727eb 100644 --- a/proxy/vless/outbound/outbound.go +++ b/proxy/vless/outbound/outbound.go @@ -194,7 +194,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } // default: serverWriter := bufferWriter - serverWriter := encoding.EncodeBodyAddons(bufferWriter, request, requestAddons, trafficState, ctx) + serverWriter := encoding.EncodeBodyAddons(bufferWriter, request, requestAddons, trafficState, true, ctx) if request.Command == protocol.RequestCommandMux && request.Port == 666 { serverWriter = xudp.NewPacketWriter(serverWriter, target, xudp.GetGlobalID(ctx)) } @@ -234,7 +234,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } } ctx1 := session.ContextWithInbound(ctx, nil) // TODO enable splice - err = encoding.XtlsWrite(clientReader, serverWriter, timer, conn, trafficState, ob, ctx1) + err = encoding.XtlsWrite(clientReader, serverWriter, timer, conn, trafficState, ob, true, ctx1) } else { // from clientReader.ReadMultiBuffer to serverWriter.WriteMultiBuffer err = buf.Copy(clientReader, serverWriter, buf.UpdateActivity(timer)) @@ -261,7 +261,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte // default: serverReader := buf.NewReader(conn) serverReader := encoding.DecodeBodyAddons(conn, request, responseAddons) if requestAddons.Flow == vless.XRV { - serverReader = proxy.NewVisionReader(serverReader, trafficState, ctx) + serverReader = proxy.NewVisionReader(serverReader, trafficState, false, ctx) } if request.Command == protocol.RequestCommandMux && request.Port == 666 { if requestAddons.Flow == vless.XRV { @@ -272,7 +272,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte } if requestAddons.Flow == vless.XRV { - err = encoding.XtlsRead(serverReader, clientWriter, timer, conn, input, rawInput, trafficState, ob, ctx) + err = encoding.XtlsRead(serverReader, clientWriter, timer, conn, input, rawInput, trafficState, ob, false, ctx) } else { // from serverReader.ReadMultiBuffer to clientWriter.WriteMultiBuffer err = buf.Copy(serverReader, clientWriter, buf.UpdateActivity(timer)) From 1bb0beaa43334980172262754b7ea7f96e0ca48a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 20:45:47 +0000 Subject: [PATCH 700/867] Bump github.com/miekg/dns from 1.1.62 to 1.1.63 (#4330) Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.62 to 1.1.63. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.62...v1.1.63) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dd93bf5c..6af46b83 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.6.0 github.com/gorilla/websocket v1.5.3 - github.com/miekg/dns v1.1.62 + github.com/miekg/dns v1.1.63 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.0 github.com/quic-go/quic-go v0.49.0 diff --git a/go.sum b/go.sum index b33ef529..794712f9 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,8 @@ github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0N github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ= -github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ= +github.com/miekg/dns v1.1.63 h1:8M5aAw6OMZfFXTT7K5V0Eu5YiiL8l7nUAkyN6C9YwaY= +github.com/miekg/dns v1.1.63/go.mod h1:6NGHfjhpmr5lt3XPLuyfDJi5AXbNIPM9PY6H6sF1Nfs= github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= From f35fb08aeba4dbe1963adf8985217224759c98b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 20:45:59 +0000 Subject: [PATCH 701/867] Bump google.golang.org/protobuf from 1.36.3 to 1.36.4 (#4331) Bumps google.golang.org/protobuf from 1.36.3 to 1.36.4. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6af46b83..82bff711 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/sys v0.29.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.70.0 - google.golang.org/protobuf v1.36.3 + google.golang.org/protobuf v1.36.4 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.3.0 diff --git a/go.sum b/go.sum index 794712f9..e4418c71 100644 --- a/go.sum +++ b/go.sum @@ -145,8 +145,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ= google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw= -google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU= -google.golang.org/protobuf v1.36.3/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= +google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From efdc70fbf782433689dcb114e37426395100614d Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 30 Jan 2025 10:45:12 +0000 Subject: [PATCH 702/867] XHTTP client: Add back minimal path padding for compatibility It should be reverted in the future. --- transport/internet/splithttp/config.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index f160db31..f1ccc493 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -34,12 +34,13 @@ func (c *Config) GetNormalizedQuery() string { query = pathAndQuery[1] } - /* - if query != "" { - query += "&" - } - query += "x_version=" + core.Version() - */ + if query != "" { + query += "&" + } + + // query += "x_version=" + core.Version() + + query += "x_padding=" + strings.Repeat("X", int(c.GetNormalizedXPaddingBytes().From)) return query } From 0a8470cb14ebbf7ee4cbb6c601bb9db072ace985 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 30 Jan 2025 10:57:37 +0000 Subject: [PATCH 703/867] v25.1.30 Announcement of NFTs by Project X: https://github.com/XTLS/Xray-core/discussions/3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 37d2c5d0..5a52683e 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 25 Version_y byte = 1 - Version_z byte = 1 + Version_z byte = 30 ) var ( From c2f6c899871c1f37f11f72c9525aba5330bca7de Mon Sep 17 00:00:00 2001 From: auvred <61150013+auvred@users.noreply.github.com> Date: Sat, 1 Feb 2025 17:45:34 +0300 Subject: [PATCH 704/867] Commands: Fix ambiguous printing of private x25519 key (#4343) --- main/commands/all/curve25519.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/commands/all/curve25519.go b/main/commands/all/curve25519.go index 25cc812e..bb706c6c 100644 --- a/main/commands/all/curve25519.go +++ b/main/commands/all/curve25519.go @@ -42,7 +42,8 @@ func Curve25519Genkey(StdEncoding bool, input_base64 string) { // Modify random bytes using algorithm described at: // https://cr.yp.to/ecdh.html. privateKey[0] &= 248 - privateKey[31] &= 127 | 64 + privateKey[31] &= 127 + privateKey[31] |= 64 if publicKey, err = curve25519.X25519(privateKey, curve25519.Basepoint); err != nil { output = err.Error() From 480c7d7db7602979d0f638b7bf138b747c91ee48 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 1 Feb 2025 16:51:28 +0000 Subject: [PATCH 705/867] README.md: Add Project XHTTP (Persian) to Telegram https://t.me/projectXhttp --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 033569b6..11b6912f 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,9 @@ [Project X Channel](https://t.me/projectXtls) -[Project VLESS](https://t.me/projectVless) (non-Chinese) +[Project VLESS](https://t.me/projectVless) (Русский) + +[Project XHTTP](https://t.me/projectXhttp) (Persian) ## Installation From 9b7841178a4cb7d5b7ce558afa221254d8d3fa56 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 4 Feb 2025 15:10:08 +0000 Subject: [PATCH 706/867] MITM: Allow forwarding local negotiated ALPN http/1.1 to the real website https://github.com/XTLS/Xray-core/issues/4348#issuecomment-2633656408 https://github.com/XTLS/Xray-core/issues/4348#issuecomment-2633865039 Local negotiated ALPN http/1.1 was sent by browser/app or is written in dokodemo-door RAW's `tlsSettings`. Set `"alpn": ["fromMitm"]` in freedom RAW's `tlsSettings` to forward it to the real website. --- common/session/context.go | 12 ++++++++++++ proxy/dokodemo/dokodemo.go | 4 ++++ transport/internet/tcp/dialer.go | 12 +++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/common/session/context.go b/common/session/context.go index b7af69cc..a2c97d37 100644 --- a/common/session/context.go +++ b/common/session/context.go @@ -23,6 +23,7 @@ const ( timeoutOnlyKey ctx.SessionKey = 8 allowedNetworkKey ctx.SessionKey = 9 handlerSessionKey ctx.SessionKey = 10 + mitmAlpn11Key ctx.SessionKey = 11 ) func ContextWithInbound(ctx context.Context, inbound *Inbound) context.Context { @@ -162,3 +163,14 @@ func AllowedNetworkFromContext(ctx context.Context) net.Network { } return net.Network_Unknown } + +func ContextWithMitmAlpn11(ctx context.Context, alpn11 bool) context.Context { + return context.WithValue(ctx, mitmAlpn11Key, alpn11) +} + +func MitmAlpn11FromContext(ctx context.Context) bool { + if val, ok := ctx.Value(mitmAlpn11Key).(bool); ok { + return val + } + return false +} diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 6522f071..6bd3e28f 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -18,6 +18,7 @@ import ( "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/tls" ) func init() { @@ -90,6 +91,9 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st addr := handshake.HandshakeAddressContext(ctx) if addr != nil { dest.Address = addr + if conn.(*tls.Conn).ConnectionState().NegotiatedProtocol == "http/1.1" { + ctx = session.ContextWithMitmAlpn11(ctx, true) + } destinationOverridden = true } } diff --git a/transport/internet/tcp/dialer.go b/transport/internet/tcp/dialer.go index 19b3f6b4..abc2688e 100644 --- a/transport/internet/tcp/dialer.go +++ b/transport/internet/tcp/dialer.go @@ -2,10 +2,12 @@ package tcp import ( "context" + "strings" "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/common/session" "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/reality" "github.com/xtls/xray-core/transport/internet/stat" @@ -24,7 +26,8 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me tlsConfig := config.GetTLSConfig(tls.WithDestination(dest)) if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil { conn = tls.UClient(conn, tlsConfig, fingerprint) - if len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "http/1.1" { + if len(tlsConfig.NextProtos) == 1 && (tlsConfig.NextProtos[0] == "http/1.1" || + (strings.ToLower(tlsConfig.NextProtos[0]) == "frommitm" && session.MitmAlpn11FromContext(ctx))) { if err := conn.(*tls.UConn).WebsocketHandshakeContext(ctx); err != nil { return nil, err } @@ -34,6 +37,13 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } } } else { + if len(tlsConfig.NextProtos) == 1 && strings.ToLower(tlsConfig.NextProtos[0]) == "frommitm" { + if session.MitmAlpn11FromContext(ctx) { + tlsConfig.NextProtos = []string{"http/1.1"} // new slice + } else { + tlsConfig.NextProtos = nil + } + } conn = tls.Client(conn, tlsConfig) } } else if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { From c6a31f457cddc64b8c3bd08c66db1db128036c4f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 6 Feb 2025 07:37:30 +0000 Subject: [PATCH 707/867] MITM: Allow using local received SNI in the outgoing `serverName` & `verifyPeerCertInNames` https://github.com/XTLS/Xray-core/issues/4348#issuecomment-2637370175 Local received SNI was sent by browser/app. In freedom RAW's `tlsSettings`, set `"serverName": "fromMitm"` to forward it to the real website. In freedom RAW's `tlsSettings`, set `"verifyPeerCertInNames": ["fromMitm"]` to use all possible names to verify the certificate. --- common/session/context.go | 12 ++++++ infra/conf/transport_internet.go | 8 ++-- proxy/dokodemo/dokodemo.go | 18 ++++----- transport/internet/tcp/dialer.go | 34 +++++++++++++--- transport/internet/tls/config.go | 60 +++++++++++++++++++++++------ transport/internet/tls/config.pb.go | 50 ++++++++++++------------ transport/internet/tls/config.proto | 16 ++++---- transport/internet/tls/tls.go | 37 +++++++----------- 8 files changed, 150 insertions(+), 85 deletions(-) diff --git a/common/session/context.go b/common/session/context.go index a2c97d37..f2c8de7f 100644 --- a/common/session/context.go +++ b/common/session/context.go @@ -24,6 +24,7 @@ const ( allowedNetworkKey ctx.SessionKey = 9 handlerSessionKey ctx.SessionKey = 10 mitmAlpn11Key ctx.SessionKey = 11 + mitmServerNameKey ctx.SessionKey = 12 ) func ContextWithInbound(ctx context.Context, inbound *Inbound) context.Context { @@ -174,3 +175,14 @@ func MitmAlpn11FromContext(ctx context.Context) bool { } return false } + +func ContextWithMitmServerName(ctx context.Context, serverName string) context.Context { + return context.WithValue(ctx, mitmServerNameKey, serverName) +} + +func MitmServerNameFromContext(ctx context.Context) string { + if val, ok := ctx.Value(mitmServerNameKey).(string); ok { + return val + } + return "" +} diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 16b659c4..962b39ee 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -411,6 +411,7 @@ type TLSConfig struct { CurvePreferences *StringList `json:"curvePreferences"` MasterKeyLog string `json:"masterKeyLog"` ServerNameToVerify string `json:"serverNameToVerify"` + VerifyPeerCertInNames []string `json:"verifyPeerCertInNames"` } // Build implements Buildable. @@ -469,10 +470,11 @@ func (c *TLSConfig) Build() (proto.Message, error) { } config.MasterKeyLog = c.MasterKeyLog - config.ServerNameToVerify = c.ServerNameToVerify - if config.ServerNameToVerify != "" && config.Fingerprint == "unsafe" { - return nil, errors.New(`serverNameToVerify only works with uTLS for now`) + + if c.ServerNameToVerify != "" { + return nil, errors.PrintRemovedFeatureError("serverNameToVerify", "verifyPeerCertInNames") } + config.VerifyPeerCertInNames = c.VerifyPeerCertInNames return config, nil } diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 6bd3e28f..c16135f5 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -64,10 +64,6 @@ func (d *DokodemoDoor) policy() policy.Session { return p } -type hasHandshakeAddressContext interface { - HandshakeAddressContext(ctx context.Context) net.Address -} - // Process implements proxy.Inbound. func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error { errors.LogDebug(ctx, "processing connection from: ", conn.RemoteAddr()) @@ -87,14 +83,14 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st destinationOverridden = true } } - if handshake, ok := conn.(hasHandshakeAddressContext); ok && !destinationOverridden { - addr := handshake.HandshakeAddressContext(ctx) - if addr != nil { - dest.Address = addr - if conn.(*tls.Conn).ConnectionState().NegotiatedProtocol == "http/1.1" { - ctx = session.ContextWithMitmAlpn11(ctx, true) - } + if tlsConn, ok := conn.(tls.Interface); ok && !destinationOverridden { + if serverName := tlsConn.HandshakeContextServerName(ctx); serverName != "" { + dest.Address = net.DomainAddress(serverName) destinationOverridden = true + ctx = session.ContextWithMitmServerName(ctx, serverName) + } + if tlsConn.NegotiatedProtocol() == "http/1.1" { + ctx = session.ContextWithMitmAlpn11(ctx, true) } } } diff --git a/transport/internet/tcp/dialer.go b/transport/internet/tcp/dialer.go index abc2688e..8d9bbf78 100644 --- a/transport/internet/tcp/dialer.go +++ b/transport/internet/tcp/dialer.go @@ -14,6 +14,10 @@ import ( "github.com/xtls/xray-core/transport/internet/tls" ) +func IsFromMitm(str string) bool { + return strings.ToLower(str) == "frommitm" +} + // Dial dials a new TCP connection to the given destination. func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (stat.Connection, error) { errors.LogInfo(ctx, "dialing TCP to ", dest) @@ -23,11 +27,28 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } if config := tls.ConfigFromStreamSettings(streamSettings); config != nil { + mitmServerName := session.MitmServerNameFromContext(ctx) + mitmAlpn11 := session.MitmAlpn11FromContext(ctx) tlsConfig := config.GetTLSConfig(tls.WithDestination(dest)) + if IsFromMitm(tlsConfig.ServerName) { + tlsConfig.ServerName = mitmServerName + } + if r, ok := tlsConfig.Rand.(*tls.RandCarrier); ok && len(r.VerifyPeerCertInNames) > 0 && IsFromMitm(r.VerifyPeerCertInNames[0]) { + r.VerifyPeerCertInNames = r.VerifyPeerCertInNames[1:] + after := mitmServerName + for { + if len(after) > 0 { + r.VerifyPeerCertInNames = append(r.VerifyPeerCertInNames, after) + } + _, after, _ = strings.Cut(after, ".") + if !strings.Contains(after, ".") { + break + } + } + } if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil { conn = tls.UClient(conn, tlsConfig, fingerprint) - if len(tlsConfig.NextProtos) == 1 && (tlsConfig.NextProtos[0] == "http/1.1" || - (strings.ToLower(tlsConfig.NextProtos[0]) == "frommitm" && session.MitmAlpn11FromContext(ctx))) { + if len(tlsConfig.NextProtos) == 1 && (tlsConfig.NextProtos[0] == "http/1.1" || (IsFromMitm(tlsConfig.NextProtos[0]) && mitmAlpn11)) { if err := conn.(*tls.UConn).WebsocketHandshakeContext(ctx); err != nil { return nil, err } @@ -37,14 +58,17 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } } } else { - if len(tlsConfig.NextProtos) == 1 && strings.ToLower(tlsConfig.NextProtos[0]) == "frommitm" { - if session.MitmAlpn11FromContext(ctx) { - tlsConfig.NextProtos = []string{"http/1.1"} // new slice + if len(tlsConfig.NextProtos) == 1 && IsFromMitm(tlsConfig.NextProtos[0]) { + if mitmAlpn11 { + tlsConfig.NextProtos[0] = "http/1.1" } else { tlsConfig.NextProtos = nil } } conn = tls.Client(conn, tlsConfig) + if err := conn.(*tls.Conn).HandshakeContext(ctx); err != nil { + return nil, err + } } } else if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { if conn, err = reality.UClient(conn, config, ctx, dest); err != nil { diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 8278cafb..8788b579 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -9,6 +9,7 @@ import ( "crypto/x509" "encoding/base64" "os" + "slices" "strings" "sync" "time" @@ -277,10 +278,35 @@ func (c *Config) parseServerName() string { return c.ServerName } -func (c *Config) verifyPeerCert(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error { - if c.PinnedPeerCertificateChainSha256 != nil { +func (r *RandCarrier) verifyPeerCert(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error { + if r.VerifyPeerCertInNames != nil { + if len(r.VerifyPeerCertInNames) > 0 { + certs := make([]*x509.Certificate, len(rawCerts)) + for i, asn1Data := range rawCerts { + certs[i], _ = x509.ParseCertificate(asn1Data) + } + opts := x509.VerifyOptions{ + Roots: r.RootCAs, + CurrentTime: time.Now(), + Intermediates: x509.NewCertPool(), + } + for _, cert := range certs[1:] { + opts.Intermediates.AddCert(cert) + } + for _, opts.DNSName = range r.VerifyPeerCertInNames { + if _, err := certs[0].Verify(opts); err == nil { + return nil + } + } + } + if r.PinnedPeerCertificateChainSha256 == nil { + errors.New("peer cert is invalid.") + } + } + + if r.PinnedPeerCertificateChainSha256 != nil { hashValue := GenerateCertChainHash(rawCerts) - for _, v := range c.PinnedPeerCertificateChainSha256 { + for _, v := range r.PinnedPeerCertificateChainSha256 { if hmac.Equal(hashValue, v) { return nil } @@ -288,11 +314,11 @@ func (c *Config) verifyPeerCert(rawCerts [][]byte, verifiedChains [][]*x509.Cert return errors.New("peer cert is unrecognized: ", base64.StdEncoding.EncodeToString(hashValue)) } - if c.PinnedPeerCertificatePublicKeySha256 != nil { + if r.PinnedPeerCertificatePublicKeySha256 != nil { for _, v := range verifiedChains { for _, cert := range v { publicHash := GenerateCertPublicKeyHash(cert) - for _, c := range c.PinnedPeerCertificatePublicKeySha256 { + for _, c := range r.PinnedPeerCertificatePublicKeySha256 { if hmac.Equal(publicHash, c) { return nil } @@ -305,7 +331,10 @@ func (c *Config) verifyPeerCert(rawCerts [][]byte, verifiedChains [][]*x509.Cert } type RandCarrier struct { - ServerNameToVerify string + RootCAs *x509.CertPool + VerifyPeerCertInNames []string + PinnedPeerCertificateChainSha256 [][]byte + PinnedPeerCertificatePublicKeySha256 [][]byte } func (r *RandCarrier) Read(p []byte) (n int, err error) { @@ -329,16 +358,25 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config { } } + randCarrier := &RandCarrier{ + RootCAs: root, + VerifyPeerCertInNames: slices.Clone(c.VerifyPeerCertInNames), + PinnedPeerCertificateChainSha256: c.PinnedPeerCertificateChainSha256, + PinnedPeerCertificatePublicKeySha256: c.PinnedPeerCertificatePublicKeySha256, + } config := &tls.Config{ - Rand: &RandCarrier{ - ServerNameToVerify: c.ServerNameToVerify, - }, + Rand: randCarrier, ClientSessionCache: globalSessionCache, RootCAs: root, InsecureSkipVerify: c.AllowInsecure, - NextProtos: c.NextProtocol, + NextProtos: slices.Clone(c.NextProtocol), SessionTicketsDisabled: !c.EnableSessionResumption, - VerifyPeerCertificate: c.verifyPeerCert, + VerifyPeerCertificate: randCarrier.verifyPeerCert, + } + if len(c.VerifyPeerCertInNames) > 0 { + config.InsecureSkipVerify = true + } else { + randCarrier.VerifyPeerCertInNames = nil } for _, opt := range opts { diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index e59fe502..43053c78 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -202,20 +202,21 @@ type Config struct { // TLS Client Hello fingerprint (uTLS). Fingerprint string `protobuf:"bytes,11,opt,name=fingerprint,proto3" json:"fingerprint,omitempty"` RejectUnknownSni bool `protobuf:"varint,12,opt,name=reject_unknown_sni,json=rejectUnknownSni,proto3" json:"reject_unknown_sni,omitempty"` - // @Document A pinned certificate chain sha256 hash. - // @Document If the server's hash does not match this value, the connection will be aborted. - // @Document This value replace allow_insecure. + // @Document Some certificate chain sha256 hashes. + // @Document After normal validation or allow_insecure, if the server's cert chain hash does not match any of these values, the connection will be aborted. // @Critical PinnedPeerCertificateChainSha256 [][]byte `protobuf:"bytes,13,rep,name=pinned_peer_certificate_chain_sha256,json=pinnedPeerCertificateChainSha256,proto3" json:"pinned_peer_certificate_chain_sha256,omitempty"` - // @Document A pinned certificate public key sha256 hash. - // @Document If the server's public key hash does not match this value, the connection will be aborted. - // @Document This value replace allow_insecure. + // @Document Some certificate public key sha256 hashes. + // @Document After normal validation (required), if the verified cert's public key hash does not match any of these values, the connection will be aborted. // @Critical PinnedPeerCertificatePublicKeySha256 [][]byte `protobuf:"bytes,14,rep,name=pinned_peer_certificate_public_key_sha256,json=pinnedPeerCertificatePublicKeySha256,proto3" json:"pinned_peer_certificate_public_key_sha256,omitempty"` MasterKeyLog string `protobuf:"bytes,15,opt,name=master_key_log,json=masterKeyLog,proto3" json:"master_key_log,omitempty"` // Lists of string as CurvePreferences values. - CurvePreferences []string `protobuf:"bytes,16,rep,name=curve_preferences,json=curvePreferences,proto3" json:"curve_preferences,omitempty"` - ServerNameToVerify string `protobuf:"bytes,17,opt,name=server_name_to_verify,json=serverNameToVerify,proto3" json:"server_name_to_verify,omitempty"` + CurvePreferences []string `protobuf:"bytes,16,rep,name=curve_preferences,json=curvePreferences,proto3" json:"curve_preferences,omitempty"` + // @Document Replaces server_name to verify the peer cert. + // @Document After allow_insecure (automatically), if the server's cert can't be verified by any of these names, pinned_peer_certificate_chain_sha256 will be tried. + // @Critical + VerifyPeerCertInNames []string `protobuf:"bytes,17,rep,name=verify_peer_cert_in_names,json=verifyPeerCertInNames,proto3" json:"verify_peer_cert_in_names,omitempty"` } func (x *Config) Reset() { @@ -353,11 +354,11 @@ func (x *Config) GetCurvePreferences() []string { return nil } -func (x *Config) GetServerNameToVerify() string { +func (x *Config) GetVerifyPeerCertInNames() []string { if x != nil { - return x.ServerNameToVerify + return x.VerifyPeerCertInNames } - return "" + return nil } var File_transport_internet_tls_config_proto protoreflect.FileDescriptor @@ -391,7 +392,7 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x4e, 0x43, 0x49, 0x50, 0x48, 0x45, 0x52, 0x4d, 0x45, 0x4e, 0x54, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, 0x5f, 0x56, 0x45, 0x52, 0x49, 0x46, 0x59, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x54, 0x59, - 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0x93, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, + 0x5f, 0x49, 0x53, 0x53, 0x55, 0x45, 0x10, 0x02, 0x22, 0x9a, 0x06, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x69, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0d, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x49, 0x6e, 0x73, 0x65, 0x63, 0x75, 0x72, 0x65, 0x12, 0x4a, 0x0a, 0x0b, 0x63, 0x65, @@ -437,18 +438,19 @@ var file_transport_internet_tls_config_proto_rawDesc = []byte{ 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, 0x12, 0x2b, 0x0a, 0x11, 0x63, 0x75, 0x72, 0x76, 0x65, 0x5f, 0x70, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x09, 0x52, 0x10, 0x63, 0x75, 0x72, 0x76, 0x65, - 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x31, 0x0a, 0x15, 0x73, - 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x74, 0x6f, 0x5f, 0x76, 0x65, - 0x72, 0x69, 0x66, 0x79, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x73, 0x65, 0x72, 0x76, - 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x54, 0x6f, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x42, 0x73, - 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, - 0x73, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, - 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, - 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x50, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x38, 0x0a, 0x19, 0x76, + 0x65, 0x72, 0x69, 0x66, 0x79, 0x5f, 0x70, 0x65, 0x65, 0x72, 0x5f, 0x63, 0x65, 0x72, 0x74, 0x5f, + 0x69, 0x6e, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x09, 0x52, 0x15, + 0x76, 0x65, 0x72, 0x69, 0x66, 0x79, 0x50, 0x65, 0x65, 0x72, 0x43, 0x65, 0x72, 0x74, 0x49, 0x6e, + 0x4e, 0x61, 0x6d, 0x65, 0x73, 0x42, 0x73, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x74, 0x6c, 0x73, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x74, 0x6c, 0x73, 0xaa, 0x02, 0x1b, 0x58, + 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x54, 0x6c, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/transport/internet/tls/config.proto b/transport/internet/tls/config.proto index bb2564a3..c52d0be1 100644 --- a/transport/internet/tls/config.proto +++ b/transport/internet/tls/config.proto @@ -69,16 +69,14 @@ message Config { bool reject_unknown_sni = 12; - /* @Document A pinned certificate chain sha256 hash. - @Document If the server's hash does not match this value, the connection will be aborted. - @Document This value replace allow_insecure. + /* @Document Some certificate chain sha256 hashes. + @Document After normal validation or allow_insecure, if the server's cert chain hash does not match any of these values, the connection will be aborted. @Critical */ repeated bytes pinned_peer_certificate_chain_sha256 = 13; - /* @Document A pinned certificate public key sha256 hash. - @Document If the server's public key hash does not match this value, the connection will be aborted. - @Document This value replace allow_insecure. + /* @Document Some certificate public key sha256 hashes. + @Document After normal validation (required), if the verified cert's public key hash does not match any of these values, the connection will be aborted. @Critical */ repeated bytes pinned_peer_certificate_public_key_sha256 = 14; @@ -88,5 +86,9 @@ message Config { // Lists of string as CurvePreferences values. repeated string curve_preferences = 16; - string server_name_to_verify = 17; + /* @Document Replaces server_name to verify the peer cert. + @Document After allow_insecure (automatically), if the server's cert can't be verified by any of these names, pinned_peer_certificate_chain_sha256 will be tried. + @Critical + */ + repeated string verify_peer_cert_in_names = 17; } diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index e15231f4..bdf77d9a 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -16,6 +16,7 @@ type Interface interface { net.Conn HandshakeContext(ctx context.Context) error VerifyHostname(host string) error + HandshakeContextServerName(ctx context.Context) string NegotiatedProtocol() string } @@ -43,15 +44,11 @@ func (c *Conn) WriteMultiBuffer(mb buf.MultiBuffer) error { return err } -func (c *Conn) HandshakeAddressContext(ctx context.Context) net.Address { +func (c *Conn) HandshakeContextServerName(ctx context.Context) string { if err := c.HandshakeContext(ctx); err != nil { - return nil + return "" } - state := c.ConnectionState() - if state.ServerName == "" { - return nil - } - return net.ParseAddress(state.ServerName) + return c.ConnectionState().ServerName } func (c *Conn) NegotiatedProtocol() string { @@ -85,15 +82,11 @@ func (c *UConn) Close() error { return c.Conn.Close() } -func (c *UConn) HandshakeAddressContext(ctx context.Context) net.Address { +func (c *UConn) HandshakeContextServerName(ctx context.Context) string { if err := c.HandshakeContext(ctx); err != nil { - return nil + return "" } - state := c.ConnectionState() - if state.ServerName == "" { - return nil - } - return net.ParseAddress(state.ServerName) + return c.ConnectionState().ServerName } // WebsocketHandshake basically calls UConn.Handshake inside it but it will only send @@ -134,17 +127,13 @@ func UClient(c net.Conn, config *tls.Config, fingerprint *utls.ClientHelloID) ne } func copyConfig(c *tls.Config) *utls.Config { - serverNameToVerify := "" - if r, ok := c.Rand.(*RandCarrier); ok { - serverNameToVerify = r.ServerNameToVerify - } return &utls.Config{ - RootCAs: c.RootCAs, - ServerName: c.ServerName, - InsecureSkipVerify: c.InsecureSkipVerify, - VerifyPeerCertificate: c.VerifyPeerCertificate, - KeyLogWriter: c.KeyLogWriter, - InsecureServerNameToVerify: serverNameToVerify, + Rand: c.Rand, + RootCAs: c.RootCAs, + ServerName: c.ServerName, + InsecureSkipVerify: c.InsecureSkipVerify, + VerifyPeerCertificate: c.VerifyPeerCertificate, + KeyLogWriter: c.KeyLogWriter, } } From 527caa3711a1dc3e29fd2a62549d4b1efdd64a77 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 6 Feb 2025 07:50:48 +0000 Subject: [PATCH 708/867] Log: Add microseconds for golang's standard logger Completes https://github.com/XTLS/Xray-core/commit/5679d717eef23f48d4f60a0a34684f46c478e053 --- main/run.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main/run.go b/main/run.go index 4134fb64..f74085d8 100644 --- a/main/run.go +++ b/main/run.go @@ -45,6 +45,7 @@ The -dump flag tells Xray to print the merged config. func init() { cmdRun.Run = executeRun // break init loop + log.SetFlags(log.Ldate | log.Ltime | log.Lmicroseconds) } var ( From 88d40d636731a7d6c18b46283b29b22b315e1029 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 11:28:02 +0000 Subject: [PATCH 709/867] Bump golang.org/x/sys from 0.29.0 to 0.30.0 (#4350) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.29.0 to 0.30.0. - [Commits](https://github.com/golang/sys/compare/v0.29.0...v0.30.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 82bff711..2e8c2f71 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/crypto v0.32.0 golang.org/x/net v0.34.0 golang.org/x/sync v0.10.0 - golang.org/x/sys v0.29.0 + golang.org/x/sys v0.30.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.70.0 google.golang.org/protobuf v1.36.4 diff --git a/go.sum b/go.sum index e4418c71..deccde15 100644 --- a/go.sum +++ b/go.sum @@ -119,8 +119,8 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= -golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From e17c06882172d1b0365cbca83f0a7698597cbf03 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 11:30:58 +0000 Subject: [PATCH 710/867] Bump golang.org/x/sync from 0.10.0 to 0.11.0 (#4351) Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.10.0 to 0.11.0. - [Commits](https://github.com/golang/sync/compare/v0.10.0...v0.11.0) --- updated-dependencies: - dependency-name: golang.org/x/sync dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2e8c2f71..cb43767f 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.32.0 golang.org/x/net v0.34.0 - golang.org/x/sync v0.10.0 + golang.org/x/sync v0.11.0 golang.org/x/sys v0.30.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.70.0 diff --git a/go.sum b/go.sum index deccde15..7cf241ed 100644 --- a/go.sum +++ b/go.sum @@ -109,8 +109,8 @@ golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= From 07c35ed52ad0e57e9c47a25c7d029b9d4b09ec52 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Feb 2025 11:31:13 +0000 Subject: [PATCH 711/867] Bump github.com/cloudflare/circl from 1.5.0 to 1.6.0 (#4352) Bumps [github.com/cloudflare/circl](https://github.com/cloudflare/circl) from 1.5.0 to 1.6.0. - [Release notes](https://github.com/cloudflare/circl/releases) - [Commits](https://github.com/cloudflare/circl/compare/v1.5.0...v1.6.0) --- updated-dependencies: - dependency-name: github.com/cloudflare/circl dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cb43767f..a2904844 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.23 require ( github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 - github.com/cloudflare/circl v1.5.0 + github.com/cloudflare/circl v1.6.0 github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.6.0 diff --git a/go.sum b/go.sum index 7cf241ed..1421f201 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 h1:Wo41lDOevRJS github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0/go.mod h1:FVGavL/QEBQDcBpr3fAojoK17xX5k9bicBphrOpP7uM= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= -github.com/cloudflare/circl v1.5.0 h1:hxIWksrX6XN5a1L2TI/h53AGPhNHoUBo+TD1ms9+pys= -github.com/cloudflare/circl v1.5.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= +github.com/cloudflare/circl v1.6.0 h1:cr5JKic4HI+LkINy2lg3W2jF8sHCVTBncJr5gIIq7qk= +github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 117de1fd3c2703c0c85705e47dc7e93716e97c79 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 7 Feb 2025 08:15:40 +0000 Subject: [PATCH 712/867] MITM freedom RAW TLS: Report website with unexpected Negotiated Protocol / invalid Domain Fronting certificate https://github.com/XTLS/Xray-core/issues/4348#issuecomment-2639965524 Needs `"alpn": ["fromMitm"]` / `"verifyPeerCertInNames": ["fromMitm", ...]`. --- proxy/dokodemo/dokodemo.go | 2 +- transport/internet/tcp/dialer.go | 42 +++++++++++++++++++------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index c16135f5..4fb431f4 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -89,7 +89,7 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn st destinationOverridden = true ctx = session.ContextWithMitmServerName(ctx, serverName) } - if tlsConn.NegotiatedProtocol() == "http/1.1" { + if tlsConn.NegotiatedProtocol() != "h2" { ctx = session.ContextWithMitmAlpn11(ctx, true) } } diff --git a/transport/internet/tcp/dialer.go b/transport/internet/tcp/dialer.go index 8d9bbf78..d9fb4aab 100644 --- a/transport/internet/tcp/dialer.go +++ b/transport/internet/tcp/dialer.go @@ -33,7 +33,9 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if IsFromMitm(tlsConfig.ServerName) { tlsConfig.ServerName = mitmServerName } - if r, ok := tlsConfig.Rand.(*tls.RandCarrier); ok && len(r.VerifyPeerCertInNames) > 0 && IsFromMitm(r.VerifyPeerCertInNames[0]) { + r, ok := tlsConfig.Rand.(*tls.RandCarrier) + isFromMitmVerify := ok && len(r.VerifyPeerCertInNames) > 0 && IsFromMitm(r.VerifyPeerCertInNames[0]) + if isFromMitmVerify { r.VerifyPeerCertInNames = r.VerifyPeerCertInNames[1:] after := mitmServerName for { @@ -46,29 +48,35 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me } } } + isFromMitmAlpn := len(tlsConfig.NextProtos) == 1 && IsFromMitm(tlsConfig.NextProtos[0]) + if isFromMitmAlpn { + if mitmAlpn11 { + tlsConfig.NextProtos[0] = "http/1.1" + } else { + tlsConfig.NextProtos = []string{"h2", "http/1.1"} + } + } if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil { conn = tls.UClient(conn, tlsConfig, fingerprint) - if len(tlsConfig.NextProtos) == 1 && (tlsConfig.NextProtos[0] == "http/1.1" || (IsFromMitm(tlsConfig.NextProtos[0]) && mitmAlpn11)) { - if err := conn.(*tls.UConn).WebsocketHandshakeContext(ctx); err != nil { - return nil, err - } + if len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "http/1.1" { // allow manually specify + err = conn.(*tls.UConn).WebsocketHandshakeContext(ctx) } else { - if err := conn.(*tls.UConn).HandshakeContext(ctx); err != nil { - return nil, err - } + err = conn.(*tls.UConn).HandshakeContext(ctx) } } else { - if len(tlsConfig.NextProtos) == 1 && IsFromMitm(tlsConfig.NextProtos[0]) { - if mitmAlpn11 { - tlsConfig.NextProtos[0] = "http/1.1" - } else { - tlsConfig.NextProtos = nil - } - } conn = tls.Client(conn, tlsConfig) - if err := conn.(*tls.Conn).HandshakeContext(ctx); err != nil { - return nil, err + err = conn.(*tls.Conn).HandshakeContext(ctx) + } + if err != nil { + if isFromMitmVerify { + return nil, errors.New("MITM freedom RAW TLS: failed to verify Domain Fronting certificate from " + mitmServerName).Base(err).AtWarning() } + return nil, err + } + negotiatedProtocol := conn.(tls.Interface).NegotiatedProtocol() + if isFromMitmAlpn && !mitmAlpn11 && negotiatedProtocol != "h2" { + conn.Close() + return nil, errors.New("MITM freedom RAW TLS: unexpected Negotiated Protocol (" + negotiatedProtocol + ") with " + mitmServerName).AtWarning() } } else if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { if conn, err = reality.UClient(conn, config, ctx, dest); err != nil { From 1982c2366edb349fa9c784ef5811468ef8ff647d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Feb 2025 10:09:50 +0000 Subject: [PATCH 713/867] Bump google.golang.org/protobuf from 1.36.4 to 1.36.5 (#4363) Bumps google.golang.org/protobuf from 1.36.4 to 1.36.5. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a2904844..deed4b09 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/sys v0.30.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.70.0 - google.golang.org/protobuf v1.36.4 + google.golang.org/protobuf v1.36.5 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.3.0 diff --git a/go.sum b/go.sum index 1421f201..3f246781 100644 --- a/go.sum +++ b/go.sum @@ -145,8 +145,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ= google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw= -google.golang.org/protobuf v1.36.4 h1:6A3ZDJHn/eNqc1i+IdefRzy/9PokBTPvcqMySR7NNIM= -google.golang.org/protobuf v1.36.4/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= +google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From e893fa1828fc88920c526cfc32b552b7a830250e Mon Sep 17 00:00:00 2001 From: Maxim Plotnikov <51321197+mr1cloud@users.noreply.github.com> Date: Fri, 7 Feb 2025 07:19:47 -0500 Subject: [PATCH 714/867] API: Add user IPs and access times tracking (#4360) --- app/stats/command/command.go | 18 ++ app/stats/command/command.pb.go | 194 ++++++++++++------ app/stats/command/command.proto | 6 + app/stats/command/command_grpc.pb.go | 46 ++++- app/stats/online_map.go | 10 + features/stats/stats.go | 3 + main/commands/all/api/api.go | 1 + main/commands/all/api/stats_online_ip_list.go | 47 +++++ 8 files changed, 263 insertions(+), 62 deletions(-) create mode 100644 main/commands/all/api/stats_online_ip_list.go diff --git a/app/stats/command/command.go b/app/stats/command/command.go index e4926bab..64e31d38 100644 --- a/app/stats/command/command.go +++ b/app/stats/command/command.go @@ -60,6 +60,24 @@ func (s *statsServer) GetStatsOnline(ctx context.Context, request *GetStatsReque }, nil } +func (s *statsServer) GetStatsOnlineIpList(ctx context.Context, request *GetStatsRequest) (*GetStatsOnlineIpListResponse, error) { + c := s.stats.GetOnlineMap(request.Name) + + if c == nil { + return nil, errors.New(request.Name, " not found.") + } + + ips := make(map[string]int64) + for ip, t := range c.IpTimeMap() { + ips[ip] = t.Unix() + } + + return &GetStatsOnlineIpListResponse{ + Name: request.Name, + Ips: ips, + }, nil +} + func (s *statsServer) QueryStats(ctx context.Context, request *QueryStatsRequest) (*QueryStatsResponse, error) { matcher, err := strmatcher.Substr.New(request.Pattern) if err != nil { diff --git a/app/stats/command/command.pb.go b/app/stats/command/command.pb.go index c9566834..062c2d28 100644 --- a/app/stats/command/command.pb.go +++ b/app/stats/command/command.pb.go @@ -424,6 +424,59 @@ func (x *SysStatsResponse) GetUptime() uint32 { return 0 } +type GetStatsOnlineIpListResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Ips map[string]int64 `protobuf:"bytes,2,rep,name=ips,proto3" json:"ips,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` +} + +func (x *GetStatsOnlineIpListResponse) Reset() { + *x = GetStatsOnlineIpListResponse{} + mi := &file_app_stats_command_command_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetStatsOnlineIpListResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetStatsOnlineIpListResponse) ProtoMessage() {} + +func (x *GetStatsOnlineIpListResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_stats_command_command_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetStatsOnlineIpListResponse.ProtoReflect.Descriptor instead. +func (*GetStatsOnlineIpListResponse) Descriptor() ([]byte, []int) { + return file_app_stats_command_command_proto_rawDescGZIP(), []int{7} +} + +func (x *GetStatsOnlineIpListResponse) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *GetStatsOnlineIpListResponse) GetIps() map[string]int64 { + if x != nil { + return x.Ips + } + return nil +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -432,7 +485,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - mi := &file_app_stats_command_command_proto_msgTypes[7] + mi := &file_app_stats_command_command_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -444,7 +497,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_app_stats_command_command_proto_msgTypes[7] + mi := &file_app_stats_command_command_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -457,7 +510,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_app_stats_command_command_proto_rawDescGZIP(), []int{7} + return file_app_stats_command_command_proto_rawDescGZIP(), []int{8} } var File_app_stats_command_command_proto protoreflect.FileDescriptor @@ -506,40 +559,60 @@ var file_app_stats_command_command_proto_rawDesc = []byte{ 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, 0x50, 0x61, 0x75, 0x73, 0x65, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x4e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x70, 0x74, - 0x69, 0x6d, 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xa1, 0x03, - 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, - 0x0a, 0x08, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, - 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, - 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, - 0x65, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, - 0x65, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, + 0x69, 0x6d, 0x65, 0x22, 0xbb, 0x01, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, + 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x4f, 0x0a, 0x03, 0x69, 0x70, 0x73, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, + 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x70, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x49, 0x70, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x52, 0x03, 0x69, 0x70, 0x73, 0x1a, 0x36, 0x0a, 0x08, 0x49, 0x70, 0x73, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, + 0x01, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0x9a, 0x04, 0x0a, 0x0c, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x08, + 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, - 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, + 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, + 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x12, + 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, + 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x12, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, + 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x62, 0x0a, 0x0b, 0x47, + 0x65, 0x74, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, - 0x74, 0x61, 0x74, 0x73, 0x12, 0x29, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, - 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x62, 0x0a, - 0x0b, 0x47, 0x65, 0x74, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x27, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, - 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, - 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x42, 0x64, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, - 0x01, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, - 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, - 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, - 0x16, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x2e, - 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, + 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x53, 0x79, 0x73, + 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x77, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, + 0x65, 0x49, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, + 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x34, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, + 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x73, 0x4f, 0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x49, 0x70, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x64, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x2f, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x16, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -554,33 +627,38 @@ func file_app_stats_command_command_proto_rawDescGZIP() []byte { return file_app_stats_command_command_proto_rawDescData } -var file_app_stats_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_app_stats_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 10) var file_app_stats_command_command_proto_goTypes = []any{ - (*GetStatsRequest)(nil), // 0: xray.app.stats.command.GetStatsRequest - (*Stat)(nil), // 1: xray.app.stats.command.Stat - (*GetStatsResponse)(nil), // 2: xray.app.stats.command.GetStatsResponse - (*QueryStatsRequest)(nil), // 3: xray.app.stats.command.QueryStatsRequest - (*QueryStatsResponse)(nil), // 4: xray.app.stats.command.QueryStatsResponse - (*SysStatsRequest)(nil), // 5: xray.app.stats.command.SysStatsRequest - (*SysStatsResponse)(nil), // 6: xray.app.stats.command.SysStatsResponse - (*Config)(nil), // 7: xray.app.stats.command.Config + (*GetStatsRequest)(nil), // 0: xray.app.stats.command.GetStatsRequest + (*Stat)(nil), // 1: xray.app.stats.command.Stat + (*GetStatsResponse)(nil), // 2: xray.app.stats.command.GetStatsResponse + (*QueryStatsRequest)(nil), // 3: xray.app.stats.command.QueryStatsRequest + (*QueryStatsResponse)(nil), // 4: xray.app.stats.command.QueryStatsResponse + (*SysStatsRequest)(nil), // 5: xray.app.stats.command.SysStatsRequest + (*SysStatsResponse)(nil), // 6: xray.app.stats.command.SysStatsResponse + (*GetStatsOnlineIpListResponse)(nil), // 7: xray.app.stats.command.GetStatsOnlineIpListResponse + (*Config)(nil), // 8: xray.app.stats.command.Config + nil, // 9: xray.app.stats.command.GetStatsOnlineIpListResponse.IpsEntry } var file_app_stats_command_command_proto_depIdxs = []int32{ 1, // 0: xray.app.stats.command.GetStatsResponse.stat:type_name -> xray.app.stats.command.Stat 1, // 1: xray.app.stats.command.QueryStatsResponse.stat:type_name -> xray.app.stats.command.Stat - 0, // 2: xray.app.stats.command.StatsService.GetStats:input_type -> xray.app.stats.command.GetStatsRequest - 0, // 3: xray.app.stats.command.StatsService.GetStatsOnline:input_type -> xray.app.stats.command.GetStatsRequest - 3, // 4: xray.app.stats.command.StatsService.QueryStats:input_type -> xray.app.stats.command.QueryStatsRequest - 5, // 5: xray.app.stats.command.StatsService.GetSysStats:input_type -> xray.app.stats.command.SysStatsRequest - 2, // 6: xray.app.stats.command.StatsService.GetStats:output_type -> xray.app.stats.command.GetStatsResponse - 2, // 7: xray.app.stats.command.StatsService.GetStatsOnline:output_type -> xray.app.stats.command.GetStatsResponse - 4, // 8: xray.app.stats.command.StatsService.QueryStats:output_type -> xray.app.stats.command.QueryStatsResponse - 6, // 9: xray.app.stats.command.StatsService.GetSysStats:output_type -> xray.app.stats.command.SysStatsResponse - 6, // [6:10] is the sub-list for method output_type - 2, // [2:6] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 9, // 2: xray.app.stats.command.GetStatsOnlineIpListResponse.ips:type_name -> xray.app.stats.command.GetStatsOnlineIpListResponse.IpsEntry + 0, // 3: xray.app.stats.command.StatsService.GetStats:input_type -> xray.app.stats.command.GetStatsRequest + 0, // 4: xray.app.stats.command.StatsService.GetStatsOnline:input_type -> xray.app.stats.command.GetStatsRequest + 3, // 5: xray.app.stats.command.StatsService.QueryStats:input_type -> xray.app.stats.command.QueryStatsRequest + 5, // 6: xray.app.stats.command.StatsService.GetSysStats:input_type -> xray.app.stats.command.SysStatsRequest + 0, // 7: xray.app.stats.command.StatsService.GetStatsOnlineIpList:input_type -> xray.app.stats.command.GetStatsRequest + 2, // 8: xray.app.stats.command.StatsService.GetStats:output_type -> xray.app.stats.command.GetStatsResponse + 2, // 9: xray.app.stats.command.StatsService.GetStatsOnline:output_type -> xray.app.stats.command.GetStatsResponse + 4, // 10: xray.app.stats.command.StatsService.QueryStats:output_type -> xray.app.stats.command.QueryStatsResponse + 6, // 11: xray.app.stats.command.StatsService.GetSysStats:output_type -> xray.app.stats.command.SysStatsResponse + 7, // 12: xray.app.stats.command.StatsService.GetStatsOnlineIpList:output_type -> xray.app.stats.command.GetStatsOnlineIpListResponse + 8, // [8:13] is the sub-list for method output_type + 3, // [3:8] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_app_stats_command_command_proto_init() } @@ -594,7 +672,7 @@ func file_app_stats_command_command_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_stats_command_command_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 10, NumExtensions: 0, NumServices: 1, }, diff --git a/app/stats/command/command.proto b/app/stats/command/command.proto index 1d2ed867..58ed7371 100644 --- a/app/stats/command/command.proto +++ b/app/stats/command/command.proto @@ -46,11 +46,17 @@ message SysStatsResponse { uint32 Uptime = 10; } +message GetStatsOnlineIpListResponse { + string name = 1; + map ips = 2; +} + service StatsService { rpc GetStats(GetStatsRequest) returns (GetStatsResponse) {} rpc GetStatsOnline(GetStatsRequest) returns (GetStatsResponse) {} rpc QueryStats(QueryStatsRequest) returns (QueryStatsResponse) {} rpc GetSysStats(SysStatsRequest) returns (SysStatsResponse) {} + rpc GetStatsOnlineIpList(GetStatsRequest) returns (GetStatsOnlineIpListResponse) {} } message Config {} diff --git a/app/stats/command/command_grpc.pb.go b/app/stats/command/command_grpc.pb.go index d0bdc60b..6f72eadd 100644 --- a/app/stats/command/command_grpc.pb.go +++ b/app/stats/command/command_grpc.pb.go @@ -19,10 +19,11 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - StatsService_GetStats_FullMethodName = "/xray.app.stats.command.StatsService/GetStats" - StatsService_GetStatsOnline_FullMethodName = "/xray.app.stats.command.StatsService/GetStatsOnline" - StatsService_QueryStats_FullMethodName = "/xray.app.stats.command.StatsService/QueryStats" - StatsService_GetSysStats_FullMethodName = "/xray.app.stats.command.StatsService/GetSysStats" + StatsService_GetStats_FullMethodName = "/xray.app.stats.command.StatsService/GetStats" + StatsService_GetStatsOnline_FullMethodName = "/xray.app.stats.command.StatsService/GetStatsOnline" + StatsService_QueryStats_FullMethodName = "/xray.app.stats.command.StatsService/QueryStats" + StatsService_GetSysStats_FullMethodName = "/xray.app.stats.command.StatsService/GetSysStats" + StatsService_GetStatsOnlineIpList_FullMethodName = "/xray.app.stats.command.StatsService/GetStatsOnlineIpList" ) // StatsServiceClient is the client API for StatsService service. @@ -33,6 +34,7 @@ type StatsServiceClient interface { GetStatsOnline(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) QueryStats(ctx context.Context, in *QueryStatsRequest, opts ...grpc.CallOption) (*QueryStatsResponse, error) GetSysStats(ctx context.Context, in *SysStatsRequest, opts ...grpc.CallOption) (*SysStatsResponse, error) + GetStatsOnlineIpList(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsOnlineIpListResponse, error) } type statsServiceClient struct { @@ -83,6 +85,16 @@ func (c *statsServiceClient) GetSysStats(ctx context.Context, in *SysStatsReques return out, nil } +func (c *statsServiceClient) GetStatsOnlineIpList(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsOnlineIpListResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetStatsOnlineIpListResponse) + err := c.cc.Invoke(ctx, StatsService_GetStatsOnlineIpList_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // StatsServiceServer is the server API for StatsService service. // All implementations must embed UnimplementedStatsServiceServer // for forward compatibility. @@ -91,6 +103,7 @@ type StatsServiceServer interface { GetStatsOnline(context.Context, *GetStatsRequest) (*GetStatsResponse, error) QueryStats(context.Context, *QueryStatsRequest) (*QueryStatsResponse, error) GetSysStats(context.Context, *SysStatsRequest) (*SysStatsResponse, error) + GetStatsOnlineIpList(context.Context, *GetStatsRequest) (*GetStatsOnlineIpListResponse, error) mustEmbedUnimplementedStatsServiceServer() } @@ -113,6 +126,9 @@ func (UnimplementedStatsServiceServer) QueryStats(context.Context, *QueryStatsRe func (UnimplementedStatsServiceServer) GetSysStats(context.Context, *SysStatsRequest) (*SysStatsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetSysStats not implemented") } +func (UnimplementedStatsServiceServer) GetStatsOnlineIpList(context.Context, *GetStatsRequest) (*GetStatsOnlineIpListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetStatsOnlineIpList not implemented") +} func (UnimplementedStatsServiceServer) mustEmbedUnimplementedStatsServiceServer() {} func (UnimplementedStatsServiceServer) testEmbeddedByValue() {} @@ -206,6 +222,24 @@ func _StatsService_GetSysStats_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _StatsService_GetStatsOnlineIpList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetStatsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StatsServiceServer).GetStatsOnlineIpList(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: StatsService_GetStatsOnlineIpList_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StatsServiceServer).GetStatsOnlineIpList(ctx, req.(*GetStatsRequest)) + } + return interceptor(ctx, in, info, handler) +} + // StatsService_ServiceDesc is the grpc.ServiceDesc for StatsService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -229,6 +263,10 @@ var StatsService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetSysStats", Handler: _StatsService_GetSysStats_Handler, }, + { + MethodName: "GetStatsOnlineIpList", + Handler: _StatsService_GetStatsOnlineIpList_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "app/stats/command/command.proto", diff --git a/app/stats/online_map.go b/app/stats/online_map.go index 0ba2b924..9505b28b 100644 --- a/app/stats/online_map.go +++ b/app/stats/online_map.go @@ -78,3 +78,13 @@ func (c *OnlineMap) RemoveExpiredIPs(list map[string]time.Time) map[string]time. } return list } + +func (c *OnlineMap) IpTimeMap() map[string]time.Time { + list := c.ipList + if time.Since(c.lastCleanup) > c.cleanupPeriod { + list = c.RemoveExpiredIPs(list) + c.lastCleanup = time.Now() + } + + return c.ipList +} diff --git a/features/stats/stats.go b/features/stats/stats.go index de343a82..ab5b4067 100644 --- a/features/stats/stats.go +++ b/features/stats/stats.go @@ -2,6 +2,7 @@ package stats import ( "context" + "time" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" @@ -30,6 +31,8 @@ type OnlineMap interface { AddIP(string) // List is the current OnlineMap ip list. List() []string + // IpTimeMap return client ips and their last access time. + IpTimeMap() map[string]time.Time } // Channel is the interface for stats channel. diff --git a/main/commands/all/api/api.go b/main/commands/all/api/api.go index 329450c9..8188d071 100644 --- a/main/commands/all/api/api.go +++ b/main/commands/all/api/api.go @@ -27,5 +27,6 @@ var CmdAPI = &base.Command{ cmdRemoveRules, cmdSourceIpBlock, cmdOnlineStats, + cmdOnlineStatsIpList, }, } diff --git a/main/commands/all/api/stats_online_ip_list.go b/main/commands/all/api/stats_online_ip_list.go new file mode 100644 index 00000000..45b0ed51 --- /dev/null +++ b/main/commands/all/api/stats_online_ip_list.go @@ -0,0 +1,47 @@ +package api + +import ( + statsService "github.com/xtls/xray-core/app/stats/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdOnlineStatsIpList = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api statsonlineiplist [--server=127.0.0.1:8080] [-name '']", + Short: "Get online user ips list and access times", + Long: ` +Get statistics from Xray. +Arguments: + -s, -server + The API server address. Default 127.0.0.1:8080 + -t, -timeout + Timeout seconds to call API. Default 3 + -email + email of the user. + -reset + Reset the counter to fetching its value (not used). +Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -email "user1@test.com" +`, + Run: executeOnlineStatsIpList, +} + +func executeOnlineStatsIpList(cmd *base.Command, args []string) { + setSharedFlags(cmd) + email := cmd.Flag.String("email", "", "") + cmd.Flag.Parse(args) + statName := "user>>>" + *email + ">>>online" + conn, ctx, close := dialAPIServer() + defer close() + + client := statsService.NewStatsServiceClient(conn) + r := &statsService.GetStatsRequest{ + Name: statName, + Reset_: false, + } + resp, err := client.GetStatsOnlineIpList(ctx, r) + if err != nil { + base.Fatalf("failed to get stats: %s", err) + } + showJSONResponse(resp) +} From ae327eb7e6fcb80c0c255fe5a6cd2e63b914a840 Mon Sep 17 00:00:00 2001 From: Artur Melanchyk Date: Fri, 7 Feb 2025 14:48:33 +0100 Subject: [PATCH 715/867] Chore: Make some Maps into real Sets (#4362) --- app/proxyman/inbound/dynamic.go | 6 +++--- transport/internet/reality/reality.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/proxyman/inbound/dynamic.go b/app/proxyman/inbound/dynamic.go index 0a98b888..9bf49717 100644 --- a/app/proxyman/inbound/dynamic.go +++ b/app/proxyman/inbound/dynamic.go @@ -23,7 +23,7 @@ type DynamicInboundHandler struct { receiverConfig *proxyman.ReceiverConfig streamSettings *internet.MemoryStreamConfig portMutex sync.Mutex - portsInUse map[net.Port]bool + portsInUse map[net.Port]struct{} workerMutex sync.RWMutex worker []worker lastRefresh time.Time @@ -39,7 +39,7 @@ func NewDynamicInboundHandler(ctx context.Context, tag string, receiverConfig *p tag: tag, proxyConfig: proxyConfig, receiverConfig: receiverConfig, - portsInUse: make(map[net.Port]bool), + portsInUse: make(map[net.Port]struct{}), mux: mux.NewServer(ctx), v: v, ctx: ctx, @@ -84,7 +84,7 @@ func (h *DynamicInboundHandler) allocatePort() net.Port { port := net.Port(allPorts[r]) _, used := h.portsInUse[port] if !used { - h.portsInUse[port] = true + h.portsInUse[port] = struct{}{} return port } } diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index a65507c6..0efcd96e 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -180,12 +180,12 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati prefix := []byte("https://" + uConn.ServerName) maps.Lock() if maps.maps == nil { - maps.maps = make(map[string]map[string]bool) + maps.maps = make(map[string]map[string]struct{}) } paths := maps.maps[uConn.ServerName] if paths == nil { - paths = make(map[string]bool) - paths[config.SpiderX] = true + paths = make(map[string]struct{}) + paths[config.SpiderX] = struct{}{} maps.maps[uConn.ServerName] = paths } firstURL := string(prefix) + getPathLocked(paths) @@ -232,7 +232,7 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati for _, m := range href.FindAllSubmatch(body, -1) { m[1] = bytes.TrimPrefix(m[1], prefix) if !bytes.Contains(m[1], dot) { - paths[string(m[1])] = true + paths[string(m[1])] = struct{}{} } } req.URL.Path = getPathLocked(paths) @@ -267,10 +267,10 @@ var ( var maps struct { sync.Mutex - maps map[string]map[string]bool + maps map[string]map[string]struct{} } -func getPathLocked(paths map[string]bool) string { +func getPathLocked(paths map[string]struct{}) string { stopAt := int(randBetween(0, int64(len(paths)-1))) i := 0 for s := range paths { From 1d9e6bc2f376625694f17271747ca0869b069f48 Mon Sep 17 00:00:00 2001 From: Daniel Lavrushin Date: Fri, 7 Feb 2025 05:57:52 -0800 Subject: [PATCH 716/867] README.md: Add XrayUI to Asuswrt-Merlin clients (#4355) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 11b6912f..2f78f78d 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,8 @@ - [PassWall](https://github.com/xiaorouji/openwrt-passwall), [PassWall 2](https://github.com/xiaorouji/openwrt-passwall2) - [ShadowSocksR Plus+](https://github.com/fw876/helloworld) - [luci-app-xray](https://github.com/yichya/luci-app-xray) ([openwrt-xray](https://github.com/yichya/openwrt-xray)) +- Asuswrt-Merlin + - [XRAYUI](https://github.com/DanielLavrushin/asuswrt-merlin-xrayui) - Windows - [v2rayN](https://github.com/2dust/v2rayN) - [Furious](https://github.com/LorenEteval/Furious) From c81d8e488a0f4cd47016cd3b6095d2e7238f7627 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 8 Feb 2025 04:47:43 +0000 Subject: [PATCH 717/867] Geofiles: Switch to Loyalsoldier's v2ray-rules-dat https://github.com/XTLS/Xray-core/issues/4348#issuecomment-2643351198 --- .github/workflows/hourly-prepare.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/hourly-prepare.yml b/.github/workflows/hourly-prepare.yml index d07c1ee3..8e0b35fb 100644 --- a/.github/workflows/hourly-prepare.yml +++ b/.github/workflows/hourly-prepare.yml @@ -38,18 +38,18 @@ jobs: max_attempts: 60 command: | [ -d 'resources' ] || mkdir resources - LIST=('geoip geoip geoip' 'domain-list-community dlc geosite') + LIST=('v2ray-rules-dat geoip geoip' 'v2ray-rules-dat geosite geosite') for i in "${LIST[@]}" do INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) FILE_NAME="${INFO[2]}.dat" echo -e "Verifying HASH key..." - HASH="$(curl -sL "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" + HASH="$(curl -sL "https://raw.githubusercontent.com/Loyalsoldier/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then continue else - echo -e "Downloading https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat..." - curl -L "https://raw.githubusercontent.com/v2fly/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} + echo -e "Downloading https://raw.githubusercontent.com/Loyalsoldier/${INFO[0]}/release/${INFO[1]}.dat..." + curl -L "https://raw.githubusercontent.com/Loyalsoldier/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} echo -e "Verifying HASH key..." [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } echo "unhit=true" >> $GITHUB_OUTPUT From db5f18b98cb7c556422f6be004bc76f358dfa849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Sat, 8 Feb 2025 16:07:46 +0800 Subject: [PATCH 718/867] Workflows: Reduce Geodata update frequency (#4369) --- ...repare.yml => scheduled-assets-update.yml} | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) rename .github/workflows/{hourly-prepare.yml => scheduled-assets-update.yml} (70%) diff --git a/.github/workflows/hourly-prepare.yml b/.github/workflows/scheduled-assets-update.yml similarity index 70% rename from .github/workflows/hourly-prepare.yml rename to .github/workflows/scheduled-assets-update.yml index 8e0b35fb..fff1aa7b 100644 --- a/.github/workflows/hourly-prepare.yml +++ b/.github/workflows/scheduled-assets-update.yml @@ -1,4 +1,4 @@ -name: Timely assets update +name: Scheduled assets update # NOTE: This Github Actions is required by other actions, for preparing other packaging assets in a # routine manner, for example: GeoIP/GeoSite. @@ -8,19 +8,20 @@ name: Timely assets update on: workflow_dispatch: schedule: - # Update assets on every hour (xx:30) - - cron: '30 * * * *' + # Update GeoData on every day (22:30 UTC) + - cron: '30 22 * * *' push: # Prevent triggering update request storm paths: - - ".github/workflows/hourly-prepare.yml" + - ".github/workflows/scheduled-assets-update.yml" pull_request: # Prevent triggering update request storm paths: - - ".github/workflows/hourly-prepare.yml" + - ".github/workflows/scheduled-assets-update.yml" jobs: geodat: + if: github.event.schedule == '30 22 * * *' || github.event_name == 'push'|| github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - name: Restore Geodat Cache @@ -38,18 +39,18 @@ jobs: max_attempts: 60 command: | [ -d 'resources' ] || mkdir resources - LIST=('v2ray-rules-dat geoip geoip' 'v2ray-rules-dat geosite geosite') + LIST=('Loyalsoldier v2ray-rules-dat geoip geoip' 'Loyalsoldier v2ray-rules-dat geosite geosite') for i in "${LIST[@]}" do - INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3}')) - FILE_NAME="${INFO[2]}.dat" + INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3,$4}')) + FILE_NAME="${INFO[3]}.dat" echo -e "Verifying HASH key..." - HASH="$(curl -sL "https://raw.githubusercontent.com/Loyalsoldier/${INFO[0]}/release/${INFO[1]}.dat.sha256sum" | awk -F ' ' '{print $1}')" + HASH="$(curl -sL "https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat.sha256sum" | awk -F ' ' '{print $1}')" if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then continue else - echo -e "Downloading https://raw.githubusercontent.com/Loyalsoldier/${INFO[0]}/release/${INFO[1]}.dat..." - curl -L "https://raw.githubusercontent.com/Loyalsoldier/${INFO[0]}/release/${INFO[1]}.dat" -o ./resources/${FILE_NAME} + echo -e "Downloading https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat..." + curl -L "https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat" -o ./resources/${FILE_NAME} echo -e "Verifying HASH key..." [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } echo "unhit=true" >> $GITHUB_OUTPUT From d4c7cd02fd8b5d98dfd67b7322af381e192dc0f1 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 8 Feb 2025 12:11:25 +0000 Subject: [PATCH 719/867] MITM freedom RAW TLS: Allow "fromMitm" to be written at any position in `verifyPeerCertInNames`, Add checking for `alpn` "fromMitm" https://github.com/XTLS/Xray-core/issues/4348#issuecomment-2643340434 --- infra/conf/transport_internet.go | 11 +++++++++-- transport/internet/tcp/dialer.go | 30 +++++++++++++++++++----------- transport/internet/tls/config.go | 2 +- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 962b39ee..7b993a36 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -433,6 +433,13 @@ func (c *TLSConfig) Build() (proto.Message, error) { if c.ALPN != nil && len(*c.ALPN) > 0 { config.NextProtocol = []string(*c.ALPN) } + if len(config.NextProtocol) > 1 { + for _, p := range config.NextProtocol { + if tcp.IsFromMitm(p) { + return nil, errors.New(`only one element is allowed in "alpn" when using "fromMitm" in it`) + } + } + } if c.CurvePreferences != nil && len(*c.CurvePreferences) > 0 { config.CurvePreferences = []string(*c.CurvePreferences) } @@ -443,7 +450,7 @@ func (c *TLSConfig) Build() (proto.Message, error) { config.CipherSuites = c.CipherSuites config.Fingerprint = strings.ToLower(c.Fingerprint) if config.Fingerprint != "unsafe" && tls.GetFingerprint(config.Fingerprint) == nil { - return nil, errors.New(`unknown fingerprint: `, config.Fingerprint) + return nil, errors.New(`unknown "fingerprint": `, config.Fingerprint) } config.RejectUnknownSni = c.RejectUnknownSNI @@ -472,7 +479,7 @@ func (c *TLSConfig) Build() (proto.Message, error) { config.MasterKeyLog = c.MasterKeyLog if c.ServerNameToVerify != "" { - return nil, errors.PrintRemovedFeatureError("serverNameToVerify", "verifyPeerCertInNames") + return nil, errors.PrintRemovedFeatureError(`"serverNameToVerify"`, `"verifyPeerCertInNames"`) } config.VerifyPeerCertInNames = c.VerifyPeerCertInNames diff --git a/transport/internet/tcp/dialer.go b/transport/internet/tcp/dialer.go index d9fb4aab..63b9d627 100644 --- a/transport/internet/tcp/dialer.go +++ b/transport/internet/tcp/dialer.go @@ -2,6 +2,7 @@ package tcp import ( "context" + "slices" "strings" "github.com/xtls/xray-core/common" @@ -33,17 +34,24 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me if IsFromMitm(tlsConfig.ServerName) { tlsConfig.ServerName = mitmServerName } - r, ok := tlsConfig.Rand.(*tls.RandCarrier) - isFromMitmVerify := ok && len(r.VerifyPeerCertInNames) > 0 && IsFromMitm(r.VerifyPeerCertInNames[0]) - if isFromMitmVerify { - r.VerifyPeerCertInNames = r.VerifyPeerCertInNames[1:] - after := mitmServerName - for { - if len(after) > 0 { - r.VerifyPeerCertInNames = append(r.VerifyPeerCertInNames, after) - } - _, after, _ = strings.Cut(after, ".") - if !strings.Contains(after, ".") { + isFromMitmVerify := false + if r, ok := tlsConfig.Rand.(*tls.RandCarrier); ok && len(r.VerifyPeerCertInNames) > 0 { + for i, name := range r.VerifyPeerCertInNames { + if IsFromMitm(name) { + isFromMitmVerify = true + r.VerifyPeerCertInNames[0], r.VerifyPeerCertInNames[i] = r.VerifyPeerCertInNames[i], r.VerifyPeerCertInNames[0] + r.VerifyPeerCertInNames = r.VerifyPeerCertInNames[1:] + after := mitmServerName + for { + if len(after) > 0 { + r.VerifyPeerCertInNames = append(r.VerifyPeerCertInNames, after) + } + _, after, _ = strings.Cut(after, ".") + if !strings.Contains(after, ".") { + break + } + } + slices.Reverse(r.VerifyPeerCertInNames) break } } diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 8788b579..171b30b6 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -300,7 +300,7 @@ func (r *RandCarrier) verifyPeerCert(rawCerts [][]byte, verifiedChains [][]*x509 } } if r.PinnedPeerCertificateChainSha256 == nil { - errors.New("peer cert is invalid.") + return errors.New("peer cert is invalid.") } } From 613c63b165829a0b3e5bfc3a72eff21d96ab4874 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 8 Feb 2025 18:05:41 +0000 Subject: [PATCH 720/867] DNS DoH h2c Remote: Add `verifyPeerCertInNames` "fromMitm" support https://github.com/XTLS/Xray-core/issues/4313#issuecomment-2645838663 --- app/dns/nameserver_doh.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index 177c7561..f602d80a 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -54,7 +54,12 @@ func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, queryStrategy if err != nil { return nil, err } - link, err := s.dispatcher.Dispatch(toDnsContext(ctx, s.dohURL), dest) + dnsCtx := toDnsContext(ctx, s.dohURL) + if h2c { + dnsCtx = session.ContextWithMitmAlpn11(dnsCtx, false) // for insurance + dnsCtx = session.ContextWithMitmServerName(dnsCtx, url.Hostname()) + } + link, err := s.dispatcher.Dispatch(dnsCtx, dest) select { case <-ctx.Done(): return nil, ctx.Err() From 925a985cc02f59f2dbd94d8209aa08fe8bd9af12 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 8 Feb 2025 18:29:54 +0000 Subject: [PATCH 721/867] Commands: Use ".crt" & ".key" suffixes when generating TLS certificates https://github.com/XTLS/Xray-core/issues/4313#issuecomment-2645844058 --- common/protocol/tls/cert/.gitignore | 3 ++- common/protocol/tls/cert/cert_test.go | 4 ++-- main/commands/all/tls/cert.go | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/common/protocol/tls/cert/.gitignore b/common/protocol/tls/cert/.gitignore index 612424a3..b8987f0b 100644 --- a/common/protocol/tls/cert/.gitignore +++ b/common/protocol/tls/cert/.gitignore @@ -1 +1,2 @@ -*.pem \ No newline at end of file +*.crt +*.key \ No newline at end of file diff --git a/common/protocol/tls/cert/cert_test.go b/common/protocol/tls/cert/cert_test.go index e06e61d7..4245f3d6 100644 --- a/common/protocol/tls/cert/cert_test.go +++ b/common/protocol/tls/cert/cert_test.go @@ -78,9 +78,9 @@ func printJSON(certificate *Certificate) { func printFile(certificate *Certificate, name string) error { certPEM, keyPEM := certificate.ToPEM() return task.Run(context.Background(), func() error { - return writeFile(certPEM, name+"_cert.pem") + return writeFile(certPEM, name+".crt") }, func() error { - return writeFile(keyPEM, name+"_key.pem") + return writeFile(keyPEM, name+".key") }) } diff --git a/main/commands/all/tls/cert.go b/main/commands/all/tls/cert.go index c7e39eb6..83cb42b4 100644 --- a/main/commands/all/tls/cert.go +++ b/main/commands/all/tls/cert.go @@ -120,9 +120,9 @@ func writeFile(content []byte, name string) error { func printFile(certificate *cert.Certificate, name string) error { certPEM, keyPEM := certificate.ToPEM() return task.Run(context.Background(), func() error { - return writeFile(certPEM, name+"_cert.pem") + return writeFile(certPEM, name+".crt") }, func() error { - return writeFile(keyPEM, name+"_key.pem") + return writeFile(keyPEM, name+".key") }) } From 2d7ca4a6a6261f321fb0b02e8d02d9139058830c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Feb 2025 08:30:42 +0000 Subject: [PATCH 722/867] Bump golang.org/x/crypto from 0.32.0 to 0.33.0 (#4375) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.32.0 to 0.33.0. - [Commits](https://github.com/golang/crypto/compare/v0.32.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index deed4b09..b77e2dfd 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.32.0 + golang.org/x/crypto v0.33.0 golang.org/x/net v0.34.0 golang.org/x/sync v0.11.0 golang.org/x/sys v0.30.0 @@ -51,7 +51,7 @@ require ( go.uber.org/mock v0.5.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/mod v0.21.0 // indirect - golang.org/x/text v0.21.0 // indirect + golang.org/x/text v0.22.0 // indirect golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.26.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect diff --git a/go.sum b/go.sum index 3f246781..76f0b6ce 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= -golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= @@ -125,8 +125,8 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From dcd7e92c4536b78aaa6ecf99c9fdb4dcef37ef32 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 10 Feb 2025 13:56:13 +0000 Subject: [PATCH 723/867] XHTTP server: Finish stream-up's HTTP POST when its request.Body is closed https://github.com/XTLS/Xray-core/issues/4373#issuecomment-2647908310 Fixes https://github.com/XTLS/Xray-core/issues/4373 --- transport/internet/splithttp/hub.go | 32 ++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index a9aba350..1c5ace05 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -161,7 +161,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } scMaxEachPostBytes := int(h.ln.config.GetNormalizedScMaxEachPostBytes().To) - if request.Method == "POST" && sessionId != "" { + if request.Method == "POST" && sessionId != "" { // stream-up, packet-up seq := "" if len(subpath) > 1 { seq = subpath[1] @@ -173,8 +173,12 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req writer.WriteHeader(http.StatusBadRequest) return } + uploadDone := done.New() err = currentSession.uploadQueue.Push(Packet{ - Reader: request.Body, + Reader: &httpRequestBodyReader{ + requestReader: request.Body, + uploadDone: uploadDone, + }, }) if err != nil { errors.LogInfoInner(context.Background(), err, "failed to upload (PushReader)") @@ -199,8 +203,12 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } }() } - <-request.Context().Done() + select { + case <-request.Context().Done(): + case <-uploadDone.Wait(): + } } + uploadDone.Close() return } @@ -243,7 +251,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } writer.WriteHeader(http.StatusOK) - } else if request.Method == "GET" || sessionId == "" { + } else if request.Method == "GET" || sessionId == "" { // stream-down, stream-one responseFlusher, ok := writer.(http.Flusher) if !ok { panic("expected http.ResponseWriter to be an http.Flusher") @@ -283,7 +291,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req reader: request.Body, remoteAddr: remoteAddr, } - if sessionId != "" { + if sessionId != "" { // if not stream-one conn.reader = currentSession.uploadQueue } @@ -302,6 +310,20 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } } +type httpRequestBodyReader struct { + requestReader io.ReadCloser + uploadDone *done.Instance +} + +func (c *httpRequestBodyReader) Read(b []byte) (int, error) { + return c.requestReader.Read(b) +} + +func (c *httpRequestBodyReader) Close() error { + defer c.uploadDone.Close() + return c.requestReader.Close() +} + type httpResponseBodyWriter struct { sync.Mutex responseWriter http.ResponseWriter From 5033cbceea8464e9e33c3d3d66a794708aca6f81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 11 Feb 2025 13:14:22 +0000 Subject: [PATCH 724/867] Bump golang.org/x/net from 0.34.0 to 0.35.0 (#4382) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.34.0 to 0.35.0. - [Commits](https://github.com/golang/net/compare/v0.34.0...v0.35.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b77e2dfd..a09b0adf 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.33.0 - golang.org/x/net v0.34.0 + golang.org/x/net v0.35.0 golang.org/x/sync v0.11.0 golang.org/x/sys v0.30.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index 76f0b6ce..ca63fb8d 100644 --- a/go.sum +++ b/go.sum @@ -105,8 +105,8 @@ golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= -golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= +golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= +golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= From a71762b5dade15601e230fd407576fbc28385ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Tue, 11 Feb 2025 21:19:03 +0800 Subject: [PATCH 725/867] Workflows: Fix Actions' manual dispatch for assets update (#4378) --- .github/workflows/scheduled-assets-update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scheduled-assets-update.yml b/.github/workflows/scheduled-assets-update.yml index fff1aa7b..fb3ca455 100644 --- a/.github/workflows/scheduled-assets-update.yml +++ b/.github/workflows/scheduled-assets-update.yml @@ -21,7 +21,7 @@ on: jobs: geodat: - if: github.event.schedule == '30 22 * * *' || github.event_name == 'push'|| github.event_name == 'pull_request' + if: github.event.schedule == '30 22 * * *' || github.event_name == 'push'|| github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - name: Restore Geodat Cache From 94c7970fd64592c0729a67f40c2a44f864bd4387 Mon Sep 17 00:00:00 2001 From: yiguous <147401898+yiguous@users.noreply.github.com> Date: Wed, 12 Feb 2025 22:55:16 +0800 Subject: [PATCH 726/867] Config: Correctly marshal PortList and NameServerConfig to JSON (#4386) --- infra/conf/common.go | 18 ++++++++++++++++++ infra/conf/dns.go | 14 +++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/infra/conf/common.go b/infra/conf/common.go index 1cda2459..fa48edea 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -203,6 +203,24 @@ func (list *PortList) Build() *net.PortList { return portList } +func (v PortList) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +func (v PortList) String() string { + ports := []string{} + for _, port := range v.Range { + if port.From == port.To { + p := strconv.Itoa(int(port.From)) + ports = append(ports, p) + } else { + p := fmt.Sprintf("%d-%d", port.From, port.To) + ports = append(ports, p) + } + } + return strings.Join(ports, ",") +} + // UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (list *PortList) UnmarshalJSON(data []byte) error { var listStr string diff --git a/infra/conf/dns.go b/infra/conf/dns.go index d9ed9ab5..65964f3d 100644 --- a/infra/conf/dns.go +++ b/infra/conf/dns.go @@ -12,13 +12,13 @@ import ( ) type NameServerConfig struct { - Address *Address - ClientIP *Address - Port uint16 - SkipFallback bool - Domains []string - ExpectIPs StringList - QueryStrategy string + Address *Address `json:"address"` + ClientIP *Address `json:"clientIp"` + Port uint16 `json:"port"` + SkipFallback bool `json:"skipFallback"` + Domains []string `json:"domains"` + ExpectIPs StringList `json:"expectIps"` + QueryStrategy string `json:"queryStrategy"` } func (c *NameServerConfig) UnmarshalJSON(data []byte) error { From 22c50a70c61f18b54f9e9de82962a053261a398c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 13 Feb 2025 22:01:33 +0800 Subject: [PATCH 727/867] UDS: Make all remote addr 0.0.0.0 (#4390) https://github.com/XTLS/Xray-core/pull/4389#issuecomment-2656360673 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- app/proxyman/inbound/worker.go | 14 +------ common/net/destination.go | 10 ++--- transport/internet/system_listener.go | 56 ++++++++++++++++++--------- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index 6ef8cca4..a14a338f 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -2,7 +2,6 @@ package inbound import ( "context" - "strings" "sync" "sync/atomic" "time" @@ -464,19 +463,8 @@ func (w *dsWorker) callback(conn stat.Connection) { WriteCounter: w.downlinkCounter, } } - // For most of time, unix obviously have no source addr. But if we leave it empty, it will cause panic. - // So we use gateway as source for log. - // However, there are some special situations where a valid source address might be available. - // Such as the source address parsed from X-Forwarded-For in websocket. - // In that case, we keep it. - var source net.Destination - if !strings.Contains(conn.RemoteAddr().String(), "unix") { - source = net.DestinationFromAddr(conn.RemoteAddr()) - } else { - source = net.UnixDestination(w.address) - } ctx = session.ContextWithInbound(ctx, &session.Inbound{ - Source: source, + Source: net.DestinationFromAddr(conn.RemoteAddr()), Gateway: net.UnixDestination(w.address), Tag: w.tag, Conn: conn, diff --git a/common/net/destination.go b/common/net/destination.go index 952dcc6b..90f8298b 100644 --- a/common/net/destination.go +++ b/common/net/destination.go @@ -89,12 +89,10 @@ func UnixDestination(address Address) Destination { // NetAddr returns the network address in this Destination in string form. func (d Destination) NetAddr() string { addr := "" - if d.Address != nil { - if d.Network == Network_TCP || d.Network == Network_UDP { - addr = d.Address.String() + ":" + d.Port.String() - } else if d.Network == Network_UNIX { - addr = d.Address.String() - } + if d.Network == Network_TCP || d.Network == Network_UDP { + addr = d.Address.String() + ":" + d.Port.String() + } else if d.Network == Network_UNIX { + addr = d.Address.String() } return addr } diff --git a/transport/internet/system_listener.go b/transport/internet/system_listener.go index ad7ae892..cdabd3bf 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -21,19 +21,6 @@ type DefaultListener struct { controllers []control.Func } -type combinedListener struct { - net.Listener - locker *FileLocker // for unix domain socket -} - -func (cl *combinedListener) Close() error { - if cl.locker != nil { - cl.locker.Release() - cl.locker = nil - } - return cl.Listener.Close() -} - func getControlFunc(ctx context.Context, sockopt *SocketConfig, controllers []control.Func) func(network, address string, c syscall.RawConn) error { return func(network, address string, c syscall.RawConn) error { return c.Control(func(fd uintptr) { @@ -54,6 +41,40 @@ func getControlFunc(ctx context.Context, sockopt *SocketConfig, controllers []co } } +// For some reason, other component of ray will assume the listener is a TCP listener and have valid remote address. +// But in fact it doesn't. So we need to wrap the listener to make it return 0.0.0.0(unspecified) as remote address. +// If other issues encountered, we should able to fix it here. +type listenUDSWrapper struct { + net.Listener + locker *FileLocker +} + +func (l *listenUDSWrapper) Accept() (net.Conn, error) { + conn, err := l.Listener.Accept() + if err != nil { + return nil, err + } + return &listenUDSWrapperConn{Conn: conn}, nil +} + +func (l *listenUDSWrapper) Close() error { + if l.locker != nil { + l.locker.Release() + l.locker = nil + } + return l.Listener.Close() +} + +type listenUDSWrapperConn struct { + net.Conn +} + +func (conn *listenUDSWrapperConn) RemoteAddr() net.Addr { + return &net.TCPAddr{ + IP: []byte{0, 0, 0, 0}, + } +} + func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *SocketConfig) (l net.Listener, err error) { var lc net.ListenConfig var network, address string @@ -113,9 +134,9 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S callback = func(l net.Listener, err error) (net.Listener, error) { if err != nil { locker.Release() - return l, err + return nil, err } - l = &combinedListener{Listener: l, locker: locker} + l = &listenUDSWrapper{Listener: l, locker: locker} if filePerm == nil { return l, nil } @@ -129,9 +150,8 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S } } - l, err = lc.Listen(ctx, network, address) - l, err = callback(l, err) - if sockopt != nil && sockopt.AcceptProxyProtocol { + l, err = callback(lc.Listen(ctx, network, address)) + if err == nil && sockopt != nil && sockopt.AcceptProxyProtocol { policyFunc := func(upstream net.Addr) (proxyproto.Policy, error) { return proxyproto.REQUIRE, nil } l = &proxyproto.Listener{Listener: l, Policy: policyFunc} } From 958b13ebb5fcefce6cdcbfd6ef959c560064e919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=90=B2=93=F0=90=B3=9B=F0=90=B3=AA=F0=90=B3=82?= =?UTF-8?q?=F0=90=B3=90=20=F0=90=B2=80=F0=90=B3=A2=F0=90=B3=A6=F0=90=B3=AB?= =?UTF-8?q?=F0=90=B3=A2=20=F0=90=B2=A5=F0=90=B3=94=F0=90=B3=9B=F0=90=B3=AA?= =?UTF-8?q?=F0=90=B3=8C=F0=90=B3=91=F0=90=B3=96=F0=90=B3=87?= <26771058+KobeArthurScofield@users.noreply.github.com> Date: Tue, 18 Feb 2025 16:33:05 +0800 Subject: [PATCH 728/867] Build: End of the easily mistaken 'Makefile' (#4395) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- .github/workflows/release-win7.yml | 27 +++++++++++----------- .github/workflows/release.yml | 24 ++++++++++++------- Makefile | 37 ------------------------------ README.md | 10 ++++---- 4 files changed, 36 insertions(+), 62 deletions(-) delete mode 100644 Makefile diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml index 0d00634a..239de1b5 100644 --- a/.github/workflows/release-win7.yml +++ b/.github/workflows/release-win7.yml @@ -1,11 +1,5 @@ name: Build and Release for Windows 7 -# NOTE: This Github Actions file depends on the Makefile. -# Building the correct package requires the correct binaries generated by the Makefile. To -# ensure the correct output, the Makefile must accept the appropriate input and compile the -# correct file with the correct name. If you need to modify this file, please ensure it won't -# disrupt the Makefile. - on: workflow_dispatch: release: @@ -37,6 +31,9 @@ jobs: GOARCH: ${{ matrix.goarch }} CGO_ENABLED: 0 steps: + - name: Checkout codebase + uses: actions/checkout@v4 + - name: Show workflow information run: | _NAME=${{ matrix.assetname }} @@ -46,18 +43,17 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: stable + go-version-file: go.mod check-latest: true - name: Setup patched builder run: | GOSDK=$(go env GOROOT) - curl -O -L https://github.com/XTLS/go-win7/releases/latest/download/go-for-win7-linux-amd64.zip rm -r $GOSDK/* + cd $GOSDK + curl -O -L https://github.com/XTLS/go-win7/releases/latest/download/go-for-win7-linux-amd64.zip unzip ./go-for-win7-linux-amd64.zip -d $GOSDK - - - name: Checkout codebase - uses: actions/checkout@v4 + rm ./go-for-win7-linux-amd64.zip - name: Get project dependencies run: go mod download @@ -65,8 +61,13 @@ jobs: - name: Build Xray run: | mkdir -p build_assets - make - find . -maxdepth 1 -type f -regex './\(wxray\|xray\).exe' -exec mv {} ./build_assets/ \; + COMMID=$(git describe --always --dirty) + echo 'Building Xray for Windows 7...' + go build -o build_assets/xray.exe -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main + echo 'CreateObject("Wscript.Shell").Run "xray.exe -config config.json",0' > build_assets/xray_no_window.vbs + echo 'Start-Process -FilePath ".\xray.exe" -ArgumentList "-config .\config.json" -WindowStyle Hidden' > build_assets/xray_no_window.ps1 + # The line below is for without running conhost.exe version. Commented for not being used. Provided for reference. + # go build -o build_assets/wxray.exe -trimpath -buildvcs=false -ldflags="-H windowsgui -X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main - name: Restore Geodat Cache uses: actions/cache/restore@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bc8c51d..4de01e48 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,11 +1,5 @@ name: Build and Release -# NOTE: This Github Actions file depends on the Makefile. -# Building the correct package requires the correct binaries generated by the Makefile. To -# ensure the correct output, the Makefile must accept the appropriate input and compile the -# correct file with the correct name. If you need to modify this file, please ensure it won't -# disrupt the Makefile. - on: workflow_dispatch: release: @@ -129,8 +123,22 @@ jobs: - name: Build Xray run: | mkdir -p build_assets - make - find . -maxdepth 1 -type f -regex './\(wxray\|xray\|xray_softfloat\)\(\|.exe\)' -exec mv {} ./build_assets/ \; + COMMID=$(git describe --always --dirty) + if [[ ${GOOS} == 'windows' ]]; then + echo 'Building Xray for Windows...' + go build -o build_assets/xray.exe -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main + echo 'CreateObject("Wscript.Shell").Run "xray.exe -config config.json",0' > build_assets/xray_no_window.vbs + echo 'Start-Process -FilePath ".\xray.exe" -ArgumentList "-config .\config.json" -WindowStyle Hidden' > build_assets/xray_no_window.ps1 + # The line below is for without running conhost.exe version. Commented for not being used. Provided for reference. + # go build -o build_assets/wxray.exe -trimpath -buildvcs=false -ldflags="-H windowsgui -X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main + else + echo 'Building Xray...' + go build -o build_assets/xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main + if [[ ${GOARCH} == 'mips' || ${GOARCH} == 'mipsle' ]]; then + echo 'Building soft-float Xray for MIPS/MIPSLE 32-bit...' + GOMIPS=softfloat go build -o build_assets/xray_softfloat -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main + fi + fi - name: Restore Geodat Cache uses: actions/cache/restore@v4 diff --git a/Makefile b/Makefile deleted file mode 100644 index 7653e306..00000000 --- a/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -NAME = xray - -VERSION=$(shell git describe --always --dirty) - -# NOTE: This MAKEFILE can be used to build Xray-core locally and in Automatic workflows. It is \ - provided for convenience in automatic building and functions as a part of it. -# NOTE: If you need to modify this file, please be aware that:\ - - This file is not the main Makefile; it only accepts environment variables and builds the \ - binary.\ - - Automatic building expects the correct binaries to be built by this Makefile. If you \ - intend to propose a change to this Makefile, carefully review the file below and ensure \ - that the change will not accidentally break the automatic building:\ - .github/workflows/release.yml \ - Otherwise it is recommended to contact the project maintainers. - -LDFLAGS = -X github.com/xtls/xray-core/core.build=$(VERSION) -s -w -buildid= -PARAMS = -trimpath -ldflags "$(LDFLAGS)" -v -MAIN = ./main -PREFIX ?= $(shell go env GOPATH) -ifeq ($(GOOS),windows) -OUTPUT = $(NAME).exe -ADDITION = go build -o w$(NAME).exe -trimpath -ldflags "-H windowsgui $(LDFLAGS)" -v $(MAIN) -else -OUTPUT = $(NAME) -endif -ifeq ($(shell echo "$(GOARCH)" | grep -Eq "(mips|mipsle)" && echo true),true) # -ADDITION = GOMIPS=softfloat go build -o $(NAME)_softfloat -trimpath -ldflags "$(LDFLAGS)" -v $(MAIN) -endif -.PHONY: clean build - -build: - go build -o $(OUTPUT) $(PARAMS) $(MAIN) - $(ADDITION) - -clean: - go clean -v -i $(PWD) - rm -f xray xray.exe wxray.exe xray_softfloat diff --git a/README.md b/README.md index 2f78f78d..7b258cff 100644 --- a/README.md +++ b/README.md @@ -126,25 +126,27 @@ - [Xray-core v1.0.0](https://github.com/XTLS/Xray-core/releases/tag/v1.0.0) was forked from [v2fly-core 9a03cc5](https://github.com/v2fly/v2ray-core/commit/9a03cc5c98d04cc28320fcee26dbc236b3291256), and we have made & accumulated a huge number of enhancements over time, check [the release notes for each version](https://github.com/XTLS/Xray-core/releases). - For third-party projects used in [Xray-core](https://github.com/XTLS/Xray-core), check your local or [the latest go.mod](https://github.com/XTLS/Xray-core/blob/main/go.mod). -## Compilation +## One-line Compilation ### Windows (PowerShell) ```powershell $env:CGO_ENABLED=0 -go build -o xray.exe -trimpath -ldflags "-s -w -buildid=" ./main +go build -o xray.exe -trimpath -buildvcs=false -ldflags="-s -w -buildid=" -v ./main ``` ### Linux / macOS ```bash -CGO_ENABLED=0 go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main +CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -ldflags="-s -w -buildid=" -v ./main ``` ### Reproducible Releases +Make sure that you are using the same Go version, and remember to set the git commit id (7 bytes): + ```bash -make +CGO_ENABLED=0 go build -o xray -trimpath -buildvcs=false -ldflags="-X github.com/xtls/xray-core/core.build=REPLACE -s -w -buildid=" -v ./main ``` ## Stargazers over time From a1714cc4ceefd4f4b5053e88010547d984c9c39e Mon Sep 17 00:00:00 2001 From: Bill Zhong Date: Tue, 18 Feb 2025 05:06:39 -0330 Subject: [PATCH 729/867] API: Improve cli usage descriptions (#4401) --- main/commands/all/api/balancer_info.go | 15 ++++------ main/commands/all/api/balancer_override.go | 26 +++++++---------- main/commands/all/api/inbound_user.go | 22 +++++++++----- main/commands/all/api/inbound_user_count.go | 20 ++++++++----- main/commands/all/api/inbounds_add.go | 13 ++++++--- main/commands/all/api/inbounds_remove.go | 13 ++++++--- main/commands/all/api/logger_restart.go | 13 +++++++-- main/commands/all/api/outbounds_add.go | 13 ++++++--- main/commands/all/api/outbounds_remove.go | 13 ++++++--- main/commands/all/api/rules_add.go | 13 ++++++--- main/commands/all/api/rules_remove.go | 15 ++++++---- main/commands/all/api/source_ip_block.go | 29 ++++++++++++------- main/commands/all/api/stats_get.go | 21 +++++++++----- main/commands/all/api/stats_online.go | 24 ++++++++------- main/commands/all/api/stats_online_ip_list.go | 24 ++++++++------- main/commands/all/api/stats_query.go | 17 +++++++---- main/commands/all/api/stats_sys.go | 17 +++++++---- 17 files changed, 194 insertions(+), 114 deletions(-) diff --git a/main/commands/all/api/balancer_info.go b/main/commands/all/api/balancer_info.go index 0d376d63..f5b6804c 100644 --- a/main/commands/all/api/balancer_info.go +++ b/main/commands/all/api/balancer_info.go @@ -13,25 +13,20 @@ import ( var cmdBalancerInfo = &base.Command{ CustomFlags: true, UsageLine: "{{.Exec}} api bi [--server=127.0.0.1:8080] [balancer]...", - Short: "balancer information", + Short: "Retrieve balancer information", Long: ` -Get information of specified balancers, including health, strategy -and selecting. If no balancer tag specified, get information of -all balancers. +Retrieve information of specified balancers, including health, strategy and selecting. +If no balancer tag specified, information for all balancers is returned. -> Make sure you have "RoutingService" set in "config.api.services" -of server config. +> Ensure that "RoutingService" is enabled under "config.api.services" in the server configuration. Arguments: - -json - Use json output. - -s, -server The API server address. Default 127.0.0.1:8080 -t, -timeout - Timeout seconds to call API. Default 3 + Timeout in seconds for calling API. Default 3 Example: diff --git a/main/commands/all/api/balancer_override.go b/main/commands/all/api/balancer_override.go index 3ac013e9..7386b1a5 100644 --- a/main/commands/all/api/balancer_override.go +++ b/main/commands/all/api/balancer_override.go @@ -7,31 +7,27 @@ import ( var cmdBalancerOverride = &base.Command{ CustomFlags: true, - UsageLine: "{{.Exec}} api bo [--server=127.0.0.1:8080] <-b balancer> outboundTag", - Short: "balancer override", + UsageLine: "{{.Exec}} api bo [--server=127.0.0.1:8080] <-b balancer> outboundTag <-r>", + Short: "Override balancer", Long: ` -Override a balancer's selection. +Override the selection target of a balancer. -> Make sure you have "RoutingService" set in "config.api.services" -of server config. +> Ensure that the "RoutingService" is properly configured under "config.api.services" in the server configuration. -Once a balancer's selecting is overridden: +Once the balancer's selection is overridden: - The balancer's selection result will always be outboundTag Arguments: - -r, -remove - Remove the overridden - - -r, -remove - Remove the override - - -s, -server + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + -t, -timeout + Timeout in seconds for calling API. Default 3 + + -r, -remove + Remove the existing override. Example: diff --git a/main/commands/all/api/inbound_user.go b/main/commands/all/api/inbound_user.go index 7a443183..23c191d5 100644 --- a/main/commands/all/api/inbound_user.go +++ b/main/commands/all/api/inbound_user.go @@ -8,20 +8,28 @@ import ( var cmdInboundUser = &base.Command{ CustomFlags: true, UsageLine: "{{.Exec}} api inbounduser [--server=127.0.0.1:8080] -tag=tag [-email=email]", - Short: "Get Inbound User", + Short: "Retrieve inbound user(s)", Long: ` Get User info from an inbound. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + -tag Inbound tag - -email - User email. If email is not given, will get all users + + -email + The user's email address. If not provided, all users will be retrieved. + Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -tag="tag name" -email="xray@love.com" + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -tag="tag name" + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -tag="tag name" -email="xray@love.com" `, Run: executeInboundUser, } diff --git a/main/commands/all/api/inbound_user_count.go b/main/commands/all/api/inbound_user_count.go index 18cab7e8..8c7c0fc3 100644 --- a/main/commands/all/api/inbound_user_count.go +++ b/main/commands/all/api/inbound_user_count.go @@ -8,18 +8,24 @@ import ( var cmdInboundUserCount = &base.Command{ CustomFlags: true, UsageLine: "{{.Exec}} api inboundusercount [--server=127.0.0.1:8080] -tag=tag", - Short: "Get Inbound User Count", + Short: "Retrieve inbound user count", Long: ` -Get User count from an inbound. +Retrieve the user count for a specified inbound tag. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + -tag - Inbound tag + Inbound tag + Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -tag="tag name" + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -tag="tag name" `, Run: executeInboundUserCount, } diff --git a/main/commands/all/api/inbounds_add.go b/main/commands/all/api/inbounds_add.go index dad8b0f9..9bad6f87 100644 --- a/main/commands/all/api/inbounds_add.go +++ b/main/commands/all/api/inbounds_add.go @@ -15,13 +15,18 @@ var cmdAddInbounds = &base.Command{ Short: "Add inbounds", Long: ` Add inbounds to Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json c2.json + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json c2.json `, Run: executeAddInbounds, } diff --git a/main/commands/all/api/inbounds_remove.go b/main/commands/all/api/inbounds_remove.go index 9ab83e20..400a239e 100644 --- a/main/commands/all/api/inbounds_remove.go +++ b/main/commands/all/api/inbounds_remove.go @@ -14,13 +14,18 @@ var cmdRemoveInbounds = &base.Command{ Short: "Remove inbounds", Long: ` Remove inbounds from Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json "tag name" + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json "tag name" `, Run: executeRemoveInbounds, } diff --git a/main/commands/all/api/logger_restart.go b/main/commands/all/api/logger_restart.go index 7bd6f10d..15dacc15 100644 --- a/main/commands/all/api/logger_restart.go +++ b/main/commands/all/api/logger_restart.go @@ -11,11 +11,18 @@ var cmdRestartLogger = &base.Command{ Short: "Restart the logger", Long: ` Restart the logger of Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + +Example: + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 `, Run: executeRestartLogger, } diff --git a/main/commands/all/api/outbounds_add.go b/main/commands/all/api/outbounds_add.go index 5066e543..8d36f75a 100644 --- a/main/commands/all/api/outbounds_add.go +++ b/main/commands/all/api/outbounds_add.go @@ -15,13 +15,18 @@ var cmdAddOutbounds = &base.Command{ Short: "Add outbounds", Long: ` Add outbounds to Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json c2.json + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json c2.json `, Run: executeAddOutbounds, } diff --git a/main/commands/all/api/outbounds_remove.go b/main/commands/all/api/outbounds_remove.go index 9fdbc078..a081bc62 100644 --- a/main/commands/all/api/outbounds_remove.go +++ b/main/commands/all/api/outbounds_remove.go @@ -14,13 +14,18 @@ var cmdRemoveOutbounds = &base.Command{ Short: "Remove outbounds", Long: ` Remove outbounds from Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json "tag name" + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json "tag name" `, Run: executeRemoveOutbounds, } diff --git a/main/commands/all/api/rules_add.go b/main/commands/all/api/rules_add.go index 11ec1e01..2e1404e6 100644 --- a/main/commands/all/api/rules_add.go +++ b/main/commands/all/api/rules_add.go @@ -16,16 +16,21 @@ var cmdAddRules = &base.Command{ Short: "Add routing rules", Long: ` Add routing rules to Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout + + -t, -timeout Timeout seconds to call API. Default 3 + -append - append or replace config. Default false + Append to the existing configuration instead of replacing it. Default false Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json c2.json + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json c2.json `, Run: executeAddRules, } diff --git a/main/commands/all/api/rules_remove.go b/main/commands/all/api/rules_remove.go index 4904022a..ac9a8d09 100644 --- a/main/commands/all/api/rules_remove.go +++ b/main/commands/all/api/rules_remove.go @@ -9,17 +9,22 @@ import ( var cmdRemoveRules = &base.Command{ CustomFlags: true, - UsageLine: "{{.Exec}} api rmrules [--server=127.0.0.1:8080] ruleTag1 ruleTag2...", + UsageLine: "{{.Exec}} api rmrules [--server=127.0.0.1:8080] [ruleTag]...", Short: "Remove routing rules by ruleTag", Long: ` Remove routing rules by ruleTag from Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 ruleTag1 ruleTag2 + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 ruleTag1 ruleTag2 `, Run: executeRemoveRules, } diff --git a/main/commands/all/api/source_ip_block.go b/main/commands/all/api/source_ip_block.go index 1f773187..11f3d55d 100644 --- a/main/commands/all/api/source_ip_block.go +++ b/main/commands/all/api/source_ip_block.go @@ -14,25 +14,34 @@ import ( var cmdSourceIpBlock = &base.Command{ CustomFlags: true, UsageLine: "{{.Exec}} api sib [--server=127.0.0.1:8080] -outbound=blocked -inbound=socks 1.2.3.4", - Short: "Drop connections by source ip", + Short: "Block connections by source IP", Long: ` -Drop connections by source ip. +Block connections by source IP address. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + -outbound - route traffic to specific outbound. + Specifies the outbound tag. + -inbound - target traffig from specific inbound. + Specifies the inbound tag. + -ruletag - set ruleTag. Default sourceIpBlock + The ruleTag. Default sourceIpBlock + -reset remove ruletag and apply new source IPs. Default false - Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 c1.json c2.json +Example: + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -outbound=blocked -inbound=socks 1.2.3.4 + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -outbound=blocked -inbound=socks 1.2.3.4 -reset `, Run: executeSourceIpBlock, } diff --git a/main/commands/all/api/stats_get.go b/main/commands/all/api/stats_get.go index c03fe5f8..9b5d82f9 100644 --- a/main/commands/all/api/stats_get.go +++ b/main/commands/all/api/stats_get.go @@ -8,19 +8,26 @@ import ( var cmdGetStats = &base.Command{ CustomFlags: true, UsageLine: "{{.Exec}} api stats [--server=127.0.0.1:8080] [-name '']", - Short: "Get statistics", + Short: "Retrieve statistics", Long: ` -Get statistics from Xray. +Retrieve the statistics from Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + -name - Name of the stat counter. + Name of the counter. + -reset - Reset the counter to fetching its value. + Reset the counter after fetching their values. Default false + Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -name "inbound>>>statin>>>traffic>>>downlink" `, Run: executeGetStats, diff --git a/main/commands/all/api/stats_online.go b/main/commands/all/api/stats_online.go index 93592807..aca547a6 100644 --- a/main/commands/all/api/stats_online.go +++ b/main/commands/all/api/stats_online.go @@ -7,21 +7,25 @@ import ( var cmdOnlineStats = &base.Command{ CustomFlags: true, - UsageLine: "{{.Exec}} api statsonline [--server=127.0.0.1:8080] [-name '']", - Short: "Get online user", + UsageLine: "{{.Exec}} api statsonline [--server=127.0.0.1:8080] [-email '']", + Short: "Retrieve the online session count for a user", Long: ` -Get statistics from Xray. +Retrieve the current number of active sessions for a user from Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + -email - email of the user. - -reset - Reset the counter to fetching its value. + The user's email address. + Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -email "user1@test.com" + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -email "xray@love.com" `, Run: executeOnlineStats, } diff --git a/main/commands/all/api/stats_online_ip_list.go b/main/commands/all/api/stats_online_ip_list.go index 45b0ed51..74e066f9 100644 --- a/main/commands/all/api/stats_online_ip_list.go +++ b/main/commands/all/api/stats_online_ip_list.go @@ -7,21 +7,25 @@ import ( var cmdOnlineStatsIpList = &base.Command{ CustomFlags: true, - UsageLine: "{{.Exec}} api statsonlineiplist [--server=127.0.0.1:8080] [-name '']", - Short: "Get online user ips list and access times", + UsageLine: "{{.Exec}} api statsonlineiplist [--server=127.0.0.1:8080] [-email '']", + Short: "Retrieve a user's online IP addresses and access times", Long: ` -Get statistics from Xray. +Retrieve the online IP addresses and corresponding access timestamps for a user from Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + -email - email of the user. - -reset - Reset the counter to fetching its value (not used). + The user's email address. + Example: - {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -email "user1@test.com" + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -email "xray@love.com" `, Run: executeOnlineStatsIpList, } diff --git a/main/commands/all/api/stats_query.go b/main/commands/all/api/stats_query.go index f3163199..99d64437 100644 --- a/main/commands/all/api/stats_query.go +++ b/main/commands/all/api/stats_query.go @@ -11,16 +11,23 @@ var cmdQueryStats = &base.Command{ Short: "Query statistics", Long: ` Query statistics from Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + -pattern - Pattern of the query. + Filter pattern for the statistics query. + -reset - Reset the counter to fetching its value. + Reset the counter after fetching their values. Default false + Example: + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 -pattern "counter_" `, Run: executeQueryStats, diff --git a/main/commands/all/api/stats_sys.go b/main/commands/all/api/stats_sys.go index de7a8ce2..e34d056e 100644 --- a/main/commands/all/api/stats_sys.go +++ b/main/commands/all/api/stats_sys.go @@ -8,14 +8,21 @@ import ( var cmdSysStats = &base.Command{ CustomFlags: true, UsageLine: "{{.Exec}} api statssys [--server=127.0.0.1:8080]", - Short: "Get system statistics", + Short: "Retrieve system statistics", Long: ` -Get system statistics from Xray. +Retrieve system statistics from Xray. + Arguments: - -s, -server + + -s, -server The API server address. Default 127.0.0.1:8080 - -t, -timeout - Timeout seconds to call API. Default 3 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + +Example: + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 `, Run: executeSysStats, } From eef74b2c7dd6d988b8baab6b5d15062e6497f372 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Tue, 18 Feb 2025 03:37:52 -0500 Subject: [PATCH 730/867] XTLS: More separate uplink/downlink flags for splice copy (#4407) - In 03131c72dbbfc13ba4ce8e1f9f65f43f3dda7372 new flags were added for uplink/downlink, but that was not suffcient - Now that the traffic state contains all possible info - Each inbound and outbound is responsible to set their own CanSpliceCopy flag. Note that this also open up more splice usage. E.g. socks in -> freedom out - Fixes https://github.com/XTLS/Xray-core/issues/4033 --- proxy/http/client.go | 1 + proxy/http/server.go | 1 + proxy/proxy.go | 175 +++++++++++++++++++++---------- proxy/socks/client.go | 2 + proxy/socks/server.go | 2 + proxy/vless/encoding/encoding.go | 18 ++-- 6 files changed, 132 insertions(+), 67 deletions(-) diff --git a/proxy/http/client.go b/proxy/http/client.go index 862ca418..b1326bec 100644 --- a/proxy/http/client.go +++ b/proxy/http/client.go @@ -151,6 +151,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter return buf.Copy(link.Reader, buf.NewWriter(conn), buf.UpdateActivity(timer)) } responseFunc := func() error { + ob.CanSpliceCopy = 1 defer timer.SetTimeout(p.Timeouts.UplinkOnly) return buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer)) } diff --git a/proxy/http/server.go b/proxy/http/server.go index 01216513..24708e69 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -207,6 +207,7 @@ func (s *Server) handleConnect(ctx context.Context, _ *http.Request, reader *buf } responseDone := func() error { + inbound.CanSpliceCopy = 1 defer timer.SetTimeout(plcy.Timeouts.UplinkOnly) v2writer := buf.NewWriter(conn) diff --git a/proxy/proxy.go b/proxy/proxy.go index a3d3fccb..a90aa340 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -107,19 +107,33 @@ type TrafficState struct { IsTLS bool Cipher uint16 RemainingServerHello int32 + Inbound InboundState + Outbound OutboundState +} +type InboundState struct { // reader link state WithinPaddingBuffers bool - DownlinkReaderDirectCopy bool UplinkReaderDirectCopy bool RemainingCommand int32 RemainingContent int32 RemainingPadding int32 CurrentCommand int - // write link state IsPadding bool DownlinkWriterDirectCopy bool +} + +type OutboundState struct { + // reader link state + WithinPaddingBuffers bool + DownlinkReaderDirectCopy bool + RemainingCommand int32 + RemainingContent int32 + RemainingPadding int32 + CurrentCommand int + // write link state + IsPadding bool UplinkWriterDirectCopy bool } @@ -132,16 +146,26 @@ func NewTrafficState(userUUID []byte) *TrafficState { IsTLS: false, Cipher: 0, RemainingServerHello: -1, - WithinPaddingBuffers: true, - DownlinkReaderDirectCopy: false, - UplinkReaderDirectCopy: false, - RemainingCommand: -1, - RemainingContent: -1, - RemainingPadding: -1, - CurrentCommand: 0, - IsPadding: true, - DownlinkWriterDirectCopy: false, - UplinkWriterDirectCopy: false, + Inbound: InboundState{ + WithinPaddingBuffers: true, + UplinkReaderDirectCopy: false, + RemainingCommand: -1, + RemainingContent: -1, + RemainingPadding: -1, + CurrentCommand: 0, + IsPadding: true, + DownlinkWriterDirectCopy: false, + }, + Outbound: OutboundState{ + WithinPaddingBuffers: true, + DownlinkReaderDirectCopy: false, + RemainingCommand: -1, + RemainingContent: -1, + RemainingPadding: -1, + CurrentCommand: 0, + IsPadding: true, + UplinkWriterDirectCopy: false, + }, } } @@ -166,28 +190,43 @@ func NewVisionReader(reader buf.Reader, state *TrafficState, isUplink bool, cont func (w *VisionReader) ReadMultiBuffer() (buf.MultiBuffer, error) { buffer, err := w.Reader.ReadMultiBuffer() if !buffer.IsEmpty() { - if w.trafficState.WithinPaddingBuffers || w.trafficState.NumberOfPacketToFilter > 0 { + var withinPaddingBuffers *bool + var remainingContent *int32 + var remainingPadding *int32 + var currentCommand *int + var switchToDirectCopy *bool + if w.isUplink { + withinPaddingBuffers = &w.trafficState.Inbound.WithinPaddingBuffers + remainingContent = &w.trafficState.Inbound.RemainingContent + remainingPadding = &w.trafficState.Inbound.RemainingPadding + currentCommand = &w.trafficState.Inbound.CurrentCommand + switchToDirectCopy = &w.trafficState.Inbound.UplinkReaderDirectCopy + } else { + withinPaddingBuffers = &w.trafficState.Outbound.WithinPaddingBuffers + remainingContent = &w.trafficState.Outbound.RemainingContent + remainingPadding = &w.trafficState.Outbound.RemainingPadding + currentCommand = &w.trafficState.Outbound.CurrentCommand + switchToDirectCopy = &w.trafficState.Outbound.DownlinkReaderDirectCopy + } + + if *withinPaddingBuffers || w.trafficState.NumberOfPacketToFilter > 0 { mb2 := make(buf.MultiBuffer, 0, len(buffer)) for _, b := range buffer { - newbuffer := XtlsUnpadding(b, w.trafficState, w.ctx) + newbuffer := XtlsUnpadding(b, w.trafficState, w.isUplink, w.ctx) if newbuffer.Len() > 0 { mb2 = append(mb2, newbuffer) } } buffer = mb2 - if w.trafficState.RemainingContent > 0 || w.trafficState.RemainingPadding > 0 || w.trafficState.CurrentCommand == 0 { - w.trafficState.WithinPaddingBuffers = true - } else if w.trafficState.CurrentCommand == 1 { - w.trafficState.WithinPaddingBuffers = false - } else if w.trafficState.CurrentCommand == 2 { - w.trafficState.WithinPaddingBuffers = false - if w.isUplink { - w.trafficState.UplinkReaderDirectCopy = true - } else { - w.trafficState.DownlinkReaderDirectCopy = true - } + if *remainingContent > 0 || *remainingPadding > 0 || *currentCommand == 0 { + *withinPaddingBuffers = true + } else if *currentCommand == 1 { + *withinPaddingBuffers = false + } else if *currentCommand == 2 { + *withinPaddingBuffers = false + *switchToDirectCopy = true } else { - errors.LogInfo(w.ctx, "XtlsRead unknown command ", w.trafficState.CurrentCommand, buffer.Len()) + errors.LogInfo(w.ctx, "XtlsRead unknown command ", *currentCommand, buffer.Len()) } } if w.trafficState.NumberOfPacketToFilter > 0 { @@ -223,7 +262,16 @@ func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { if w.trafficState.NumberOfPacketToFilter > 0 { XtlsFilterTls(mb, w.trafficState, w.ctx) } - if w.trafficState.IsPadding { + var isPadding *bool + var switchToDirectCopy *bool + if w.isUplink { + isPadding = &w.trafficState.Outbound.IsPadding + switchToDirectCopy = &w.trafficState.Outbound.UplinkWriterDirectCopy + } else { + isPadding = &w.trafficState.Inbound.IsPadding + switchToDirectCopy = &w.trafficState.Inbound.DownlinkWriterDirectCopy + } + if *isPadding { if len(mb) == 1 && mb[0] == nil { mb[0] = XtlsPadding(nil, CommandPaddingContinue, &w.writeOnceUserUUID, true, w.ctx) // we do a long padding to hide vless header return w.Writer.WriteMultiBuffer(mb) @@ -233,11 +281,7 @@ func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { for i, b := range mb { if w.trafficState.IsTLS && b.Len() >= 6 && bytes.Equal(TlsApplicationDataStart, b.BytesTo(3)) { if w.trafficState.EnableXtls { - if w.isUplink { - w.trafficState.UplinkWriterDirectCopy = true - } else { - w.trafficState.DownlinkWriterDirectCopy = true - } + *switchToDirectCopy = true } var command byte = CommandPaddingContinue if i == len(mb)-1 { @@ -247,16 +291,16 @@ func (w *VisionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { } } mb[i] = XtlsPadding(b, command, &w.writeOnceUserUUID, true, w.ctx) - w.trafficState.IsPadding = false // padding going to end + *isPadding = false // padding going to end longPadding = false continue } else if !w.trafficState.IsTLS12orAbove && w.trafficState.NumberOfPacketToFilter <= 1 { // For compatibility with earlier vision receiver, we finish padding 1 packet early - w.trafficState.IsPadding = false + *isPadding = false mb[i] = XtlsPadding(b, CommandPaddingEnd, &w.writeOnceUserUUID, longPadding, w.ctx) break } var command byte = CommandPaddingContinue - if i == len(mb)-1 && !w.trafficState.IsPadding { + if i == len(mb)-1 && !*isPadding { command = CommandPaddingEnd if w.trafficState.EnableXtls { command = CommandPaddingDirect @@ -343,38 +387,53 @@ func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool } // XtlsUnpadding remove padding and parse command -func XtlsUnpadding(b *buf.Buffer, s *TrafficState, ctx context.Context) *buf.Buffer { - if s.RemainingCommand == -1 && s.RemainingContent == -1 && s.RemainingPadding == -1 { // initial state +func XtlsUnpadding(b *buf.Buffer, s *TrafficState, isUplink bool, ctx context.Context) *buf.Buffer { + var remainingCommand *int32 + var remainingContent *int32 + var remainingPadding *int32 + var currentCommand *int + if isUplink { + remainingCommand = &s.Inbound.RemainingCommand + remainingContent = &s.Inbound.RemainingContent + remainingPadding = &s.Inbound.RemainingPadding + currentCommand = &s.Inbound.CurrentCommand + } else { + remainingCommand = &s.Outbound.RemainingCommand + remainingContent = &s.Outbound.RemainingContent + remainingPadding = &s.Outbound.RemainingPadding + currentCommand = &s.Outbound.CurrentCommand + } + if *remainingCommand == -1 && *remainingContent == -1 && *remainingPadding == -1 { // initial state if b.Len() >= 21 && bytes.Equal(s.UserUUID, b.BytesTo(16)) { b.Advance(16) - s.RemainingCommand = 5 + *remainingCommand = 5 } else { return b } } newbuffer := buf.New() for b.Len() > 0 { - if s.RemainingCommand > 0 { + if *remainingCommand > 0 { data, err := b.ReadByte() if err != nil { return newbuffer } - switch s.RemainingCommand { + switch *remainingCommand { case 5: - s.CurrentCommand = int(data) + *currentCommand = int(data) case 4: - s.RemainingContent = int32(data) << 8 + *remainingContent = int32(data) << 8 case 3: - s.RemainingContent = s.RemainingContent | int32(data) + *remainingContent = *remainingContent | int32(data) case 2: - s.RemainingPadding = int32(data) << 8 + *remainingPadding = int32(data) << 8 case 1: - s.RemainingPadding = s.RemainingPadding | int32(data) - errors.LogInfo(ctx, "Xtls Unpadding new block, content ", s.RemainingContent, " padding ", s.RemainingPadding, " command ", s.CurrentCommand) + *remainingPadding = *remainingPadding | int32(data) + errors.LogInfo(ctx, "Xtls Unpadding new block, content ", *remainingContent, " padding ", *remainingPadding, " command ", *currentCommand) } - s.RemainingCommand-- - } else if s.RemainingContent > 0 { - len := s.RemainingContent + *remainingCommand-- + } else if *remainingContent > 0 { + len := *remainingContent if b.Len() < len { len = b.Len() } @@ -383,22 +442,22 @@ func XtlsUnpadding(b *buf.Buffer, s *TrafficState, ctx context.Context) *buf.Buf return newbuffer } newbuffer.Write(data) - s.RemainingContent -= len + *remainingContent -= len } else { // remainingPadding > 0 - len := s.RemainingPadding + len := *remainingPadding if b.Len() < len { len = b.Len() } b.Advance(len) - s.RemainingPadding -= len + *remainingPadding -= len } - if s.RemainingCommand <= 0 && s.RemainingContent <= 0 && s.RemainingPadding <= 0 { // this block done - if s.CurrentCommand == 0 { - s.RemainingCommand = 5 + if *remainingCommand <= 0 && *remainingContent <= 0 && *remainingPadding <= 0 { // this block done + if *currentCommand == 0 { + *remainingCommand = 5 } else { - s.RemainingCommand = -1 // set to initial state - s.RemainingContent = -1 - s.RemainingPadding = -1 + *remainingCommand = -1 // set to initial state + *remainingContent = -1 + *remainingPadding = -1 if b.Len() > 0 { // shouldn't happen newbuffer.Write(b.Bytes()) } diff --git a/proxy/socks/client.go b/proxy/socks/client.go index 2ed5740a..232215ec 100644 --- a/proxy/socks/client.go +++ b/proxy/socks/client.go @@ -146,6 +146,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter return buf.Copy(link.Reader, buf.NewWriter(conn), buf.UpdateActivity(timer)) } responseFunc = func() error { + ob.CanSpliceCopy = 1 defer timer.SetTimeout(p.Timeouts.UplinkOnly) return buf.Copy(buf.NewReader(conn), link.Writer, buf.UpdateActivity(timer)) } @@ -161,6 +162,7 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter return buf.Copy(link.Reader, writer, buf.UpdateActivity(timer)) } responseFunc = func() error { + ob.CanSpliceCopy = 1 defer timer.SetTimeout(p.Timeouts.UplinkOnly) reader := &UDPReader{Reader: udpConn} return buf.Copy(reader, link.Writer, buf.UpdateActivity(timer)) diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 472b23a0..dd6f3953 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -199,6 +199,7 @@ func (s *Server) transport(ctx context.Context, reader io.Reader, writer io.Writ } responseDone := func() error { + inbound.CanSpliceCopy = 1 defer timer.SetTimeout(plcy.Timeouts.UplinkOnly) v2writer := buf.NewWriter(writer) @@ -256,6 +257,7 @@ func (s *Server) handleUDPPayload(ctx context.Context, conn stat.Connection, dis if inbound != nil && inbound.Source.IsValid() { errors.LogInfo(ctx, "client UDP connection from ", inbound.Source) } + inbound.CanSpliceCopy = 1 var dest *net.Destination diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index 3fce3290..38043e68 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -175,16 +175,16 @@ func DecodeResponseHeader(reader io.Reader, request *protocol.RequestHeader) (*A func XtlsRead(reader buf.Reader, writer buf.Writer, timer *signal.ActivityTimer, conn net.Conn, input *bytes.Reader, rawInput *bytes.Buffer, trafficState *proxy.TrafficState, ob *session.Outbound, isUplink bool, ctx context.Context) error { err := func() error { for { - if isUplink && trafficState.UplinkReaderDirectCopy || !isUplink && trafficState.DownlinkReaderDirectCopy { + if isUplink && trafficState.Inbound.UplinkReaderDirectCopy || !isUplink && trafficState.Outbound.DownlinkReaderDirectCopy { var writerConn net.Conn var inTimer *signal.ActivityTimer if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Conn != nil { writerConn = inbound.Conn inTimer = inbound.Timer - if inbound.CanSpliceCopy == 2 { + if isUplink && inbound.CanSpliceCopy == 2 { inbound.CanSpliceCopy = 1 } - if ob != nil && ob.CanSpliceCopy == 2 { // ob need to be passed in due to context can change + if !isUplink && ob != nil && ob.CanSpliceCopy == 2 { // ob need to be passed in due to context can change ob.CanSpliceCopy = 1 } } @@ -193,7 +193,7 @@ func XtlsRead(reader buf.Reader, writer buf.Writer, timer *signal.ActivityTimer, buffer, err := reader.ReadMultiBuffer() if !buffer.IsEmpty() { timer.Update() - if isUplink && trafficState.UplinkReaderDirectCopy || !isUplink && trafficState.DownlinkReaderDirectCopy { + if isUplink && trafficState.Inbound.UplinkReaderDirectCopy || !isUplink && trafficState.Outbound.DownlinkReaderDirectCopy { // XTLS Vision processes struct TLS Conn's input and rawInput if inputBuffer, err := buf.ReadFrom(input); err == nil { if !inputBuffer.IsEmpty() { @@ -227,12 +227,12 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate var ct stats.Counter for { buffer, err := reader.ReadMultiBuffer() - if isUplink && trafficState.UplinkWriterDirectCopy || !isUplink && trafficState.DownlinkWriterDirectCopy { + if isUplink && trafficState.Outbound.UplinkWriterDirectCopy || !isUplink && trafficState.Inbound.DownlinkWriterDirectCopy { if inbound := session.InboundFromContext(ctx); inbound != nil { - if inbound.CanSpliceCopy == 2 { + if !isUplink && inbound.CanSpliceCopy == 2 { inbound.CanSpliceCopy = 1 } - if ob != nil && ob.CanSpliceCopy == 2 { + if isUplink && ob != nil && ob.CanSpliceCopy == 2 { ob.CanSpliceCopy = 1 } } @@ -240,9 +240,9 @@ func XtlsWrite(reader buf.Reader, writer buf.Writer, timer signal.ActivityUpdate writer = buf.NewWriter(rawConn) ct = writerCounter if isUplink { - trafficState.UplinkWriterDirectCopy = false + trafficState.Outbound.UplinkWriterDirectCopy = false } else { - trafficState.DownlinkWriterDirectCopy = false + trafficState.Inbound.DownlinkWriterDirectCopy = false } } if !buffer.IsEmpty() { From 8cb63db6c0c83f73333d033f8a30bf8730955e65 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 18 Feb 2025 10:50:50 +0000 Subject: [PATCH 731/867] XHTTP server: Set remoteAddr & localAddr correctly Completes https://github.com/XTLS/Xray-core/commit/22c50a70c61f18b54f9e9de82962a053261a398c --- common/net/system.go | 3 +- proxy/proxy.go | 35 +++++---- transport/internet/splithttp/hub.go | 78 ++++++++++--------- .../internet/splithttp/splithttp_test.go | 26 +++---- transport/internet/system_listener.go | 6 +- 5 files changed, 77 insertions(+), 71 deletions(-) diff --git a/common/net/system.go b/common/net/system.go index e5bded04..7e1c4b01 100644 --- a/common/net/system.go +++ b/common/net/system.go @@ -76,8 +76,9 @@ type ( ) var ( - ResolveUnixAddr = net.ResolveUnixAddr + ResolveTCPAddr = net.ResolveTCPAddr ResolveUDPAddr = net.ResolveUDPAddr + ResolveUnixAddr = net.ResolveUnixAddr ) type Resolver = net.Resolver diff --git a/proxy/proxy.go b/proxy/proxy.go index a90aa340..57649795 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -113,12 +113,12 @@ type TrafficState struct { type InboundState struct { // reader link state - WithinPaddingBuffers bool - UplinkReaderDirectCopy bool - RemainingCommand int32 - RemainingContent int32 - RemainingPadding int32 - CurrentCommand int + WithinPaddingBuffers bool + UplinkReaderDirectCopy bool + RemainingCommand int32 + RemainingContent int32 + RemainingPadding int32 + CurrentCommand int // write link state IsPadding bool DownlinkWriterDirectCopy bool @@ -133,19 +133,19 @@ type OutboundState struct { RemainingPadding int32 CurrentCommand int // write link state - IsPadding bool - UplinkWriterDirectCopy bool + IsPadding bool + UplinkWriterDirectCopy bool } func NewTrafficState(userUUID []byte) *TrafficState { return &TrafficState{ - UserUUID: userUUID, - NumberOfPacketToFilter: 8, - EnableXtls: false, - IsTLS12orAbove: false, - IsTLS: false, - Cipher: 0, - RemainingServerHello: -1, + UserUUID: userUUID, + NumberOfPacketToFilter: 8, + EnableXtls: false, + IsTLS12orAbove: false, + IsTLS: false, + Cipher: 0, + RemainingServerHello: -1, Inbound: InboundState{ WithinPaddingBuffers: true, UplinkReaderDirectCopy: false, @@ -524,7 +524,7 @@ func XtlsFilterTls(buffer buf.MultiBuffer, trafficState *TrafficState, ctx conte } } -// UnwrapRawConn support unwrap stats, tls, utls, reality and proxyproto conn and get raw tcp conn from it +// UnwrapRawConn support unwrap stats, tls, utls, reality, proxyproto, uds-wrapper conn and get raw tcp/uds conn from it func UnwrapRawConn(conn net.Conn) (net.Conn, stats.Counter, stats.Counter) { var readCounter, writerCounter stats.Counter if conn != nil { @@ -547,6 +547,9 @@ func UnwrapRawConn(conn net.Conn) (net.Conn, stats.Counter, stats.Counter) { conn = pc.Raw() // 8192 > 4096, there is no need to process pc's bufReader } + if uc, ok := conn.(*internet.UDSWrapperConn); ok { + conn = uc.Conn + } } return conn, readCounter, writerCounter } diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 1c5ace05..e205ce8d 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -3,9 +3,8 @@ package splithttp import ( "bytes" "context" - "crypto/tls" + gotls "crypto/tls" "io" - gonet "net" "net/http" "net/url" "strconv" @@ -24,7 +23,7 @@ import ( "github.com/xtls/xray-core/transport/internet" "github.com/xtls/xray-core/transport/internet/reality" "github.com/xtls/xray-core/transport/internet/stat" - v2tls "github.com/xtls/xray-core/transport/internet/tls" + "github.com/xtls/xray-core/transport/internet/tls" "golang.org/x/net/http2" "golang.org/x/net/http2/h2c" ) @@ -36,7 +35,7 @@ type requestHandler struct { ln *Listener sessionMu *sync.Mutex sessions sync.Map - localAddr gonet.TCPAddr + localAddr net.Addr } type httpSession struct { @@ -144,14 +143,25 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } forwardedAddrs := http_proto.ParseXForwardedFor(request.Header) - remoteAddr, err := gonet.ResolveTCPAddr("tcp", request.RemoteAddr) + var remoteAddr net.Addr + var err error + remoteAddr, err = net.ResolveTCPAddr("tcp", request.RemoteAddr) if err != nil { - remoteAddr = &gonet.TCPAddr{} + remoteAddr = &net.TCPAddr{ + IP: []byte{0, 0, 0, 0}, + Port: 0, + } + } + if request.ProtoMajor == 3 { + remoteAddr = &net.UDPAddr{ + IP: remoteAddr.(*net.TCPAddr).IP, + Port: remoteAddr.(*net.TCPAddr).Port, + } } if len(forwardedAddrs) > 0 && forwardedAddrs[0].Family().IsIP() { remoteAddr = &net.TCPAddr{ IP: forwardedAddrs[0].IP(), - Port: int(0), + Port: 0, } } @@ -289,6 +299,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req responseFlusher: responseFlusher, }, reader: request.Body, + localAddr: h.localAddr, remoteAddr: remoteAddr, } if sessionId != "" { // if not stream-one @@ -362,34 +373,30 @@ type Listener struct { isH3 bool } -func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (internet.Listener, error) { +func ListenXH(ctx context.Context, address net.Address, port net.Port, streamSettings *internet.MemoryStreamConfig, addConn internet.ConnHandler) (internet.Listener, error) { l := &Listener{ addConn: addConn, } - shSettings := streamSettings.ProtocolSettings.(*Config) - l.config = shSettings + l.config = streamSettings.ProtocolSettings.(*Config) if l.config != nil { if streamSettings.SocketSettings == nil { streamSettings.SocketSettings = &internet.SocketConfig{} } } - var listener net.Listener - var err error - var localAddr = gonet.TCPAddr{} handler := &requestHandler{ - config: shSettings, - host: shSettings.Host, - path: shSettings.GetNormalizedPath(), + config: l.config, + host: l.config.Host, + path: l.config.GetNormalizedPath(), ln: l, sessionMu: &sync.Mutex{}, sessions: sync.Map{}, - localAddr: localAddr, } tlsConfig := getTLSConfig(streamSettings) l.isH3 = len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "h3" + var err error if port == net.Port(0) { // unix - listener, err = internet.ListenSystem(ctx, &net.UnixAddr{ + l.listener, err = internet.ListenSystem(ctx, &net.UnixAddr{ Name: address.Domain(), Net: "unix", }, streamSettings.SocketSettings) @@ -405,13 +412,14 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet if err != nil { return nil, errors.New("failed to listen UDP for XHTTP/3 on ", address, ":", port).Base(err) } - h3listener, err := quic.ListenEarly(Conn, tlsConfig, nil) + l.h3listener, err = quic.ListenEarly(Conn, tlsConfig, nil) if err != nil { return nil, errors.New("failed to listen QUIC for XHTTP/3 on ", address, ":", port).Base(err) } - l.h3listener = h3listener errors.LogInfo(ctx, "listening QUIC for XHTTP/3 on ", address, ":", port) + handler.localAddr = l.h3listener.Addr() + l.h3server = &http3.Server{ Handler: handler, } @@ -421,11 +429,7 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet } }() } else { // tcp - localAddr = gonet.TCPAddr{ - IP: address.IP(), - Port: int(port), - } - listener, err = internet.ListenSystem(ctx, &net.TCPAddr{ + l.listener, err = internet.ListenSystem(ctx, &net.TCPAddr{ IP: address.IP(), Port: int(port), }, streamSettings.SocketSettings) @@ -436,26 +440,24 @@ func ListenSH(ctx context.Context, address net.Address, port net.Port, streamSet } // tcp/unix (h1/h2) - if listener != nil { - if config := v2tls.ConfigFromStreamSettings(streamSettings); config != nil { + if l.listener != nil { + if config := tls.ConfigFromStreamSettings(streamSettings); config != nil { if tlsConfig := config.GetTLSConfig(); tlsConfig != nil { - listener = tls.NewListener(listener, tlsConfig) + l.listener = gotls.NewListener(l.listener, tlsConfig) } } - if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { - listener = goreality.NewListener(listener, config.GetREALITYConfig()) + l.listener = goreality.NewListener(l.listener, config.GetREALITYConfig()) } + handler.localAddr = l.listener.Addr() + // h2cHandler can handle both plaintext HTTP/1.1 and h2c - h2cHandler := h2c.NewHandler(handler, &http2.Server{}) - l.listener = listener l.server = http.Server{ - Handler: h2cHandler, + Handler: h2c.NewHandler(handler, &http2.Server{}), ReadHeaderTimeout: time.Second * 4, MaxHeaderBytes: 8192, } - go func() { if err := l.server.Serve(l.listener); err != nil { errors.LogWarningInner(ctx, err, "failed to serve HTTP for XHTTP") @@ -488,13 +490,13 @@ func (ln *Listener) Close() error { } return errors.New("listener does not have an HTTP/3 server or a net.listener") } -func getTLSConfig(streamSettings *internet.MemoryStreamConfig) *tls.Config { - config := v2tls.ConfigFromStreamSettings(streamSettings) +func getTLSConfig(streamSettings *internet.MemoryStreamConfig) *gotls.Config { + config := tls.ConfigFromStreamSettings(streamSettings) if config == nil { - return &tls.Config{} + return &gotls.Config{} } return config.GetTLSConfig() } func init() { - common.Must(internet.RegisterTransportListener(protocolName, ListenSH)) + common.Must(internet.RegisterTransportListener(protocolName, ListenXH)) } diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index 20043b4a..f566ecc4 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -26,9 +26,9 @@ import ( "golang.org/x/net/http2" ) -func Test_listenSHAndDial(t *testing.T) { +func Test_ListenXHAndDial(t *testing.T) { listenPort := tcp.PickPort() - listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, &internet.MemoryStreamConfig{ + listen, err := ListenXH(context.Background(), net.LocalHostIP, listenPort, &internet.MemoryStreamConfig{ ProtocolName: "splithttp", ProtocolSettings: &Config{ Path: "/sh", @@ -85,7 +85,7 @@ func Test_listenSHAndDial(t *testing.T) { func TestDialWithRemoteAddr(t *testing.T) { listenPort := tcp.PickPort() - listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, &internet.MemoryStreamConfig{ + listen, err := ListenXH(context.Background(), net.LocalHostIP, listenPort, &internet.MemoryStreamConfig{ ProtocolName: "splithttp", ProtocolSettings: &Config{ Path: "sh", @@ -125,7 +125,7 @@ func TestDialWithRemoteAddr(t *testing.T) { common.Must(listen.Close()) } -func Test_listenSHAndDial_TLS(t *testing.T) { +func Test_ListenXHAndDial_TLS(t *testing.T) { if runtime.GOARCH == "arm64" { return } @@ -145,7 +145,7 @@ func Test_listenSHAndDial_TLS(t *testing.T) { Certificate: []*tls.Certificate{tls.ParseCertificate(cert.MustGenerate(nil, cert.CommonName("localhost")))}, }, } - listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { + listen, err := ListenXH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { go func() { defer conn.Close() @@ -180,7 +180,7 @@ func Test_listenSHAndDial_TLS(t *testing.T) { } } -func Test_listenSHAndDial_H2C(t *testing.T) { +func Test_ListenXHAndDial_H2C(t *testing.T) { if runtime.GOARCH == "arm64" { return } @@ -193,7 +193,7 @@ func Test_listenSHAndDial_H2C(t *testing.T) { Path: "shs", }, } - listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { + listen, err := ListenXH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { go func() { _ = conn.Close() }() @@ -227,7 +227,7 @@ func Test_listenSHAndDial_H2C(t *testing.T) { } } -func Test_listenSHAndDial_QUIC(t *testing.T) { +func Test_ListenXHAndDial_QUIC(t *testing.T) { if runtime.GOARCH == "arm64" { return } @@ -250,7 +250,7 @@ func Test_listenSHAndDial_QUIC(t *testing.T) { } serverClosed := false - listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { + listen, err := ListenXH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { go func() { defer conn.Close() @@ -309,11 +309,11 @@ func Test_listenSHAndDial_QUIC(t *testing.T) { } } -func Test_listenSHAndDial_Unix(t *testing.T) { +func Test_ListenXHAndDial_Unix(t *testing.T) { tempDir := t.TempDir() tempSocket := tempDir + "/server.sock" - listen, err := ListenSH(context.Background(), net.DomainAddress(tempSocket), 0, &internet.MemoryStreamConfig{ + listen, err := ListenXH(context.Background(), net.DomainAddress(tempSocket), 0, &internet.MemoryStreamConfig{ ProtocolName: "splithttp", ProtocolSettings: &Config{ Path: "/sh", @@ -373,7 +373,7 @@ func Test_listenSHAndDial_Unix(t *testing.T) { func Test_queryString(t *testing.T) { listenPort := tcp.PickPort() - listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, &internet.MemoryStreamConfig{ + listen, err := ListenXH(context.Background(), net.LocalHostIP, listenPort, &internet.MemoryStreamConfig{ ProtocolName: "splithttp", ProtocolSettings: &Config{ // this querystring does not have any effect, but sometimes people blindly copy it from websocket config. make sure the outbound doesn't break @@ -431,7 +431,7 @@ func Test_maxUpload(t *testing.T) { } var uploadSize int - listen, err := ListenSH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { + listen, err := ListenXH(context.Background(), net.LocalHostIP, listenPort, streamSettings, func(conn stat.Connection) { go func(c stat.Connection) { defer c.Close() var b [10240]byte diff --git a/transport/internet/system_listener.go b/transport/internet/system_listener.go index cdabd3bf..1086aef5 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -54,7 +54,7 @@ func (l *listenUDSWrapper) Accept() (net.Conn, error) { if err != nil { return nil, err } - return &listenUDSWrapperConn{Conn: conn}, nil + return &UDSWrapperConn{Conn: conn}, nil } func (l *listenUDSWrapper) Close() error { @@ -65,11 +65,11 @@ func (l *listenUDSWrapper) Close() error { return l.Listener.Close() } -type listenUDSWrapperConn struct { +type UDSWrapperConn struct { net.Conn } -func (conn *listenUDSWrapperConn) RemoteAddr() net.Addr { +func (conn *UDSWrapperConn) RemoteAddr() net.Addr { return &net.TCPAddr{ IP: []byte{0, 0, 0, 0}, } From c5de08bea62cab07c79edac307bfadf27e71bff2 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:11:36 +0000 Subject: [PATCH 732/867] XHTTP client: Revert "Add back minimal path padding for compatibility" Reverts https://github.com/XTLS/Xray-core/commit/efdc70fbf782433689dcb114e37426395100614d --- transport/internet/splithttp/config.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index f1ccc493..f160db31 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -34,13 +34,12 @@ func (c *Config) GetNormalizedQuery() string { query = pathAndQuery[1] } - if query != "" { - query += "&" - } - - // query += "x_version=" + core.Version() - - query += "x_padding=" + strings.Repeat("X", int(c.GetNormalizedXPaddingBytes().From)) + /* + if query != "" { + query += "&" + } + query += "x_version=" + core.Version() + */ return query } From 4b01eb439829c9adc090f18467376680f2db7f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Tue, 18 Feb 2025 19:32:48 +0800 Subject: [PATCH 733/867] Metrics: Add direct listen (#4409) --- app/metrics/config.pb.go | 27 ++++++++++++++++++--------- app/metrics/config.proto | 1 + app/metrics/metrics.go | 22 +++++++++++++++++++++- infra/conf/metrics.go | 12 +++++++++--- 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/app/metrics/config.pb.go b/app/metrics/config.pb.go index d62dcef9..b0874b3b 100644 --- a/app/metrics/config.pb.go +++ b/app/metrics/config.pb.go @@ -27,7 +27,8 @@ type Config struct { unknownFields protoimpl.UnknownFields // Tag of the outbound handler that handles metrics http connections. - Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` + Tag string `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"` + Listen string `protobuf:"bytes,2,opt,name=listen,proto3" json:"listen,omitempty"` } func (x *Config) Reset() { @@ -67,20 +68,28 @@ func (x *Config) GetTag() string { return "" } +func (x *Config) GetListen() string { + if x != nil { + return x.Listen + } + return "" +} + var File_app_metrics_config_proto protoreflect.FileDescriptor var file_app_metrics_config_proto_rawDesc = []byte{ 0x0a, 0x18, 0x61, 0x70, 0x70, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x22, 0x1a, 0x0a, 0x06, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x22, 0x32, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x42, 0x52, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, - 0x50, 0x01, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, - 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, - 0x70, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0xaa, 0x02, 0x10, 0x58, 0x72, 0x61, 0x79, - 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6c, 0x69, 0x73, 0x74, + 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6c, 0x69, 0x73, 0x74, 0x65, 0x6e, + 0x42, 0x52, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x50, 0x01, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, + 0x73, 0xaa, 0x02, 0x10, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x4d, 0x65, 0x74, + 0x72, 0x69, 0x63, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/app/metrics/config.proto b/app/metrics/config.proto index 5e6880f1..0441df03 100644 --- a/app/metrics/config.proto +++ b/app/metrics/config.proto @@ -10,4 +10,5 @@ option java_multiple_files = true; message Config { // Tag of the outbound handler that handles metrics http connections. string tag = 1; + string listen = 2; } diff --git a/app/metrics/metrics.go b/app/metrics/metrics.go index 757d673d..1dc5b2f5 100644 --- a/app/metrics/metrics.go +++ b/app/metrics/metrics.go @@ -24,12 +24,15 @@ type MetricsHandler struct { statsManager feature_stats.Manager observatory extension.Observatory tag string + listen string + tcpListener net.Listener } // NewMetricsHandler creates a new MetricsHandler based on the given config. func NewMetricsHandler(ctx context.Context, config *Config) (*MetricsHandler, error) { c := &MetricsHandler{ - tag: config.Tag, + tag: config.Tag, + listen: config.Listen, } common.Must(core.RequireFeatures(ctx, func(om outbound.Manager, sm feature_stats.Manager) { c.statsManager = sm @@ -87,6 +90,23 @@ func (p *MetricsHandler) Type() interface{} { } func (p *MetricsHandler) Start() error { + + // direct listen a port if listen is set + if p.listen != "" { + TCPlistener, err := net.Listen("tcp", p.listen) + if err != nil { + return err + } + p.tcpListener = TCPlistener + errors.LogInfo(context.Background(), "Metrics server listening on ", p.listen) + + go func() { + if err := http.Serve(TCPlistener, http.DefaultServeMux); err != nil { + errors.LogErrorInner(context.Background(), err, "failed to start metrics server") + } + }() + } + listener := &OutboundListener{ buffer: make(chan net.Conn, 4), done: done.New(), diff --git a/infra/conf/metrics.go b/infra/conf/metrics.go index 3f550e88..75965206 100644 --- a/infra/conf/metrics.go +++ b/infra/conf/metrics.go @@ -6,15 +6,21 @@ import ( ) type MetricsConfig struct { - Tag string `json:"tag"` + Tag string `json:"tag"` + Listen string `json:"listen"` } func (c *MetricsConfig) Build() (*metrics.Config, error) { + if c.Listen == "" && c.Tag == "" { + return nil, errors.New("Metrics must have a tag or listen address.") + } + // If the tag is empty but have "listen" set a default "Metrics" for compatibility. if c.Tag == "" { - return nil, errors.New("metrics tag can't be empty.") + c.Tag = "Metrics" } return &metrics.Config{ - Tag: c.Tag, + Tag: c.Tag, + Listen: c.Listen, }, nil } From 52381a3c038b374469fceb9dbaf12d3d09c91b04 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 18 Feb 2025 11:55:07 +0000 Subject: [PATCH 734/867] v25.2.18 Announcement of NFTs by Project X: https://github.com/XTLS/Xray-core/discussions/3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- app/observatory/burst/healthping.go | 6 +++--- app/observatory/observer.go | 8 ++++---- core/core.go | 4 ++-- core/xray.go | 2 +- transport/internet/splithttp/hub.go | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/observatory/burst/healthping.go b/app/observatory/burst/healthping.go index f0842602..0d8cab9f 100644 --- a/app/observatory/burst/healthping.go +++ b/app/observatory/burst/healthping.go @@ -66,10 +66,10 @@ func NewHealthPing(ctx context.Context, dispatcher routing.Dispatcher, config *H settings.Timeout = time.Duration(5) * time.Second } return &HealthPing{ - ctx: ctx, + ctx: ctx, dispatcher: dispatcher, - Settings: settings, - Results: nil, + Settings: settings, + Results: nil, } } diff --git a/app/observatory/observer.go b/app/observatory/observer.go index 657396f6..a6fba3ad 100644 --- a/app/observatory/observer.go +++ b/app/observatory/observer.go @@ -32,7 +32,7 @@ type Observer struct { finished *done.Instance - ohm outbound.Manager + ohm outbound.Manager dispatcher routing.Dispatcher } @@ -226,9 +226,9 @@ func New(ctx context.Context, config *Config) (*Observer, error) { return nil, errors.New("Cannot get depended features").Base(err) } return &Observer{ - config: config, - ctx: ctx, - ohm: outboundManager, + config: config, + ctx: ctx, + ohm: outboundManager, dispatcher: dispatcher, }, nil } diff --git a/core/core.go b/core/core.go index 5a52683e..5db6fd45 100644 --- a/core/core.go +++ b/core/core.go @@ -18,8 +18,8 @@ import ( var ( Version_x byte = 25 - Version_y byte = 1 - Version_z byte = 30 + Version_y byte = 2 + Version_z byte = 18 ) var ( diff --git a/core/xray.go b/core/xray.go index f6ccc27d..0cc56daa 100644 --- a/core/xray.go +++ b/core/xray.go @@ -359,7 +359,7 @@ func (s *Instance) AddFeature(feature features.Feature) error { } s.pendingOptionalResolutions = pendingOptional s.resolveLock.Unlock() - + var err error for _, r := range availableResolution { err = r.callbackResolution(s.features) // only return the last error for now diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index e205ce8d..86a750f7 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -425,7 +425,7 @@ func ListenXH(ctx context.Context, address net.Address, port net.Port, streamSet } go func() { if err := l.h3server.ServeListener(l.h3listener); err != nil { - errors.LogWarningInner(ctx, err, "failed to serve HTTP/3 for XHTTP/3") + errors.LogErrorInner(ctx, err, "failed to serve HTTP/3 for XHTTP/3") } }() } else { // tcp @@ -460,7 +460,7 @@ func ListenXH(ctx context.Context, address net.Address, port net.Port, streamSet } go func() { if err := l.server.Serve(l.listener); err != nil { - errors.LogWarningInner(ctx, err, "failed to serve HTTP for XHTTP") + errors.LogErrorInner(ctx, err, "failed to serve HTTP for XHTTP") } }() } From b38a53e6299333e5999f661d7f73a51a2ab34b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Wed, 19 Feb 2025 19:31:29 +0800 Subject: [PATCH 735/867] UDS: Use UnixListenerWrapper & UnixConnWrapper (#4413) Fixes https://github.com/XTLS/Xray-core/issues/4411 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- proxy/proxy.go | 4 ++-- transport/internet/system_listener.go | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/proxy/proxy.go b/proxy/proxy.go index 57649795..3fec31af 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -547,8 +547,8 @@ func UnwrapRawConn(conn net.Conn) (net.Conn, stats.Counter, stats.Counter) { conn = pc.Raw() // 8192 > 4096, there is no need to process pc's bufReader } - if uc, ok := conn.(*internet.UDSWrapperConn); ok { - conn = uc.Conn + if uc, ok := conn.(*internet.UnixConnWrapper); ok { + conn = uc.UnixConn } } return conn, readCounter, writerCounter diff --git a/transport/internet/system_listener.go b/transport/internet/system_listener.go index 1086aef5..fa3092a1 100644 --- a/transport/internet/system_listener.go +++ b/transport/internet/system_listener.go @@ -44,32 +44,32 @@ func getControlFunc(ctx context.Context, sockopt *SocketConfig, controllers []co // For some reason, other component of ray will assume the listener is a TCP listener and have valid remote address. // But in fact it doesn't. So we need to wrap the listener to make it return 0.0.0.0(unspecified) as remote address. // If other issues encountered, we should able to fix it here. -type listenUDSWrapper struct { - net.Listener +type UnixListenerWrapper struct { + *net.UnixListener locker *FileLocker } -func (l *listenUDSWrapper) Accept() (net.Conn, error) { - conn, err := l.Listener.Accept() +func (l *UnixListenerWrapper) Accept() (net.Conn, error) { + conn, err := l.UnixListener.Accept() if err != nil { return nil, err } - return &UDSWrapperConn{Conn: conn}, nil + return &UnixConnWrapper{UnixConn: conn.(*net.UnixConn)}, nil } -func (l *listenUDSWrapper) Close() error { +func (l *UnixListenerWrapper) Close() error { if l.locker != nil { l.locker.Release() l.locker = nil } - return l.Listener.Close() + return l.UnixListener.Close() } -type UDSWrapperConn struct { - net.Conn +type UnixConnWrapper struct { + *net.UnixConn } -func (conn *UDSWrapperConn) RemoteAddr() net.Addr { +func (conn *UnixConnWrapper) RemoteAddr() net.Addr { return &net.TCPAddr{ IP: []byte{0, 0, 0, 0}, } @@ -136,7 +136,7 @@ func (dl *DefaultListener) Listen(ctx context.Context, addr net.Addr, sockopt *S locker.Release() return nil, err } - l = &listenUDSWrapper{Listener: l, locker: locker} + l = &UnixListenerWrapper{UnixListener: l.(*net.UnixListener), locker: locker} if filePerm == nil { return l, nil } From b786a50aee65359c8bbab6fc8ab39f33f4bf0d9a Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 20 Feb 2025 16:28:06 +0000 Subject: [PATCH 736/867] XHTTP server: Fix stream-up "single POST problem", Use united httpServerConn instead of recover() https://github.com/XTLS/Xray-core/issues/4373#issuecomment-2671795675 https://github.com/XTLS/Xray-core/issues/4406#issuecomment-2668041926 --- transport/internet/splithttp/hub.go | 114 +++++++------------ transport/internet/splithttp/upload_queue.go | 30 +++-- 2 files changed, 63 insertions(+), 81 deletions(-) diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 86a750f7..179d696a 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -47,21 +47,6 @@ type httpSession struct { isFullyConnected *done.Instance } -func (h *requestHandler) maybeReapSession(isFullyConnected *done.Instance, sessionId string) { - shouldReap := done.New() - go func() { - time.Sleep(30 * time.Second) - shouldReap.Close() - }() - - select { - case <-isFullyConnected.Wait(): - return - case <-shouldReap.Wait(): - h.sessions.Delete(sessionId) - } -} - func (h *requestHandler) upsertSession(sessionId string) *httpSession { // fast path currentSessionAny, ok := h.sessions.Load(sessionId) @@ -84,7 +69,21 @@ func (h *requestHandler) upsertSession(sessionId string) *httpSession { } h.sessions.Store(sessionId, s) - go h.maybeReapSession(s.isFullyConnected, sessionId) + + shouldReap := done.New() + go func() { + time.Sleep(30 * time.Second) + shouldReap.Close() + }() + go func() { + select { + case <-shouldReap.Wait(): + h.sessions.Delete(sessionId) + s.uploadQueue.Close() + case <-s.isFullyConnected.Wait(): + } + }() + return s } @@ -183,12 +182,13 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req writer.WriteHeader(http.StatusBadRequest) return } - uploadDone := done.New() + httpSC := &httpServerConn{ + Instance: done.New(), + Reader: request.Body, + ResponseWriter: writer, + } err = currentSession.uploadQueue.Push(Packet{ - Reader: &httpRequestBodyReader{ - requestReader: request.Body, - uploadDone: uploadDone, - }, + Reader: httpSC, }) if err != nil { errors.LogInfoInner(context.Background(), err, "failed to upload (PushReader)") @@ -200,25 +200,21 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req scStreamUpServerSecs := h.config.GetNormalizedScStreamUpServerSecs() if referrer != "" && scStreamUpServerSecs.To > 0 { go func() { - defer func() { - recover() - }() for { - _, err := writer.Write(bytes.Repeat([]byte{'X'}, int(h.config.GetNormalizedXPaddingBytes().rand()))) + _, err := httpSC.Write(bytes.Repeat([]byte{'X'}, int(h.config.GetNormalizedXPaddingBytes().rand()))) if err != nil { break } - writer.(http.Flusher).Flush() time.Sleep(time.Duration(scStreamUpServerSecs.rand()) * time.Second) } }() } select { case <-request.Context().Done(): - case <-uploadDone.Wait(): + case <-httpSC.Wait(): } } - uploadDone.Close() + httpSC.Close() return } @@ -262,11 +258,6 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req writer.WriteHeader(http.StatusOK) } else if request.Method == "GET" || sessionId == "" { // stream-down, stream-one - responseFlusher, ok := writer.(http.Flusher) - if !ok { - panic("expected http.ResponseWriter to be an http.Flusher") - } - if sessionId != "" { // after GET is done, the connection is finished. disable automatic // session reaping, and handle it in defer @@ -287,20 +278,18 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } writer.WriteHeader(http.StatusOK) + writer.(http.Flusher).Flush() - responseFlusher.Flush() - - downloadDone := done.New() - + httpSC := &httpServerConn{ + Instance: done.New(), + Reader: request.Body, + ResponseWriter: writer, + } conn := splitConn{ - writer: &httpResponseBodyWriter{ - responseWriter: writer, - downloadDone: downloadDone, - responseFlusher: responseFlusher, - }, - reader: request.Body, - localAddr: h.localAddr, + writer: httpSC, + reader: httpSC, remoteAddr: remoteAddr, + localAddr: h.localAddr, } if sessionId != "" { // if not stream-one conn.reader = currentSession.uploadQueue @@ -311,7 +300,7 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req // "A ResponseWriter may not be used after [Handler.ServeHTTP] has returned." select { case <-request.Context().Done(): - case <-downloadDone.Wait(): + case <-httpSC.Wait(): } conn.Close() @@ -321,45 +310,30 @@ func (h *requestHandler) ServeHTTP(writer http.ResponseWriter, request *http.Req } } -type httpRequestBodyReader struct { - requestReader io.ReadCloser - uploadDone *done.Instance -} - -func (c *httpRequestBodyReader) Read(b []byte) (int, error) { - return c.requestReader.Read(b) -} - -func (c *httpRequestBodyReader) Close() error { - defer c.uploadDone.Close() - return c.requestReader.Close() -} - -type httpResponseBodyWriter struct { +type httpServerConn struct { sync.Mutex - responseWriter http.ResponseWriter - responseFlusher http.Flusher - downloadDone *done.Instance + *done.Instance + io.Reader // no need to Close request.Body + http.ResponseWriter } -func (c *httpResponseBodyWriter) Write(b []byte) (int, error) { +func (c *httpServerConn) Write(b []byte) (int, error) { c.Lock() defer c.Unlock() - if c.downloadDone.Done() { + if c.Done() { return 0, io.ErrClosedPipe } - n, err := c.responseWriter.Write(b) + n, err := c.ResponseWriter.Write(b) if err == nil { - c.responseFlusher.Flush() + c.ResponseWriter.(http.Flusher).Flush() } return n, err } -func (c *httpResponseBodyWriter) Close() error { +func (c *httpServerConn) Close() error { c.Lock() defer c.Unlock() - c.downloadDone.Close() - return nil + return c.Instance.Close() } type Listener struct { diff --git a/transport/internet/splithttp/upload_queue.go b/transport/internet/splithttp/upload_queue.go index 382e381e..69b9a972 100644 --- a/transport/internet/splithttp/upload_queue.go +++ b/transport/internet/splithttp/upload_queue.go @@ -20,6 +20,7 @@ type Packet struct { type uploadQueue struct { reader io.ReadCloser + nomore bool pushedPackets chan Packet writeCloseMutex sync.Mutex heap uploadHeap @@ -42,19 +43,15 @@ func (h *uploadQueue) Push(p Packet) error { h.writeCloseMutex.Lock() defer h.writeCloseMutex.Unlock() - runtime.Gosched() - if h.reader != nil && p.Reader != nil { - p.Reader.Close() - return errors.New("h.reader already exists") - } - if h.closed { - if p.Reader != nil { - p.Reader.Close() - } return errors.New("packet queue closed") } - + if h.nomore { + return errors.New("h.reader already exists") + } + if p.Reader != nil { + h.nomore = true + } h.pushedPackets <- p return nil } @@ -65,9 +62,20 @@ func (h *uploadQueue) Close() error { if !h.closed { h.closed = true + runtime.Gosched() // hope Read() gets the packet + f: + for { + select { + case p := <-h.pushedPackets: + if p.Reader != nil { + h.reader = p.Reader + } + default: + break f + } + } close(h.pushedPackets) } - runtime.Gosched() if h.reader != nil { return h.reader.Close() } From 89792aee9d9bcad42b6fd70a703632902f6c25f4 Mon Sep 17 00:00:00 2001 From: lastrise <54949052+lastrise@users.noreply.github.com> Date: Fri, 21 Feb 2025 00:15:59 +0400 Subject: [PATCH 737/867] Outbound: Add outbound sendThrough origin behavior (#4349) * added support of sending through origin for outbounds * added strings package import * usage of net.SplitHostPort instead of manual splitting --------- Co-authored-by: poly --- app/proxyman/outbound/handler.go | 11 ++++++++++- infra/conf/xray.go | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index df7d52a4..3819f52b 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -273,7 +273,16 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connecti outbounds := session.OutboundsFromContext(ctx) ob := outbounds[len(outbounds)-1] if h.senderSettings.ViaCidr == "" { - ob.Gateway = h.senderSettings.Via.AsAddress() + if h.senderSettings.Via.AsAddress().Family().IsDomain() && h.senderSettings.Via.AsAddress().Domain() == "origin" { + if inbound := session.InboundFromContext(ctx); inbound != nil { + origin, _, err := net.SplitHostPort(inbound.Conn.LocalAddr().String()) + if err == nil { + ob.Gateway = net.ParseAddress(origin) + } + } + } else { + ob.Gateway = h.senderSettings.Via.AsAddress() + } } else { //Get a random address. ob.Gateway = ParseRandomIPv6(h.senderSettings.Via.AsAddress(), h.senderSettings.ViaCidr) } diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 4de55bad..a9cc88bc 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -292,7 +292,9 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) { senderSettings.ViaCidr = strings.Split(*c.SendThrough, "/")[1] } else { if address.Family().IsDomain() { - return nil, errors.New("unable to send through: " + address.String()) + if address.Address.Domain() != "origin" { + return nil, errors.New("unable to send through: " + address.String()) + } } } senderSettings.Via = address.Build() From 71a6d89c23d0b76b577029a12963954e28b2ce5a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 06:34:33 +0000 Subject: [PATCH 738/867] Bump github.com/quic-go/quic-go from 0.49.0 to 0.50.0 (#4420) Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.49.0 to 0.50.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.49.0...v0.50.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a09b0adf..488f2272 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/miekg/dns v1.1.63 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.0 - github.com/quic-go/quic-go v0.49.0 + github.com/quic-go/quic-go v0.50.0 github.com/refraction-networking/utls v1.6.7 github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 diff --git a/go.sum b/go.sum index ca63fb8d..43653c6a 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= -github.com/quic-go/quic-go v0.49.0 h1:w5iJHXwHxs1QxyBv1EHKuC50GX5to8mJAxvtnttJp94= -github.com/quic-go/quic-go v0.49.0/go.mod h1:s2wDnmCdooUQBmQfpUSTCYBl1/D4FcqbULMMkASvR6s= +github.com/quic-go/quic-go v0.50.0 h1:3H/ld1pa3CYhkcc20TPIyG1bNsdhn9qZBGN3b9/UyUo= +github.com/quic-go/quic-go v0.50.0/go.mod h1:Vim6OmUvlYdwBhXP9ZVrtGmCMWa3wEqhq3NgYrI8b4E= github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From be43f66b63d5fdc7322675127672cb5cbe14a125 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 21 Feb 2025 07:58:31 +0000 Subject: [PATCH 739/867] v25.2.21 Announcement of NFTs by Project X: https://github.com/XTLS/Xray-core/discussions/3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 5db6fd45..37e2e8b7 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 25 Version_y byte = 2 - Version_z byte = 18 + Version_z byte = 21 ) var ( From ce2384ccccb92a92fd1faf3eb7748459c09e53c6 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 25 Feb 2025 11:35:25 +0000 Subject: [PATCH 740/867] Use Go 1.24 --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 488f2272..635962a0 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/xtls/xray-core -go 1.23 +go 1.24 require ( github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 From d451078e72c134af15b0b789ac7f5b0fdf71e06e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Tue, 25 Feb 2025 21:11:37 +0800 Subject: [PATCH 741/867] Chore: Fix tests (#4440) --- infra/vprotogen/main.go | 3 +-- main/commands/all/convert/json.go | 6 +++--- main/commands/all/convert/protobuf.go | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/infra/vprotogen/main.go b/infra/vprotogen/main.go index f5a4152a..2c1e2298 100644 --- a/infra/vprotogen/main.go +++ b/infra/vprotogen/main.go @@ -89,12 +89,11 @@ func whichProtoc(suffix, targetedVersion string) (string, error) { path, err := exec.LookPath(protoc) if err != nil { - errStr := fmt.Sprintf(` + return "", fmt.Errorf(` Command "%s" not found. Make sure that %s is in your system path or current path. Download %s v%s or later from https://github.com/protocolbuffers/protobuf/releases `, protoc, protoc, protoc, targetedVersion) - return "", fmt.Errorf(errStr) } return path, nil } diff --git a/main/commands/all/convert/json.go b/main/commands/all/convert/json.go index d20634df..58066795 100644 --- a/main/commands/all/convert/json.go +++ b/main/commands/all/convert/json.go @@ -50,17 +50,17 @@ func executeTypedMessageToJson(cmd *base.Command, args []string) { reader, err := confloader.LoadConfig(cmd.Flag.Arg(0)) if err != nil { - base.Fatalf(err.Error()) + base.Fatalf("failed to load config: %s", err) } b, err := io.ReadAll(reader) if err != nil { - base.Fatalf(err.Error()) + base.Fatalf("failed to read config: %s", err) } tm := cserial.TypedMessage{} if err = json.Unmarshal(b, &tm); err != nil { - base.Fatalf(err.Error()) + base.Fatalf("failed to unmarshal config: %s", err) } if j, ok := creflect.MarshalToJson(&tm, injectTypeInfo); ok { diff --git a/main/commands/all/convert/protobuf.go b/main/commands/all/convert/protobuf.go index 17d6feae..c77df963 100644 --- a/main/commands/all/convert/protobuf.go +++ b/main/commands/all/convert/protobuf.go @@ -53,12 +53,12 @@ func executeConvertConfigsToProtobuf(cmd *base.Command, args []string) { } if len(unnamedArgs) < 1 { - base.Fatalf("empty config list") + base.Fatalf("invalid config list length: %d", len(unnamedArgs)) } pbConfig, err := core.LoadConfig("auto", unnamedArgs) if err != nil { - base.Fatalf(err.Error()) + base.Fatalf("failed to load config: %s", err) } if optDump { From 225d151cd30bd9a82952db58f9fc031845c90f87 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:26:00 +0000 Subject: [PATCH 742/867] Bump github.com/google/go-cmp from 0.6.0 to 0.7.0 (#4433) Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.6.0 to 0.7.0. - [Release notes](https://github.com/google/go-cmp/releases) - [Commits](https://github.com/google/go-cmp/compare/v0.6.0...v0.7.0) --- updated-dependencies: - dependency-name: github.com/google/go-cmp dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 635962a0..dc2e9e5d 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/cloudflare/circl v1.6.0 github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 github.com/golang/mock v1.7.0-rc.1 - github.com/google/go-cmp v0.6.0 + github.com/google/go-cmp v0.7.0 github.com/gorilla/websocket v1.5.3 github.com/miekg/dns v1.1.63 github.com/pelletier/go-toml v1.9.5 diff --git a/go.sum b/go.sum index 43653c6a..66f5284a 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/pprof v0.0.0-20240528025155-186aa0362fba h1:ql1qNgCyOB7iAEk8JTNM+zJrgIbnyCKX/wdlyPufP5g= github.com/google/pprof v0.0.0-20240528025155-186aa0362fba/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= From 4c12e1686bee4c6e2d4225c36bb8014d0eb4656d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:26:32 +0000 Subject: [PATCH 743/867] Bump golang.org/x/crypto from 0.33.0 to 0.35.0 (#4438) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.33.0 to 0.35.0. - [Commits](https://github.com/golang/crypto/compare/v0.33.0...v0.35.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dc2e9e5d..7fe5060d 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.33.0 + golang.org/x/crypto v0.35.0 golang.org/x/net v0.35.0 golang.org/x/sync v0.11.0 golang.org/x/sys v0.30.0 diff --git a/go.sum b/go.sum index 66f5284a..99d85eb6 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= -golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= +golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= +golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= From 06b4a7ce4d2ce309a00e59cf842bad590c498c04 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Feb 2025 13:26:54 +0000 Subject: [PATCH 744/867] Bump lukechampine.com/blake3 from 1.3.0 to 1.4.0 (#4439) Bumps [lukechampine.com/blake3](https://github.com/lukechampine/blake3) from 1.3.0 to 1.4.0. - [Commits](https://github.com/lukechampine/blake3/compare/v1.3.0...v1.4.0) --- updated-dependencies: - dependency-name: lukechampine.com/blake3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7fe5060d..a3bae638 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( google.golang.org/protobuf v1.36.5 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 - lukechampine.com/blake3 v1.3.0 + lukechampine.com/blake3 v1.4.0 ) require ( diff --git a/go.sum b/go.sum index 99d85eb6..9f20efd4 100644 --- a/go.sum +++ b/go.sum @@ -160,5 +160,5 @@ gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h1:P+U/06iIKPQ3DLcg+zBfSCia gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0/go.mod h1:NQHVAzMwvZ+Qe3ElSiHmq9RUm1MdNHpUZ52fiEqvn+0= h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo= h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= -lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= -lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= +lukechampine.com/blake3 v1.4.0 h1:xDbKOZCVbnZsfzM6mHSYcGRHZ3YrLDzqz8XnV4uaD5w= +lukechampine.com/blake3 v1.4.0/go.mod h1:MQJNQCTnR+kwOP/JEZSxj3MaQjp80FOFSNMMHXcSeX0= From 4b616f5cd020bf02e7f9f27e6adffdc1871a3a3a Mon Sep 17 00:00:00 2001 From: A1lo Date: Sat, 1 Mar 2025 11:20:54 +0800 Subject: [PATCH 745/867] XHTTP server: Switch to Go 1.24 native h2c support (#4451) --- transport/internet/splithttp/hub.go | 10 ++++++---- transport/internet/splithttp/splithttp_test.go | 17 ++++------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/transport/internet/splithttp/hub.go b/transport/internet/splithttp/hub.go index 179d696a..d161741a 100644 --- a/transport/internet/splithttp/hub.go +++ b/transport/internet/splithttp/hub.go @@ -24,8 +24,6 @@ import ( "github.com/xtls/xray-core/transport/internet/reality" "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" - "golang.org/x/net/http2" - "golang.org/x/net/http2/h2c" ) type requestHandler struct { @@ -426,11 +424,15 @@ func ListenXH(ctx context.Context, address net.Address, port net.Port, streamSet handler.localAddr = l.listener.Addr() - // h2cHandler can handle both plaintext HTTP/1.1 and h2c + // server can handle both plaintext HTTP/1.1 and h2c + protocols := new(http.Protocols) + protocols.SetHTTP1(true) + protocols.SetUnencryptedHTTP2(true) l.server = http.Server{ - Handler: h2c.NewHandler(handler, &http2.Server{}), + Handler: handler, ReadHeaderTimeout: time.Second * 4, MaxHeaderBytes: 8192, + Protocols: protocols, } go func() { if err := l.server.Serve(l.listener); err != nil { diff --git a/transport/internet/splithttp/splithttp_test.go b/transport/internet/splithttp/splithttp_test.go index f566ecc4..1db54255 100644 --- a/transport/internet/splithttp/splithttp_test.go +++ b/transport/internet/splithttp/splithttp_test.go @@ -3,10 +3,8 @@ package splithttp_test import ( "context" "crypto/rand" - gotls "crypto/tls" "fmt" "io" - gonet "net" "net/http" "runtime" "testing" @@ -23,7 +21,6 @@ import ( . "github.com/xtls/xray-core/transport/internet/splithttp" "github.com/xtls/xray-core/transport/internet/stat" "github.com/xtls/xray-core/transport/internet/tls" - "golang.org/x/net/http2" ) func Test_ListenXHAndDial(t *testing.T) { @@ -201,17 +198,11 @@ func Test_ListenXHAndDial_H2C(t *testing.T) { common.Must(err) defer listen.Close() + protocols := new(http.Protocols) + protocols.SetUnencryptedHTTP2(true) client := http.Client{ - Transport: &http2.Transport{ - // So http2.Transport doesn't complain the URL scheme isn't 'https' - AllowHTTP: true, - // even with AllowHTTP, http2.Transport will attempt to establish - // the connection using DialTLSContext. Disable TLS with custom - // dial context. - DialTLSContext: func(ctx context.Context, network, addr string, cfg *gotls.Config) (gonet.Conn, error) { - var d gonet.Dialer - return d.DialContext(ctx, network, addr) - }, + Transport: &http.Transport{ + Protocols: protocols, }, } From 8d46f7e14c4a0256638f6f914709546b94326f42 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 1 Mar 2025 15:33:21 +0000 Subject: [PATCH 746/867] TLS fingerprints: Refine "random" & "randomized", Add "randomizednoalpn" https://github.com/XTLS/Xray-core/issues/4436#issuecomment-2687801214 --- transport/internet/tls/tls.go | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index bdf77d9a..d2d5fa74 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -151,10 +151,14 @@ func init() { weights := utls.DefaultWeights weights.TLSVersMax_Set_VersionTLS13 = 1 weights.FirstKeyShare_Set_CurveP256 = 0 - randomized := utls.HelloRandomized + randomized := utls.HelloRandomizedALPN randomized.Seed, _ = utls.NewPRNGSeed() randomized.Weights = &weights + randomizednoalpn := utls.HelloRandomizedNoALPN + randomizednoalpn.Seed, _ = utls.NewPRNGSeed() + randomizednoalpn.Weights = &weights PresetFingerprints["randomized"] = &randomized + PresetFingerprints["randomizednoalpn"] = &randomizednoalpn } func GetFingerprint(name string) (fingerprint *utls.ClientHelloID) { @@ -175,17 +179,18 @@ func GetFingerprint(name string) (fingerprint *utls.ClientHelloID) { var PresetFingerprints = map[string]*utls.ClientHelloID{ // Recommended preset options in GUI clients - "chrome": &utls.HelloChrome_Auto, - "firefox": &utls.HelloFirefox_Auto, - "safari": &utls.HelloSafari_Auto, - "ios": &utls.HelloIOS_Auto, - "android": &utls.HelloAndroid_11_OkHttp, - "edge": &utls.HelloEdge_Auto, - "360": &utls.Hello360_Auto, - "qq": &utls.HelloQQ_Auto, - "random": nil, - "randomized": nil, - "unsafe": nil, + "chrome": &utls.HelloChrome_Auto, + "firefox": &utls.HelloFirefox_Auto, + "safari": &utls.HelloSafari_Auto, + "ios": &utls.HelloIOS_Auto, + "android": &utls.HelloAndroid_11_OkHttp, + "edge": &utls.HelloEdge_Auto, + "360": &utls.Hello360_Auto, + "qq": &utls.HelloQQ_Auto, + "random": nil, + "randomized": nil, + "randomizednoalpn": nil, + "unsafe": nil, } var ModernFingerprints = map[string]*utls.ClientHelloID{ @@ -193,12 +198,14 @@ var ModernFingerprints = map[string]*utls.ClientHelloID{ "hellofirefox_99": &utls.HelloFirefox_99, "hellofirefox_102": &utls.HelloFirefox_102, "hellofirefox_105": &utls.HelloFirefox_105, + "hellofirefox_120": &utls.HelloFirefox_120, "hellochrome_83": &utls.HelloChrome_83, "hellochrome_87": &utls.HelloChrome_87, "hellochrome_96": &utls.HelloChrome_96, "hellochrome_100": &utls.HelloChrome_100, "hellochrome_102": &utls.HelloChrome_102, "hellochrome_106_shuffle": &utls.HelloChrome_106_Shuffle, + "hellochrome_120": &utls.HelloChrome_120, "helloios_13": &utls.HelloIOS_13, "helloios_14": &utls.HelloIOS_14, "helloedge_85": &utls.HelloEdge_85, From b9cb93d3c23d3a66716123628d37943ffc41d2eb Mon Sep 17 00:00:00 2001 From: j3l11234 <297259024@qq.com> Date: Sun, 2 Mar 2025 21:07:55 +0800 Subject: [PATCH 747/867] Sockopt: Add `addressPortStrategy` (query SRV or TXT) (#4416) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 风扇滑翔翼 --- infra/conf/transport_internet.go | 22 ++++ transport/internet/config.pb.go | 215 ++++++++++++++++++++++--------- transport/internet/config.proto | 12 ++ transport/internet/dialer.go | 95 ++++++++++++++ 4 files changed, 280 insertions(+), 64 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 7b993a36..0de5bfcc 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -711,6 +711,7 @@ type SocketConfig struct { Interface string `json:"interface"` TcpMptcp bool `json:"tcpMptcp"` CustomSockopt []*CustomSockoptConfig `json:"customSockopt"` + AddressPortStrategy string `json:"addressPortStrategy"` } // Build implements Buildable. @@ -780,6 +781,26 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { customSockopts = append(customSockopts, customSockopt) } + addressPortStrategy := internet.AddressPortStrategy_None + switch strings.ToLower(c.AddressPortStrategy) { + case "none", "": + addressPortStrategy = internet.AddressPortStrategy_None + case "srvportonly": + addressPortStrategy = internet.AddressPortStrategy_SrvPortOnly + case "srvaddressonly": + addressPortStrategy = internet.AddressPortStrategy_SrvAddressOnly + case "srvportandaddress": + addressPortStrategy = internet.AddressPortStrategy_SrvPortAndAddress + case "txtportonly": + addressPortStrategy = internet.AddressPortStrategy_TxtPortOnly + case "txtaddressonly": + addressPortStrategy = internet.AddressPortStrategy_TxtAddressOnly + case "txtportandaddress": + addressPortStrategy = internet.AddressPortStrategy_TxtPortAndAddress + default: + return nil, errors.New("unsupported address and port strategy: ", c.AddressPortStrategy) + } + return &internet.SocketConfig{ Mark: c.Mark, Tfo: tfo, @@ -798,6 +819,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { Interface: c.Interface, TcpMptcp: c.TcpMptcp, CustomSockopt: customSockopts, + AddressPortStrategy: addressPortStrategy, }, nil } diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index d74fa665..ae1b38f3 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -95,6 +95,67 @@ func (DomainStrategy) EnumDescriptor() ([]byte, []int) { return file_transport_internet_config_proto_rawDescGZIP(), []int{0} } +type AddressPortStrategy int32 + +const ( + AddressPortStrategy_None AddressPortStrategy = 0 + AddressPortStrategy_SrvPortOnly AddressPortStrategy = 1 + AddressPortStrategy_SrvAddressOnly AddressPortStrategy = 2 + AddressPortStrategy_SrvPortAndAddress AddressPortStrategy = 3 + AddressPortStrategy_TxtPortOnly AddressPortStrategy = 4 + AddressPortStrategy_TxtAddressOnly AddressPortStrategy = 5 + AddressPortStrategy_TxtPortAndAddress AddressPortStrategy = 6 +) + +// Enum value maps for AddressPortStrategy. +var ( + AddressPortStrategy_name = map[int32]string{ + 0: "None", + 1: "SrvPortOnly", + 2: "SrvAddressOnly", + 3: "SrvPortAndAddress", + 4: "TxtPortOnly", + 5: "TxtAddressOnly", + 6: "TxtPortAndAddress", + } + AddressPortStrategy_value = map[string]int32{ + "None": 0, + "SrvPortOnly": 1, + "SrvAddressOnly": 2, + "SrvPortAndAddress": 3, + "TxtPortOnly": 4, + "TxtAddressOnly": 5, + "TxtPortAndAddress": 6, + } +) + +func (x AddressPortStrategy) Enum() *AddressPortStrategy { + p := new(AddressPortStrategy) + *p = x + return p +} + +func (x AddressPortStrategy) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (AddressPortStrategy) Descriptor() protoreflect.EnumDescriptor { + return file_transport_internet_config_proto_enumTypes[1].Descriptor() +} + +func (AddressPortStrategy) Type() protoreflect.EnumType { + return &file_transport_internet_config_proto_enumTypes[1] +} + +func (x AddressPortStrategy) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use AddressPortStrategy.Descriptor instead. +func (AddressPortStrategy) EnumDescriptor() ([]byte, []int) { + return file_transport_internet_config_proto_rawDescGZIP(), []int{1} +} + type SocketConfig_TProxyMode int32 const ( @@ -131,11 +192,11 @@ func (x SocketConfig_TProxyMode) String() string { } func (SocketConfig_TProxyMode) Descriptor() protoreflect.EnumDescriptor { - return file_transport_internet_config_proto_enumTypes[1].Descriptor() + return file_transport_internet_config_proto_enumTypes[2].Descriptor() } func (SocketConfig_TProxyMode) Type() protoreflect.EnumType { - return &file_transport_internet_config_proto_enumTypes[1] + return &file_transport_internet_config_proto_enumTypes[2] } func (x SocketConfig_TProxyMode) Number() protoreflect.EnumNumber { @@ -434,23 +495,24 @@ type SocketConfig struct { Tproxy SocketConfig_TProxyMode `protobuf:"varint,3,opt,name=tproxy,proto3,enum=xray.transport.internet.SocketConfig_TProxyMode" json:"tproxy,omitempty"` // ReceiveOriginalDestAddress is for enabling IP_RECVORIGDSTADDR socket // option. This option is for UDP only. - ReceiveOriginalDestAddress bool `protobuf:"varint,4,opt,name=receive_original_dest_address,json=receiveOriginalDestAddress,proto3" json:"receive_original_dest_address,omitempty"` - BindAddress []byte `protobuf:"bytes,5,opt,name=bind_address,json=bindAddress,proto3" json:"bind_address,omitempty"` - BindPort uint32 `protobuf:"varint,6,opt,name=bind_port,json=bindPort,proto3" json:"bind_port,omitempty"` - AcceptProxyProtocol bool `protobuf:"varint,7,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` - DomainStrategy DomainStrategy `protobuf:"varint,8,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.transport.internet.DomainStrategy" json:"domain_strategy,omitempty"` - DialerProxy string `protobuf:"bytes,9,opt,name=dialer_proxy,json=dialerProxy,proto3" json:"dialer_proxy,omitempty"` - TcpKeepAliveInterval int32 `protobuf:"varint,10,opt,name=tcp_keep_alive_interval,json=tcpKeepAliveInterval,proto3" json:"tcp_keep_alive_interval,omitempty"` - TcpKeepAliveIdle int32 `protobuf:"varint,11,opt,name=tcp_keep_alive_idle,json=tcpKeepAliveIdle,proto3" json:"tcp_keep_alive_idle,omitempty"` - TcpCongestion string `protobuf:"bytes,12,opt,name=tcp_congestion,json=tcpCongestion,proto3" json:"tcp_congestion,omitempty"` - Interface string `protobuf:"bytes,13,opt,name=interface,proto3" json:"interface,omitempty"` - V6Only bool `protobuf:"varint,14,opt,name=v6only,proto3" json:"v6only,omitempty"` - TcpWindowClamp int32 `protobuf:"varint,15,opt,name=tcp_window_clamp,json=tcpWindowClamp,proto3" json:"tcp_window_clamp,omitempty"` - TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` - TcpMaxSeg int32 `protobuf:"varint,17,opt,name=tcp_max_seg,json=tcpMaxSeg,proto3" json:"tcp_max_seg,omitempty"` - Penetrate bool `protobuf:"varint,18,opt,name=penetrate,proto3" json:"penetrate,omitempty"` - TcpMptcp bool `protobuf:"varint,19,opt,name=tcp_mptcp,json=tcpMptcp,proto3" json:"tcp_mptcp,omitempty"` - CustomSockopt []*CustomSockopt `protobuf:"bytes,20,rep,name=customSockopt,proto3" json:"customSockopt,omitempty"` + ReceiveOriginalDestAddress bool `protobuf:"varint,4,opt,name=receive_original_dest_address,json=receiveOriginalDestAddress,proto3" json:"receive_original_dest_address,omitempty"` + BindAddress []byte `protobuf:"bytes,5,opt,name=bind_address,json=bindAddress,proto3" json:"bind_address,omitempty"` + BindPort uint32 `protobuf:"varint,6,opt,name=bind_port,json=bindPort,proto3" json:"bind_port,omitempty"` + AcceptProxyProtocol bool `protobuf:"varint,7,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` + DomainStrategy DomainStrategy `protobuf:"varint,8,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.transport.internet.DomainStrategy" json:"domain_strategy,omitempty"` + DialerProxy string `protobuf:"bytes,9,opt,name=dialer_proxy,json=dialerProxy,proto3" json:"dialer_proxy,omitempty"` + TcpKeepAliveInterval int32 `protobuf:"varint,10,opt,name=tcp_keep_alive_interval,json=tcpKeepAliveInterval,proto3" json:"tcp_keep_alive_interval,omitempty"` + TcpKeepAliveIdle int32 `protobuf:"varint,11,opt,name=tcp_keep_alive_idle,json=tcpKeepAliveIdle,proto3" json:"tcp_keep_alive_idle,omitempty"` + TcpCongestion string `protobuf:"bytes,12,opt,name=tcp_congestion,json=tcpCongestion,proto3" json:"tcp_congestion,omitempty"` + Interface string `protobuf:"bytes,13,opt,name=interface,proto3" json:"interface,omitempty"` + V6Only bool `protobuf:"varint,14,opt,name=v6only,proto3" json:"v6only,omitempty"` + TcpWindowClamp int32 `protobuf:"varint,15,opt,name=tcp_window_clamp,json=tcpWindowClamp,proto3" json:"tcp_window_clamp,omitempty"` + TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` + TcpMaxSeg int32 `protobuf:"varint,17,opt,name=tcp_max_seg,json=tcpMaxSeg,proto3" json:"tcp_max_seg,omitempty"` + Penetrate bool `protobuf:"varint,18,opt,name=penetrate,proto3" json:"penetrate,omitempty"` + TcpMptcp bool `protobuf:"varint,19,opt,name=tcp_mptcp,json=tcpMptcp,proto3" json:"tcp_mptcp,omitempty"` + CustomSockopt []*CustomSockopt `protobuf:"bytes,20,rep,name=customSockopt,proto3" json:"customSockopt,omitempty"` + AddressPortStrategy AddressPortStrategy `protobuf:"varint,21,opt,name=address_port_strategy,json=addressPortStrategy,proto3,enum=xray.transport.internet.AddressPortStrategy" json:"address_port_strategy,omitempty"` } func (x *SocketConfig) Reset() { @@ -623,6 +685,13 @@ func (x *SocketConfig) GetCustomSockopt() []*CustomSockopt { return nil } +func (x *SocketConfig) GetAddressPortStrategy() AddressPortStrategy { + if x != nil { + return x.AddressPortStrategy + } + return AddressPortStrategy_None +} + var File_transport_internet_config_proto protoreflect.FileDescriptor var file_transport_internet_config_proto_rawDesc = []byte{ @@ -678,7 +747,7 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x28, 0x09, 0x52, 0x03, 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x22, 0x9b, 0x07, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, + 0x65, 0x22, 0xfd, 0x07, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, 0x6f, @@ -732,28 +801,44 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x74, 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x52, - 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x22, 0x2f, - 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, - 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, - 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, - 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, - 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, - 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, - 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, - 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, - 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, - 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, - 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, - 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, - 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x42, 0x67, 0x0a, 0x1b, 0x63, - 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, - 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, - 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x12, 0x60, + 0x0a, 0x15, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2c, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, + 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, + 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x13, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, + 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, + 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, + 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, + 0x02, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, + 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, + 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, + 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, + 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, + 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, + 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, + 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, + 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, + 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x2a, 0x97, 0x01, + 0x0a, 0x13, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, + 0x0f, 0x0a, 0x0b, 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x01, + 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x72, 0x76, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, + 0x6c, 0x79, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x41, + 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x54, + 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, + 0x54, 0x78, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x05, + 0x12, 0x15, 0x0a, 0x11, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x06, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, + 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, + 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -768,33 +853,35 @@ func file_transport_internet_config_proto_rawDescGZIP() []byte { return file_transport_internet_config_proto_rawDescData } -var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 3) var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5) var file_transport_internet_config_proto_goTypes = []any{ (DomainStrategy)(0), // 0: xray.transport.internet.DomainStrategy - (SocketConfig_TProxyMode)(0), // 1: xray.transport.internet.SocketConfig.TProxyMode - (*TransportConfig)(nil), // 2: xray.transport.internet.TransportConfig - (*StreamConfig)(nil), // 3: xray.transport.internet.StreamConfig - (*ProxyConfig)(nil), // 4: xray.transport.internet.ProxyConfig - (*CustomSockopt)(nil), // 5: xray.transport.internet.CustomSockopt - (*SocketConfig)(nil), // 6: xray.transport.internet.SocketConfig - (*serial.TypedMessage)(nil), // 7: xray.common.serial.TypedMessage - (*net.IPOrDomain)(nil), // 8: xray.common.net.IPOrDomain + (AddressPortStrategy)(0), // 1: xray.transport.internet.AddressPortStrategy + (SocketConfig_TProxyMode)(0), // 2: xray.transport.internet.SocketConfig.TProxyMode + (*TransportConfig)(nil), // 3: xray.transport.internet.TransportConfig + (*StreamConfig)(nil), // 4: xray.transport.internet.StreamConfig + (*ProxyConfig)(nil), // 5: xray.transport.internet.ProxyConfig + (*CustomSockopt)(nil), // 6: xray.transport.internet.CustomSockopt + (*SocketConfig)(nil), // 7: xray.transport.internet.SocketConfig + (*serial.TypedMessage)(nil), // 8: xray.common.serial.TypedMessage + (*net.IPOrDomain)(nil), // 9: xray.common.net.IPOrDomain } var file_transport_internet_config_proto_depIdxs = []int32{ - 7, // 0: xray.transport.internet.TransportConfig.settings:type_name -> xray.common.serial.TypedMessage - 8, // 1: xray.transport.internet.StreamConfig.address:type_name -> xray.common.net.IPOrDomain - 2, // 2: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig - 7, // 3: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage - 6, // 4: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig - 1, // 5: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode + 8, // 0: xray.transport.internet.TransportConfig.settings:type_name -> xray.common.serial.TypedMessage + 9, // 1: xray.transport.internet.StreamConfig.address:type_name -> xray.common.net.IPOrDomain + 3, // 2: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig + 8, // 3: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage + 7, // 4: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig + 2, // 5: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode 0, // 6: xray.transport.internet.SocketConfig.domain_strategy:type_name -> xray.transport.internet.DomainStrategy - 5, // 7: xray.transport.internet.SocketConfig.customSockopt:type_name -> xray.transport.internet.CustomSockopt - 8, // [8:8] is the sub-list for method output_type - 8, // [8:8] is the sub-list for method input_type - 8, // [8:8] is the sub-list for extension type_name - 8, // [8:8] is the sub-list for extension extendee - 0, // [0:8] is the sub-list for field type_name + 6, // 7: xray.transport.internet.SocketConfig.customSockopt:type_name -> xray.transport.internet.CustomSockopt + 1, // 8: xray.transport.internet.SocketConfig.address_port_strategy:type_name -> xray.transport.internet.AddressPortStrategy + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name } func init() { file_transport_internet_config_proto_init() } @@ -807,7 +894,7 @@ func file_transport_internet_config_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_transport_internet_config_proto_rawDesc, - NumEnums: 2, + NumEnums: 3, NumMessages: 5, NumExtensions: 0, NumServices: 0, diff --git a/transport/internet/config.proto b/transport/internet/config.proto index 9293179e..d51998b2 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -23,6 +23,16 @@ enum DomainStrategy { FORCE_IP64 = 10; } +enum AddressPortStrategy { + None = 0; + SrvPortOnly = 1; + SrvAddressOnly = 2; + SrvPortAndAddress = 3; + TxtPortOnly = 4; + TxtAddressOnly = 5; + TxtPortAndAddress = 6; +} + message TransportConfig { // Transport protocol name. string protocol_name = 3; @@ -116,4 +126,6 @@ message SocketConfig { bool tcp_mptcp = 19; repeated CustomSockopt customSockopt = 20; + + AddressPortStrategy address_port_strategy = 21; } diff --git a/transport/internet/dialer.go b/transport/internet/dialer.go index 8ab51551..3b6fbfd5 100644 --- a/transport/internet/dialer.go +++ b/transport/internet/dialer.go @@ -2,6 +2,9 @@ package internet import ( "context" + "fmt" + gonet "net" + "strings" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/dice" @@ -140,6 +143,93 @@ func redirect(ctx context.Context, dst net.Destination, obt string) net.Conn { return nil } +func checkAddressPortStrategy(ctx context.Context, dest net.Destination, sockopt *SocketConfig) (*net.Destination, error) { + if sockopt.AddressPortStrategy == AddressPortStrategy_None { + return nil, nil + } + newDest := dest + var OverridePort, OverrideAddress bool + var OverrideBy string + switch sockopt.AddressPortStrategy { + case AddressPortStrategy_SrvPortOnly: + OverridePort = true + OverrideAddress = false + OverrideBy = "srv" + case AddressPortStrategy_SrvAddressOnly: + OverridePort = false + OverrideAddress = true + OverrideBy = "srv" + case AddressPortStrategy_SrvPortAndAddress: + OverridePort = true + OverrideAddress = true + OverrideBy = "srv" + case AddressPortStrategy_TxtPortOnly: + OverridePort = true + OverrideAddress = false + OverrideBy = "txt" + case AddressPortStrategy_TxtAddressOnly: + OverridePort = false + OverrideAddress = true + OverrideBy = "txt" + case AddressPortStrategy_TxtPortAndAddress: + OverridePort = true + OverrideAddress = true + OverrideBy = "txt" + default: + return nil, errors.New("unknown AddressPortStrategy") + } + + if !dest.Address.Family().IsDomain() { + return nil, nil + } + + if OverrideBy == "srv" { + errors.LogDebug(ctx, "query SRV record for "+dest.Address.String()) + parts := strings.SplitN(dest.Address.String(), ".", 3) + if len(parts) != 3 { + return nil, errors.New("invalid address format", dest.Address.String()) + } + _, srvRecords, err := gonet.DefaultResolver.LookupSRV(context.Background(), parts[0][1:], parts[1][1:], parts[2]) + if err != nil { + return nil, errors.New("failed to lookup SRV record").Base(err) + } + errors.LogDebug(ctx, "SRV record: "+fmt.Sprintf("addr=%s, port=%d, priority=%d, weight=%d", srvRecords[0].Target, srvRecords[0].Port, srvRecords[0].Priority, srvRecords[0].Weight)) + if OverridePort { + newDest.Port = net.Port(srvRecords[0].Port) + } + if OverrideAddress { + newDest.Address = net.ParseAddress(srvRecords[0].Target) + } + return &newDest, nil + } + if OverrideBy == "txt" { + errors.LogDebug(ctx, "query TXT record for "+dest.Address.String()) + txtRecords, err := gonet.DefaultResolver.LookupTXT(ctx, dest.Address.String()) + if err != nil { + errors.LogError(ctx, "failed to lookup SRV record: "+err.Error()) + return nil, errors.New("failed to lookup SRV record").Base(err) + } + for _, txtRecord := range txtRecords { + errors.LogDebug(ctx, "TXT record: "+txtRecord) + addr_s, port_s, _ := net.SplitHostPort(string(txtRecord)) + addr := net.ParseAddress(addr_s) + port, err := net.PortFromString(port_s) + if err != nil { + continue + } + + if OverridePort { + newDest.Port = port + } + if OverrideAddress { + newDest.Address = addr + } + return &newDest, nil + } + } + return nil, nil +} + // DialSystem calls system dialer to create a network connection. func DialSystem(ctx context.Context, dest net.Destination, sockopt *SocketConfig) (net.Conn, error) { var src net.Address @@ -152,6 +242,11 @@ func DialSystem(ctx context.Context, dest net.Destination, sockopt *SocketConfig return effectiveSystemDialer.Dial(ctx, src, dest, sockopt) } + if newDest, err := checkAddressPortStrategy(ctx, dest, sockopt); err == nil && newDest != nil { + errors.LogInfo(ctx, "replace destination with "+newDest.String()) + dest = *newDest + } + if canLookupIP(ctx, dest, sockopt) { ips, err := lookupIP(dest.Address.String(), sockopt.DomainStrategy, src) if err == nil && len(ips) > 0 { From e466b0497c3c563622146e2595d4870e4a43f56e Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:45:12 +0000 Subject: [PATCH 748/867] DNS DoH: Use Chrome's fingerprint & keepAlivePeriod, Add header padding by default https://github.com/XTLS/Xray-core/discussions/4430#discussioncomment-12374292 --- app/dns/nameserver.go | 8 +- app/dns/nameserver_doh.go | 169 +++++++++++-------------- app/dns/nameserver_doh_test.go | 8 +- common/crypto/crypto.go | 13 ++ common/net/net.go | 12 ++ proxy/freedom/freedom.go | 22 +--- transport/internet/reality/reality.go | 23 +--- transport/internet/splithttp/config.go | 9 +- transport/internet/splithttp/dialer.go | 24 +--- transport/internet/tls/config.pb.go | 2 +- transport/internet/tls/config.proto | 2 +- 11 files changed, 130 insertions(+), 162 deletions(-) diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index 89f5b25e..b23cb186 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -45,11 +45,13 @@ func NewServer(ctx context.Context, dest net.Destination, dispatcher routing.Dis case strings.EqualFold(u.String(), "localhost"): return NewLocalNameServer(queryStrategy), nil case strings.EqualFold(u.Scheme, "https"): // DNS-over-HTTPS Remote mode - return NewDoHNameServer(u, dispatcher, queryStrategy, false) + return NewDoHNameServer(u, queryStrategy, dispatcher, false), nil case strings.EqualFold(u.Scheme, "h2c"): // DNS-over-HTTPS h2c Remote mode - return NewDoHNameServer(u, dispatcher, queryStrategy, true) + return NewDoHNameServer(u, queryStrategy, dispatcher, true), nil case strings.EqualFold(u.Scheme, "https+local"): // DNS-over-HTTPS Local mode - return NewDoHLocalNameServer(u, queryStrategy), nil + return NewDoHNameServer(u, queryStrategy, nil, false), nil + case strings.EqualFold(u.Scheme, "h2c+local"): // DNS-over-HTTPS h2c Local mode + return NewDoHNameServer(u, queryStrategy, nil, true), nil case strings.EqualFold(u.Scheme, "quic+local"): // DNS-over-QUIC Local mode return NewQUICNameServer(u, queryStrategy) case strings.EqualFold(u.Scheme, "tcp"): // DNS-over-TCP Remote mode diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index f602d80a..c74b9e53 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -8,10 +8,13 @@ import ( "io" "net/http" "net/url" + "strings" "sync" "time" + utls "github.com/refraction-networking/utls" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/crypto" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/log" "github.com/xtls/xray-core/common/net" @@ -31,7 +34,6 @@ import ( // which is compatible with traditional dns over udp(RFC1035), // thus most of the DOH implementation is copied from udpns.go type DoHNameServer struct { - dispatcher routing.Dispatcher sync.RWMutex ips map[string]*record pub *pubsub.Service @@ -42,108 +44,18 @@ type DoHNameServer struct { queryStrategy QueryStrategy } -// NewDoHNameServer creates DOH server object for remote resolving. -func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, queryStrategy QueryStrategy, h2c bool) (*DoHNameServer, error) { +// NewDoHNameServer creates DOH/DOHL client object for remote/local resolving. +func NewDoHNameServer(url *url.URL, queryStrategy QueryStrategy, dispatcher routing.Dispatcher, h2c bool) *DoHNameServer { url.Scheme = "https" - errors.LogInfo(context.Background(), "DNS: created Remote DNS-over-HTTPS client for ", url.String(), ", with h2c ", h2c) - s := baseDOHNameServer(url, "DOH", queryStrategy) - - s.dispatcher = dispatcher - dialContext := func(ctx context.Context, network, addr string) (net.Conn, error) { - dest, err := net.ParseDestination(network + ":" + addr) - if err != nil { - return nil, err - } - dnsCtx := toDnsContext(ctx, s.dohURL) - if h2c { - dnsCtx = session.ContextWithMitmAlpn11(dnsCtx, false) // for insurance - dnsCtx = session.ContextWithMitmServerName(dnsCtx, url.Hostname()) - } - link, err := s.dispatcher.Dispatch(dnsCtx, dest) - select { - case <-ctx.Done(): - return nil, ctx.Err() - default: - - } - if err != nil { - return nil, err - } - - cc := common.ChainedClosable{} - if cw, ok := link.Writer.(common.Closable); ok { - cc = append(cc, cw) - } - if cr, ok := link.Reader.(common.Closable); ok { - cc = append(cc, cr) - } - return cnc.NewConnection( - cnc.ConnectionInputMulti(link.Writer), - cnc.ConnectionOutputMulti(link.Reader), - cnc.ConnectionOnClose(cc), - ), nil + mode := "DOH" + if dispatcher == nil { + mode = "DOHL" } - - s.httpClient = &http.Client{ - Timeout: time.Second * 180, - Transport: &http.Transport{ - MaxIdleConns: 30, - IdleConnTimeout: 90 * time.Second, - TLSHandshakeTimeout: 30 * time.Second, - ForceAttemptHTTP2: true, - DialContext: dialContext, - }, - } - if h2c { - s.httpClient.Transport = &http2.Transport{ - IdleConnTimeout: 90 * time.Second, - DialTLSContext: func(ctx context.Context, network, addr string, cfg *tls.Config) (net.Conn, error) { - return dialContext(ctx, network, addr) - }, - } - } - - return s, nil -} - -// NewDoHLocalNameServer creates DOH client object for local resolving -func NewDoHLocalNameServer(url *url.URL, queryStrategy QueryStrategy) *DoHNameServer { - url.Scheme = "https" - s := baseDOHNameServer(url, "DOHL", queryStrategy) - tr := &http.Transport{ - IdleConnTimeout: 90 * time.Second, - ForceAttemptHTTP2: true, - DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { - dest, err := net.ParseDestination(network + ":" + addr) - if err != nil { - return nil, err - } - conn, err := internet.DialSystem(ctx, dest, nil) - log.Record(&log.AccessMessage{ - From: "DNS", - To: s.dohURL, - Status: log.AccessAccepted, - Detour: "local", - }) - if err != nil { - return nil, err - } - return conn, nil - }, - } - s.httpClient = &http.Client{ - Timeout: time.Second * 180, - Transport: tr, - } - errors.LogInfo(context.Background(), "DNS: created Local DNS-over-HTTPS client for ", url.String()) - return s -} - -func baseDOHNameServer(url *url.URL, prefix string, queryStrategy QueryStrategy) *DoHNameServer { + errors.LogInfo(context.Background(), "DNS: created ", mode, " client for ", url.String(), ", with h2c ", h2c) s := &DoHNameServer{ ips: make(map[string]*record), pub: pubsub.NewService(), - name: prefix + "//" + url.Host, + name: mode + "//" + url.Host, dohURL: url.String(), queryStrategy: queryStrategy, } @@ -151,6 +63,65 @@ func baseDOHNameServer(url *url.URL, prefix string, queryStrategy QueryStrategy) Interval: time.Minute, Execute: s.Cleanup, } + s.httpClient = &http.Client{ + Transport: &http2.Transport{ + IdleConnTimeout: net.ConnIdleTimeout, + ReadIdleTimeout: net.ChromeH2KeepAlivePeriod, + DialTLSContext: func(ctx context.Context, network, addr string, cfg *tls.Config) (net.Conn, error) { + dest, err := net.ParseDestination(network + ":" + addr) + if err != nil { + return nil, err + } + var conn net.Conn + if dispatcher != nil { + dnsCtx := toDnsContext(ctx, s.dohURL) + if h2c { + dnsCtx = session.ContextWithMitmAlpn11(dnsCtx, false) // for insurance + dnsCtx = session.ContextWithMitmServerName(dnsCtx, url.Hostname()) + } + link, err := dispatcher.Dispatch(dnsCtx, dest) + select { + case <-ctx.Done(): + return nil, ctx.Err() + default: + } + if err != nil { + return nil, err + } + cc := common.ChainedClosable{} + if cw, ok := link.Writer.(common.Closable); ok { + cc = append(cc, cw) + } + if cr, ok := link.Reader.(common.Closable); ok { + cc = append(cc, cr) + } + conn = cnc.NewConnection( + cnc.ConnectionInputMulti(link.Writer), + cnc.ConnectionOutputMulti(link.Reader), + cnc.ConnectionOnClose(cc), + ) + } else { + log.Record(&log.AccessMessage{ + From: "DNS", + To: s.dohURL, + Status: log.AccessAccepted, + Detour: "local", + }) + conn, err = internet.DialSystem(ctx, dest, nil) + if err != nil { + return nil, err + } + } + if !h2c { + conn = utls.UClient(conn, &utls.Config{ServerName: url.Hostname()}, utls.HelloChrome_Auto) + if err := conn.(*utls.UConn).HandshakeContext(ctx); err != nil { + return nil, err + } + } + return conn, nil + }, + }, + } return s } @@ -310,6 +281,8 @@ func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte, req.Header.Add("Accept", "application/dns-message") req.Header.Add("Content-Type", "application/dns-message") + req.Header.Set("X-Padding", strings.Repeat("X", int(crypto.RandBetween(100, 1000)))) + hc := s.httpClient resp, err := hc.Do(req.WithContext(ctx)) diff --git a/app/dns/nameserver_doh_test.go b/app/dns/nameserver_doh_test.go index ae4f9cc7..3dfcb15c 100644 --- a/app/dns/nameserver_doh_test.go +++ b/app/dns/nameserver_doh_test.go @@ -17,7 +17,7 @@ func TestDOHNameServer(t *testing.T) { url, err := url.Parse("https+local://1.1.1.1/dns-query") common.Must(err) - s := NewDoHLocalNameServer(url, QueryStrategy_USE_IP) + s := NewDoHNameServer(url, QueryStrategy_USE_IP, nil, false) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, @@ -34,7 +34,7 @@ func TestDOHNameServerWithCache(t *testing.T) { url, err := url.Parse("https+local://1.1.1.1/dns-query") common.Must(err) - s := NewDoHLocalNameServer(url, QueryStrategy_USE_IP) + s := NewDoHNameServer(url, QueryStrategy_USE_IP, nil, false) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, @@ -62,7 +62,7 @@ func TestDOHNameServerWithIPv4Override(t *testing.T) { url, err := url.Parse("https+local://1.1.1.1/dns-query") common.Must(err) - s := NewDoHLocalNameServer(url, QueryStrategy_USE_IP4) + s := NewDoHNameServer(url, QueryStrategy_USE_IP4, nil, false) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, @@ -85,7 +85,7 @@ func TestDOHNameServerWithIPv6Override(t *testing.T) { url, err := url.Parse("https+local://1.1.1.1/dns-query") common.Must(err) - s := NewDoHLocalNameServer(url, QueryStrategy_USE_IP6) + s := NewDoHNameServer(url, QueryStrategy_USE_IP6, nil, false) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, diff --git a/common/crypto/crypto.go b/common/crypto/crypto.go index 4ed70634..464b4fa7 100644 --- a/common/crypto/crypto.go +++ b/common/crypto/crypto.go @@ -1,2 +1,15 @@ // Package crypto provides common crypto libraries for Xray. package crypto // import "github.com/xtls/xray-core/common/crypto" + +import ( + "crypto/rand" + "math/big" +) + +func RandBetween(from int64, to int64) int64 { + if from == to { + return from + } + bigInt, _ := rand.Int(rand.Reader, big.NewInt(to-from)) + return from + bigInt.Int64() +} diff --git a/common/net/net.go b/common/net/net.go index ce321425..92431c42 100644 --- a/common/net/net.go +++ b/common/net/net.go @@ -1,2 +1,14 @@ // Package net is a drop-in replacement to Golang's net package, with some more functionalities. package net // import "github.com/xtls/xray-core/common/net" + +import "time" + +// defines the maximum time an idle TCP session can survive in the tunnel, so +// it should be consistent across HTTP versions and with other transports. +const ConnIdleTimeout = 300 * time.Second + +// consistent with quic-go +const QuicgoH3KeepAlivePeriod = 10 * time.Second + +// consistent with chrome +const ChromeH2KeepAlivePeriod = 45 * time.Second diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 19bc15ab..324941ee 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -4,12 +4,12 @@ import ( "context" "crypto/rand" "io" - "math/big" "time" "github.com/pires/go-proxyproto" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" + "github.com/xtls/xray-core/common/crypto" "github.com/xtls/xray-core/common/dice" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" @@ -414,7 +414,7 @@ func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { noise = n.Packet } else { //Random noise - noise, err = GenerateRandomBytes(randBetween(int64(n.LengthMin), + noise, err = GenerateRandomBytes(crypto.RandBetween(int64(n.LengthMin), int64(n.LengthMax))) } if err != nil { @@ -423,7 +423,7 @@ func (w *NoisePacketWriter) WriteMultiBuffer(mb buf.MultiBuffer) error { w.Writer.WriteMultiBuffer(buf.MultiBuffer{buf.FromBytes(noise)}) if n.DelayMin != 0 || n.DelayMax != 0 { - time.Sleep(time.Duration(randBetween(int64(n.DelayMin), int64(n.DelayMax))) * time.Millisecond) + time.Sleep(time.Duration(crypto.RandBetween(int64(n.DelayMin), int64(n.DelayMax))) * time.Millisecond) } } @@ -452,7 +452,7 @@ func (f *FragmentWriter) Write(b []byte) (int, error) { buf := make([]byte, 1024) var hello []byte for from := 0; ; { - to := from + int(randBetween(int64(f.fragment.LengthMin), int64(f.fragment.LengthMax))) + to := from + int(crypto.RandBetween(int64(f.fragment.LengthMin), int64(f.fragment.LengthMax))) if to > len(data) { to = len(data) } @@ -466,7 +466,7 @@ func (f *FragmentWriter) Write(b []byte) (int, error) { hello = append(hello, buf[:5+l]...) } else { _, err := f.writer.Write(buf[:5+l]) - time.Sleep(time.Duration(randBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond) + time.Sleep(time.Duration(crypto.RandBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond) if err != nil { return 0, err } @@ -493,13 +493,13 @@ func (f *FragmentWriter) Write(b []byte) (int, error) { return f.writer.Write(b) } for from := 0; ; { - to := from + int(randBetween(int64(f.fragment.LengthMin), int64(f.fragment.LengthMax))) + to := from + int(crypto.RandBetween(int64(f.fragment.LengthMin), int64(f.fragment.LengthMax))) if to > len(b) { to = len(b) } n, err := f.writer.Write(b[from:to]) from += n - time.Sleep(time.Duration(randBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond) + time.Sleep(time.Duration(crypto.RandBetween(int64(f.fragment.IntervalMin), int64(f.fragment.IntervalMax))) * time.Millisecond) if err != nil { return from, err } @@ -509,14 +509,6 @@ func (f *FragmentWriter) Write(b []byte) (int, error) { } } -// stolen from github.com/xtls/xray-core/transport/internet/reality -func randBetween(left int64, right int64) int64 { - if left == right { - return left - } - bigInt, _ := rand.Int(rand.Reader, big.NewInt(right-left)) - return left + bigInt.Int64() -} func GenerateRandomBytes(n int64) ([]byte, error) { b := make([]byte, n) _, err := rand.Read(b) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 0efcd96e..a9352aaf 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -8,7 +8,6 @@ import ( "crypto/ecdh" "crypto/ed25519" "crypto/hmac" - "crypto/rand" "crypto/sha256" "crypto/sha512" gotls "crypto/tls" @@ -16,7 +15,6 @@ import ( "encoding/binary" "fmt" "io" - "math/big" "net/http" "reflect" "regexp" @@ -27,6 +25,7 @@ import ( utls "github.com/refraction-networking/utls" "github.com/xtls/reality" + "github.com/xtls/xray-core/common/crypto" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/core" @@ -213,13 +212,13 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati } times := 1 if !first { - times = int(randBetween(config.SpiderY[4], config.SpiderY[5])) + times = int(crypto.RandBetween(config.SpiderY[4], config.SpiderY[5])) } for j := 0; j < times; j++ { if !first && j == 0 { req.Header.Set("Referer", firstURL) } - req.AddCookie(&http.Cookie{Name: "padding", Value: strings.Repeat("0", int(randBetween(config.SpiderY[0], config.SpiderY[1])))}) + req.AddCookie(&http.Cookie{Name: "padding", Value: strings.Repeat("0", int(crypto.RandBetween(config.SpiderY[0], config.SpiderY[1])))}) if resp, err = client.Do(req); err != nil { break } @@ -243,18 +242,18 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati } maps.Unlock() if !first { - time.Sleep(time.Duration(randBetween(config.SpiderY[6], config.SpiderY[7])) * time.Millisecond) // interval + time.Sleep(time.Duration(crypto.RandBetween(config.SpiderY[6], config.SpiderY[7])) * time.Millisecond) // interval } } } get(true) - concurrency := int(randBetween(config.SpiderY[2], config.SpiderY[3])) + concurrency := int(crypto.RandBetween(config.SpiderY[2], config.SpiderY[3])) for i := 0; i < concurrency; i++ { go get(false) } // Do not close the connection }() - time.Sleep(time.Duration(randBetween(config.SpiderY[8], config.SpiderY[9])) * time.Millisecond) // return + time.Sleep(time.Duration(crypto.RandBetween(config.SpiderY[8], config.SpiderY[9])) * time.Millisecond) // return return nil, errors.New("REALITY: processed invalid connection").AtWarning() } return uConn, nil @@ -271,7 +270,7 @@ var maps struct { } func getPathLocked(paths map[string]struct{}) string { - stopAt := int(randBetween(0, int64(len(paths)-1))) + stopAt := int(crypto.RandBetween(0, int64(len(paths)-1))) i := 0 for s := range paths { if i == stopAt { @@ -281,11 +280,3 @@ func getPathLocked(paths map[string]struct{}) string { } return "/" } - -func randBetween(left int64, right int64) int64 { - if left == right { - return left - } - bigInt, _ := rand.Int(rand.Reader, big.NewInt(right-left)) - return left + bigInt.Int64() -} diff --git a/transport/internet/splithttp/config.go b/transport/internet/splithttp/config.go index f160db31..21e81aa1 100644 --- a/transport/internet/splithttp/config.go +++ b/transport/internet/splithttp/config.go @@ -1,13 +1,12 @@ package splithttp import ( - "crypto/rand" - "math/big" "net/http" "net/url" "strings" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/crypto" "github.com/xtls/xray-core/transport/internet" ) @@ -184,9 +183,5 @@ func init() { } func (c RangeConfig) rand() int32 { - if c.From == c.To { - return c.From - } - bigInt, _ := rand.Int(rand.Reader, big.NewInt(int64(c.To-c.From))) - return c.From + int32(bigInt.Int64()) + return int32(crypto.RandBetween(int64(c.From), int64(c.To))) } diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index b97c39e9..f996a42e 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -30,16 +30,6 @@ import ( "golang.org/x/net/http2" ) -// defines the maximum time an idle TCP session can survive in the tunnel, so -// it should be consistent across HTTP versions and with other transports. -const connIdleTimeout = 300 * time.Second - -// consistent with quic-go -const quicgoH3KeepAlivePeriod = 10 * time.Second - -// consistent with chrome -const chromeH2KeepAlivePeriod = 45 * time.Second - type dialerConf struct { net.Destination *internet.MemoryStreamConfig @@ -154,13 +144,13 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea if httpVersion == "3" { if keepAlivePeriod == 0 { - keepAlivePeriod = quicgoH3KeepAlivePeriod + keepAlivePeriod = net.QuicgoH3KeepAlivePeriod } if keepAlivePeriod < 0 { keepAlivePeriod = 0 } quicConfig := &quic.Config{ - MaxIdleTimeout: connIdleTimeout, + MaxIdleTimeout: net.ConnIdleTimeout, // these two are defaults of quic-go/http3. the default of quic-go (no // http3) is different, so it is hardcoded here for clarity. @@ -168,7 +158,7 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea MaxIncomingStreams: -1, KeepAlivePeriod: keepAlivePeriod, } - transport = &http3.RoundTripper{ + transport = &http3.Transport{ QUICConfig: quicConfig, TLSClientConfig: gotlsConfig, Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) { @@ -198,7 +188,7 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea return nil, err } default: - udpConn = &internet.FakePacketConn{c} + udpConn = &internet.FakePacketConn{Conn: c} udpAddr, err = net.ResolveUDPAddr("udp", c.RemoteAddr().String()) if err != nil { return nil, err @@ -210,7 +200,7 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea } } else if httpVersion == "2" { if keepAlivePeriod == 0 { - keepAlivePeriod = chromeH2KeepAlivePeriod + keepAlivePeriod = net.ChromeH2KeepAlivePeriod } if keepAlivePeriod < 0 { keepAlivePeriod = 0 @@ -219,7 +209,7 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea DialTLSContext: func(ctxInner context.Context, network string, addr string, cfg *gotls.Config) (net.Conn, error) { return dialContext(ctxInner) }, - IdleConnTimeout: connIdleTimeout, + IdleConnTimeout: net.ConnIdleTimeout, ReadIdleTimeout: keepAlivePeriod, } } else { @@ -230,7 +220,7 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea transport = &http.Transport{ DialTLSContext: httpDialContext, DialContext: httpDialContext, - IdleConnTimeout: connIdleTimeout, + IdleConnTimeout: net.ConnIdleTimeout, // chunked transfer download with KeepAlives is buggy with // http.Client and our custom dial context. DisableKeepAlives: true, diff --git a/transport/internet/tls/config.pb.go b/transport/internet/tls/config.pb.go index 43053c78..bc45dc4e 100644 --- a/transport/internet/tls/config.pb.go +++ b/transport/internet/tls/config.pb.go @@ -207,7 +207,7 @@ type Config struct { // @Critical PinnedPeerCertificateChainSha256 [][]byte `protobuf:"bytes,13,rep,name=pinned_peer_certificate_chain_sha256,json=pinnedPeerCertificateChainSha256,proto3" json:"pinned_peer_certificate_chain_sha256,omitempty"` // @Document Some certificate public key sha256 hashes. - // @Document After normal validation (required), if the verified cert's public key hash does not match any of these values, the connection will be aborted. + // @Document After normal validation (required), if one of certs in verified chain matches one of these values, the connection will be eventually accepted. // @Critical PinnedPeerCertificatePublicKeySha256 [][]byte `protobuf:"bytes,14,rep,name=pinned_peer_certificate_public_key_sha256,json=pinnedPeerCertificatePublicKeySha256,proto3" json:"pinned_peer_certificate_public_key_sha256,omitempty"` MasterKeyLog string `protobuf:"bytes,15,opt,name=master_key_log,json=masterKeyLog,proto3" json:"master_key_log,omitempty"` diff --git a/transport/internet/tls/config.proto b/transport/internet/tls/config.proto index c52d0be1..3fac25af 100644 --- a/transport/internet/tls/config.proto +++ b/transport/internet/tls/config.proto @@ -76,7 +76,7 @@ message Config { repeated bytes pinned_peer_certificate_chain_sha256 = 13; /* @Document Some certificate public key sha256 hashes. - @Document After normal validation (required), if the verified cert's public key hash does not match any of these values, the connection will be aborted. + @Document After normal validation (required), if one of certs in verified chain matches one of these values, the connection will be eventually accepted. @Critical */ repeated bytes pinned_peer_certificate_public_key_sha256 = 14; From e15dff94b5bdba40d54b8dea8e31fb997d26d8ed Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 3 Mar 2025 15:30:22 +0000 Subject: [PATCH 749/867] v25.3.3 Announcement of NFTs by Project X: https://github.com/XTLS/Xray-core/discussions/3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/core.go b/core/core.go index 37e2e8b7..e36a90e2 100644 --- a/core/core.go +++ b/core/core.go @@ -18,8 +18,8 @@ import ( var ( Version_x byte = 25 - Version_y byte = 2 - Version_z byte = 21 + Version_y byte = 3 + Version_z byte = 3 ) var ( From dde0a4f2729d9c56c0b7c7581b77d98f8f46e108 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 4 Mar 2025 05:29:03 +0000 Subject: [PATCH 750/867] REALITY config: Add `password` as an alias of `publicKey` https://github.com/XTLS/Xray-core/issues/4458#issuecomment-2696181682 --- infra/conf/transport_internet.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 0de5bfcc..78bd76fe 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -502,6 +502,7 @@ type REALITYConfig struct { Fingerprint string `json:"fingerprint"` ServerName string `json:"serverName"` + Password string `json:"password"` PublicKey string `json:"publicKey"` ShortId string `json:"shortId"` SpiderX string `json:"spiderX"` @@ -610,11 +611,14 @@ func (c *REALITYConfig) Build() (proto.Message, error) { if len(c.ServerNames) != 0 { return nil, errors.New(`non-empty "serverNames", please use "serverName" instead`) } + if c.Password != "" { + c.PublicKey = c.Password + } if c.PublicKey == "" { - return nil, errors.New(`empty "publicKey"`) + return nil, errors.New(`empty "password"`) } if config.PublicKey, err = base64.RawURLEncoding.DecodeString(c.PublicKey); err != nil || len(config.PublicKey) != 32 { - return nil, errors.New(`invalid "publicKey": `, c.PublicKey) + return nil, errors.New(`invalid "password": `, c.PublicKey) } if len(c.ShortIds) != 0 { return nil, errors.New(`non-empty "shortIds", please use "shortId" instead`) From 16eee1b89c835dd7be44f12c24ce7f303bda8a9f Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 4 Mar 2025 11:01:03 +0000 Subject: [PATCH 751/867] Mux server: Clone the session.Content attached on ctx as well https://github.com/XTLS/Xray-core/pull/3908#issuecomment-2696911994 Fixes https://github.com/XTLS/Xray-core/pull/3904 for good --- app/proxyman/inbound/worker.go | 1 + common/mux/server.go | 2 +- common/protocol/http/sniff.go | 2 +- common/session/context.go | 12 +++++++++-- common/session/session.go | 39 ++-------------------------------- 5 files changed, 15 insertions(+), 41 deletions(-) diff --git a/app/proxyman/inbound/worker.go b/app/proxyman/inbound/worker.go index a14a338f..12e29876 100644 --- a/app/proxyman/inbound/worker.go +++ b/app/proxyman/inbound/worker.go @@ -324,6 +324,7 @@ func (w *udpWorker) callback(b *buf.Buffer, source net.Destination, originalDest if w.sniffingConfig != nil { content.SniffingRequest.Enabled = w.sniffingConfig.Enabled content.SniffingRequest.OverrideDestinationForProtocol = w.sniffingConfig.DestinationOverride + content.SniffingRequest.ExcludeForDomain = w.sniffingConfig.DomainsExcluded content.SniffingRequest.MetadataOnly = w.sniffingConfig.MetadataOnly content.SniffingRequest.RouteOnly = w.sniffingConfig.RouteOnly } diff --git a/common/mux/server.go b/common/mux/server.go index 480175ba..8fc0ae09 100644 --- a/common/mux/server.go +++ b/common/mux/server.go @@ -120,7 +120,7 @@ func (w *ServerWorker) handleStatusKeepAlive(meta *FrameMetadata, reader *buf.Bu func (w *ServerWorker) handleStatusNew(ctx context.Context, meta *FrameMetadata, reader *buf.BufferedReader) error { // deep-clone outbounds because it is going to be mutated concurrently // (Target and OriginalTarget) - ctx = session.ContextCloneOutbounds(ctx) + ctx = session.ContextCloneOutboundsAndContent(ctx) errors.LogInfo(ctx, "received request for ", meta.Target) { msg := &log.AccessMessage{ diff --git a/common/protocol/http/sniff.go b/common/protocol/http/sniff.go index 40968294..e85a0792 100644 --- a/common/protocol/http/sniff.go +++ b/common/protocol/http/sniff.go @@ -63,7 +63,7 @@ func SniffHTTP(b []byte, c context.Context) (*SniffHeader, error) { ShouldSniffAttr := true // If content.Attributes have information, that means it comes from HTTP inbound PlainHTTP mode. // It will set attributes, so skip it. - if content == nil || content.AttributeLen() != 0 { + if content == nil || len(content.Attributes) != 0 { ShouldSniffAttr = false } if err := beginWithHTTPMethod(b); err != nil { diff --git a/common/session/context.go b/common/session/context.go index f2c8de7f..0e2558c2 100644 --- a/common/session/context.go +++ b/common/session/context.go @@ -42,7 +42,7 @@ func ContextWithOutbounds(ctx context.Context, outbounds []*Outbound) context.Co return context.WithValue(ctx, outboundSessionKey, outbounds) } -func ContextCloneOutbounds(ctx context.Context) context.Context { +func ContextCloneOutboundsAndContent(ctx context.Context) context.Context { outbounds := OutboundsFromContext(ctx) newOutbounds := make([]*Outbound, len(outbounds)) for i, ob := range outbounds { @@ -55,7 +55,15 @@ func ContextCloneOutbounds(ctx context.Context) context.Context { newOutbounds[i] = &v } - return ContextWithOutbounds(ctx, newOutbounds) + content := ContentFromContext(ctx) + newContent := Content{} + if content != nil { + newContent = *content + if content.Attributes != nil { + panic("content.Attributes != nil") + } + } + return ContextWithContent(ContextWithOutbounds(ctx, newOutbounds), &newContent) } func OutboundsFromContext(ctx context.Context) []*Outbound { diff --git a/common/session/session.go b/common/session/session.go index cad15400..4de97374 100644 --- a/common/session/session.go +++ b/common/session/session.go @@ -4,7 +4,6 @@ package session // import "github.com/xtls/xray-core/common/session" import ( "context" "math/rand" - "sync" c "github.com/xtls/xray-core/common/ctx" "github.com/xtls/xray-core/common/errors" @@ -75,8 +74,8 @@ type Outbound struct { // SniffingRequest controls the behavior of content sniffing. type SniffingRequest struct { - ExcludeForDomain []string - OverrideDestinationForProtocol []string + ExcludeForDomain []string // read-only once set + OverrideDestinationForProtocol []string // read-only once set Enabled bool MetadataOnly bool RouteOnly bool @@ -92,10 +91,6 @@ type Content struct { Attributes map[string]string SkipDNSResolve bool - - mu sync.Mutex - - isLocked bool } // Sockopt is the settings for socket connection. @@ -104,22 +99,8 @@ type Sockopt struct { Mark int32 } -// Some how when using mux, there will be a same ctx between different requests -// This will cause problem as it's designed for single request, like concurrent map writes -// Add a Mutex as a temp solution - // SetAttribute attaches additional string attributes to content. func (c *Content) SetAttribute(name string, value string) { - if c.isLocked { - errors.LogError(context.Background(), "Multiple goroutines are tring to access one routing content, tring to write ", name, ":", value) - } - c.mu.Lock() - c.isLocked = true - defer func() { - c.isLocked = false - c.mu.Unlock() - }() - if c.Attributes == nil { c.Attributes = make(map[string]string) } @@ -128,24 +109,8 @@ func (c *Content) SetAttribute(name string, value string) { // Attribute retrieves additional string attributes from content. func (c *Content) Attribute(name string) string { - c.mu.Lock() - c.isLocked = true - defer func() { - c.isLocked = false - c.mu.Unlock() - }() if c.Attributes == nil { return "" } return c.Attributes[name] } - -func (c *Content) AttributeLen() int { - c.mu.Lock() - c.isLocked = true - defer func() { - c.isLocked = false - c.mu.Unlock() - }() - return len(c.Attributes) -} From a977b6357ed048546725157c26184bd324015dc7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 09:23:31 +0000 Subject: [PATCH 752/867] Bump golang.org/x/net from 0.35.0 to 0.36.0 (#4462) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.35.0 to 0.36.0. - [Commits](https://github.com/golang/net/compare/v0.35.0...v0.36.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a3bae638..28bbda72 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.35.0 - golang.org/x/net v0.35.0 + golang.org/x/net v0.36.0 golang.org/x/sync v0.11.0 golang.org/x/sys v0.30.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index 9f20efd4..1a4b391a 100644 --- a/go.sum +++ b/go.sum @@ -105,8 +105,8 @@ golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= -golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= +golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA= +golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= From 152959824fbd7b3cf0119bf09d1405230f5c10c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Mar 2025 09:23:38 +0000 Subject: [PATCH 753/867] Bump google.golang.org/grpc from 1.70.0 to 1.71.0 (#4463) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.70.0 to 1.71.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.70.0...v1.71.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 30 ++++++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 28bbda72..d7955e72 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.11.0 golang.org/x/sys v0.30.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.70.0 + google.golang.org/grpc v1.71.0 google.golang.org/protobuf v1.36.5 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 @@ -55,7 +55,7 @@ require ( golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.26.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 1a4b391a..a2c07a9b 100644 --- a/go.sum +++ b/go.sum @@ -79,16 +79,18 @@ github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZla github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= -go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= -go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= -go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= -go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= -go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= -go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= -go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= -go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= -go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= +go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= +go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= +go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= +go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= @@ -141,10 +143,10 @@ golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeu golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a h1:hgh8P4EuoxpsuKMXX/To36nOFD7vixReXgn8lPGnt+o= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241202173237-19429a94021a/go.mod h1:5uTbfoYQed2U9p3KIj2/Zzm02PYhndfdmML0qC3q3FU= -google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ= -google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= +google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg= +google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 6d6f1c6967089e3e8ef4a50addc33de4b7f3c699 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 6 Mar 2025 10:59:49 +0000 Subject: [PATCH 754/867] Bump golang.org/x/net from 0.36.0 to 0.37.0 (#4469) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.36.0 to 0.37.0. - [Commits](https://github.com/golang/net/compare/v0.36.0...v0.37.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index d7955e72..66c86613 100644 --- a/go.mod +++ b/go.mod @@ -22,10 +22,10 @@ require ( github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.35.0 - golang.org/x/net v0.36.0 - golang.org/x/sync v0.11.0 - golang.org/x/sys v0.30.0 + golang.org/x/crypto v0.36.0 + golang.org/x/net v0.37.0 + golang.org/x/sync v0.12.0 + golang.org/x/sys v0.31.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.71.0 google.golang.org/protobuf v1.36.5 @@ -51,7 +51,7 @@ require ( go.uber.org/mock v0.5.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/mod v0.21.0 // indirect - golang.org/x/text v0.22.0 // indirect + golang.org/x/text v0.23.0 // indirect golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.26.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect diff --git a/go.sum b/go.sum index a2c07a9b..93200ef4 100644 --- a/go.sum +++ b/go.sum @@ -97,8 +97,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= -golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= @@ -107,12 +107,12 @@ golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA= -golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= -golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -121,14 +121,14 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 306fa51475503900e12839eef3dccdc5e412fe56 Mon Sep 17 00:00:00 2001 From: Happ-dev Date: Thu, 6 Mar 2025 15:27:25 +0300 Subject: [PATCH 755/867] README.md: Add Happ to iOS clients (#4465) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7b258cff..fd37beb1 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ - [X-flutter](https://github.com/XTLS/X-flutter) - [SaeedDev94/Xray](https://github.com/SaeedDev94/Xray) - iOS & macOS arm64 + - [Happ](https://apps.apple.com/app/happ-proxy-utility/id6504287215) - [FoXray](https://apps.apple.com/app/foxray/id6448898396) - [Streisand](https://apps.apple.com/app/streisand/id6450534064) - macOS arm64 & x64 From 2cba2c4d59e48a04aa5d09b8e4c2b2d26f8608a4 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:50:15 +0000 Subject: [PATCH 756/867] v25.3.6 Announcement of NFTs by Project X: https://github.com/XTLS/Xray-core/discussions/3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index e36a90e2..345f9daf 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 25 Version_y byte = 3 - Version_z byte = 3 + Version_z byte = 6 ) var ( From eca99771cab1f460994e3e9dda528bdb9a7566b4 Mon Sep 17 00:00:00 2001 From: Nikita Korotaev <104270279+iambabyninja@users.noreply.github.com> Date: Thu, 20 Mar 2025 15:50:43 +0500 Subject: [PATCH 757/867] README.md: Add Remnawave to Web Panels (#4498) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fd37beb1..5090d6e8 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ - [teddysun/xray](https://hub.docker.com/r/teddysun/xray) - [wulabing/xray_docker](https://github.com/wulabing/xray_docker) - Web Panel - **WARNING: Please DO NOT USE plain HTTP panels like 3X-UI**, as they are believed to be bribed by Iran GFW for supporting plain HTTP by default and refused to change (https://github.com/XTLS/Xray-core/pull/3884#issuecomment-2439595331), which has already put many users' data security in danger in the past few years. **If you are already using 3X-UI, please switch to the following panels, which are verified to support HTTPS and SSH port forwarding only:** + - [Remnawave](https://github.com/remnawave/panel) - [Marzban](https://github.com/Gozargah/Marzban) - [Xray-UI](https://github.com/qist/xray-ui) - [Hiddify](https://github.com/hiddify/Hiddify-Manager) From 3d2112815990177a0cf02138867c253d6c4915fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Mar 2025 11:06:51 +0000 Subject: [PATCH 758/867] Bump github.com/miekg/dns from 1.1.63 to 1.1.64 (#4506) Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.63 to 1.1.64. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.63...v1.1.64) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 66c86613..be8d7dd4 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.7.0 github.com/gorilla/websocket v1.5.3 - github.com/miekg/dns v1.1.63 + github.com/miekg/dns v1.1.64 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.0 github.com/quic-go/quic-go v0.50.0 @@ -50,10 +50,10 @@ require ( github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.5.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect - golang.org/x/mod v0.21.0 // indirect + golang.org/x/mod v0.23.0 // indirect golang.org/x/text v0.23.0 // indirect golang.org/x/time v0.7.0 // indirect - golang.org/x/tools v0.26.0 // indirect + golang.org/x/tools v0.30.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 93200ef4..43b0b222 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,8 @@ github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0N github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/miekg/dns v1.1.63 h1:8M5aAw6OMZfFXTT7K5V0Eu5YiiL8l7nUAkyN6C9YwaY= -github.com/miekg/dns v1.1.63/go.mod h1:6NGHfjhpmr5lt3XPLuyfDJi5AXbNIPM9PY6H6sF1Nfs= +github.com/miekg/dns v1.1.64 h1:wuZgD9wwCE6XMT05UU/mlSko71eRSXEAm2EbjQXLKnQ= +github.com/miekg/dns v1.1.64/go.mod h1:Dzw9769uoKVaLuODMDZz9M6ynFU6Em65csPuoi8G0ck= github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= @@ -102,8 +102,8 @@ golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZv golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= -golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= +golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -134,8 +134,8 @@ golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= -golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= +golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY= +golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From b70d0abebe393b1296aa1934eca0751692f8cc73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 20 Mar 2025 19:12:36 +0800 Subject: [PATCH 759/867] API: Fix data race in online ipList (#4513) Fixes https://github.com/XTLS/Xray-core/issues/4512 --- app/stats/online_map.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/stats/online_map.go b/app/stats/online_map.go index 9505b28b..7cc6ac96 100644 --- a/app/stats/online_map.go +++ b/app/stats/online_map.go @@ -40,11 +40,11 @@ func (c *OnlineMap) AddIP(ip string) { if ip == "127.0.0.1" { return } + c.access.Lock() if _, ok := list[ip]; !ok { - c.access.Lock() list[ip] = time.Now() - c.access.Unlock() } + c.access.Unlock() if time.Since(c.lastCleanup) > c.cleanupPeriod { list = c.RemoveExpiredIPs(list) c.lastCleanup = time.Now() From 335845a9b2ffb3ec22474d586d2f98d3a0f65929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 20 Mar 2025 19:21:21 +0800 Subject: [PATCH 760/867] DNS: Ensure order for DNS server match (#4510) Fixes https://github.com/XTLS/Xray-core/issues/4508 --- app/dns/dns.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/dns/dns.go b/app/dns/dns.go index db59f292..bc544a5a 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -4,6 +4,7 @@ package dns import ( "context" "fmt" + "sort" "strings" "sync" @@ -250,7 +251,11 @@ func (s *DNS) sortClients(domain string) []*Client { // Priority domain matching hasMatch := false - for _, match := range s.domainMatcher.Match(domain) { + MatchSlice := s.domainMatcher.Match(domain) + sort.Slice(MatchSlice, func(i, j int) bool { + return MatchSlice[i] < MatchSlice[j] + }) + for _, match := range MatchSlice { info := s.matcherInfos[match] client := s.clients[info.clientIdx] domainRule := client.domains[info.domainRuleIdx] From 6a211a0bb92a2dac8cbd85673f080cb98dfd40ee Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Thu, 20 Mar 2025 13:09:02 +0100 Subject: [PATCH 761/867] DNS: Add `allowUnexpectedIPs` for DnsServerObject (#4497) Closes https://github.com/XTLS/Xray-core/issues/4424 --- app/dns/config.pb.go | 29 +++++++++++++++++++--------- app/dns/config.proto | 1 + app/dns/nameserver.go | 15 ++++++++++----- infra/conf/dns.go | 44 +++++++++++++++++++++++-------------------- 4 files changed, 55 insertions(+), 34 deletions(-) diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index 05fd6099..33dc904b 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -128,13 +128,14 @@ type NameServer struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address *net.Endpoint `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - ClientIp []byte `protobuf:"bytes,5,opt,name=client_ip,json=clientIp,proto3" json:"client_ip,omitempty"` - SkipFallback bool `protobuf:"varint,6,opt,name=skipFallback,proto3" json:"skipFallback,omitempty"` - PrioritizedDomain []*NameServer_PriorityDomain `protobuf:"bytes,2,rep,name=prioritized_domain,json=prioritizedDomain,proto3" json:"prioritized_domain,omitempty"` - Geoip []*router.GeoIP `protobuf:"bytes,3,rep,name=geoip,proto3" json:"geoip,omitempty"` - OriginalRules []*NameServer_OriginalRule `protobuf:"bytes,4,rep,name=original_rules,json=originalRules,proto3" json:"original_rules,omitempty"` - QueryStrategy QueryStrategy `protobuf:"varint,7,opt,name=query_strategy,json=queryStrategy,proto3,enum=xray.app.dns.QueryStrategy" json:"query_strategy,omitempty"` + Address *net.Endpoint `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + ClientIp []byte `protobuf:"bytes,5,opt,name=client_ip,json=clientIp,proto3" json:"client_ip,omitempty"` + SkipFallback bool `protobuf:"varint,6,opt,name=skipFallback,proto3" json:"skipFallback,omitempty"` + PrioritizedDomain []*NameServer_PriorityDomain `protobuf:"bytes,2,rep,name=prioritized_domain,json=prioritizedDomain,proto3" json:"prioritized_domain,omitempty"` + Geoip []*router.GeoIP `protobuf:"bytes,3,rep,name=geoip,proto3" json:"geoip,omitempty"` + OriginalRules []*NameServer_OriginalRule `protobuf:"bytes,4,rep,name=original_rules,json=originalRules,proto3" json:"original_rules,omitempty"` + QueryStrategy QueryStrategy `protobuf:"varint,7,opt,name=query_strategy,json=queryStrategy,proto3,enum=xray.app.dns.QueryStrategy" json:"query_strategy,omitempty"` + AllowUnexpectedIPs bool `protobuf:"varint,8,opt,name=allowUnexpectedIPs,proto3" json:"allowUnexpectedIPs,omitempty"` } func (x *NameServer) Reset() { @@ -216,6 +217,13 @@ func (x *NameServer) GetQueryStrategy() QueryStrategy { return QueryStrategy_USE_IP } +func (x *NameServer) GetAllowUnexpectedIPs() bool { + if x != nil { + return x.AllowUnexpectedIPs + } + return false +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -508,7 +516,7 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x1c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb2, 0x04, 0x0a, 0x0a, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe2, 0x04, 0x0a, 0x0a, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, @@ -534,7 +542,10 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, - 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, 0x69, 0x6f, + 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x2e, 0x0a, 0x12, 0x61, 0x6c, 0x6c, 0x6f, + 0x77, 0x55, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x55, 0x6e, 0x65, 0x78, 0x70, + 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, diff --git a/app/dns/config.proto b/app/dns/config.proto index 11e0c8de..ea4d5e31 100644 --- a/app/dns/config.proto +++ b/app/dns/config.proto @@ -28,6 +28,7 @@ message NameServer { repeated xray.app.router.GeoIP geoip = 3; repeated OriginalRule original_rules = 4; QueryStrategy query_strategy = 7; + bool allowUnexpectedIPs = 8; } enum DomainMatchingType { diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index b23cb186..e1f902bf 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -25,11 +25,12 @@ type Server interface { // Client is the interface for DNS client. type Client struct { - server Server - clientIP net.IP - skipFallback bool - domains []string - expectIPs []*router.GeoIPMatcher + server Server + clientIP net.IP + skipFallback bool + domains []string + expectIPs []*router.GeoIPMatcher + allowUnexpectedIPs bool } var errExpectedIPNonMatch = errors.New("expectIPs not match") @@ -166,6 +167,7 @@ func NewClient( client.skipFallback = ns.SkipFallback client.domains = rules client.expectIPs = matchers + client.allowUnexpectedIPs = ns.AllowUnexpectedIPs return nil }) return client, err @@ -203,6 +205,9 @@ func (c *Client) MatchExpectedIPs(domain string, ips []net.IP) ([]net.IP, error) } } if len(newIps) == 0 { + if c.allowUnexpectedIPs { + return ips, nil + } return nil, errExpectedIPNonMatch } errors.LogDebug(context.Background(), "domain ", domain, " expectIPs ", newIps, " matched at server ", c.Name()) diff --git a/infra/conf/dns.go b/infra/conf/dns.go index 65964f3d..b2289026 100644 --- a/infra/conf/dns.go +++ b/infra/conf/dns.go @@ -12,13 +12,14 @@ import ( ) type NameServerConfig struct { - Address *Address `json:"address"` - ClientIP *Address `json:"clientIp"` - Port uint16 `json:"port"` - SkipFallback bool `json:"skipFallback"` - Domains []string `json:"domains"` - ExpectIPs StringList `json:"expectIps"` - QueryStrategy string `json:"queryStrategy"` + Address *Address `json:"address"` + ClientIP *Address `json:"clientIp"` + Port uint16 `json:"port"` + SkipFallback bool `json:"skipFallback"` + Domains []string `json:"domains"` + ExpectIPs StringList `json:"expectIps"` + QueryStrategy string `json:"queryStrategy"` + AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` } func (c *NameServerConfig) UnmarshalJSON(data []byte) error { @@ -29,13 +30,14 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { } var advanced struct { - Address *Address `json:"address"` - ClientIP *Address `json:"clientIp"` - Port uint16 `json:"port"` - SkipFallback bool `json:"skipFallback"` - Domains []string `json:"domains"` - ExpectIPs StringList `json:"expectIps"` - QueryStrategy string `json:"queryStrategy"` + Address *Address `json:"address"` + ClientIP *Address `json:"clientIp"` + Port uint16 `json:"port"` + SkipFallback bool `json:"skipFallback"` + Domains []string `json:"domains"` + ExpectIPs StringList `json:"expectIps"` + QueryStrategy string `json:"queryStrategy"` + AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` } if err := json.Unmarshal(data, &advanced); err == nil { c.Address = advanced.Address @@ -45,6 +47,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { c.Domains = advanced.Domains c.ExpectIPs = advanced.ExpectIPs c.QueryStrategy = advanced.QueryStrategy + c.AllowUnexpectedIPs = advanced.AllowUnexpectedIPs return nil } @@ -111,12 +114,13 @@ func (c *NameServerConfig) Build() (*dns.NameServer, error) { Address: c.Address.Build(), Port: uint32(c.Port), }, - ClientIp: myClientIP, - SkipFallback: c.SkipFallback, - PrioritizedDomain: domains, - Geoip: geoipList, - OriginalRules: originalRules, - QueryStrategy: resolveQueryStrategy(c.QueryStrategy), + ClientIp: myClientIP, + SkipFallback: c.SkipFallback, + PrioritizedDomain: domains, + Geoip: geoipList, + OriginalRules: originalRules, + QueryStrategy: resolveQueryStrategy(c.QueryStrategy), + AllowUnexpectedIPs: c.AllowUnexpectedIPs, }, nil } From 6f8e253dec926ce324cceba16c7d2d6eb7a46b9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 21 Mar 2025 08:18:59 +0800 Subject: [PATCH 762/867] DNS: Add `tag` for DnsServerObject (#4515) Closes https://github.com/XTLS/Xray-core/issues/4505 --- app/dns/config.pb.go | 123 ++++++++++++++++++++++-------------------- app/dns/config.proto | 1 + app/dns/nameserver.go | 10 ++++ infra/conf/dns.go | 4 ++ 4 files changed, 81 insertions(+), 57 deletions(-) diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index 33dc904b..7f6888a3 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -136,6 +136,7 @@ type NameServer struct { OriginalRules []*NameServer_OriginalRule `protobuf:"bytes,4,rep,name=original_rules,json=originalRules,proto3" json:"original_rules,omitempty"` QueryStrategy QueryStrategy `protobuf:"varint,7,opt,name=query_strategy,json=queryStrategy,proto3,enum=xray.app.dns.QueryStrategy" json:"query_strategy,omitempty"` AllowUnexpectedIPs bool `protobuf:"varint,8,opt,name=allowUnexpectedIPs,proto3" json:"allowUnexpectedIPs,omitempty"` + Tag string `protobuf:"bytes,9,opt,name=tag,proto3" json:"tag,omitempty"` } func (x *NameServer) Reset() { @@ -224,6 +225,13 @@ func (x *NameServer) GetAllowUnexpectedIPs() bool { return false } +func (x *NameServer) GetTag() string { + if x != nil { + return x.Tag + } + return "" +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -516,7 +524,7 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x1c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe2, 0x04, 0x0a, 0x0a, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf4, 0x04, 0x0a, 0x0a, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, @@ -545,63 +553,64 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x2e, 0x0a, 0x12, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x55, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x55, 0x6e, 0x65, 0x78, 0x70, - 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, 0x69, 0x6f, - 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, - 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x36, 0x0a, 0x0c, 0x4f, 0x72, 0x69, 0x67, - 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, - 0x22, 0x9c, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x0b, 0x6e, - 0x61, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, - 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, - 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x49, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, - 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x0b, 0x73, 0x74, 0x61, - 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, - 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x42, - 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, - 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, - 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x64, 0x69, 0x73, - 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x36, 0x0a, 0x16, + 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, + 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, + 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x36, 0x0a, 0x0c, 0x4f, 0x72, + 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x75, + 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x12, + 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, + 0x7a, 0x65, 0x22, 0x9c, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, + 0x0b, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, + 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0a, 0x6e, 0x61, + 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6c, 0x69, + 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, + 0x68, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x0b, 0x73, + 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, + 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x22, 0x0a, 0x0c, + 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, + 0x12, 0x42, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x67, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, + 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x64, + 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x36, + 0x0a, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, - 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x64, 0x69, - 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, 0x66, 0x4d, - 0x61, 0x74, 0x63, 0x68, 0x1a, 0x92, 0x01, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, - 0x70, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, - 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, - 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x02, - 0x69, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x5f, 0x64, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, - 0x69, 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x2a, - 0x45, 0x0a, 0x12, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, - 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, - 0x0d, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x01, 0x12, 0x0b, - 0x0a, 0x07, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x52, - 0x65, 0x67, 0x65, 0x78, 0x10, 0x03, 0x2a, 0x35, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, - 0x50, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x01, - 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x42, 0x46, 0x0a, - 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, - 0x73, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, - 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, - 0x70, 0x2e, 0x44, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x1a, 0x92, 0x01, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x4d, + 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, + 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, + 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, + 0x52, 0x02, 0x69, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x5f, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, + 0x6f, 0x78, 0x69, 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x07, 0x10, + 0x08, 0x2a, 0x45, 0x0a, 0x12, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, + 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, + 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x01, + 0x12, 0x0b, 0x0a, 0x07, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x02, 0x12, 0x09, 0x0a, + 0x05, 0x52, 0x65, 0x67, 0x65, 0x78, 0x10, 0x03, 0x2a, 0x35, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, + 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, + 0x5f, 0x49, 0x50, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, + 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x42, + 0x46, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x64, 0x6e, 0x73, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, + 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, + 0x41, 0x70, 0x70, 0x2e, 0x44, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/app/dns/config.proto b/app/dns/config.proto index ea4d5e31..03c8a333 100644 --- a/app/dns/config.proto +++ b/app/dns/config.proto @@ -29,6 +29,7 @@ message NameServer { repeated OriginalRule original_rules = 4; QueryStrategy query_strategy = 7; bool allowUnexpectedIPs = 8; + string tag = 9; } enum DomainMatchingType { diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index e1f902bf..d46c00b7 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -9,6 +9,7 @@ import ( "github.com/xtls/xray-core/app/router" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/common/strmatcher" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/dns" @@ -31,6 +32,7 @@ type Client struct { domains []string expectIPs []*router.GeoIPMatcher allowUnexpectedIPs bool + tag string } var errExpectedIPNonMatch = errors.New("expectIPs not match") @@ -168,6 +170,7 @@ func NewClient( client.domains = rules client.expectIPs = matchers client.allowUnexpectedIPs = ns.AllowUnexpectedIPs + client.tag = ns.Tag return nil }) return client, err @@ -181,6 +184,13 @@ func (c *Client) Name() string { // QueryIP sends DNS query to the name server with the client's IP. func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption, disableCache bool) ([]net.IP, error) { ctx, cancel := context.WithTimeout(ctx, 4*time.Second) + if len(c.tag) != 0 { + content := session.InboundFromContext(ctx) + errors.LogDebug(ctx, "DNS: client override tag from ", content.Tag, " to ", c.tag) + // create a new context to override the tag + // do not direct set *content.Tag, it might be used by other clients + ctx = session.ContextWithInbound(ctx, &session.Inbound{Tag: c.tag}) + } ips, err := c.server.QueryIP(ctx, domain, c.clientIP, option, disableCache) cancel() diff --git a/infra/conf/dns.go b/infra/conf/dns.go index b2289026..f2e91573 100644 --- a/infra/conf/dns.go +++ b/infra/conf/dns.go @@ -20,6 +20,7 @@ type NameServerConfig struct { ExpectIPs StringList `json:"expectIps"` QueryStrategy string `json:"queryStrategy"` AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` + Tag string `json:"tag"` } func (c *NameServerConfig) UnmarshalJSON(data []byte) error { @@ -38,6 +39,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { ExpectIPs StringList `json:"expectIps"` QueryStrategy string `json:"queryStrategy"` AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` + Tag string `json:"tag"` } if err := json.Unmarshal(data, &advanced); err == nil { c.Address = advanced.Address @@ -48,6 +50,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { c.ExpectIPs = advanced.ExpectIPs c.QueryStrategy = advanced.QueryStrategy c.AllowUnexpectedIPs = advanced.AllowUnexpectedIPs + c.Tag = advanced.Tag return nil } @@ -121,6 +124,7 @@ func (c *NameServerConfig) Build() (*dns.NameServer, error) { OriginalRules: originalRules, QueryStrategy: resolveQueryStrategy(c.QueryStrategy), AllowUnexpectedIPs: c.AllowUnexpectedIPs, + Tag: c.Tag, }, nil } From 86a225cda1b2f26014ae32cf27d6883a6433d2a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 21 Mar 2025 08:22:04 +0800 Subject: [PATCH 763/867] DNS: Retry with EDNS0 when response is truncated (#4516) --- app/dns/dnscommon.go | 16 +++++++++------- app/dns/dnscommon_test.go | 8 +++++--- app/dns/nameserver_udp.go | 40 ++++++++++++++++++++++++++++++++++----- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/app/dns/dnscommon.go b/app/dns/dnscommon.go index 42f9da2c..c2689d6d 100644 --- a/app/dns/dnscommon.go +++ b/app/dns/dnscommon.go @@ -31,10 +31,11 @@ type record struct { // IPRecord is a cacheable item for a resolved domain type IPRecord struct { - ReqID uint16 - IP []net.Address - Expire time.Time - RCode dnsmessage.RCode + ReqID uint16 + IP []net.Address + Expire time.Time + RCode dnsmessage.RCode + RawHeader *dnsmessage.Header } func (r *IPRecord) getIPs() ([]net.Address, error) { @@ -179,9 +180,10 @@ func parseResponse(payload []byte) (*IPRecord, error) { now := time.Now() ipRecord := &IPRecord{ - ReqID: h.ID, - RCode: h.RCode, - Expire: now.Add(time.Second * 600), + ReqID: h.ID, + RCode: h.RCode, + Expire: now.Add(time.Second * 600), + RawHeader: &h, } L: diff --git a/app/dns/dnscommon_test.go b/app/dns/dnscommon_test.go index d11f8632..4c6f9d73 100644 --- a/app/dns/dnscommon_test.go +++ b/app/dns/dnscommon_test.go @@ -51,7 +51,7 @@ func Test_parseResponse(t *testing.T) { }{ { "empty", - &IPRecord{0, []net.Address(nil), time.Time{}, dnsmessage.RCodeSuccess}, + &IPRecord{0, []net.Address(nil), time.Time{}, dnsmessage.RCodeSuccess, nil}, false, }, { @@ -66,12 +66,13 @@ func Test_parseResponse(t *testing.T) { []net.Address{net.ParseAddress("8.8.8.8"), net.ParseAddress("8.8.4.4")}, time.Time{}, dnsmessage.RCodeSuccess, + nil, }, false, }, { "aaaa record", - &IPRecord{2, []net.Address{net.ParseAddress("2001::123:8888"), net.ParseAddress("2001::123:8844")}, time.Time{}, dnsmessage.RCodeSuccess}, + &IPRecord{2, []net.Address{net.ParseAddress("2001::123:8888"), net.ParseAddress("2001::123:8844")}, time.Time{}, dnsmessage.RCodeSuccess, nil}, false, }, } @@ -84,8 +85,9 @@ func Test_parseResponse(t *testing.T) { } if got != nil { - // reset the time + // reset the time and RawHeader got.Expire = time.Time{} + got.RawHeader = nil } if cmp.Diff(got, tt.want) != "" { t.Error(cmp.Diff(got, tt.want)) diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index 47d70435..967576bc 100644 --- a/app/dns/nameserver_udp.go +++ b/app/dns/nameserver_udp.go @@ -27,7 +27,7 @@ type ClassicNameServer struct { name string address *net.Destination ips map[string]*record - requests map[uint16]*dnsRequest + requests map[uint16]*udpDnsRequest pub *pubsub.Service udpServer *udp.Dispatcher cleanup *task.Periodic @@ -35,6 +35,11 @@ type ClassicNameServer struct { queryStrategy QueryStrategy } +type udpDnsRequest struct { + dnsRequest + ctx context.Context +} + // NewClassicNameServer creates udp server object for remote resolving. func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) *ClassicNameServer { // default to 53 if unspecific @@ -45,7 +50,7 @@ func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher s := &ClassicNameServer{ address: &address, ips: make(map[string]*record), - requests: make(map[uint16]*dnsRequest), + requests: make(map[uint16]*udpDnsRequest), pub: pubsub.NewService(), name: strings.ToUpper(address.String()), queryStrategy: queryStrategy, @@ -101,7 +106,7 @@ func (s *ClassicNameServer) Cleanup() error { } if len(s.requests) == 0 { - s.requests = make(map[uint16]*dnsRequest) + s.requests = make(map[uint16]*udpDnsRequest) } return nil @@ -128,6 +133,27 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, packet *udp_prot return } + // if truncated, retry with EDNS0 option(udp payload size: 1350) + if ipRec.RawHeader.Truncated { + // if already has EDNS0 option, no need to retry + if ok && len(req.msg.Additionals) == 0 { + // copy necessary meta data from original request + // and add EDNS0 option + opt := new(dnsmessage.Resource) + common.Must(opt.Header.SetEDNS0(1350, 0xfe00, true)) + opt.Body = &dnsmessage.OPTResource{} + newMsg := *req.msg + newReq := *req + newMsg.Additionals = append(newMsg.Additionals, *opt) + newMsg.ID = s.newReqID() + newReq.msg = &newMsg + s.addPendingRequest(&newReq) + b, _ := dns.PackMessage(newReq.msg) + s.udpServer.Dispatch(toDnsContext(newReq.ctx, s.address.String()), *s.address, b) + return + } + } + var rec record switch req.reqType { case dnsmessage.TypeA: @@ -179,7 +205,7 @@ func (s *ClassicNameServer) newReqID() uint16 { return uint16(atomic.AddUint32(&s.reqID, 1)) } -func (s *ClassicNameServer) addPendingRequest(req *dnsRequest) { +func (s *ClassicNameServer) addPendingRequest(req *udpDnsRequest) { s.Lock() defer s.Unlock() @@ -194,7 +220,11 @@ func (s *ClassicNameServer) sendQuery(ctx context.Context, domain string, client reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP)) for _, req := range reqs { - s.addPendingRequest(req) + udpReq := &udpDnsRequest{ + dnsRequest: *req, + ctx: ctx, + } + s.addPendingRequest(udpReq) b, _ := dns.PackMessage(req.msg) s.udpServer.Dispatch(toDnsContext(ctx, s.address.String()), *s.address, b) } From 1067171e6abb2d7d12e0817248d8a2b4959868af Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Fri, 21 Mar 2025 13:54:58 +0330 Subject: [PATCH 764/867] DNS: Add `timeoutMs` for DnsServerObject (#4523) --- app/dns/config.pb.go | 124 +++++++++++++++++++++++------------------- app/dns/config.proto | 1 + app/dns/nameserver.go | 13 ++++- infra/conf/dns.go | 4 ++ 4 files changed, 83 insertions(+), 59 deletions(-) diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index 7f6888a3..67fbd84e 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -137,6 +137,7 @@ type NameServer struct { QueryStrategy QueryStrategy `protobuf:"varint,7,opt,name=query_strategy,json=queryStrategy,proto3,enum=xray.app.dns.QueryStrategy" json:"query_strategy,omitempty"` AllowUnexpectedIPs bool `protobuf:"varint,8,opt,name=allowUnexpectedIPs,proto3" json:"allowUnexpectedIPs,omitempty"` Tag string `protobuf:"bytes,9,opt,name=tag,proto3" json:"tag,omitempty"` + TimeoutMs uint64 `protobuf:"varint,10,opt,name=timeoutMs,proto3" json:"timeoutMs,omitempty"` } func (x *NameServer) Reset() { @@ -232,6 +233,13 @@ func (x *NameServer) GetTag() string { return "" } +func (x *NameServer) GetTimeoutMs() uint64 { + if x != nil { + return x.TimeoutMs + } + return 0 +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -524,7 +532,7 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x1c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xf4, 0x04, 0x0a, 0x0a, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x92, 0x05, 0x0a, 0x0a, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, @@ -554,63 +562,65 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x77, 0x55, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x55, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, - 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, - 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x36, 0x0a, 0x0c, 0x4f, 0x72, - 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x75, - 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x12, - 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, - 0x7a, 0x65, 0x22, 0x9c, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, - 0x0b, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, - 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0a, 0x6e, 0x61, - 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6c, 0x69, - 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, - 0x68, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, - 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x0b, 0x73, - 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, - 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x22, 0x0a, 0x0c, - 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, - 0x12, 0x42, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x67, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, - 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x64, - 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x36, - 0x0a, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, + 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, + 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x4d, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x4d, 0x73, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, 0x69, 0x6f, + 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, + 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x36, 0x0a, 0x0c, 0x4f, 0x72, 0x69, 0x67, + 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, + 0x22, 0x9c, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x0b, 0x6e, + 0x61, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, + 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, + 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x49, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, + 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, + 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, + 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x0b, 0x73, 0x74, 0x61, + 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, + 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x42, + 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, + 0x67, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x64, 0x69, 0x73, + 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x36, 0x0a, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, - 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x1a, 0x92, 0x01, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x4d, - 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, - 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, - 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, - 0x52, 0x02, 0x69, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x5f, - 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, - 0x6f, 0x78, 0x69, 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x07, 0x10, - 0x08, 0x2a, 0x45, 0x0a, 0x12, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, - 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, - 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x01, - 0x12, 0x0b, 0x0a, 0x07, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x02, 0x12, 0x09, 0x0a, - 0x05, 0x52, 0x65, 0x67, 0x65, 0x78, 0x10, 0x03, 0x2a, 0x35, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, - 0x5f, 0x49, 0x50, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, - 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x42, - 0x46, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, - 0x64, 0x6e, 0x73, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, - 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, - 0x41, 0x70, 0x70, 0x2e, 0x44, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x64, 0x69, + 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, 0x66, 0x4d, + 0x61, 0x74, 0x63, 0x68, 0x1a, 0x92, 0x01, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, + 0x70, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, + 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, + 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, + 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, + 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x02, + 0x69, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x5f, 0x64, 0x6f, + 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, + 0x69, 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x2a, + 0x45, 0x0a, 0x12, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, + 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, + 0x0d, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x01, 0x12, 0x0b, + 0x0a, 0x07, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x52, + 0x65, 0x67, 0x65, 0x78, 0x10, 0x03, 0x2a, 0x35, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, + 0x50, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x01, + 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x42, 0x46, 0x0a, + 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, + 0x73, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, + 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, + 0x70, 0x2e, 0x44, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/app/dns/config.proto b/app/dns/config.proto index 03c8a333..8935ffa8 100644 --- a/app/dns/config.proto +++ b/app/dns/config.proto @@ -30,6 +30,7 @@ message NameServer { QueryStrategy query_strategy = 7; bool allowUnexpectedIPs = 8; string tag = 9; + uint64 timeoutMs = 10; } enum DomainMatchingType { diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index d46c00b7..14513b3b 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -32,7 +32,8 @@ type Client struct { domains []string expectIPs []*router.GeoIPMatcher allowUnexpectedIPs bool - tag string + tag string + timeoutMs time.Duration } var errExpectedIPNonMatch = errors.New("expectIPs not match") @@ -164,6 +165,13 @@ func NewClient( } } + var timeoutMs time.Duration + if ns.TimeoutMs > 0 { + timeoutMs = time.Duration(ns.TimeoutMs) * time.Millisecond + } else { + timeoutMs = 4000 * time.Millisecond + } + client.server = server client.clientIP = clientIP client.skipFallback = ns.SkipFallback @@ -171,6 +179,7 @@ func NewClient( client.expectIPs = matchers client.allowUnexpectedIPs = ns.AllowUnexpectedIPs client.tag = ns.Tag + client.timeoutMs = timeoutMs return nil }) return client, err @@ -183,7 +192,7 @@ func (c *Client) Name() string { // QueryIP sends DNS query to the name server with the client's IP. func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption, disableCache bool) ([]net.IP, error) { - ctx, cancel := context.WithTimeout(ctx, 4*time.Second) + ctx, cancel := context.WithTimeout(ctx, c.timeoutMs) if len(c.tag) != 0 { content := session.InboundFromContext(ctx) errors.LogDebug(ctx, "DNS: client override tag from ", content.Tag, " to ", c.tag) diff --git a/infra/conf/dns.go b/infra/conf/dns.go index f2e91573..20051447 100644 --- a/infra/conf/dns.go +++ b/infra/conf/dns.go @@ -21,6 +21,7 @@ type NameServerConfig struct { QueryStrategy string `json:"queryStrategy"` AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` Tag string `json:"tag"` + TimeoutMs uint64 `json:"timeoutMs"` } func (c *NameServerConfig) UnmarshalJSON(data []byte) error { @@ -40,6 +41,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { QueryStrategy string `json:"queryStrategy"` AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` Tag string `json:"tag"` + TimeoutMs uint64 `json:"timeoutMs"` } if err := json.Unmarshal(data, &advanced); err == nil { c.Address = advanced.Address @@ -51,6 +53,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { c.QueryStrategy = advanced.QueryStrategy c.AllowUnexpectedIPs = advanced.AllowUnexpectedIPs c.Tag = advanced.Tag + c.TimeoutMs = advanced.TimeoutMs return nil } @@ -125,6 +128,7 @@ func (c *NameServerConfig) Build() (*dns.NameServer, error) { QueryStrategy: resolveQueryStrategy(c.QueryStrategy), AllowUnexpectedIPs: c.AllowUnexpectedIPs, Tag: c.Tag, + TimeoutMs: c.TimeoutMs, }, nil } From b585b26f29e9a3ce2d32f01c9987e6c410e58988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 21 Mar 2025 18:48:46 +0800 Subject: [PATCH 765/867] Sockopt: Fix Windows UDP `interface` bind; Allow `customSockopt` work for UDP (#4504) --- infra/conf/transport_internet.go | 18 ++- transport/internet/config.pb.go | 212 ++++++++++++++------------ transport/internet/config.proto | 9 +- transport/internet/sockopt_linux.go | 57 ++++--- transport/internet/sockopt_windows.go | 2 +- transport/internet/system_dialer.go | 8 +- 6 files changed, 169 insertions(+), 137 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 78bd76fe..2d73e524 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -691,10 +691,11 @@ func (p TransportProtocol) Build() (string, error) { } type CustomSockoptConfig struct { - Level string `json:"level"` - Opt string `json:"opt"` - Value string `json:"value"` - Type string `json:"type"` + Network string `json:"network"` + Level string `json:"level"` + Opt string `json:"opt"` + Value string `json:"value"` + Type string `json:"type"` } type SocketConfig struct { @@ -777,10 +778,11 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { for _, copt := range c.CustomSockopt { customSockopt := &internet.CustomSockopt{ - Level: copt.Level, - Opt: copt.Opt, - Value: copt.Value, - Type: copt.Type, + Network: copt.Network, + Level: copt.Level, + Opt: copt.Opt, + Value: copt.Value, + Type: copt.Type, } customSockopts = append(customSockopts, customSockopt) } diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index ae1b38f3..37a08143 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -417,10 +417,11 @@ type CustomSockopt struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Level string `protobuf:"bytes,1,opt,name=level,proto3" json:"level,omitempty"` - Opt string `protobuf:"bytes,2,opt,name=opt,proto3" json:"opt,omitempty"` - Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` - Type string `protobuf:"bytes,4,opt,name=type,proto3" json:"type,omitempty"` + Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"` + Level string `protobuf:"bytes,2,opt,name=level,proto3" json:"level,omitempty"` + Opt string `protobuf:"bytes,3,opt,name=opt,proto3" json:"opt,omitempty"` + Value string `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` + Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` } func (x *CustomSockopt) Reset() { @@ -453,6 +454,13 @@ func (*CustomSockopt) Descriptor() ([]byte, []int) { return file_transport_internet_config_proto_rawDescGZIP(), []int{3} } +func (x *CustomSockopt) GetNetwork() string { + if x != nil { + return x.Network + } + return "" +} + func (x *CustomSockopt) GetLevel() string { if x != nil { return x.Level @@ -740,105 +748,107 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x30, 0x0a, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x22, 0x61, + 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x22, 0x7b, 0x0a, 0x0d, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x12, - 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x22, 0xfd, 0x07, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x06, 0x74, 0x70, 0x72, 0x6f, - 0x78, 0x79, 0x12, 0x41, 0x0a, 0x1d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x6f, 0x72, - 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, 0x65, 0x63, 0x65, 0x69, - 0x76, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x73, 0x74, 0x41, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x61, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x69, 0x6e, - 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x69, 0x6e, 0x64, - 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x62, 0x69, 0x6e, - 0x64, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, - 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x50, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x08, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x44, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x64, - 0x69, 0x61, 0x6c, 0x65, 0x72, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x35, - 0x0a, 0x17, 0x74, 0x63, 0x70, 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, - 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x14, 0x74, 0x63, 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, - 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x2d, 0x0a, 0x13, 0x74, 0x63, 0x70, 0x5f, 0x6b, 0x65, 0x65, - 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x64, 0x6c, 0x65, 0x18, 0x0b, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x10, 0x74, 0x63, 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, - 0x49, 0x64, 0x6c, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x67, - 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x63, - 0x70, 0x43, 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x36, 0x6f, - 0x6e, 0x6c, 0x79, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, - 0x79, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, - 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, - 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, 0x74, - 0x63, 0x70, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, - 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, 0x72, 0x54, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x61, 0x78, - 0x5f, 0x73, 0x65, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x63, 0x70, 0x4d, - 0x61, 0x78, 0x53, 0x65, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x65, 0x6e, 0x65, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x70, 0x65, 0x6e, 0x65, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x70, 0x74, 0x63, 0x70, - 0x18, 0x13, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74, 0x63, 0x70, 0x4d, 0x70, 0x74, 0x63, 0x70, - 0x12, 0x4c, 0x0a, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, - 0x74, 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x52, - 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x12, 0x60, - 0x0a, 0x15, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2c, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, - 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, - 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x13, 0x61, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, - 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, - 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, - 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, - 0x02, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, - 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, - 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, - 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, - 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, - 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, - 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, - 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, - 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, - 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, - 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x2a, 0x97, 0x01, - 0x0a, 0x13, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, - 0x0f, 0x0a, 0x0b, 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x01, - 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x72, 0x76, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, - 0x6c, 0x79, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x41, - 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x54, - 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, - 0x54, 0x78, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x05, - 0x12, 0x15, 0x0a, 0x11, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x06, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, + 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, + 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, + 0x10, 0x0a, 0x03, 0x6f, 0x70, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x70, + 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xfd, 0x07, 0x0a, 0x0c, + 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, + 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, + 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, + 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, + 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, + 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, + 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x06, 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x41, 0x0a, 0x1d, + 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, + 0x5f, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x69, 0x67, + 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, + 0x21, 0x0a, 0x0c, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x62, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x12, + 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, + 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x63, 0x6f, 0x6c, 0x12, 0x50, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, - 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, 0x5f, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x61, + 0x6c, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x35, 0x0a, 0x17, 0x74, 0x63, 0x70, 0x5f, + 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x76, 0x61, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x14, 0x74, 0x63, 0x70, 0x4b, 0x65, + 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, + 0x2d, 0x0a, 0x13, 0x74, 0x63, 0x70, 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, + 0x65, 0x5f, 0x69, 0x64, 0x6c, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, 0x63, + 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x64, 0x6c, 0x65, 0x12, 0x25, + 0x0a, 0x0e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x63, 0x70, 0x43, 0x6f, 0x6e, 0x67, 0x65, + 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, + 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, + 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0e, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x12, 0x28, 0x0a, 0x10, 0x74, + 0x63, 0x70, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x18, + 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, + 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, + 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x65, 0x67, 0x18, 0x11, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x63, 0x70, 0x4d, 0x61, 0x78, 0x53, 0x65, 0x67, 0x12, + 0x1c, 0x0a, 0x09, 0x70, 0x65, 0x6e, 0x65, 0x74, 0x72, 0x61, 0x74, 0x65, 0x18, 0x12, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x09, 0x70, 0x65, 0x6e, 0x65, 0x74, 0x72, 0x61, 0x74, 0x65, 0x12, 0x1b, 0x0a, + 0x09, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x70, 0x74, 0x63, 0x70, 0x18, 0x13, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x08, 0x74, 0x63, 0x70, 0x4d, 0x70, 0x74, 0x63, 0x70, 0x12, 0x4c, 0x0a, 0x0d, 0x63, 0x75, + 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x18, 0x14, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, + 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x43, 0x75, 0x73, 0x74, + 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x52, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, + 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x12, 0x60, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, + 0x79, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, + 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, + 0x74, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, + 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x13, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, + 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, + 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, + 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, + 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, + 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, + 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, + 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, + 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, + 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, + 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, + 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, + 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, + 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, + 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x2a, 0x97, 0x01, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, + 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x72, 0x76, + 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x72, + 0x76, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x02, 0x12, 0x15, + 0x0a, 0x11, 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, + 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x54, 0x78, 0x74, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x78, + 0x74, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, + 0x06, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, + 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/transport/internet/config.proto b/transport/internet/config.proto index d51998b2..54479e22 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -65,10 +65,11 @@ message ProxyConfig { } message CustomSockopt { - string level = 1; - string opt = 2; - string value = 3; - string type = 4; + string network = 1; + string level = 2; + string opt = 3; + string value = 4; + string type = 5; } // SocketConfig is options to be applied on network sockets. diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index 8f14fe66..2d5877ab 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -3,6 +3,7 @@ package internet import ( "net" "strconv" + "strings" "syscall" "github.com/xtls/xray-core/common/errors" @@ -35,6 +36,8 @@ func bindAddr(fd uintptr, ip []byte, port uint32) error { return syscall.Bind(int(fd), sockaddr) } +// applyOutboundSocketOptions applies socket options for outbound connection. +// note that unlike other part of Xray, this function needs network with speified network stack(tcp4/tcp6/udp4/udp6) func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error { if config.Mark != 0 { if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_MARK, int(config.Mark)); err != nil { @@ -103,30 +106,38 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf } } - if len(config.CustomSockopt) > 0 { - for _, custom := range config.CustomSockopt { - var level = 0x6 // default TCP - var opt int - if len(custom.Opt) == 0 { - return errors.New("No opt!") - } else { - opt, _ = strconv.Atoi(custom.Opt) + } + + if len(config.CustomSockopt) > 0 { + for _, custom := range config.CustomSockopt { + // Skip unwanted network type + // network might be tcp4 or tcp6 + // use HasPrefix so that "tcp" can match tcp4/6 with "tcp" if user want to control all tcp (udp is also the same) + // if it is empty, strings.HasPrefix will always return true to make it apply for all networks + if !strings.HasPrefix(network, custom.Network) { + continue + } + var level = 0x6 // default TCP + var opt int + if len(custom.Opt) == 0 { + return errors.New("No opt!") + } else { + opt, _ = strconv.Atoi(custom.Opt) + } + if custom.Level != "" { + level, _ = strconv.Atoi(custom.Level) + } + if custom.Type == "int" { + value, _ := strconv.Atoi(custom.Value) + if err := syscall.SetsockoptInt(int(fd), level, opt, value); err != nil { + return errors.New("failed to set CustomSockoptInt", opt, value, err) } - if custom.Level != "" { - level, _ = strconv.Atoi(custom.Level) - } - if custom.Type == "int" { - value, _ := strconv.Atoi(custom.Value) - if err := syscall.SetsockoptInt(int(fd), level, opt, value); err != nil { - return errors.New("failed to set CustomSockoptInt", opt, value, err) - } - } else if custom.Type == "str" { - if err := syscall.SetsockoptString(int(fd), level, opt, custom.Value); err != nil { - return errors.New("failed to set CustomSockoptString", opt, custom.Value, err) - } - } else { - return errors.New("unknown CustomSockopt type:", custom.Type) + } else if custom.Type == "str" { + if err := syscall.SetsockoptString(int(fd), level, opt, custom.Value); err != nil { + return errors.New("failed to set CustomSockoptString", opt, custom.Value, err) } + } else { + return errors.New("unknown CustomSockopt type:", custom.Type) } } } @@ -140,6 +151,8 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf return nil } +// applyInboundSocketOptions applies socket options for inbound listener. +// note that unlike other part of Xray, this function needs network with speified network stack(tcp4/tcp6/udp4/udp6) func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) error { if config.Mark != 0 { if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_MARK, int(config.Mark)); err != nil { diff --git a/transport/internet/sockopt_windows.go b/transport/internet/sockopt_windows.go index ef6be945..fa45011d 100644 --- a/transport/internet/sockopt_windows.go +++ b/transport/internet/sockopt_windows.go @@ -33,7 +33,7 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf if err != nil { return errors.New("failed to find the interface").Base(err) } - isV4 := (network == "tcp4") + isV4 := (network == "tcp4" || network == "udp4") if isV4 { var bytes [4]byte binary.BigEndian.PutUint32(bytes[:], uint32(inf.Index)) diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index 52b1e830..0b3c2f10 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -73,7 +73,13 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne return nil, err } sys.Control(func(fd uintptr) { - if err := applyOutboundSocketOptions("udp", dest.NetAddr(), fd, sockopt); err != nil { + var network string + if destAddr.IP.To4() != nil { + network = "udp4" + } else { + network = "udp6" + } + if err := applyOutboundSocketOptions(network, dest.NetAddr(), fd, sockopt); err != nil { errors.LogInfo(ctx, err, "failed to apply socket options") } }) From 607c2a6d31ea1db70e8079f27ea4c7a771158652 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 21 Mar 2025 20:13:09 +0000 Subject: [PATCH 766/867] DNS DoH: Use EDNS0 with 100-300 padding by default (body padding) https://github.com/XTLS/Xray-core/pull/4516#issuecomment-2744093003 --- app/dns/dnscommon.go | 78 +++++++++++++++++++++----------------- app/dns/dnscommon_test.go | 2 +- app/dns/nameserver_doh.go | 4 +- app/dns/nameserver_quic.go | 2 +- app/dns/nameserver_tcp.go | 2 +- app/dns/nameserver_udp.go | 2 +- 6 files changed, 51 insertions(+), 39 deletions(-) diff --git a/app/dns/dnscommon.go b/app/dns/dnscommon.go index c2689d6d..e11cc097 100644 --- a/app/dns/dnscommon.go +++ b/app/dns/dnscommon.go @@ -68,49 +68,59 @@ type dnsRequest struct { msg *dnsmessage.Message } -func genEDNS0Options(clientIP net.IP) *dnsmessage.Resource { - if len(clientIP) == 0 { +func genEDNS0Options(clientIP net.IP, padding int) *dnsmessage.Resource { + if len(clientIP) == 0 && padding == 0 { return nil } - var netmask int - var family uint16 - - if len(clientIP) == 4 { - family = 1 - netmask = 24 // 24 for IPV4, 96 for IPv6 - } else { - family = 2 - netmask = 96 - } - - b := make([]byte, 4) - binary.BigEndian.PutUint16(b[0:], family) - b[2] = byte(netmask) - b[3] = 0 - switch family { - case 1: - ip := clientIP.To4().Mask(net.CIDRMask(netmask, net.IPv4len*8)) - needLength := (netmask + 8 - 1) / 8 // division rounding up - b = append(b, ip[:needLength]...) - case 2: - ip := clientIP.Mask(net.CIDRMask(netmask, net.IPv6len*8)) - needLength := (netmask + 8 - 1) / 8 // division rounding up - b = append(b, ip[:needLength]...) - } - - const EDNS0SUBNET = 0x08 + const EDNS0SUBNET = 0x8 + const EDNS0PADDING = 0xc opt := new(dnsmessage.Resource) common.Must(opt.Header.SetEDNS0(1350, 0xfe00, true)) + body := dnsmessage.OPTResource{} + opt.Body = &body - opt.Body = &dnsmessage.OPTResource{ - Options: []dnsmessage.Option{ - { + if len(clientIP) != 0 { + var netmask int + var family uint16 + + if len(clientIP) == 4 { + family = 1 + netmask = 24 // 24 for IPV4, 96 for IPv6 + } else { + family = 2 + netmask = 96 + } + + b := make([]byte, 4) + binary.BigEndian.PutUint16(b[0:], family) + b[2] = byte(netmask) + b[3] = 0 + switch family { + case 1: + ip := clientIP.To4().Mask(net.CIDRMask(netmask, net.IPv4len*8)) + needLength := (netmask + 8 - 1) / 8 // division rounding up + b = append(b, ip[:needLength]...) + case 2: + ip := clientIP.Mask(net.CIDRMask(netmask, net.IPv6len*8)) + needLength := (netmask + 8 - 1) / 8 // division rounding up + b = append(b, ip[:needLength]...) + } + + body.Options = append(body.Options, + dnsmessage.Option{ Code: EDNS0SUBNET, Data: b, - }, - }, + }) + } + + if padding != 0 { + body.Options = append(body.Options, + dnsmessage.Option{ + Code: EDNS0PADDING, + Data: make([]byte, padding), + }) } return opt diff --git a/app/dns/dnscommon_test.go b/app/dns/dnscommon_test.go index 4c6f9d73..2affb2a3 100644 --- a/app/dns/dnscommon_test.go +++ b/app/dns/dnscommon_test.go @@ -156,7 +156,7 @@ func Test_genEDNS0Options(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - if got := genEDNS0Options(tt.args.clientIP); got == nil { + if got := genEDNS0Options(tt.args.clientIP, 0); got == nil { t.Errorf("genEDNS0Options() = %v, want %v", got, tt.want) } }) diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index c74b9e53..1739062d 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -219,7 +219,9 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, clientIP n return } - reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP)) + // As we don't want our traffic pattern looks like DoH, we use Random-Length Padding instead of Block-Length Padding recommended in RFC 8467 + // Although DoH server like 1.1.1.1 will pad the response to Block-Length 468, at least it is better than no padding for response at all + reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP, int(crypto.RandBetween(100, 300)))) var deadline time.Time if d, ok := ctx.Deadline(); ok { diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 997635a8..f816cf1f 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -160,7 +160,7 @@ func (s *QUICNameServer) newReqID() uint16 { func (s *QUICNameServer) sendQuery(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption) { errors.LogInfo(ctx, s.name, " querying: ", domain) - reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP)) + reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP, 0)) var deadline time.Time if d, ok := ctx.Deadline(); ok { diff --git a/app/dns/nameserver_tcp.go b/app/dns/nameserver_tcp.go index 0146e007..35c9a07f 100644 --- a/app/dns/nameserver_tcp.go +++ b/app/dns/nameserver_tcp.go @@ -192,7 +192,7 @@ func (s *TCPNameServer) newReqID() uint16 { func (s *TCPNameServer) sendQuery(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption) { errors.LogDebug(ctx, s.name, " querying DNS for: ", domain) - reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP)) + reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP, 0)) var deadline time.Time if d, ok := ctx.Deadline(); ok { diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index 967576bc..79592e9b 100644 --- a/app/dns/nameserver_udp.go +++ b/app/dns/nameserver_udp.go @@ -217,7 +217,7 @@ func (s *ClassicNameServer) addPendingRequest(req *udpDnsRequest) { func (s *ClassicNameServer) sendQuery(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption) { errors.LogDebug(ctx, s.name, " querying DNS for: ", domain) - reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP)) + reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP, 0)) for _, req := range reqs { udpReq := &udpDnsRequest{ From 673a9ae06362bd130048ff5b543aaf5924d31acf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Mar 2025 09:49:58 +0000 Subject: [PATCH 767/867] Bump github.com/quic-go/quic-go from 0.50.0 to 0.50.1 (#4539) Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.50.0 to 0.50.1. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.50.0...v0.50.1) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index be8d7dd4..456b3ab4 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/miekg/dns v1.1.64 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.0 - github.com/quic-go/quic-go v0.50.0 + github.com/quic-go/quic-go v0.50.1 github.com/refraction-networking/utls v1.6.7 github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 diff --git a/go.sum b/go.sum index 43b0b222..a43edf73 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= -github.com/quic-go/quic-go v0.50.0 h1:3H/ld1pa3CYhkcc20TPIyG1bNsdhn9qZBGN3b9/UyUo= -github.com/quic-go/quic-go v0.50.0/go.mod h1:Vim6OmUvlYdwBhXP9ZVrtGmCMWa3wEqhq3NgYrI8b4E= +github.com/quic-go/quic-go v0.50.1 h1:unsgjFIUqW8a2oopkY7YNONpV1gYND6Nt9hnt1PN94Q= +github.com/quic-go/quic-go v0.50.1/go.mod h1:Vim6OmUvlYdwBhXP9ZVrtGmCMWa3wEqhq3NgYrI8b4E= github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From 2d3210e4b815c791d58a845236d809a7908adc45 Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Mon, 24 Mar 2025 16:26:48 +0330 Subject: [PATCH 768/867] Env: Add `XRAY_LOCATION_CERT` variable (#4536) https://github.com/XTLS/Xray-core/issues/4531#issuecomment-2746155941 Fixes https://github.com/XTLS/Xray-core/issues/4531 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- common/platform/filesystem/file.go | 8 ++++++++ common/platform/others.go | 8 +++++++- common/platform/platform.go | 1 + common/platform/windows.go | 8 +++++++- infra/conf/transport_internet.go | 2 +- transport/internet/tls/config.go | 4 ++-- 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/common/platform/filesystem/file.go b/common/platform/filesystem/file.go index e10bfc11..e4fe2a9a 100644 --- a/common/platform/filesystem/file.go +++ b/common/platform/filesystem/file.go @@ -3,6 +3,7 @@ package filesystem import ( "io" "os" + "path/filepath" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/platform" @@ -28,6 +29,13 @@ func ReadAsset(file string) ([]byte, error) { return ReadFile(platform.GetAssetLocation(file)) } +func ReadCert(file string) ([]byte, error) { + if filepath.IsAbs(file) { + return ReadFile(file) + } + return ReadFile(platform.GetCertLocation(file)) +} + func CopyFile(dst string, src string) error { bytes, err := ReadFile(src) if err != nil { diff --git a/common/platform/others.go b/common/platform/others.go index 7401a526..a405ac48 100644 --- a/common/platform/others.go +++ b/common/platform/others.go @@ -21,7 +21,7 @@ func GetToolLocation(file string) string { return filepath.Join(toolPath, file) } -// GetAssetLocation searches for `file` in certain locations +// GetAssetLocation searches for `file` in the env dir, the executable dir, and certain locations func GetAssetLocation(file string) string { assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir) defPath := filepath.Join(assetPath, file) @@ -42,3 +42,9 @@ func GetAssetLocation(file string) string { // asset not found, let the caller throw out the error return defPath } + +// GetCertLocation searches for `file` in the env dir and the executable dir +func GetCertLocation(file string) string { + certPath := NewEnvFlag(CertLocation).GetValue(getExecutableDir) + return filepath.Join(certPath, file) +} diff --git a/common/platform/platform.go b/common/platform/platform.go index 51e25447..b865dc0d 100644 --- a/common/platform/platform.go +++ b/common/platform/platform.go @@ -13,6 +13,7 @@ const ( ConfdirLocation = "xray.location.confdir" ToolLocation = "xray.location.tool" AssetLocation = "xray.location.asset" + CertLocation = "xray.location.cert" UseReadV = "xray.buf.readv" UseFreedomSplice = "xray.buf.splice" diff --git a/common/platform/windows.go b/common/platform/windows.go index 872e8461..cb25a1ad 100644 --- a/common/platform/windows.go +++ b/common/platform/windows.go @@ -19,8 +19,14 @@ func GetToolLocation(file string) string { return filepath.Join(toolPath, file+".exe") } -// GetAssetLocation searches for `file` in the executable dir +// GetAssetLocation searches for `file` in the env dir and the executable dir func GetAssetLocation(file string) string { assetPath := NewEnvFlag(AssetLocation).GetValue(getExecutableDir) return filepath.Join(assetPath, file) } + +// GetCertLocation searches for `file` in the env dir and the executable dir +func GetCertLocation(file string) string { + certPath := NewEnvFlag(CertLocation).GetValue(getExecutableDir) + return filepath.Join(certPath, file) +} diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 2d73e524..e32be326 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -334,7 +334,7 @@ func (c *SplitHTTPConfig) Build() (proto.Message, error) { func readFileOrString(f string, s []string) ([]byte, error) { if len(f) > 0 { - return filesystem.ReadFile(f) + return filesystem.ReadCert(f) } if len(s) > 0 { return []byte(strings.Join(s, "\n")), nil diff --git a/transport/internet/tls/config.go b/transport/internet/tls/config.go index 171b30b6..d6701a7d 100644 --- a/transport/internet/tls/config.go +++ b/transport/internet/tls/config.go @@ -109,12 +109,12 @@ func setupOcspTicker(entry *Certificate, callback func(isReloaded, isOcspstaplin for { var isReloaded bool if entry.CertificatePath != "" && entry.KeyPath != "" { - newCert, err := filesystem.ReadFile(entry.CertificatePath) + newCert, err := filesystem.ReadCert(entry.CertificatePath) if err != nil { errors.LogErrorInner(context.Background(), err, "failed to parse certificate") return } - newKey, err := filesystem.ReadFile(entry.KeyPath) + newKey, err := filesystem.ReadCert(entry.KeyPath) if err != nil { errors.LogErrorInner(context.Background(), err, "failed to parse key") return From 4afe2d0cff2cecaf41c7e91ccc1ab9bbaf3b63e6 Mon Sep 17 00:00:00 2001 From: Meo597 <197331664+Meo597@users.noreply.github.com> Date: Mon, 24 Mar 2025 21:33:56 +0800 Subject: [PATCH 769/867] DNS: Support returning upstream TTL to clients (#4526) Closes https://github.com/XTLS/Xray-core/issues/4527 --- app/dns/dns.go | 19 +++++++------- app/dns/dns_test.go | 44 ++++++++++++++++---------------- app/dns/dnscommon.go | 9 ++++--- app/dns/nameserver.go | 11 ++++---- app/dns/nameserver_doh.go | 34 ++++++++++++------------ app/dns/nameserver_doh_test.go | 10 ++++---- app/dns/nameserver_fakedns.go | 10 ++++---- app/dns/nameserver_local.go | 6 ++--- app/dns/nameserver_local_test.go | 2 +- app/dns/nameserver_quic.go | 34 ++++++++++++------------ app/dns/nameserver_quic_test.go | 8 +++--- app/dns/nameserver_tcp.go | 32 ++++++++++++----------- app/dns/nameserver_tcp_test.go | 10 ++++---- app/dns/nameserver_udp.go | 32 ++++++++++++----------- app/router/router_test.go | 4 +-- features/dns/client.go | 2 +- features/dns/localdns/client.go | 13 +++++----- features/routing/dns/context.go | 2 +- proxy/dns/dns.go | 18 ++++++------- proxy/freedom/freedom.go | 4 +-- proxy/wireguard/bind.go | 2 +- proxy/wireguard/client.go | 8 +++--- testing/mocks/dns.go | 7 ++--- transport/internet/dialer.go | 4 +-- 24 files changed, 168 insertions(+), 157 deletions(-) diff --git a/app/dns/dns.go b/app/dns/dns.go index bc544a5a..9b84106c 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -157,16 +157,16 @@ func (s *DNS) IsOwnLink(ctx context.Context) bool { } // LookupIP implements dns.Client. -func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, error) { +func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, uint32, error) { if domain == "" { - return nil, errors.New("empty domain name") + return nil, 0, errors.New("empty domain name") } option.IPv4Enable = option.IPv4Enable && s.ipOption.IPv4Enable option.IPv6Enable = option.IPv6Enable && s.ipOption.IPv6Enable if !option.IPv4Enable && !option.IPv6Enable { - return nil, dns.ErrEmptyResponse + return nil, 0, dns.ErrEmptyResponse } // Normalize the FQDN form query @@ -177,13 +177,14 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, error) { case addrs == nil: // Domain not recorded in static host break case len(addrs) == 0: // Domain recorded, but no valid IP returned (e.g. IPv4 address with only IPv6 enabled) - return nil, dns.ErrEmptyResponse + return nil, 0, dns.ErrEmptyResponse case len(addrs) == 1 && addrs[0].Family().IsDomain(): // Domain replacement errors.LogInfo(s.ctx, "domain replaced: ", domain, " -> ", addrs[0].Domain()) domain = addrs[0].Domain() default: // Successfully found ip records in static host errors.LogInfo(s.ctx, "returning ", len(addrs), " IP(s) for domain ", domain, " -> ", addrs) - return toNetIP(addrs) + ips, err := toNetIP(addrs) + return ips, 10, err // Hosts ttl is 10 } // Name servers lookup @@ -194,9 +195,9 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, error) { errors.LogDebug(s.ctx, "skip DNS resolution for domain ", domain, " at server ", client.Name()) continue } - ips, err := client.QueryIP(ctx, domain, option, s.disableCache) + ips, ttl, err := client.QueryIP(ctx, domain, option, s.disableCache) if len(ips) > 0 { - return ips, nil + return ips, ttl, nil } if err != nil { errors.LogInfoInner(s.ctx, err, "failed to lookup ip for domain ", domain, " at server ", client.Name()) @@ -204,11 +205,11 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, error) { } // 5 for RcodeRefused in miekg/dns, hardcode to reduce binary size if err != context.Canceled && err != context.DeadlineExceeded && err != errExpectedIPNonMatch && err != dns.ErrEmptyResponse && dns.RCodeFromError(err) != 5 { - return nil, err + return nil, 0, err } } - return nil, errors.New("returning nil for domain ", domain).Base(errors.Combine(errs...)) + return nil, 0, errors.New("returning nil for domain ", domain).Base(errors.Combine(errs...)) } // LookupHosts implements dns.HostsLookup. diff --git a/app/dns/dns_test.go b/app/dns/dns_test.go index 500c057e..ab985384 100644 --- a/app/dns/dns_test.go +++ b/app/dns/dns_test.go @@ -155,7 +155,7 @@ func TestUDPServerSubnet(t *testing.T) { client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client) - ips, err := client.LookupIP("google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("google.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -216,7 +216,7 @@ func TestUDPServer(t *testing.T) { client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client) { - ips, err := client.LookupIP("google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("google.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -231,7 +231,7 @@ func TestUDPServer(t *testing.T) { } { - ips, err := client.LookupIP("facebook.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("facebook.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -246,7 +246,7 @@ func TestUDPServer(t *testing.T) { } { - _, err := client.LookupIP("notexist.google.com", feature_dns.IPOption{ + _, _, err := client.LookupIP("notexist.google.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -260,7 +260,7 @@ func TestUDPServer(t *testing.T) { } { - ips, err := client.LookupIP("ipv4only.google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("ipv4only.google.com", feature_dns.IPOption{ IPv4Enable: false, IPv6Enable: true, FakeEnable: false, @@ -276,7 +276,7 @@ func TestUDPServer(t *testing.T) { dnsServer.Shutdown() { - ips, err := client.LookupIP("google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("google.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -357,7 +357,7 @@ func TestPrioritizedDomain(t *testing.T) { startTime := time.Now() { - ips, err := client.LookupIP("google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("google.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -423,7 +423,7 @@ func TestUDPServerIPv6(t *testing.T) { client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client) { - ips, err := client.LookupIP("ipv6.google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("ipv6.google.com", feature_dns.IPOption{ IPv4Enable: false, IPv6Enable: true, FakeEnable: false, @@ -492,7 +492,7 @@ func TestStaticHostDomain(t *testing.T) { client := v.GetFeature(feature_dns.ClientType()).(feature_dns.Client) { - ips, err := client.LookupIP("example.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("example.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -603,7 +603,7 @@ func TestIPMatch(t *testing.T) { startTime := time.Now() { - ips, err := client.LookupIP("google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("google.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -726,7 +726,7 @@ func TestLocalDomain(t *testing.T) { startTime := time.Now() { // Will match dotless: - ips, err := client.LookupIP("hostname", feature_dns.IPOption{ + ips, _, err := client.LookupIP("hostname", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -741,7 +741,7 @@ func TestLocalDomain(t *testing.T) { } { // Will match domain:local - ips, err := client.LookupIP("hostname.local", feature_dns.IPOption{ + ips, _, err := client.LookupIP("hostname.local", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -756,7 +756,7 @@ func TestLocalDomain(t *testing.T) { } { // Will match static ip - ips, err := client.LookupIP("hostnamestatic", feature_dns.IPOption{ + ips, _, err := client.LookupIP("hostnamestatic", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -771,7 +771,7 @@ func TestLocalDomain(t *testing.T) { } { // Will match domain replacing - ips, err := client.LookupIP("hostnamealias", feature_dns.IPOption{ + ips, _, err := client.LookupIP("hostnamealias", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -786,7 +786,7 @@ func TestLocalDomain(t *testing.T) { } { // Will match dotless:localhost, but not expectIPs: 127.0.0.2, 127.0.0.3, then matches at dotless: - ips, err := client.LookupIP("localhost", feature_dns.IPOption{ + ips, _, err := client.LookupIP("localhost", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -801,7 +801,7 @@ func TestLocalDomain(t *testing.T) { } { // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3 - ips, err := client.LookupIP("localhost-a", feature_dns.IPOption{ + ips, _, err := client.LookupIP("localhost-a", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -816,7 +816,7 @@ func TestLocalDomain(t *testing.T) { } { // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3 - ips, err := client.LookupIP("localhost-b", feature_dns.IPOption{ + ips, _, err := client.LookupIP("localhost-b", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -831,7 +831,7 @@ func TestLocalDomain(t *testing.T) { } { // Will match dotless: - ips, err := client.LookupIP("Mijia Cloud", feature_dns.IPOption{ + ips, _, err := client.LookupIP("Mijia Cloud", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -997,7 +997,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) { startTime := time.Now() { // Will match server 1,2 and server 1 returns expected ip - ips, err := client.LookupIP("google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("google.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -1012,7 +1012,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) { } { // Will match server 1,2 and server 1 returns unexpected ip, then server 2 returns expected one - ips, err := client.LookupIP("ipv6.google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("ipv6.google.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: false, FakeEnable: false, @@ -1027,7 +1027,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) { } { // Will match server 3,1,2 and server 3 returns expected one - ips, err := client.LookupIP("api.google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("api.google.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, @@ -1042,7 +1042,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) { } { // Will match server 4,3,1,2 and server 4 returns expected one - ips, err := client.LookupIP("v2.api.google.com", feature_dns.IPOption{ + ips, _, err := client.LookupIP("v2.api.google.com", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, diff --git a/app/dns/dnscommon.go b/app/dns/dnscommon.go index e11cc097..0dc07f72 100644 --- a/app/dns/dnscommon.go +++ b/app/dns/dnscommon.go @@ -38,14 +38,15 @@ type IPRecord struct { RawHeader *dnsmessage.Header } -func (r *IPRecord) getIPs() ([]net.Address, error) { +func (r *IPRecord) getIPs() ([]net.Address, uint32, error) { if r == nil || r.Expire.Before(time.Now()) { - return nil, errRecordNotFound + return nil, 0, errRecordNotFound } if r.RCode != dnsmessage.RCodeSuccess { - return nil, dns_feature.RCodeError(r.RCode) + return nil, 0, dns_feature.RCodeError(r.RCode) } - return r.IP, nil + ttl := uint32(time.Until(r.Expire) / time.Second) + return r.IP, ttl, nil } func isNewer(baseRec *IPRecord, newRec *IPRecord) bool { diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index 14513b3b..774d87c3 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -21,7 +21,7 @@ type Server interface { // Name of the Client. Name() string // QueryIP sends IP queries to its configured server. - QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns.IPOption, disableCache bool) ([]net.IP, error) + QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns.IPOption, disableCache bool) ([]net.IP, uint32, error) } // Client is the interface for DNS client. @@ -191,7 +191,7 @@ func (c *Client) Name() string { } // QueryIP sends DNS query to the name server with the client's IP. -func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption, disableCache bool) ([]net.IP, error) { +func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption, disableCache bool) ([]net.IP, uint32, error) { ctx, cancel := context.WithTimeout(ctx, c.timeoutMs) if len(c.tag) != 0 { content := session.InboundFromContext(ctx) @@ -200,13 +200,14 @@ func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption // do not direct set *content.Tag, it might be used by other clients ctx = session.ContextWithInbound(ctx, &session.Inbound{Tag: c.tag}) } - ips, err := c.server.QueryIP(ctx, domain, c.clientIP, option, disableCache) + ips, ttl, err := c.server.QueryIP(ctx, domain, c.clientIP, option, disableCache) cancel() if err != nil { - return ips, err + return ips, ttl, err } - return c.MatchExpectedIPs(domain, ips) + netips, err := c.MatchExpectedIPs(domain, ips) + return netips, ttl, err } // MatchExpectedIPs matches queried domain IPs with expected IPs and returns matched ones. diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index 1739062d..8a23e0c3 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -301,64 +301,66 @@ func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte, return io.ReadAll(resp.Body) } -func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, error) { +func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { s.RLock() record, found := s.ips[domain] s.RUnlock() if !found { - return nil, errRecordNotFound + return nil, 0, errRecordNotFound } var err4 error var err6 error var ips []net.Address var ip6 []net.Address + var ttl uint32 if option.IPv4Enable { - ips, err4 = record.A.getIPs() + ips, ttl, err4 = record.A.getIPs() } if option.IPv6Enable { - ip6, err6 = record.AAAA.getIPs() + ip6, ttl, err6 = record.AAAA.getIPs() ips = append(ips, ip6...) } if len(ips) > 0 { - return toNetIP(ips) + netips, err := toNetIP(ips) + return netips, ttl, err } if err4 != nil { - return nil, err4 + return nil, 0, err4 } if err6 != nil { - return nil, err6 + return nil, 0, err6 } if (option.IPv4Enable && record.A != nil) || (option.IPv6Enable && record.AAAA != nil) { - return nil, dns_feature.ErrEmptyResponse + return nil, 0, dns_feature.ErrEmptyResponse } - return nil, errRecordNotFound + return nil, 0, errRecordNotFound } // QueryIP implements Server. -func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, error) { // nolint: dupl +func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, uint32, error) { // nolint: dupl fqdn := Fqdn(domain) option = ResolveIpOptionOverride(s.queryStrategy, option) if !option.IPv4Enable && !option.IPv6Enable { - return nil, dns_feature.ErrEmptyResponse + return nil, 0, dns_feature.ErrEmptyResponse } if disableCache { errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { - ips, err := s.findIPsForDomain(fqdn, option) + ips, ttl, err := s.findIPsForDomain(fqdn, option) if err == nil || err == dns_feature.ErrEmptyResponse { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) - return ips, err + return ips, ttl, err } } @@ -392,15 +394,15 @@ func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, clientIP net start := time.Now() for { - ips, err := s.findIPsForDomain(fqdn, option) + ips, ttl, err := s.findIPsForDomain(fqdn, option) if err != errRecordNotFound { log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) - return ips, err + return ips, ttl, err } select { case <-ctx.Done(): - return nil, ctx.Err() + return nil, 0, ctx.Err() case <-done: } } diff --git a/app/dns/nameserver_doh_test.go b/app/dns/nameserver_doh_test.go index 3dfcb15c..a27a5e9f 100644 --- a/app/dns/nameserver_doh_test.go +++ b/app/dns/nameserver_doh_test.go @@ -19,7 +19,7 @@ func TestDOHNameServer(t *testing.T) { s := NewDoHNameServer(url, QueryStrategy_USE_IP, nil, false) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) @@ -36,7 +36,7 @@ func TestDOHNameServerWithCache(t *testing.T) { s := NewDoHNameServer(url, QueryStrategy_USE_IP, nil, false) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) @@ -47,7 +47,7 @@ func TestDOHNameServerWithCache(t *testing.T) { } ctx2, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips2, err := s.QueryIP(ctx2, "google.com", net.IP(nil), dns_feature.IPOption{ + ips2, _, err := s.QueryIP(ctx2, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, }, true) @@ -64,7 +64,7 @@ func TestDOHNameServerWithIPv4Override(t *testing.T) { s := NewDoHNameServer(url, QueryStrategy_USE_IP4, nil, false) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) @@ -87,7 +87,7 @@ func TestDOHNameServerWithIPv6Override(t *testing.T) { s := NewDoHNameServer(url, QueryStrategy_USE_IP6, nil, false) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) diff --git a/app/dns/nameserver_fakedns.go b/app/dns/nameserver_fakedns.go index ae7a1a7d..37c2f723 100644 --- a/app/dns/nameserver_fakedns.go +++ b/app/dns/nameserver_fakedns.go @@ -20,9 +20,9 @@ func (FakeDNSServer) Name() string { return "FakeDNS" } -func (f *FakeDNSServer) QueryIP(ctx context.Context, domain string, _ net.IP, opt dns.IPOption, _ bool) ([]net.IP, error) { +func (f *FakeDNSServer) QueryIP(ctx context.Context, domain string, _ net.IP, opt dns.IPOption, _ bool) ([]net.IP, uint32, error) { if f.fakeDNSEngine == nil { - return nil, errors.New("Unable to locate a fake DNS Engine").AtError() + return nil, 0, errors.New("Unable to locate a fake DNS Engine").AtError() } var ips []net.Address @@ -34,13 +34,13 @@ func (f *FakeDNSServer) QueryIP(ctx context.Context, domain string, _ net.IP, op netIP, err := toNetIP(ips) if err != nil { - return nil, errors.New("Unable to convert IP to net ip").Base(err).AtError() + return nil, 0, errors.New("Unable to convert IP to net ip").Base(err).AtError() } errors.LogInfo(ctx, f.Name(), " got answer: ", domain, " -> ", ips) if len(netIP) > 0 { - return netIP, nil + return netIP, 1, nil // fakeIP ttl is 1 } - return nil, dns.ErrEmptyResponse + return nil, 0, dns.ErrEmptyResponse } diff --git a/app/dns/nameserver_local.go b/app/dns/nameserver_local.go index 14de8356..1b45e5f0 100644 --- a/app/dns/nameserver_local.go +++ b/app/dns/nameserver_local.go @@ -21,14 +21,14 @@ type LocalNameServer struct { const errEmptyResponse = "No address associated with hostname" // QueryIP implements Server. -func (s *LocalNameServer) QueryIP(ctx context.Context, domain string, _ net.IP, option dns.IPOption, _ bool) (ips []net.IP, err error) { +func (s *LocalNameServer) QueryIP(ctx context.Context, domain string, _ net.IP, option dns.IPOption, _ bool) (ips []net.IP, ttl uint32, err error) { option = ResolveIpOptionOverride(s.queryStrategy, option) if !option.IPv4Enable && !option.IPv6Enable { - return nil, dns.ErrEmptyResponse + return nil, 0, dns.ErrEmptyResponse } start := time.Now() - ips, err = s.client.LookupIP(domain, option) + ips, ttl, err = s.client.LookupIP(domain, option) if err != nil && strings.HasSuffix(err.Error(), errEmptyResponse) { err = dns.ErrEmptyResponse diff --git a/app/dns/nameserver_local_test.go b/app/dns/nameserver_local_test.go index 500962f7..a32c69e6 100644 --- a/app/dns/nameserver_local_test.go +++ b/app/dns/nameserver_local_test.go @@ -14,7 +14,7 @@ import ( func TestLocalNameServer(t *testing.T) { s := NewLocalNameServer(QueryStrategy_USE_IP) ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) - ips, err := s.QueryIP(ctx, "google.com", net.IP{}, dns.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP{}, dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index f816cf1f..2b0b7b66 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -244,64 +244,66 @@ func (s *QUICNameServer) sendQuery(ctx context.Context, domain string, clientIP } } -func (s *QUICNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, error) { +func (s *QUICNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { s.RLock() record, found := s.ips[domain] s.RUnlock() if !found { - return nil, errRecordNotFound + return nil, 0, errRecordNotFound } var err4 error var err6 error var ips []net.Address var ip6 []net.Address + var ttl uint32 if option.IPv4Enable { - ips, err4 = record.A.getIPs() + ips, ttl, err4 = record.A.getIPs() } if option.IPv6Enable { - ip6, err6 = record.AAAA.getIPs() + ip6, ttl, err6 = record.AAAA.getIPs() ips = append(ips, ip6...) } if len(ips) > 0 { - return toNetIP(ips) + netips, err := toNetIP(ips) + return netips, ttl, err } if err4 != nil { - return nil, err4 + return nil, 0, err4 } if err6 != nil { - return nil, err6 + return nil, 0, err6 } if (option.IPv4Enable && record.A != nil) || (option.IPv6Enable && record.AAAA != nil) { - return nil, dns_feature.ErrEmptyResponse + return nil, 0, dns_feature.ErrEmptyResponse } - return nil, errRecordNotFound + return nil, 0, errRecordNotFound } // QueryIP is called from dns.Server->queryIPTimeout -func (s *QUICNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, error) { +func (s *QUICNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, uint32, error) { fqdn := Fqdn(domain) option = ResolveIpOptionOverride(s.queryStrategy, option) if !option.IPv4Enable && !option.IPv6Enable { - return nil, dns_feature.ErrEmptyResponse + return nil, 0, dns_feature.ErrEmptyResponse } if disableCache { errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { - ips, err := s.findIPsForDomain(fqdn, option) + ips, ttl, err := s.findIPsForDomain(fqdn, option) if err == nil || err == dns_feature.ErrEmptyResponse { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) - return ips, err + return ips, ttl, err } } @@ -335,15 +337,15 @@ func (s *QUICNameServer) QueryIP(ctx context.Context, domain string, clientIP ne start := time.Now() for { - ips, err := s.findIPsForDomain(fqdn, option) + ips, ttl, err := s.findIPsForDomain(fqdn, option) if err != errRecordNotFound { log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) - return ips, err + return ips, ttl, err } select { case <-ctx.Done(): - return nil, ctx.Err() + return nil, 0, ctx.Err() case <-done: } } diff --git a/app/dns/nameserver_quic_test.go b/app/dns/nameserver_quic_test.go index 0088aa33..56f9c3ee 100644 --- a/app/dns/nameserver_quic_test.go +++ b/app/dns/nameserver_quic_test.go @@ -19,7 +19,7 @@ func TestQUICNameServer(t *testing.T) { s, err := NewQUICNameServer(url, QueryStrategy_USE_IP) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) @@ -30,7 +30,7 @@ func TestQUICNameServer(t *testing.T) { } ctx2, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips2, err := s.QueryIP(ctx2, "google.com", net.IP(nil), dns.IPOption{ + ips2, _, err := s.QueryIP(ctx2, "google.com", net.IP(nil), dns.IPOption{ IPv4Enable: true, IPv6Enable: true, }, true) @@ -47,7 +47,7 @@ func TestQUICNameServerWithIPv4Override(t *testing.T) { s, err := NewQUICNameServer(url, QueryStrategy_USE_IP4) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) @@ -70,7 +70,7 @@ func TestQUICNameServerWithIPv6Override(t *testing.T) { s, err := NewQUICNameServer(url, QueryStrategy_USE_IP6) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) diff --git a/app/dns/nameserver_tcp.go b/app/dns/nameserver_tcp.go index 35c9a07f..d84974b0 100644 --- a/app/dns/nameserver_tcp.go +++ b/app/dns/nameserver_tcp.go @@ -273,60 +273,62 @@ func (s *TCPNameServer) sendQuery(ctx context.Context, domain string, clientIP n } } -func (s *TCPNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, error) { +func (s *TCPNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { s.RLock() record, found := s.ips[domain] s.RUnlock() if !found { - return nil, errRecordNotFound + return nil, 0, errRecordNotFound } var err4 error var err6 error var ips []net.Address var ip6 []net.Address + var ttl uint32 if option.IPv4Enable { - ips, err4 = record.A.getIPs() + ips, ttl, err4 = record.A.getIPs() } if option.IPv6Enable { - ip6, err6 = record.AAAA.getIPs() + ip6, ttl, err6 = record.AAAA.getIPs() ips = append(ips, ip6...) } if len(ips) > 0 { - return toNetIP(ips) + netips, err := toNetIP(ips) + return netips, ttl, err } if err4 != nil { - return nil, err4 + return nil, 0, err4 } if err6 != nil { - return nil, err6 + return nil, 0, err6 } - return nil, dns_feature.ErrEmptyResponse + return nil, 0, dns_feature.ErrEmptyResponse } // QueryIP implements Server. -func (s *TCPNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, error) { +func (s *TCPNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, uint32, error) { fqdn := Fqdn(domain) option = ResolveIpOptionOverride(s.queryStrategy, option) if !option.IPv4Enable && !option.IPv6Enable { - return nil, dns_feature.ErrEmptyResponse + return nil, 0, dns_feature.ErrEmptyResponse } if disableCache { errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { - ips, err := s.findIPsForDomain(fqdn, option) + ips, ttl, err := s.findIPsForDomain(fqdn, option) if err == nil || err == dns_feature.ErrEmptyResponse { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) - return ips, err + return ips, ttl, err } } @@ -360,15 +362,15 @@ func (s *TCPNameServer) QueryIP(ctx context.Context, domain string, clientIP net start := time.Now() for { - ips, err := s.findIPsForDomain(fqdn, option) + ips, ttl, err := s.findIPsForDomain(fqdn, option) if err != errRecordNotFound { log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) - return ips, err + return ips, ttl, err } select { case <-ctx.Done(): - return nil, ctx.Err() + return nil, 0, ctx.Err() case <-done: } } diff --git a/app/dns/nameserver_tcp_test.go b/app/dns/nameserver_tcp_test.go index 6b2b2465..de4ecb89 100644 --- a/app/dns/nameserver_tcp_test.go +++ b/app/dns/nameserver_tcp_test.go @@ -19,7 +19,7 @@ func TestTCPLocalNameServer(t *testing.T) { s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) @@ -36,7 +36,7 @@ func TestTCPLocalNameServerWithCache(t *testing.T) { s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) @@ -47,7 +47,7 @@ func TestTCPLocalNameServerWithCache(t *testing.T) { } ctx2, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips2, err := s.QueryIP(ctx2, "google.com", net.IP(nil), dns_feature.IPOption{ + ips2, _, err := s.QueryIP(ctx2, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, }, true) @@ -64,7 +64,7 @@ func TestTCPLocalNameServerWithIPv4Override(t *testing.T) { s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP4) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) @@ -88,7 +88,7 @@ func TestTCPLocalNameServerWithIPv6Override(t *testing.T) { s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP6) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, }, false) diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index 79592e9b..79df14ed 100644 --- a/app/dns/nameserver_udp.go +++ b/app/dns/nameserver_udp.go @@ -230,60 +230,62 @@ func (s *ClassicNameServer) sendQuery(ctx context.Context, domain string, client } } -func (s *ClassicNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, error) { +func (s *ClassicNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { s.RLock() record, found := s.ips[domain] s.RUnlock() if !found { - return nil, errRecordNotFound + return nil, 0, errRecordNotFound } var err4 error var err6 error var ips []net.Address var ip6 []net.Address + var ttl uint32 if option.IPv4Enable { - ips, err4 = record.A.getIPs() + ips, ttl, err4 = record.A.getIPs() } if option.IPv6Enable { - ip6, err6 = record.AAAA.getIPs() + ip6, ttl, err6 = record.AAAA.getIPs() ips = append(ips, ip6...) } if len(ips) > 0 { - return toNetIP(ips) + netips, err := toNetIP(ips) + return netips, ttl, err } if err4 != nil { - return nil, err4 + return nil, 0, err4 } if err6 != nil { - return nil, err6 + return nil, 0, err6 } - return nil, dns_feature.ErrEmptyResponse + return nil, 0, dns_feature.ErrEmptyResponse } // QueryIP implements Server. -func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, error) { +func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, uint32, error) { fqdn := Fqdn(domain) option = ResolveIpOptionOverride(s.queryStrategy, option) if !option.IPv4Enable && !option.IPv6Enable { - return nil, dns_feature.ErrEmptyResponse + return nil, 0, dns_feature.ErrEmptyResponse } if disableCache { errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { - ips, err := s.findIPsForDomain(fqdn, option) + ips, ttl, err := s.findIPsForDomain(fqdn, option) if err == nil || err == dns_feature.ErrEmptyResponse { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) - return ips, err + return ips, ttl, err } } @@ -317,15 +319,15 @@ func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, clientIP start := time.Now() for { - ips, err := s.findIPsForDomain(fqdn, option) + ips, ttl, err := s.findIPsForDomain(fqdn, option) if err != errRecordNotFound { log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) - return ips, err + return ips, ttl, err } select { case <-ctx.Done(): - return nil, ctx.Err() + return nil, 0, ctx.Err() case <-done: } } diff --git a/app/router/router_test.go b/app/router/router_test.go index 09f831b2..a0516e05 100644 --- a/app/router/router_test.go +++ b/app/router/router_test.go @@ -177,7 +177,7 @@ func TestIPOnDemand(t *testing.T) { IPv4Enable: true, IPv6Enable: true, FakeEnable: false, - }).Return([]net.IP{{192, 168, 0, 1}}, nil).AnyTimes() + }).Return([]net.IP{{192, 168, 0, 1}}, uint32(600), nil).AnyTimes() r := new(Router) common.Must(r.Init(context.TODO(), config, mockDNS, nil, nil)) @@ -222,7 +222,7 @@ func TestIPIfNonMatchDomain(t *testing.T) { IPv4Enable: true, IPv6Enable: true, FakeEnable: false, - }).Return([]net.IP{{192, 168, 0, 1}}, nil).AnyTimes() + }).Return([]net.IP{{192, 168, 0, 1}}, uint32(600), nil).AnyTimes() r := new(Router) common.Must(r.Init(context.TODO(), config, mockDNS, nil, nil)) diff --git a/features/dns/client.go b/features/dns/client.go index d3a911da..9e7be91d 100644 --- a/features/dns/client.go +++ b/features/dns/client.go @@ -21,7 +21,7 @@ type Client interface { features.Feature // LookupIP returns IP address for the given domain. IPs may contain IPv4 and/or IPv6 addresses. - LookupIP(domain string, option IPOption) ([]net.IP, error) + LookupIP(domain string, option IPOption) ([]net.IP, uint32, error) } type HostsLookup interface { diff --git a/features/dns/localdns/client.go b/features/dns/localdns/client.go index 92419dfa..a94c9474 100644 --- a/features/dns/localdns/client.go +++ b/features/dns/localdns/client.go @@ -20,10 +20,10 @@ func (*Client) Start() error { return nil } func (*Client) Close() error { return nil } // LookupIP implements Client. -func (*Client) LookupIP(host string, option dns.IPOption) ([]net.IP, error) { +func (*Client) LookupIP(host string, option dns.IPOption) ([]net.IP, uint32, error) { ips, err := net.LookupIP(host) if err != nil { - return nil, err + return nil, 0, err } parsedIPs := make([]net.IP, 0, len(ips)) ipv4 := make([]net.IP, 0, len(ips)) @@ -40,21 +40,22 @@ func (*Client) LookupIP(host string, option dns.IPOption) ([]net.IP, error) { ipv6 = append(ipv6, ip) } } + // Local DNS ttl is 600 switch { case option.IPv4Enable && option.IPv6Enable: if len(parsedIPs) > 0 { - return parsedIPs, nil + return parsedIPs, 600, nil } case option.IPv4Enable: if len(ipv4) > 0 { - return ipv4, nil + return ipv4, 600, nil } case option.IPv6Enable: if len(ipv6) > 0 { - return ipv6, nil + return ipv6, 600, nil } } - return nil, dns.ErrEmptyResponse + return nil, 0, dns.ErrEmptyResponse } // New create a new dns.Client that queries localhost for DNS. diff --git a/features/routing/dns/context.go b/features/routing/dns/context.go index d5b138d7..a65895f6 100644 --- a/features/routing/dns/context.go +++ b/features/routing/dns/context.go @@ -23,7 +23,7 @@ func (ctx *ResolvableContext) GetTargetIPs() []net.IP { } if domain := ctx.GetTargetDomain(); len(domain) != 0 { - ips, err := ctx.dnsClient.LookupIP(domain, dns.IPOption{ + ips, _, err := ctx.dnsClient.LookupIP(domain, dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index b7a3264a..2344d412 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -236,17 +236,18 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string, var ips []net.IP var err error - var ttl uint32 = 600 + var ttl4 uint32 + var ttl6 uint32 switch qType { case dnsmessage.TypeA: - ips, err = h.client.LookupIP(domain, dns.IPOption{ + ips, ttl4, err = h.client.LookupIP(domain, dns.IPOption{ IPv4Enable: true, IPv6Enable: false, FakeEnable: true, }) case dnsmessage.TypeAAAA: - ips, err = h.client.LookupIP(domain, dns.IPOption{ + ips, ttl6, err = h.client.LookupIP(domain, dns.IPOption{ IPv4Enable: false, IPv6Enable: true, FakeEnable: true, @@ -259,10 +260,6 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string, return } - if fkr0, ok := h.fdns.(dns.FakeDNSEngineRev0); ok && len(ips) > 0 && fkr0.IsIPInIPPool(net.IPAddress(ips[0])) { - ttl = 1 - } - switch qType { case dnsmessage.TypeA: for i, ip := range ips { @@ -293,16 +290,17 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string, })) common.Must(builder.StartAnswers()) - rHeader := dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(domain), Class: dnsmessage.ClassINET, TTL: ttl} + rHeader4 := dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(domain), Class: dnsmessage.ClassINET, TTL: ttl4} + rHeader6 := dnsmessage.ResourceHeader{Name: dnsmessage.MustNewName(domain), Class: dnsmessage.ClassINET, TTL: ttl6} for _, ip := range ips { if len(ip) == net.IPv4len { var r dnsmessage.AResource copy(r.A[:], ip) - common.Must(builder.AResource(rHeader, r)) + common.Must(builder.AResource(rHeader4, r)) } else { var r dnsmessage.AAAAResource copy(r.AAAA[:], ip) - common.Must(builder.AAAAResource(rHeader, r)) + common.Must(builder.AAAAResource(rHeader6, r)) } } msgBytes, err := builder.Finish() diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 324941ee..779992f7 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -71,13 +71,13 @@ func (h *Handler) policy() policy.Session { } func (h *Handler) resolveIP(ctx context.Context, domain string, localAddr net.Address) net.Address { - ips, err := h.dns.LookupIP(domain, dns.IPOption{ + ips, _, err := h.dns.LookupIP(domain, dns.IPOption{ IPv4Enable: (localAddr == nil || localAddr.Family().IsIPv4()) && h.config.preferIP4(), IPv6Enable: (localAddr == nil || localAddr.Family().IsIPv6()) && h.config.preferIP6(), }) { // Resolve fallback if (len(ips) == 0 || err != nil) && h.config.hasFallback() && localAddr == nil { - ips, err = h.dns.LookupIP(domain, dns.IPOption{ + ips, _, err = h.dns.LookupIP(domain, dns.IPOption{ IPv4Enable: h.config.fallbackIP4(), IPv6Enable: h.config.fallbackIP6(), }) diff --git a/proxy/wireguard/bind.go b/proxy/wireguard/bind.go index 80ab6a8d..79de7eba 100644 --- a/proxy/wireguard/bind.go +++ b/proxy/wireguard/bind.go @@ -54,7 +54,7 @@ func (n *netBind) ParseEndpoint(s string) (conn.Endpoint, error) { addr := xnet.ParseAddress(ipStr) if addr.Family() == xnet.AddressFamilyDomain { - ips, err := n.dns.LookupIP(addr.Domain(), n.dnsOption) + ips, _, err := n.dns.LookupIP(addr.Domain(), n.dnsOption) if err != nil { return nil, err } else if len(ips) == 0 { diff --git a/proxy/wireguard/client.go b/proxy/wireguard/client.go index c26cbf4d..ff1592ef 100644 --- a/proxy/wireguard/client.go +++ b/proxy/wireguard/client.go @@ -150,13 +150,13 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte // resolve dns addr := destination.Address if addr.Family().IsDomain() { - ips, err := h.dns.LookupIP(addr.Domain(), dns.IPOption{ + ips, _, err := h.dns.LookupIP(addr.Domain(), dns.IPOption{ IPv4Enable: h.hasIPv4 && h.conf.preferIP4(), IPv6Enable: h.hasIPv6 && h.conf.preferIP6(), }) { // Resolve fallback if (len(ips) == 0 || err != nil) && h.conf.hasFallback() { - ips, err = h.dns.LookupIP(addr.Domain(), dns.IPOption{ + ips, _, err = h.dns.LookupIP(addr.Domain(), dns.IPOption{ IPv4Enable: h.hasIPv4 && h.conf.fallbackIP4(), IPv6Enable: h.hasIPv6 && h.conf.fallbackIP6(), }) @@ -284,13 +284,13 @@ func (h *Handler) createIPCRequest() string { addr = net.ParseAddress(dialerIp.String()) errors.LogInfo(h.bind.ctx, "createIPCRequest use dialer dest ip: ", addr) } else { - ips, err := h.dns.LookupIP(addr.Domain(), dns.IPOption{ + ips, _, err := h.dns.LookupIP(addr.Domain(), dns.IPOption{ IPv4Enable: h.hasIPv4 && h.conf.preferIP4(), IPv6Enable: h.hasIPv6 && h.conf.preferIP6(), }) { // Resolve fallback if (len(ips) == 0 || err != nil) && h.conf.hasFallback() { - ips, err = h.dns.LookupIP(addr.Domain(), dns.IPOption{ + ips, _, err = h.dns.LookupIP(addr.Domain(), dns.IPOption{ IPv4Enable: h.hasIPv4 && h.conf.fallbackIP4(), IPv6Enable: h.hasIPv6 && h.conf.fallbackIP6(), }) diff --git a/testing/mocks/dns.go b/testing/mocks/dns.go index 15ddfbf4..fb398366 100644 --- a/testing/mocks/dns.go +++ b/testing/mocks/dns.go @@ -50,12 +50,13 @@ func (mr *DNSClientMockRecorder) Close() *gomock.Call { } // LookupIP mocks base method -func (m *DNSClient) LookupIP(arg0 string, arg1 dns.IPOption) ([]net.IP, error) { +func (m *DNSClient) LookupIP(arg0 string, arg1 dns.IPOption) ([]net.IP, uint32, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "LookupIP", arg0, arg1) ret0, _ := ret[0].([]net.IP) - ret1, _ := ret[1].(error) - return ret0, ret1 + ret1, _ := ret[1].(uint32) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 } // LookupIP indicates an expected call of LookupIP diff --git a/transport/internet/dialer.go b/transport/internet/dialer.go index 3b6fbfd5..554ee5cf 100644 --- a/transport/internet/dialer.go +++ b/transport/internet/dialer.go @@ -90,13 +90,13 @@ func lookupIP(domain string, strategy DomainStrategy, localAddr net.Address) ([] return nil, nil } - ips, err := dnsClient.LookupIP(domain, dns.IPOption{ + ips, _, err := dnsClient.LookupIP(domain, dns.IPOption{ IPv4Enable: (localAddr == nil || localAddr.Family().IsIPv4()) && strategy.preferIP4(), IPv6Enable: (localAddr == nil || localAddr.Family().IsIPv6()) && strategy.preferIP6(), }) { // Resolve fallback if (len(ips) == 0 || err != nil) && strategy.hasFallback() && localAddr == nil { - ips, err = dnsClient.LookupIP(domain, dns.IPOption{ + ips, _, err = dnsClient.LookupIP(domain, dns.IPOption{ IPv4Enable: strategy.fallbackIP4(), IPv6Enable: strategy.fallbackIP6(), }) From 5922caff89117ca229fb97319fc0de5ff047bb34 Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Wed, 26 Mar 2025 15:48:58 +0330 Subject: [PATCH 770/867] DNS: Add `expectedIPs` as an alias of `expectIPs` (#4551) https://github.com/XTLS/Xray-core/discussions/1903#discussioncomment-5543921 --- app/dns/dns_test.go | 6 +++--- app/dns/nameserver.go | 18 ++++++++---------- infra/conf/dns.go | 15 +++++++++++---- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/app/dns/dns_test.go b/app/dns/dns_test.go index ab985384..4bdc9ae3 100644 --- a/app/dns/dns_test.go +++ b/app/dns/dns_test.go @@ -785,7 +785,7 @@ func TestLocalDomain(t *testing.T) { } } - { // Will match dotless:localhost, but not expectIPs: 127.0.0.2, 127.0.0.3, then matches at dotless: + { // Will match dotless:localhost, but not expectedIPs: 127.0.0.2, 127.0.0.3, then matches at dotless: ips, _, err := client.LookupIP("localhost", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, @@ -800,7 +800,7 @@ func TestLocalDomain(t *testing.T) { } } - { // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3 + { // Will match dotless:localhost, and expectedIPs: 127.0.0.2, 127.0.0.3 ips, _, err := client.LookupIP("localhost-a", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, @@ -815,7 +815,7 @@ func TestLocalDomain(t *testing.T) { } } - { // Will match dotless:localhost, and expectIPs: 127.0.0.2, 127.0.0.3 + { // Will match dotless:localhost, and expectedIPs: 127.0.0.2, 127.0.0.3 ips, _, err := client.LookupIP("localhost-b", feature_dns.IPOption{ IPv4Enable: true, IPv6Enable: true, diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index 774d87c3..1a5ab3b6 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -30,13 +30,13 @@ type Client struct { clientIP net.IP skipFallback bool domains []string - expectIPs []*router.GeoIPMatcher + expectedIPs []*router.GeoIPMatcher allowUnexpectedIPs bool tag string timeoutMs time.Duration } -var errExpectedIPNonMatch = errors.New("expectIPs not match") +var errExpectedIPNonMatch = errors.New("expectedIPs not match") // NewServer creates a name server object according to the network destination url. func NewServer(ctx context.Context, dest net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) (Server, error) { @@ -165,18 +165,16 @@ func NewClient( } } - var timeoutMs time.Duration + var timeoutMs = 4000 * time.Millisecond if ns.TimeoutMs > 0 { timeoutMs = time.Duration(ns.TimeoutMs) * time.Millisecond - } else { - timeoutMs = 4000 * time.Millisecond } - + client.server = server client.clientIP = clientIP client.skipFallback = ns.SkipFallback client.domains = rules - client.expectIPs = matchers + client.expectedIPs = matchers client.allowUnexpectedIPs = ns.AllowUnexpectedIPs client.tag = ns.Tag client.timeoutMs = timeoutMs @@ -212,12 +210,12 @@ func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption // MatchExpectedIPs matches queried domain IPs with expected IPs and returns matched ones. func (c *Client) MatchExpectedIPs(domain string, ips []net.IP) ([]net.IP, error) { - if len(c.expectIPs) == 0 { + if len(c.expectedIPs) == 0 { return ips, nil } newIps := []net.IP{} for _, ip := range ips { - for _, matcher := range c.expectIPs { + for _, matcher := range c.expectedIPs { if matcher.Match(ip) { newIps = append(newIps, ip) break @@ -230,7 +228,7 @@ func (c *Client) MatchExpectedIPs(domain string, ips []net.IP) ([]net.IP, error) } return nil, errExpectedIPNonMatch } - errors.LogDebug(context.Background(), "domain ", domain, " expectIPs ", newIps, " matched at server ", c.Name()) + errors.LogDebug(context.Background(), "domain ", domain, " expectedIPs ", newIps, " matched at server ", c.Name()) return newIps, nil } diff --git a/infra/conf/dns.go b/infra/conf/dns.go index 20051447..607cbf07 100644 --- a/infra/conf/dns.go +++ b/infra/conf/dns.go @@ -17,7 +17,8 @@ type NameServerConfig struct { Port uint16 `json:"port"` SkipFallback bool `json:"skipFallback"` Domains []string `json:"domains"` - ExpectIPs StringList `json:"expectIps"` + ExpectedIPs StringList `json:"expectedIPs"` + ExpectIPs StringList `json:"expectIPs"` QueryStrategy string `json:"queryStrategy"` AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` Tag string `json:"tag"` @@ -37,7 +38,8 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { Port uint16 `json:"port"` SkipFallback bool `json:"skipFallback"` Domains []string `json:"domains"` - ExpectIPs StringList `json:"expectIps"` + ExpectedIPs StringList `json:"expectedIPs"` + ExpectIPs StringList `json:"expectIPs"` QueryStrategy string `json:"queryStrategy"` AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` Tag string `json:"tag"` @@ -49,6 +51,7 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { c.Port = advanced.Port c.SkipFallback = advanced.SkipFallback c.Domains = advanced.Domains + c.ExpectedIPs = advanced.ExpectedIPs c.ExpectIPs = advanced.ExpectIPs c.QueryStrategy = advanced.QueryStrategy c.AllowUnexpectedIPs = advanced.AllowUnexpectedIPs @@ -101,9 +104,13 @@ func (c *NameServerConfig) Build() (*dns.NameServer, error) { }) } - geoipList, err := ToCidrList(c.ExpectIPs) + var expectedIPs = c.ExpectedIPs + if len(expectedIPs) == 0 { + expectedIPs = c.ExpectIPs + } + geoipList, err := ToCidrList(expectedIPs) if err != nil { - return nil, errors.New("invalid IP rule: ", c.ExpectIPs).Base(err) + return nil, errors.New("invalid IP rule: ", expectedIPs).Base(err) } var myClientIP []byte From e129b1e90d6d68c5f2402a1981a45482584d45a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 26 Mar 2025 12:20:17 +0000 Subject: [PATCH 771/867] Bump google.golang.org/protobuf from 1.36.5 to 1.36.6 (#4549) Bumps google.golang.org/protobuf from 1.36.5 to 1.36.6. --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 456b3ab4..57bf8b99 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( golang.org/x/sys v0.31.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.71.0 - google.golang.org/protobuf v1.36.5 + google.golang.org/protobuf v1.36.6 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.4.0 diff --git a/go.sum b/go.sum index a43edf73..aacd27ca 100644 --- a/go.sum +++ b/go.sum @@ -147,8 +147,8 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg= google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= -google.golang.org/protobuf v1.36.5 h1:tPhr+woSbjfYvY6/GPufUoYizxw1cF/yFoxJ2fmpwlM= -google.golang.org/protobuf v1.36.5/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= +google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 29e37e8a826a273f37f1d7ecae0f834d0dea0bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Wed, 26 Mar 2025 20:30:48 +0800 Subject: [PATCH 772/867] HTTP inbound: Directly forward plain HTTP 1xx response header (#4547) Fixes https://github.com/XTLS/Xray-core/issues/4545 --- proxy/http/server.go | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/proxy/http/server.go b/proxy/http/server.go index 24708e69..3721dd47 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -294,7 +294,7 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, wri responseDone := func() error { responseReader := bufio.NewReaderSize(&buf.BufferedReader{Reader: link.Reader}, buf.Size) - response, err := http.ReadResponse(responseReader, request) + response, err := readResponseAndHandle100Continue(responseReader, request, writer) if err == nil { http_proto.RemoveHopByHopHeaders(response.Header) if response.ContentLength >= 0 { @@ -338,6 +338,38 @@ func (s *Server) handlePlainHTTP(ctx context.Context, request *http.Request, wri return result } +// Sometimes, server might send 1xx response to client +// it should not be processed by http proxy handler, just forward it to client +func readResponseAndHandle100Continue(r *bufio.Reader, req *http.Request, writer io.Writer) (*http.Response, error) { + // have a little look of response + peekBytes, err := r.Peek(56) + if err == nil || err == bufio.ErrBufferFull { + str := string(peekBytes) + ResponseLine := strings.Split(str, "\r\n")[0] + _, status, _ := strings.Cut(ResponseLine, " ") + // only handle 1xx response + if strings.HasPrefix(status, "1") { + ResponseHeader1xx := []byte{} + // read until \r\n\r\n (end of http response header) + for { + data, err := r.ReadSlice('\n') + if err != nil { + return nil, errors.New("failed to read http 1xx response").Base(err) + } + ResponseHeader1xx = append(ResponseHeader1xx, data...) + if bytes.Equal(ResponseHeader1xx[len(ResponseHeader1xx)-4:], []byte{'\r', '\n', '\r', '\n'}) { + break + } + if len(ResponseHeader1xx) > 1024 { + return nil, errors.New("too big http 1xx response") + } + } + writer.Write(ResponseHeader1xx) + } + } + return http.ReadResponse(r, req) +} + func init() { common.Must(common.RegisterConfig((*ServerConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) { return NewServer(ctx, config.(*ServerConfig)) From 8530bdb0ded4b5f1c91df11c2e65cda194fe1a8e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 29 Mar 2025 13:42:20 +0000 Subject: [PATCH 773/867] Bump golang.org/x/net from 0.37.0 to 0.38.0 (#4561) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.37.0 to 0.38.0. - [Commits](https://github.com/golang/net/compare/v0.37.0...v0.38.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 57bf8b99..c7047ed0 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.36.0 - golang.org/x/net v0.37.0 + golang.org/x/net v0.38.0 golang.org/x/sync v0.12.0 golang.org/x/sys v0.31.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index aacd27ca..d4df8932 100644 --- a/go.sum +++ b/go.sum @@ -107,8 +107,8 @@ golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= -golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= +golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= From 681e943848b0dbc03f2c45e9ad6f736f97688b47 Mon Sep 17 00:00:00 2001 From: Pk-web6936 <202365630+Pk-web6936@users.noreply.github.com> Date: Sat, 29 Mar 2025 17:16:26 +0330 Subject: [PATCH 774/867] Chore: Optimize .gitignore (#4564) --- .gitignore | 17 +++++++++++++++-- common/protocol/tls/cert/.gitignore | 2 -- 2 files changed, 15 insertions(+), 4 deletions(-) delete mode 100644 common/protocol/tls/cert/.gitignore diff --git a/.gitignore b/.gitignore index 22469b88..ac744f79 100644 --- a/.gitignore +++ b/.gitignore @@ -14,10 +14,18 @@ # Dependency directories (remove the comment below to include it) # vendor/ +# macOS specific files *.DS_Store -.idea + +# IDE specific files +.idea/ +.vscode/ + +# Archive files *.zip *.tar.gz + +# Binaries xray xray_softfloat mockgen @@ -26,8 +34,13 @@ vprotogen errorgen !common/errors/errorgen/ *.dat -.vscode + +# Build assets /build_assets # Output from dlv test **/debug.* + +# Certificates +*.crt +*.key diff --git a/common/protocol/tls/cert/.gitignore b/common/protocol/tls/cert/.gitignore deleted file mode 100644 index b8987f0b..00000000 --- a/common/protocol/tls/cert/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.crt -*.key \ No newline at end of file From 1685c61e442ece0da357254f69c6b264d13c193d Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Sat, 29 Mar 2025 17:35:27 +0330 Subject: [PATCH 775/867] DNS: Use cache for NXDOMAIN (rcode 3 error) (#4560) https://github.com/XTLS/Xray-core/pull/4558#issuecomment-2759007356 --- app/dns/nameserver_doh.go | 2 +- app/dns/nameserver_quic.go | 2 +- app/dns/nameserver_tcp.go | 2 +- app/dns/nameserver_udp.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index 8a23e0c3..6cdb8ee7 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -357,7 +357,7 @@ func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, clientIP net errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err == nil || err == dns_feature.ErrEmptyResponse { + if err == nil || err == dns_feature.ErrEmptyResponse || dns_feature.RCodeFromError(err) == 3 { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, ttl, err diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 2b0b7b66..6ce5809b 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -300,7 +300,7 @@ func (s *QUICNameServer) QueryIP(ctx context.Context, domain string, clientIP ne errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err == nil || err == dns_feature.ErrEmptyResponse { + if err == nil || err == dns_feature.ErrEmptyResponse || dns_feature.RCodeFromError(err) == 3 { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, ttl, err diff --git a/app/dns/nameserver_tcp.go b/app/dns/nameserver_tcp.go index d84974b0..49854312 100644 --- a/app/dns/nameserver_tcp.go +++ b/app/dns/nameserver_tcp.go @@ -325,7 +325,7 @@ func (s *TCPNameServer) QueryIP(ctx context.Context, domain string, clientIP net errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err == nil || err == dns_feature.ErrEmptyResponse { + if err == nil || err == dns_feature.ErrEmptyResponse || dns_feature.RCodeFromError(err) == 3 { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, ttl, err diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index 79df14ed..23803efa 100644 --- a/app/dns/nameserver_udp.go +++ b/app/dns/nameserver_udp.go @@ -282,7 +282,7 @@ func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, clientIP errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) } else { ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err == nil || err == dns_feature.ErrEmptyResponse { + if err == nil || err == dns_feature.ErrEmptyResponse || dns_feature.RCodeFromError(err) == 3 { errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, ttl, err From 52a2c636825e35e2110b1bd575fddd6ac28ec014 Mon Sep 17 00:00:00 2001 From: xqzr <34030394+xqzr@users.noreply.github.com> Date: Mon, 31 Mar 2025 04:51:36 +0800 Subject: [PATCH 776/867] Sockopt: Fix Windows Multicast `interface` bind (#4568) https://github.com/XTLS/Xray-core/pull/4568#issuecomment-2763492336 --- transport/internet/sockopt_windows.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/transport/internet/sockopt_windows.go b/transport/internet/sockopt_windows.go index fa45011d..e1c1d25e 100644 --- a/transport/internet/sockopt_windows.go +++ b/transport/internet/sockopt_windows.go @@ -13,6 +13,8 @@ const ( TCP_FASTOPEN = 15 IP_UNICAST_IF = 31 IPV6_UNICAST_IF = 31 + IP_MULTICAST_IF = 9 + IPV6_MULTICAST_IF = 9 ) func setTFO(fd syscall.Handle, tfo int) error { @@ -41,10 +43,16 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, IP_UNICAST_IF, int(idx)); err != nil { return errors.New("failed to set IP_UNICAST_IF").Base(err) } + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, IP_MULTICAST_IF, int(idx)); err != nil { + return errors.New("failed to set IP_MULTICAST_IF").Base(err) + } } else { if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_UNICAST_IF, inf.Index); err != nil { return errors.New("failed to set IPV6_UNICAST_IF").Base(err) } + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_MULTICAST_IF, inf.Index); err != nil { + return errors.New("failed to set IPV6_MULTICAST_IF").Base(err) + } } } From 17207fc5e4ab3eb594a2671cfdca229cae546d8f Mon Sep 17 00:00:00 2001 From: Ilya Gulya Date: Mon, 31 Mar 2025 03:50:25 +0500 Subject: [PATCH 777/867] WireGuard: Improve config error handling; Prevent panic in case of errors during server initialization (#4566) https://github.com/XTLS/Xray-core/pull/4566#issuecomment-2764779273 --- infra/conf/wireguard.go | 6 +++- infra/conf/xray.go | 40 ++++++++++++------------ proxy/wireguard/gvisortun/tun.go | 13 ++++---- proxy/wireguard/server_test.go | 52 ++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 28 deletions(-) create mode 100644 proxy/wireguard/server_test.go diff --git a/infra/conf/wireguard.go b/infra/conf/wireguard.go index 9952101a..34ce7215 100644 --- a/infra/conf/wireguard.go +++ b/infra/conf/wireguard.go @@ -67,7 +67,7 @@ func (c *WireGuardConfig) Build() (proto.Message, error) { var err error config.SecretKey, err = ParseWireGuardKey(c.SecretKey) if err != nil { - return nil, err + return nil, errors.New("invalid WireGuard secret key: %w", err) } if c.Address == nil { @@ -126,6 +126,10 @@ func (c *WireGuardConfig) Build() (proto.Message, error) { func ParseWireGuardKey(str string) (string, error) { var err error + if str == "" { + return "", errors.New("key must not be empty") + } + if len(str)%2 == 0 { _, err = hex.DecodeString(str) if err == nil { diff --git a/infra/conf/xray.go b/infra/conf/xray.go index a9cc88bc..4b084b56 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -241,14 +241,14 @@ func (c *InboundDetourConfig) Build() (*core.InboundHandlerConfig, error) { } rawConfig, err := inboundConfigLoader.LoadWithID(settings, c.Protocol) if err != nil { - return nil, errors.New("failed to load inbound detour config.").Base(err) + return nil, errors.New("failed to load inbound detour config for protocol ", c.Protocol).Base(err) } if dokodemoConfig, ok := rawConfig.(*DokodemoConfig); ok { receiverSettings.ReceiveOriginalDestination = dokodemoConfig.Redirect } ts, err := rawConfig.(Buildable).Build() if err != nil { - return nil, err + return nil, errors.New("failed to build inbound handler for protocol ", c.Protocol).Base(err) } return &core.InboundHandlerConfig{ @@ -303,7 +303,7 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) { if c.StreamSetting != nil { ss, err := c.StreamSetting.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build stream settings for outbound detour").Base(err) } senderSettings.StreamSettings = ss } @@ -311,7 +311,7 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) { if c.ProxySettings != nil { ps, err := c.ProxySettings.Build() if err != nil { - return nil, errors.New("invalid outbound detour proxy settings.").Base(err) + return nil, errors.New("invalid outbound detour proxy settings").Base(err) } if ps.TransportLayerProxy { if senderSettings.StreamSettings != nil { @@ -331,7 +331,7 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) { if c.MuxSettings != nil { ms, err := c.MuxSettings.Build() if err != nil { - return nil, errors.New("failed to build Mux config.").Base(err) + return nil, errors.New("failed to build Mux config").Base(err) } senderSettings.MultiplexSettings = ms } @@ -342,11 +342,11 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) { } rawConfig, err := outboundConfigLoader.LoadWithID(settings, c.Protocol) if err != nil { - return nil, errors.New("failed to parse to outbound detour config.").Base(err) + return nil, errors.New("failed to load outbound detour config for protocol ", c.Protocol).Base(err) } ts, err := rawConfig.(Buildable).Build() if err != nil { - return nil, err + return nil, errors.New("failed to build outbound handler for protocol ", c.Protocol).Base(err) } return &core.OutboundHandlerConfig{ @@ -490,7 +490,7 @@ func (c *Config) Override(o *Config, fn string) { // Build implements Buildable. func (c *Config) Build() (*core.Config, error) { if err := PostProcessConfigureFile(c); err != nil { - return nil, err + return nil, errors.New("failed to post-process configuration file").Base(err) } config := &core.Config{ @@ -504,21 +504,21 @@ func (c *Config) Build() (*core.Config, error) { if c.API != nil { apiConf, err := c.API.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build API configuration").Base(err) } config.App = append(config.App, serial.ToTypedMessage(apiConf)) } if c.Metrics != nil { metricsConf, err := c.Metrics.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build metrics configuration").Base(err) } config.App = append(config.App, serial.ToTypedMessage(metricsConf)) } if c.Stats != nil { statsConf, err := c.Stats.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build stats configuration").Base(err) } config.App = append(config.App, serial.ToTypedMessage(statsConf)) } @@ -536,7 +536,7 @@ func (c *Config) Build() (*core.Config, error) { if c.RouterConfig != nil { routerConfig, err := c.RouterConfig.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build routing configuration").Base(err) } config.App = append(config.App, serial.ToTypedMessage(routerConfig)) } @@ -544,7 +544,7 @@ func (c *Config) Build() (*core.Config, error) { if c.DNSConfig != nil { dnsApp, err := c.DNSConfig.Build() if err != nil { - return nil, errors.New("failed to parse DNS config").Base(err) + return nil, errors.New("failed to build DNS configuration").Base(err) } config.App = append(config.App, serial.ToTypedMessage(dnsApp)) } @@ -552,7 +552,7 @@ func (c *Config) Build() (*core.Config, error) { if c.Policy != nil { pc, err := c.Policy.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build policy configuration").Base(err) } config.App = append(config.App, serial.ToTypedMessage(pc)) } @@ -560,7 +560,7 @@ func (c *Config) Build() (*core.Config, error) { if c.Reverse != nil { r, err := c.Reverse.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build reverse configuration").Base(err) } config.App = append(config.App, serial.ToTypedMessage(r)) } @@ -568,7 +568,7 @@ func (c *Config) Build() (*core.Config, error) { if c.FakeDNS != nil { r, err := c.FakeDNS.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build fake DNS configuration").Base(err) } config.App = append([]*serial.TypedMessage{serial.ToTypedMessage(r)}, config.App...) } @@ -576,7 +576,7 @@ func (c *Config) Build() (*core.Config, error) { if c.Observatory != nil { r, err := c.Observatory.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build observatory configuration").Base(err) } config.App = append(config.App, serial.ToTypedMessage(r)) } @@ -584,7 +584,7 @@ func (c *Config) Build() (*core.Config, error) { if c.BurstObservatory != nil { r, err := c.BurstObservatory.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build burst observatory configuration").Base(err) } config.App = append(config.App, serial.ToTypedMessage(r)) } @@ -602,7 +602,7 @@ func (c *Config) Build() (*core.Config, error) { for _, rawInboundConfig := range inbounds { ic, err := rawInboundConfig.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build inbound config with tag ", rawInboundConfig.Tag).Base(err) } config.Inbound = append(config.Inbound, ic) } @@ -616,7 +616,7 @@ func (c *Config) Build() (*core.Config, error) { for _, rawOutboundConfig := range outbounds { oc, err := rawOutboundConfig.Build() if err != nil { - return nil, err + return nil, errors.New("failed to build outbound config with tag ", rawOutboundConfig.Tag).Base(err) } config.Outbound = append(config.Outbound, oc) } diff --git a/proxy/wireguard/gvisortun/tun.go b/proxy/wireguard/gvisortun/tun.go index 65677c48..2f9aa33c 100644 --- a/proxy/wireguard/gvisortun/tun.go +++ b/proxy/wireguard/gvisortun/tun.go @@ -10,6 +10,7 @@ import ( "fmt" "net/netip" "os" + "sync" "syscall" "golang.zx2c4.com/wireguard/tun" @@ -33,6 +34,7 @@ type netTun struct { incomingPacket chan *buffer.View mtu int hasV4, hasV6 bool + closeOnce sync.Once } type Net netTun @@ -174,18 +176,15 @@ func (tun *netTun) Flush() error { // Close implements tun.Device func (tun *netTun) Close() error { - tun.stack.RemoveNIC(1) + tun.closeOnce.Do(func() { + tun.stack.RemoveNIC(1) - if tun.events != nil { close(tun.events) - } - tun.ep.Close() + tun.ep.Close() - if tun.incomingPacket != nil { close(tun.incomingPacket) - } - + }) return nil } diff --git a/proxy/wireguard/server_test.go b/proxy/wireguard/server_test.go new file mode 100644 index 00000000..057b508e --- /dev/null +++ b/proxy/wireguard/server_test.go @@ -0,0 +1,52 @@ +package wireguard_test + +import ( + "context" + "github.com/stretchr/testify/assert" + "runtime/debug" + "testing" + + "github.com/xtls/xray-core/core" + "github.com/xtls/xray-core/proxy/wireguard" +) + +// TestWireGuardServerInitializationError verifies that an error during TUN initialization +// (triggered by an empty SecretKey) in the WireGuard server does not cause a panic and returns an error instead. +func TestWireGuardServerInitializationError(t *testing.T) { + // Create a minimal core instance with default features + config := &core.Config{} + instance, err := core.New(config) + if err != nil { + t.Fatalf("Failed to create core instance: %v", err) + } + // Set the Xray instance in the context + ctx := context.WithValue(context.Background(), core.XrayKey(1), instance) + + // Define the server configuration with an empty SecretKey to trigger error + conf := &wireguard.DeviceConfig{ + IsClient: false, + Endpoint: []string{"10.0.0.1/32"}, + Mtu: 1420, + SecretKey: "", // Empty SecretKey to trigger error + Peers: []*wireguard.PeerConfig{ + { + PublicKey: "some_public_key", + AllowedIps: []string{"10.0.0.2/32"}, + }, + }, + } + + // Use defer to catch any panic and fail the test explicitly + defer func() { + if r := recover(); r != nil { + t.Errorf("TUN initialization panicked: %v", r) + debug.PrintStack() + } + }() + + // Attempt to initialize the WireGuard server + _, err = wireguard.NewServer(ctx, conf) + + // Check that an error is returned + assert.ErrorContains(t, err, "failed to set private_key: hex string does not fit the slice") +} From 8284a0ef8f1ee3774982cb6e53f53848401fa3a5 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 31 Mar 2025 10:09:33 +0000 Subject: [PATCH 778/867] Dialer: Do not use ListenSystemPacket() when dialing UDP https://github.com/XTLS/Xray-core/pull/4530#issuecomment-2765744961 --- transport/internet/system_dialer.go | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index 0b3c2f10..63365099 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -59,7 +59,17 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne Port: 0, } } - packetConn, err := ListenSystemPacket(ctx, srcAddr, sockopt) + var lc net.ListenConfig + lc.Control = func(network, address string, c syscall.RawConn) error { + return c.Control(func(fd uintptr) { + if sockopt != nil { + if err := applyOutboundSocketOptions(network, "", fd, sockopt); err != nil { + errors.LogInfo(ctx, err, "failed to apply socket options") + } + } + }) + } + packetConn, err := lc.ListenPacket(ctx, srcAddr.Network(), srcAddr.String()) if err != nil { return nil, err } @@ -67,23 +77,6 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne if err != nil { return nil, err } - if sockopt != nil { - sys, err := packetConn.(*net.UDPConn).SyscallConn() - if err != nil { - return nil, err - } - sys.Control(func(fd uintptr) { - var network string - if destAddr.IP.To4() != nil { - network = "udp4" - } else { - network = "udp6" - } - if err := applyOutboundSocketOptions(network, dest.NetAddr(), fd, sockopt); err != nil { - errors.LogInfo(ctx, err, "failed to apply socket options") - } - }) - } return &PacketConnWrapper{ Conn: packetConn, Dest: destAddr, From 63eb0539b3fcdceda7144703b73cb9f878946c89 Mon Sep 17 00:00:00 2001 From: 92613hjh <204437135+92613hjh@users.noreply.github.com> Date: Mon, 31 Mar 2025 19:19:06 +0800 Subject: [PATCH 779/867] Sockopt: Fix Darwin (macOS, iOS...) UDP `interface` bind (#4530) Fixes https://github.com/XTLS/Xray-core/issues/4007 --- transport/internet/sockopt_darwin.go | 125 +++++++++++++-------------- 1 file changed, 61 insertions(+), 64 deletions(-) diff --git a/transport/internet/sockopt_darwin.go b/transport/internet/sockopt_darwin.go index 79e2133a..86af492a 100644 --- a/transport/internet/sockopt_darwin.go +++ b/transport/internet/sockopt_darwin.go @@ -1,7 +1,7 @@ package internet import ( - network "net" + gonet "net" "os" "syscall" "unsafe" @@ -108,13 +108,58 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf return err } } - if config.Interface != "" { - InterfaceIndex := getInterfaceIndexByName(config.Interface) - if InterfaceIndex != 0 { - if err := unix.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_BOUND_IF, InterfaceIndex); err != nil { - return errors.New("failed to set Interface").Base(err) + + if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 { + if config.TcpKeepAliveIdle > 0 { + if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil { + return errors.New("failed to set TCP_KEEPINTVL", err) } } + if config.TcpKeepAliveInterval > 0 { + if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, sysTCP_KEEPINTVL, int(config.TcpKeepAliveIdle)); err != nil { + return errors.New("failed to set TCP_KEEPIDLE", err) + } + } + if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1); err != nil { + return errors.New("failed to set SO_KEEPALIVE", err) + } + } else if config.TcpKeepAliveInterval < 0 || config.TcpKeepAliveIdle < 0 { + if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 0); err != nil { + return errors.New("failed to unset SO_KEEPALIVE", err) + } + } + } + + if config.Interface != "" { + iface, err := gonet.InterfaceByName(config.Interface) + + if err != nil { + return errors.New("failed to get interface ", config.Interface).Base(err) + } + if network == "tcp6" || network == "udp6" { + if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_BOUND_IF, iface.Index); err != nil { + return errors.New("failed to set IPV6_BOUND_IF").Base(err) + } + } else { + if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_BOUND_IF, iface.Index); err != nil { + return errors.New("failed to set IP_BOUND_IF").Base(err) + } + } + } + + return nil +} + +func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) error { + if isTCPSocket(network) { + tfo := config.ParseTFOValue() + if tfo > 0 { + tfo = TCP_FASTOPEN_SERVER + } + if tfo >= 0 { + if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, tfo); err != nil { + return err + } } if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 { @@ -138,46 +183,19 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf } } - return nil -} + if config.Interface != "" { + iface, err := gonet.InterfaceByName(config.Interface) -func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) error { - if isTCPSocket(network) { - tfo := config.ParseTFOValue() - if tfo > 0 { - tfo = TCP_FASTOPEN_SERVER + if err != nil { + return errors.New("failed to get interface ", config.Interface).Base(err) } - if tfo >= 0 { - if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, tfo); err != nil { - return err + if network == "tcp6" || network == "udp6" { + if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_BOUND_IF, iface.Index); err != nil { + return errors.New("failed to set IPV6_BOUND_IF").Base(err) } - } - if config.Interface != "" { - InterfaceIndex := getInterfaceIndexByName(config.Interface) - if InterfaceIndex != 0 { - if err := unix.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_BOUND_IF, InterfaceIndex); err != nil { - return errors.New("failed to set Interface").Base(err) - } - } - } - - if config.TcpKeepAliveIdle > 0 || config.TcpKeepAliveInterval > 0 { - if config.TcpKeepAliveIdle > 0 { - if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_KEEPALIVE, int(config.TcpKeepAliveInterval)); err != nil { - return errors.New("failed to set TCP_KEEPINTVL", err) - } - } - if config.TcpKeepAliveInterval > 0 { - if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, sysTCP_KEEPINTVL, int(config.TcpKeepAliveIdle)); err != nil { - return errors.New("failed to set TCP_KEEPIDLE", err) - } - } - if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 1); err != nil { - return errors.New("failed to set SO_KEEPALIVE", err) - } - } else if config.TcpKeepAliveInterval < 0 || config.TcpKeepAliveIdle < 0 { - if err := unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_KEEPALIVE, 0); err != nil { - return errors.New("failed to unset SO_KEEPALIVE", err) + } else { + if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_IP, unix.IP_BOUND_IF, iface.Index); err != nil { + return errors.New("failed to set IP_BOUND_IF").Base(err) } } } @@ -224,24 +242,3 @@ func setReusePort(fd uintptr) error { } return nil } -func getInterfaceIndexByName(name string) int { - ifaces, err := network.Interfaces() - if err == nil { - for _, iface := range ifaces { - if (iface.Flags&network.FlagUp == network.FlagUp) && (iface.Flags&network.FlagLoopback != network.FlagLoopback) { - addrs, _ := iface.Addrs() - for _, addr := range addrs { - if ipnet, ok := addr.(*network.IPNet); ok && !ipnet.IP.IsLoopback() { - if ipnet.IP.To4() != nil { - if iface.Name == name { - return iface.Index - } - } - } - } - } - - } - } - return 0 -} From 2abeda9c4222ad7b2a300cdd8d46c2b256896178 Mon Sep 17 00:00:00 2001 From: xqzr <34030394+xqzr@users.noreply.github.com> Date: Mon, 31 Mar 2025 20:13:57 +0800 Subject: [PATCH 780/867] Sockopt: Allow listen `v6only` work for Windows & Darwin (#4571) Completes https://github.com/XTLS/Xray-core/pull/1677 --------- Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- transport/internet/sockopt_darwin.go | 6 ++++++ transport/internet/sockopt_windows.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/transport/internet/sockopt_darwin.go b/transport/internet/sockopt_darwin.go index 86af492a..f684de98 100644 --- a/transport/internet/sockopt_darwin.go +++ b/transport/internet/sockopt_darwin.go @@ -200,6 +200,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) } } + if config.V6Only { + if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_IPV6, unix.IPV6_V6ONLY, 1); err != nil { + return errors.New("failed to set IPV6_V6ONLY").Base(err) + } + } + return nil } diff --git a/transport/internet/sockopt_windows.go b/transport/internet/sockopt_windows.go index e1c1d25e..cbd3b41e 100644 --- a/transport/internet/sockopt_windows.go +++ b/transport/internet/sockopt_windows.go @@ -15,6 +15,7 @@ const ( IPV6_UNICAST_IF = 31 IP_MULTICAST_IF = 9 IPV6_MULTICAST_IF = 9 + IPV6_V6ONLY = 27 ) func setTFO(fd syscall.Handle, tfo int) error { @@ -90,6 +91,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) } } + if config.V6Only { + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_V6ONLY, 1); err != nil { + return errors.New("failed to set IPV6_V6ONLY").Base(err) + } + } + return nil } From ab5d7cf3d2d678de7ecb749ea5177852eb08ac57 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Mon, 31 Mar 2025 12:33:38 +0000 Subject: [PATCH 781/867] v25.3.31 Announcement of NFTs by Project X: https://github.com/XTLS/Xray-core/discussions/3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 345f9daf..4e512118 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 25 Version_y byte = 3 - Version_z byte = 6 + Version_z byte = 31 ) var ( From 33a4336b1df99ee45991a3e3b8003c8f98560a7f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 10:29:49 -0400 Subject: [PATCH 782/867] Bump github.com/miekg/dns from 1.1.64 to 1.1.65 (#4594) Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.64 to 1.1.65. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.64...v1.1.65) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-version: 1.1.65 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c7047ed0..d7f77c0b 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.7.0 github.com/gorilla/websocket v1.5.3 - github.com/miekg/dns v1.1.64 + github.com/miekg/dns v1.1.65 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.0 github.com/quic-go/quic-go v0.50.1 diff --git a/go.sum b/go.sum index d4df8932..1b084cda 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,8 @@ github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0N github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/miekg/dns v1.1.64 h1:wuZgD9wwCE6XMT05UU/mlSko71eRSXEAm2EbjQXLKnQ= -github.com/miekg/dns v1.1.64/go.mod h1:Dzw9769uoKVaLuODMDZz9M6ynFU6Em65csPuoi8G0ck= +github.com/miekg/dns v1.1.65 h1:0+tIPHzUW0GCge7IiK3guGP57VAw7hoPDfApjkMD1Fc= +github.com/miekg/dns v1.1.65/go.mod h1:Dzw9769uoKVaLuODMDZz9M6ynFU6Em65csPuoi8G0ck= github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= From dd2a40e64d1ac4059adc84a43a251d5f4b70d26c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 10:30:33 -0400 Subject: [PATCH 783/867] Bump google.golang.org/grpc from 1.71.0 to 1.71.1 (#4577) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.71.0 to 1.71.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.71.0...v1.71.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d7f77c0b..5e0a65a8 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.12.0 golang.org/x/sys v0.31.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.71.0 + google.golang.org/grpc v1.71.1 google.golang.org/protobuf v1.36.6 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 1b084cda..49891b35 100644 --- a/go.sum +++ b/go.sum @@ -145,8 +145,8 @@ golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uI golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI= google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= -google.golang.org/grpc v1.71.0 h1:kF77BGdPTQ4/JZWMlb9VpJ5pa25aqvVqogsxNHHdeBg= -google.golang.org/grpc v1.71.0/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= +google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= +google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 8b2fe32a33226ecf62a39d4c2d9ca36042196271 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 10:52:54 -0400 Subject: [PATCH 784/867] Bump golang.org/x/sys from 0.31.0 to 0.32.0 (#4595) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.31.0 to 0.32.0. - [Commits](https://github.com/golang/sys/compare/v0.31.0...v0.32.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-version: 0.32.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5e0a65a8..d64d4ccc 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,7 @@ require ( golang.org/x/crypto v0.36.0 golang.org/x/net v0.38.0 golang.org/x/sync v0.12.0 - golang.org/x/sys v0.31.0 + golang.org/x/sys v0.32.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.71.1 google.golang.org/protobuf v1.36.6 diff --git a/go.sum b/go.sum index 49891b35..cd59c05f 100644 --- a/go.sum +++ b/go.sum @@ -121,8 +121,8 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= -golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From ab15822ee3d6346251bc40e7fe21e5039f86efac Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 10:56:34 -0400 Subject: [PATCH 785/867] Bump golang.org/x/sync from 0.12.0 to 0.13.0 (#4596) Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.12.0 to 0.13.0. - [Commits](https://github.com/golang/sync/compare/v0.12.0...v0.13.0) --- updated-dependencies: - dependency-name: golang.org/x/sync dependency-version: 0.13.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d64d4ccc..8eedad9b 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.36.0 golang.org/x/net v0.38.0 - golang.org/x/sync v0.12.0 + golang.org/x/sync v0.13.0 golang.org/x/sys v0.32.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.71.1 diff --git a/go.sum b/go.sum index cd59c05f..a679d458 100644 --- a/go.sum +++ b/go.sum @@ -111,8 +111,8 @@ golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= -golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= +golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= From 0dbab7bcd7738743884d0f30091ed98c60d645fd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Apr 2025 10:56:44 -0400 Subject: [PATCH 786/867] Bump golang.org/x/crypto from 0.36.0 to 0.37.0 (#4597) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.36.0 to 0.37.0. - [Commits](https://github.com/golang/crypto/compare/v0.36.0...v0.37.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-version: 0.37.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 8eedad9b..f62fca59 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.36.0 + golang.org/x/crypto v0.37.0 golang.org/x/net v0.38.0 golang.org/x/sync v0.13.0 golang.org/x/sys v0.32.0 @@ -51,7 +51,7 @@ require ( go.uber.org/mock v0.5.0 // indirect golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/mod v0.23.0 // indirect - golang.org/x/text v0.23.0 // indirect + golang.org/x/text v0.24.0 // indirect golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.30.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect diff --git a/go.sum b/go.sum index a679d458..7873d779 100644 --- a/go.sum +++ b/go.sum @@ -97,8 +97,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= -golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= +golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= @@ -127,8 +127,8 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= -golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= +golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 2d3126b75277e97cb8816228e4a338090d1d61d7 Mon Sep 17 00:00:00 2001 From: Ragavendaran Puliyadi Date: Mon, 7 Apr 2025 21:16:49 +0530 Subject: [PATCH 787/867] Config: Implement missing MarshalJSON for structs having custom UnmarshalJSON (#4585) * conf: implement MarshalJSON for FakeDNSConfig * conf: Rewrite MarshalJSON for PortList decouple PortRange from PortList. * conf: implement MarshalJSON for HostAddress * conf: Add MarshalJSON comments and use pointers. --- infra/conf/cfgcommon/duration/duration.go | 2 ++ infra/conf/common.go | 42 +++++++++++++++++------ infra/conf/dns.go | 18 ++++++++++ infra/conf/fakedns.go | 12 +++++++ 4 files changed, 63 insertions(+), 11 deletions(-) diff --git a/infra/conf/cfgcommon/duration/duration.go b/infra/conf/cfgcommon/duration/duration.go index aed8e613..f1bbd4d7 100644 --- a/infra/conf/cfgcommon/duration/duration.go +++ b/infra/conf/cfgcommon/duration/duration.go @@ -8,11 +8,13 @@ import ( type Duration int64 +// MarshalJSON implements encoding/json.Marshaler.MarshalJSON func (d *Duration) MarshalJSON() ([]byte, error) { dr := time.Duration(*d) return json.Marshal(dr.String()) } +// UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (d *Duration) UnmarshalJSON(b []byte) error { var v interface{} if err := json.Unmarshal(b, &v); err != nil { diff --git a/infra/conf/common.go b/infra/conf/common.go index fa48edea..ab3cfba7 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -23,6 +23,7 @@ func (v StringList) Len() int { return len(v) } +// UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (v *StringList) UnmarshalJSON(data []byte) error { var strarray []string if err := json.Unmarshal(data, &strarray); err == nil { @@ -43,10 +44,12 @@ type Address struct { net.Address } -func (v Address) MarshalJSON() ([]byte, error) { +// MarshalJSON implements encoding/json.Marshaler.MarshalJSON +func (v *Address) MarshalJSON() ([]byte, error) { return json.Marshal(v.Address.String()) } +// UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (v *Address) UnmarshalJSON(data []byte) error { var rawStr string if err := json.Unmarshal(data, &rawStr); err != nil { @@ -81,6 +84,7 @@ func (v Network) Build() net.Network { type NetworkList []Network +// UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (v *NetworkList) UnmarshalJSON(data []byte) error { var strarray []Network if err := json.Unmarshal(data, &strarray); err == nil { @@ -169,6 +173,19 @@ func (v *PortRange) Build() *net.PortRange { } } +// MarshalJSON implements encoding/json.Marshaler.MarshalJSON +func (v *PortRange) MarshalJSON() ([]byte, error) { + return json.Marshal(v.String()) +} + +func (port *PortRange) String() string { + if port.From == port.To { + return strconv.Itoa(int(port.From)) + } else { + return fmt.Sprintf("%d-%d", port.From, port.To) + } +} + // UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (v *PortRange) UnmarshalJSON(data []byte) error { port, err := parseIntPort(data) @@ -203,20 +220,21 @@ func (list *PortList) Build() *net.PortList { return portList } -func (v PortList) MarshalJSON() ([]byte, error) { - return json.Marshal(v.String()) +// MarshalJSON implements encoding/json.Marshaler.MarshalJSON +func (v *PortList) MarshalJSON() ([]byte, error) { + portStr := v.String() + port, err := strconv.Atoi(portStr) + if err == nil { + return json.Marshal(port) + } else { + return json.Marshal(portStr) + } } func (v PortList) String() string { ports := []string{} for _, port := range v.Range { - if port.From == port.To { - p := strconv.Itoa(int(port.From)) - ports = append(ports, p) - } else { - p := fmt.Sprintf("%d-%d", port.From, port.To) - ports = append(ports, p) - } + ports = append(ports, port.String()) } return strings.Join(ports, ",") } @@ -277,7 +295,8 @@ type Int32Range struct { To int32 } -func (v Int32Range) MarshalJSON() ([]byte, error) { +// MarshalJSON implements encoding/json.Marshaler.MarshalJSON +func (v *Int32Range) MarshalJSON() ([]byte, error) { return json.Marshal(v.String()) } @@ -289,6 +308,7 @@ func (v Int32Range) String() string { } } +// UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (v *Int32Range) UnmarshalJSON(data []byte) error { defer v.ensureOrder() var str string diff --git a/infra/conf/dns.go b/infra/conf/dns.go index 607cbf07..7baeda87 100644 --- a/infra/conf/dns.go +++ b/infra/conf/dns.go @@ -25,6 +25,7 @@ type NameServerConfig struct { TimeoutMs uint64 `json:"timeoutMs"` } +// UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (c *NameServerConfig) UnmarshalJSON(data []byte) error { var address Address if err := json.Unmarshal(data, &address); err == nil { @@ -163,6 +164,18 @@ type HostAddress struct { addrs []*Address } +// MarshalJSON implements encoding/json.Marshaler.MarshalJSON +func (h *HostAddress) MarshalJSON() ([]byte, error) { + if (h.addr != nil) != (h.addrs != nil) { + if h.addr != nil { + return json.Marshal(h.addr) + } else if h.addrs != nil { + return json.Marshal(h.addrs) + } + } + return nil, errors.New("unexpected config state") +} + // UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (h *HostAddress) UnmarshalJSON(data []byte) error { addr := new(Address) @@ -208,6 +221,11 @@ func getHostMapping(ha *HostAddress) *dns.Config_HostMapping { } } +// MarshalJSON implements encoding/json.Marshaler.MarshalJSON +func (m *HostsWrapper) MarshalJSON() ([]byte, error) { + return json.Marshal(m.Hosts) +} + // UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (m *HostsWrapper) UnmarshalJSON(data []byte) error { hosts := make(map[string]*HostAddress) diff --git a/infra/conf/fakedns.go b/infra/conf/fakedns.go index 86240366..3aa20115 100644 --- a/infra/conf/fakedns.go +++ b/infra/conf/fakedns.go @@ -20,6 +20,18 @@ type FakeDNSConfig struct { pools []*FakeDNSPoolElementConfig } +// MarshalJSON implements encoding/json.Marshaler.MarshalJSON +func (f *FakeDNSConfig) MarshalJSON() ([]byte, error) { + if (f.pool != nil) != (f.pools != nil) { + if f.pool != nil { + return json.Marshal(f.pool) + } else if f.pools != nil { + return json.Marshal(f.pools) + } + } + return nil, errors.New("unexpected config state") +} + // UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON func (f *FakeDNSConfig) UnmarshalJSON(data []byte) error { var pool FakeDNSPoolElementConfig From 78a1e37e89e7aef498d2a5154349c3b7c79441fc Mon Sep 17 00:00:00 2001 From: xqzr <34030394+xqzr@users.noreply.github.com> Date: Mon, 7 Apr 2025 23:50:07 +0800 Subject: [PATCH 788/867] Sockopt: Use Windows `syscall` (#4581) --- transport/internet/sockopt_windows.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/transport/internet/sockopt_windows.go b/transport/internet/sockopt_windows.go index cbd3b41e..e333309f 100644 --- a/transport/internet/sockopt_windows.go +++ b/transport/internet/sockopt_windows.go @@ -13,9 +13,6 @@ const ( TCP_FASTOPEN = 15 IP_UNICAST_IF = 31 IPV6_UNICAST_IF = 31 - IP_MULTICAST_IF = 9 - IPV6_MULTICAST_IF = 9 - IPV6_V6ONLY = 27 ) func setTFO(fd syscall.Handle, tfo int) error { @@ -44,14 +41,14 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, IP_UNICAST_IF, int(idx)); err != nil { return errors.New("failed to set IP_UNICAST_IF").Base(err) } - if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, IP_MULTICAST_IF, int(idx)); err != nil { + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, int(idx)); err != nil { return errors.New("failed to set IP_MULTICAST_IF").Base(err) } } else { if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_UNICAST_IF, inf.Index); err != nil { return errors.New("failed to set IPV6_UNICAST_IF").Base(err) } - if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_MULTICAST_IF, inf.Index); err != nil { + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, syscall.IPV6_MULTICAST_IF, inf.Index); err != nil { return errors.New("failed to set IPV6_MULTICAST_IF").Base(err) } } @@ -92,7 +89,7 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) } if config.V6Only { - if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_V6ONLY, 1); err != nil { + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY, 1); err != nil { return errors.New("failed to set IPV6_V6ONLY").Base(err) } } From 19e884bebf50f52c9455552e92d7290916dfd366 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 11:17:36 -0400 Subject: [PATCH 789/867] Bump golang.org/x/net from 0.38.0 to 0.39.0 (#4598) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.38.0 to 0.39.0. - [Commits](https://github.com/golang/net/compare/v0.38.0...v0.39.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-version: 0.39.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f62fca59..a8d41c16 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.37.0 - golang.org/x/net v0.38.0 + golang.org/x/net v0.39.0 golang.org/x/sync v0.13.0 golang.org/x/sys v0.32.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 diff --git a/go.sum b/go.sum index 7873d779..beb97337 100644 --- a/go.sum +++ b/go.sum @@ -107,8 +107,8 @@ golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= -golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= +golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= From 53552d73cc9628003d3cf621f74e67926f6868d5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 13 Apr 2025 00:55:00 -0400 Subject: [PATCH 790/867] Bump github.com/cloudflare/circl from 1.6.0 to 1.6.1 (#4602) Bumps [github.com/cloudflare/circl](https://github.com/cloudflare/circl) from 1.6.0 to 1.6.1. - [Release notes](https://github.com/cloudflare/circl/releases) - [Commits](https://github.com/cloudflare/circl/compare/v1.6.0...v1.6.1) --- updated-dependencies: - dependency-name: github.com/cloudflare/circl dependency-version: 1.6.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a8d41c16..b8dadd1a 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.24 require ( github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 - github.com/cloudflare/circl v1.6.0 + github.com/cloudflare/circl v1.6.1 github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.7.0 diff --git a/go.sum b/go.sum index beb97337..76ec3c42 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0 h1:Wo41lDOevRJS github.com/OmarTariq612/goech v0.0.0-20240405204721-8e2e1dafd3a0/go.mod h1:FVGavL/QEBQDcBpr3fAojoK17xX5k9bicBphrOpP7uM= github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= -github.com/cloudflare/circl v1.6.0 h1:cr5JKic4HI+LkINy2lg3W2jF8sHCVTBncJr5gIIq7qk= -github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= +github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0= +github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 7a2f42f8d5f6fc8b347c6a2b06808421bd934868 Mon Sep 17 00:00:00 2001 From: Cl-He-O <93776896+Cl-He-O@users.noreply.github.com> Date: Mon, 14 Apr 2025 15:08:26 +0000 Subject: [PATCH 791/867] Fix issues related to android client (#4616) * WireGuard: Fix tunnel not closed * Dialer: Apply controllers in lc.Control --- app/proxyman/outbound/handler.go | 1 + proxy/wireguard/client.go | 14 ++++++++++++++ transport/internet/system_dialer.go | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 3819f52b..ab44a1d5 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -325,6 +325,7 @@ func (h *Handler) Start() error { // Close implements common.Closable. func (h *Handler) Close() error { common.Close(h.mux) + common.Close(h.proxy) return nil } diff --git a/proxy/wireguard/client.go b/proxy/wireguard/client.go index ff1592ef..345581c7 100644 --- a/proxy/wireguard/client.go +++ b/proxy/wireguard/client.go @@ -77,6 +77,20 @@ func New(ctx context.Context, conf *DeviceConfig) (*Handler, error) { }, nil } +func (h *Handler) Close() (err error) { + go func() { + h.wgLock.Lock() + defer h.wgLock.Unlock() + + if h.net != nil { + _ = h.net.Close() + h.net = nil + } + }() + + return nil +} + func (h *Handler) processWireGuard(ctx context.Context, dialer internet.Dialer) (err error) { h.wgLock.Lock() defer h.wgLock.Unlock() diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index 63365099..cc8f3cc0 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -61,6 +61,11 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne } var lc net.ListenConfig lc.Control = func(network, address string, c syscall.RawConn) error { + for _, ctl := range d.controllers { + if err := ctl(network, address, c); err != nil { + errors.LogInfoInner(ctx, err, "failed to apply external controller") + } + } return c.Control(func(fd uintptr) { if sockopt != nil { if err := applyOutboundSocketOptions(network, "", fd, sockopt); err != nil { From 5f3ae64f0cb6dc8e520b3be69e11cf374c108f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 18 Apr 2025 10:30:47 +0800 Subject: [PATCH 792/867] Sockopt: Allow `customSockopt` work for Windows & Darwin (#4576) * Sockopt: Add custom sockopt on Windows & Darwin * fix windows udp by the way * use resolved addr https://github.com/XTLS/Xray-core/pull/4504#issuecomment-2769153797 --- infra/conf/transport_internet.go | 2 + transport/internet/config.pb.go | 221 ++++++++++++++------------ transport/internet/config.proto | 11 +- transport/internet/sockopt_darwin.go | 80 ++++++++++ transport/internet/sockopt_linux.go | 19 ++- transport/internet/sockopt_windows.go | 81 +++++++++- transport/internet/system_dialer.go | 10 +- 7 files changed, 306 insertions(+), 118 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index e32be326..b4ae0801 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -691,6 +691,7 @@ func (p TransportProtocol) Build() (string, error) { } type CustomSockoptConfig struct { + Syetem string `json:"system"` Network string `json:"network"` Level string `json:"level"` Opt string `json:"opt"` @@ -778,6 +779,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { for _, copt := range c.CustomSockopt { customSockopt := &internet.CustomSockopt{ + System: copt.Syetem, Network: copt.Network, Level: copt.Level, Opt: copt.Opt, diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 37a08143..6aa11b3e 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -417,11 +417,12 @@ type CustomSockopt struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"` - Level string `protobuf:"bytes,2,opt,name=level,proto3" json:"level,omitempty"` - Opt string `protobuf:"bytes,3,opt,name=opt,proto3" json:"opt,omitempty"` - Value string `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` - Type string `protobuf:"bytes,5,opt,name=type,proto3" json:"type,omitempty"` + System string `protobuf:"bytes,1,opt,name=system,proto3" json:"system,omitempty"` + Network string `protobuf:"bytes,2,opt,name=network,proto3" json:"network,omitempty"` + Level string `protobuf:"bytes,3,opt,name=level,proto3" json:"level,omitempty"` + Opt string `protobuf:"bytes,4,opt,name=opt,proto3" json:"opt,omitempty"` + Value string `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"` + Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty"` } func (x *CustomSockopt) Reset() { @@ -454,6 +455,13 @@ func (*CustomSockopt) Descriptor() ([]byte, []int) { return file_transport_internet_config_proto_rawDescGZIP(), []int{3} } +func (x *CustomSockopt) GetSystem() string { + if x != nil { + return x.System + } + return "" +} + func (x *CustomSockopt) GetNetwork() string { if x != nil { return x.Network @@ -748,107 +756,108 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x30, 0x0a, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x74, 0x72, 0x61, 0x6e, 0x73, - 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x22, 0x7b, - 0x0a, 0x0d, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x12, - 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, - 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, - 0x10, 0x0a, 0x03, 0x6f, 0x70, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x70, - 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xfd, 0x07, 0x0a, 0x0c, - 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, - 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, - 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, - 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, - 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, - 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, - 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x06, 0x74, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x41, 0x0a, 0x1d, - 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, - 0x5f, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x69, 0x67, - 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x73, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, - 0x21, 0x0a, 0x0c, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, 0x62, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x62, 0x69, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, 0x62, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x12, - 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, - 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x63, 0x6f, 0x6c, 0x12, 0x50, 0x0a, 0x0f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, 0x5f, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x61, - 0x6c, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x35, 0x0a, 0x17, 0x74, 0x63, 0x70, 0x5f, - 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, - 0x76, 0x61, 0x6c, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x14, 0x74, 0x63, 0x70, 0x4b, 0x65, - 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, - 0x2d, 0x0a, 0x13, 0x74, 0x63, 0x70, 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, - 0x65, 0x5f, 0x69, 0x64, 0x6c, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, 0x63, - 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, 0x49, 0x64, 0x6c, 0x65, 0x12, 0x25, - 0x0a, 0x0e, 0x74, 0x63, 0x70, 0x5f, 0x63, 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x74, 0x63, 0x70, 0x43, 0x6f, 0x6e, 0x67, 0x65, - 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, - 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, - 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0e, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x06, 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x12, 0x28, 0x0a, 0x10, 0x74, - 0x63, 0x70, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x5f, 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x18, - 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, - 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, - 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x65, 0x67, 0x18, 0x11, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, 0x63, 0x70, 0x4d, 0x61, 0x78, 0x53, 0x65, 0x67, 0x12, - 0x1c, 0x0a, 0x09, 0x70, 0x65, 0x6e, 0x65, 0x74, 0x72, 0x61, 0x74, 0x65, 0x18, 0x12, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x09, 0x70, 0x65, 0x6e, 0x65, 0x74, 0x72, 0x61, 0x74, 0x65, 0x12, 0x1b, 0x0a, - 0x09, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x70, 0x74, 0x63, 0x70, 0x18, 0x13, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x08, 0x74, 0x63, 0x70, 0x4d, 0x70, 0x74, 0x63, 0x70, 0x12, 0x4c, 0x0a, 0x0d, 0x63, 0x75, - 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x18, 0x14, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, - 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x43, 0x75, 0x73, 0x74, - 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x52, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, - 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, 0x12, 0x60, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, - 0x79, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x2c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, - 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, - 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x13, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, - 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, - 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, - 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, - 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, - 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, - 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, - 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, - 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, - 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, - 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, - 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, - 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, - 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, - 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, 0x2a, 0x97, 0x01, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, - 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x72, 0x76, - 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x72, - 0x76, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x02, 0x12, 0x15, - 0x0a, 0x11, 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, - 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x54, 0x78, 0x74, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x78, - 0x74, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, - 0x06, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, - 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, - 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, - 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, - 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x70, 0x6f, 0x72, 0x74, 0x4c, 0x61, 0x79, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x22, 0x93, + 0x01, 0x0a, 0x0d, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, 0x74, + 0x12, 0x16, 0x0a, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x12, 0x18, 0x0a, 0x07, 0x6e, 0x65, 0x74, 0x77, + 0x6f, 0x72, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x65, 0x74, 0x77, 0x6f, + 0x72, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x6f, 0x70, 0x74, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, + 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x22, 0xfd, 0x07, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x30, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x2e, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x06, 0x74, + 0x70, 0x72, 0x6f, 0x78, 0x79, 0x12, 0x41, 0x0a, 0x1d, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, + 0x5f, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x64, 0x65, 0x73, 0x74, 0x5f, 0x61, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x1a, 0x72, 0x65, + 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x44, 0x65, 0x73, + 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x69, 0x6e, 0x64, + 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0b, + 0x62, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1b, 0x0a, 0x09, 0x62, + 0x69, 0x6e, 0x64, 0x5f, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x08, + 0x62, 0x69, 0x6e, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x32, 0x0a, 0x15, 0x61, 0x63, 0x63, 0x65, + 0x70, 0x74, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, + 0x6c, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x61, 0x63, 0x63, 0x65, 0x70, 0x74, 0x50, + 0x72, 0x6f, 0x78, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x12, 0x50, 0x0a, 0x0f, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, + 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, + 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, + 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0e, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x21, + 0x0a, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, 0x5f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x18, 0x09, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x69, 0x61, 0x6c, 0x65, 0x72, 0x50, 0x72, 0x6f, 0x78, + 0x79, 0x12, 0x35, 0x0a, 0x17, 0x74, 0x63, 0x70, 0x5f, 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, + 0x69, 0x76, 0x65, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x14, 0x74, 0x63, 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, 0x69, 0x76, 0x65, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c, 0x12, 0x2d, 0x0a, 0x13, 0x74, 0x63, 0x70, 0x5f, + 0x6b, 0x65, 0x65, 0x70, 0x5f, 0x61, 0x6c, 0x69, 0x76, 0x65, 0x5f, 0x69, 0x64, 0x6c, 0x65, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, 0x63, 0x70, 0x4b, 0x65, 0x65, 0x70, 0x41, 0x6c, + 0x69, 0x76, 0x65, 0x49, 0x64, 0x6c, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x74, 0x63, 0x70, 0x5f, 0x63, + 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0d, 0x74, 0x63, 0x70, 0x43, 0x6f, 0x6e, 0x67, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1c, + 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x76, 0x36, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x76, 0x36, + 0x6f, 0x6e, 0x6c, 0x79, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x77, 0x69, 0x6e, 0x64, + 0x6f, 0x77, 0x5f, 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, + 0x74, 0x63, 0x70, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x43, 0x6c, 0x61, 0x6d, 0x70, 0x12, 0x28, + 0x0a, 0x10, 0x74, 0x63, 0x70, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x18, 0x10, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x74, 0x63, 0x70, 0x55, 0x73, 0x65, + 0x72, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1e, 0x0a, 0x0b, 0x74, 0x63, 0x70, 0x5f, + 0x6d, 0x61, 0x78, 0x5f, 0x73, 0x65, 0x67, 0x18, 0x11, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x74, + 0x63, 0x70, 0x4d, 0x61, 0x78, 0x53, 0x65, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x65, 0x6e, 0x65, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x18, 0x12, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x70, 0x65, 0x6e, + 0x65, 0x74, 0x72, 0x61, 0x74, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x63, 0x70, 0x5f, 0x6d, 0x70, + 0x74, 0x63, 0x70, 0x18, 0x13, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x74, 0x63, 0x70, 0x4d, 0x70, + 0x74, 0x63, 0x70, 0x12, 0x4c, 0x0a, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, + 0x6b, 0x6f, 0x70, 0x74, 0x18, 0x14, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, + 0x70, 0x74, 0x52, 0x0d, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x53, 0x6f, 0x63, 0x6b, 0x6f, 0x70, + 0x74, 0x12, 0x60, 0x0a, 0x15, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x70, 0x6f, 0x72, + 0x74, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x15, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x2c, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x13, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, + 0x65, 0x67, 0x79, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, + 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, + 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, + 0x63, 0x74, 0x10, 0x02, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, + 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, + 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, + 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, + 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, + 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, + 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, + 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, + 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, + 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, + 0x2a, 0x97, 0x01, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, + 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, + 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, + 0x79, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x72, 0x76, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x72, 0x76, 0x50, 0x6f, + 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x03, 0x12, 0x0f, + 0x0a, 0x0b, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x04, 0x12, + 0x12, 0x0a, 0x0e, 0x54, 0x78, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, + 0x79, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, + 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x06, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, + 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, + 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, + 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/transport/internet/config.proto b/transport/internet/config.proto index 54479e22..cb892c30 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -65,11 +65,12 @@ message ProxyConfig { } message CustomSockopt { - string network = 1; - string level = 2; - string opt = 3; - string value = 4; - string type = 5; + string system = 1; + string network = 2; + string level = 3; + string opt = 4; + string value = 5; + string type = 6; } // SocketConfig is options to be applied on network sockets. diff --git a/transport/internet/sockopt_darwin.go b/transport/internet/sockopt_darwin.go index f684de98..2c827214 100644 --- a/transport/internet/sockopt_darwin.go +++ b/transport/internet/sockopt_darwin.go @@ -1,8 +1,12 @@ package internet import ( + "context" gonet "net" "os" + "runtime" + "strconv" + "strings" "syscall" "unsafe" @@ -147,6 +151,44 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf } } + if len(config.CustomSockopt) > 0 { + for _, custom := range config.CustomSockopt { + if custom.System != "" && custom.System != runtime.GOOS { + errors.LogDebug(context.Background(), "CustomSockopt system not match: ", "want ", custom.System, " got ", runtime.GOOS) + continue + } + // Skip unwanted network type + // network might be tcp4 or tcp6 + // use HasPrefix so that "tcp" can match tcp4/6 with "tcp" if user want to control all tcp (udp is also the same) + // if it is empty, strings.HasPrefix will always return true to make it apply for all networks + if !strings.HasPrefix(network, custom.Network) { + continue + } + var level = 0x6 // default TCP + var opt int + if len(custom.Opt) == 0 { + return errors.New("No opt!") + } else { + opt, _ = strconv.Atoi(custom.Opt) + } + if custom.Level != "" { + level, _ = strconv.Atoi(custom.Level) + } + if custom.Type == "int" { + value, _ := strconv.Atoi(custom.Value) + if err := syscall.SetsockoptInt(int(fd), level, opt, value); err != nil { + return errors.New("failed to set CustomSockoptInt", opt, value, err) + } + } else if custom.Type == "str" { + if err := syscall.SetsockoptString(int(fd), level, opt, custom.Value); err != nil { + return errors.New("failed to set CustomSockoptString", opt, custom.Value, err) + } + } else { + return errors.New("unknown CustomSockopt type:", custom.Type) + } + } + } + return nil } @@ -206,6 +248,44 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) } } + if len(config.CustomSockopt) > 0 { + for _, custom := range config.CustomSockopt { + if custom.System != "" && custom.System != runtime.GOOS { + errors.LogDebug(context.Background(), "CustomSockopt system not match: ", "want ", custom.System, " got ", runtime.GOOS) + continue + } + // Skip unwanted network type + // network might be tcp4 or tcp6 + // use HasPrefix so that "tcp" can match tcp4/6 with "tcp" if user want to control all tcp (udp is also the same) + // if it is empty, strings.HasPrefix will always return true to make it apply for all networks + if !strings.HasPrefix(network, custom.Network) { + continue + } + var level = 0x6 // default TCP + var opt int + if len(custom.Opt) == 0 { + return errors.New("No opt!") + } else { + opt, _ = strconv.Atoi(custom.Opt) + } + if custom.Level != "" { + level, _ = strconv.Atoi(custom.Level) + } + if custom.Type == "int" { + value, _ := strconv.Atoi(custom.Value) + if err := syscall.SetsockoptInt(int(fd), level, opt, value); err != nil { + return errors.New("failed to set CustomSockoptInt", opt, value, err) + } + } else if custom.Type == "str" { + if err := syscall.SetsockoptString(int(fd), level, opt, custom.Value); err != nil { + return errors.New("failed to set CustomSockoptString", opt, custom.Value, err) + } + } else { + return errors.New("unknown CustomSockopt type:", custom.Type) + } + } + } + return nil } diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index 2d5877ab..aa24cceb 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -1,7 +1,9 @@ package internet import ( + "context" "net" + "runtime" "strconv" "strings" "syscall" @@ -110,11 +112,15 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf if len(config.CustomSockopt) > 0 { for _, custom := range config.CustomSockopt { + if custom.System != "" && custom.System != runtime.GOOS{ + errors.LogDebug(context.Background(), "CustomSockopt system not match: ", "want ", custom.System, " got ", runtime.GOOS) + continue + } // Skip unwanted network type // network might be tcp4 or tcp6 // use HasPrefix so that "tcp" can match tcp4/6 with "tcp" if user want to control all tcp (udp is also the same) // if it is empty, strings.HasPrefix will always return true to make it apply for all networks - if !strings.HasPrefix(network, custom.Network) { + if !strings.HasPrefix(network, custom.Network){ continue } var level = 0x6 // default TCP @@ -212,6 +218,17 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) } if len(config.CustomSockopt) > 0 { for _, custom := range config.CustomSockopt { + if custom.System != "" && custom.System != runtime.GOOS{ + errors.LogDebug(context.Background(), "CustomSockopt system not match: ", "want ", custom.System, " got ", runtime.GOOS) + continue + } + // Skip unwanted network type + // network might be tcp4 or tcp6 + // use HasPrefix so that "tcp" can match tcp4/6 with "tcp" if user want to control all tcp (udp is also the same) + // if it is empty, strings.HasPrefix will always return true to make it apply for all networks + if !strings.HasPrefix(network, custom.Network){ + continue + } var level = 0x6 // default TCP var opt int if len(custom.Opt) == 0 { diff --git a/transport/internet/sockopt_windows.go b/transport/internet/sockopt_windows.go index e333309f..fb8a9703 100644 --- a/transport/internet/sockopt_windows.go +++ b/transport/internet/sockopt_windows.go @@ -1,8 +1,12 @@ package internet import ( + "context" "encoding/binary" "net" + "runtime" + "strconv" + "strings" "syscall" "unsafe" @@ -33,7 +37,10 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf if err != nil { return errors.New("failed to find the interface").Base(err) } - isV4 := (network == "tcp4" || network == "udp4") + // easy way to check if the address is ipv4 + isV4 := strings.Contains(address, ".") + // note: DO NOT trust the passed network variable, it can be udp6 even if the address is ipv4 + // because operating system might(always) use ipv6 socket to process ipv4 if isV4 { var bytes [4]byte binary.BigEndian.PutUint32(bytes[:], uint32(inf.Index)) @@ -69,6 +76,42 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf } } + if len(config.CustomSockopt) > 0 { + for _, custom := range config.CustomSockopt { + if custom.System != "" && custom.System != runtime.GOOS { + errors.LogDebug(context.Background(), "CustomSockopt system not match: ", "want ", custom.System, " got ", runtime.GOOS) + continue + } + // Skip unwanted network type + // network might be tcp4 or tcp6 + // use HasPrefix so that "tcp" can match tcp4/6 with "tcp" if user want to control all tcp (udp is also the same) + // if it is empty, strings.HasPrefix will always return true to make it apply for all networks + if !strings.HasPrefix(network, custom.Network) { + continue + } + var level = 0x6 // default TCP + var opt int + if len(custom.Opt) == 0 { + return errors.New("No opt!") + } else { + opt, _ = strconv.Atoi(custom.Opt) + } + if custom.Level != "" { + level, _ = strconv.Atoi(custom.Level) + } + if custom.Type == "int" { + value, _ := strconv.Atoi(custom.Value) + if err := syscall.SetsockoptInt(syscall.Handle(fd), level, opt, value); err != nil { + return errors.New("failed to set CustomSockoptInt", opt, value, err) + } + } else if custom.Type == "str" { + return errors.New("failed to set CustomSockoptString: Str type does not supported on windows") + } else { + return errors.New("unknown CustomSockopt type:", custom.Type) + } + } + } + return nil } @@ -94,6 +137,42 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) } } + if len(config.CustomSockopt) > 0 { + for _, custom := range config.CustomSockopt { + if custom.System != "" && custom.System != runtime.GOOS { + errors.LogDebug(context.Background(), "CustomSockopt system not match: ", "want ", custom.System, " got ", runtime.GOOS) + continue + } + // Skip unwanted network type + // network might be tcp4 or tcp6 + // use HasPrefix so that "tcp" can match tcp4/6 with "tcp" if user want to control all tcp (udp is also the same) + // if it is empty, strings.HasPrefix will always return true to make it apply for all networks + if !strings.HasPrefix(network, custom.Network) { + continue + } + var level = 0x6 // default TCP + var opt int + if len(custom.Opt) == 0 { + return errors.New("No opt!") + } else { + opt, _ = strconv.Atoi(custom.Opt) + } + if custom.Level != "" { + level, _ = strconv.Atoi(custom.Level) + } + if custom.Type == "int" { + value, _ := strconv.Atoi(custom.Value) + if err := syscall.SetsockoptInt(syscall.Handle(fd), level, opt, value); err != nil { + return errors.New("failed to set CustomSockoptInt", opt, value, err) + } + } else if custom.Type == "str" { + return errors.New("failed to set CustomSockoptString: Str type does not supported on windows") + } else { + return errors.New("unknown CustomSockopt type:", custom.Type) + } + } + } + return nil } diff --git a/transport/internet/system_dialer.go b/transport/internet/system_dialer.go index cc8f3cc0..ba7db103 100644 --- a/transport/internet/system_dialer.go +++ b/transport/internet/system_dialer.go @@ -60,6 +60,10 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne } } var lc net.ListenConfig + destAddr, err := net.ResolveUDPAddr("udp", dest.NetAddr()) + if err != nil { + return nil, err + } lc.Control = func(network, address string, c syscall.RawConn) error { for _, ctl := range d.controllers { if err := ctl(network, address, c); err != nil { @@ -68,7 +72,7 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne } return c.Control(func(fd uintptr) { if sockopt != nil { - if err := applyOutboundSocketOptions(network, "", fd, sockopt); err != nil { + if err := applyOutboundSocketOptions(network, destAddr.String(), fd, sockopt); err != nil { errors.LogInfo(ctx, err, "failed to apply socket options") } } @@ -78,10 +82,6 @@ func (d *DefaultSystemDialer) Dial(ctx context.Context, src net.Address, dest ne if err != nil { return nil, err } - destAddr, err := net.ResolveUDPAddr("udp", dest.NetAddr()) - if err != nil { - return nil, err - } return &PacketConnWrapper{ Conn: packetConn, Dest: destAddr, From 82123259807d3f33d016e7aebe52bc9b1e8e0c17 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 18 Apr 2025 03:18:38 +0000 Subject: [PATCH 793/867] README.md: Add Loon to Others https://t.me/LoonNews/1662 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5090d6e8..de631a31 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,7 @@ - iOS & macOS arm64 - [Shadowrocket](https://apps.apple.com/app/shadowrocket/id932747118) + - [Loon](https://apps.apple.com/us/app/loon/id1373567447) - Xray Tools - [xray-knife](https://github.com/lilendian0x00/xray-knife) - [xray-checker](https://github.com/kutovoys/xray-checker) From 2916b1b977006b7d41daa143dc79ffd2e78705cb Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 18 Apr 2025 03:57:14 +0000 Subject: [PATCH 794/867] README.md: Rename Clash.Meta to mihomo in Others --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index de631a31..d0a21059 100644 --- a/README.md +++ b/README.md @@ -115,10 +115,9 @@ - [XrayR](https://github.com/XrayR-project/XrayR) - [XrayR-release](https://github.com/XrayR-project/XrayR-release) - [XrayR-V2Board](https://github.com/missuo/XrayR-V2Board) -- [Clash.Meta](https://github.com/MetaCubeX/Clash.Meta) - - [clashN](https://github.com/2dust/clashN) - - [Clash Meta for Android](https://github.com/MetaCubeX/ClashMetaForAndroid) -- [sing-box](https://github.com/SagerNet/sing-box) +- Cores + - [mihomo](https://github.com/MetaCubeX/mihomo) + - [sing-box](https://github.com/SagerNet/sing-box) ## Contributing From 0995fa41fe692e332412670665bd934e4c734caa Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 18 Apr 2025 06:18:51 +0000 Subject: [PATCH 795/867] XHTTP client: Set packet-up as the default `mode` (auto) when using TLS https://t.me/projectXtls/929 --- transport/internet/splithttp/dialer.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transport/internet/splithttp/dialer.go b/transport/internet/splithttp/dialer.go index f996a42e..c5fba78b 100644 --- a/transport/internet/splithttp/dialer.go +++ b/transport/internet/splithttp/dialer.go @@ -281,11 +281,11 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me mode := transportConfiguration.Mode if mode == "" || mode == "auto" { mode = "packet-up" - if httpVersion == "2" { - mode = "stream-up" - } - if realityConfig != nil && transportConfiguration.DownloadSettings == nil { + if realityConfig != nil { mode = "stream-one" + if transportConfiguration.DownloadSettings != nil { + mode = "stream-up" + } } } From 907a182f6436e717b56daf52f41f63e630fa9cf5 Mon Sep 17 00:00:00 2001 From: xqzr <34030394+xqzr@users.noreply.github.com> Date: Sat, 19 Apr 2025 17:30:12 +0800 Subject: [PATCH 796/867] Sockopt: Fix Windows IP_MULTICAST_IF & IPV6_MULTICAST_IF (#4627) Completes https://github.com/XTLS/Xray-core/pull/4568 --- transport/internet/sockopt_windows.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/transport/internet/sockopt_windows.go b/transport/internet/sockopt_windows.go index fb8a9703..1389ca06 100644 --- a/transport/internet/sockopt_windows.go +++ b/transport/internet/sockopt_windows.go @@ -41,6 +41,7 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf isV4 := strings.Contains(address, ".") // note: DO NOT trust the passed network variable, it can be udp6 even if the address is ipv4 // because operating system might(always) use ipv6 socket to process ipv4 + host, _, err := net.SplitHostPort(address) if isV4 { var bytes [4]byte binary.BigEndian.PutUint32(bytes[:], uint32(inf.Index)) @@ -48,15 +49,19 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, IP_UNICAST_IF, int(idx)); err != nil { return errors.New("failed to set IP_UNICAST_IF").Base(err) } - if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, int(idx)); err != nil { - return errors.New("failed to set IP_MULTICAST_IF").Base(err) + if ip := net.ParseIP(host); ip != nil && ip.IsMulticast() && isUDPSocket(network) { + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IP, syscall.IP_MULTICAST_IF, int(idx)); err != nil { + return errors.New("failed to set IP_MULTICAST_IF").Base(err) + } } } else { if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, IPV6_UNICAST_IF, inf.Index); err != nil { return errors.New("failed to set IPV6_UNICAST_IF").Base(err) } - if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, syscall.IPV6_MULTICAST_IF, inf.Index); err != nil { - return errors.New("failed to set IPV6_MULTICAST_IF").Base(err) + if ip := net.ParseIP(host); ip != nil && ip.IsMulticast() && isUDPSocket(network) { + if err := syscall.SetsockoptInt(syscall.Handle(fd), syscall.IPPROTO_IPV6, syscall.IPV6_MULTICAST_IF, inf.Index); err != nil { + return errors.New("failed to set IPV6_MULTICAST_IF").Base(err) + } } } } From 0563c9750e149fadae3aff06a1b87b689cb10ec2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 02:57:57 +0000 Subject: [PATCH 797/867] Bump google.golang.org/grpc from 1.71.1 to 1.72.0 (#4640) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.71.1 to 1.72.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.71.1...v1.72.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-version: 1.72.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index b8dadd1a..ec5e4569 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.13.0 golang.org/x/sys v0.32.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.71.1 + google.golang.org/grpc v1.72.0 google.golang.org/protobuf v1.36.6 gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h12.io/socks v1.0.3 @@ -55,7 +55,7 @@ require ( golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.30.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 76ec3c42..1dff5182 100644 --- a/go.sum +++ b/go.sum @@ -143,10 +143,10 @@ golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeu golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f h1:OxYkA3wjPsZyBylwymxSHa7ViiW1Sml4ToBrncvFehI= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f/go.mod h1:+2Yz8+CLJbIfL9z73EW45avw8Lmge3xVElCP9zEKi50= -google.golang.org/grpc v1.71.1 h1:ffsFWr7ygTUscGPI0KKK6TLrGz0476KUvvsbqWK0rPI= -google.golang.org/grpc v1.71.1/go.mod h1:H0GRtasmQOh9LkFoCPDu3ZrwUtD1YGE+b2vYBYd/8Ec= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= +google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= +google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 800b33c626202c7741ef08919d85bbf2e1a9bf9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 02:58:09 +0000 Subject: [PATCH 798/867] Bump github.com/quic-go/quic-go from 0.50.1 to 0.51.0 (#4634) Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.50.1 to 0.51.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Changelog](https://github.com/quic-go/quic-go/blob/master/Changelog.md) - [Commits](https://github.com/quic-go/quic-go/compare/v0.50.1...v0.51.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-version: 0.51.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 3 +-- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index ec5e4569..f28740eb 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/miekg/dns v1.1.65 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.0 - github.com/quic-go/quic-go v0.50.1 + github.com/quic-go/quic-go v0.51.0 github.com/refraction-networking/utls v1.6.7 github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 @@ -49,7 +49,6 @@ require ( github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.5.0 // indirect - golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/text v0.24.0 // indirect golang.org/x/time v0.7.0 // indirect diff --git a/go.sum b/go.sum index 1dff5182..e64d54ae 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= -github.com/quic-go/quic-go v0.50.1 h1:unsgjFIUqW8a2oopkY7YNONpV1gYND6Nt9hnt1PN94Q= -github.com/quic-go/quic-go v0.50.1/go.mod h1:Vim6OmUvlYdwBhXP9ZVrtGmCMWa3wEqhq3NgYrI8b4E= +github.com/quic-go/quic-go v0.51.0 h1:K8exxe9zXxeRKxaXxi/GpUqYiTrtdiWP8bo1KFya6Wc= +github.com/quic-go/quic-go v0.51.0/go.mod h1:MFlGGpcpJqRAfmYi6NC2cptDPSxRWTOGNuP4wqrWmzQ= github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= @@ -99,8 +99,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= -golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc h1:O9NuF4s+E/PvMIy+9IUZB9znFwUIXEWSstNjek6VpVg= -golang.org/x/exp v0.0.0-20240531132922-fd00a4e0eefc/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= From 922ae98a4ad133fe8d421fc2da551f92baed9ed9 Mon Sep 17 00:00:00 2001 From: peter zhang <1809194+ddatsh@users.noreply.github.com> Date: Wed, 23 Apr 2025 11:05:36 +0800 Subject: [PATCH 799/867] DNS log: Optimize IP address display (#4630) --- app/dns/nameserver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index 1a5ab3b6..f1d02616 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -161,7 +161,7 @@ func NewClient( case *net.IPOrDomain_Domain: errors.LogInfo(ctx, "DNS: client ", ns.Address.Address.GetDomain(), " uses clientIP ", clientIP.String()) case *net.IPOrDomain_Ip: - errors.LogInfo(ctx, "DNS: client ", ns.Address.Address.GetIp(), " uses clientIP ", clientIP.String()) + errors.LogInfo(ctx, "DNS: client ", net.IP(ns.Address.Address.GetIp()), " uses clientIP ", clientIP.String()) } } From 0dd74cf072ed5e8941b63e8e01122ae568ea9140 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Apr 2025 00:14:52 +0000 Subject: [PATCH 800/867] Bump github.com/refraction-networking/utls from 1.6.7 to 1.7.1 Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.6.7 to 1.7.1. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.6.7...v1.7.1) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-version: 1.7.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f28740eb..0ed16813 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.0 github.com/quic-go/quic-go v0.51.0 - github.com/refraction-networking/utls v1.6.7 + github.com/refraction-networking/utls v1.7.1 github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 diff --git a/go.sum b/go.sum index e64d54ae..b19c7dbd 100644 --- a/go.sum +++ b/go.sum @@ -56,8 +56,8 @@ github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= github.com/quic-go/quic-go v0.51.0 h1:K8exxe9zXxeRKxaXxi/GpUqYiTrtdiWP8bo1KFya6Wc= github.com/quic-go/quic-go v0.51.0/go.mod h1:MFlGGpcpJqRAfmYi6NC2cptDPSxRWTOGNuP4wqrWmzQ= -github.com/refraction-networking/utls v1.6.7 h1:zVJ7sP1dJx/WtVuITug3qYUq034cDq9B2MR1K67ULZM= -github.com/refraction-networking/utls v1.6.7/go.mod h1:BC3O4vQzye5hqpmDTWUqi4P5DDhzJfkV1tdqtawQIH0= +github.com/refraction-networking/utls v1.7.1 h1:dxg+jla3uocgN8HtX+ccwDr68uCBBO3qLrkZUbqkcw0= +github.com/refraction-networking/utls v1.7.1/go.mod h1:TUhh27RHMGtQvjQq+RyO11P6ZNQNBb3N0v7wsEjKAIQ= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/sagernet/sing v0.5.1 h1:mhL/MZVq0TjuvHcpYcFtmSD1BFOxZ/+8ofbNZcg1k1Y= From a608c5a1dbfa59b8328ac5d0363f360b2fd3bebe Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Sat, 26 Apr 2025 12:00:27 -0400 Subject: [PATCH 801/867] uTLS: Add new fingerprints PSK extension, Post-Quantum Key Agreement, ML-KEM --- transport/internet/reality/reality.go | 4 ++-- transport/internet/tls/tls.go | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index a9352aaf..0543b26d 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -137,10 +137,10 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati if err != nil { return nil, errors.New("REALITY: publicKey == nil") } - if uConn.HandshakeState.State13.EcdheKey == nil { + if uConn.HandshakeState.State13.KeyShareKeys.Ecdhe == nil { return nil, errors.New("Current fingerprint ", uConn.ClientHelloID.Client, uConn.ClientHelloID.Version, " does not support TLS 1.3, REALITY handshake cannot establish.") } - uConn.AuthKey, _ = uConn.HandshakeState.State13.EcdheKey.ECDH(publicKey) + uConn.AuthKey, _ = uConn.HandshakeState.State13.KeyShareKeys.Ecdhe.ECDH(publicKey) if uConn.AuthKey == nil { return nil, errors.New("REALITY: SharedKey == nil") } diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index d2d5fa74..42904be6 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -163,7 +163,7 @@ func init() { func GetFingerprint(name string) (fingerprint *utls.ClientHelloID) { if name == "" { - return &utls.HelloChrome_Auto + return &utls.HelloChrome_120 } if fingerprint = PresetFingerprints[name]; fingerprint != nil { return @@ -179,7 +179,7 @@ func GetFingerprint(name string) (fingerprint *utls.ClientHelloID) { var PresetFingerprints = map[string]*utls.ClientHelloID{ // Recommended preset options in GUI clients - "chrome": &utls.HelloChrome_Auto, + "chrome": &utls.HelloChrome_120, "firefox": &utls.HelloFirefox_Auto, "safari": &utls.HelloSafari_Auto, "ios": &utls.HelloIOS_Auto, @@ -240,4 +240,13 @@ var OtherFingerprints = map[string]*utls.ClientHelloID{ "hello360_auto": &utls.Hello360_Auto, "hello360_7_5": &utls.Hello360_7_5, "helloqq_auto": &utls.HelloQQ_Auto, + + // reality currently does not support these new fingerprints + "hellochrome_100_psk": &utls.HelloChrome_100_PSK, + "hellochrome_112_psk_shuf": &utls.HelloChrome_112_PSK_Shuf, + "hellochrome_114_padding_psk_shuf": &utls.HelloChrome_114_Padding_PSK_Shuf, + "hellochrome_115_pq": &utls.HelloChrome_115_PQ, + "hellochrome_115_pq_psk": &utls.HelloChrome_115_PQ_PSK, + "hellochrome_120_pq": &utls.HelloChrome_120_PQ, + "hellochrome_131": &utls.HelloChrome_131, } From 58c48664e2da30ec0fd0550209dfe02678a3ba2b Mon Sep 17 00:00:00 2001 From: j2rong4cn <36783515+j2rong4cn@users.noreply.github.com> Date: Mon, 28 Apr 2025 18:03:03 +0800 Subject: [PATCH 802/867] QUIC sniffer: Full support for handling multiple initial packets (#4642) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> Co-authored-by: Vigilans Co-authored-by: Shelikhoo Co-authored-by: dyhkwong <50692134+dyhkwong@users.noreply.github.com> --- app/dispatcher/default.go | 43 ++--- app/dispatcher/sniffer.go | 8 +- common/buf/buffer.go | 47 ++++-- common/protocol/protocol.go | 6 + common/protocol/quic/sniff.go | 94 +++++------ common/protocol/quic/sniff_test.go | 251 +++++++++++++++++++++++++++++ common/protocol/tls/sniff.go | 17 +- 7 files changed, 371 insertions(+), 95 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 7bc58056..34a59fa5 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -33,23 +33,21 @@ type cachedReader struct { cache buf.MultiBuffer } -func (r *cachedReader) Cache(b *buf.Buffer) { - mb, _ := r.reader.ReadMultiBufferTimeout(time.Millisecond * 100) +func (r *cachedReader) Cache(b *buf.Buffer, deadline time.Duration) error { + mb, err := r.reader.ReadMultiBufferTimeout(deadline) + if err != nil { + return err + } r.Lock() if !mb.IsEmpty() { r.cache, _ = buf.MergeMulti(r.cache, mb) } - cacheLen := r.cache.Len() - if cacheLen <= b.Cap() { - b.Clear() - } else { - b.Release() - *b = *buf.NewWithSize(cacheLen) - } - rawBytes := b.Extend(cacheLen) + b.Clear() + rawBytes := b.Extend(b.Cap()) n := r.cache.Copy(rawBytes) b.Resize(0, int32(n)) r.Unlock() + return nil } func (r *cachedReader) readInternal() buf.MultiBuffer { @@ -355,7 +353,7 @@ func (d *DefaultDispatcher) DispatchLink(ctx context.Context, destination net.De } func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, network net.Network) (SniffResult, error) { - payload := buf.New() + payload := buf.NewWithSize(32767) defer payload.Release() sniffer := NewSniffer(ctx) @@ -367,26 +365,33 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw } contentResult, contentErr := func() (SniffResult, error) { + cacheDeadline := 200 * time.Millisecond totalAttempt := 0 for { select { case <-ctx.Done(): return nil, ctx.Err() default: - totalAttempt++ - if totalAttempt > 2 { - return nil, errSniffingTimeout - } + cachingStartingTimeStamp := time.Now() + cacheErr := cReader.Cache(payload, cacheDeadline) + cachingTimeElapsed := time.Since(cachingStartingTimeStamp) + cacheDeadline -= cachingTimeElapsed - cReader.Cache(payload) if !payload.IsEmpty() { result, err := sniffer.Sniff(ctx, payload.Bytes(), network) - if err != common.ErrNoClue { + switch err { + case common.ErrNoClue: // No Clue: protocol not matches, and sniffer cannot determine whether there will be a match or not + totalAttempt++ + case protocol.ErrProtoNeedMoreData: // Protocol Need More Data: protocol matches, but need more data to complete sniffing + if cacheErr != nil { // Cache error (e.g. timeout) counts for failed attempt + totalAttempt++ + } + default: return result, err } } - if payload.IsFull() { - return nil, errUnknownContent + if totalAttempt >= 2 || cacheDeadline <= 0 { + return nil, errSniffingTimeout } } } diff --git a/app/dispatcher/sniffer.go b/app/dispatcher/sniffer.go index c138447d..d6acf0d9 100644 --- a/app/dispatcher/sniffer.go +++ b/app/dispatcher/sniffer.go @@ -6,6 +6,7 @@ import ( "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/common/protocol" "github.com/xtls/xray-core/common/protocol/bittorrent" "github.com/xtls/xray-core/common/protocol/http" "github.com/xtls/xray-core/common/protocol/quic" @@ -58,14 +59,17 @@ var errUnknownContent = errors.New("unknown content") func (s *Sniffer) Sniff(c context.Context, payload []byte, network net.Network) (SniffResult, error) { var pendingSniffer []protocolSnifferWithMetadata for _, si := range s.sniffer { - s := si.protocolSniffer + protocolSniffer := si.protocolSniffer if si.metadataSniffer || si.network != network { continue } - result, err := s(c, payload) + result, err := protocolSniffer(c, payload) if err == common.ErrNoClue { pendingSniffer = append(pendingSniffer, si) continue + } else if err == protocol.ErrProtoNeedMoreData { // Sniffer protocol matched, but need more data to complete sniffing + s.sniffer = []protocolSnifferWithMetadata{si} + return nil, err } if err == nil && result != nil { diff --git a/common/buf/buffer.go b/common/buf/buffer.go index 63779586..facf6812 100644 --- a/common/buf/buffer.go +++ b/common/buf/buffer.go @@ -15,6 +15,15 @@ const ( var pool = bytespool.GetPool(Size) +// ownership represents the data owner of the buffer. +type ownership uint8 + +const ( + managed ownership = iota + unmanaged + bytespools +) + // Buffer is a recyclable allocation of a byte array. Buffer.Release() recycles // the buffer into an internal buffer pool, in order to recreate a buffer more // quickly. @@ -22,11 +31,11 @@ type Buffer struct { v []byte start int32 end int32 - unmanaged bool + ownership ownership UDP *net.Destination } -// New creates a Buffer with 0 length and 8K capacity. +// New creates a Buffer with 0 length and 8K capacity, managed. func New() *Buffer { buf := pool.Get().([]byte) if cap(buf) >= Size { @@ -40,7 +49,7 @@ func New() *Buffer { } } -// NewExisted creates a managed, standard size Buffer with an existed bytearray +// NewExisted creates a standard size Buffer with an existed bytearray, managed. func NewExisted(b []byte) *Buffer { if cap(b) < Size { panic("Invalid buffer") @@ -57,16 +66,16 @@ func NewExisted(b []byte) *Buffer { } } -// FromBytes creates a Buffer with an existed bytearray +// FromBytes creates a Buffer with an existed bytearray, unmanaged. func FromBytes(b []byte) *Buffer { return &Buffer{ v: b, end: int32(len(b)), - unmanaged: true, + ownership: unmanaged, } } -// StackNew creates a new Buffer object on stack. +// StackNew creates a new Buffer object on stack, managed. // This method is for buffers that is released in the same function. func StackNew() Buffer { buf := pool.Get().([]byte) @@ -81,9 +90,17 @@ func StackNew() Buffer { } } +// NewWithSize creates a Buffer with 0 length and capacity with at least the given size, bytespool's. +func NewWithSize(size int32) *Buffer { + return &Buffer{ + v: bytespool.Alloc(size), + ownership: bytespools, + } +} + // Release recycles the buffer into an internal buffer pool. func (b *Buffer) Release() { - if b == nil || b.v == nil || b.unmanaged { + if b == nil || b.v == nil || b.ownership == unmanaged { return } @@ -91,8 +108,13 @@ func (b *Buffer) Release() { b.v = nil b.Clear() - if cap(p) == Size { - pool.Put(p) + switch b.ownership { + case managed: + if cap(p) == Size { + pool.Put(p) + } + case bytespools: + bytespool.Free(p) } b.UDP = nil } @@ -215,13 +237,6 @@ func (b *Buffer) Cap() int32 { return int32(len(b.v)) } -// NewWithSize creates a Buffer with 0 length and capacity with at least the given size. -func NewWithSize(size int32) *Buffer { - return &Buffer{ - v: bytespool.Alloc(size), - } -} - // IsEmpty returns true if the buffer is empty. func (b *Buffer) IsEmpty() bool { return b.Len() == 0 diff --git a/common/protocol/protocol.go b/common/protocol/protocol.go index 28b5e51b..61c963c5 100644 --- a/common/protocol/protocol.go +++ b/common/protocol/protocol.go @@ -1 +1,7 @@ package protocol // import "github.com/xtls/xray-core/common/protocol" + +import ( + "errors" +) + +var ErrProtoNeedMoreData = errors.New("protocol matches, but need more data to complete sniffing") diff --git a/common/protocol/quic/sniff.go b/common/protocol/quic/sniff.go index 779e291b..61171c01 100644 --- a/common/protocol/quic/sniff.go +++ b/common/protocol/quic/sniff.go @@ -1,7 +1,6 @@ package quic import ( - "context" "crypto" "crypto/aes" "crypto/tls" @@ -13,6 +12,7 @@ import ( "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/bytespool" "github.com/xtls/xray-core/common/errors" + "github.com/xtls/xray-core/common/protocol" ptls "github.com/xtls/xray-core/common/protocol/tls" "golang.org/x/crypto/hkdf" ) @@ -47,22 +47,17 @@ var ( errNotQuicInitial = errors.New("not initial packet") ) -func SniffQUIC(b []byte) (resultReturn *SniffHeader, errorReturn error) { - // In extremely rare cases, this sniffer may cause slice error - // and we set recover() here to prevent crash. - // TODO: Thoroughly fix this panic - defer func() { - if r := recover(); r != nil { - errors.LogError(context.Background(), "Failed to sniff QUIC: ", r) - resultReturn = nil - errorReturn = common.ErrNoClue - } - }() +func SniffQUIC(b []byte) (*SniffHeader, error) { + if len(b) == 0 { + return nil, common.ErrNoClue + } // Crypto data separated across packets cryptoLen := 0 - cryptoData := bytespool.Alloc(int32(len(b))) + cryptoData := bytespool.Alloc(32767) defer bytespool.Free(cryptoData) + cache := buf.New() + defer cache.Release() // Parse QUIC packets for len(b) > 0 { @@ -105,13 +100,15 @@ func SniffQUIC(b []byte) (resultReturn *SniffHeader, errorReturn error) { return nil, errNotQuic } - tokenLen, err := quicvarint.Read(buffer) - if err != nil || tokenLen > uint64(len(b)) { - return nil, errNotQuic - } + if isQuicInitial { // Only initial packets have token, see https://datatracker.ietf.org/doc/html/rfc9000#section-17.2.2 + tokenLen, err := quicvarint.Read(buffer) + if err != nil || tokenLen > uint64(len(b)) { + return nil, errNotQuic + } - if _, err = buffer.ReadBytes(int32(tokenLen)); err != nil { - return nil, errNotQuic + if _, err = buffer.ReadBytes(int32(tokenLen)); err != nil { + return nil, errNotQuic + } } packetLen, err := quicvarint.Read(buffer) @@ -130,9 +127,6 @@ func SniffQUIC(b []byte) (resultReturn *SniffHeader, errorReturn error) { continue } - origPNBytes := make([]byte, 4) - copy(origPNBytes, b[hdrLen:hdrLen+4]) - var salt []byte if versionNumber == version1 { salt = quicSalt @@ -147,44 +141,34 @@ func SniffQUIC(b []byte) (resultReturn *SniffHeader, errorReturn error) { return nil, err } - cache := buf.New() - defer cache.Release() - + cache.Clear() mask := cache.Extend(int32(block.BlockSize())) block.Encrypt(mask, b[hdrLen+4:hdrLen+4+16]) b[0] ^= mask[0] & 0xf - for i := range b[hdrLen : hdrLen+4] { + packetNumberLength := int(b[0]&0x3 + 1) + for i := range packetNumberLength { b[hdrLen+i] ^= mask[i+1] } - packetNumberLength := b[0]&0x3 + 1 - if packetNumberLength != 1 { - return nil, errNotQuicInitial - } - var packetNumber uint32 - { - n, err := buffer.ReadByte() - if err != nil { - return nil, err - } - packetNumber = uint32(n) - } - - extHdrLen := hdrLen + int(packetNumberLength) - copy(b[extHdrLen:hdrLen+4], origPNBytes[packetNumberLength:]) - data := b[extHdrLen : int(packetLen)+hdrLen] key := hkdfExpandLabel(crypto.SHA256, secret, []byte{}, "quic key", 16) iv := hkdfExpandLabel(crypto.SHA256, secret, []byte{}, "quic iv", 12) cipher := AEADAESGCMTLS13(key, iv) + nonce := cache.Extend(int32(cipher.NonceSize())) - binary.BigEndian.PutUint64(nonce[len(nonce)-8:], uint64(packetNumber)) + _, err = buffer.Read(nonce[len(nonce)-packetNumberLength:]) + if err != nil { + return nil, err + } + + extHdrLen := hdrLen + packetNumberLength + data := b[extHdrLen : int(packetLen)+hdrLen] decrypted, err := cipher.Open(b[extHdrLen:extHdrLen], nonce, data, b[:extHdrLen]) if err != nil { return nil, err } buffer = buf.FromBytes(decrypted) - for i := 0; !buffer.IsEmpty(); i++ { - frameType := byte(0x0) // Default to PADDING frame + for !buffer.IsEmpty() { + frameType, _ := buffer.ReadByte() for frameType == 0x0 && !buffer.IsEmpty() { frameType, _ = buffer.ReadByte() } @@ -234,13 +218,12 @@ func SniffQUIC(b []byte) (resultReturn *SniffHeader, errorReturn error) { return nil, io.ErrUnexpectedEOF } if cryptoLen < int(offset+length) { - cryptoLen = int(offset + length) - if len(cryptoData) < cryptoLen { - newCryptoData := bytespool.Alloc(int32(cryptoLen)) - copy(newCryptoData, cryptoData) - bytespool.Free(cryptoData) - cryptoData = newCryptoData + newCryptoLen := int(offset + length) + if len(cryptoData) < newCryptoLen { + return nil, io.ErrShortBuffer } + wipeBytes(cryptoData[cryptoLen:newCryptoLen]) + cryptoLen = newCryptoLen } if _, err := buffer.Read(cryptoData[offset : offset+length]); err != nil { // Field: Crypto Data return nil, io.ErrUnexpectedEOF @@ -276,7 +259,14 @@ func SniffQUIC(b []byte) (resultReturn *SniffHeader, errorReturn error) { } return &SniffHeader{domain: tlsHdr.Domain()}, nil } - return nil, common.ErrNoClue + // All payload is parsed as valid QUIC packets, but we need more packets for crypto data to read client hello. + return nil, protocol.ErrProtoNeedMoreData +} + +func wipeBytes(b []byte) { + for i := range len(b) { + b[i] = 0x0 + } } func hkdfExpandLabel(hash crypto.Hash, secret, context []byte, label string, length int) []byte { diff --git a/common/protocol/quic/sniff_test.go b/common/protocol/quic/sniff_test.go index cddb4c87..121279b5 100644 --- a/common/protocol/quic/sniff_test.go +++ b/common/protocol/quic/sniff_test.go @@ -2,9 +2,11 @@ package quic_test import ( "encoding/hex" + "errors" "testing" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/protocol" "github.com/xtls/xray-core/common/protocol/quic" ) @@ -16,3 +18,252 @@ func TestSniffQUIC(t *testing.T) { t.Error("failed") } } + +func TestSniffQUICComplex(t *testing.T) { + tests := []struct { + name string + hexData string + domain string + wantErr bool + needsMoreData bool + }{ + { + name: "EmptyPacket", + hexData: "0000000000000000000000000000000000000000000000000000000000000000", + domain: "", + wantErr: true, + needsMoreData: false, + }, + { + name: "NTP Packet Client", + hexData: "23000000000000000000000000000000000000000000000000000000000000000000000000000000acb84a797d4044c9", + domain: "", + wantErr: true, + needsMoreData: false, + }, + { + name: "NTP Packet Server", + hexData: "240106ec000000000000000e47505373ea4dcaef2f4b4c31acb84a797d4044c9eb58b8693dd70c27eb58b8693dd7dde2", + domain: "", + wantErr: true, + needsMoreData: false, + }, + { + name: "DNS Packet Client", + hexData: "4500004a8e2d40003f1146392a2a2d03080808081eea00350036a8175ad4010000010000000000000675706461746504636f64650c76697375616c73747564696f03636f6d0000010001", + domain: "", + wantErr: true, + needsMoreData: false, + }, + { + name: "DNS Packet Client", + hexData: "4500004a667a40003f116dec2a2a2d030808080866980035003605d9b524010000010000000000000675706461746504636f64650c76697375616c73747564696f03636f6d0000410001", + domain: "", + wantErr: true, + needsMoreData: false, + }, + { + name: "DNS Packet Server", + hexData: "b524818000010006000100000675706461746504636f64650c76697375616c73747564696f03636f6d0000410001c00c00050001000000ec00301e7673636f64652d7570646174652d67366763623667676474686b63746439037a303107617a7572656664036e657400c03a000500010000000b002311737461722d617a75726566642d70726f640e747261666669636d616e61676572c065c076000500010000003c002c0473686564086475616c2d6c6f770b732d706172742d3030313706742d3030303908742d6d7365646765c065c0a5000500010000006c001411617a75726566642d742d66622d70726f64c088c0dd000500010000003c0026046475616c0b732d706172742d3030313706742d303030390b66622d742d6d7365646765c065c0fd00050001000000300002c102c1150006000100000030002d036e7331c115066d736e687374096d6963726f736f6674c0257848b78d00000708000003840024ea000000003c", + domain: "", + wantErr: true, + needsMoreData: false, + }, + { + name: "DNS Packet Server", + hexData: "5ad4818000010007000000000675706461746504636f64650c76697375616c73747564696f03636f6d0000010001c00c000500010000008400301e7673636f64652d7570646174652d67366763623667676474686b63746439037a303107617a7572656664036e657400c03a000500010000001e002311737461722d617a75726566642d70726f640e747261666669636d616e61676572c065c076000500010000003c002c0473686564086475616c2d6c6f770b732d706172742d3030313706742d3030303908742d6d7365646765c065c0a50005000100000010001411617a75726566642d742d66622d70726f64c088c0dd000500010000003c0026046475616c0b732d706172742d3030313706742d303030390b66622d742d6d7365646765c065c0fd00050001000000100002c102c102000100010000001000040d6bfd2d", + domain: "", + wantErr: true, + needsMoreData: false, + }, + { + name: "QUIC, NonHandshake Packet", + hexData: "548439ba3a0cffd27dabe08ebf9e603dd4801781e133b1a0276d29a047c3b8856adcced0067c4b11a08985bf93c05863305bd4b43ee9168cd5fdae0c392ff74ae06ce13e8d97dabec81ee927a844fa840f781edf9deb22f3162bf77009b3f5800c5e45539ac104368e7df8ba", + domain: "", + wantErr: true, + needsMoreData: false, + }, + { + name: "QUIC, NonHandshake Packet", + hexData: "53f4144825dab3ba251b83d0089e910210bec1a6507cca92ad9ff539cc21f6c75e3551ca44003d9a", + domain: "", + wantErr: true, + needsMoreData: false, + }, + { + name: "QUIC, NonHandshake Packet", + hexData: "528dc5524c03e7517949422cc3f6ffbfff74b2ec30a87654a71a", + domain: "", + wantErr: true, + needsMoreData: false, + }, + { + name: "QUIC Chromebook Handshake[1]; packet 1", + hexData: "cb00000001088ca3be26059ca269000044d088950f316207d551c91c88d791557c440a19184322536d2c900034358c1b3964f2d2935337b8d044d35bf62b4eea9ceaac64121aa634c7cd28630722d169fa0f215b940d47d7996ca56f0d463dbf97a4a1b5818c5297a26fe58f5553dfb513ad589750a61682f229996555c7121c8bf48b06b68ab06427b01af485d832f9894099a20d3baadcff7b1cf07e2c059d3e7ba88d4ad35ef0ffea1fdc6ac3db271dfcca892a41ab25284936225c9bc593ce242b11b8abed4a8df902987eef0c6d90669e3606f47dd6ad05f44ba3a0cd356854261bbb1e2d8f6b83cc57cfa57eda3e5d7181b6ec418f6eeca81c259a33e4b0a913de720f2f8782764766ac9602a7f52a1082ec3da30dbefcf38c781a3e033810c4f2babf9b72adf7164159d98142181492e4468c0e10ab29013bf238e7360e09767ca49d59a9eb18f06a372bad711fefa90295f8e0839b1080570648212b321e5bd6f614bf0d3dc2817628b0c052a32820c16cb7f531c49244c48eb1429625246f9c164ae4ee1e83eaa8ff0eef1acf5a3d8ca88f1e4597db5ba5c0cb23d6100dd53da4f439ae64c4d3d43d1fbb5677f4fdc3bd2c2948dfc7e0be1a33c842033da15529cfd3cae00da68343d835db867f746854804410ba68f0dd7711b0fe55817b83f6ce1a12ad38acf2a3156f819f0dc68ea799c05583d9728f2856577811b260dba40d6c5e82c9e558c5b8f3f4599caf05ea591118e0b80ad621e0a76e4926047593a896752cb168420cb1b02d4211de5e5b7c891f319b5c0cf687e1d261a01f2acbade6bd73cd1ade0a02e240e9351384e1a6868c21a4878f39f0fa94ee1e36c5a46449241a3fe0147ff50176787eca7f3a936c901aeef56770bff74feecb985e6670d20dfd8ed17952dca5a5292213345c61db09bb5bcf5bf74565f61f9dccab51a289c3160ffe4a9b29cc76ea46778d9317a890efea2ad905f4219463a3baca3c02f5c3682634be7c2e86e366272a8263fec8e871644a79299d4aa74f1b1414b2f963cce6e059978faf813625af7869c1dec92035478c0e46dc66d938d4131aca27a59b2103b8cefa8e08aeb44b53b205b932902aea8d519faaaa12e354a6f532b4f716d7929e655dc2e98b494a99153854af5732a2659f2c21e4069896a1835ad05c5e53781cab16599cf4af47c196deeff9115c80d13f93aeb28b08023e6a1d3cf7da2a4457a9e443176bcdfef8f8de630c02bd0efdc5ddda56ad8f6b47edbda6353205e6e655f690092a48deb7f8a5254a7d778e07216cd97dfefcf740c1acd2977ef0fa17f798ea9752bae46e3aa3ec9b13f4c95c20a7839b8409000fa1f17e8dc46cc05c41bff696ee03c0371cae8638e8018ff4ebedd9f27d56443e534a72dd3d18a64790b676ddd060376759fa4a12ffc17f4be83492126ec1dc0fcd4aefef73a0b9c443ec3532b9a66b1a60daacf45e6557115edc0cc4d08758754a44beffedaa0d1265e50beed1a01752904ee3f7e706ed290b1a79071b142105b7c02e692ff318710e3ce9c3b9ec557cdecef173796417341ada414faa06b52adf645db454b56468ccf0da50a942ebc09487797cb45a085ec1e2e06fcd1f5b72eac291955a62e5aa379a374aea3a0dec3e4e0ba1dde350a94c72dbea7505922e26e99d62f751c2b301413a73fb6b20a36052151473ebecd04d0a771ec326957bc28c2020fdf6f01d9abed69b3c3e73168b404a1748b15310b167396da01c7d", + domain: "", + wantErr: true, + needsMoreData: true, + }, + { + name: "QUIC Chromebook Handshake[1]; packet 1 - 2", + hexData: "cb00000001088ca3be26059ca269000044d088950f316207d551c91c88d791557c440a19184322536d2c900034358c1b3964f2d2935337b8d044d35bf62b4eea9ceaac64121aa634c7cd28630722d169fa0f215b940d47d7996ca56f0d463dbf97a4a1b5818c5297a26fe58f5553dfb513ad589750a61682f229996555c7121c8bf48b06b68ab06427b01af485d832f9894099a20d3baadcff7b1cf07e2c059d3e7ba88d4ad35ef0ffea1fdc6ac3db271dfcca892a41ab25284936225c9bc593ce242b11b8abed4a8df902987eef0c6d90669e3606f47dd6ad05f44ba3a0cd356854261bbb1e2d8f6b83cc57cfa57eda3e5d7181b6ec418f6eeca81c259a33e4b0a913de720f2f8782764766ac9602a7f52a1082ec3da30dbefcf38c781a3e033810c4f2babf9b72adf7164159d98142181492e4468c0e10ab29013bf238e7360e09767ca49d59a9eb18f06a372bad711fefa90295f8e0839b1080570648212b321e5bd6f614bf0d3dc2817628b0c052a32820c16cb7f531c49244c48eb1429625246f9c164ae4ee1e83eaa8ff0eef1acf5a3d8ca88f1e4597db5ba5c0cb23d6100dd53da4f439ae64c4d3d43d1fbb5677f4fdc3bd2c2948dfc7e0be1a33c842033da15529cfd3cae00da68343d835db867f746854804410ba68f0dd7711b0fe55817b83f6ce1a12ad38acf2a3156f819f0dc68ea799c05583d9728f2856577811b260dba40d6c5e82c9e558c5b8f3f4599caf05ea591118e0b80ad621e0a76e4926047593a896752cb168420cb1b02d4211de5e5b7c891f319b5c0cf687e1d261a01f2acbade6bd73cd1ade0a02e240e9351384e1a6868c21a4878f39f0fa94ee1e36c5a46449241a3fe0147ff50176787eca7f3a936c901aeef56770bff74feecb985e6670d20dfd8ed17952dca5a5292213345c61db09bb5bcf5bf74565f61f9dccab51a289c3160ffe4a9b29cc76ea46778d9317a890efea2ad905f4219463a3baca3c02f5c3682634be7c2e86e366272a8263fec8e871644a79299d4aa74f1b1414b2f963cce6e059978faf813625af7869c1dec92035478c0e46dc66d938d4131aca27a59b2103b8cefa8e08aeb44b53b205b932902aea8d519faaaa12e354a6f532b4f716d7929e655dc2e98b494a99153854af5732a2659f2c21e4069896a1835ad05c5e53781cab16599cf4af47c196deeff9115c80d13f93aeb28b08023e6a1d3cf7da2a4457a9e443176bcdfef8f8de630c02bd0efdc5ddda56ad8f6b47edbda6353205e6e655f690092a48deb7f8a5254a7d778e07216cd97dfefcf740c1acd2977ef0fa17f798ea9752bae46e3aa3ec9b13f4c95c20a7839b8409000fa1f17e8dc46cc05c41bff696ee03c0371cae8638e8018ff4ebedd9f27d56443e534a72dd3d18a64790b676ddd060376759fa4a12ffc17f4be83492126ec1dc0fcd4aefef73a0b9c443ec3532b9a66b1a60daacf45e6557115edc0cc4d08758754a44beffedaa0d1265e50beed1a01752904ee3f7e706ed290b1a79071b142105b7c02e692ff318710e3ce9c3b9ec557cdecef173796417341ada414faa06b52adf645db454b56468ccf0da50a942ebc09487797cb45a085ec1e2e06fcd1f5b72eac291955a62e5aa379a374aea3a0dec3e4e0ba1dde350a94c72dbea7505922e26e99d62f751c2b301413a73fb6b20a36052151473ebecd04d0a771ec326957bc28c2020fdf6f01d9abed69b3c3e73168b404a1748b15310b167396da01c7dc700000001088ca3be26059ca269000044d00a7e7a252620d0fdfb63c0c193d6a9fe6a36aa9ce1b29dfa5f11f2567850b88384a2cc682eca2e292749365b833e5f7540019cd4f3143ed078aec07990b0d6ece18310403e73e1fe2975a8f9cb05796fa6196faaba3ee12a22b63a28a624cf4f7bedd44de000dc5ea698c65664df995b7d5fade0aab1cf0ecc5afd5ecb8fb80deecae3a8c97c20171f00ac3b5dc9a9027ca9c25571c72bb32070f6e3fb583560b0da6041b72e0a9601b8ad17d3c45e9dcc059f9f4758e8c35a839a9f6f4c501cb64e32e886fc733bc51069fbe4406f04d908285974c387d5b3e5f0f674941d05993bf8bda0d5ffd8c4fb528e150ff4bf37e38bd9c6346816fe360d4a206da81e815c1f7905184b6146b33427c6e38f1179981c18b82a3544442dd997c182d956037ae8f106eaf67ba133e7f15f1550b257d431f01ba0472659c6a5c2e6ff5e4ce9e692f4ef9fb169a75df4eb13f0b20e1994f3f8687bdca300c7e749af7b7a3b6597a6b950fe378a68c77766fdabe95248ed41d37805756b7ffa9cee0898bd661f6657cbf1af9aa8c7e437d432ca854c95307e6a7dfb6504ee3f7852fb3c246d168a03810b6c3d4e3d40bdee3def579effb66563f5bac98cfa1b071cd6f33e425e016bb3514a183b72cb3a393e9e519ba60e2177c98f530835e3b6eab78cdcb8abdbc769bc07e10c8e38bea710d5de1bdb2fa8d0d9b19e8cc31d16725a696e55342c89b667497e3d7f90e48f8503d8ead2a32a1930c3b24a4a9dcf2d8ec781705dd97d7df6e26828712fe42114419d5b8346bd86c239bd02f34e55f71400cb10c1fac7d8efa1a2ab258c17ace4288c8576ab92447b648fd15f4e038ec1c81a135e3bbb6f581a994c6a4902aeb1b5588cb1b5b53c8540296d96b6d2eccd67bae9609233f36304b5186d4698b88bb3ce8b1191a62b990436cf10718fd5759cb2281ac122f49ccbef8a3206348c1a930e7fc4bb498a11d89374e1480c7b8725b5f65e8c8d6f58da17f9134abce77eb9a6fcda514e7d3ab2e3610f86945f0dca519a3844da1b3a4b0e03c80528a2f79be478d07ff26166e30294bf0e69bf07a5bbd6d879adf6d618a1ec8365023408980bf67f0525a2fdee97fccc38fe104d4f58ed15e3671dfedf684856a27fbe286adba40ff0336def93f0174e9e35d341f5de73190d330d72227db9a866b69418e17e8e19ec884c1ffe2f0ad6deec37c9d49d536d0242fab282b0cf86cc9b15341757e0d361bddcbe5cbb062b3148d7c3c62af5c5dd5922a49920f351647030f62ed16929a404aa514fcbc38e67ba4f275e02a04c486b1a8e5b5efda197fd63e6f41fdeffa652c690dd6b00ca65df3688672ead9744f7d631e42e3b42f3ed1bff51b30f89211a7467cde65eab3659af7690cf307420a5823f31999d8f63c6c6ba0296ed4a46d5df6404f8db33e7252cc6bfcf7f55fee1f1e3b0573b6c6615793ff0691b7cfd23c195f66eb333d7efb0cfb74cf159787f87ad01fc131c6763bb1117bbfb8c2e8197ffba6b8c747565b1332bdbd6553b840939c2f98aa8eb1c549491c640e012fc549852fa7a93f81e5db152c761fc7d01bce0325619965c09f6730a162e7be53af7d9ce4b5ac0f4eb487361d2ac231d4ce92e5d9a084bc7b609ccf60056ecc82cd0c06a088cfbcf7d764b3109331c42f989da82b05cfe4c134a6784e664fa67a89c0624e3cc73ccfdea3f292db28f7c7b1b109f680f6b537f135c62f764", + domain: "dns.google", + wantErr: false, + needsMoreData: false, + }, + { + name: "QUIC Chromebook Handshake[2]; packet 1", + hexData: "cf0000000108452af27900a1723300404600ca8530029a6bc59ff3e85beb5fc838ac3147ba5c2f6421ddcffdd85167d8de70eff2b1fa016dad4918337dec0feb660edb98e078dea51fa914055984b7957bd732fa4c831e448967af34752fd95835e3caba1e022d6d164f3f53f1bd7f60d560a8684079e90626aa1a4d3fe728158f7e1055ff76d1566072113982b193fb932265381e4de7afb35caa4ec56f31595a33fa2eb0bc84feb9f273224050938825fd21aa7317042ad00785ffd36151aee566a5dfe17d72591af1235059171568e5af0d13fc56e7897c3d632be753d8dea184c3d96d92bc56978cc669d94dd4c5e8dc3dcba7f0a39368fb1e87981e54bba7b86fbd8e8023a94d84f0290f402a5244cb4b0eeaaa57610ea59711a43932c521f10edb4560375693cbea60240389b8cebfd94035cabe4fc96ce8a726b979775e06c3bb0e3c4c866fe82e89fb725499e711e39310b93c785b313459f22d4ba37f90b19447165c2584269d98bf47d1f7ca89585797e4d6f1a4a1db7d2b0ae91a93fb15c3bb0ab953c3656b3b2ca20833d15e95329baff6d2ade1b0921b5ed3ae96648bf123b5265e27b049e9a8674455ff5f763f039568026e4fbe9882fef761c573d8f12e342c274a8dd3ad9854a688ce57cdddb52c758161ae3a59f67fc0d5b85f12e27617e7f4366e97a61fcda084e620dde35686f01dac49ce4bd76b986e3223c215919a1b228beeb74b7fcf32827d55be8f1b3b5fed24df2db023faecbb313b18a151cc4af8199d4bb08f8127b8207a0286d52758eaca87fd476ece0e3b17bcd8afb0289e8fd33c4455d4db6f058826c301ea303bfe2c0a6651a8fb6a2e1897852d758076adb04ad907077c5d5f94089da78d8923a34f1022ed672f378fe0dd81a709b372c0a2042a42e683c051c653e42b43c4a0ea8e961074d2901d4157ac9878b13a207b05ec471cff10d922b74d05623513cd6a4ea192ad21d4089de269633d4d2d1388d98d7c8a9e29848d5558b8aa2b73b437446a640230e6adb7f4b317ee5d66681c4aae11f69b1e5f96cb32ca6331405426cb706167d86f6f8fd588a72d7b2a6906798b81f174d808e1e3fc461e598e797c41bced26b87d09282d7b6d95076c285462e0c420a6f0e171ffe2791b5d221c03520409fe36622ff77796d9b7ef82babb25313acda9c621b22bf45ed909f9365b508860645af4c3aca78e6abca2d3a65c9159fbcd577438505d3f65a57c9412c12c069ad4d6db450beb08603abef621a9e029593fb5881dbd524ea2953b4acaaf59269b584c754e88c033247bb7c032e548d34fd9b2678e62fdf953dabf2be21c3e2d7b18ec7e3aedaf2cd082e19a369c1bcd4ca67e3d464e2200ecc3df98b0aa7f349415d68bcab0441ac3366607eff024bb786aec031a4619f8a24f554fe93c8520a03affcf11e40b6d5002f98c1708cac6c56e77eccba85ea6600d1391cfd202cc7914bfbaa3303266d1a820bf2dc84d2dfcdc4cdb79e6de3fbe3c02b288dcf955652f674f3f59b50849ea7dbf755bdafa27fba3db1267fb1354d8bf25a60cacb900b4d7ba913f9ba5f6b00559ad58b2f34a658ff7ef7f7d1ceeffd9c8325f271e6b5ba44d89685b744306963aa5e05ac0e8b00ada772dd5ae5ffb7043109afea86593743564c7acb4c8e7ef0e57d081eb1b9c0916078b113ece8a6036264a9b9781183c035342d50c7b069f3a01a40230e37ed8efde073c07d0e68066541d78c2f3cbe1e603cfcaaa", + domain: "", + wantErr: true, + needsMoreData: true, + }, + { + name: "QUIC Chromebook Handshake[2]; packet 1-2", + hexData: "cf0000000108452af27900a1723300404600ca8530029a6bc59ff3e85beb5fc838ac3147ba5c2f6421ddcffdd85167d8de70eff2b1fa016dad4918337dec0feb660edb98e078dea51fa914055984b7957bd732fa4c831e448967af34752fd95835e3caba1e022d6d164f3f53f1bd7f60d560a8684079e90626aa1a4d3fe728158f7e1055ff76d1566072113982b193fb932265381e4de7afb35caa4ec56f31595a33fa2eb0bc84feb9f273224050938825fd21aa7317042ad00785ffd36151aee566a5dfe17d72591af1235059171568e5af0d13fc56e7897c3d632be753d8dea184c3d96d92bc56978cc669d94dd4c5e8dc3dcba7f0a39368fb1e87981e54bba7b86fbd8e8023a94d84f0290f402a5244cb4b0eeaaa57610ea59711a43932c521f10edb4560375693cbea60240389b8cebfd94035cabe4fc96ce8a726b979775e06c3bb0e3c4c866fe82e89fb725499e711e39310b93c785b313459f22d4ba37f90b19447165c2584269d98bf47d1f7ca89585797e4d6f1a4a1db7d2b0ae91a93fb15c3bb0ab953c3656b3b2ca20833d15e95329baff6d2ade1b0921b5ed3ae96648bf123b5265e27b049e9a8674455ff5f763f039568026e4fbe9882fef761c573d8f12e342c274a8dd3ad9854a688ce57cdddb52c758161ae3a59f67fc0d5b85f12e27617e7f4366e97a61fcda084e620dde35686f01dac49ce4bd76b986e3223c215919a1b228beeb74b7fcf32827d55be8f1b3b5fed24df2db023faecbb313b18a151cc4af8199d4bb08f8127b8207a0286d52758eaca87fd476ece0e3b17bcd8afb0289e8fd33c4455d4db6f058826c301ea303bfe2c0a6651a8fb6a2e1897852d758076adb04ad907077c5d5f94089da78d8923a34f1022ed672f378fe0dd81a709b372c0a2042a42e683c051c653e42b43c4a0ea8e961074d2901d4157ac9878b13a207b05ec471cff10d922b74d05623513cd6a4ea192ad21d4089de269633d4d2d1388d98d7c8a9e29848d5558b8aa2b73b437446a640230e6adb7f4b317ee5d66681c4aae11f69b1e5f96cb32ca6331405426cb706167d86f6f8fd588a72d7b2a6906798b81f174d808e1e3fc461e598e797c41bced26b87d09282d7b6d95076c285462e0c420a6f0e171ffe2791b5d221c03520409fe36622ff77796d9b7ef82babb25313acda9c621b22bf45ed909f9365b508860645af4c3aca78e6abca2d3a65c9159fbcd577438505d3f65a57c9412c12c069ad4d6db450beb08603abef621a9e029593fb5881dbd524ea2953b4acaaf59269b584c754e88c033247bb7c032e548d34fd9b2678e62fdf953dabf2be21c3e2d7b18ec7e3aedaf2cd082e19a369c1bcd4ca67e3d464e2200ecc3df98b0aa7f349415d68bcab0441ac3366607eff024bb786aec031a4619f8a24f554fe93c8520a03affcf11e40b6d5002f98c1708cac6c56e77eccba85ea6600d1391cfd202cc7914bfbaa3303266d1a820bf2dc84d2dfcdc4cdb79e6de3fbe3c02b288dcf955652f674f3f59b50849ea7dbf755bdafa27fba3db1267fb1354d8bf25a60cacb900b4d7ba913f9ba5f6b00559ad58b2f34a658ff7ef7f7d1ceeffd9c8325f271e6b5ba44d89685b744306963aa5e05ac0e8b00ada772dd5ae5ffb7043109afea86593743564c7acb4c8e7ef0e57d081eb1b9c0916078b113ece8a6036264a9b9781183c035342d50c7b069f3a01a40230e37ed8efde073c07d0e68066541d78c2f3cbe1e603cfcaaac40000000108452af27900a1723300404600ca8530029a6bc59ff3e85beb5fc838ac3147ba5c2f6421ddcffdd85167d8de70eff2b1fa016dad4918337dec0feb660edb98e078dea51fa914055984b7957bd732fa4c831e4489522d29bb5c84749f83c8e1edfd9da8d1738164a8a9c59e37a5c9994d90bb982dcfa69b20f868960dc139618f1adc2546d34340ae13d826260c54a456bbf7469ee37b1be1d7177004468d7e92cac62a0b165d6a114ad479861dd58959e094b5a6250359301d4a614d529660760e3d1cdec9bf444a3761309bab40e4a977bc749e0dae431952f5f7e6b1ebc1383d343359a387da4301f7fa4b400475e9b82367e56278376dd1c80349f083988945a13649008109cc12a3acf569ffcc5481fbcd86b544e7dc8434e9dd42bd8e5716a844d37879568db046857389d36cc7550c75f94e314db6749aa987f0fc730fae0fcf465d01c2fb745269dfc10132ddb5404dda2f9455780f5818730834aa9db4740793359884b9927b0bd1a5ca96052b4f17397d8b78aa891401bb8bed6726ea2229d919798c50e24d5f40576ac204847be9244aadbe5c773684c37475036541d209c177d4e9c22a1253292ce4ffb886b925b6cf83cc251976a68887eda2777590f51804b790b51eee77e717b7ef0eea71634594df36e6ae9e7574d65c51ac3196f0b2a3b0f023c81f05f7807f958dda03418ed49e14b645e814b9aa55b37c809be3172ca21fe4c7a78e17e9ece8def2dd2949310ecaa41b1b477f4e85db5288aa144e333f47ef291d0e822941181c13859d9fd6d640904ee764c9276125228c932dff3fb12f564f039b52f5ba1ab4d119641df8fe13f784802b99347f0046da63f471e34b1d12d3111cffe7b5d90cf5999879f6f23e7785f09cb10df32821bb68dd8fdcfcdbedd63f2428b2292b9f0e76ff36403c9644fd43e01112ee6218d0ec1c86f6d147e4b802293e906750c7046f53bf05a144e321d3b45e08e4064fd3828fdd1b5d1ceed74081f61319dc0ad9a6e8a3b9cc802e952d24e2271712e2c2cda7daca2f835e6c804feeef8d918404cc82a1aa9534bddff68a472b208a0d0a7fd68a08fbc411132af47a6b67a32617b7b9991524c21599e8e3cb9395cdab87a3f5bf5d1833a9c7ea021b29cf428c877c6b21d62f99340ac7f85ae721acc10968e7d79f111ca40c75e14060d07cffa046d71151a0b00eab657300344b04bd1a8871650c34ceda8610d7c1ba8d37673da6aaa580400e0230c69fba8ba21927de2f5897656144694550d1df3d268804adc707e7b236501734aeabb2e61cb08012bd96eca5a486d7a55f996992c36233815abd71c30e263ba0c5d9456fe0828df16f6af7929390bb143c426d9dfeaf4bb373554479ebe609b36b4bc3dd08ce216b9cdc5726edb458c5e4036d0edc688d3e39d20f8254b5d1f174518f15b344efc27fc56572c0159aa593d5b46bc33818f986e3df8caebd4c7b702ef50dd582714a2b94ecd1c4e90af37d388445c478a32ff6e8f5852ee115966b708eed04da322b98813a69423e95f90b89ce85518e39bcef36fdd5bd312b2c6c5ee85962675274c18f39ee35155517f70fd74b31bb2de6b5108d369252e6fb289e453833132ef7960da1cc0934790c039b9a1b0c74f23eb3b61fe9b4d0ea67de757b93af451eef303b1373199af446a0fa98d5991bbd4771ee63317e6da86efbe213dfff595c41b98e0e89f4f2df110104e760feebf4cb3361171c9fceb1e1c809a268", + domain: "", + wantErr: true, + needsMoreData: true, + }, + { + name: "QUIC Chromebook Handshake[2]; packet 1-3", + hexData: "cf0000000108452af27900a1723300404600ca8530029a6bc59ff3e85beb5fc838ac3147ba5c2f6421ddcffdd85167d8de70eff2b1fa016dad4918337dec0feb660edb98e078dea51fa914055984b7957bd732fa4c831e448967af34752fd95835e3caba1e022d6d164f3f53f1bd7f60d560a8684079e90626aa1a4d3fe728158f7e1055ff76d1566072113982b193fb932265381e4de7afb35caa4ec56f31595a33fa2eb0bc84feb9f273224050938825fd21aa7317042ad00785ffd36151aee566a5dfe17d72591af1235059171568e5af0d13fc56e7897c3d632be753d8dea184c3d96d92bc56978cc669d94dd4c5e8dc3dcba7f0a39368fb1e87981e54bba7b86fbd8e8023a94d84f0290f402a5244cb4b0eeaaa57610ea59711a43932c521f10edb4560375693cbea60240389b8cebfd94035cabe4fc96ce8a726b979775e06c3bb0e3c4c866fe82e89fb725499e711e39310b93c785b313459f22d4ba37f90b19447165c2584269d98bf47d1f7ca89585797e4d6f1a4a1db7d2b0ae91a93fb15c3bb0ab953c3656b3b2ca20833d15e95329baff6d2ade1b0921b5ed3ae96648bf123b5265e27b049e9a8674455ff5f763f039568026e4fbe9882fef761c573d8f12e342c274a8dd3ad9854a688ce57cdddb52c758161ae3a59f67fc0d5b85f12e27617e7f4366e97a61fcda084e620dde35686f01dac49ce4bd76b986e3223c215919a1b228beeb74b7fcf32827d55be8f1b3b5fed24df2db023faecbb313b18a151cc4af8199d4bb08f8127b8207a0286d52758eaca87fd476ece0e3b17bcd8afb0289e8fd33c4455d4db6f058826c301ea303bfe2c0a6651a8fb6a2e1897852d758076adb04ad907077c5d5f94089da78d8923a34f1022ed672f378fe0dd81a709b372c0a2042a42e683c051c653e42b43c4a0ea8e961074d2901d4157ac9878b13a207b05ec471cff10d922b74d05623513cd6a4ea192ad21d4089de269633d4d2d1388d98d7c8a9e29848d5558b8aa2b73b437446a640230e6adb7f4b317ee5d66681c4aae11f69b1e5f96cb32ca6331405426cb706167d86f6f8fd588a72d7b2a6906798b81f174d808e1e3fc461e598e797c41bced26b87d09282d7b6d95076c285462e0c420a6f0e171ffe2791b5d221c03520409fe36622ff77796d9b7ef82babb25313acda9c621b22bf45ed909f9365b508860645af4c3aca78e6abca2d3a65c9159fbcd577438505d3f65a57c9412c12c069ad4d6db450beb08603abef621a9e029593fb5881dbd524ea2953b4acaaf59269b584c754e88c033247bb7c032e548d34fd9b2678e62fdf953dabf2be21c3e2d7b18ec7e3aedaf2cd082e19a369c1bcd4ca67e3d464e2200ecc3df98b0aa7f349415d68bcab0441ac3366607eff024bb786aec031a4619f8a24f554fe93c8520a03affcf11e40b6d5002f98c1708cac6c56e77eccba85ea6600d1391cfd202cc7914bfbaa3303266d1a820bf2dc84d2dfcdc4cdb79e6de3fbe3c02b288dcf955652f674f3f59b50849ea7dbf755bdafa27fba3db1267fb1354d8bf25a60cacb900b4d7ba913f9ba5f6b00559ad58b2f34a658ff7ef7f7d1ceeffd9c8325f271e6b5ba44d89685b744306963aa5e05ac0e8b00ada772dd5ae5ffb7043109afea86593743564c7acb4c8e7ef0e57d081eb1b9c0916078b113ece8a6036264a9b9781183c035342d50c7b069f3a01a40230e37ed8efde073c07d0e68066541d78c2f3cbe1e603cfcaaac40000000108452af27900a1723300404600ca8530029a6bc59ff3e85beb5fc838ac3147ba5c2f6421ddcffdd85167d8de70eff2b1fa016dad4918337dec0feb660edb98e078dea51fa914055984b7957bd732fa4c831e4489522d29bb5c84749f83c8e1edfd9da8d1738164a8a9c59e37a5c9994d90bb982dcfa69b20f868960dc139618f1adc2546d34340ae13d826260c54a456bbf7469ee37b1be1d7177004468d7e92cac62a0b165d6a114ad479861dd58959e094b5a6250359301d4a614d529660760e3d1cdec9bf444a3761309bab40e4a977bc749e0dae431952f5f7e6b1ebc1383d343359a387da4301f7fa4b400475e9b82367e56278376dd1c80349f083988945a13649008109cc12a3acf569ffcc5481fbcd86b544e7dc8434e9dd42bd8e5716a844d37879568db046857389d36cc7550c75f94e314db6749aa987f0fc730fae0fcf465d01c2fb745269dfc10132ddb5404dda2f9455780f5818730834aa9db4740793359884b9927b0bd1a5ca96052b4f17397d8b78aa891401bb8bed6726ea2229d919798c50e24d5f40576ac204847be9244aadbe5c773684c37475036541d209c177d4e9c22a1253292ce4ffb886b925b6cf83cc251976a68887eda2777590f51804b790b51eee77e717b7ef0eea71634594df36e6ae9e7574d65c51ac3196f0b2a3b0f023c81f05f7807f958dda03418ed49e14b645e814b9aa55b37c809be3172ca21fe4c7a78e17e9ece8def2dd2949310ecaa41b1b477f4e85db5288aa144e333f47ef291d0e822941181c13859d9fd6d640904ee764c9276125228c932dff3fb12f564f039b52f5ba1ab4d119641df8fe13f784802b99347f0046da63f471e34b1d12d3111cffe7b5d90cf5999879f6f23e7785f09cb10df32821bb68dd8fdcfcdbedd63f2428b2292b9f0e76ff36403c9644fd43e01112ee6218d0ec1c86f6d147e4b802293e906750c7046f53bf05a144e321d3b45e08e4064fd3828fdd1b5d1ceed74081f61319dc0ad9a6e8a3b9cc802e952d24e2271712e2c2cda7daca2f835e6c804feeef8d918404cc82a1aa9534bddff68a472b208a0d0a7fd68a08fbc411132af47a6b67a32617b7b9991524c21599e8e3cb9395cdab87a3f5bf5d1833a9c7ea021b29cf428c877c6b21d62f99340ac7f85ae721acc10968e7d79f111ca40c75e14060d07cffa046d71151a0b00eab657300344b04bd1a8871650c34ceda8610d7c1ba8d37673da6aaa580400e0230c69fba8ba21927de2f5897656144694550d1df3d268804adc707e7b236501734aeabb2e61cb08012bd96eca5a486d7a55f996992c36233815abd71c30e263ba0c5d9456fe0828df16f6af7929390bb143c426d9dfeaf4bb373554479ebe609b36b4bc3dd08ce216b9cdc5726edb458c5e4036d0edc688d3e39d20f8254b5d1f174518f15b344efc27fc56572c0159aa593d5b46bc33818f986e3df8caebd4c7b702ef50dd582714a2b94ecd1c4e90af37d388445c478a32ff6e8f5852ee115966b708eed04da322b98813a69423e95f90b89ce85518e39bcef36fdd5bd312b2c6c5ee85962675274c18f39ee35155517f70fd74b31bb2de6b5108d369252e6fb289e453833132ef7960da1cc0934790c039b9a1b0c74f23eb3b61fe9b4d0ea67de757b93af451eef303b1373199af446a0fa98d5991bbd4771ee63317e6da86efbe213dfff595c41b98e0e89f4f2df110104e760feebf4cb3361171c9fceb1e1c809a268c60000000108452af27900a1723300404600ca8530029a6bc59ff3e85beb5fc838ac3147ba5c2f6421ddcffdd85167d8de70eff2b1fa016dad4918337dec0feb660edb98e078dea51fa914055984b7957bd732fa4c831e44892ff5e6b16d8a259a9128c2c0c3c525462781a344c3df7f19a747e0e79ca8714995c867fc697a3cb87b35e769465a8e966bcb35b7e897ad036aa23a6c021e2445a0eb79962151cd20dbb43ae1231847de01caf4e5589dfebf026e95f7d1d742e140d9dda849396a70cc0798f1eef06fd5f4cfbc9a190ddf04cc332c5b7b15e53af311190ced92a1291c12b8799f2b50e076539a8370ee667e1791a78f38e565a48acbaa1c78ba941dba8b0d040f8fb8bbcc9f6bf5705efa613a24b12d6ac9cebb4f3fac1b09a07b49d8a3a62808eb0a324629f13a012e6ad0feb11ad97c1572983c713b62f27584809ba43e64e4af9845af807c0783104838f4e2ac33fa848866f3cc64a7b6203a5c09e8ad231f0f06ae2fb7b39a64cedd823b0ff297ad9be1ccac436777ccb3e22ef6b9c12e6d5e34926f50e8ca8c8c0532c810b074d001c11791a01bf25786b57a5da54065dcee4962822e929f47ee44d3b8c83d45a8b7a936dc2a6fa396e4194fa032d1627eca59f69857fc40dab5835d3613dade1c74b09c345bd32c509e9545d2330b157a7acb76409f3ac8eaa22802414f38c5422fe4c5189caaf5c1b93ce7c0892f0cfc477490d335aa78961d632a973cf106bd974c2714176fb0f98cf12f2887a0d7bd491756dd374331eb3e6adb9f2bd0d6b273403fd14b314eb27ebbb6f6e78ce310437004b757c048149cf04429ae4a6d6e65c9b3e0b9c9c4d4ef52007eaaad9670320f10cd5317b3d3edc374d45c98b217dd28fb3c2c2fb6e74a3aced143e3242084b192ba6df24e69fdb883e850714fe27a45f43883486a986574fd1fc10f259fe90786441554514c8dade1f3b86fdaf5f54ab655e2d803c98aa56073b00c32148a1ed367dff3a2bd934ecba55141389990b661bbd9ce1ef1def13747d45500daf92cec9e60908274703e761cd46affd46622f2a2192a79425ebf51c875fc7ba3598e15e0ba2465fc3e87c8a5da1915d3b8abe4b16d21259f311183eee1e7d2b808a91a7c89b284df0eb6a2a79c610bbe47722b3e04d5a6c0e574816a94d97349b6976010eb8c7debf42210982f78de482b7cd068051bf57908dbf46b5ceaf64f5fb33ede4412c1ce81eb1dfb4e99e10dd9b57ebc6e62ecbf4ee2db04d9e48c62bd45f8fa51704d414296a2d51d25ced6a192034a44c67e09d8985b573f98e03fa36dd8dcce2c04b4d5b1f276b6a642aadbdcafcf09de1d234bf8bbbf64aeadf01519ddafb419b3e62d204e04c3d7ebaf54b09e387ac3e9c4781c11625a2f44fddb7a1886f21929bd01c283f64903b6ccbb463984dfadc00f6af2a421517da023fd319f528195cac5fe907624b70c0172479d07d78e266dbf20ab8fc302228f279ffdba7395a839c4a9d7a4e001a260e1702393968f1e9722f023b204cf09cfee9a7bba045e4a2a449ee9fbb5c36e93028cfc87a2e34914b1b4f01beeded175ac0fa73fea9292f2bc3b1247164d8e05cddc3981bdc24e5f596571c418f6fa00fd9d4d0898cbf0d2f5413bed5f100f1854903017b6bc88bd7e303b5e0e2417bbcc984731128eda550d31f9af0e6e743eb6916466bbd435617d56fa60b05cd7dca66a9f6f4be23d3c5ff5d900822c6d1d8d71b0bab24f57d9682381a87c", + domain: "signaler-pa.clients6.google.com", + wantErr: false, + needsMoreData: false, + }, + { + name: "QUIC Chromebook Handshake[3]; packet 1", + hexData: "cb0000000108676ef9ec3514fd5f004046001ae0c831dde6ac72f1337c9ca111f5b32afdf102d75c017d3bccb6fa89902b750b00c51bb226afa517754b72e962ff007c1c8c8749a21be1d8d94f7bf73437c010cd60e0bd4489d0a84868f32ecd4bd0d4c95a8a08d60d8303ef02323bdbcd96a33940824d25b9594bd8ae5716b9d043ab27ba03a2593c4d149b923711dd98e45456db19c8ea71e982562ae787c1b6cbe3ca1b03df2df62aa8e3127c5f68bdf80ed90588e7ec1f41f5a6281b87a12348cb17a04e9eaa461fef2e0e3ae70ebdc7bffa15c6b61ab270173e46dec0fd081f935a5fe6338d3b9cd38fcb52cb159edb66d2927238294313990da25c22f40d40e3cd72e76bbd066de731cf8fb6b4b7bc7639efb788c0b108dbf8280845a2cc62fbaf5fb8e1ecbe5ba7791aab94786c1c71c9058d0153b34a3f5bc8903e0d120f353defbe973cd33568bd03609dcdab8af1e8563897f5dd0251c6e6514bf40bd447d376fed21b2c54ebf74680df241bdc2ea5579bc0736cf3257c20d275746e8e6853aa89dcda8c2dbe523438ab92ca1ed1ab4f109e4ea84de57dfb6c544d695a5b710fe2d432f2b58644f8aeb965752d3a1d1a3057c2229192f89b254f5d292c22f1060642729df3667ef39e27691c82da9be847a59a17ba7345d23a37e31ec135633cc5ea84c752f56d4ec75878a2920b93e9b4e091e0114552712e1e50ade42e26ac0266b84043a493e1ce2e80cd57422de16a88deceaa55385dc2a977ffc9063e7c427200b6d8511ef9004f89412587bd6d0057898f5ae284db78b0ec861fed36dfb7c7a9679ad0480eefe71985ba6f731bd0e816a901e0c017dd0cb7fc8a4606dec2091a51aab16d6f9bbdecf3fea177671e68250a84fe19de8df78d711e22b81372bc22ae21ac7208ed41201f6e26cd6748e9d6e2f4884f5acba736b2432536718891638d43991bd97c232829e26be6e6bb303d44849b245ef758eb2813bc87cf21a30f132360111e3015de5d1e4f0c5a98aff159c29f6debed7c2f18f455dfc7f33995a90b7625688507ecef1e7db48e7030ea6c4fa835bbc1dfbea6c0a6c704d658d4866a42b9860b1c8b5b64cb669e102c81e369b5f07b8fa08816a566a99f4d2910f6e8d751d52f1e2889f0ec9acfcb4627e0da5c35452be05c7766eddf3c42ceb6a312044075a4231b4203718c886498a313f3ba12e44e368b04ec3ea6e72d6fed9b6b334cbc0ba89f0aa9a129b1bad5b0ad8690291a344967f58e52415859852c6ca3ea24bc93ec1041fd1dc8a6a181326d3026098db0cddec90b3cd6df1e7638a3703f70c9a3baff8f005b90f362459a275a8b39daa78ff24613434594f96b8023a41a17d815e5c0319a39e07d32841339f14f404030b4a22551b86ba94832a1c49053d63140b503f2f64354ce10abe6c08f6cdaf6d8dc361c3c9d1a8077ad34dccc699b6fe07c16f8f7743d04003d672f82e643b3f1d5e263495504e11e6b2e676c11b3d0033d5f837e6bfd01602584ff181e3cb86f081015a9311eed546b42a8280680aa538353949f89674c554b43241e36536430ae9e0190729ce902e8f06a952d23b62816deb3b62b45375033ede2d8065a8e7b38f5aee0a5c66eb2f21f33fa6795d4b086e6f6ac941ba0c883ccf6e54e52164384045e0b0d74a9361f224303c841ec907be250725ab06cf79dd8bff8f46c08963a409b9b71b5c634c987c5e163f73fc32553be1231c72444c5e2a91189824034a784948f", + domain: "", + wantErr: true, + needsMoreData: true, + }, + { + name: "QUIC Chromebook Handshake[3]; packet 1-2", + hexData: "cb0000000108676ef9ec3514fd5f004046001ae0c831dde6ac72f1337c9ca111f5b32afdf102d75c017d3bccb6fa89902b750b00c51bb226afa517754b72e962ff007c1c8c8749a21be1d8d94f7bf73437c010cd60e0bd4489d0a84868f32ecd4bd0d4c95a8a08d60d8303ef02323bdbcd96a33940824d25b9594bd8ae5716b9d043ab27ba03a2593c4d149b923711dd98e45456db19c8ea71e982562ae787c1b6cbe3ca1b03df2df62aa8e3127c5f68bdf80ed90588e7ec1f41f5a6281b87a12348cb17a04e9eaa461fef2e0e3ae70ebdc7bffa15c6b61ab270173e46dec0fd081f935a5fe6338d3b9cd38fcb52cb159edb66d2927238294313990da25c22f40d40e3cd72e76bbd066de731cf8fb6b4b7bc7639efb788c0b108dbf8280845a2cc62fbaf5fb8e1ecbe5ba7791aab94786c1c71c9058d0153b34a3f5bc8903e0d120f353defbe973cd33568bd03609dcdab8af1e8563897f5dd0251c6e6514bf40bd447d376fed21b2c54ebf74680df241bdc2ea5579bc0736cf3257c20d275746e8e6853aa89dcda8c2dbe523438ab92ca1ed1ab4f109e4ea84de57dfb6c544d695a5b710fe2d432f2b58644f8aeb965752d3a1d1a3057c2229192f89b254f5d292c22f1060642729df3667ef39e27691c82da9be847a59a17ba7345d23a37e31ec135633cc5ea84c752f56d4ec75878a2920b93e9b4e091e0114552712e1e50ade42e26ac0266b84043a493e1ce2e80cd57422de16a88deceaa55385dc2a977ffc9063e7c427200b6d8511ef9004f89412587bd6d0057898f5ae284db78b0ec861fed36dfb7c7a9679ad0480eefe71985ba6f731bd0e816a901e0c017dd0cb7fc8a4606dec2091a51aab16d6f9bbdecf3fea177671e68250a84fe19de8df78d711e22b81372bc22ae21ac7208ed41201f6e26cd6748e9d6e2f4884f5acba736b2432536718891638d43991bd97c232829e26be6e6bb303d44849b245ef758eb2813bc87cf21a30f132360111e3015de5d1e4f0c5a98aff159c29f6debed7c2f18f455dfc7f33995a90b7625688507ecef1e7db48e7030ea6c4fa835bbc1dfbea6c0a6c704d658d4866a42b9860b1c8b5b64cb669e102c81e369b5f07b8fa08816a566a99f4d2910f6e8d751d52f1e2889f0ec9acfcb4627e0da5c35452be05c7766eddf3c42ceb6a312044075a4231b4203718c886498a313f3ba12e44e368b04ec3ea6e72d6fed9b6b334cbc0ba89f0aa9a129b1bad5b0ad8690291a344967f58e52415859852c6ca3ea24bc93ec1041fd1dc8a6a181326d3026098db0cddec90b3cd6df1e7638a3703f70c9a3baff8f005b90f362459a275a8b39daa78ff24613434594f96b8023a41a17d815e5c0319a39e07d32841339f14f404030b4a22551b86ba94832a1c49053d63140b503f2f64354ce10abe6c08f6cdaf6d8dc361c3c9d1a8077ad34dccc699b6fe07c16f8f7743d04003d672f82e643b3f1d5e263495504e11e6b2e676c11b3d0033d5f837e6bfd01602584ff181e3cb86f081015a9311eed546b42a8280680aa538353949f89674c554b43241e36536430ae9e0190729ce902e8f06a952d23b62816deb3b62b45375033ede2d8065a8e7b38f5aee0a5c66eb2f21f33fa6795d4b086e6f6ac941ba0c883ccf6e54e52164384045e0b0d74a9361f224303c841ec907be250725ab06cf79dd8bff8f46c08963a409b9b71b5c634c987c5e163f73fc32553be1231c72444c5e2a91189824034a784948fc90000000108676ef9ec3514fd5f004046001ae0c831dde6ac72f1337c9ca111f5b32afdf102d75c017d3bccb6fa89902b750b00c51bb226afa517754b72e962ff007c1c8c8749a21be1d8d94f7bf73437c010cd60e0bd448983eee52163a177650f57b2cd8404bc619b9b59e796f9808bcd549ae6ae30d448c90f2783978bf9314a8038f45c0da5983163bd26f38f559f59447e8cf004f93b6b5c8af7b09603db021d4bdfa641bd83926eae1709a7a427add14df90cb258c6d4663d4d29709da89c90613d2ff9334637d53ca89407804eb863f78e110b866af2734c980705d9f969730a41132e788fc9e426d0f68ed24157aaff0383438d2715262e9b8b03cff850ba88127a05a8b68ac9a5ae5b098bb9ba5eaadd71ae846b3c0f68db728361eb8c8ed899c77725afbdfabf93812c49cbf4ee64047a96ea71258dbe5be3f988029d005fa2d9fc6e1e53fbeb6888074521b972e2ac71b4f22b754fc743e0de21af1e2ab416b2481e03227a1c7d7ea6cac5bc37ee3597d3bf11bf13a688dfa3d9aeff1eb1a7fdfcf8b6c722a4853f7c2b2d31e0b2b691f4273d4793fbb7a00f27a25577bfcba95e60699c9d2a926e71d64f535b633f2fd03320b28fe86c6619c54b34e6caf8f5a71b8a144c9236bf07edaacb486ff8ac63173af099efe7c9d006a5bb756449fb32b1fbff2e315fd5e96b586bb922a9795e29ffe6ead037c556e1bf30e24afb344cf873201007096b6f687f157588e236b71ade4d9245d8f065f2e23b36fad798d0f5504ddf25b828698d0cbdc28478b20d692d2ab605797a67232b0795927d886de798f00b4e7c69517d62b748e62e01d53dd1e77ac9a1605c0408713ff309ad53ff8f2bef17f9074f01134374068bf1f5dc07125180b5ea6902ec2d55c7d6d5f7ed4ef8732f9d34b4627678611fc9579e4321cea012c4e457dee6a11c41bdd1eb965056e885757af389079a558434eb3d59ae56a232302759431172ecc88de1c5400265f0f47e21396e3c38e0ba022c3e55ee4b85527cf49dece94445adc740cd26c18004a1cb984cc1732a138844da1ab003f89c589b6f3cc10c99a1b0d87be763f83e1b12c6fa6938ebc55d2ba33c25ca816dde207f7186f0c70b56b33feb538eb31175fdcfb036e365087f1b630628affdbbdee20d1976cb009f32db5f35aadb8117aa02ff2da9bdeaffbcc8bf3412efefeb00365e5f1ea577afd6e1c3585c67ffe1fa120382aa54028dcae9bbd624432a6256687d05483f2611f1ddd14b40f66fdf547e7eba904a79bd27733c9a8fbfb01154dda3457c4eacff8116941777ec570ff040e217d648ea5076588a6417462481eba68ebc59af04ba49b92f70b68a007977fde48b94b0af35475ea19cbec92df6449b065880bf03452cb3b3582f3d1a010e585be6506f3e067226471a94ce46c515f20502b3866553c10f037d9be89ad5858d6b2d2d94c70159247f66958d0e841d1c5b4254809d52475fdf96d087c3c6647b86006147a9ebb3f52ea6f4b89d886725b9e9243efd95e434bd8dd785143c57c06863b68df8f832987eb0c730c8b96634c1f888da2ef420cb0ebacf81f4b25c65962ae40c09ac4b0b2d440e3bdaa7309d87a1fa6af1c2e13e7a63c253fae027ceb2067cef8421b62d205f5d37c7204eaf594b1b43f9d9b67509a6709df48769ab9e1078f9e59d7656ec2132b5ebccf297e757a052835fffe94ae073131ac49c4f4374a1904cd4bf3041b236b73ea19eaa583db577fe35", + domain: "", + wantErr: true, + needsMoreData: true, + }, + { + name: "QUIC Chromebook Handshake[3]; packet 1-3", + hexData: "cb0000000108676ef9ec3514fd5f004046001ae0c831dde6ac72f1337c9ca111f5b32afdf102d75c017d3bccb6fa89902b750b00c51bb226afa517754b72e962ff007c1c8c8749a21be1d8d94f7bf73437c010cd60e0bd4489d0a84868f32ecd4bd0d4c95a8a08d60d8303ef02323bdbcd96a33940824d25b9594bd8ae5716b9d043ab27ba03a2593c4d149b923711dd98e45456db19c8ea71e982562ae787c1b6cbe3ca1b03df2df62aa8e3127c5f68bdf80ed90588e7ec1f41f5a6281b87a12348cb17a04e9eaa461fef2e0e3ae70ebdc7bffa15c6b61ab270173e46dec0fd081f935a5fe6338d3b9cd38fcb52cb159edb66d2927238294313990da25c22f40d40e3cd72e76bbd066de731cf8fb6b4b7bc7639efb788c0b108dbf8280845a2cc62fbaf5fb8e1ecbe5ba7791aab94786c1c71c9058d0153b34a3f5bc8903e0d120f353defbe973cd33568bd03609dcdab8af1e8563897f5dd0251c6e6514bf40bd447d376fed21b2c54ebf74680df241bdc2ea5579bc0736cf3257c20d275746e8e6853aa89dcda8c2dbe523438ab92ca1ed1ab4f109e4ea84de57dfb6c544d695a5b710fe2d432f2b58644f8aeb965752d3a1d1a3057c2229192f89b254f5d292c22f1060642729df3667ef39e27691c82da9be847a59a17ba7345d23a37e31ec135633cc5ea84c752f56d4ec75878a2920b93e9b4e091e0114552712e1e50ade42e26ac0266b84043a493e1ce2e80cd57422de16a88deceaa55385dc2a977ffc9063e7c427200b6d8511ef9004f89412587bd6d0057898f5ae284db78b0ec861fed36dfb7c7a9679ad0480eefe71985ba6f731bd0e816a901e0c017dd0cb7fc8a4606dec2091a51aab16d6f9bbdecf3fea177671e68250a84fe19de8df78d711e22b81372bc22ae21ac7208ed41201f6e26cd6748e9d6e2f4884f5acba736b2432536718891638d43991bd97c232829e26be6e6bb303d44849b245ef758eb2813bc87cf21a30f132360111e3015de5d1e4f0c5a98aff159c29f6debed7c2f18f455dfc7f33995a90b7625688507ecef1e7db48e7030ea6c4fa835bbc1dfbea6c0a6c704d658d4866a42b9860b1c8b5b64cb669e102c81e369b5f07b8fa08816a566a99f4d2910f6e8d751d52f1e2889f0ec9acfcb4627e0da5c35452be05c7766eddf3c42ceb6a312044075a4231b4203718c886498a313f3ba12e44e368b04ec3ea6e72d6fed9b6b334cbc0ba89f0aa9a129b1bad5b0ad8690291a344967f58e52415859852c6ca3ea24bc93ec1041fd1dc8a6a181326d3026098db0cddec90b3cd6df1e7638a3703f70c9a3baff8f005b90f362459a275a8b39daa78ff24613434594f96b8023a41a17d815e5c0319a39e07d32841339f14f404030b4a22551b86ba94832a1c49053d63140b503f2f64354ce10abe6c08f6cdaf6d8dc361c3c9d1a8077ad34dccc699b6fe07c16f8f7743d04003d672f82e643b3f1d5e263495504e11e6b2e676c11b3d0033d5f837e6bfd01602584ff181e3cb86f081015a9311eed546b42a8280680aa538353949f89674c554b43241e36536430ae9e0190729ce902e8f06a952d23b62816deb3b62b45375033ede2d8065a8e7b38f5aee0a5c66eb2f21f33fa6795d4b086e6f6ac941ba0c883ccf6e54e52164384045e0b0d74a9361f224303c841ec907be250725ab06cf79dd8bff8f46c08963a409b9b71b5c634c987c5e163f73fc32553be1231c72444c5e2a91189824034a784948fc90000000108676ef9ec3514fd5f004046001ae0c831dde6ac72f1337c9ca111f5b32afdf102d75c017d3bccb6fa89902b750b00c51bb226afa517754b72e962ff007c1c8c8749a21be1d8d94f7bf73437c010cd60e0bd448983eee52163a177650f57b2cd8404bc619b9b59e796f9808bcd549ae6ae30d448c90f2783978bf9314a8038f45c0da5983163bd26f38f559f59447e8cf004f93b6b5c8af7b09603db021d4bdfa641bd83926eae1709a7a427add14df90cb258c6d4663d4d29709da89c90613d2ff9334637d53ca89407804eb863f78e110b866af2734c980705d9f969730a41132e788fc9e426d0f68ed24157aaff0383438d2715262e9b8b03cff850ba88127a05a8b68ac9a5ae5b098bb9ba5eaadd71ae846b3c0f68db728361eb8c8ed899c77725afbdfabf93812c49cbf4ee64047a96ea71258dbe5be3f988029d005fa2d9fc6e1e53fbeb6888074521b972e2ac71b4f22b754fc743e0de21af1e2ab416b2481e03227a1c7d7ea6cac5bc37ee3597d3bf11bf13a688dfa3d9aeff1eb1a7fdfcf8b6c722a4853f7c2b2d31e0b2b691f4273d4793fbb7a00f27a25577bfcba95e60699c9d2a926e71d64f535b633f2fd03320b28fe86c6619c54b34e6caf8f5a71b8a144c9236bf07edaacb486ff8ac63173af099efe7c9d006a5bb756449fb32b1fbff2e315fd5e96b586bb922a9795e29ffe6ead037c556e1bf30e24afb344cf873201007096b6f687f157588e236b71ade4d9245d8f065f2e23b36fad798d0f5504ddf25b828698d0cbdc28478b20d692d2ab605797a67232b0795927d886de798f00b4e7c69517d62b748e62e01d53dd1e77ac9a1605c0408713ff309ad53ff8f2bef17f9074f01134374068bf1f5dc07125180b5ea6902ec2d55c7d6d5f7ed4ef8732f9d34b4627678611fc9579e4321cea012c4e457dee6a11c41bdd1eb965056e885757af389079a558434eb3d59ae56a232302759431172ecc88de1c5400265f0f47e21396e3c38e0ba022c3e55ee4b85527cf49dece94445adc740cd26c18004a1cb984cc1732a138844da1ab003f89c589b6f3cc10c99a1b0d87be763f83e1b12c6fa6938ebc55d2ba33c25ca816dde207f7186f0c70b56b33feb538eb31175fdcfb036e365087f1b630628affdbbdee20d1976cb009f32db5f35aadb8117aa02ff2da9bdeaffbcc8bf3412efefeb00365e5f1ea577afd6e1c3585c67ffe1fa120382aa54028dcae9bbd624432a6256687d05483f2611f1ddd14b40f66fdf547e7eba904a79bd27733c9a8fbfb01154dda3457c4eacff8116941777ec570ff040e217d648ea5076588a6417462481eba68ebc59af04ba49b92f70b68a007977fde48b94b0af35475ea19cbec92df6449b065880bf03452cb3b3582f3d1a010e585be6506f3e067226471a94ce46c515f20502b3866553c10f037d9be89ad5858d6b2d2d94c70159247f66958d0e841d1c5b4254809d52475fdf96d087c3c6647b86006147a9ebb3f52ea6f4b89d886725b9e9243efd95e434bd8dd785143c57c06863b68df8f832987eb0c730c8b96634c1f888da2ef420cb0ebacf81f4b25c65962ae40c09ac4b0b2d440e3bdaa7309d87a1fa6af1c2e13e7a63c253fae027ceb2067cef8421b62d205f5d37c7204eaf594b1b43f9d9b67509a6709df48769ab9e1078f9e59d7656ec2132b5ebccf297e757a052835fffe94ae073131ac49c4f4374a1904cd4bf3041b236b73ea19eaa583db577fe35ca0000000108676ef9ec3514fd5f004046001ae0c831dde6ac72f1337c9ca111f5b32afdf102d75c017d3bccb6fa89902b750b00c51bb226afa517754b72e962ff007c1c8c8749a21be1d8d94f7bf73437c010cd60e0bd4489ea77dbb530c7ba127c66c3d7bbc00c336fd4e09e1775c646dffaa8696f7b8b00bf91261fc5164d57a4b9652b7cff4e301d32224b4e48cbfca535b2070ac46181615358d87e244ba6e369f6719bd5a551ac05dc78c222fd0969d0d943cbfaa3570ec25ab2768e9679d1cd1a3528659d010c409a0719526c44e4d9915dc5b0618ebc9e35f06b31bfd8e01fad99dabe32f6bfa00b3a5db5a01920d6685c34efb958729ffc5acfe46b3605715149b65b2f638007885a0866bbdde6765992b9acce2f527de906443f8643845489f1224fd3bbbb3fa78ca4848fe0167ec7cff8a05a17eb7c7a05a80c3106647e5d9aae350f33d10f3a60ab1c705858323a8f610d98cc68ef3cea66eedbb788b9a3da873bfd44ed632aa952ed7bb2004f4502260cef0596ec6e82e7683bdd2cb1f63b01b3f928ffa86b89cbeee922f1fd192fea0bdd17cf62d14f06f9e27bf5cafec90ab26f103e1dcb96ae4335e444b1fbad294cc395c5dc3a1c0c1fb4078d362eb229c42bc42ff53115c51f137d75596b3e6d3d28974720d6935430054c6b630bade51ad508d31fdfd572bd37f70e3dc06021d2b0ccf91a7975aa501e152d62980f02ce0ee94b547a2fbede47cf1f5c0a541ccc8992dd006f77437ce6a6b1f4f91833914a1cc51acf9336a620c4a22073966cde3ecac3224941dec004e741e05c11b43796dc531ce33e7c9a4fa68fa689880842e37a3a04fb75f3fcee86813388df74d443d1c35d7adea290effa98309b22ceca9bc252ccb4c443733db691adf0af559a5b7565043f84e91c5ed9f79ebf49f0bd60b68a7b8730032574e8e21548204c75321a374bbbf822efb1281ddf32feeced4bfe22bcf7c1a309954c1e356175a8a1a1a074a22f4561acd872d813c88ea9f0f22ac8d7b7b2088bc8565e1c56dfbc84f57aa38c2600ee20e8736076a91ee73f3137e8da3fe3871587b8bdb0a08af40babbe5493f036b45eea837dc15f761d9475d27a512a2d9dfc1ccdb81e2b581f91a5d7fe67cf6955427315a4e9c158806e651e4acff40051cd8a44b0108876c82f7b4d69033bfd8216234de545bf8fb58e489bc74d366db5e48711ba7f317dcdd1708ed5de97468a6026e15bc68ab11efc90f5465b4466bf384a8cc95f9c7fff91d776cccceeae5badebc31c3516c93a7b4682212e5a4902a9fd0327234749d83c141db2eee9688a76f4361f8b6213c88ebde69ebb84488c9ab8f42737da123eaf39373ac687df65f817939296f5477f92ad3fda0effbdd5d0594eb59d80265eef6cfcaf81b386c9d03c205c1b6714bf31be15e8f871b4791aec10884938285d6b8c18a0dfe750b753de88a2d2d855b9d1a0068ac4d2ce3a259bfdd30414380bf8b287abf2a28de442552f1d70a0aeb0867d9c7ed4e9717565ebc6aca21d85d2845faacfd8fadb1a76d9a2cd619413e631666009085bc7dad7492654ec20431e37ddd55588d2cd4d256021547cac768dfe3f7dcc9a18f0c72a743de799e98398b9bb2f216aea727d240b2f52ee269f4df4b8d7bdb439f074e3ef179ae2ae44daba64864fe427574b659a5e79defaf43e45e1357e1ff48e28ba6384c559cd036c9229151f917865b5575cda11e1ee0690bfbdb628b9a17e9c37190102", + domain: "signaler-pa.clients6.google.com", + wantErr: false, + needsMoreData: false, + }, + { + name: "QUIC Chromebook Handshake[4]; packet 1", + hexData: "cc0000000108a3e7f3133d37e2970040460094b49b4808cfaa190ce163e91b9d2c0105f36a2c93f670114f7b60598f03d6c596ceb19f410e9660903f590e3f25cf619e5c171001990b1d1b97f789595d3039e666345cc944894c6153ddd936992f160ae349757507f79fd0485766987d986518d9f19270a0021c52bff14e594c074f3c5664cf3de3b761cd36c16acf68565aaaeebf196da581533f19a464b22404b13b46ae3e4819bd4a7a85db6ddf379bb84f8dffcbb412c9ce405d8b4c98d303cb13df2e80a88ca0f09e2e2489c8d0b6d5ba9262b85869f8f989e9b82c4a270592894fda96bd27ce03e0cb4d4a4e130d9655e6da02f4348c949bc9b2aa609fdb4b9a0a3e45be25b18fbde569bb996d6419e98f2d9b7a0ca63f52f054b50771dc7c580596d86b4a94642be9a9b78a01ad2deae4607d8e0e25641aa8ed46b20fe027f4b9f77d1736aa0fec4f837cf5d878b3dcefdf3c6e82eb943dd022e98d623403950e6ea3addc0f93f92a422ed686b7beee437a4040f4a440dfd071d8c09f1344c28545b4488765a455e33e13d17434b9642dedadcb6a13ec35d51c3e7a03ae9a76cca6b1cba8312b7d8bae703e0a378300a17b7483d07893ddd941dd3e545a66faa0fabb4dc967c807665ebf4562fede176719d1a126f228acc0902e7235972a6db4eedd6547c38705629ee2574c5d2dd6c76c5c82e741f33291506e66a8df65ef6d1e7e6628fe4a4f5e141d482fc5f9d26609e64da8061eef5c0fca421d5334b199ca8270612074a1f9fbaad8b98ff7b81f8871f4ada6976f254e47c51e03d4c628beb3471ba375642ae0b41d65dec1419cd31f20ec779f5666717c1e7b4240fdcfa46a774234961083e1915e938ae0d41a66868b91949d856065c4e6813e0cbd9680a916b5eb78655dea9ad0f9c0ad0f5c244a72fcb8b589321519e34f0e6e25e6bb43abfa84a7241bc02555fa9060b9ef55f1e3a9dc3a575e16b23a36aabbd3ddeaf8f2516224179a4039a891e7f29631c2a08745bb184c66ffe98bc960e6c08a14524ae34444433591cdf7adc14419310b74594305f67c3087a2c21733e6e0be748e7af6fb6717946c313fbc0935ad3559e2d6323979cdc3bd48753b5a438605e15832efb8a0c4144060f41ed27a82dd067f2caaea3830abc97d9e080b3fd762aecbd58e8b2b17dae553dacdf3ee44198d2f19c0522b6a1b17923a210cf24902c5590afe808fd22e54e586399665d588a7febd0b402a4e6283679e1f95a2d4d7d3945e2bb8f44225ad8aa07cd07d3323ce94f39ae4c9466c05ceeb0a30981cea022d1bcab8a4b0c8e42e08211ee727728c74d7945f2350a149eb9cb7eb3a280954b64e612b53b19016a4c07427945345ffb86982c113ed797172ded4428d6b95b9ce64b48e98ab96421a179983c4a74b986f3f52d9a2d7fac8ea0955835d241bf4817a42950e2b298e51de20c026df81fdb0d28c68841bf62dfcfb4684def62c13ceddce9a25b446043056006ec8582aea14eee602eb2963f575dedfd2313d7d561c6ceac0d08c94645a222b25b7493542fee52c316f06f583612ab2ec3d420a01a61fe80b099386c2fe647292769d4571239592fe7e27f4324456ef894643f72ac450628cdcc9f376607b85f369a092c64d7d5a0559193e29cbc48e9ed77fa3fa05776d6169fbdbafa507db1e1d33a4550003a3a1a794b266e886f483eba76a8629d17d9596574068ffce61a52b209c21c77f5e7337e5541755c9f1c6b4", + domain: "", + wantErr: true, + needsMoreData: true, + }, + { + name: "QUIC Chromebook Handshake[4]; packet 1-2", + hexData: "cc0000000108a3e7f3133d37e2970040460094b49b4808cfaa190ce163e91b9d2c0105f36a2c93f670114f7b60598f03d6c596ceb19f410e9660903f590e3f25cf619e5c171001990b1d1b97f789595d3039e666345cc944894c6153ddd936992f160ae349757507f79fd0485766987d986518d9f19270a0021c52bff14e594c074f3c5664cf3de3b761cd36c16acf68565aaaeebf196da581533f19a464b22404b13b46ae3e4819bd4a7a85db6ddf379bb84f8dffcbb412c9ce405d8b4c98d303cb13df2e80a88ca0f09e2e2489c8d0b6d5ba9262b85869f8f989e9b82c4a270592894fda96bd27ce03e0cb4d4a4e130d9655e6da02f4348c949bc9b2aa609fdb4b9a0a3e45be25b18fbde569bb996d6419e98f2d9b7a0ca63f52f054b50771dc7c580596d86b4a94642be9a9b78a01ad2deae4607d8e0e25641aa8ed46b20fe027f4b9f77d1736aa0fec4f837cf5d878b3dcefdf3c6e82eb943dd022e98d623403950e6ea3addc0f93f92a422ed686b7beee437a4040f4a440dfd071d8c09f1344c28545b4488765a455e33e13d17434b9642dedadcb6a13ec35d51c3e7a03ae9a76cca6b1cba8312b7d8bae703e0a378300a17b7483d07893ddd941dd3e545a66faa0fabb4dc967c807665ebf4562fede176719d1a126f228acc0902e7235972a6db4eedd6547c38705629ee2574c5d2dd6c76c5c82e741f33291506e66a8df65ef6d1e7e6628fe4a4f5e141d482fc5f9d26609e64da8061eef5c0fca421d5334b199ca8270612074a1f9fbaad8b98ff7b81f8871f4ada6976f254e47c51e03d4c628beb3471ba375642ae0b41d65dec1419cd31f20ec779f5666717c1e7b4240fdcfa46a774234961083e1915e938ae0d41a66868b91949d856065c4e6813e0cbd9680a916b5eb78655dea9ad0f9c0ad0f5c244a72fcb8b589321519e34f0e6e25e6bb43abfa84a7241bc02555fa9060b9ef55f1e3a9dc3a575e16b23a36aabbd3ddeaf8f2516224179a4039a891e7f29631c2a08745bb184c66ffe98bc960e6c08a14524ae34444433591cdf7adc14419310b74594305f67c3087a2c21733e6e0be748e7af6fb6717946c313fbc0935ad3559e2d6323979cdc3bd48753b5a438605e15832efb8a0c4144060f41ed27a82dd067f2caaea3830abc97d9e080b3fd762aecbd58e8b2b17dae553dacdf3ee44198d2f19c0522b6a1b17923a210cf24902c5590afe808fd22e54e586399665d588a7febd0b402a4e6283679e1f95a2d4d7d3945e2bb8f44225ad8aa07cd07d3323ce94f39ae4c9466c05ceeb0a30981cea022d1bcab8a4b0c8e42e08211ee727728c74d7945f2350a149eb9cb7eb3a280954b64e612b53b19016a4c07427945345ffb86982c113ed797172ded4428d6b95b9ce64b48e98ab96421a179983c4a74b986f3f52d9a2d7fac8ea0955835d241bf4817a42950e2b298e51de20c026df81fdb0d28c68841bf62dfcfb4684def62c13ceddce9a25b446043056006ec8582aea14eee602eb2963f575dedfd2313d7d561c6ceac0d08c94645a222b25b7493542fee52c316f06f583612ab2ec3d420a01a61fe80b099386c2fe647292769d4571239592fe7e27f4324456ef894643f72ac450628cdcc9f376607b85f369a092c64d7d5a0559193e29cbc48e9ed77fa3fa05776d6169fbdbafa507db1e1d33a4550003a3a1a794b266e886f483eba76a8629d17d9596574068ffce61a52b209c21c77f5e7337e5541755c9f1c6b4cd0000000108a3e7f3133d37e2970040460094b49b4808cfaa190ce163e91b9d2c0105f36a2c93f670114f7b60598f03d6c596ceb19f410e9660903f590e3f25cf619e5c171001990b1d1b97f789595d3039e666345cc944892d4ba45357f2ca515d03b90820bb91c531a4be27266fda6022856da650cfb9c34139e8a3180e93cb73a6864471f849bdfa26c03e30c0e4d00309207cd46fb48887f60d7c51b208c247d1b311b35da70dd682cb1f7ae6a64215e5fefe25249daf308083837a3898e6052ebcf6cef3cb8e987ee1eb5ea797642d76391ae363b8eb2409d7486dd4a67c9e9b755376ca61009cb853835850e4fc1844f8e9eebca73e89317003482f70c4795ce9e2724c6d62172e010233e7bf203dde6eea9976f29896df562e8640a4ed88b5b3dff50296d0db43885f162c588d72de357c2ee049d9532642576de64d4e13cce77208e0aa9cf9838166f3375a968a5a6a01cf066ea0ca27fe4471cf0bf7eb36227867928076985588d05692d3f81d9a1158d150b2701399ee0a32693aaac43c27b76c657343b2a307e7018c2e9fe6317ec09f9afb762075430140b15016ae44acffc7467f4b1cec619942e916047c2db27f89742e53856d8c7c098beaba710340674a3f8455ab38fa2a4156fa3a45dffca1e20ec86ae792988dcb52bbf2ac97ea878e80511d3e4e70ece4b2816401ad450b9d13a1fecd7a5a363dd120285a972d52c06b632362cb8f897f799fb8342850b6670eb5083347347bd48b559f118839aa627598379963ecf18c2a900399ed936ab77ebdf95bdc5eaa75a903005e38dd99362b3d99f07ee2aea1a0ada77ec5ba76a7da2a80b672f4709bd32fad36787e37467e75fe594a24b402a6fa7e858c2abe9cffd9e885cc7091c035e4354779fc113bc084b5f6fcbd7bc618e9cc15205538cf781c96b658565cd8e39d95001d085d52f87a2970eb8f72149f4061d629ca0a928442b586aef9105326e13c015ce2b987c442b574180550302c48c2cf763b45492e25adee42d23bb2608e284caea4b3a28b77a20768dee6c0002b16e5d714eca22ca0c58195e03951b9564079ffa61c81afb2c5783ea2b8c0605d3994cfaed3c33af2279469c771269174fc5879b67617f571eb376161241ca5a89332074635413661b7fc5f925d86afb56b296dedce33d2b5011fc3b85cfb769c4a1cf5d6217ba3db367ead2159a310cd398b31df83f48f722a1df6c4b6604b2e288aa57cbc9afcf42764ccbc718a3ca42895b8e8287d632d2dd47d933a7472fd7be596c4241220917e636a44a139ec16600d74104fa6055a77c34bdbe14fb1ee56b4084d1d2dc1d56f8d636a8393385fcb4916670eaf8553b2126b12c8f187f58f00ba9bdbe8f06662688b9b8c7327b2d2c2f1443c8b87930d0948c3db62c8becb5b38cc7e484be184400f8c6293568abf1714e2832ad2c0aeb88dde64686fa7b4cd8c452b7365e70221e62dd971db057d4f8eed86e6802bbe8f56f75a8fe65d8216c81265e514042dca73f20a50373fb32e9bd62b741021337a3200b5f0a1b1329e99c57c75a60850f6c2f82cbeb9001edb54d985b7d5cd5957b31f79ee77dd8e1ce5e70d50806273885886b93a12c3dc0f211383d180a475d65bb54b0c5f761f456bfc7d045acd2c7ac648f3bf27bdb52218be48cdef7aa1ddc93e3ce11067ef4819796a4e2a30459c879841789b358b9430368b0910d6e6eaa14894f36b12fe9dd2bd1a20ddb6b12ab8fcec7d0629c9a7", + domain: "play.google.com", + wantErr: false, + needsMoreData: false, + }, + { + name: "QUIC Chromebook Handshake[5]; packet 1", + hexData: "c200000001085b15f32cf8fb5a3f00404600f909e38ed514455146c4ab8e53dd225a775dab2a06eaf73c2ec6b36c95c40873910eaa7e424e1b1fcb15892cf9e37a0ad2a1b67e9e8c6ec0c3a99e3d8775afe1e0aac824704489c14d28b48268df096f2db0c040c0ffdfb1817c4e1dd32005e87a74104515069ccd1b12f6fa3f657891bca8f0d27f4bb42b23c8310897ac09241f511888ac2e431e3ba8d9114b3f8bb1470324c8a0815dd1589686d058d03fa2669ad7367dc8877abce4700ae999112eb7cba755b20b7db66918021a36a66c60ecaaeb3e0859e3f50d14c1f8c3f56966043f437bfc16098deeb02e2236cc42d2f2802f4082bec30afc347a75f78c5e7337c52502e8e8d945bb4d792ef69419e57ee4e8f3465de4d0a49955787dff0756f1bcd98268919c112ae5e87ec333d590988e111724627143bf5a0aa69c77ee322b1240a65718e0033c4b70c6a5dc2d3248aef71598d73effa0eb397b79279ce846d9c2556fca28595eb3b196f40f052f0127711abbbc334571b8de67f7d39bd9437f9196bfe0650c4972462473776eccae42418b16edd5f45414e1a5e13300ae6705a49ef68e1748e876ce04fe611c973f94fcbe18b0c1a0ae506ce6eac268021e9744899c33ffe44dabdf1ea5413c20ab1013326255ae6df2d6861a7e914001e231ce4065e0d89fb439afb928d660cea26f99eafe65c9f89c5639f3ba8ffdcdf7a777d7859ca948f123a5c4f1491e22803754373ab0f1b605ac09ca6018c6acca7f52aad786ce96d9ae28d09a77dd88d77f23e2e33475973a23dea914fb049662800cfbed416b61835bd3bc22dace817b3b271c816ccf9603de2209067def5b8747112c49659cf6c5281402bed38a4176c0331e0841592c503d342188ac97266866a102864f76b0ff2adf781e0af84ae725fb6db418545dbb70adde5d4ea6d87f8c9b64b579d4f969830056dc0007cdad648035ccdf2c24264905422dfc1a85ac7f519f475351e046a27268312d4ab6a66ea55be01226fd5dfce06f804cafe85ad997946db3d029ef28ebdd36103c8fc05b522c1d4debe034523595cef576c771f0848a221d76c63dd044ea61a3adcbe5d4f0ebcd0bb631f4db1d88a609a1c2a6cc3de29ccd8a40e8a770d806abdae300cc178a32b4ba979652d0b8849dff252571f0b09935744c5b33628a190ae2eb43543ed8dee8539fd464abfcd3cf826aa18c4e84cd11975c5e3bfd0827f7cd211a2084c8626ed4e32bb9877f4801dabe695132b835e335563cb2f4c3e9377cac57f7766a10620f1c57c9f485d66918613daf8b257035ec91481d0076899c45abdbec38b63745428dee481c1cba81b0ab6e7efd6b0c431e018b6503cb13d4df18dbbff195bad1063d59ca5066e0733d3f499109111d22304066e7656e755518ceb6d862095ae54e532fad82f6c21c0c4d776dfecc516b00fa59e117e79481d3fd386c9b0c4d6fa4ec295a5b5b67207c3db20a206e0e31dad2c8dafb38e35dde331730bea33af32893653763e82565689009265db76b3b142d60f302a9545d82900aa6a017643c5c60583aefae43066ea3908e299612b078d06f102280dce4429461a42d80acdb6279c7aa190f9a8f61b485ffa430cbef199e1732da3d9b96cfac7ecc3b4959b86260eba763abb74c249180f67997967e716c95788bb6c04f182f40b795a929370c7fc72f1785f94cd36e3ddaddc15c7adb226cc131abc1863352caceb541d3924094db9c8a1c21c21640", + domain: "", + wantErr: true, + needsMoreData: true, + }, + { + name: "QUIC Chromebook Handshake[5]; packet 1-2", + hexData: "c200000001085b15f32cf8fb5a3f00404600f909e38ed514455146c4ab8e53dd225a775dab2a06eaf73c2ec6b36c95c40873910eaa7e424e1b1fcb15892cf9e37a0ad2a1b67e9e8c6ec0c3a99e3d8775afe1e0aac824704489c14d28b48268df096f2db0c040c0ffdfb1817c4e1dd32005e87a74104515069ccd1b12f6fa3f657891bca8f0d27f4bb42b23c8310897ac09241f511888ac2e431e3ba8d9114b3f8bb1470324c8a0815dd1589686d058d03fa2669ad7367dc8877abce4700ae999112eb7cba755b20b7db66918021a36a66c60ecaaeb3e0859e3f50d14c1f8c3f56966043f437bfc16098deeb02e2236cc42d2f2802f4082bec30afc347a75f78c5e7337c52502e8e8d945bb4d792ef69419e57ee4e8f3465de4d0a49955787dff0756f1bcd98268919c112ae5e87ec333d590988e111724627143bf5a0aa69c77ee322b1240a65718e0033c4b70c6a5dc2d3248aef71598d73effa0eb397b79279ce846d9c2556fca28595eb3b196f40f052f0127711abbbc334571b8de67f7d39bd9437f9196bfe0650c4972462473776eccae42418b16edd5f45414e1a5e13300ae6705a49ef68e1748e876ce04fe611c973f94fcbe18b0c1a0ae506ce6eac268021e9744899c33ffe44dabdf1ea5413c20ab1013326255ae6df2d6861a7e914001e231ce4065e0d89fb439afb928d660cea26f99eafe65c9f89c5639f3ba8ffdcdf7a777d7859ca948f123a5c4f1491e22803754373ab0f1b605ac09ca6018c6acca7f52aad786ce96d9ae28d09a77dd88d77f23e2e33475973a23dea914fb049662800cfbed416b61835bd3bc22dace817b3b271c816ccf9603de2209067def5b8747112c49659cf6c5281402bed38a4176c0331e0841592c503d342188ac97266866a102864f76b0ff2adf781e0af84ae725fb6db418545dbb70adde5d4ea6d87f8c9b64b579d4f969830056dc0007cdad648035ccdf2c24264905422dfc1a85ac7f519f475351e046a27268312d4ab6a66ea55be01226fd5dfce06f804cafe85ad997946db3d029ef28ebdd36103c8fc05b522c1d4debe034523595cef576c771f0848a221d76c63dd044ea61a3adcbe5d4f0ebcd0bb631f4db1d88a609a1c2a6cc3de29ccd8a40e8a770d806abdae300cc178a32b4ba979652d0b8849dff252571f0b09935744c5b33628a190ae2eb43543ed8dee8539fd464abfcd3cf826aa18c4e84cd11975c5e3bfd0827f7cd211a2084c8626ed4e32bb9877f4801dabe695132b835e335563cb2f4c3e9377cac57f7766a10620f1c57c9f485d66918613daf8b257035ec91481d0076899c45abdbec38b63745428dee481c1cba81b0ab6e7efd6b0c431e018b6503cb13d4df18dbbff195bad1063d59ca5066e0733d3f499109111d22304066e7656e755518ceb6d862095ae54e532fad82f6c21c0c4d776dfecc516b00fa59e117e79481d3fd386c9b0c4d6fa4ec295a5b5b67207c3db20a206e0e31dad2c8dafb38e35dde331730bea33af32893653763e82565689009265db76b3b142d60f302a9545d82900aa6a017643c5c60583aefae43066ea3908e299612b078d06f102280dce4429461a42d80acdb6279c7aa190f9a8f61b485ffa430cbef199e1732da3d9b96cfac7ecc3b4959b86260eba763abb74c249180f67997967e716c95788bb6c04f182f40b795a929370c7fc72f1785f94cd36e3ddaddc15c7adb226cc131abc1863352caceb541d3924094db9c8a1c21c21640c900000001085b15f32cf8fb5a3f00404600f909e38ed514455146c4ab8e53dd225a775dab2a06eaf73c2ec6b36c95c40873910eaa7e424e1b1fcb15892cf9e37a0ad2a1b67e9e8c6ec0c3a99e3d8775afe1e0aac8247044898c283466f3b200164ad9b30e17b425e07f6722df94b9a77dd555fbf25e5b0bae4fef254daf03f156b78afd967614c78208deaadef3552040c055487804c047604c5d6846e67d33e5fb5f743a81f688220d6f4c87091a860885af95d2db27e9c5dd2361f8196f5c1ade8fb37e159980547c38c6a6ddd0e055fbbd52bd7615615ffca15a0c144899d25f21156c53cb3922d2ccb83073e26074025a3c39f64a67dc02044ce0d630d9120041b2233bd26282bd2d7d1a81d486b64cab6dba7fb4375e200f53523f714a066b96769f9b1dc7c14353fc1faa51c0aeb99507ff3ae90ad6f4bfbc9b9ea00a87f8bf8e213a84a9efe2ce624e629261d93c83642df97fe146bdef478cc92bba387c9b524ac83cde55ad8f4a4d8fb3c09c8245a50ac16ebb67d651110a10ad1f7dc74ed32b9d644bc4b229c56942072aae5c311059165ef6839e7cfa0717c7032b667b8618527722fdc10a4c0ea900e9b414521b89ca83f253ea414a410a8b0b13da25c4b618f2ccd79e5d2a7579b4c431107d56ab8df16125bc25673181a6bd5abb09941515806fda32659e5281457d8c093314da0087169781b306f348d3994d84bdef936bb11355c41ce02c359174dc2a366509c130c96ddf5f156e0eb7912ac56611cf4f59ff3a8785034e81738a53ebc7fb60aaed709d78980d39822aae7e9a9d985aee6c11252a5e984ff1d167b9d4dc5d02ca8ba1167422dfc0f68b3b5902f3fd032204a5020b14a288ecd845816575fca7ef13c85765385e9964a9f0f6e2e5c4e600b190b275cd91ee8a38ecf73d35bad7371c15fdb73059afb3178786e76750845232ef787767c6985ea9b9ed9ff73430b7afb8e0b66aa210ab1943b606021bb8f50c55534e1014003d947533c1c0bd0c16dfaabf4914497583b818e643a2d8bc32d33a07133b4eecf8bcbd802dfaae894ebd473338e074af1b3672c6f03c55e6c3885848a4379cdb5873d9ff3015f9ddf8d954b3cb4eb9f56f2e8ccb519dcba72c5832146011068d3074520370fc8008b62f3fdd65978865df1a85e58fb62315dc617a3367e6c9564fbf74f5d5015932d435f3aaaaed37bc7d14d974c0e15d899c684f17db3b4790bdeba076624f4f45a0cc1c6c078a527695110842e837ded310f8c6ddf69a18e455f09130d4b4136ca6d02eee0f103b9923adefe8cb36b8fd554a27fa7300c4a6173835ca2c4d38cc11e3849ebbf73c475b7d0713caed6e70f55b34ccffe03978f231d5f92bc1e2da7ce589e2cc2cd76183394469fa537cb927db14a383dc589cf10819eb90dbdb7981cd1eeb3a284c9ce55ed859fbfbe73ca22328073b534bc81d319b5fdb97e66d532b5ffc19516b4c70ecb68f963b053a82915f3f74c8809f082bbc89d97dff9e8c82a65ed4be8e2975b82f0b7c73f34797c61db4ea8ee273116564288563a71747cf31568317363dffdff1d9e159b2f9bcd3fe5be96a9c50ac885493cc16234c58cdf471381664c1e3b54d147ea5c779c9c9b06d5c493231d9c03b50c6cba315a5ee766a6e8578105306e0911270d347e8ade2b354037f507e4993708191d32b51a79f023f4fccabb7d2ac262004745cc528b8a6dc1d8849e9d4a0152ab326b1eab8a505eef65076aca156f7b9", + domain: "optimizationguide-pa.googleapis.com", + wantErr: false, + needsMoreData: false, + }, + { + name: "QUIC Chromebook Handshake[6]; packet 1", + hexData: "c500000001087e13dee82c592724000044d0a17c2a188dadf8c82a018cabf25d25211d9987189b2900ad36a8fa366990353230bc8d41ec5543e91e119a0fd35f72d320d670074d02f412a5418c9a3e25489db73b1f5e5ddb8fc8d6c51fd6a12dcade71e1fc8e89d2663e206185247847d218d695793a8a1054afd18d42a4feaa9bb5fae7651eab0bc5e9aa91539c311cbfd17f46d8894ac45eade657bd456ee87b4475f5e84a2c07571b082ecfdafd1a660075692ae22048d163067a60e06cf879eab20a464c6e44b242da94cc6b92e064ee6a52cb34c115056925d4615e51157da4e88f019ae144040827cf2cd2806b3f4018cde5f42e041ef55eab35fe65ff79dba1ddad5aba6221e93d4555510176463888666b1d1f53a2f3c71e8872b05717002717edd3a9c5c651be47a663ee877962623ee92310b2b1dbcd75ec2f31d9e2f0c87affe3ee083aaa0868c03c9b4e78660d8afa4e936f81dfcb2fc33dbc1ed3828195c8de3130a2757641652de23d270c8a25976546c46460d9635f499a650475a4288d1c62241f65ddd346e2bde3f4fb5fec76646f51d829b55e16a0975494c11101abb504f5398a761d59355a4843e14bfeced024239ca06717d27e932df5e050d7c54c9b3cc937f6b0731f0b1dc312b14cf4388bbc0c601abf8ca16ed7d9b597dd414156d75b486ac256f8989a072fe680961ac7446201aca359337ef0e58ffa2aa12bb3c9bd1a9f6237b5c37880cd450d8a95db7c1463c53ac4bca174f278be1a99fb75ded9fe282e0e44a03b51ad943cf8970e4ca7f8567d9a3883d07bc0ff6c11639ebc7614fa88496488cb2a49a158d0f008a6a03caf97d77c3d03a98c5a611b04f865d134e258f4094bd220e00bde789c3b3158e622d509073179c0725c7a14dde1cd76b4c6b61fc7ba87f05742f081a5c42dbe83445132b8ad1539ee36e221a9dc700ccab55e34688b082a1a8edc48335760f3d5fb7e92b548e7a09d11f15b97bda08ebb5ea355e274587720d7c1189e9ffbb00dba3c13da94d646e7742e3641d59aee50a5bd400cd992c5614325d8f1ff3529637c3f60adc1682fa6b5e26f3d52de73236680abde87ead74368e05c600a2fd291a592be00fba64eea78c9e1f5e55e61f691b3eb0ef17b7bd11f06427c89c4c930d18c0b28221a6c918322cae56397c7e2978bf253e7f2d987f4cbe66c44a96b45cddb9d5f6dae47bbc9e1f9dcbe6280e50c5dfc91efb469f408b28fed49c583800009dc8bfb4bc42174175df987a3be833582abd9aa09ba0425973de2ea9a4149a81ae1863e0c9f1b1075c26bf965dcbec2bea47ff6042495ed715b65fdd3266800994463c95960dfb6ceadfa07d58910d329fa7ef7a8f14da4a6d3b09faa5b17cbac8481ea46cbfcfb54f660929e268bcf2f86cd88a1b065dcc27f18110db9efb6fcf1eec62874ed3657b1d43419f39e785c510d239c021b7e97d258d789c90d39b434f1667495bd4f5dc5e0eb97df376d801cced0da3a85aab6ca12893d8622314b5d530f28ead33075891d0ee553d5bedcffb20fce9933ab5e117df816c96398f6a60c9e6f5b9182fd7d58869de01635b2c178ae7738beb81e318934ecd752393129fda6833718d6984d8e1a8d7bf52e9d93ad0902c0fbe3e66ae8305e43363d8996626646a684bebfb1809ac9823be750e84308ef573243b884d09ef294094ef256cfc13cb0fedb1e095ff71687c09a767bff308e562e1a6ce9964014a7afc8db2481d8d07486", + domain: "", + wantErr: true, + needsMoreData: true, + }, + { + name: "QUIC Chromebook Handshake[6]; packet 1-2", + hexData: "c500000001087e13dee82c592724000044d0a17c2a188dadf8c82a018cabf25d25211d9987189b2900ad36a8fa366990353230bc8d41ec5543e91e119a0fd35f72d320d670074d02f412a5418c9a3e25489db73b1f5e5ddb8fc8d6c51fd6a12dcade71e1fc8e89d2663e206185247847d218d695793a8a1054afd18d42a4feaa9bb5fae7651eab0bc5e9aa91539c311cbfd17f46d8894ac45eade657bd456ee87b4475f5e84a2c07571b082ecfdafd1a660075692ae22048d163067a60e06cf879eab20a464c6e44b242da94cc6b92e064ee6a52cb34c115056925d4615e51157da4e88f019ae144040827cf2cd2806b3f4018cde5f42e041ef55eab35fe65ff79dba1ddad5aba6221e93d4555510176463888666b1d1f53a2f3c71e8872b05717002717edd3a9c5c651be47a663ee877962623ee92310b2b1dbcd75ec2f31d9e2f0c87affe3ee083aaa0868c03c9b4e78660d8afa4e936f81dfcb2fc33dbc1ed3828195c8de3130a2757641652de23d270c8a25976546c46460d9635f499a650475a4288d1c62241f65ddd346e2bde3f4fb5fec76646f51d829b55e16a0975494c11101abb504f5398a761d59355a4843e14bfeced024239ca06717d27e932df5e050d7c54c9b3cc937f6b0731f0b1dc312b14cf4388bbc0c601abf8ca16ed7d9b597dd414156d75b486ac256f8989a072fe680961ac7446201aca359337ef0e58ffa2aa12bb3c9bd1a9f6237b5c37880cd450d8a95db7c1463c53ac4bca174f278be1a99fb75ded9fe282e0e44a03b51ad943cf8970e4ca7f8567d9a3883d07bc0ff6c11639ebc7614fa88496488cb2a49a158d0f008a6a03caf97d77c3d03a98c5a611b04f865d134e258f4094bd220e00bde789c3b3158e622d509073179c0725c7a14dde1cd76b4c6b61fc7ba87f05742f081a5c42dbe83445132b8ad1539ee36e221a9dc700ccab55e34688b082a1a8edc48335760f3d5fb7e92b548e7a09d11f15b97bda08ebb5ea355e274587720d7c1189e9ffbb00dba3c13da94d646e7742e3641d59aee50a5bd400cd992c5614325d8f1ff3529637c3f60adc1682fa6b5e26f3d52de73236680abde87ead74368e05c600a2fd291a592be00fba64eea78c9e1f5e55e61f691b3eb0ef17b7bd11f06427c89c4c930d18c0b28221a6c918322cae56397c7e2978bf253e7f2d987f4cbe66c44a96b45cddb9d5f6dae47bbc9e1f9dcbe6280e50c5dfc91efb469f408b28fed49c583800009dc8bfb4bc42174175df987a3be833582abd9aa09ba0425973de2ea9a4149a81ae1863e0c9f1b1075c26bf965dcbec2bea47ff6042495ed715b65fdd3266800994463c95960dfb6ceadfa07d58910d329fa7ef7a8f14da4a6d3b09faa5b17cbac8481ea46cbfcfb54f660929e268bcf2f86cd88a1b065dcc27f18110db9efb6fcf1eec62874ed3657b1d43419f39e785c510d239c021b7e97d258d789c90d39b434f1667495bd4f5dc5e0eb97df376d801cced0da3a85aab6ca12893d8622314b5d530f28ead33075891d0ee553d5bedcffb20fce9933ab5e117df816c96398f6a60c9e6f5b9182fd7d58869de01635b2c178ae7738beb81e318934ecd752393129fda6833718d6984d8e1a8d7bf52e9d93ad0902c0fbe3e66ae8305e43363d8996626646a684bebfb1809ac9823be750e84308ef573243b884d09ef294094ef256cfc13cb0fedb1e095ff71687c09a767bff308e562e1a6ce9964014a7afc8db2481d8d07486cd00000001087e13dee82c592724000044d0b2c403d66eaa310a954540668e9edc4b17a321446ac931672ca3d9097b2854efdfa7a8f610be76592b56ef9154b9ab42f4dafc575a9b9572433fa2bba180194a32a72a92a42560ae840508317cf34015b1d7d88a633588ce4333cd12bec1f9d53fe905130eb136852d4f405ef66254a0807640fe415e6d667b9f5e2148826d5a6c36b3c44b822cfb7a1e76954610a522e1bc9703e155f8f1e0c705e411d09c5dec1183c61608174767408558da03290f5536682373a09c762deb829dfe3ee061ac9f509a2b3d20dbb77f262e9ba8a5ff50f895165742c90c4ff48eb0438d5ff8491700f97fbfced20e8e95ab9b67078ece6664527eb8a4e78944c07c6bc5c48776e141418c3b5a0e58d24114b7d65a83619525f5a10be53a55f6e3e65080cf42109aa2ec166fbb9079444ea6c809b5062227fed7cc81609a6d7ea471bc82cd0759a354aa896c7a8242c3d8c845aa52225bbaf7546a0de6510189cd2852f7b70a29687eee6a3a99a3a288f3c3672a72dba2843fcee320e18ea906adf1629cc7f8220b6be890a8d37f4093022717d8c6d76080d07798ba74e9cda1a4c26189c367a6d12da14621b93fbfd2d2365465350b5864e4981955750c6d4038b74644827cd60c8cad0d6a18869f99d61b214becedd8f71a476c2a1a0ea8fade7b15de6ee522b6b90d0cc4e6d40eb85d9b5097e2969e85eae6710285016ae47fbc858d63e13d882721aaef3cbe0a6e4c4910e8b3e465fa66a738d8979a444b4a4804baf5b4f9a5fc8438f4991c32d280c5d273d0a1e0d9eea30d003162cd313780a5b000f70fb7797e6111b354c3deac241cb816328b77d71584852966392cab9b1a3d64ead878a2cfac085452397ba17b5cddf96415c31846a80fa9a5a21fd5f9963324ad75505d4b5c70903ec3b5f91c3460d88a7d1c6b111a5206d11accac8a2115e1ce8e834b01f48e041dcd71585c6fcdd3a2e83ec2ff1a2b85e75134ec966afec023d375a2a8bcd54ef0c42d50e20c6cd9b9fdab63785e62c5a4ceb8451c560b647a6cd87698e56e0be4e2990337f45f1cb4c73f0dbf98da1158d75df6eb60ab7a61d836c7b7f3e5c809b850a5cc5369ddd4e455da5e88179e932311873d177febf6226a378c72324ea710e10ef74f6462e7dba25b7df336cb2947df749ad0b8455f3c5c9ba5c0c8eb1e665fe50451c928ce87cc81a0ae2102e7a4fc297392818db885943112fae3c4547ea48c89ef9cd44c2edba4856dbc72b956e4fc6a875bdac57b1cd2378ddb9322e5a1d1844977ff2a6e94d8a00f4ef0a7ef7949f0840c6cc781252830c70d37df9846a69eb95bc733ec420b7b3724572521496da27bba1fcb73c28eed1eefb094283ab01284ebd82004e0be9977f23fbf135b8162ac41a2bf9e1b941b05cb52c80279775070cf2f851bb0168235c97de47880d2d51f1d5ba8327af33f16f49d44326b0d08d20ca7880ff88a14d3201452d7fd452b24fc3b69b89c5149795bc4d0bf51b6ace2c9146048e5ca0259b4955a069a16d5a73e72248cec44b2ca542dcd326aca3ba53bd48368719f44d53eddbace11ff28c11c7fd90c38966752532d3f81325d1682839b2da3d69acc85275c71ef3b10c4d983cfb0cb464f554d9360b0d6ec8fd25b85824350866207eef9e2c66e43f5d08e86aa6186b36d9ece72f56e06ac8e51a1b53fab4cc496e69307e9810a9b5cf960f306ec54131dd8e917a5861ba92f6885e41993", + domain: "lh3.google.com", + wantErr: false, + needsMoreData: false, + }, + { + name: "QUIC Chromebook Handshake[7]; packet 1", + hexData: "c9000000010852e6d0c4f5f177b700404600eae9a1449fd711efdca846f59b6c9975a2189c1430f740e0e0eb4d50be086b798a47e037ee6afe9785b45df6302cfb87d39b9c03d0712f11793adab33e74904249722c4a1544896cd650da62160bdb601194f82a98c06df2546b79b5bab9503eafdbfbcfd1128204b52c9c5dde4d661cb84f2e015b7de9e10109874176362b7f06d4b49d850f2dcc8485aacb82fed8017fe454a1c31cfb82d392d6894081fa3ab1e5f2b71df79bf5a52a68a90d4752cf441220acbb274e3473f65c1a6e4cea3295da23e4a07818d5ba80b0668638c6ecb0b3ee12ecb8bed4ca32e27f4eee7376010b3905b8f7055728b8b1eda2e2707338b86f9a6115a23b29a010769d9a0e19d2bd06b81a507c4775d7215030862a026f168664255912c321669a5eff84ded4fec82af394cee909110758e5ad4de945236001bc0627d8e88ead3c3a6790d7e50887ced96f8380a80b11477147abc24dc4963c1907a07fec13e3cd8d5bab83cabd7cf8bb66af4911dfcdaf0f13aade34865b0740bebe4b4a482f1e3105bb9c3e5fece975187fa4eae5cb8fc868376b8b8329f89e407618aa5265f8ce73437e9f2714d752dad78025a38eaca1ebd6617a9a8a0bdefa8b3d3daad006978ba85d17ce3269da06be92eec61e4c5c99712517f01588b0b7deb4d7a75cadd5643daebc731f4a7bfaf17e8f002721b054a5d6d6ca7a3430c9480daff6adfd0a5480968b4fe0ee616d2e1f2f01268dcda2ee523fa593a0c83cbfc051dd7d503d48b152eb53894f79d4f6d38f05af35b287d16df579575b755f36e87b6df082108fda812195d5f60d2ceb59a54f09bb270d660c1d923348c7fdad97dc081e749a393af83bbcdd3c290efa19bce1a0f68dab0061df9dbee778dffb7754db10cbcc354a4b66c614e29d216a3a45a38594d337f775cb88c940924734ad52f8856606147b14ae2cf2990e1c401d79d27e4d6723afa4047454580698b9108b952b78b6bfd31db3b376f0879b2a0d8949b8443ffb9f7eb84b8024c620680481944312e86d183735effadab2d9f144a72d170fb035ed230f1451c94cb3f39bc28929e7480b22bbf6c906070eda03884cdd7ada9b10b7af27315c3bde8b4a273d46d1f764669aca152120da3e0a4fcf1be84b4f3cdfefe235a16598022cc74ad8f32e78aa06eb74ef61cccfc82ed35bcb70f008368ccdc17a6f64a316fcc9f006f307fa7a1a50f28c343c4c93a39df73a0d0a6dfc6f8ab10e966f738bee331e5a29d91ed993fd2638f0ec9d0ce539552b0a312fb85ed5e9f392fbc76a6164298b9de2c47dcb21a895957e92bc1270dfef3f00f44cc42c5f5005132dd030f9aec804045731c6a3eed3776beebe9451488932a1172b979f371aa370308037e57513a8fc9dd03d63fc2e5f7dcd683de26e116ea11a1d3b5e61fb5bbddc98e4ccd20be9ee71c02cacc95cbb17dd404558f586d4f0334bd12fc0a584d29eef3b4c2ce3f87babc462b6d24ca10aa8f1eb1abbd29d11ce3f1c92426c4950e53ba6c914cb4bf0bb1b44b25452cafbf246b76ce17f829bef3178174fbac4f932e6ac18e579fbbf8790611187c6f01de70fa82a21e979c90eed3c7f7b7e416491a000b5f2216e54858fa61893391b115573b2b960a0f7dc1e2a703a6f38485589c9133b4509fb54b4a602cc7d3341298e8e5da88d5e06aad28738650c08d8c71239735375e5bca7ea91dd78d748d65af598192317fd69e03daeecc99b8b", + domain: "", + wantErr: true, + needsMoreData: true, + }, + { + name: "QUIC Chromebook Handshake[7]; packet 1-2", + hexData: "c9000000010852e6d0c4f5f177b700404600eae9a1449fd711efdca846f59b6c9975a2189c1430f740e0e0eb4d50be086b798a47e037ee6afe9785b45df6302cfb87d39b9c03d0712f11793adab33e74904249722c4a1544896cd650da62160bdb601194f82a98c06df2546b79b5bab9503eafdbfbcfd1128204b52c9c5dde4d661cb84f2e015b7de9e10109874176362b7f06d4b49d850f2dcc8485aacb82fed8017fe454a1c31cfb82d392d6894081fa3ab1e5f2b71df79bf5a52a68a90d4752cf441220acbb274e3473f65c1a6e4cea3295da23e4a07818d5ba80b0668638c6ecb0b3ee12ecb8bed4ca32e27f4eee7376010b3905b8f7055728b8b1eda2e2707338b86f9a6115a23b29a010769d9a0e19d2bd06b81a507c4775d7215030862a026f168664255912c321669a5eff84ded4fec82af394cee909110758e5ad4de945236001bc0627d8e88ead3c3a6790d7e50887ced96f8380a80b11477147abc24dc4963c1907a07fec13e3cd8d5bab83cabd7cf8bb66af4911dfcdaf0f13aade34865b0740bebe4b4a482f1e3105bb9c3e5fece975187fa4eae5cb8fc868376b8b8329f89e407618aa5265f8ce73437e9f2714d752dad78025a38eaca1ebd6617a9a8a0bdefa8b3d3daad006978ba85d17ce3269da06be92eec61e4c5c99712517f01588b0b7deb4d7a75cadd5643daebc731f4a7bfaf17e8f002721b054a5d6d6ca7a3430c9480daff6adfd0a5480968b4fe0ee616d2e1f2f01268dcda2ee523fa593a0c83cbfc051dd7d503d48b152eb53894f79d4f6d38f05af35b287d16df579575b755f36e87b6df082108fda812195d5f60d2ceb59a54f09bb270d660c1d923348c7fdad97dc081e749a393af83bbcdd3c290efa19bce1a0f68dab0061df9dbee778dffb7754db10cbcc354a4b66c614e29d216a3a45a38594d337f775cb88c940924734ad52f8856606147b14ae2cf2990e1c401d79d27e4d6723afa4047454580698b9108b952b78b6bfd31db3b376f0879b2a0d8949b8443ffb9f7eb84b8024c620680481944312e86d183735effadab2d9f144a72d170fb035ed230f1451c94cb3f39bc28929e7480b22bbf6c906070eda03884cdd7ada9b10b7af27315c3bde8b4a273d46d1f764669aca152120da3e0a4fcf1be84b4f3cdfefe235a16598022cc74ad8f32e78aa06eb74ef61cccfc82ed35bcb70f008368ccdc17a6f64a316fcc9f006f307fa7a1a50f28c343c4c93a39df73a0d0a6dfc6f8ab10e966f738bee331e5a29d91ed993fd2638f0ec9d0ce539552b0a312fb85ed5e9f392fbc76a6164298b9de2c47dcb21a895957e92bc1270dfef3f00f44cc42c5f5005132dd030f9aec804045731c6a3eed3776beebe9451488932a1172b979f371aa370308037e57513a8fc9dd03d63fc2e5f7dcd683de26e116ea11a1d3b5e61fb5bbddc98e4ccd20be9ee71c02cacc95cbb17dd404558f586d4f0334bd12fc0a584d29eef3b4c2ce3f87babc462b6d24ca10aa8f1eb1abbd29d11ce3f1c92426c4950e53ba6c914cb4bf0bb1b44b25452cafbf246b76ce17f829bef3178174fbac4f932e6ac18e579fbbf8790611187c6f01de70fa82a21e979c90eed3c7f7b7e416491a000b5f2216e54858fa61893391b115573b2b960a0f7dc1e2a703a6f38485589c9133b4509fb54b4a602cc7d3341298e8e5da88d5e06aad28738650c08d8c71239735375e5bca7ea91dd78d748d65af598192317fd69e03daeecc99b8bc4000000010852e6d0c4f5f177b700404600eae9a1449fd711efdca846f59b6c9975a2189c1430f740e0e0eb4d50be086b798a47e037ee6afe9785b45df6302cfb87d39b9c03d0712f11793adab33e74904249722c4a1544898bcc839c7364f9518287bbf01c06e9fd67f74096cab78bc885ad264ca9151a48420ea11d5b9e3bc899cc0d663509c926bee5ef2a389a9945f5919677472b3245a2a68ab91654ba5f75026ae738a9e10b6b7439503961bedbfa2494099a9bba3b9595f70cacd8950abd5d3b8a85ac61e6482847e0ac71cbd63df462f4978afc7084ec5c9e65f3b57ad22f802d699c94f260212a61db6e6958ed60356bf991d3af9582cd1724a90f08e869ebd7f29fc3fb9e1198819a967096de1bdeea692fade6229b41c5efe6cdae313014db328e99bae1f323584a308f575b923a11185634b24c8cc1d608303c8ca5c1ae3d54b8b7ecb689d5e0e22323c5e47d8f9093080bcf1553f7fa238e156658ef50281f633f184e47992645c82ab9985b9b13f97f0bbd9db94285c131fff5870ea38691ade2e017ee6417a118a9b31f5b85ba2c76163f8668d90d448976d9d37238605d36b0b7e7abfb0e9c2866bb11b128bb70f003aeb77f439c6148d28719a4f336f4d622140faff82595233cff94906695e402b9115ba7b99f7d832f55d8de481af808ed9d48a493c3301d2b633cdcdc7a64acefaa9408b99a52768edeb9824cdb49257c6d3ea3f23763f70b74fc46252a97f7b3e173a93e81cca50fb12e8b0ea1083f9262e1607156296b5ff85e1531335441c90b442aa5dc616ed7b520bc040502280a0bdb011d6e9dac154587f033b3e9434cef567b724bf5203c315ef5e283028ec72ff33736499b8d326cd643e3a37d53e70b9a2384ac6037f488075eef8b2e507774d3d450ea4b1b65c1587eb2a60c6aad0ae20745a2c50f8acd8bc1e25740b4e7ab4b03a59731ccc487831b46ca0211264f4fd4a498e145aca0d7339663d29a7f32a14fc2b62a32f6354abf2d7de5ed9d7e0a1d6dbbfe14af25ca8c927dc8eeb2618f308eac81405552f1bafcaaede51f560fe5eb6aa78b8650ae97040b46469503c85994ebcf7ffa0222905657111325f861d380935c2a5b9ad26094e85b92327f79f66b4a2f8cd674344f931f0e056ba58a084a1026bc422b80ec11b17de1ca965e8ac9ede1464588303986ba8fabb395b55de5580131ae3bf61822e4e2817dacf765e034542e435c4e9ebc58f21cfa7901dfbcc2b2be98cc55fa6d9e0030e17a32abf84d551a74f7391dd204847c25ee6382f6374b8ecc5b29b598b9ba562e0a6f25ebb932570ae8ab7ef7d06e444fdf79845e88b3132ffb6e1f330e3424272da082486aba357bd254ef0738bb7f5c9db73d2a9ba0c9afeb34e09ff0e20bd44ba1a46ad3081db2f750d00b647756dec1bb41032e1aaf56f58d7046102aef6ae40517f9cbc148692401ad06ea4ff6ed3e5c8a0cff8f9466a3530a99cfb9b5a857a967675df0cfbe3b798fdc2d929fa4c86e3b3e3c45b75fa5db6c15953f25bcd025d7efc3172b2206a200128f6d8caca97154b2608511b35b0cba9a550d8f791552faed64036cfb8498dc60492207ab81c3f3edeafd9d3acf5bca2f2735117a273c70345d3b7e289b9948edda3d5ebb8adde7de2451fe2d942d92ab383dc9a9adb6fb9e8cbc0b73d852f176e0265a6107e6a59746e2f2e7203fd445e5fe278d02cd5dac1b7988e205c37bc5f35dc27572743810453b9b27e55c", + domain: "", + wantErr: true, + needsMoreData: true, + }, + { + name: "QUIC Chromebook Handshake[7]; packet 1-3", + hexData: "c9000000010852e6d0c4f5f177b700404600eae9a1449fd711efdca846f59b6c9975a2189c1430f740e0e0eb4d50be086b798a47e037ee6afe9785b45df6302cfb87d39b9c03d0712f11793adab33e74904249722c4a1544896cd650da62160bdb601194f82a98c06df2546b79b5bab9503eafdbfbcfd1128204b52c9c5dde4d661cb84f2e015b7de9e10109874176362b7f06d4b49d850f2dcc8485aacb82fed8017fe454a1c31cfb82d392d6894081fa3ab1e5f2b71df79bf5a52a68a90d4752cf441220acbb274e3473f65c1a6e4cea3295da23e4a07818d5ba80b0668638c6ecb0b3ee12ecb8bed4ca32e27f4eee7376010b3905b8f7055728b8b1eda2e2707338b86f9a6115a23b29a010769d9a0e19d2bd06b81a507c4775d7215030862a026f168664255912c321669a5eff84ded4fec82af394cee909110758e5ad4de945236001bc0627d8e88ead3c3a6790d7e50887ced96f8380a80b11477147abc24dc4963c1907a07fec13e3cd8d5bab83cabd7cf8bb66af4911dfcdaf0f13aade34865b0740bebe4b4a482f1e3105bb9c3e5fece975187fa4eae5cb8fc868376b8b8329f89e407618aa5265f8ce73437e9f2714d752dad78025a38eaca1ebd6617a9a8a0bdefa8b3d3daad006978ba85d17ce3269da06be92eec61e4c5c99712517f01588b0b7deb4d7a75cadd5643daebc731f4a7bfaf17e8f002721b054a5d6d6ca7a3430c9480daff6adfd0a5480968b4fe0ee616d2e1f2f01268dcda2ee523fa593a0c83cbfc051dd7d503d48b152eb53894f79d4f6d38f05af35b287d16df579575b755f36e87b6df082108fda812195d5f60d2ceb59a54f09bb270d660c1d923348c7fdad97dc081e749a393af83bbcdd3c290efa19bce1a0f68dab0061df9dbee778dffb7754db10cbcc354a4b66c614e29d216a3a45a38594d337f775cb88c940924734ad52f8856606147b14ae2cf2990e1c401d79d27e4d6723afa4047454580698b9108b952b78b6bfd31db3b376f0879b2a0d8949b8443ffb9f7eb84b8024c620680481944312e86d183735effadab2d9f144a72d170fb035ed230f1451c94cb3f39bc28929e7480b22bbf6c906070eda03884cdd7ada9b10b7af27315c3bde8b4a273d46d1f764669aca152120da3e0a4fcf1be84b4f3cdfefe235a16598022cc74ad8f32e78aa06eb74ef61cccfc82ed35bcb70f008368ccdc17a6f64a316fcc9f006f307fa7a1a50f28c343c4c93a39df73a0d0a6dfc6f8ab10e966f738bee331e5a29d91ed993fd2638f0ec9d0ce539552b0a312fb85ed5e9f392fbc76a6164298b9de2c47dcb21a895957e92bc1270dfef3f00f44cc42c5f5005132dd030f9aec804045731c6a3eed3776beebe9451488932a1172b979f371aa370308037e57513a8fc9dd03d63fc2e5f7dcd683de26e116ea11a1d3b5e61fb5bbddc98e4ccd20be9ee71c02cacc95cbb17dd404558f586d4f0334bd12fc0a584d29eef3b4c2ce3f87babc462b6d24ca10aa8f1eb1abbd29d11ce3f1c92426c4950e53ba6c914cb4bf0bb1b44b25452cafbf246b76ce17f829bef3178174fbac4f932e6ac18e579fbbf8790611187c6f01de70fa82a21e979c90eed3c7f7b7e416491a000b5f2216e54858fa61893391b115573b2b960a0f7dc1e2a703a6f38485589c9133b4509fb54b4a602cc7d3341298e8e5da88d5e06aad28738650c08d8c71239735375e5bca7ea91dd78d748d65af598192317fd69e03daeecc99b8bc4000000010852e6d0c4f5f177b700404600eae9a1449fd711efdca846f59b6c9975a2189c1430f740e0e0eb4d50be086b798a47e037ee6afe9785b45df6302cfb87d39b9c03d0712f11793adab33e74904249722c4a1544898bcc839c7364f9518287bbf01c06e9fd67f74096cab78bc885ad264ca9151a48420ea11d5b9e3bc899cc0d663509c926bee5ef2a389a9945f5919677472b3245a2a68ab91654ba5f75026ae738a9e10b6b7439503961bedbfa2494099a9bba3b9595f70cacd8950abd5d3b8a85ac61e6482847e0ac71cbd63df462f4978afc7084ec5c9e65f3b57ad22f802d699c94f260212a61db6e6958ed60356bf991d3af9582cd1724a90f08e869ebd7f29fc3fb9e1198819a967096de1bdeea692fade6229b41c5efe6cdae313014db328e99bae1f323584a308f575b923a11185634b24c8cc1d608303c8ca5c1ae3d54b8b7ecb689d5e0e22323c5e47d8f9093080bcf1553f7fa238e156658ef50281f633f184e47992645c82ab9985b9b13f97f0bbd9db94285c131fff5870ea38691ade2e017ee6417a118a9b31f5b85ba2c76163f8668d90d448976d9d37238605d36b0b7e7abfb0e9c2866bb11b128bb70f003aeb77f439c6148d28719a4f336f4d622140faff82595233cff94906695e402b9115ba7b99f7d832f55d8de481af808ed9d48a493c3301d2b633cdcdc7a64acefaa9408b99a52768edeb9824cdb49257c6d3ea3f23763f70b74fc46252a97f7b3e173a93e81cca50fb12e8b0ea1083f9262e1607156296b5ff85e1531335441c90b442aa5dc616ed7b520bc040502280a0bdb011d6e9dac154587f033b3e9434cef567b724bf5203c315ef5e283028ec72ff33736499b8d326cd643e3a37d53e70b9a2384ac6037f488075eef8b2e507774d3d450ea4b1b65c1587eb2a60c6aad0ae20745a2c50f8acd8bc1e25740b4e7ab4b03a59731ccc487831b46ca0211264f4fd4a498e145aca0d7339663d29a7f32a14fc2b62a32f6354abf2d7de5ed9d7e0a1d6dbbfe14af25ca8c927dc8eeb2618f308eac81405552f1bafcaaede51f560fe5eb6aa78b8650ae97040b46469503c85994ebcf7ffa0222905657111325f861d380935c2a5b9ad26094e85b92327f79f66b4a2f8cd674344f931f0e056ba58a084a1026bc422b80ec11b17de1ca965e8ac9ede1464588303986ba8fabb395b55de5580131ae3bf61822e4e2817dacf765e034542e435c4e9ebc58f21cfa7901dfbcc2b2be98cc55fa6d9e0030e17a32abf84d551a74f7391dd204847c25ee6382f6374b8ecc5b29b598b9ba562e0a6f25ebb932570ae8ab7ef7d06e444fdf79845e88b3132ffb6e1f330e3424272da082486aba357bd254ef0738bb7f5c9db73d2a9ba0c9afeb34e09ff0e20bd44ba1a46ad3081db2f750d00b647756dec1bb41032e1aaf56f58d7046102aef6ae40517f9cbc148692401ad06ea4ff6ed3e5c8a0cff8f9466a3530a99cfb9b5a857a967675df0cfbe3b798fdc2d929fa4c86e3b3e3c45b75fa5db6c15953f25bcd025d7efc3172b2206a200128f6d8caca97154b2608511b35b0cba9a550d8f791552faed64036cfb8498dc60492207ab81c3f3edeafd9d3acf5bca2f2735117a273c70345d3b7e289b9948edda3d5ebb8adde7de2451fe2d942d92ab383dc9a9adb6fb9e8cbc0b73d852f176e0265a6107e6a59746e2f2e7203fd445e5fe278d02cd5dac1b7988e205c37bc5f35dc27572743810453b9b27e55cc5000000010852e6d0c4f5f177b700404600eae9a1449fd711efdca846f59b6c9975a2189c1430f740e0e0eb4d50be086b798a47e037ee6afe9785b45df6302cfb87d39b9c03d0712f11793adab33e74904249722c4a1544894fb2a6f735bea394066ea4ab5d3ef6f419c4bb099bcea8fd7e36d8ec14fae027d0c84ba8c38a5ea1e2e9ff24ec334dee8085d1fa9d88df2c5ce3dddd981f7b2a68011f2d4034f8e4c6f43e645fc71e19927aec56045f0ef72d9da1942dbe3e42248c2f695525c8d8fcf6dbc970c2eb5d607e07dce5c8c66d4de07de6b2c35bd3bfa12cd4e4fcd4cdda3e0b2ff7575d406db96502f1ec4d9b5748215fe2a4018c7dbdb5ead1ddfc06da5233ce359e4f3924f2af1b80c7af9d13437e0107f7e240e485458a3a656e31a543bc5a80f6a598dcbbd87ff9cb4ce6842abadb72d62ae03e6d12b7f43ac1805e408d738148fa3a5c34deae7378d7d7309a7e09f5bac848f4c031693fbe3382a2de66a9d007420512e24b8a78a9489b30794c7cc51dd751c1cdeb2870b7c4a9b9606547f843c1a16d9be986b2f3e3d2f73f89c8e15da9de3dfdf7a667ced977332c5c62fd83d3c9a5e9718643e716db8f1b6fb58904ca17c24c9a4a191ec42be4c405fb00e443429582ff712dfdbadf1bb7e2d2abb0cc14f39c13a3b7013c62fd99488f043a6aec3ed7998b943ee24905fc915e3144c54393fa67ff34fdce2e48bba044f13ee1cd9c4f59a1a41f7fb7bdd8daee73461234f7cce5d54b078c3ad2b0aa37850ed4bb24f4d310d4ce75ede546ed6e73c0ee495ff8ce4b7256e8f43949539bf9df6e8d0fbf066fb506020c5a72e5e8b686641b78b365474c65fe9d8dd41133e27326fe82744b45b6ad1170433f3746647a68b824e94a213cda4c02f78465acbccdccb5bad1c70806d5a5c98c94338f88bf980b05b72cb82a4fd5b2a8586a5e5c5f2760115df595091809cfd12829f09622b53ca1d3809060aa7ab5d1f3640b3c2792a55c58fc3e80ac5d7f39ab5774a80fa1fc70461d396fa70dad1f90598244ce4197cb3ea42dce4afd61ca8ef93c8bc254d347872db21edcc3857bcb8dbe627508aa4856bd7d46e512db071905b3db100f425ba9f7181f0cce005cee2a95ffc190ddc1939e7049e58791b0e186433b0409f5a49e4e3262690a5160f8267c9099afdc58182236833fe7f825dfca34b08801345c1592bbab4964b34d7efa6c9d92e0106ede9a10fbf2a1be32f61f914211c3caa8b4c14edec5f9c139ee14789fe7d6634ede9bf9789caa60f5bf30b092e65ff95d3b32cbdc3e5842e3b16b935d31a3a0963bb0fe60f41efb6590f24eaf5e84006b28b3c755203113237e43fa70a37a009f71da49ea3f8097914d6128ee2b18adac49b5111fd3d18db9fd61ef8a2202fac5cfce646ccbea7eaaa81df0f1b7243465de15a3900143f479852f0e40bfad434b96eea3941f527b0d31c3d8f43188b911140766b5d7146feb93bf4da1ec47023dcd8f89863e487ba25c3105a4e43c4ea90f479eb0f774f3aa044b817f7e69b5dd1b3954e7dcdb2a6c4d191d5b9178262449413310f3876dd93145716781cb077025deb37d23c35e6fdf867d5353d10303b9e60efa50e9ecd013cd3f5270fc0e117a19ffb63038c594190018bd9c1c18a799f548c08a3e6f768de0de344cff160689fed73aa7fc4edc26f77413145775745c25fc2c9da5b62e24eab9b21895cfcda6e6457ae9fdfa6c54b49b0d160dad0aa7f8cbd3820a3098", + domain: "ogads-pa.clients6.google.com", + wantErr: false, + needsMoreData: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + pkt, err := hex.DecodeString(tt.hexData) + if err != nil { + t.Fatalf("failed to decode hex string: %v", err) + } + quicHdr, err := quic.SniffQUIC(pkt) + if (err != nil) != tt.wantErr { + t.Errorf("SniffQUIC() error = %v, wantErr %v", err, tt.wantErr) + return + } + if (errors.Is(err, protocol.ErrProtoNeedMoreData)) != tt.needsMoreData { + t.Errorf("SniffQUIC() error = %v, expectsNoClue %v", err, tt.needsMoreData) + return + } + if err == nil && quicHdr.Domain() != tt.domain { + t.Errorf("SniffQUIC() domain = %v, want %v", quicHdr.Domain(), tt.domain) + } + }) + } +} + +func TestSniffQUICIncompleteServerName(t *testing.T) { + // 2 packets + pkts, err := hex.DecodeString("ca0000000108d799f48baf472fc3004047005411dcdaa24bd4c3cdbef653940a1ea0a671bb8c23222a8502bfcbd0a335af016df330b1190e4b1efd420aa82c4414a7dfd7b1aa63aa7bd0269ec8ed0d24895a467b737fcc514488a8142241b81c4952fb32e9f123f3f8d1be9eecc1340d7fa747c6f4838810209d51ad453fcec084ffaa382f9fed010a0585f8ce73c36dc6c628df940f72fb5b8e3e06f4612128d3b8f87725770d81305489a3a23cd443fcc668fece0ec9a909c82cfdb66819ce031422c3edd49ea72b6216efb940b8c186e2510b0f93d4cf3b6434ed9f5817c5a5a19fa861d24883bd48ba296df81e887fcb9ef18013ab1070df268049f3d35e8ddfffd2b100e4eb687176a02e7975085caa138e9df7cb6f9862356faafba3300f586df09af3b4e3eec15b6d1f14b34fe4eeb8e762ff482f3b7b0595c16d3eb20cf9c892b3f7c6449e51ffa33f3dc877d32e572e10ba4d5a320117110b150bec4a9434103de963aa2de1b22eaa992b59a8583c7a2d4e5743ef98a1b1f5f4aaeb2b49dbe441c331e7cb028e70432ce0890f78d40671f13d5feccc4ab264ae903affaa951897128d598ed8e8542294aa03abb0a2a7ec970ab874387b8777827c4847bb29ff93d0427c1fcc581407465611e4400bfeab39de4c4f65572365156421503706d66138317e514214db27303ad8b5b17eb443e959faad1ccb3d3def5f3843b241dd9a60378cd907a02cc5c6e8527715c7734079cf9143586ed471587690816133fa8f09b8421f2de6ff1f5cecc134ac404e53a367b57fd4f3c85fe7e121e7094fbf93c06d427cec30cd519ee43a6018a8bb8717c05d7660b379101a182bfd3018d485d5b46e81d39445ccd4d8baefdd7590e664f2289f11bbad3d35ea6d70e157aaa7f9e91a692794b85c5b86db33863151468d32792ecfdb2aec52784ded5aa431fa9a7337ddd9e95313a897fe5ca6ef3c7e0cf3d41f7f104506f8695f2ba307715022e5e98472d6ff24125004d14db2c7a4cc71ca39a9874bfb93b64dd54ef451097059bbdfa96aca6c6c01e1f000b8d35bdead1502874e5d80ac00a79593b6d7e2fbee406c2212b4abd7b7e9f0037518de232cd6559443f4e3f0f03c17cef616a74992f65754bb6699b08c0eb2ec59508086e496e070c6239a73f11a9d14a727b10188ca97ebf04851fa475ed1774836a94cfb6543c33888dfc250100e9992b0cca8bd27ae8552541f1b3d81546f15b740e4f07b41af864769fe17290eb7076c0c1f938ce56a45ead6deb6c89164f829543414a1b8cd2361c3d9b22cf85d4ad0d4221dcc87533506e32c1cfdc8240636b669f97f7c6e150ea3753fcb63a7b9eedb5615b257651e090b567a20fdc5c167ad58fa940985572db004db2b14709a6663c1fb79dc045e45cb7228f11eab4c60a48fffc702cd74dcf5aabded8355a5ae1a5e6325a3afff608e53af3aa944437139c438e6200c75bb27c8a8ce7ce9f9ec9723c4423e9e49c807b12484783ed79fc501b544f03e4b29bdf0c74eb055dbac9b78fe87a66efc819f9d2ea637dd478b920b7196232b970ed092050ba0621329aa2b3e26184176137a9c6283e4cc2c03c07e28d2da7b0485da51f131686f4dd6b23735c66316142f48781885c35c9940054a4b9187a20914bedd1c48e94af358994da5c6060dd224b0ba84ddd5e95f395fe941d464e2cccd857a180de756d32407540c3611b649c7a71cbf5a492bf5c8d4e112a743498ce83ea3e94bcaa6c00000000108d799f48baf472fc3004047005411dcdaa24bd4c3cdbef653940a1ea0a671bb8c23222a8502bfcbd0a335af016df330b1190e4b1efd420aa82c4414a7dfd7b1aa63aa7bd0269ec8ed0d24895a467b737fcc514488e7151df796764293639665547941eaaa7d83dfc9d42952583a821611921cba9e0276f9244f197e011b6c2d898255802c81c8792dd68d03cd8982ee6146c8734814e9640e0999312f97e898db60642ceca21700be9e698b5e577062148d1ac840e737f7bc4f18f9ffd13e656fca1517c96d0e0c607b67d7e75795f62131255b44c2178d896192348d5f053060fa21c855236401e853e435fbc71a428c8e126cd8393cb860193fd6304d9576e8a8ce7f6959739afa7d7ffaf86516afb061ade1eef603e8e5c66f002cacbef25546e84b59be707c547837f7b49471a59325ad58a4f189a525a3a354a4be5ffd3db34ce0585ec470f78f0ff6eb807989d5998e2fccc80bd651de654da3581b6c8a858b56c4df47c3041c50d74f0b3a3a5a325882cd356d0c46d6db74559cef934a1655c65a06daff218244f5f4e95b96794e45d371a03afee2c89768fe3d7bc134844f45440620a88d6ddb5d07b7f6c9b2adfbf5743c5c586520504febf14ee4b216f8186ee1bf9802ccebd4dac519bd337a554940a3873cd21ef32f3d4d4fdfd3eaabb172b5314490b3587a9ca2dc12637fa80dcd526859bb83d54f67dedeb173470e052beec9edba4b41444d31253accb3381237179a5381d437fc4d47c0a82f1c9da8c76ad3eee9417bf69acb8d530ac824e65d796b84bee40b14daa9e80c11e466f93233e1768ecc6c0237e71b901f1faa093bbd9e5324b2a160d02f09d4590392279a15c73edc4d1d7501ebad992fc8f1c9dce96c190879225dbbb09d20532f9dcbb845e3484c87cb8c3b06fe892b07bdc60926e3d4b5c9024acde5abed0a72686d546da535a2122cfd6d6488a491dc9612b90f3f6709835e83f59fd612c2259c3ac944fdae87ffd744176a92fbea1efd037565a39d5bc38991cfe6617135b43cd6c6484a3b228e10d3f8184227a7ee63121be20f099c4264461d52aecf4b8ee1a4d0ec41717f9a68e1394544cf3be0a3a171ece35c879b67afdaac49c12731e6dc5ccaa49fa72610901036a7f0752951077cd9f1d77eb6e4f12c16dab08e1a9655fda3ba0e80c34c767f40e61491f706ab9d1b50f48273ca4e37708d075909a3e2c4b173510114d8377b5300994f9a4f794db2781b98c2e9d0056fdbe87b249beb3e7301c86efe6b32242b4c7fabef280a1ca7bdd6abb38624cbebb01b6b75b07d0cd9090b2c296d0e330b9008788dd6f7e1af1dd63b02408f1a67b57be3316152270bf90c36e9f74322c9caba5adab3309e5bd7c44d3c2ac77329e167dafda7395e37313723fb550a6ab96729a9fa8f9e4a3e5957bffa3302617d48fd38196635309928c491ca974a112768de16043fc618001780b49a0bac2ea9fc2607ebd1f25b8ef65a6cab42d16c9184e23af496ac5cfab274d9557006d9c52bb56cd8c019ddf085f260a0582ef465c73f97fedc02271dda53eec20e6aa50503357ed1847f7d976899cb24e5dd42dd87ae48db3c9335b38957fc0f86a6ceee590b1cbee41fc6ace3189886bd86f9b082e66fb263f1a98dd8e564bff9ec412ae79e29fd519ac96e9c5b446b436b78a6ca555c496ca5c5e73c2c1c5837b13f7a953d57738440d4ed60efd4701bbbbcad79e1697b5724695f52dab8bce02e7f") + common.Must(err) + // The first packet ServerName is incomplete + pkt1 := make([]byte, 1250) + copy(pkt1, pkts) + quicHdr, err := quic.SniffQUIC(pkt1) + if !errors.Is(err, protocol.ErrProtoNeedMoreData) { + t.Error("failed") + } else { + quicHdr, err = quic.SniffQUIC(pkts) + } + if err != nil || quicHdr.Domain() != "play.google.com" { + t.Error("failed") + } +} + +func TestSniffQUICPacketNumberLength4(t *testing.T) { + // packetNumberLength = 4 + pkt, err := hex.DecodeString("c60000000108fa6cc47e912693590000449e5ea65fc129945b27f59f0b18f737a53e44f322681ecec36beeb943293db0ed751bd86413a840f9b9e9be718f3e2dba1100a8bab3a21e1541580ffd98e79aa89fa723e8d3a46f7876504c82b9ef3a081b0f8cb551370d9801ee86da77f09eec5aa19b7bf580a80ded3c9c83378285177115fd30b350c2a596ae265b3b538a81c183c0cfd13eabecfbbeb38416a5b19259731b838842c0eb33e646b9bb1f672043e90de33c3442151ee8db7d9cd66238f769f4486432ac28785a5083c616539f8320321060f64f9a0dc6af718754d645892397ff32956c4c1c97d0d9e44cdfa8d1a0ad90c3bbb7810b2196d638fd772a172a9510ea12ef12fe4050c5678851be26ec6ea6ab11824cc86ce071d110f72816166c01622c0207e9d97f8867ec7c63149e974c5a81db9cb5e0061cff2713538daa1c9ad1382ab7d883ecc85158dc76587793b258b4b0aded3f4c12b515a9183ee419b304cf748fc321f15b3f80cc53da1b889d1ac06b996d35e8d01306885851ad253083f37d0d588c9f619da25f6eb8360b846bc26913af616e2c3eabce9dbb61f7dc96b6dcb79e19905ac9ba8f3938d03f8a3647403dc919f37bb585a0d67b7ce955547d15c82eed6d94b04dfa009eaf8b30448e1450043c48845acb4fefcf29bdd55ec14e395d0e8cd8400ffdda5a58747c6e8a66d0dc5fb25f3615081b2b546e004079573e99290f5daf72705ca495707468dd26d94c7f04d7e6f89d8148ecbab67c8c0062984e0ba02539527370a2a157a58eab342ad671641812ed35b4a52ba07d244d9b5d64e29f012133d21fa4afa31645c21f6d836ad937bb75f7177768b5f94bb77e95aaf9a85f8fb7e599d482724f694cf5d7d3f61bfca892794bdcb3de7a5f321db8120560bc32b8839c0a5994917c151cc6bd4c1614c5f117e637c19dab7cff28c4848c3b328eb97e49cefded2d44a824f2705807770c2ef9dd07f0fe0198659ad062e1889e280e5f3d1c52a92ef27d4565ebae9b9a18a803b70f38e5db237ed99583d8952c79492e35e1f1c41664f1f45566126a7ec44a90004b015b893aa805fcd772737fb8dbbe7af56b9eac288ef6cab7cbb6f7a3c0b29a43bc84b6280def0f7d727b3238cba3eda2e2d110de87ad0f10e25a60783cdb0c05116df5359b19b40007812b898d03dc1d697690761856d785b83ac95778db69c3df7a8f0e092ee6ed2c9c189ebe40734b02cee2d02599e931d4cc560d38a7ec355b9f339b932613ee18f8162e8d3cb81301bfc6d726b7c26ec96d5edcaf0de171563482ed2f2de3001dbca2aee1029fdaece4340fd2d5ae8333819d5ece7c9d3f77f99a81fccd1fbcc3ea585c1538e0363141e0fd20338a193695377987afacd0baf1f0dce11b4bbf29965109bddb508e8a0974c08906d4ea340d51af376c3dda55bf97e3ba5d688533980e12704679bb18d0ef4ddd5b3af1b7676528c4bf4a84c84d40892715c0a8808ad51d6ebcc6469da708d6953e9ddcfbd19bae90e9b078f1b6641401b979304b0ef52b1441e1797ed366bb0519ca8bf9c6eba72518647d0a1400ca66a20fdd8e3ff06ee52c199bd8f941b1722a0bbf8c15447452788ba81a68431f735d99e8a80691ef64d1bf470350c8878aed3e2421223d0ba6a3d84928c8e6db0972263df9da49b8f5") + common.Must(err) + quicHdr, err := quic.SniffQUIC(pkt) + if err != nil || quicHdr.Domain() != "www.google.com" { + t.Error("failed") + } +} diff --git a/common/protocol/tls/sniff.go b/common/protocol/tls/sniff.go index e7661fa7..11660b92 100644 --- a/common/protocol/tls/sniff.go +++ b/common/protocol/tls/sniff.go @@ -3,9 +3,9 @@ package tls import ( "encoding/binary" "errors" - "strings" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/protocol" ) type SniffHeader struct { @@ -59,9 +59,6 @@ func ReadClientHello(data []byte, h *SniffHeader) error { } data = data[1+compressionMethodsLen:] - if len(data) == 0 { - return errNotClientHello - } if len(data) < 2 { return errNotClientHello } @@ -104,13 +101,21 @@ func ReadClientHello(data []byte, h *SniffHeader) error { return errNotClientHello } if nameType == 0 { - serverName := string(d[:nameLen]) + // QUIC separated across packets + // May cause the serverName to be incomplete + b := byte(0) + for _, b = range d[:nameLen] { + if b <= ' ' { + return protocol.ErrProtoNeedMoreData + } + } // An SNI value may not include a // trailing dot. See // https://tools.ietf.org/html/rfc6066#section-3. - if strings.HasSuffix(serverName, ".") { + if b == '.' { return errNotClientHello } + serverName := string(d[:nameLen]) h.domain = serverName return nil } From 2eed70e17dda9db003ecf6aa7ca5ce88f76f7a38 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Tue, 29 Apr 2025 07:33:37 +0000 Subject: [PATCH 803/867] buffer.go: Ensure extended part by Extend() & Resize() are all-zero https://github.com/XTLS/Xray-core/pull/4655#issuecomment-2837693439 --- common/buf/buffer.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/buf/buffer.go b/common/buf/buffer.go index facf6812..2aa60e6a 100644 --- a/common/buf/buffer.go +++ b/common/buf/buffer.go @@ -13,6 +13,8 @@ const ( Size = 8192 ) +var zero = [Size * 10]byte{0} + var pool = bytespool.GetPool(Size) // ownership represents the data owner of the buffer. @@ -150,6 +152,7 @@ func (b *Buffer) Extend(n int32) []byte { } ext := b.v[b.end:end] b.end = end + copy(ext, zero[:]) return ext } @@ -198,6 +201,7 @@ func (b *Buffer) Check() { // Resize cuts the buffer at the given position. func (b *Buffer) Resize(from, to int32) { + oldEnd := b.end if from < 0 { from += b.Len() } @@ -210,6 +214,9 @@ func (b *Buffer) Resize(from, to int32) { b.end = b.start + to b.start += from b.Check() + if b.end > oldEnd { + copy(b.v[oldEnd:b.end], zero[:]) + } } // Advance cuts the buffer at the given position. From d9ebb9b2dc1fd41a013eb4006522234e5c4326e1 Mon Sep 17 00:00:00 2001 From: j2rong4cn <36783515+j2rong4cn@users.noreply.github.com> Date: Tue, 29 Apr 2025 16:04:04 +0800 Subject: [PATCH 804/867] QUIC sniffer: Optimize the code (#4655) Based on https://github.com/XTLS/Xray-core/commit/2eed70e17dda9db003ecf6aa7ca5ce88f76f7a38 --- app/dispatcher/default.go | 2 +- common/protocol/quic/sniff.go | 29 +++++++++++------------------ 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 34a59fa5..54864cbb 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -43,7 +43,7 @@ func (r *cachedReader) Cache(b *buf.Buffer, deadline time.Duration) error { r.cache, _ = buf.MergeMulti(r.cache, mb) } b.Clear() - rawBytes := b.Extend(b.Cap()) + rawBytes := b.Extend(min(r.cache.Len(), b.Cap())) n := r.cache.Copy(rawBytes) b.Resize(0, int32(n)) r.Unlock() diff --git a/common/protocol/quic/sniff.go b/common/protocol/quic/sniff.go index 61171c01..3a22d454 100644 --- a/common/protocol/quic/sniff.go +++ b/common/protocol/quic/sniff.go @@ -10,7 +10,6 @@ import ( "github.com/quic-go/quic-go/quicvarint" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" - "github.com/xtls/xray-core/common/bytespool" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/protocol" ptls "github.com/xtls/xray-core/common/protocol/tls" @@ -53,9 +52,9 @@ func SniffQUIC(b []byte) (*SniffHeader, error) { } // Crypto data separated across packets - cryptoLen := 0 - cryptoData := bytespool.Alloc(32767) - defer bytespool.Free(cryptoData) + cryptoLen := int32(0) + cryptoDataBuf := buf.NewWithSize(32767) + defer cryptoDataBuf.Release() cache := buf.New() defer cache.Release() @@ -143,7 +142,7 @@ func SniffQUIC(b []byte) (*SniffHeader, error) { cache.Clear() mask := cache.Extend(int32(block.BlockSize())) - block.Encrypt(mask, b[hdrLen+4:hdrLen+4+16]) + block.Encrypt(mask, b[hdrLen+4:hdrLen+4+len(mask)]) b[0] ^= mask[0] & 0xf packetNumberLength := int(b[0]&0x3 + 1) for i := range packetNumberLength { @@ -217,15 +216,15 @@ func SniffQUIC(b []byte) (*SniffHeader, error) { if err != nil || length > uint64(buffer.Len()) { return nil, io.ErrUnexpectedEOF } - if cryptoLen < int(offset+length) { - newCryptoLen := int(offset + length) - if len(cryptoData) < newCryptoLen { + currentCryptoLen := int32(offset + length) + if cryptoLen < currentCryptoLen { + if cryptoDataBuf.Cap() < currentCryptoLen { return nil, io.ErrShortBuffer } - wipeBytes(cryptoData[cryptoLen:newCryptoLen]) - cryptoLen = newCryptoLen + cryptoDataBuf.Extend(currentCryptoLen - cryptoLen) + cryptoLen = currentCryptoLen } - if _, err := buffer.Read(cryptoData[offset : offset+length]); err != nil { // Field: Crypto Data + if _, err := buffer.Read(cryptoDataBuf.BytesRange(int32(offset), currentCryptoLen)); err != nil { // Field: Crypto Data return nil, io.ErrUnexpectedEOF } case 0x1c: // CONNECTION_CLOSE frame, only 0x1c is permitted in initial packet @@ -250,7 +249,7 @@ func SniffQUIC(b []byte) (*SniffHeader, error) { } tlsHdr := &ptls.SniffHeader{} - err = ptls.ReadClientHello(cryptoData[:cryptoLen], tlsHdr) + err = ptls.ReadClientHello(cryptoDataBuf.BytesRange(0, cryptoLen), tlsHdr) if err != nil { // The crypto data may have not been fully recovered in current packets, // So we continue to sniff rest packets. @@ -263,12 +262,6 @@ func SniffQUIC(b []byte) (*SniffHeader, error) { return nil, protocol.ErrProtoNeedMoreData } -func wipeBytes(b []byte) { - for i := range len(b) { - b[i] = 0x0 - } -} - func hkdfExpandLabel(hash crypto.Hash, secret, context []byte, label string, length int) []byte { b := make([]byte, 3, 3+6+len(label)+1+len(context)) binary.BigEndian.PutUint16(b, uint16(length)) From 1c4e2467889754a99358b7d9a6a685753102be2d Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Tue, 29 Apr 2025 12:03:36 +0330 Subject: [PATCH 805/867] Sockopt: Fix some domainStrategy & dialerProxy bugs (#4661) --- transport/internet/dialer.go | 68 ++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/transport/internet/dialer.go b/transport/internet/dialer.go index 554ee5cf..74e5f0b6 100644 --- a/transport/internet/dialer.go +++ b/transport/internet/dialer.go @@ -87,7 +87,7 @@ var ( func lookupIP(domain string, strategy DomainStrategy, localAddr net.Address) ([]net.IP, error) { if dnsClient == nil { - return nil, nil + return nil, errors.New("DNS client not initialized").AtError() } ips, _, err := dnsClient.LookupIP(domain, dns.IPOption{ @@ -103,44 +103,45 @@ func lookupIP(domain string, strategy DomainStrategy, localAddr net.Address) ([] } } + if err == nil && len(ips) == 0 { + return nil, dns.ErrEmptyResponse + } return ips, err } -func canLookupIP(ctx context.Context, dst net.Destination, sockopt *SocketConfig) bool { - if dst.Address.Family().IsIP() || dnsClient == nil { +func canLookupIP(dst net.Destination, sockopt *SocketConfig) bool { + if dst.Address.Family().IsIP() { return false } return sockopt.DomainStrategy.hasStrategy() } -func redirect(ctx context.Context, dst net.Destination, obt string) net.Conn { +func redirect(ctx context.Context, dst net.Destination, obt string, h outbound.Handler) net.Conn { errors.LogInfo(ctx, "redirecting request "+dst.String()+" to "+obt) - h := obm.GetHandler(obt) outbounds := session.OutboundsFromContext(ctx) ctx = session.ContextWithOutbounds(ctx, append(outbounds, &session.Outbound{ Target: dst, Gateway: nil, Tag: obt, })) // add another outbound in session ctx - if h != nil { - ur, uw := pipe.New(pipe.OptionsFromContext(ctx)...) - dr, dw := pipe.New(pipe.OptionsFromContext(ctx)...) - go h.Dispatch(context.WithoutCancel(ctx), &transport.Link{Reader: ur, Writer: dw}) - var readerOpt cnc.ConnectionOption - if dst.Network == net.Network_TCP { - readerOpt = cnc.ConnectionOutputMulti(dr) - } else { - readerOpt = cnc.ConnectionOutputMultiUDP(dr) - } - nc := cnc.NewConnection( - cnc.ConnectionInputMulti(uw), - readerOpt, - cnc.ConnectionOnClose(common.ChainedClosable{uw, dw}), - ) - return nc + ur, uw := pipe.New(pipe.OptionsFromContext(ctx)...) + dr, dw := pipe.New(pipe.OptionsFromContext(ctx)...) + + go h.Dispatch(context.WithoutCancel(ctx), &transport.Link{Reader: ur, Writer: dw}) + var readerOpt cnc.ConnectionOption + if dst.Network == net.Network_TCP { + readerOpt = cnc.ConnectionOutputMulti(dr) + } else { + readerOpt = cnc.ConnectionOutputMultiUDP(dr) } - return nil + nc := cnc.NewConnection( + cnc.ConnectionInputMulti(uw), + readerOpt, + cnc.ConnectionOnClose(common.ChainedClosable{uw, dw}), + ) + return nc + } func checkAddressPortStrategy(ctx context.Context, dest net.Destination, sockopt *SocketConfig) (*net.Destination, error) { @@ -247,21 +248,28 @@ func DialSystem(ctx context.Context, dest net.Destination, sockopt *SocketConfig dest = *newDest } - if canLookupIP(ctx, dest, sockopt) { + if canLookupIP(dest, sockopt) { ips, err := lookupIP(dest.Address.String(), sockopt.DomainStrategy, src) - if err == nil && len(ips) > 0 { + if err != nil { + errors.LogErrorInner(ctx, err, "failed to resolve ip") + if sockopt.DomainStrategy.forceIP() { + return nil, err + } + } else { dest.Address = net.IPAddress(ips[dice.Roll(len(ips))]) errors.LogInfo(ctx, "replace destination with "+dest.String()) - } else if err != nil { - errors.LogWarningInner(ctx, err, "failed to resolve ip") } } - if obm != nil && len(sockopt.DialerProxy) > 0 { - nc := redirect(ctx, dest, sockopt.DialerProxy) - if nc != nil { - return nc, nil + if len(sockopt.DialerProxy) > 0 { + if obm == nil { + return nil, errors.New("there is no outbound manager for dialerProxy").AtError() } + h := obm.GetHandler(sockopt.DialerProxy) + if h == nil { + return nil, errors.New("there is no outbound handler for dialerProxy").AtError() + } + return redirect(ctx, dest, sockopt.DialerProxy, h), nil } return effectiveSystemDialer.Dial(ctx, src, dest, sockopt) From aa4134f4a675db90bc58f34999551627fad9b00a Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Tue, 29 Apr 2025 12:09:57 +0330 Subject: [PATCH 806/867] DNS: Fix some bugs; Refactors; Optimizations (#4659) --- app/dns/cache_controller.go | 188 ++++++++++++++++++++++ app/dns/dns.go | 121 ++++++++------ app/dns/dns_test.go | 4 +- app/dns/dnscommon.go | 38 ++--- app/dns/dnscommon_test.go | 6 +- app/dns/nameserver.go | 99 ++++++------ app/dns/nameserver_doh.go | 247 ++++++---------------------- app/dns/nameserver_doh_test.go | 32 ++-- app/dns/nameserver_fakedns.go | 2 +- app/dns/nameserver_local.go | 25 +-- app/dns/nameserver_local_test.go | 7 +- app/dns/nameserver_quic.go | 259 ++++++++--------------------- app/dns/nameserver_quic_test.go | 27 ++-- app/dns/nameserver_tcp.go | 268 ++++++++----------------------- app/dns/nameserver_tcp_test.go | 32 ++-- app/dns/nameserver_udp.go | 243 +++++++--------------------- app/router/condition.go | 2 +- app/router/condition_geoip.go | 2 +- common/errors/multi_error.go | 5 +- features/dns/client.go | 2 + features/dns/localdns/client.go | 24 +-- proxy/dns/dns.go | 3 +- 22 files changed, 658 insertions(+), 978 deletions(-) create mode 100644 app/dns/cache_controller.go diff --git a/app/dns/cache_controller.go b/app/dns/cache_controller.go new file mode 100644 index 00000000..f23c414d --- /dev/null +++ b/app/dns/cache_controller.go @@ -0,0 +1,188 @@ +package dns + +import ( + "context" + go_errors "errors" + "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/common/signal/pubsub" + "github.com/xtls/xray-core/common/task" + dns_feature "github.com/xtls/xray-core/features/dns" + "golang.org/x/net/dns/dnsmessage" + "sync" + "time" +) + +type CacheController struct { + sync.RWMutex + ips map[string]*record + pub *pubsub.Service + cacheCleanup *task.Periodic + name string + disableCache bool +} + +func NewCacheController(name string, disableCache bool) *CacheController { + c := &CacheController{ + name: name, + disableCache: disableCache, + ips: make(map[string]*record), + pub: pubsub.NewService(), + } + + c.cacheCleanup = &task.Periodic{ + Interval: time.Minute, + Execute: c.CacheCleanup, + } + return c +} + +// CacheCleanup clears expired items from cache +func (c *CacheController) CacheCleanup() error { + now := time.Now() + c.Lock() + defer c.Unlock() + + if len(c.ips) == 0 { + return errors.New("nothing to do. stopping...") + } + + for domain, record := range c.ips { + if record.A != nil && record.A.Expire.Before(now) { + record.A = nil + } + if record.AAAA != nil && record.AAAA.Expire.Before(now) { + record.AAAA = nil + } + + if record.A == nil && record.AAAA == nil { + errors.LogDebug(context.Background(), c.name, "cache cleanup ", domain) + delete(c.ips, domain) + } else { + c.ips[domain] = record + } + } + + if len(c.ips) == 0 { + c.ips = make(map[string]*record) + } + + return nil +} + +func (c *CacheController) updateIP(req *dnsRequest, ipRec *IPRecord) { + elapsed := time.Since(req.start) + + c.Lock() + rec, found := c.ips[req.domain] + if !found { + rec = &record{} + } + + switch req.reqType { + case dnsmessage.TypeA: + rec.A = ipRec + case dnsmessage.TypeAAAA: + rec.AAAA = ipRec + } + + errors.LogInfo(context.Background(), c.name, " got answer: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed) + c.ips[req.domain] = rec + + switch req.reqType { + case dnsmessage.TypeA: + c.pub.Publish(req.domain+"4", nil) + if !c.disableCache { + _, _, err := rec.AAAA.getIPs() + if !go_errors.Is(err, errRecordNotFound) { + c.pub.Publish(req.domain+"6", nil) + } + } + case dnsmessage.TypeAAAA: + c.pub.Publish(req.domain+"6", nil) + if !c.disableCache { + _, _, err := rec.A.getIPs() + if !go_errors.Is(err, errRecordNotFound) { + c.pub.Publish(req.domain+"4", nil) + } + } + } + + c.Unlock() + common.Must(c.cacheCleanup.Start()) +} + +func (c *CacheController) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { + c.RLock() + record, found := c.ips[domain] + c.RUnlock() + + if !found { + return nil, 0, errRecordNotFound + } + + var errs []error + var allIPs []net.IP + var rTTL uint32 = dns_feature.DefaultTTL + + mergeReq := option.IPv4Enable && option.IPv6Enable + + if option.IPv4Enable { + ips, ttl, err := record.A.getIPs() + if !mergeReq || go_errors.Is(err, errRecordNotFound) { + return ips, ttl, err + } + if ttl < rTTL { + rTTL = ttl + } + if len(ips) > 0 { + allIPs = append(allIPs, ips...) + } else { + errs = append(errs, err) + } + } + + if option.IPv6Enable { + ips, ttl, err := record.AAAA.getIPs() + if !mergeReq || go_errors.Is(err, errRecordNotFound) { + return ips, ttl, err + } + if ttl < rTTL { + rTTL = ttl + } + if len(ips) > 0 { + allIPs = append(allIPs, ips...) + } else { + errs = append(errs, err) + } + } + + if len(allIPs) > 0 { + return allIPs, rTTL, nil + } + if go_errors.Is(errs[0], errs[1]) { + return nil, rTTL, errs[0] + } + return nil, rTTL, errors.Combine(errs...) +} + +func (c *CacheController) registerSubscribers(domain string, option dns_feature.IPOption) (sub4 *pubsub.Subscriber, sub6 *pubsub.Subscriber) { + // ipv4 and ipv6 belong to different subscription groups + if option.IPv4Enable { + sub4 = c.pub.Subscribe(domain + "4") + } + if option.IPv6Enable { + sub6 = c.pub.Subscribe(domain + "6") + } + return +} + +func closeSubscribers(sub4 *pubsub.Subscriber, sub6 *pubsub.Subscriber) { + if sub4 != nil { + sub4.Close() + } + if sub6 != nil { + sub6.Close() + } +} diff --git a/app/dns/dns.go b/app/dns/dns.go index 9b84106c..3b9cfbcb 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -3,12 +3,12 @@ package dns import ( "context" + go_errors "errors" "fmt" "sort" "strings" "sync" - "github.com/xtls/xray-core/app/router" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" @@ -20,8 +20,6 @@ import ( // DNS is a DNS rely server. type DNS struct { sync.Mutex - tag string - disableCache bool disableFallback bool disableFallbackIfMatch bool ipOption *dns.IPOption @@ -40,13 +38,6 @@ type DomainMatcherInfo struct { // New creates a new DNS server with given configuration. func New(ctx context.Context, config *Config) (*DNS, error) { - var tag string - if len(config.Tag) > 0 { - tag = config.Tag - } else { - tag = generateRandomTag() - } - var clientIP net.IP switch len(config.ClientIp) { case 0, net.IPv4len, net.IPv6len: @@ -55,26 +46,28 @@ func New(ctx context.Context, config *Config) (*DNS, error) { return nil, errors.New("unexpected client IP length ", len(config.ClientIp)) } - var ipOption *dns.IPOption + var ipOption dns.IPOption switch config.QueryStrategy { case QueryStrategy_USE_IP: - ipOption = &dns.IPOption{ + ipOption = dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, } case QueryStrategy_USE_IP4: - ipOption = &dns.IPOption{ + ipOption = dns.IPOption{ IPv4Enable: true, IPv6Enable: false, FakeEnable: false, } case QueryStrategy_USE_IP6: - ipOption = &dns.IPOption{ + ipOption = dns.IPOption{ IPv4Enable: false, IPv6Enable: true, FakeEnable: false, } + default: + return nil, errors.New("unexpected query strategy ", config.QueryStrategy) } hosts, err := NewStaticHosts(config.StaticHosts) @@ -82,8 +75,14 @@ func New(ctx context.Context, config *Config) (*DNS, error) { return nil, errors.New("failed to create hosts").Base(err) } - clients := []*Client{} + var clients []*Client domainRuleCount := 0 + + var defaultTag = config.Tag + if len(config.Tag) == 0 { + defaultTag = generateRandomTag() + } + for _, ns := range config.NameServer { domainRuleCount += len(ns.PrioritizedDomain) } @@ -91,7 +90,6 @@ func New(ctx context.Context, config *Config) (*DNS, error) { // MatcherInfos is ensured to cover the maximum index domainMatcher could return, where matcher's index starts from 1 matcherInfos := make([]*DomainMatcherInfo, domainRuleCount+1) domainMatcher := &strmatcher.MatcherGroup{} - geoipContainer := router.GeoIPMatcherContainer{} for _, ns := range config.NameServer { clientIdx := len(clients) @@ -109,7 +107,18 @@ func New(ctx context.Context, config *Config) (*DNS, error) { case net.IPv4len, net.IPv6len: myClientIP = net.IP(ns.ClientIp) } - client, err := NewClient(ctx, ns, myClientIP, geoipContainer, &matcherInfos, updateDomain) + + disableCache := config.DisableCache + + var tag = defaultTag + if len(ns.Tag) > 0 { + tag = ns.Tag + } + clientIPOption := ResolveIpOptionOverride(ns.QueryStrategy, ipOption) + if !clientIPOption.IPv4Enable && !clientIPOption.IPv6Enable { + return nil, errors.New("no QueryStrategy available for ", ns.Address) + } + client, err := NewClient(ctx, ns, myClientIP, disableCache, tag, clientIPOption, &matcherInfos, updateDomain) if err != nil { return nil, errors.New("failed to create client").Base(err) } @@ -118,18 +127,16 @@ func New(ctx context.Context, config *Config) (*DNS, error) { // If there is no DNS client in config, add a `localhost` DNS client if len(clients) == 0 { - clients = append(clients, NewLocalDNSClient()) + clients = append(clients, NewLocalDNSClient(ipOption)) } return &DNS{ - tag: tag, hosts: hosts, - ipOption: ipOption, + ipOption: &ipOption, clients: clients, ctx: ctx, domainMatcher: domainMatcher, matcherInfos: matcherInfos, - disableCache: config.DisableCache, disableFallback: config.DisableFallback, disableFallbackIfMatch: config.DisableFallbackIfMatch, }, nil @@ -153,11 +160,21 @@ func (s *DNS) Close() error { // IsOwnLink implements proxy.dns.ownLinkVerifier func (s *DNS) IsOwnLink(ctx context.Context) bool { inbound := session.InboundFromContext(ctx) - return inbound != nil && inbound.Tag == s.tag + if inbound == nil { + return false + } + for _, client := range s.clients { + if client.tag == inbound.Tag { + return true + } + } + return false } // LookupIP implements dns.Client. func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, uint32, error) { + // Normalize the FQDN form query + domain = strings.TrimSuffix(domain, ".") if domain == "" { return nil, 0, errors.New("empty domain name") } @@ -169,9 +186,6 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, uint32, er return nil, 0, dns.ErrEmptyResponse } - // Normalize the FQDN form query - domain = strings.TrimSuffix(domain, ".") - // Static host lookup switch addrs := s.hosts.Lookup(domain, option); { case addrs == nil: // Domain not recorded in static host @@ -184,32 +198,49 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, uint32, er default: // Successfully found ip records in static host errors.LogInfo(s.ctx, "returning ", len(addrs), " IP(s) for domain ", domain, " -> ", addrs) ips, err := toNetIP(addrs) - return ips, 10, err // Hosts ttl is 10 + if err != nil { + return nil, 0, err + } + return ips, 10, nil // Hosts ttl is 10 } // Name servers lookup - errs := []error{} - ctx := session.ContextWithInbound(s.ctx, &session.Inbound{Tag: s.tag}) + var errs []error for _, client := range s.sortClients(domain) { if !option.FakeEnable && strings.EqualFold(client.Name(), "FakeDNS") { errors.LogDebug(s.ctx, "skip DNS resolution for domain ", domain, " at server ", client.Name()) continue } - ips, ttl, err := client.QueryIP(ctx, domain, option, s.disableCache) + + ips, ttl, err := client.QueryIP(s.ctx, domain, option) + if len(ips) > 0 { + if ttl == 0 { + ttl = 1 + } return ips, ttl, nil } - if err != nil { - errors.LogInfoInner(s.ctx, err, "failed to lookup ip for domain ", domain, " at server ", client.Name()) - errs = append(errs, err) - } - // 5 for RcodeRefused in miekg/dns, hardcode to reduce binary size - if err != context.Canceled && err != context.DeadlineExceeded && err != errExpectedIPNonMatch && err != dns.ErrEmptyResponse && dns.RCodeFromError(err) != 5 { - return nil, 0, err + + errors.LogInfoInner(s.ctx, err, "failed to lookup ip for domain ", domain, " at server ", client.Name()) + if err == nil { + err = dns.ErrEmptyResponse } + errs = append(errs, err) + } - return nil, 0, errors.New("returning nil for domain ", domain).Base(errors.Combine(errs...)) + if len(errs) > 0 { + allErrs := errors.Combine(errs...) + err0 := errs[0] + if errors.AllEqual(err0, allErrs) { + if go_errors.Is(err0, dns.ErrEmptyResponse) { + return nil, 0, dns.ErrEmptyResponse + } + return nil, 0, errors.New("returning nil for domain ", domain).Base(err0) + } + return nil, 0, errors.New("returning nil for domain ", domain).Base(allErrs) + } + return nil, 0, dns.ErrEmptyResponse } // LookupHosts implements dns.HostsLookup. @@ -228,22 +259,6 @@ func (s *DNS) LookupHosts(domain string) *net.Address { return nil } -// GetIPOption implements ClientWithIPOption. -func (s *DNS) GetIPOption() *dns.IPOption { - return s.ipOption -} - -// SetQueryOption implements ClientWithIPOption. -func (s *DNS) SetQueryOption(isIPv4Enable, isIPv6Enable bool) { - s.ipOption.IPv4Enable = isIPv4Enable - s.ipOption.IPv6Enable = isIPv6Enable -} - -// SetFakeDNSOption implements ClientWithIPOption. -func (s *DNS) SetFakeDNSOption(isFakeEnable bool) { - s.ipOption.FakeEnable = isFakeEnable -} - func (s *DNS) sortClients(domain string) []*Client { clients := make([]*Client, 0, len(s.clients)) clientUsed := make([]bool, len(s.clients)) diff --git a/app/dns/dns_test.go b/app/dns/dns_test.go index 4bdc9ae3..7ea6fcf8 100644 --- a/app/dns/dns_test.go +++ b/app/dns/dns_test.go @@ -76,6 +76,9 @@ func (*staticHandler) ServeDNS(w dns.ResponseWriter, r *dns.Msg) { case q.Name == "notexist.google.com." && q.Qtype == dns.TypeAAAA: ans.MsgHdr.Rcode = dns.RcodeNameError + case q.Name == "notexist.google.com." && q.Qtype == dns.TypeA: + ans.MsgHdr.Rcode = dns.RcodeNameError + case q.Name == "hostname." && q.Qtype == dns.TypeA: rr, _ := dns.NewRR("hostname. IN A 127.0.0.1") ans.Answer = append(ans.Answer, rr) @@ -117,7 +120,6 @@ func TestUDPServerSubnet(t *testing.T) { Handler: &staticHandler{}, UDPSize: 1200, } - go dnsServer.ListenAndServe() time.Sleep(time.Second) diff --git a/app/dns/dnscommon.go b/app/dns/dnscommon.go index 0dc07f72..0bd712ff 100644 --- a/app/dns/dnscommon.go +++ b/app/dns/dnscommon.go @@ -32,31 +32,30 @@ type record struct { // IPRecord is a cacheable item for a resolved domain type IPRecord struct { ReqID uint16 - IP []net.Address + IP []net.IP Expire time.Time RCode dnsmessage.RCode RawHeader *dnsmessage.Header } -func (r *IPRecord) getIPs() ([]net.Address, uint32, error) { - if r == nil || r.Expire.Before(time.Now()) { +func (r *IPRecord) getIPs() ([]net.IP, uint32, error) { + if r == nil { return nil, 0, errRecordNotFound } - if r.RCode != dnsmessage.RCodeSuccess { - return nil, 0, dns_feature.RCodeError(r.RCode) + untilExpire := time.Until(r.Expire) + if untilExpire <= 0 { + return nil, 0, errRecordNotFound } - ttl := uint32(time.Until(r.Expire) / time.Second) - return r.IP, ttl, nil -} -func isNewer(baseRec *IPRecord, newRec *IPRecord) bool { - if newRec == nil { - return false + ttl := uint32(untilExpire/time.Second) + uint32(1) + if r.RCode != dnsmessage.RCodeSuccess { + return nil, ttl, dns_feature.RCodeError(r.RCode) } - if baseRec == nil { - return true + if len(r.IP) == 0 { + return nil, ttl, dns_feature.ErrEmptyResponse } - return baseRec.Expire.Before(newRec.Expire) + + return r.IP, ttl, nil } var errRecordNotFound = errors.New("record not found") @@ -193,7 +192,7 @@ func parseResponse(payload []byte) (*IPRecord, error) { ipRecord := &IPRecord{ ReqID: h.ID, RCode: h.RCode, - Expire: now.Add(time.Second * 600), + Expire: now.Add(time.Second * dns_feature.DefaultTTL), RawHeader: &h, } @@ -209,7 +208,7 @@ L: ttl := ah.TTL if ttl == 0 { - ttl = 600 + ttl = 1 } expire := now.Add(time.Duration(ttl) * time.Second) if ipRecord.Expire.After(expire) { @@ -223,14 +222,17 @@ L: errors.LogInfoInner(context.Background(), err, "failed to parse A record for domain: ", ah.Name) break L } - ipRecord.IP = append(ipRecord.IP, net.IPAddress(ans.A[:])) + ipRecord.IP = append(ipRecord.IP, net.IPAddress(ans.A[:]).IP()) case dnsmessage.TypeAAAA: ans, err := parser.AAAAResource() if err != nil { errors.LogInfoInner(context.Background(), err, "failed to parse AAAA record for domain: ", ah.Name) break L } - ipRecord.IP = append(ipRecord.IP, net.IPAddress(ans.AAAA[:])) + newIP := net.IPAddress(ans.AAAA[:]).IP() + if len(newIP) == net.IPv6len { + ipRecord.IP = append(ipRecord.IP, newIP) + } default: if err := parser.SkipAnswer(); err != nil { errors.LogInfoInner(context.Background(), err, "failed to skip answer") diff --git a/app/dns/dnscommon_test.go b/app/dns/dnscommon_test.go index 2affb2a3..bbaa9a21 100644 --- a/app/dns/dnscommon_test.go +++ b/app/dns/dnscommon_test.go @@ -51,7 +51,7 @@ func Test_parseResponse(t *testing.T) { }{ { "empty", - &IPRecord{0, []net.Address(nil), time.Time{}, dnsmessage.RCodeSuccess, nil}, + &IPRecord{0, []net.IP(nil), time.Time{}, dnsmessage.RCodeSuccess, nil}, false, }, { @@ -63,7 +63,7 @@ func Test_parseResponse(t *testing.T) { "a record", &IPRecord{ 1, - []net.Address{net.ParseAddress("8.8.8.8"), net.ParseAddress("8.8.4.4")}, + []net.IP{net.ParseIP("8.8.8.8"), net.ParseIP("8.8.4.4")}, time.Time{}, dnsmessage.RCodeSuccess, nil, @@ -72,7 +72,7 @@ func Test_parseResponse(t *testing.T) { }, { "aaaa record", - &IPRecord{2, []net.Address{net.ParseAddress("2001::123:8888"), net.ParseAddress("2001::123:8844")}, time.Time{}, dnsmessage.RCodeSuccess, nil}, + &IPRecord{2, []net.IP{net.ParseIP("2001::123:8888"), net.ParseIP("2001::123:8844")}, time.Time{}, dnsmessage.RCodeSuccess, nil}, false, }, } diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index f1d02616..31681c4a 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -21,25 +21,23 @@ type Server interface { // Name of the Client. Name() string // QueryIP sends IP queries to its configured server. - QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns.IPOption, disableCache bool) ([]net.IP, uint32, error) + QueryIP(ctx context.Context, domain string, option dns.IPOption) ([]net.IP, uint32, error) } // Client is the interface for DNS client. type Client struct { server Server - clientIP net.IP skipFallback bool domains []string expectedIPs []*router.GeoIPMatcher allowUnexpectedIPs bool tag string timeoutMs time.Duration + ipOption *dns.IPOption } -var errExpectedIPNonMatch = errors.New("expectedIPs not match") - // NewServer creates a name server object according to the network destination url. -func NewServer(ctx context.Context, dest net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) (Server, error) { +func NewServer(ctx context.Context, dest net.Destination, dispatcher routing.Dispatcher, disableCache bool, clientIP net.IP) (Server, error) { if address := dest.Address; address.Family().IsDomain() { u, err := url.Parse(address.Domain()) if err != nil { @@ -47,26 +45,29 @@ func NewServer(ctx context.Context, dest net.Destination, dispatcher routing.Dis } switch { case strings.EqualFold(u.String(), "localhost"): - return NewLocalNameServer(queryStrategy), nil + return NewLocalNameServer(), nil case strings.EqualFold(u.Scheme, "https"): // DNS-over-HTTPS Remote mode - return NewDoHNameServer(u, queryStrategy, dispatcher, false), nil + return NewDoHNameServer(u, dispatcher, false, disableCache, clientIP), nil case strings.EqualFold(u.Scheme, "h2c"): // DNS-over-HTTPS h2c Remote mode - return NewDoHNameServer(u, queryStrategy, dispatcher, true), nil + return NewDoHNameServer(u, dispatcher, true, disableCache, clientIP), nil case strings.EqualFold(u.Scheme, "https+local"): // DNS-over-HTTPS Local mode - return NewDoHNameServer(u, queryStrategy, nil, false), nil + return NewDoHNameServer(u, nil, false, disableCache, clientIP), nil case strings.EqualFold(u.Scheme, "h2c+local"): // DNS-over-HTTPS h2c Local mode - return NewDoHNameServer(u, queryStrategy, nil, true), nil + return NewDoHNameServer(u, nil, true, disableCache, clientIP), nil case strings.EqualFold(u.Scheme, "quic+local"): // DNS-over-QUIC Local mode - return NewQUICNameServer(u, queryStrategy) + return NewQUICNameServer(u, disableCache, clientIP) case strings.EqualFold(u.Scheme, "tcp"): // DNS-over-TCP Remote mode - return NewTCPNameServer(u, dispatcher, queryStrategy) + return NewTCPNameServer(u, dispatcher, disableCache, clientIP) case strings.EqualFold(u.Scheme, "tcp+local"): // DNS-over-TCP Local mode - return NewTCPLocalNameServer(u, queryStrategy) + return NewTCPLocalNameServer(u, disableCache, clientIP) case strings.EqualFold(u.String(), "fakedns"): var fd dns.FakeDNSEngine - core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { + err = core.RequireFeatures(ctx, func(fdns dns.FakeDNSEngine) { fd = fdns }) + if err != nil { + return nil, err + } return NewFakeDNSServer(fd), nil } } @@ -74,7 +75,7 @@ func NewServer(ctx context.Context, dest net.Destination, dispatcher routing.Dis dest.Network = net.Network_UDP } if dest.Network == net.Network_UDP { // UDP classic DNS mode - return NewClassicNameServer(dest, dispatcher, queryStrategy), nil + return NewClassicNameServer(dest, dispatcher, disableCache, clientIP), nil } return nil, errors.New("No available name server could be created from ", dest).AtWarning() } @@ -84,7 +85,9 @@ func NewClient( ctx context.Context, ns *NameServer, clientIP net.IP, - container router.GeoIPMatcherContainer, + disableCache bool, + tag string, + ipOption dns.IPOption, matcherInfos *[]*DomainMatcherInfo, updateDomainRule func(strmatcher.Matcher, int, []*DomainMatcherInfo) error, ) (*Client, error) { @@ -92,7 +95,7 @@ func NewClient( err := core.RequireFeatures(ctx, func(dispatcher routing.Dispatcher) error { // Create a new server for each client for now - server, err := NewServer(ctx, ns.Address.AsDestination(), dispatcher, ns.GetQueryStrategy()) + server, err := NewServer(ctx, ns.Address.AsDestination(), dispatcher, disableCache, clientIP) if err != nil { return errors.New("failed to create nameserver").Base(err).AtWarning() } @@ -149,7 +152,7 @@ func NewClient( // Establish expected IPs var matchers []*router.GeoIPMatcher for _, geoip := range ns.Geoip { - matcher, err := container.Add(geoip) + matcher, err := router.GlobalGeoIPContainer.Add(geoip) if err != nil { return errors.New("failed to create ip matcher").Base(err).AtWarning() } @@ -169,15 +172,15 @@ func NewClient( if ns.TimeoutMs > 0 { timeoutMs = time.Duration(ns.TimeoutMs) * time.Millisecond } - + client.server = server - client.clientIP = clientIP client.skipFallback = ns.SkipFallback client.domains = rules client.expectedIPs = matchers client.allowUnexpectedIPs = ns.AllowUnexpectedIPs - client.tag = ns.Tag + client.tag = tag client.timeoutMs = timeoutMs + client.ipOption = &ipOption return nil }) return client, err @@ -189,31 +192,43 @@ func (c *Client) Name() string { } // QueryIP sends DNS query to the name server with the client's IP. -func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption, disableCache bool) ([]net.IP, uint32, error) { - ctx, cancel := context.WithTimeout(ctx, c.timeoutMs) - if len(c.tag) != 0 { - content := session.InboundFromContext(ctx) - errors.LogDebug(ctx, "DNS: client override tag from ", content.Tag, " to ", c.tag) - // create a new context to override the tag - // do not direct set *content.Tag, it might be used by other clients - ctx = session.ContextWithInbound(ctx, &session.Inbound{Tag: c.tag}) +func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption) ([]net.IP, uint32, error) { + option.IPv4Enable = option.IPv4Enable && c.ipOption.IPv4Enable + option.IPv6Enable = option.IPv6Enable && c.ipOption.IPv6Enable + if !option.IPv4Enable && !option.IPv6Enable { + return nil, 0, dns.ErrEmptyResponse } - ips, ttl, err := c.server.QueryIP(ctx, domain, c.clientIP, option, disableCache) + + ctx, cancel := context.WithTimeout(ctx, c.timeoutMs) + ctx = session.ContextWithInbound(ctx, &session.Inbound{Tag: c.tag}) + ips, ttl, err := c.server.QueryIP(ctx, domain, option) cancel() if err != nil { - return ips, ttl, err + return nil, 0, err } - netips, err := c.MatchExpectedIPs(domain, ips) - return netips, ttl, err + + if len(ips) == 0 { + return nil, 0, dns.ErrEmptyResponse + } + + if len(c.expectedIPs) > 0 { + newIps := c.MatchExpectedIPs(domain, ips) + if len(newIps) == 0 { + if !c.allowUnexpectedIPs { + return nil, 0, dns.ErrEmptyResponse + } + } else { + ips = newIps + } + } + + return ips, ttl, nil } // MatchExpectedIPs matches queried domain IPs with expected IPs and returns matched ones. -func (c *Client) MatchExpectedIPs(domain string, ips []net.IP) ([]net.IP, error) { - if len(c.expectedIPs) == 0 { - return ips, nil - } - newIps := []net.IP{} +func (c *Client) MatchExpectedIPs(domain string, ips []net.IP) []net.IP { + var newIps []net.IP for _, ip := range ips { for _, matcher := range c.expectedIPs { if matcher.Match(ip) { @@ -222,14 +237,8 @@ func (c *Client) MatchExpectedIPs(domain string, ips []net.IP) ([]net.IP, error) } } } - if len(newIps) == 0 { - if c.allowUnexpectedIPs { - return ips, nil - } - return nil, errExpectedIPNonMatch - } errors.LogDebug(context.Background(), "domain ", domain, " expectedIPs ", newIps, " matched at server ", c.Name()) - return newIps, nil + return newIps } func ResolveIpOptionOverride(queryStrategy QueryStrategy, ipOption dns.IPOption) dns.IPOption { diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index 6cdb8ee7..cba59423 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -4,12 +4,12 @@ import ( "bytes" "context" "crypto/tls" + go_errors "errors" "fmt" "io" "net/http" "net/url" "strings" - "sync" "time" utls "github.com/refraction-networking/utls" @@ -21,12 +21,9 @@ import ( "github.com/xtls/xray-core/common/net/cnc" "github.com/xtls/xray-core/common/protocol/dns" "github.com/xtls/xray-core/common/session" - "github.com/xtls/xray-core/common/signal/pubsub" - "github.com/xtls/xray-core/common/task" 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" "golang.org/x/net/http2" ) @@ -34,18 +31,14 @@ import ( // which is compatible with traditional dns over udp(RFC1035), // thus most of the DOH implementation is copied from udpns.go type DoHNameServer struct { - sync.RWMutex - ips map[string]*record - pub *pubsub.Service - cleanup *task.Periodic - httpClient *http.Client - dohURL string - name string - queryStrategy QueryStrategy + cacheController *CacheController + httpClient *http.Client + dohURL string + clientIP net.IP } // NewDoHNameServer creates DOH/DOHL client object for remote/local resolving. -func NewDoHNameServer(url *url.URL, queryStrategy QueryStrategy, dispatcher routing.Dispatcher, h2c bool) *DoHNameServer { +func NewDoHNameServer(url *url.URL, dispatcher routing.Dispatcher, h2c bool, disableCache bool, clientIP net.IP) *DoHNameServer { url.Scheme = "https" mode := "DOH" if dispatcher == nil { @@ -53,15 +46,9 @@ func NewDoHNameServer(url *url.URL, queryStrategy QueryStrategy, dispatcher rout } errors.LogInfo(context.Background(), "DNS: created ", mode, " client for ", url.String(), ", with h2c ", h2c) s := &DoHNameServer{ - ips: make(map[string]*record), - pub: pubsub.NewService(), - name: mode + "//" + url.Host, - dohURL: url.String(), - queryStrategy: queryStrategy, - } - s.cleanup = &task.Periodic{ - Interval: time.Minute, - Execute: s.Cleanup, + cacheController: NewCacheController(mode+"//"+url.Host, disableCache), + dohURL: url.String(), + clientIP: clientIP, } s.httpClient = &http.Client{ Transport: &http2.Transport{ @@ -127,101 +114,25 @@ func NewDoHNameServer(url *url.URL, queryStrategy QueryStrategy, dispatcher rout // Name implements Server. func (s *DoHNameServer) Name() string { - return s.name -} - -// Cleanup clears expired items from cache -func (s *DoHNameServer) Cleanup() error { - now := time.Now() - s.Lock() - defer s.Unlock() - - if len(s.ips) == 0 { - return errors.New("nothing to do. stopping...") - } - - for domain, record := range s.ips { - if record.A != nil && record.A.Expire.Before(now) { - record.A = nil - } - if record.AAAA != nil && record.AAAA.Expire.Before(now) { - record.AAAA = nil - } - - if record.A == nil && record.AAAA == nil { - errors.LogDebug(context.Background(), s.name, " cleanup ", domain) - delete(s.ips, domain) - } else { - s.ips[domain] = record - } - } - - if len(s.ips) == 0 { - s.ips = make(map[string]*record) - } - - return nil -} - -func (s *DoHNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) { - elapsed := time.Since(req.start) - - s.Lock() - rec, found := s.ips[req.domain] - if !found { - rec = &record{} - } - updated := false - - switch req.reqType { - case dnsmessage.TypeA: - if isNewer(rec.A, ipRec) { - rec.A = ipRec - updated = true - } - case dnsmessage.TypeAAAA: - addr := make([]net.Address, 0, len(ipRec.IP)) - for _, ip := range ipRec.IP { - if len(ip.IP()) == net.IPv6len { - addr = append(addr, ip) - } - } - ipRec.IP = addr - if isNewer(rec.AAAA, ipRec) { - rec.AAAA = ipRec - updated = true - } - } - errors.LogInfo(context.Background(), s.name, " got answer: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed) - - if updated { - s.ips[req.domain] = rec - } - switch req.reqType { - case dnsmessage.TypeA: - s.pub.Publish(req.domain+"4", nil) - case dnsmessage.TypeAAAA: - s.pub.Publish(req.domain+"6", nil) - } - s.Unlock() - common.Must(s.cleanup.Start()) + return s.cacheController.name } func (s *DoHNameServer) newReqID() uint16 { return 0 } -func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption) { - errors.LogInfo(ctx, s.name, " querying: ", domain) +func (s *DoHNameServer) sendQuery(ctx context.Context, noResponseErrCh chan<- error, domain string, option dns_feature.IPOption) { + errors.LogInfo(ctx, s.Name(), " querying: ", domain) - if s.name+"." == "DOH//"+domain { - errors.LogError(ctx, s.name, " tries to resolve itself! Use IP or set \"hosts\" instead.") + if s.Name()+"." == "DOH//"+domain { + errors.LogError(ctx, s.Name(), " tries to resolve itself! Use IP or set \"hosts\" instead.") + noResponseErrCh <- errors.New("tries to resolve itself!", s.Name()) return } // As we don't want our traffic pattern looks like DoH, we use Random-Length Padding instead of Block-Length Padding recommended in RFC 8467 // Although DoH server like 1.1.1.1 will pad the response to Block-Length 468, at least it is better than no padding for response at all - reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP, int(crypto.RandBetween(100, 300)))) + reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(s.clientIP, int(crypto.RandBetween(100, 300)))) var deadline time.Time if d, ok := ctx.Deadline(); ok { @@ -256,19 +167,22 @@ func (s *DoHNameServer) sendQuery(ctx context.Context, domain string, clientIP n b, err := dns.PackMessage(r.msg) if err != nil { errors.LogErrorInner(ctx, err, "failed to pack dns query for ", domain) + noResponseErrCh <- err return } resp, err := s.dohHTTPSContext(dnsCtx, b.Bytes()) if err != nil { errors.LogErrorInner(ctx, err, "failed to retrieve response for ", domain) + noResponseErrCh <- err return } rec, err := parseResponse(resp) if err != nil { errors.LogErrorInner(ctx, err, "failed to handle DOH response for ", domain) + noResponseErrCh <- err return } - s.updateIP(r, rec) + s.cacheController.updateIP(r, rec) }(req) } } @@ -301,109 +215,50 @@ func (s *DoHNameServer) dohHTTPSContext(ctx context.Context, b []byte) ([]byte, return io.ReadAll(resp.Body) } -func (s *DoHNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { - s.RLock() - record, found := s.ips[domain] - s.RUnlock() - - if !found { - return nil, 0, errRecordNotFound - } - - var err4 error - var err6 error - var ips []net.Address - var ip6 []net.Address - var ttl uint32 - - if option.IPv4Enable { - ips, ttl, err4 = record.A.getIPs() - } - - if option.IPv6Enable { - ip6, ttl, err6 = record.AAAA.getIPs() - ips = append(ips, ip6...) - } - - if len(ips) > 0 { - netips, err := toNetIP(ips) - return netips, ttl, err - } - - if err4 != nil { - return nil, 0, err4 - } - - if err6 != nil { - return nil, 0, err6 - } - - if (option.IPv4Enable && record.A != nil) || (option.IPv6Enable && record.AAAA != nil) { - return nil, 0, dns_feature.ErrEmptyResponse - } - - return nil, 0, errRecordNotFound -} - // QueryIP implements Server. -func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, uint32, error) { // nolint: dupl +func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { // nolint: dupl fqdn := Fqdn(domain) - option = ResolveIpOptionOverride(s.queryStrategy, option) - if !option.IPv4Enable && !option.IPv6Enable { - return nil, 0, dns_feature.ErrEmptyResponse - } + sub4, sub6 := s.cacheController.registerSubscribers(fqdn, option) + defer closeSubscribers(sub4, sub6) - if disableCache { - errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) + if s.cacheController.disableCache { + errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.Name()) } else { - ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err == nil || err == dns_feature.ErrEmptyResponse || dns_feature.RCodeFromError(err) == 3 { - errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) - log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) + ips, ttl, err := s.cacheController.findIPsForDomain(fqdn, option) + if !go_errors.Is(err, errRecordNotFound) { + errors.LogDebugInner(ctx, err, s.Name(), " cache HIT ", domain, " -> ", ips) + log.Record(&log.DNSLog{Server: s.Name(), Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, ttl, err } } - // ipv4 and ipv6 belong to different subscription groups - var sub4, sub6 *pubsub.Subscriber - if option.IPv4Enable { - sub4 = s.pub.Subscribe(fqdn + "4") - defer sub4.Close() - } - if option.IPv6Enable { - sub6 = s.pub.Subscribe(fqdn + "6") - defer sub6.Close() - } - done := make(chan interface{}) - go func() { - if sub4 != nil { - select { - case <-sub4.Wait(): - case <-ctx.Done(): - } - } - if sub6 != nil { - select { - case <-sub6.Wait(): - case <-ctx.Done(): - } - } - close(done) - }() - s.sendQuery(ctx, fqdn, clientIP, option) + noResponseErrCh := make(chan error, 2) + s.sendQuery(ctx, noResponseErrCh, fqdn, option) start := time.Now() - for { - ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err != errRecordNotFound { - log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) - return ips, ttl, err - } - + if sub4 != nil { select { case <-ctx.Done(): return nil, 0, ctx.Err() - case <-done: + case err := <-noResponseErrCh: + return nil, 0, err + case <-sub4.Wait(): + sub4.Close() } } + if sub6 != nil { + select { + case <-ctx.Done(): + return nil, 0, ctx.Err() + case err := <-noResponseErrCh: + return nil, 0, err + case <-sub6.Wait(): + sub6.Close() + } + } + + ips, ttl, err := s.cacheController.findIPsForDomain(fqdn, option) + log.Record(&log.DNSLog{Server: s.Name(), Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) + return ips, ttl, err + } diff --git a/app/dns/nameserver_doh_test.go b/app/dns/nameserver_doh_test.go index a27a5e9f..96412c22 100644 --- a/app/dns/nameserver_doh_test.go +++ b/app/dns/nameserver_doh_test.go @@ -17,12 +17,12 @@ func TestDOHNameServer(t *testing.T) { url, err := url.Parse("https+local://1.1.1.1/dns-query") common.Must(err) - s := NewDoHNameServer(url, QueryStrategy_USE_IP, nil, false) + s := NewDoHNameServer(url, nil, false, false, net.IP(nil)) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, - }, false) + }) cancel() common.Must(err) if len(ips) == 0 { @@ -34,12 +34,12 @@ func TestDOHNameServerWithCache(t *testing.T) { url, err := url.Parse("https+local://1.1.1.1/dns-query") common.Must(err) - s := NewDoHNameServer(url, QueryStrategy_USE_IP, nil, false) + s := NewDoHNameServer(url, nil, false, false, net.IP(nil)) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, - }, false) + }) cancel() common.Must(err) if len(ips) == 0 { @@ -47,10 +47,10 @@ func TestDOHNameServerWithCache(t *testing.T) { } ctx2, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips2, _, err := s.QueryIP(ctx2, "google.com", net.IP(nil), dns_feature.IPOption{ + ips2, _, err := s.QueryIP(ctx2, "google.com", dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, - }, true) + }) cancel() common.Must(err) if r := cmp.Diff(ips2, ips); r != "" { @@ -62,12 +62,12 @@ func TestDOHNameServerWithIPv4Override(t *testing.T) { url, err := url.Parse("https+local://1.1.1.1/dns-query") common.Must(err) - s := NewDoHNameServer(url, QueryStrategy_USE_IP4, nil, false) + s := NewDoHNameServer(url, nil, false, false, net.IP(nil)) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", dns_feature.IPOption{ IPv4Enable: true, - IPv6Enable: true, - }, false) + IPv6Enable: false, + }) cancel() common.Must(err) if len(ips) == 0 { @@ -85,12 +85,12 @@ func TestDOHNameServerWithIPv6Override(t *testing.T) { url, err := url.Parse("https+local://1.1.1.1/dns-query") common.Must(err) - s := NewDoHNameServer(url, QueryStrategy_USE_IP6, nil, false) + s := NewDoHNameServer(url, nil, false, false, net.IP(nil)) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ - IPv4Enable: true, + ips, _, err := s.QueryIP(ctx, "google.com", dns_feature.IPOption{ + IPv4Enable: false, IPv6Enable: true, - }, false) + }) cancel() common.Must(err) if len(ips) == 0 { diff --git a/app/dns/nameserver_fakedns.go b/app/dns/nameserver_fakedns.go index 37c2f723..8c598ac8 100644 --- a/app/dns/nameserver_fakedns.go +++ b/app/dns/nameserver_fakedns.go @@ -20,7 +20,7 @@ func (FakeDNSServer) Name() string { return "FakeDNS" } -func (f *FakeDNSServer) QueryIP(ctx context.Context, domain string, _ net.IP, opt dns.IPOption, _ bool) ([]net.IP, uint32, error) { +func (f *FakeDNSServer) QueryIP(ctx context.Context, domain string, opt dns.IPOption) ([]net.IP, uint32, error) { if f.fakeDNSEngine == nil { return nil, 0, errors.New("Unable to locate a fake DNS Engine").AtError() } diff --git a/app/dns/nameserver_local.go b/app/dns/nameserver_local.go index 1b45e5f0..91b003e3 100644 --- a/app/dns/nameserver_local.go +++ b/app/dns/nameserver_local.go @@ -2,7 +2,6 @@ package dns import ( "context" - "strings" "time" "github.com/xtls/xray-core/common/errors" @@ -14,26 +13,15 @@ import ( // LocalNameServer is an wrapper over local DNS feature. type LocalNameServer struct { - client *localdns.Client - queryStrategy QueryStrategy + client *localdns.Client } -const errEmptyResponse = "No address associated with hostname" - // QueryIP implements Server. -func (s *LocalNameServer) QueryIP(ctx context.Context, domain string, _ net.IP, option dns.IPOption, _ bool) (ips []net.IP, ttl uint32, err error) { - option = ResolveIpOptionOverride(s.queryStrategy, option) - if !option.IPv4Enable && !option.IPv6Enable { - return nil, 0, dns.ErrEmptyResponse - } +func (s *LocalNameServer) QueryIP(ctx context.Context, domain string, option dns.IPOption) (ips []net.IP, ttl uint32, err error) { start := time.Now() ips, ttl, err = s.client.LookupIP(domain, option) - if err != nil && strings.HasSuffix(err.Error(), errEmptyResponse) { - err = dns.ErrEmptyResponse - } - if len(ips) > 0 { errors.LogInfo(ctx, "Localhost got answer: ", domain, " -> ", ips) log.Record(&log.DNSLog{Server: s.Name(), Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) @@ -48,15 +36,14 @@ func (s *LocalNameServer) Name() string { } // NewLocalNameServer creates localdns server object for directly lookup in system DNS. -func NewLocalNameServer(queryStrategy QueryStrategy) *LocalNameServer { +func NewLocalNameServer() *LocalNameServer { errors.LogInfo(context.Background(), "DNS: created localhost client") return &LocalNameServer{ - queryStrategy: queryStrategy, - client: localdns.New(), + client: localdns.New(), } } // NewLocalDNSClient creates localdns client object for directly lookup in system DNS. -func NewLocalDNSClient() *Client { - return &Client{server: NewLocalNameServer(QueryStrategy_USE_IP)} +func NewLocalDNSClient(ipOption dns.IPOption) *Client { + return &Client{server: NewLocalNameServer(), ipOption: &ipOption} } diff --git a/app/dns/nameserver_local_test.go b/app/dns/nameserver_local_test.go index a32c69e6..71aa08c4 100644 --- a/app/dns/nameserver_local_test.go +++ b/app/dns/nameserver_local_test.go @@ -7,18 +7,17 @@ import ( . "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 TestLocalNameServer(t *testing.T) { - s := NewLocalNameServer(QueryStrategy_USE_IP) + s := NewLocalNameServer() ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP{}, dns.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", dns.IPOption{ IPv4Enable: true, IPv6Enable: true, FakeEnable: false, - }, false) + }) cancel() common.Must(err) if len(ips) == 0 { diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index 6ce5809b..5512edc4 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -4,23 +4,20 @@ import ( "bytes" "context" "encoding/binary" + go_errors "errors" "net/url" "sync" "time" "github.com/quic-go/quic-go" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/log" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol/dns" "github.com/xtls/xray-core/common/session" - "github.com/xtls/xray-core/common/signal/pubsub" - "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" ) @@ -33,17 +30,14 @@ const handshakeTimeout = time.Second * 8 // QUICNameServer implemented DNS over QUIC type QUICNameServer struct { sync.RWMutex - ips map[string]*record - pub *pubsub.Service - cleanup *task.Periodic - name string - destination *net.Destination - connection quic.Connection - queryStrategy QueryStrategy + cacheController *CacheController + destination *net.Destination + connection quic.Connection + clientIP net.IP } // NewQUICNameServer creates DNS-over-QUIC client object for local resolving -func NewQUICNameServer(url *url.URL, queryStrategy QueryStrategy) (*QUICNameServer, error) { +func NewQUICNameServer(url *url.URL, disableCache bool, clientIP net.IP) (*QUICNameServer, error) { errors.LogInfo(context.Background(), "DNS: created Local DNS-over-QUIC client for ", url.String()) var err error @@ -57,15 +51,9 @@ func NewQUICNameServer(url *url.URL, queryStrategy QueryStrategy) (*QUICNameServ dest := net.UDPDestination(net.ParseAddress(url.Hostname()), port) s := &QUICNameServer{ - ips: make(map[string]*record), - pub: pubsub.NewService(), - name: url.String(), - destination: &dest, - queryStrategy: queryStrategy, - } - s.cleanup = &task.Periodic{ - Interval: time.Minute, - Execute: s.Cleanup, + cacheController: NewCacheController(url.String(), disableCache), + destination: &dest, + clientIP: clientIP, } return s, nil @@ -73,94 +61,17 @@ func NewQUICNameServer(url *url.URL, queryStrategy QueryStrategy) (*QUICNameServ // Name returns client name func (s *QUICNameServer) Name() string { - return s.name -} - -// Cleanup clears expired items from cache -func (s *QUICNameServer) Cleanup() error { - now := time.Now() - s.Lock() - defer s.Unlock() - - if len(s.ips) == 0 { - return errors.New("nothing to do. stopping...") - } - - for domain, record := range s.ips { - if record.A != nil && record.A.Expire.Before(now) { - record.A = nil - } - if record.AAAA != nil && record.AAAA.Expire.Before(now) { - record.AAAA = nil - } - - if record.A == nil && record.AAAA == nil { - errors.LogDebug(context.Background(), s.name, " cleanup ", domain) - delete(s.ips, domain) - } else { - s.ips[domain] = record - } - } - - if len(s.ips) == 0 { - s.ips = make(map[string]*record) - } - - return nil -} - -func (s *QUICNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) { - elapsed := time.Since(req.start) - - s.Lock() - rec, found := s.ips[req.domain] - if !found { - rec = &record{} - } - updated := false - - switch req.reqType { - case dnsmessage.TypeA: - if isNewer(rec.A, ipRec) { - rec.A = ipRec - updated = true - } - case dnsmessage.TypeAAAA: - addr := make([]net.Address, 0) - for _, ip := range ipRec.IP { - if len(ip.IP()) == net.IPv6len { - addr = append(addr, ip) - } - } - ipRec.IP = addr - if isNewer(rec.AAAA, ipRec) { - rec.AAAA = ipRec - updated = true - } - } - errors.LogInfo(context.Background(), s.name, " got answer: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed) - - if updated { - s.ips[req.domain] = rec - } - switch req.reqType { - case dnsmessage.TypeA: - s.pub.Publish(req.domain+"4", nil) - case dnsmessage.TypeAAAA: - s.pub.Publish(req.domain+"6", nil) - } - s.Unlock() - common.Must(s.cleanup.Start()) + return s.cacheController.name } func (s *QUICNameServer) newReqID() uint16 { return 0 } -func (s *QUICNameServer) sendQuery(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption) { - errors.LogInfo(ctx, s.name, " querying: ", domain) +func (s *QUICNameServer) sendQuery(ctx context.Context, noResponseErrCh chan<- error, domain string, option dns_feature.IPOption) { + errors.LogInfo(ctx, s.Name(), " querying: ", domain) - reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP, 0)) + reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(s.clientIP, 0)) var deadline time.Time if d, ok := ctx.Deadline(); ok { @@ -192,23 +103,36 @@ func (s *QUICNameServer) sendQuery(ctx context.Context, domain string, clientIP b, err := dns.PackMessage(r.msg) if err != nil { errors.LogErrorInner(ctx, err, "failed to pack dns query") + noResponseErrCh <- err return } dnsReqBuf := buf.New() - binary.Write(dnsReqBuf, binary.BigEndian, uint16(b.Len())) - dnsReqBuf.Write(b.Bytes()) + err = binary.Write(dnsReqBuf, binary.BigEndian, uint16(b.Len())) + if err != nil { + errors.LogErrorInner(ctx, err, "binary write failed") + noResponseErrCh <- err + return + } + _, err = dnsReqBuf.Write(b.Bytes()) + if err != nil { + errors.LogErrorInner(ctx, err, "buffer write failed") + noResponseErrCh <- err + return + } b.Release() conn, err := s.openStream(dnsCtx) if err != nil { errors.LogErrorInner(ctx, err, "failed to open quic connection") + noResponseErrCh <- err return } _, err = conn.Write(dnsReqBuf.Bytes()) if err != nil { errors.LogErrorInner(ctx, err, "failed to send query") + noResponseErrCh <- err return } @@ -219,136 +143,81 @@ func (s *QUICNameServer) sendQuery(ctx context.Context, domain string, clientIP n, err := respBuf.ReadFullFrom(conn, 2) if err != nil && n == 0 { errors.LogErrorInner(ctx, err, "failed to read response length") + noResponseErrCh <- err return } var length int16 err = binary.Read(bytes.NewReader(respBuf.Bytes()), binary.BigEndian, &length) if err != nil { errors.LogErrorInner(ctx, err, "failed to parse response length") + noResponseErrCh <- err return } respBuf.Clear() n, err = respBuf.ReadFullFrom(conn, int32(length)) if err != nil && n == 0 { errors.LogErrorInner(ctx, err, "failed to read response length") + noResponseErrCh <- err return } rec, err := parseResponse(respBuf.Bytes()) if err != nil { errors.LogErrorInner(ctx, err, "failed to handle response") + noResponseErrCh <- err return } - s.updateIP(r, rec) + s.cacheController.updateIP(r, rec) }(req) } } -func (s *QUICNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { - s.RLock() - record, found := s.ips[domain] - s.RUnlock() - - if !found { - return nil, 0, errRecordNotFound - } - - var err4 error - var err6 error - var ips []net.Address - var ip6 []net.Address - var ttl uint32 - - if option.IPv4Enable { - ips, ttl, err4 = record.A.getIPs() - } - - if option.IPv6Enable { - ip6, ttl, err6 = record.AAAA.getIPs() - ips = append(ips, ip6...) - } - - if len(ips) > 0 { - netips, err := toNetIP(ips) - return netips, ttl, err - } - - if err4 != nil { - return nil, 0, err4 - } - - if err6 != nil { - return nil, 0, err6 - } - - if (option.IPv4Enable && record.A != nil) || (option.IPv6Enable && record.AAAA != nil) { - return nil, 0, dns_feature.ErrEmptyResponse - } - - return nil, 0, errRecordNotFound -} - // QueryIP is called from dns.Server->queryIPTimeout -func (s *QUICNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, uint32, error) { +func (s *QUICNameServer) QueryIP(ctx context.Context, domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { fqdn := Fqdn(domain) - option = ResolveIpOptionOverride(s.queryStrategy, option) - if !option.IPv4Enable && !option.IPv6Enable { - return nil, 0, dns_feature.ErrEmptyResponse - } + sub4, sub6 := s.cacheController.registerSubscribers(fqdn, option) + defer closeSubscribers(sub4, sub6) - if disableCache { - errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) + if s.cacheController.disableCache { + errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.Name()) } else { - ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err == nil || err == dns_feature.ErrEmptyResponse || dns_feature.RCodeFromError(err) == 3 { - errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) - log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) + ips, ttl, err := s.cacheController.findIPsForDomain(fqdn, option) + if !go_errors.Is(err, errRecordNotFound) { + errors.LogDebugInner(ctx, err, s.Name(), " cache HIT ", domain, " -> ", ips) + log.Record(&log.DNSLog{Server: s.Name(), Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, ttl, err } } - // ipv4 and ipv6 belong to different subscription groups - var sub4, sub6 *pubsub.Subscriber - if option.IPv4Enable { - sub4 = s.pub.Subscribe(fqdn + "4") - defer sub4.Close() - } - if option.IPv6Enable { - sub6 = s.pub.Subscribe(fqdn + "6") - defer sub6.Close() - } - done := make(chan interface{}) - go func() { - if sub4 != nil { - select { - case <-sub4.Wait(): - case <-ctx.Done(): - } - } - if sub6 != nil { - select { - case <-sub6.Wait(): - case <-ctx.Done(): - } - } - close(done) - }() - s.sendQuery(ctx, fqdn, clientIP, option) + noResponseErrCh := make(chan error, 2) + s.sendQuery(ctx, noResponseErrCh, fqdn, option) start := time.Now() - for { - ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err != errRecordNotFound { - log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) - return ips, ttl, err - } - + if sub4 != nil { select { case <-ctx.Done(): return nil, 0, ctx.Err() - case <-done: + case err := <-noResponseErrCh: + return nil, 0, err + case <-sub4.Wait(): + sub4.Close() } } + if sub6 != nil { + select { + case <-ctx.Done(): + return nil, 0, ctx.Err() + case err := <-noResponseErrCh: + return nil, 0, err + case <-sub6.Wait(): + sub6.Close() + } + } + + ips, ttl, err := s.cacheController.findIPsForDomain(fqdn, option) + log.Record(&log.DNSLog{Server: s.Name(), Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) + return ips, ttl, err + } func isActive(s quic.Connection) bool { diff --git a/app/dns/nameserver_quic_test.go b/app/dns/nameserver_quic_test.go index 56f9c3ee..fd11d2e6 100644 --- a/app/dns/nameserver_quic_test.go +++ b/app/dns/nameserver_quic_test.go @@ -16,24 +16,23 @@ import ( func TestQUICNameServer(t *testing.T) { url, err := url.Parse("quic://dns.adguard-dns.com") common.Must(err) - s, err := NewQUICNameServer(url, QueryStrategy_USE_IP) + s, err := NewQUICNameServer(url, false, net.IP(nil)) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", dns.IPOption{ IPv4Enable: true, IPv6Enable: true, - }, false) + }) cancel() common.Must(err) if len(ips) == 0 { t.Error("expect some ips, but got 0") } - ctx2, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips2, _, err := s.QueryIP(ctx2, "google.com", net.IP(nil), dns.IPOption{ + ips2, _, err := s.QueryIP(ctx2, "google.com", dns.IPOption{ IPv4Enable: true, IPv6Enable: true, - }, true) + }) cancel() common.Must(err) if r := cmp.Diff(ips2, ips); r != "" { @@ -44,13 +43,13 @@ func TestQUICNameServer(t *testing.T) { func TestQUICNameServerWithIPv4Override(t *testing.T) { url, err := url.Parse("quic://dns.adguard-dns.com") common.Must(err) - s, err := NewQUICNameServer(url, QueryStrategy_USE_IP4) + s, err := NewQUICNameServer(url, false, net.IP(nil)) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", dns.IPOption{ IPv4Enable: true, - IPv6Enable: true, - }, false) + IPv6Enable: false, + }) cancel() common.Must(err) if len(ips) == 0 { @@ -67,13 +66,13 @@ func TestQUICNameServerWithIPv4Override(t *testing.T) { func TestQUICNameServerWithIPv6Override(t *testing.T) { url, err := url.Parse("quic://dns.adguard-dns.com") common.Must(err) - s, err := NewQUICNameServer(url, QueryStrategy_USE_IP6) + s, err := NewQUICNameServer(url, false, net.IP(nil)) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*2) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns.IPOption{ - IPv4Enable: true, + ips, _, err := s.QueryIP(ctx, "google.com", dns.IPOption{ + IPv4Enable: false, IPv6Enable: true, - }, false) + }) cancel() common.Must(err) if len(ips) == 0 { diff --git a/app/dns/nameserver_tcp.go b/app/dns/nameserver_tcp.go index 49854312..1937c25c 100644 --- a/app/dns/nameserver_tcp.go +++ b/app/dns/nameserver_tcp.go @@ -4,12 +4,11 @@ import ( "bytes" "context" "encoding/binary" + go_errors "errors" "net/url" - "sync" "sync/atomic" "time" - "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/buf" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/log" @@ -17,34 +16,28 @@ import ( "github.com/xtls/xray-core/common/net/cnc" "github.com/xtls/xray-core/common/protocol/dns" "github.com/xtls/xray-core/common/session" - "github.com/xtls/xray-core/common/signal/pubsub" - "github.com/xtls/xray-core/common/task" 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). type TCPNameServer struct { - sync.RWMutex - name string - destination *net.Destination - ips map[string]*record - pub *pubsub.Service - cleanup *task.Periodic - reqID uint32 - dial func(context.Context) (net.Conn, error) - queryStrategy QueryStrategy + cacheController *CacheController + destination *net.Destination + reqID uint32 + dial func(context.Context) (net.Conn, error) + clientIP net.IP } // NewTCPNameServer creates DNS over TCP server object for remote resolving. func NewTCPNameServer( url *url.URL, dispatcher routing.Dispatcher, - queryStrategy QueryStrategy, + disableCache bool, + clientIP net.IP, ) (*TCPNameServer, error) { - s, err := baseTCPNameServer(url, "TCP", queryStrategy) + s, err := baseTCPNameServer(url, "TCP", disableCache, clientIP) if err != nil { return nil, err } @@ -65,8 +58,8 @@ func NewTCPNameServer( } // NewTCPLocalNameServer creates DNS over TCP client object for local resolving -func NewTCPLocalNameServer(url *url.URL, queryStrategy QueryStrategy) (*TCPNameServer, error) { - s, err := baseTCPNameServer(url, "TCPL", queryStrategy) +func NewTCPLocalNameServer(url *url.URL, disableCache bool, clientIP net.IP) (*TCPNameServer, error) { + s, err := baseTCPNameServer(url, "TCPL", disableCache, clientIP) if err != nil { return nil, err } @@ -78,7 +71,7 @@ func NewTCPLocalNameServer(url *url.URL, queryStrategy QueryStrategy) (*TCPNameS return s, nil } -func baseTCPNameServer(url *url.URL, prefix string, queryStrategy QueryStrategy) (*TCPNameServer, error) { +func baseTCPNameServer(url *url.URL, prefix string, disableCache bool, clientIP net.IP) (*TCPNameServer, error) { port := net.Port(53) if url.Port() != "" { var err error @@ -89,15 +82,9 @@ func baseTCPNameServer(url *url.URL, prefix string, queryStrategy QueryStrategy) dest := net.TCPDestination(net.ParseAddress(url.Hostname()), port) s := &TCPNameServer{ - destination: &dest, - ips: make(map[string]*record), - pub: pubsub.NewService(), - name: prefix + "//" + dest.NetAddr(), - queryStrategy: queryStrategy, - } - s.cleanup = &task.Periodic{ - Interval: time.Minute, - Execute: s.Cleanup, + cacheController: NewCacheController(prefix+"//"+dest.NetAddr(), disableCache), + destination: &dest, + clientIP: clientIP, } return s, nil @@ -105,94 +92,17 @@ func baseTCPNameServer(url *url.URL, prefix string, queryStrategy QueryStrategy) // Name implements Server. func (s *TCPNameServer) Name() string { - return s.name -} - -// Cleanup clears expired items from cache -func (s *TCPNameServer) Cleanup() error { - now := time.Now() - s.Lock() - defer s.Unlock() - - if len(s.ips) == 0 { - return errors.New("nothing to do. stopping...") - } - - for domain, record := range s.ips { - if record.A != nil && record.A.Expire.Before(now) { - record.A = nil - } - if record.AAAA != nil && record.AAAA.Expire.Before(now) { - record.AAAA = nil - } - - if record.A == nil && record.AAAA == nil { - errors.LogDebug(context.Background(), s.name, " cleanup ", domain) - delete(s.ips, domain) - } else { - s.ips[domain] = record - } - } - - if len(s.ips) == 0 { - s.ips = make(map[string]*record) - } - - return nil -} - -func (s *TCPNameServer) updateIP(req *dnsRequest, ipRec *IPRecord) { - elapsed := time.Since(req.start) - - s.Lock() - rec, found := s.ips[req.domain] - if !found { - rec = &record{} - } - updated := false - - switch req.reqType { - case dnsmessage.TypeA: - if isNewer(rec.A, ipRec) { - rec.A = ipRec - updated = true - } - case dnsmessage.TypeAAAA: - addr := make([]net.Address, 0) - for _, ip := range ipRec.IP { - if len(ip.IP()) == net.IPv6len { - addr = append(addr, ip) - } - } - ipRec.IP = addr - if isNewer(rec.AAAA, ipRec) { - rec.AAAA = ipRec - updated = true - } - } - errors.LogInfo(context.Background(), s.name, " got answer: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed) - - if updated { - s.ips[req.domain] = rec - } - switch req.reqType { - case dnsmessage.TypeA: - s.pub.Publish(req.domain+"4", nil) - case dnsmessage.TypeAAAA: - s.pub.Publish(req.domain+"6", nil) - } - s.Unlock() - common.Must(s.cleanup.Start()) + return s.cacheController.name } func (s *TCPNameServer) newReqID() uint16 { return uint16(atomic.AddUint32(&s.reqID, 1)) } -func (s *TCPNameServer) sendQuery(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption) { - errors.LogDebug(ctx, s.name, " querying DNS for: ", domain) +func (s *TCPNameServer) sendQuery(ctx context.Context, noResponseErrCh chan<- error, domain string, option dns_feature.IPOption) { + errors.LogDebug(ctx, s.Name(), " querying DNS for: ", domain) - reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP, 0)) + reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(s.clientIP, 0)) var deadline time.Time if d, ok := ctx.Deadline(); ok { @@ -221,23 +131,36 @@ func (s *TCPNameServer) sendQuery(ctx context.Context, domain string, clientIP n b, err := dns.PackMessage(r.msg) if err != nil { errors.LogErrorInner(ctx, err, "failed to pack dns query") + noResponseErrCh <- err return } conn, err := s.dial(dnsCtx) if err != nil { errors.LogErrorInner(ctx, err, "failed to dial namesever") + noResponseErrCh <- err return } defer conn.Close() dnsReqBuf := buf.New() - binary.Write(dnsReqBuf, binary.BigEndian, uint16(b.Len())) - dnsReqBuf.Write(b.Bytes()) + err = binary.Write(dnsReqBuf, binary.BigEndian, uint16(b.Len())) + if err != nil { + errors.LogErrorInner(ctx, err, "binary write failed") + noResponseErrCh <- err + return + } + _, err = dnsReqBuf.Write(b.Bytes()) + if err != nil { + errors.LogErrorInner(ctx, err, "buffer write failed") + noResponseErrCh <- err + return + } b.Release() _, err = conn.Write(dnsReqBuf.Bytes()) if err != nil { errors.LogErrorInner(ctx, err, "failed to send query") + noResponseErrCh <- err return } dnsReqBuf.Release() @@ -247,131 +170,80 @@ func (s *TCPNameServer) sendQuery(ctx context.Context, domain string, clientIP n n, err := respBuf.ReadFullFrom(conn, 2) if err != nil && n == 0 { errors.LogErrorInner(ctx, err, "failed to read response length") + noResponseErrCh <- err return } var length int16 err = binary.Read(bytes.NewReader(respBuf.Bytes()), binary.BigEndian, &length) if err != nil { errors.LogErrorInner(ctx, err, "failed to parse response length") + noResponseErrCh <- err return } respBuf.Clear() n, err = respBuf.ReadFullFrom(conn, int32(length)) if err != nil && n == 0 { errors.LogErrorInner(ctx, err, "failed to read response length") + noResponseErrCh <- err return } rec, err := parseResponse(respBuf.Bytes()) if err != nil { errors.LogErrorInner(ctx, err, "failed to parse DNS over TCP response") + noResponseErrCh <- err return } - s.updateIP(r, rec) + s.cacheController.updateIP(r, rec) }(req) } } -func (s *TCPNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { - s.RLock() - record, found := s.ips[domain] - s.RUnlock() - - if !found { - return nil, 0, errRecordNotFound - } - - var err4 error - var err6 error - var ips []net.Address - var ip6 []net.Address - var ttl uint32 - - if option.IPv4Enable { - ips, ttl, err4 = record.A.getIPs() - } - - if option.IPv6Enable { - ip6, ttl, err6 = record.AAAA.getIPs() - ips = append(ips, ip6...) - } - - if len(ips) > 0 { - netips, err := toNetIP(ips) - return netips, ttl, err - } - - if err4 != nil { - return nil, 0, err4 - } - - if err6 != nil { - return nil, 0, err6 - } - - return nil, 0, dns_feature.ErrEmptyResponse -} - // QueryIP implements Server. -func (s *TCPNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, uint32, error) { +func (s *TCPNameServer) QueryIP(ctx context.Context, domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { fqdn := Fqdn(domain) - option = ResolveIpOptionOverride(s.queryStrategy, option) - if !option.IPv4Enable && !option.IPv6Enable { - return nil, 0, dns_feature.ErrEmptyResponse - } + sub4, sub6 := s.cacheController.registerSubscribers(fqdn, option) + defer closeSubscribers(sub4, sub6) - if disableCache { - errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) + if s.cacheController.disableCache { + errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.Name()) } else { - ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err == nil || err == dns_feature.ErrEmptyResponse || dns_feature.RCodeFromError(err) == 3 { - errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) - log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) + ips, ttl, err := s.cacheController.findIPsForDomain(fqdn, option) + if !go_errors.Is(err, errRecordNotFound) { + errors.LogDebugInner(ctx, err, s.Name(), " cache HIT ", domain, " -> ", ips) + log.Record(&log.DNSLog{Server: s.Name(), Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, ttl, err } } - // ipv4 and ipv6 belong to different subscription groups - var sub4, sub6 *pubsub.Subscriber - if option.IPv4Enable { - sub4 = s.pub.Subscribe(fqdn + "4") - defer sub4.Close() - } - if option.IPv6Enable { - sub6 = s.pub.Subscribe(fqdn + "6") - defer sub6.Close() - } - done := make(chan interface{}) - go func() { - if sub4 != nil { - select { - case <-sub4.Wait(): - case <-ctx.Done(): - } - } - if sub6 != nil { - select { - case <-sub6.Wait(): - case <-ctx.Done(): - } - } - close(done) - }() - s.sendQuery(ctx, fqdn, clientIP, option) + noResponseErrCh := make(chan error, 2) + s.sendQuery(ctx, noResponseErrCh, fqdn, option) start := time.Now() - for { - ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err != errRecordNotFound { - log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) - return ips, ttl, err - } - + if sub4 != nil { select { case <-ctx.Done(): return nil, 0, ctx.Err() - case <-done: + case err := <-noResponseErrCh: + return nil, 0, err + case <-sub4.Wait(): + sub4.Close() } } + if sub6 != nil { + select { + case <-ctx.Done(): + return nil, 0, ctx.Err() + case err := <-noResponseErrCh: + return nil, 0, err + case <-sub6.Wait(): + sub6.Close() + } + } + + ips, ttl, err := s.cacheController.findIPsForDomain(fqdn, option) + log.Record(&log.DNSLog{Server: s.Name(), Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) + return ips, ttl, err + } diff --git a/app/dns/nameserver_tcp_test.go b/app/dns/nameserver_tcp_test.go index de4ecb89..074896ca 100644 --- a/app/dns/nameserver_tcp_test.go +++ b/app/dns/nameserver_tcp_test.go @@ -16,13 +16,13 @@ import ( func TestTCPLocalNameServer(t *testing.T) { url, err := url.Parse("tcp+local://8.8.8.8") common.Must(err) - s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP) + s, err := NewTCPLocalNameServer(url, false, net.IP(nil)) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, - }, false) + }) cancel() common.Must(err) if len(ips) == 0 { @@ -33,13 +33,13 @@ func TestTCPLocalNameServer(t *testing.T) { func TestTCPLocalNameServerWithCache(t *testing.T) { url, err := url.Parse("tcp+local://8.8.8.8") common.Must(err) - s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP) + s, err := NewTCPLocalNameServer(url, false, net.IP(nil)) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, - }, false) + }) cancel() common.Must(err) if len(ips) == 0 { @@ -47,10 +47,10 @@ func TestTCPLocalNameServerWithCache(t *testing.T) { } ctx2, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips2, _, err := s.QueryIP(ctx2, "google.com", net.IP(nil), dns_feature.IPOption{ + ips2, _, err := s.QueryIP(ctx2, "google.com", dns_feature.IPOption{ IPv4Enable: true, IPv6Enable: true, - }, true) + }) cancel() common.Must(err) if r := cmp.Diff(ips2, ips); r != "" { @@ -61,13 +61,13 @@ func TestTCPLocalNameServerWithCache(t *testing.T) { func TestTCPLocalNameServerWithIPv4Override(t *testing.T) { url, err := url.Parse("tcp+local://8.8.8.8") common.Must(err) - s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP4) + s, err := NewTCPLocalNameServer(url, false, net.IP(nil)) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ + ips, _, err := s.QueryIP(ctx, "google.com", dns_feature.IPOption{ IPv4Enable: true, - IPv6Enable: true, - }, false) + IPv6Enable: false, + }) cancel() common.Must(err) @@ -85,13 +85,13 @@ func TestTCPLocalNameServerWithIPv4Override(t *testing.T) { func TestTCPLocalNameServerWithIPv6Override(t *testing.T) { url, err := url.Parse("tcp+local://8.8.8.8") common.Must(err) - s, err := NewTCPLocalNameServer(url, QueryStrategy_USE_IP6) + s, err := NewTCPLocalNameServer(url, false, net.IP(nil)) common.Must(err) ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) - ips, _, err := s.QueryIP(ctx, "google.com", net.IP(nil), dns_feature.IPOption{ - IPv4Enable: true, + ips, _, err := s.QueryIP(ctx, "google.com", dns_feature.IPOption{ + IPv4Enable: false, IPv6Enable: true, - }, false) + }) cancel() common.Must(err) diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index 23803efa..3c25e612 100644 --- a/app/dns/nameserver_udp.go +++ b/app/dns/nameserver_udp.go @@ -2,6 +2,7 @@ package dns import ( "context" + go_errors "errors" "strings" "sync" "sync/atomic" @@ -13,7 +14,6 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/protocol/dns" udp_proto "github.com/xtls/xray-core/common/protocol/udp" - "github.com/xtls/xray-core/common/signal/pubsub" "github.com/xtls/xray-core/common/task" dns_feature "github.com/xtls/xray-core/features/dns" "github.com/xtls/xray-core/features/routing" @@ -24,15 +24,13 @@ import ( // ClassicNameServer implemented traditional UDP DNS. type ClassicNameServer struct { sync.RWMutex - name string - address *net.Destination - ips map[string]*record - requests map[uint16]*udpDnsRequest - pub *pubsub.Service - udpServer *udp.Dispatcher - cleanup *task.Periodic - reqID uint32 - queryStrategy QueryStrategy + cacheController *CacheController + address *net.Destination + requests map[uint16]*udpDnsRequest + udpServer *udp.Dispatcher + requestsCleanup *task.Periodic + reqID uint32 + clientIP net.IP } type udpDnsRequest struct { @@ -41,23 +39,21 @@ type udpDnsRequest struct { } // NewClassicNameServer creates udp server object for remote resolving. -func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher, queryStrategy QueryStrategy) *ClassicNameServer { +func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher, disableCache bool, clientIP net.IP) *ClassicNameServer { // default to 53 if unspecific if address.Port == 0 { address.Port = net.Port(53) } s := &ClassicNameServer{ - address: &address, - ips: make(map[string]*record), - requests: make(map[uint16]*udpDnsRequest), - pub: pubsub.NewService(), - name: strings.ToUpper(address.String()), - queryStrategy: queryStrategy, + cacheController: NewCacheController(strings.ToUpper(address.String()), disableCache), + address: &address, + requests: make(map[uint16]*udpDnsRequest), + clientIP: clientIP, } - s.cleanup = &task.Periodic{ + s.requestsCleanup = &task.Periodic{ Interval: time.Minute, - Execute: s.Cleanup, + Execute: s.RequestsCleanup, } s.udpServer = udp.NewDispatcher(dispatcher, s.HandleResponse) errors.LogInfo(context.Background(), "DNS: created UDP client initialized for ", address.NetAddr()) @@ -66,37 +62,17 @@ func NewClassicNameServer(address net.Destination, dispatcher routing.Dispatcher // Name implements Server. func (s *ClassicNameServer) Name() string { - return s.name + return s.cacheController.name } -// Cleanup clears expired items from cache -func (s *ClassicNameServer) Cleanup() error { +// RequestsCleanup clears expired items from cache +func (s *ClassicNameServer) RequestsCleanup() error { now := time.Now() s.Lock() defer s.Unlock() - if len(s.ips) == 0 && len(s.requests) == 0 { - return errors.New(s.name, " nothing to do. stopping...") - } - - for domain, record := range s.ips { - if record.A != nil && record.A.Expire.Before(now) { - record.A = nil - } - if record.AAAA != nil && record.AAAA.Expire.Before(now) { - record.AAAA = nil - } - - if record.A == nil && record.AAAA == nil { - errors.LogDebug(context.Background(), s.name, " cleanup ", domain) - delete(s.ips, domain) - } else { - s.ips[domain] = record - } - } - - if len(s.ips) == 0 { - s.ips = make(map[string]*record) + if len(s.requests) == 0 { + return errors.New(s.Name(), " nothing to do. stopping...") } for id, req := range s.requests { @@ -116,7 +92,7 @@ func (s *ClassicNameServer) Cleanup() error { func (s *ClassicNameServer) HandleResponse(ctx context.Context, packet *udp_proto.Packet) { ipRec, err := parseResponse(packet.Payload.Bytes()) if err != nil { - errors.LogError(ctx, s.name, " fail to parse responded DNS udp") + errors.LogError(ctx, s.Name(), " fail to parse responded DNS udp") return } @@ -129,14 +105,14 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, packet *udp_prot } s.Unlock() if !ok { - errors.LogError(ctx, s.name, " cannot find the pending request") + errors.LogError(ctx, s.Name(), " cannot find the pending request") return } // if truncated, retry with EDNS0 option(udp payload size: 1350) if ipRec.RawHeader.Truncated { // if already has EDNS0 option, no need to retry - if ok && len(req.msg.Additionals) == 0 { + if len(req.msg.Additionals) == 0 { // copy necessary meta data from original request // and add EDNS0 option opt := new(dnsmessage.Resource) @@ -154,51 +130,7 @@ func (s *ClassicNameServer) HandleResponse(ctx context.Context, packet *udp_prot } } - var rec record - switch req.reqType { - case dnsmessage.TypeA: - rec.A = ipRec - case dnsmessage.TypeAAAA: - rec.AAAA = ipRec - } - - elapsed := time.Since(req.start) - errors.LogInfo(ctx, s.name, " got answer: ", req.domain, " ", req.reqType, " -> ", ipRec.IP, " ", elapsed) - if len(req.domain) > 0 && (rec.A != nil || rec.AAAA != nil) { - s.updateIP(req.domain, &rec) - } -} - -func (s *ClassicNameServer) updateIP(domain string, newRec *record) { - s.Lock() - - rec, found := s.ips[domain] - if !found { - rec = &record{} - } - - updated := false - if isNewer(rec.A, newRec.A) { - rec.A = newRec.A - updated = true - } - if isNewer(rec.AAAA, newRec.AAAA) { - rec.AAAA = newRec.AAAA - updated = true - } - - if updated { - errors.LogDebug(context.Background(), s.name, " updating IP records for domain:", domain) - s.ips[domain] = rec - } - if newRec.A != nil { - s.pub.Publish(domain+"4", nil) - } - if newRec.AAAA != nil { - s.pub.Publish(domain+"6", nil) - } - s.Unlock() - common.Must(s.cleanup.Start()) + s.cacheController.updateIP(&req.dnsRequest, ipRec) } func (s *ClassicNameServer) newReqID() uint16 { @@ -207,17 +139,17 @@ func (s *ClassicNameServer) newReqID() uint16 { func (s *ClassicNameServer) addPendingRequest(req *udpDnsRequest) { s.Lock() - defer s.Unlock() - id := req.msg.ID req.expire = time.Now().Add(time.Second * 8) s.requests[id] = req + s.Unlock() + common.Must(s.requestsCleanup.Start()) } -func (s *ClassicNameServer) sendQuery(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption) { - errors.LogDebug(ctx, s.name, " querying DNS for: ", domain) +func (s *ClassicNameServer) sendQuery(ctx context.Context, _ chan<- error, domain string, option dns_feature.IPOption) { + errors.LogDebug(ctx, s.Name(), " querying DNS for: ", domain) - reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(clientIP, 0)) + reqs := buildReqMsgs(domain, option, s.newReqID, genEDNS0Options(s.clientIP, 0)) for _, req := range reqs { udpReq := &udpDnsRequest{ @@ -230,105 +162,50 @@ func (s *ClassicNameServer) sendQuery(ctx context.Context, domain string, client } } -func (s *ClassicNameServer) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { - s.RLock() - record, found := s.ips[domain] - s.RUnlock() - - if !found { - return nil, 0, errRecordNotFound - } - - var err4 error - var err6 error - var ips []net.Address - var ip6 []net.Address - var ttl uint32 - - if option.IPv4Enable { - ips, ttl, err4 = record.A.getIPs() - } - - if option.IPv6Enable { - ip6, ttl, err6 = record.AAAA.getIPs() - ips = append(ips, ip6...) - } - - if len(ips) > 0 { - netips, err := toNetIP(ips) - return netips, ttl, err - } - - if err4 != nil { - return nil, 0, err4 - } - - if err6 != nil { - return nil, 0, err6 - } - - return nil, 0, dns_feature.ErrEmptyResponse -} - // QueryIP implements Server. -func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, clientIP net.IP, option dns_feature.IPOption, disableCache bool) ([]net.IP, uint32, error) { +func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, option dns_feature.IPOption) ([]net.IP, uint32, error) { fqdn := Fqdn(domain) - option = ResolveIpOptionOverride(s.queryStrategy, option) - if !option.IPv4Enable && !option.IPv6Enable { - return nil, 0, dns_feature.ErrEmptyResponse - } + sub4, sub6 := s.cacheController.registerSubscribers(fqdn, option) + defer closeSubscribers(sub4, sub6) - if disableCache { - errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name) + if s.cacheController.disableCache { + errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.Name()) } else { - ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err == nil || err == dns_feature.ErrEmptyResponse || dns_feature.RCodeFromError(err) == 3 { - errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips) - log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) + ips, ttl, err := s.cacheController.findIPsForDomain(fqdn, option) + if !go_errors.Is(err, errRecordNotFound) { + errors.LogDebugInner(ctx, err, s.Name(), " cache HIT ", domain, " -> ", ips) + log.Record(&log.DNSLog{Server: s.Name(), Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err}) return ips, ttl, err } } - // ipv4 and ipv6 belong to different subscription groups - var sub4, sub6 *pubsub.Subscriber - if option.IPv4Enable { - sub4 = s.pub.Subscribe(fqdn + "4") - defer sub4.Close() - } - if option.IPv6Enable { - sub6 = s.pub.Subscribe(fqdn + "6") - defer sub6.Close() - } - done := make(chan interface{}) - go func() { - if sub4 != nil { - select { - case <-sub4.Wait(): - case <-ctx.Done(): - } - } - if sub6 != nil { - select { - case <-sub6.Wait(): - case <-ctx.Done(): - } - } - close(done) - }() - s.sendQuery(ctx, fqdn, clientIP, option) + noResponseErrCh := make(chan error, 2) + s.sendQuery(ctx, noResponseErrCh, fqdn, option) start := time.Now() - for { - ips, ttl, err := s.findIPsForDomain(fqdn, option) - if err != errRecordNotFound { - log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) - return ips, ttl, err - } - + if sub4 != nil { select { case <-ctx.Done(): return nil, 0, ctx.Err() - case <-done: + case err := <-noResponseErrCh: + return nil, 0, err + case <-sub4.Wait(): + sub4.Close() } } + if sub6 != nil { + select { + case <-ctx.Done(): + return nil, 0, ctx.Err() + case err := <-noResponseErrCh: + return nil, 0, err + case <-sub6.Wait(): + sub6.Close() + } + } + + ips, ttl, err := s.cacheController.findIPsForDomain(fqdn, option) + log.Record(&log.DNSLog{Server: s.Name(), Domain: domain, Result: ips, Status: log.DNSQueried, Elapsed: time.Since(start), Error: err}) + return ips, ttl, err + } diff --git a/app/router/condition.go b/app/router/condition.go index 89da1adf..35e2424d 100644 --- a/app/router/condition.go +++ b/app/router/condition.go @@ -119,7 +119,7 @@ type MultiGeoIPMatcher struct { func NewMultiGeoIPMatcher(geoips []*GeoIP, onSource bool) (*MultiGeoIPMatcher, error) { var matchers []*GeoIPMatcher for _, geoip := range geoips { - matcher, err := globalGeoIPContainer.Add(geoip) + matcher, err := GlobalGeoIPContainer.Add(geoip) if err != nil { return nil, err } diff --git a/app/router/condition_geoip.go b/app/router/condition_geoip.go index 09c81fa8..0140cdfb 100644 --- a/app/router/condition_geoip.go +++ b/app/router/condition_geoip.go @@ -115,4 +115,4 @@ func (c *GeoIPMatcherContainer) Add(geoip *GeoIP) (*GeoIPMatcher, error) { return m, nil } -var globalGeoIPContainer GeoIPMatcherContainer +var GlobalGeoIPContainer GeoIPMatcherContainer diff --git a/common/errors/multi_error.go b/common/errors/multi_error.go index 8066ac9e..cdfec9cd 100644 --- a/common/errors/multi_error.go +++ b/common/errors/multi_error.go @@ -1,6 +1,7 @@ package errors import ( + "errors" "strings" ) @@ -36,12 +37,12 @@ func AllEqual(expected error, actual error) bool { return false } for _, err := range errs { - if err != expected { + if !errors.Is(err, expected) { return false } } return true default: - return errs == expected + return errors.Is(errs, expected) } } diff --git a/features/dns/client.go b/features/dns/client.go index 9e7be91d..7dc576fb 100644 --- a/features/dns/client.go +++ b/features/dns/client.go @@ -38,6 +38,8 @@ func ClientType() interface{} { // ErrEmptyResponse indicates that DNS query succeeded but no answer was returned. var ErrEmptyResponse = errors.New("empty response") +const DefaultTTL = 300 + type RCodeError uint16 func (e RCodeError) Error() string { diff --git a/features/dns/localdns/client.go b/features/dns/localdns/client.go index a94c9474..48e740ee 100644 --- a/features/dns/localdns/client.go +++ b/features/dns/localdns/client.go @@ -30,29 +30,31 @@ func (*Client) LookupIP(host string, option dns.IPOption) ([]net.IP, uint32, err ipv6 := make([]net.IP, 0, len(ips)) for _, ip := range ips { parsed := net.IPAddress(ip) - if parsed != nil { - parsedIPs = append(parsedIPs, parsed.IP()) + if parsed == nil { + continue } - if len(ip) == net.IPv4len { - ipv4 = append(ipv4, ip) - } - if len(ip) == net.IPv6len { - ipv6 = append(ipv6, ip) + parsedIP := parsed.IP() + parsedIPs = append(parsedIPs, parsedIP) + + if len(parsedIP) == net.IPv4len { + ipv4 = append(ipv4, parsedIP) + } else { + ipv6 = append(ipv6, parsedIP) } } - // Local DNS ttl is 600 + switch { case option.IPv4Enable && option.IPv6Enable: if len(parsedIPs) > 0 { - return parsedIPs, 600, nil + return parsedIPs, dns.DefaultTTL, nil } case option.IPv4Enable: if len(ipv4) > 0 { - return ipv4, 600, nil + return ipv4, dns.DefaultTTL, nil } case option.IPv6Enable: if len(ipv6) > 0 { - return ipv6, 600, nil + return ipv6, dns.DefaultTTL, nil } } return nil, 0, dns.ErrEmptyResponse diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index 2344d412..3308faef 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -2,6 +2,7 @@ package dns import ( "context" + go_errors "errors" "io" "sync" "time" @@ -255,7 +256,7 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string, } rcode := dns.RCodeFromError(err) - if rcode == 0 && len(ips) == 0 && !errors.AllEqual(dns.ErrEmptyResponse, errors.Cause(err)) { + if rcode == 0 && len(ips) == 0 && !go_errors.Is(err, dns.ErrEmptyResponse) { errors.LogInfoInner(context.Background(), err, "ip query") return } From 16641fc4b57759c1003d9693e2a3887fbf91c9fe Mon Sep 17 00:00:00 2001 From: j2rong4cn <36783515+j2rong4cn@users.noreply.github.com> Date: Tue, 29 Apr 2025 19:29:52 +0800 Subject: [PATCH 807/867] Workflows: Build Android(7+) using NDK; Add Android(7+) amd64 build (#4664) Makes net.LookupIP() work on Android builds --- .github/workflows/release.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4de01e48..c52f585e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,6 +42,11 @@ jobs: - goos: android goarch: arm64 # END Android ARM 8 + # BEGIN Android AMD64 + - goos: android + goarch: amd64 + patch-assetname: android-amd64 + # END Android AMD64 # Windows ARM - goos: windows goarch: arm64 @@ -104,6 +109,19 @@ jobs: - name: Checkout codebase uses: actions/checkout@v4 + - name: Set up NDK + if: matrix.goos == 'android' + run: | + wget -qO android-ndk.zip https://dl.google.com/android/repository/android-ndk-r28b-linux.zip + unzip android-ndk.zip + rm android-ndk.zip + declare -A arches=( + ["amd64"]="x86_64-linux-android24-clang" + ["arm64"]="aarch64-linux-android24-clang" + ) + echo CC="$(realpath android-ndk-*/toolchains/llvm/prebuilt/linux-x86_64/bin)/${arches[${{ matrix.goarch }}]}" >> $GITHUB_ENV + echo CGO_ENABLED=1 >> $GITHUB_ENV + - name: Show workflow information run: | _NAME=${{ matrix.patch-assetname }} @@ -119,7 +137,7 @@ jobs: - name: Get project dependencies run: go mod download - + - name: Build Xray run: | mkdir -p build_assets From 19ba9cbe91bca98e935063761876408645bf3c15 Mon Sep 17 00:00:00 2001 From: Pk-web6936 <202365630+Pk-web6936@users.noreply.github.com> Date: Tue, 29 Apr 2025 15:02:23 +0330 Subject: [PATCH 808/867] Chore: Update gVisor to the latest version; Fmt .go files (#4663) --- go.mod | 2 +- go.sum | 4 ++-- transport/internet/sockopt_linux.go | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 0ed16813..c2c6eb31 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.72.0 google.golang.org/protobuf v1.36.6 - gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 + gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5 h12.io/socks v1.0.3 lukechampine.com/blake3 v1.4.0 ) diff --git a/go.sum b/go.sum index b19c7dbd..ccc00031 100644 --- a/go.sum +++ b/go.sum @@ -156,8 +156,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0 h1:P+U/06iIKPQ3DLcg+zBfSCia1luZ2msPZrJ8jYDFPs0= -gvisor.dev/gvisor v0.0.0-20240320123526-dc6abceb7ff0/go.mod h1:NQHVAzMwvZ+Qe3ElSiHmq9RUm1MdNHpUZ52fiEqvn+0= +gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5 h1:sfK5nHuG7lRFZ2FdTT3RimOqWBg8IrVm+/Vko1FVOsk= +gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5/go.mod h1:3r5CMtNQMKIvBlrmM9xWUNamjKBYPOWyXOjmg5Kts3g= h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo= h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= lukechampine.com/blake3 v1.4.0 h1:xDbKOZCVbnZsfzM6mHSYcGRHZ3YrLDzqz8XnV4uaD5w= diff --git a/transport/internet/sockopt_linux.go b/transport/internet/sockopt_linux.go index aa24cceb..be2a0e46 100644 --- a/transport/internet/sockopt_linux.go +++ b/transport/internet/sockopt_linux.go @@ -112,7 +112,7 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf if len(config.CustomSockopt) > 0 { for _, custom := range config.CustomSockopt { - if custom.System != "" && custom.System != runtime.GOOS{ + if custom.System != "" && custom.System != runtime.GOOS { errors.LogDebug(context.Background(), "CustomSockopt system not match: ", "want ", custom.System, " got ", runtime.GOOS) continue } @@ -120,7 +120,7 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf // network might be tcp4 or tcp6 // use HasPrefix so that "tcp" can match tcp4/6 with "tcp" if user want to control all tcp (udp is also the same) // if it is empty, strings.HasPrefix will always return true to make it apply for all networks - if !strings.HasPrefix(network, custom.Network){ + if !strings.HasPrefix(network, custom.Network) { continue } var level = 0x6 // default TCP @@ -218,7 +218,7 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) } if len(config.CustomSockopt) > 0 { for _, custom := range config.CustomSockopt { - if custom.System != "" && custom.System != runtime.GOOS{ + if custom.System != "" && custom.System != runtime.GOOS { errors.LogDebug(context.Background(), "CustomSockopt system not match: ", "want ", custom.System, " got ", runtime.GOOS) continue } @@ -226,7 +226,7 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) // network might be tcp4 or tcp6 // use HasPrefix so that "tcp" can match tcp4/6 with "tcp" if user want to control all tcp (udp is also the same) // if it is empty, strings.HasPrefix will always return true to make it apply for all networks - if !strings.HasPrefix(network, custom.Network){ + if !strings.HasPrefix(network, custom.Network) { continue } var level = 0x6 // default TCP From 5e6a5ae01de7d811b4e72919bba88bfef7205fcc Mon Sep 17 00:00:00 2001 From: Aubrey Yang Date: Wed, 30 Apr 2025 13:32:02 +0900 Subject: [PATCH 809/867] Improve random IP compatibility: support IPv4, add srcip option, and sync client source IP via sendthrough (#4671) --- app/proxyman/outbound/handler.go | 69 +++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 24 deletions(-) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index ab44a1d5..9a91480f 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -241,7 +241,9 @@ func (h *Handler) DestIpAddress() net.IP { // Dial implements internet.Dialer. func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connection, error) { if h.senderSettings != nil { + if h.senderSettings.ProxySettings.HasTag() { + tag := h.senderSettings.ProxySettings.Tag handler := h.outboundManager.GetHandler(tag) if handler != nil { @@ -270,22 +272,40 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connecti } if h.senderSettings.Via != nil { + outbounds := session.OutboundsFromContext(ctx) ob := outbounds[len(outbounds)-1] - if h.senderSettings.ViaCidr == "" { - if h.senderSettings.Via.AsAddress().Family().IsDomain() && h.senderSettings.Via.AsAddress().Domain() == "origin" { - if inbound := session.InboundFromContext(ctx); inbound != nil { - origin, _, err := net.SplitHostPort(inbound.Conn.LocalAddr().String()) - if err == nil { - ob.Gateway = net.ParseAddress(origin) - } - } - } else { - ob.Gateway = h.senderSettings.Via.AsAddress() - } - } else { //Get a random address. - ob.Gateway = ParseRandomIPv6(h.senderSettings.Via.AsAddress(), h.senderSettings.ViaCidr) + addr := h.senderSettings.Via.AsAddress() + var domain string + if addr.Family().IsDomain() { + domain = addr.Domain() } + switch { + case h.senderSettings.ViaCidr != "": + ob.Gateway = ParseRandomIP(addr, h.senderSettings.ViaCidr) + + case domain == "origin": + + if inbound := session.InboundFromContext(ctx); inbound != nil { + origin, _, err := net.SplitHostPort(inbound.Conn.LocalAddr().String()) + if err == nil { + ob.Gateway = net.ParseAddress(origin) + } + + } + case domain == "srcip": + if inbound := session.InboundFromContext(ctx); inbound != nil { + srcip, _, err := net.SplitHostPort(inbound.Conn.RemoteAddr().String()) + if err == nil { + ob.Gateway = net.ParseAddress(srcip) + } + } + //case addr.Family().IsDomain(): + default: + ob.Gateway = addr + + } + } } @@ -329,20 +349,21 @@ func (h *Handler) Close() error { return nil } -func ParseRandomIPv6(address net.Address, prefix string) net.Address { - _, network, _ := gonet.ParseCIDR(address.IP().String() + "/" + prefix) +func ParseRandomIP(addr net.Address, prefix string) net.Address { - maskSize, totalBits := network.Mask.Size() - subnetSize := big.NewInt(1).Lsh(big.NewInt(1), uint(totalBits-maskSize)) + _, ipnet, _ := gonet.ParseCIDR(addr.IP().String() + "/" + prefix) - // random - randomBigInt, _ := rand.Int(rand.Reader, subnetSize) + ones, bits := ipnet.Mask.Size() + subnetSize := new(big.Int).Lsh(big.NewInt(1), uint(bits-ones)) - startIPBigInt := big.NewInt(0).SetBytes(network.IP.To16()) - randomIPBigInt := big.NewInt(0).Add(startIPBigInt, randomBigInt) + rnd, _ := rand.Int(rand.Reader, subnetSize) - randomIPBytes := randomIPBigInt.Bytes() - randomIPBytes = append(make([]byte, 16-len(randomIPBytes)), randomIPBytes...) + startInt := new(big.Int).SetBytes(ipnet.IP) + rndInt := new(big.Int).Add(startInt, rnd) - return net.ParseAddress(gonet.IP(randomIPBytes).String()) + rndBytes := rndInt.Bytes() + padded := make([]byte, len(ipnet.IP)) + copy(padded[len(padded)-len(rndBytes):], rndBytes) + + return net.ParseAddress(gonet.IP(padded).String()) } From 54c6513fd437f1031023eccae731f967cbd9d73c Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Wed, 30 Apr 2025 08:02:52 +0330 Subject: [PATCH 810/867] DNS: Extend `hosts` Abilities (#4673) --- app/dns/hosts.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/dns/hosts.go b/app/dns/hosts.go index e1ceb9c7..d0485be2 100644 --- a/app/dns/hosts.go +++ b/app/dns/hosts.go @@ -2,6 +2,7 @@ package dns import ( "context" + "sort" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" @@ -41,8 +42,6 @@ func NewStaticHosts(hosts []*Config_HostMapping) (*StaticHosts, error) { } ips = append(ips, addr) } - default: - return nil, errors.New("neither IP address nor proxied domain specified for domain: ", mapping.Domain).AtWarning() } sh.ips[id] = ips @@ -62,17 +61,20 @@ func filterIP(ips []net.Address, option dns.IPOption) []net.Address { } func (h *StaticHosts) lookupInternal(domain string) []net.Address { - var ips []net.Address - for _, id := range h.matchers.Match(domain) { - ips = append(ips, h.ips[id]...) + MatchSlice := h.matchers.Match(domain) + sort.Slice(MatchSlice, func(i, j int) bool { + return MatchSlice[i] < MatchSlice[j] + }) + if len(MatchSlice) == 0 { + return nil } - return ips + return h.ips[MatchSlice[0]] } func (h *StaticHosts) lookup(domain string, option dns.IPOption, maxDepth int) []net.Address { switch addrs := h.lookupInternal(domain); { case len(addrs) == 0: // Not recorded in static hosts, return nil - return nil + return addrs case len(addrs) == 1 && addrs[0].Family().IsDomain(): // Try to unwrap domain errors.LogDebug(context.Background(), "found replaced domain: ", domain, " -> ", addrs[0].Domain(), ". Try to unwrap it") if maxDepth > 0 { From 87ab8e512882918b797e031ce8dc8ef59756e212 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Wed, 30 Apr 2025 04:40:58 +0000 Subject: [PATCH 811/867] v25.4.30 Announcement of NFTs by Project X: #3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: #4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/core.go b/core/core.go index 4e512118..d7555674 100644 --- a/core/core.go +++ b/core/core.go @@ -18,8 +18,8 @@ import ( var ( Version_x byte = 25 - Version_y byte = 3 - Version_z byte = 31 + Version_y byte = 4 + Version_z byte = 30 ) var ( From c847c21f3b244a5d1fc008f22469f93443969eaf Mon Sep 17 00:00:00 2001 From: A1lo Date: Wed, 7 May 2025 05:54:14 +0800 Subject: [PATCH 812/867] Workflows: Authenticating the GitHub API call with GitHub token (#4703) --- .github/workflows/release-win7.yml | 2 +- .github/workflows/scheduled-assets-update.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml index 239de1b5..6595dc07 100644 --- a/.github/workflows/release-win7.yml +++ b/.github/workflows/release-win7.yml @@ -51,7 +51,7 @@ jobs: GOSDK=$(go env GOROOT) rm -r $GOSDK/* cd $GOSDK - curl -O -L https://github.com/XTLS/go-win7/releases/latest/download/go-for-win7-linux-amd64.zip + curl -O -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" https://github.com/XTLS/go-win7/releases/latest/download/go-for-win7-linux-amd64.zip unzip ./go-for-win7-linux-amd64.zip -d $GOSDK rm ./go-for-win7-linux-amd64.zip diff --git a/.github/workflows/scheduled-assets-update.yml b/.github/workflows/scheduled-assets-update.yml index fb3ca455..c5149d92 100644 --- a/.github/workflows/scheduled-assets-update.yml +++ b/.github/workflows/scheduled-assets-update.yml @@ -45,12 +45,12 @@ jobs: INFO=($(echo $i | awk 'BEGIN{FS=" ";OFS=" "} {print $1,$2,$3,$4}')) FILE_NAME="${INFO[3]}.dat" echo -e "Verifying HASH key..." - HASH="$(curl -sL "https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat.sha256sum" | awk -F ' ' '{print $1}')" + HASH="$(curl -sL -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat.sha256sum" | awk -F ' ' '{print $1}')" if [ -s "./resources/${FILE_NAME}" ] && [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ]; then continue else echo -e "Downloading https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat..." - curl -L "https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat" -o ./resources/${FILE_NAME} + curl -L -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" "https://raw.githubusercontent.com/${INFO[0]}/${INFO[1]}/release/${INFO[2]}.dat" -o ./resources/${FILE_NAME} echo -e "Verifying HASH key..." [ "$(sha256sum "./resources/${FILE_NAME}" | awk -F ' ' '{print $1}')" == "${HASH}" ] || { echo -e "The HASH key of ${FILE_NAME} does not match cloud one."; exit 1; } echo "unhit=true" >> $GITHUB_OUTPUT From d4ca42715a05aca5abee91f7fa0adf3dc8256a8f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 17:55:42 -0400 Subject: [PATCH 813/867] Bump github.com/pires/go-proxyproto from 0.8.0 to 0.8.1 (#4695) Bumps [github.com/pires/go-proxyproto](https://github.com/pires/go-proxyproto) from 0.8.0 to 0.8.1. - [Release notes](https://github.com/pires/go-proxyproto/releases) - [Commits](https://github.com/pires/go-proxyproto/compare/v0.8.0...v0.8.1) --- updated-dependencies: - dependency-name: github.com/pires/go-proxyproto dependency-version: 0.8.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c2c6eb31..6d06421e 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gorilla/websocket v1.5.3 github.com/miekg/dns v1.1.65 github.com/pelletier/go-toml v1.9.5 - github.com/pires/go-proxyproto v0.8.0 + github.com/pires/go-proxyproto v0.8.1 github.com/quic-go/quic-go v0.51.0 github.com/refraction-networking/utls v1.7.1 github.com/sagernet/sing v0.5.1 diff --git a/go.sum b/go.sum index ccc00031..ba675364 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,8 @@ github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3v github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc= github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= -github.com/pires/go-proxyproto v0.8.0 h1:5unRmEAPbHXHuLjDg01CxJWf91cw3lKHc/0xzKpXEe0= -github.com/pires/go-proxyproto v0.8.0/go.mod h1:iknsfgnH8EkjrMeMyvfKByp9TiBZCKZM0jx2xmKqnVY= +github.com/pires/go-proxyproto v0.8.1 h1:9KEixbdJfhrbtjpz/ZwCdWDD2Xem0NZ38qMYaASJgp0= +github.com/pires/go-proxyproto v0.8.1/go.mod h1:ZKAAyp3cgy5Y5Mo4n9AlScrkCZwUy0g3Jf+slqQVcuU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= From 3e52f73e3c0ccb2eab06fa1b0ee24934dbf8e39d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 6 May 2025 17:56:07 -0400 Subject: [PATCH 814/867] Bump golang.org/x/net from 0.39.0 to 0.40.0 (#4698) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.39.0 to 0.40.0. - [Commits](https://github.com/golang/net/compare/v0.39.0...v0.40.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-version: 0.40.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 6d06421e..d162fec8 100644 --- a/go.mod +++ b/go.mod @@ -22,10 +22,10 @@ require ( github.com/vishvananda/netlink v1.3.0 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.37.0 - golang.org/x/net v0.39.0 - golang.org/x/sync v0.13.0 - golang.org/x/sys v0.32.0 + golang.org/x/crypto v0.38.0 + golang.org/x/net v0.40.0 + golang.org/x/sync v0.14.0 + golang.org/x/sys v0.33.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.72.0 google.golang.org/protobuf v1.36.6 @@ -50,7 +50,7 @@ require ( github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.5.0 // indirect golang.org/x/mod v0.23.0 // indirect - golang.org/x/text v0.24.0 // indirect + golang.org/x/text v0.25.0 // indirect golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.30.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect diff --git a/go.sum b/go.sum index ba675364..b06e1f7d 100644 --- a/go.sum +++ b/go.sum @@ -97,20 +97,20 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.37.0 h1:kJNSjF/Xp7kU0iB2Z+9viTPMW4EqqsrywMXLJOOsXSE= -golang.org/x/crypto v0.37.0/go.mod h1:vg+k43peMZ0pUMhYmVAWysMK35e6ioLh3wB8ZCAfbVc= +golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= +golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= -golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= +golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= +golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= -golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= +golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -119,14 +119,14 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= -golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0= -golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU= +golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= +golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 59aa5e1b88f1b42ffc7b26debc81fee38c09910d Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Wed, 7 May 2025 01:41:08 +0330 Subject: [PATCH 815/867] DNS: temporary appending hosts results (#4702) --- app/dns/hosts.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/dns/hosts.go b/app/dns/hosts.go index d0485be2..f4e06dbb 100644 --- a/app/dns/hosts.go +++ b/app/dns/hosts.go @@ -2,8 +2,6 @@ package dns import ( "context" - "sort" - "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/strmatcher" @@ -61,14 +59,16 @@ func filterIP(ips []net.Address, option dns.IPOption) []net.Address { } func (h *StaticHosts) lookupInternal(domain string) []net.Address { - MatchSlice := h.matchers.Match(domain) - sort.Slice(MatchSlice, func(i, j int) bool { - return MatchSlice[i] < MatchSlice[j] - }) - if len(MatchSlice) == 0 { + ips := make([]net.Address, 0) + found := false + for _, id := range h.matchers.Match(domain) { + ips = append(ips, h.ips[id]...) + found = true + } + if !found { return nil } - return h.ips[MatchSlice[0]] + return ips } func (h *StaticHosts) lookup(domain string, option dns.IPOption, maxDepth int) []net.Address { From 0d0fe7ef7a40dfdb3d552bbb884a9ccbbed1ccd8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 14:48:12 -0400 Subject: [PATCH 816/867] Bump github.com/miekg/dns from 1.1.65 to 1.1.66 (#4707) Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.65 to 1.1.66. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.65...v1.1.66) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-version: 1.1.66 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index d162fec8..6117c274 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.7.0 github.com/gorilla/websocket v1.5.3 - github.com/miekg/dns v1.1.65 + github.com/miekg/dns v1.1.66 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.1 github.com/quic-go/quic-go v0.51.0 @@ -49,10 +49,10 @@ require ( github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect github.com/vishvananda/netns v0.0.4 // indirect go.uber.org/mock v0.5.0 // indirect - golang.org/x/mod v0.23.0 // indirect + golang.org/x/mod v0.24.0 // indirect golang.org/x/text v0.25.0 // indirect golang.org/x/time v0.7.0 // indirect - golang.org/x/tools v0.30.0 // indirect + golang.org/x/tools v0.32.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index b06e1f7d..4f6ee752 100644 --- a/go.sum +++ b/go.sum @@ -38,8 +38,8 @@ github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0N github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/miekg/dns v1.1.65 h1:0+tIPHzUW0GCge7IiK3guGP57VAw7hoPDfApjkMD1Fc= -github.com/miekg/dns v1.1.65/go.mod h1:Dzw9769uoKVaLuODMDZz9M6ynFU6Em65csPuoi8G0ck= +github.com/miekg/dns v1.1.66 h1:FeZXOS3VCVsKnEAd+wBkjMC3D2K+ww66Cq3VnCINuJE= +github.com/miekg/dns v1.1.66/go.mod h1:jGFzBsSNbJw6z1HYut1RKBKHA9PBdxeHrZG8J+gC2WE= github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= @@ -100,8 +100,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= -golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= +golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -132,8 +132,8 @@ golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY= -golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY= +golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= +golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From f0dfbc2e660e1274b75d12db1607743d4c00ca02 Mon Sep 17 00:00:00 2001 From: Meow <197331664+Meo597@users.noreply.github.com> Date: Fri, 9 May 2025 03:44:54 +0800 Subject: [PATCH 817/867] Workflows: Ensure Geodat exists (#4680) --- .github/workflows/release-win7.yml | 31 +++++++++++++ .github/workflows/release.yml | 46 +++++++++++++++++++ .github/workflows/scheduled-assets-update.yml | 4 +- .github/workflows/test.yml | 29 ++++++++++++ 4 files changed, 108 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-win7.yml b/.github/workflows/release-win7.yml index 6595dc07..be9173e3 100644 --- a/.github/workflows/release-win7.yml +++ b/.github/workflows/release-win7.yml @@ -9,7 +9,38 @@ on: types: [opened, synchronize, reopened] jobs: + check-assets: + runs-on: ubuntu-latest + steps: + - name: Restore Geodat Cache + uses: actions/cache/restore@v4 + with: + path: resources + key: xray-geodat- + + - name: Check Assets Existence + id: check-assets + run: | + [ -d 'resources' ] || mkdir resources + LIST=('geoip.dat' 'geosite.dat') + for FILE_NAME in "${LIST[@]}" + do + echo -e "Checking ${FILE_NAME}..." + if [ -s "./resources/${FILE_NAME}" ]; then + echo -e "${FILE_NAME} exists." + else + echo -e "${FILE_NAME} does not exist." + echo "missing=true" >> $GITHUB_OUTPUT + break + fi + done + + - name: Sleep for 90 seconds if Assets Missing + if: steps.check-assets.outputs.missing == 'true' + run: sleep 90 + build: + needs: check-assets permissions: contents: write strategy: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c52f585e..130ea983 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,53 @@ on: types: [opened, synchronize, reopened] jobs: + check-assets: + runs-on: ubuntu-latest + steps: + - name: Restore Geodat Cache + uses: actions/cache/restore@v4 + with: + path: resources + key: xray-geodat- + + - name: Check Assets Existence + id: check-assets + run: | + [ -d 'resources' ] || mkdir resources + LIST=('geoip.dat' 'geosite.dat') + for FILE_NAME in "${LIST[@]}" + do + echo -e "Checking ${FILE_NAME}..." + if [ -s "./resources/${FILE_NAME}" ]; then + echo -e "${FILE_NAME} exists." + else + echo -e "${FILE_NAME} does not exist." + echo "missing=true" >> $GITHUB_OUTPUT + break + fi + done + + - name: Trigger Asset Update Workflow if Assets Missing + if: steps.check-assets.outputs.missing == 'true' + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { owner, repo } = context.repo; + await github.rest.actions.createWorkflowDispatch({ + owner, + repo, + workflow_id: 'scheduled-assets-update.yml', + ref: context.ref + }); + console.log('Triggered scheduled-assets-update.yml due to missing assets on branch:', context.ref); + + - name: Sleep for 90 seconds if Assets Missing + if: steps.check-assets.outputs.missing == 'true' + run: sleep 90 + build: + needs: check-assets permissions: contents: write strategy: diff --git a/.github/workflows/scheduled-assets-update.yml b/.github/workflows/scheduled-assets-update.yml index c5149d92..089c3b33 100644 --- a/.github/workflows/scheduled-assets-update.yml +++ b/.github/workflows/scheduled-assets-update.yml @@ -1,6 +1,6 @@ name: Scheduled assets update -# NOTE: This Github Actions is required by other actions, for preparing other packaging assets in a +# NOTE: This Github Actions is required by other actions, for preparing other packaging assets in a # routine manner, for example: GeoIP/GeoSite. # Currently updating: # - Geodat (GeoIP/Geosite) @@ -9,7 +9,7 @@ on: workflow_dispatch: schedule: # Update GeoData on every day (22:30 UTC) - - cron: '30 22 * * *' + - cron: "30 22 * * *" push: # Prevent triggering update request storm paths: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7ef9de65..c853a143 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,36 @@ on: types: [opened, synchronize, reopened] jobs: + check-assets: + runs-on: ubuntu-latest + steps: + - name: Restore Geodat Cache + uses: actions/cache/restore@v4 + with: + path: resources + key: xray-geodat- + - name: Check Assets Existence + id: check-assets + run: | + [ -d 'resources' ] || mkdir resources + LIST=('geoip.dat' 'geosite.dat') + for FILE_NAME in "${LIST[@]}" + do + echo -e "Checking ${FILE_NAME}..." + if [ -s "./resources/${FILE_NAME}" ]; then + echo -e "${FILE_NAME} exists." + else + echo -e "${FILE_NAME} does not exist." + echo "missing=true" >> $GITHUB_OUTPUT + break + fi + done + - name: Sleep for 90 seconds if Assets Missing + if: steps.check-assets.outputs.missing == 'true' + run: sleep 90 + test: + needs: check-assets permissions: contents: read runs-on: ${{ matrix.os }} From 6ed636840bd44e693238ba09f66a812ad386b075 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 10:29:52 -0400 Subject: [PATCH 818/867] Bump actions/github-script from 6 to 7 (#4708) Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7. - [Release notes](https://github.com/actions/github-script/releases) - [Commits](https://github.com/actions/github-script/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/github-script dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 130ea983..b18e94ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,7 +37,7 @@ jobs: - name: Trigger Asset Update Workflow if Assets Missing if: steps.check-assets.outputs.missing == 'true' - uses: actions/github-script@v6 + uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | From 7afed1e74da30279dab597a370ecd104ddbaab7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 10:31:28 -0400 Subject: [PATCH 819/867] Bump lukechampine.com/blake3 from 1.4.0 to 1.4.1 (#4709) Bumps [lukechampine.com/blake3](https://github.com/lukechampine/blake3) from 1.4.0 to 1.4.1. - [Commits](https://github.com/lukechampine/blake3/compare/v1.4.0...v1.4.1) --- updated-dependencies: - dependency-name: lukechampine.com/blake3 dependency-version: 1.4.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6117c274..d98d5f72 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( google.golang.org/protobuf v1.36.6 gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5 h12.io/socks v1.0.3 - lukechampine.com/blake3 v1.4.0 + lukechampine.com/blake3 v1.4.1 ) require ( diff --git a/go.sum b/go.sum index 4f6ee752..1f51668f 100644 --- a/go.sum +++ b/go.sum @@ -160,5 +160,5 @@ gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5 h1:sfK5nHuG7lRFZ2FdTT3RimOq gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5/go.mod h1:3r5CMtNQMKIvBlrmM9xWUNamjKBYPOWyXOjmg5Kts3g= h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo= h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck= -lukechampine.com/blake3 v1.4.0 h1:xDbKOZCVbnZsfzM6mHSYcGRHZ3YrLDzqz8XnV4uaD5w= -lukechampine.com/blake3 v1.4.0/go.mod h1:MQJNQCTnR+kwOP/JEZSxj3MaQjp80FOFSNMMHXcSeX0= +lukechampine.com/blake3 v1.4.1 h1:I3Smz7gso8w4/TunLKec6K2fn+kyKtDxr/xcQEN84Wg= +lukechampine.com/blake3 v1.4.1/go.mod h1:QFosUxmjB8mnrWFSNwKmvxHpfY72bmD2tQ0kBMM3kwo= From e9b3c53a0d23ea10d568308d4e74ed81680817c6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 10:32:00 -0400 Subject: [PATCH 820/867] Bump github.com/refraction-networking/utls from 1.7.1 to 1.7.2 (#4710) Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.7.1 to 1.7.2. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.7.1...v1.7.2) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-version: 1.7.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d98d5f72..7df5469d 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.1 github.com/quic-go/quic-go v0.51.0 - github.com/refraction-networking/utls v1.7.1 + github.com/refraction-networking/utls v1.7.2 github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 diff --git a/go.sum b/go.sum index 1f51668f..a2f32a1b 100644 --- a/go.sum +++ b/go.sum @@ -56,8 +56,8 @@ github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= github.com/quic-go/quic-go v0.51.0 h1:K8exxe9zXxeRKxaXxi/GpUqYiTrtdiWP8bo1KFya6Wc= github.com/quic-go/quic-go v0.51.0/go.mod h1:MFlGGpcpJqRAfmYi6NC2cptDPSxRWTOGNuP4wqrWmzQ= -github.com/refraction-networking/utls v1.7.1 h1:dxg+jla3uocgN8HtX+ccwDr68uCBBO3qLrkZUbqkcw0= -github.com/refraction-networking/utls v1.7.1/go.mod h1:TUhh27RHMGtQvjQq+RyO11P6ZNQNBb3N0v7wsEjKAIQ= +github.com/refraction-networking/utls v1.7.2 h1:XOgYzit7lAKaa7kzAO5BJR9l4X/H200eVUD4s8SF8/s= +github.com/refraction-networking/utls v1.7.2/go.mod h1:TUhh27RHMGtQvjQq+RyO11P6ZNQNBb3N0v7wsEjKAIQ= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/sagernet/sing v0.5.1 h1:mhL/MZVq0TjuvHcpYcFtmSD1BFOxZ/+8ofbNZcg1k1Y= From 72170d8b6be0d83af1624f6d31b81cf73f1a189c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 11 May 2025 20:55:45 -0400 Subject: [PATCH 821/867] Bump github.com/vishvananda/netlink from 1.3.0 to 1.3.1 (#4719) Bumps [github.com/vishvananda/netlink](https://github.com/vishvananda/netlink) from 1.3.0 to 1.3.1. - [Release notes](https://github.com/vishvananda/netlink/releases) - [Commits](https://github.com/vishvananda/netlink/compare/v1.3.0...v1.3.1) --- updated-dependencies: - dependency-name: github.com/vishvananda/netlink dependency-version: 1.3.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 7df5469d..0995dbb6 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e - github.com/vishvananda/netlink v1.3.0 + github.com/vishvananda/netlink v1.3.1 github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.38.0 @@ -47,7 +47,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/quic-go/qpack v0.5.1 // indirect github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect - github.com/vishvananda/netns v0.0.4 // indirect + github.com/vishvananda/netns v0.0.5 // indirect go.uber.org/mock v0.5.0 // indirect golang.org/x/mod v0.24.0 // indirect golang.org/x/text v0.25.0 // indirect diff --git a/go.sum b/go.sum index a2f32a1b..1b35e101 100644 --- a/go.sum +++ b/go.sum @@ -72,10 +72,10 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e h1:5QefA066A1tF8gHIiADmOVOV5LS43gt3ONnlEl3xkwI= github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e/go.mod h1:5t19P9LBIrNamL6AcMQOncg/r10y3Pc01AbHeMhwlpU= -github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQdrZk= -github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= -github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= -github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= +github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW6bV0= +github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4= +github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= +github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= From c53c1bfc516b4e5a41a1071c38943073b43faa0a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 10:11:39 -0400 Subject: [PATCH 822/867] Bump github.com/refraction-networking/utls from 1.7.2 to 1.7.3 (#4730) Bumps [github.com/refraction-networking/utls](https://github.com/refraction-networking/utls) from 1.7.2 to 1.7.3. - [Release notes](https://github.com/refraction-networking/utls/releases) - [Commits](https://github.com/refraction-networking/utls/compare/v1.7.2...v1.7.3) --- updated-dependencies: - dependency-name: github.com/refraction-networking/utls dependency-version: 1.7.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0995dbb6..06c1c7dc 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.1 github.com/quic-go/quic-go v0.51.0 - github.com/refraction-networking/utls v1.7.2 + github.com/refraction-networking/utls v1.7.3 github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 github.com/seiflotfy/cuckoofilter v0.0.0-20240715131351-a2f2c23f1771 diff --git a/go.sum b/go.sum index 1b35e101..5182f8ba 100644 --- a/go.sum +++ b/go.sum @@ -56,8 +56,8 @@ github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= github.com/quic-go/quic-go v0.51.0 h1:K8exxe9zXxeRKxaXxi/GpUqYiTrtdiWP8bo1KFya6Wc= github.com/quic-go/quic-go v0.51.0/go.mod h1:MFlGGpcpJqRAfmYi6NC2cptDPSxRWTOGNuP4wqrWmzQ= -github.com/refraction-networking/utls v1.7.2 h1:XOgYzit7lAKaa7kzAO5BJR9l4X/H200eVUD4s8SF8/s= -github.com/refraction-networking/utls v1.7.2/go.mod h1:TUhh27RHMGtQvjQq+RyO11P6ZNQNBb3N0v7wsEjKAIQ= +github.com/refraction-networking/utls v1.7.3 h1:L0WRhHY7Oq1T0zkdzVZMR6zWZv+sXbHB9zcuvsAEqCo= +github.com/refraction-networking/utls v1.7.3/go.mod h1:TUhh27RHMGtQvjQq+RyO11P6ZNQNBb3N0v7wsEjKAIQ= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3/go.mod h1:HgjTstvQsPGkxUsCd2KWxErBblirPizecHcpD3ffK+s= github.com/sagernet/sing v0.5.1 h1:mhL/MZVq0TjuvHcpYcFtmSD1BFOxZ/+8ofbNZcg1k1Y= From 30bf7be429595e4772e8a62e7501519b0c2b63ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 May 2025 10:12:49 -0400 Subject: [PATCH 823/867] Bump google.golang.org/grpc from 1.72.0 to 1.72.1 (#4729) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.72.0 to 1.72.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.72.0...v1.72.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-version: 1.72.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 06c1c7dc..10d736d4 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.14.0 golang.org/x/sys v0.33.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.72.0 + google.golang.org/grpc v1.72.1 google.golang.org/protobuf v1.36.6 gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 5182f8ba..9c93924a 100644 --- a/go.sum +++ b/go.sum @@ -143,8 +143,8 @@ golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uI golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= -google.golang.org/grpc v1.72.0 h1:S7UkcVa60b5AAQTaO6ZKamFp1zMZSU0fGDK2WZLbBnM= -google.golang.org/grpc v1.72.0/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= +google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 882975ce5a47a0b014b333c0c02b2a3dc36cbb8e Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Thu, 15 May 2025 17:45:03 +0330 Subject: [PATCH 824/867] DNS Host: Removing code that was not being executed and should not be executed. (#4721) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Removing a piece of code that was not being executed and should not be executed. * Remove d.dns --------- Co-authored-by: 风扇滑翔翼 --- app/dispatcher/default.go | 18 ++---------------- app/dns/dns.go | 16 ---------------- features/dns/client.go | 4 ---- 3 files changed, 2 insertions(+), 36 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index 54864cbb..c24e0bbc 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -96,7 +96,6 @@ type DefaultDispatcher struct { router routing.Router policy policy.Manager stats stats.Manager - dns dns.Client fdns dns.FakeDNSEngine } @@ -107,7 +106,7 @@ func init() { core.OptionalFeatures(ctx, func(fdns dns.FakeDNSEngine) { d.fdns = fdns }) - return d.Init(config.(*Config), om, router, pm, sm, dc) + return d.Init(config.(*Config), om, router, pm, sm) }); err != nil { return nil, err } @@ -116,12 +115,11 @@ func init() { } // Init initializes DefaultDispatcher. -func (d *DefaultDispatcher) Init(config *Config, om outbound.Manager, router routing.Router, pm policy.Manager, sm stats.Manager, dns dns.Client) error { +func (d *DefaultDispatcher) Init(config *Config, om outbound.Manager, router routing.Router, pm policy.Manager, sm stats.Manager) error { d.ohm = om d.router = router d.policy = pm d.stats = sm - d.dns = dns return nil } @@ -407,18 +405,6 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw func (d *DefaultDispatcher) routedDispatch(ctx context.Context, link *transport.Link, destination net.Destination) { outbounds := session.OutboundsFromContext(ctx) ob := outbounds[len(outbounds)-1] - if hosts, ok := d.dns.(dns.HostsLookup); ok && destination.Address.Family().IsDomain() { - proxied := hosts.LookupHosts(ob.Target.String()) - if proxied != nil { - ro := ob.RouteTarget == destination - destination.Address = *proxied - if ro { - ob.RouteTarget = destination - } else { - ob.Target = destination - } - } - } var handler outbound.Handler diff --git a/app/dns/dns.go b/app/dns/dns.go index 3b9cfbcb..a0b620c3 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -243,22 +243,6 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, uint32, er return nil, 0, dns.ErrEmptyResponse } -// LookupHosts implements dns.HostsLookup. -func (s *DNS) LookupHosts(domain string) *net.Address { - domain = strings.TrimSuffix(domain, ".") - if domain == "" { - return nil - } - // Normalize the FQDN form query - addrs := s.hosts.Lookup(domain, *s.ipOption) - if len(addrs) > 0 { - errors.LogInfo(s.ctx, "domain replaced: ", domain, " -> ", addrs[0].String()) - return &addrs[0] - } - - return nil -} - func (s *DNS) sortClients(domain string) []*Client { clients := make([]*Client, 0, len(s.clients)) clientUsed := make([]bool, len(s.clients)) diff --git a/features/dns/client.go b/features/dns/client.go index 7dc576fb..2a2bd148 100644 --- a/features/dns/client.go +++ b/features/dns/client.go @@ -24,10 +24,6 @@ type Client interface { LookupIP(domain string, option IPOption) ([]net.IP, uint32, error) } -type HostsLookup interface { - LookupHosts(domain string) *net.Address -} - // ClientType returns the type of Client interface. Can be used for implementing common.HasType. // // xray:api:beta From 7ddc4a2525bc81317e6a4d5075212c155e2a15ea Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 16 May 2025 04:08:38 +0000 Subject: [PATCH 825/867] REALITY practice: Support X25519MLKEM768 for TLS' communication https://github.com/XTLS/Xray-core/pull/3813#issuecomment-2873889724 --- go.mod | 2 +- go.sum | 2 ++ transport/internet/tls/tls.go | 8 ++++---- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 10d736d4..42174255 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.1 - github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d + github.com/xtls/reality v0.0.0-20250513125209-514f8647eac0 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.38.0 golang.org/x/net v0.40.0 diff --git a/go.sum b/go.sum index 9c93924a..15a0f757 100644 --- a/go.sum +++ b/go.sum @@ -78,6 +78,8 @@ github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zd github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= +github.com/xtls/reality v0.0.0-20250513125209-514f8647eac0 h1:ou6jXqJ9Ogs0BaEIzuszo1HMBokiKpf7XpNdsVYcvfA= +github.com/xtls/reality v0.0.0-20250513125209-514f8647eac0/go.mod h1:bJdU3ExzfUlY40Xxfibq3THW9IHiE8mHu/tEzud5JWM= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= diff --git a/transport/internet/tls/tls.go b/transport/internet/tls/tls.go index 42904be6..28c7bf63 100644 --- a/transport/internet/tls/tls.go +++ b/transport/internet/tls/tls.go @@ -163,7 +163,7 @@ func init() { func GetFingerprint(name string) (fingerprint *utls.ClientHelloID) { if name == "" { - return &utls.HelloChrome_120 + return &utls.HelloChrome_Auto } if fingerprint = PresetFingerprints[name]; fingerprint != nil { return @@ -179,7 +179,7 @@ func GetFingerprint(name string) (fingerprint *utls.ClientHelloID) { var PresetFingerprints = map[string]*utls.ClientHelloID{ // Recommended preset options in GUI clients - "chrome": &utls.HelloChrome_120, + "chrome": &utls.HelloChrome_Auto, "firefox": &utls.HelloFirefox_Auto, "safari": &utls.HelloSafari_Auto, "ios": &utls.HelloIOS_Auto, @@ -206,6 +206,7 @@ var ModernFingerprints = map[string]*utls.ClientHelloID{ "hellochrome_102": &utls.HelloChrome_102, "hellochrome_106_shuffle": &utls.HelloChrome_106_Shuffle, "hellochrome_120": &utls.HelloChrome_120, + "hellochrome_131": &utls.HelloChrome_131, "helloios_13": &utls.HelloIOS_13, "helloios_14": &utls.HelloIOS_14, "helloedge_85": &utls.HelloEdge_85, @@ -241,12 +242,11 @@ var OtherFingerprints = map[string]*utls.ClientHelloID{ "hello360_7_5": &utls.Hello360_7_5, "helloqq_auto": &utls.HelloQQ_Auto, - // reality currently does not support these new fingerprints + // Chrome betas' "hellochrome_100_psk": &utls.HelloChrome_100_PSK, "hellochrome_112_psk_shuf": &utls.HelloChrome_112_PSK_Shuf, "hellochrome_114_padding_psk_shuf": &utls.HelloChrome_114_Padding_PSK_Shuf, "hellochrome_115_pq": &utls.HelloChrome_115_PQ, "hellochrome_115_pq_psk": &utls.HelloChrome_115_PQ_PSK, "hellochrome_120_pq": &utls.HelloChrome_120_PQ, - "hellochrome_131": &utls.HelloChrome_131, } From 09d84c42e9c729c23549ea71b374e154d5365922 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 16 May 2025 07:29:05 +0000 Subject: [PATCH 826/867] REALITY protocol: Remove ChaCha20-Poly1305 support for REALITY's session id auth https://github.com/XTLS/Xray-core/pull/3813#issuecomment-2885686468 https://github.com/XTLS/REALITY/pull/4#issuecomment-2885815235 Reverts https://github.com/XTLS/Xray-core/commit/65b467e448d7450f832dbf7dbf2eac610d0c3a2e --- go.mod | 2 +- go.sum | 6 ++---- transport/internet/reality/reality.go | 13 ++----------- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 42174255..83a499a5 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.1 - github.com/xtls/reality v0.0.0-20250513125209-514f8647eac0 + github.com/xtls/reality v0.0.0-20250516070713-4df2ec9a5b47 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.38.0 golang.org/x/net v0.40.0 diff --git a/go.sum b/go.sum index 15a0f757..e99d46a8 100644 --- a/go.sum +++ b/go.sum @@ -76,10 +76,8 @@ github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4= github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d h1:+B97uD9uHLgAAulhigmys4BVwZZypzK7gPN3WtpgRJg= -github.com/xtls/reality v0.0.0-20240712055506-48f0b2d5ed6d/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= -github.com/xtls/reality v0.0.0-20250513125209-514f8647eac0 h1:ou6jXqJ9Ogs0BaEIzuszo1HMBokiKpf7XpNdsVYcvfA= -github.com/xtls/reality v0.0.0-20250513125209-514f8647eac0/go.mod h1:bJdU3ExzfUlY40Xxfibq3THW9IHiE8mHu/tEzud5JWM= +github.com/xtls/reality v0.0.0-20250516070713-4df2ec9a5b47 h1:9aJWkgWBwZ83l3j7+hBh3SurvRKuNfCgsSner5n6BcM= +github.com/xtls/reality v0.0.0-20250516070713-4df2ec9a5b47/go.mod h1:bJdU3ExzfUlY40Xxfibq3THW9IHiE8mHu/tEzud5JWM= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= diff --git a/transport/internet/reality/reality.go b/transport/internet/reality/reality.go index 0543b26d..ac017ed6 100644 --- a/transport/internet/reality/reality.go +++ b/transport/internet/reality/reality.go @@ -30,14 +30,10 @@ import ( "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/transport/internet/tls" - "golang.org/x/crypto/chacha20poly1305" "golang.org/x/crypto/hkdf" "golang.org/x/net/http2" ) -//go:linkname aesgcmPreferred github.com/refraction-networking/utls.aesgcmPreferred -func aesgcmPreferred(ciphers []uint16) bool - type Conn struct { *reality.Conn } @@ -147,13 +143,8 @@ func UClient(c net.Conn, config *Config, ctx context.Context, dest net.Destinati if _, err := hkdf.New(sha256.New, uConn.AuthKey, hello.Random[:20], []byte("REALITY")).Read(uConn.AuthKey); err != nil { return nil, err } - var aead cipher.AEAD - if aesgcmPreferred(hello.CipherSuites) { - block, _ := aes.NewCipher(uConn.AuthKey) - aead, _ = cipher.NewGCM(block) - } else { - aead, _ = chacha20poly1305.New(uConn.AuthKey) - } + block, _ := aes.NewCipher(uConn.AuthKey) + aead, _ := cipher.NewGCM(block) if config.Show { errors.LogInfo(ctx, fmt.Sprintf("REALITY localAddr: %v\tuConn.AuthKey[:16]: %v\tAEAD: %T\n", localAddr, uConn.AuthKey[:16], aead)) } From bb0e561caffba4592f908b44c8e327a2a60db629 Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Fri, 16 May 2025 15:34:54 +0330 Subject: [PATCH 827/867] Sniffer: Fix potential infinite loop (#4726) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 风扇滑翔翼 --- app/dispatcher/default.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index c24e0bbc..544a0956 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -371,7 +371,10 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw return nil, ctx.Err() default: cachingStartingTimeStamp := time.Now() - cacheErr := cReader.Cache(payload, cacheDeadline) + err := cReader.Cache(payload, cacheDeadline) + if err != nil { + return nil, err + } cachingTimeElapsed := time.Since(cachingStartingTimeStamp) cacheDeadline -= cachingTimeElapsed @@ -381,12 +384,12 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw case common.ErrNoClue: // No Clue: protocol not matches, and sniffer cannot determine whether there will be a match or not totalAttempt++ case protocol.ErrProtoNeedMoreData: // Protocol Need More Data: protocol matches, but need more data to complete sniffing - if cacheErr != nil { // Cache error (e.g. timeout) counts for failed attempt - totalAttempt++ - } + // in this case, do not add totalAttempt(allow to read until timeout) default: return result, err } + } else { + totalAttempt++ } if totalAttempt >= 2 || cacheDeadline <= 0 { return nil, errSniffingTimeout From ef1c165cc595aa122d284eb92547c9f5dab513fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Fri, 16 May 2025 20:08:29 +0800 Subject: [PATCH 828/867] QUIC sniffer: Fix potential slice panic (#4732) Fixes https://github.com/XTLS/Xray-core/issues/3914#issuecomment-2853392827 --- common/protocol/quic/sniff.go | 4 ++++ common/protocol/quic/sniff_test.go | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/common/protocol/quic/sniff.go b/common/protocol/quic/sniff.go index 3a22d454..0691bad6 100644 --- a/common/protocol/quic/sniff.go +++ b/common/protocol/quic/sniff.go @@ -114,6 +114,10 @@ func SniffQUIC(b []byte) (*SniffHeader, error) { if err != nil { return nil, errNotQuic } + // packetLen is impossible to be shorter than this + if packetLen < 4 { + return nil, errNotQuic + } hdrLen := len(b) - int(buffer.Len()) if len(b) < hdrLen+int(packetLen) { diff --git a/common/protocol/quic/sniff_test.go b/common/protocol/quic/sniff_test.go index 121279b5..8a85ea87 100644 --- a/common/protocol/quic/sniff_test.go +++ b/common/protocol/quic/sniff_test.go @@ -267,3 +267,21 @@ func TestSniffQUICPacketNumberLength4(t *testing.T) { t.Error("failed") } } + +func TestSniffFakeQUICPacketWithInvalidPacketNumberLength(t *testing.T) { + pkt, err := hex.DecodeString("cb00000001081c8c6d5aeb53d54400000090709b8600000000000000000000000000000000") + common.Must(err) + _, err = quic.SniffQUIC(pkt) + if err == nil { + t.Error("failed") + } +} + +func TestSniffFakeQUICPacketWithTooShortData(t *testing.T) { + pkt, err := hex.DecodeString("cb00000001081c8c6d5aeb53d54400000090709b86") + common.Must(err) + _, err = quic.SniffQUIC(pkt) + if err == nil { + t.Error("failed") + } +} From 800b8b50cc01e7c8904e6f58a682db0e9b4f795c Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Fri, 16 May 2025 12:18:34 +0000 Subject: [PATCH 829/867] v25.5.16 Announcement of NFTs by Project X: #3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: #4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/core.go b/core/core.go index d7555674..03d00191 100644 --- a/core/core.go +++ b/core/core.go @@ -18,8 +18,8 @@ import ( var ( Version_x byte = 25 - Version_y byte = 4 - Version_z byte = 30 + Version_y byte = 5 + Version_z byte = 16 ) var ( From f1116cee60aeed8329196c39a163ac8b5db23e73 Mon Sep 17 00:00:00 2001 From: yiguodev <147401898+yiguodev@users.noreply.github.com> Date: Mon, 26 May 2025 09:31:19 +0800 Subject: [PATCH 830/867] README.md: Rename FoXray to OneXray in GUI Clients (#4754) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d0a21059..577b9f4e 100644 --- a/README.md +++ b/README.md @@ -87,13 +87,13 @@ - [SaeedDev94/Xray](https://github.com/SaeedDev94/Xray) - iOS & macOS arm64 - [Happ](https://apps.apple.com/app/happ-proxy-utility/id6504287215) - - [FoXray](https://apps.apple.com/app/foxray/id6448898396) - [Streisand](https://apps.apple.com/app/streisand/id6450534064) + - [OneXray](https://github.com/OneXray/OneXray) - macOS arm64 & x64 - [V2rayU](https://github.com/yanue/V2rayU) - [V2RayXS](https://github.com/tzmax/V2RayXS) - [Furious](https://github.com/LorenEteval/Furious) - - [FoXray](https://apps.apple.com/app/foxray/id6448898396) + - [OneXray](https://github.com/OneXray/OneXray) - Linux - [v2rayA](https://github.com/v2rayA/v2rayA) - [Furious](https://github.com/LorenEteval/Furious) From 9fe4ee75b79a651b7d471741c29d86075434b197 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 May 2025 01:33:50 +0000 Subject: [PATCH 831/867] Bump github.com/quic-go/quic-go from 0.51.0 to 0.52.0 (#4752) Bumps [github.com/quic-go/quic-go](https://github.com/quic-go/quic-go) from 0.51.0 to 0.52.0. - [Release notes](https://github.com/quic-go/quic-go/releases) - [Commits](https://github.com/quic-go/quic-go/compare/v0.51.0...v0.52.0) --- updated-dependencies: - dependency-name: github.com/quic-go/quic-go dependency-version: 0.52.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 83a499a5..00a30efb 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/miekg/dns v1.1.66 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.1 - github.com/quic-go/quic-go v0.51.0 + github.com/quic-go/quic-go v0.52.0 github.com/refraction-networking/utls v1.7.3 github.com/sagernet/sing v0.5.1 github.com/sagernet/sing-shadowsocks v0.2.7 diff --git a/go.sum b/go.sum index e99d46a8..5a80592e 100644 --- a/go.sum +++ b/go.sum @@ -54,8 +54,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/quic-go/qpack v0.5.1 h1:giqksBPnT/HDtZ6VhtFKgoLOWmlyo9Ei6u9PqzIMbhI= github.com/quic-go/qpack v0.5.1/go.mod h1:+PC4XFrEskIVkcLzpEkbLqq1uCoxPhQuvK5rH1ZgaEg= -github.com/quic-go/quic-go v0.51.0 h1:K8exxe9zXxeRKxaXxi/GpUqYiTrtdiWP8bo1KFya6Wc= -github.com/quic-go/quic-go v0.51.0/go.mod h1:MFlGGpcpJqRAfmYi6NC2cptDPSxRWTOGNuP4wqrWmzQ= +github.com/quic-go/quic-go v0.52.0 h1:/SlHrCRElyaU6MaEPKqKr9z83sBg2v4FLLvWM+Z47pA= +github.com/quic-go/quic-go v0.52.0/go.mod h1:MFlGGpcpJqRAfmYi6NC2cptDPSxRWTOGNuP4wqrWmzQ= github.com/refraction-networking/utls v1.7.3 h1:L0WRhHY7Oq1T0zkdzVZMR6zWZv+sXbHB9zcuvsAEqCo= github.com/refraction-networking/utls v1.7.3/go.mod h1:TUhh27RHMGtQvjQq+RyO11P6ZNQNBb3N0v7wsEjKAIQ= github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 h1:f/FNXud6gA3MNr8meMVVGxhp+QBTqY91tM8HjEuMjGg= From 84c8e24a6c6ba7bb1943c760f1ca3a2318600218 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Mon, 26 May 2025 21:55:30 -0400 Subject: [PATCH 832/867] Update reality to 20250527 --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 00a30efb..54309aad 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.1 - github.com/xtls/reality v0.0.0-20250516070713-4df2ec9a5b47 + github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.38.0 golang.org/x/net v0.40.0 diff --git a/go.sum b/go.sum index 5a80592e..8f005281 100644 --- a/go.sum +++ b/go.sum @@ -78,6 +78,8 @@ github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zd github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/xtls/reality v0.0.0-20250516070713-4df2ec9a5b47 h1:9aJWkgWBwZ83l3j7+hBh3SurvRKuNfCgsSner5n6BcM= github.com/xtls/reality v0.0.0-20250516070713-4df2ec9a5b47/go.mod h1:bJdU3ExzfUlY40Xxfibq3THW9IHiE8mHu/tEzud5JWM= +github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130 h1:v/TVypWnLferyoaNHh6a8oyggj9APBUzfl1OOgXNbpw= +github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130/go.mod h1:bJdU3ExzfUlY40Xxfibq3THW9IHiE8mHu/tEzud5JWM= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= From 462bc3cfba966a4b5f119f1ecb0b70be33f53fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Wed, 4 Jun 2025 20:37:43 +0800 Subject: [PATCH 833/867] BurstObservatory: Fix nil panic when pingConfig is missing (#4757) Fixes https://github.com/XTLS/Xray-core/issues/4756 --- infra/conf/observatory.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/infra/conf/observatory.go b/infra/conf/observatory.go index 1ae403db..62d6aaba 100644 --- a/infra/conf/observatory.go +++ b/infra/conf/observatory.go @@ -5,6 +5,7 @@ import ( "github.com/xtls/xray-core/app/observatory" "github.com/xtls/xray-core/app/observatory/burst" + "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/infra/conf/cfgcommon/duration" ) @@ -26,6 +27,9 @@ type BurstObservatoryConfig struct { } func (b BurstObservatoryConfig) Build() (proto.Message, error) { + if b.HealthCheck == nil { + return nil, errors.New("BurstObservatory requires a valid pingConfig") + } if result, err := b.HealthCheck.Build(); err == nil { return &burst.Config{SubjectSelector: b.SubjectSelector, PingConfig: result.(*burst.HealthPingConfig)}, nil } else { From 4af53ab3647e1509486b8df99a253dae2030770c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 13:51:39 +0000 Subject: [PATCH 834/867] Bump google.golang.org/grpc from 1.72.1 to 1.72.2 (#4763) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.72.1 to 1.72.2. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.72.1...v1.72.2) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-version: 1.72.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 54309aad..00403431 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.14.0 golang.org/x/sys v0.33.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.72.1 + google.golang.org/grpc v1.72.2 google.golang.org/protobuf v1.36.6 gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5 h12.io/socks v1.0.3 diff --git a/go.sum b/go.sum index 8f005281..e33ea4c8 100644 --- a/go.sum +++ b/go.sum @@ -145,8 +145,8 @@ golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uI golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= -google.golang.org/grpc v1.72.1 h1:HR03wO6eyZ7lknl75XlxABNVLLFc2PAb6mHlYh756mA= -google.golang.org/grpc v1.72.1/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8= +google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From dd52732e1fc5ad07523713eff86c6330182fca58 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Jun 2025 01:46:16 +0000 Subject: [PATCH 835/867] Bump google.golang.org/grpc from 1.72.2 to 1.73.0 (#4783) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.72.2 to 1.73.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.72.2...v1.73.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-version: 1.73.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 30 ++++++++++++++---------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 00403431..265b85ac 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( golang.org/x/sync v0.14.0 golang.org/x/sys v0.33.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 - google.golang.org/grpc v1.72.2 + google.golang.org/grpc v1.73.0 google.golang.org/protobuf v1.36.6 gvisor.dev/gvisor v0.0.0-20250428193742-2d800c3129d5 h12.io/socks v1.0.3 @@ -54,7 +54,7 @@ require ( golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.32.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index e33ea4c8..1fd0c7f6 100644 --- a/go.sum +++ b/go.sum @@ -76,23 +76,21 @@ github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4= github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/reality v0.0.0-20250516070713-4df2ec9a5b47 h1:9aJWkgWBwZ83l3j7+hBh3SurvRKuNfCgsSner5n6BcM= -github.com/xtls/reality v0.0.0-20250516070713-4df2ec9a5b47/go.mod h1:bJdU3ExzfUlY40Xxfibq3THW9IHiE8mHu/tEzud5JWM= github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130 h1:v/TVypWnLferyoaNHh6a8oyggj9APBUzfl1OOgXNbpw= github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130/go.mod h1:bJdU3ExzfUlY40Xxfibq3THW9IHiE8mHu/tEzud5JWM= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= -go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= -go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= -go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= -go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= -go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= -go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= -go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= -go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= -go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= -go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= +go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= +go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= +go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M= +go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= +go.opentelemetry.io/otel/sdk v1.35.0 h1:iPctf8iprVySXSKJffSS79eOjl9pvxV9ZqOWT0QejKY= +go.opentelemetry.io/otel/sdk v1.35.0/go.mod h1:+ga1bZliga3DxJ3CQGg3updiaAJoNECOgJREo9KHGQg= +go.opentelemetry.io/otel/sdk/metric v1.35.0 h1:1RriWBmCKgkeHEhM7a2uMjMUfP7MsOF5JpUCaEqEI9o= +go.opentelemetry.io/otel/sdk/metric v1.35.0/go.mod h1:is6XYCUMpcKi+ZsOvfluY5YstFnhW0BidkR+gL+qN+w= +go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs= +go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= go.uber.org/mock v0.5.0 h1:KAMbZvZPyBPWgD14IrIQ38QCyjwpvVVV6K/bHl1IwQU= go.uber.org/mock v0.5.0/go.mod h1:ge71pBPLYDk7QIi1LupWxdAykm7KIEFchiOqd6z7qMM= go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBseWJUpBw5I82+2U4M= @@ -143,10 +141,10 @@ golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 h1:B82qJJgjvYKsXS9jeu golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2/go.mod h1:deeaetjYA+DHMHg+sMSMI58GrEteJUUzzw7en6TJQcI= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4= golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a h1:51aaUVRocpvUOSQKM6Q7VuoaktNIaMCLuhZB6DKksq4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a/go.mod h1:uRxBH1mhmO8PGhU89cMcHaXKZqO+OfakD8QQO0oYwlQ= -google.golang.org/grpc v1.72.2 h1:TdbGzwb82ty4OusHWepvFWGLgIbNo1/SUynEN0ssqv8= -google.golang.org/grpc v1.72.2/go.mod h1:wH5Aktxcg25y1I3w7H69nHfXdOG3UiadoBtjh3izSDM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 h1:e0AIkUUhxyBKh6ssZNrAMeqhA7RKUj42346d1y02i2g= +google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= +google.golang.org/grpc v1.73.0 h1:VIWSmpI2MegBtTuFt5/JWy2oXxtjJ/e89Z70ImfD2ok= +google.golang.org/grpc v1.73.0/go.mod h1:50sbHOUqWoCQGI8V2HQLJM0B+LMlIUjNSZmow7EVBQc= google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= From 1f49bfc6a55e6277797c536d3a9b603a69f79d37 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 6 Jun 2025 01:46:30 +0000 Subject: [PATCH 836/867] Bump golang.org/x/net from 0.40.0 to 0.41.0 (#4786) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.40.0 to 0.41.0. - [Commits](https://github.com/golang/net/compare/v0.40.0...v0.41.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-version: 0.41.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 12 ++++++------ go.sum | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index 265b85ac..f570b84d 100644 --- a/go.mod +++ b/go.mod @@ -22,9 +22,9 @@ require ( github.com/vishvananda/netlink v1.3.1 github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130 go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.38.0 - golang.org/x/net v0.40.0 - golang.org/x/sync v0.14.0 + golang.org/x/crypto v0.39.0 + golang.org/x/net v0.41.0 + golang.org/x/sync v0.15.0 golang.org/x/sys v0.33.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.73.0 @@ -49,10 +49,10 @@ require ( github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect github.com/vishvananda/netns v0.0.5 // indirect go.uber.org/mock v0.5.0 // indirect - golang.org/x/mod v0.24.0 // indirect - golang.org/x/text v0.25.0 // indirect + golang.org/x/mod v0.25.0 // indirect + golang.org/x/text v0.26.0 // indirect golang.org/x/time v0.7.0 // indirect - golang.org/x/tools v0.32.0 // indirect + golang.org/x/tools v0.33.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 1fd0c7f6..50f1c1e7 100644 --- a/go.sum +++ b/go.sum @@ -97,20 +97,20 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= -golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= +golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= +golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= -golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= +golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w= +golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY= -golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds= +golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= +golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= -golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= +golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -125,15 +125,15 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= -golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= +golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= +golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= -golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From d0c80fc80d77ed0f7a5b83e495736060979dfb91 Mon Sep 17 00:00:00 2001 From: Tamim Hossain <132823494+CodeWithTamim@users.noreply.github.com> Date: Fri, 6 Jun 2025 07:48:19 +0600 Subject: [PATCH 837/867] Core: Export the running bool (#4775) --- core/xray.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/xray.go b/core/xray.go index 0cc56daa..58135c96 100644 --- a/core/xray.go +++ b/core/xray.go @@ -90,6 +90,11 @@ type Instance struct { ctx context.Context } +// Instance state +func (server *Instance) IsRunning() bool { + return server.running +} + func AddInboundHandler(server *Instance, config *InboundHandlerConfig) error { inboundManager := server.GetFeature(inbound.ManagerType()).(inbound.Manager) rawHandler, err := CreateObject(server, config) From d44c78b819489d4278b78a55e1ac2f2a6c46b28f Mon Sep 17 00:00:00 2001 From: Meow <197331664+Meo597@users.noreply.github.com> Date: Fri, 6 Jun 2025 09:50:05 +0800 Subject: [PATCH 838/867] Workflows: Refactor docker (#4738) * Workflows: Rewrite Docker image build process * Docker: Merge Multi-Arch Manifests --- .github/docker/Dockerfile | 71 +++++++++++++++++++++++--------- .github/docker/Dockerfile.usa | 70 +++++++++++++++++++++++++++++++ .github/docker/files/config.json | 18 -------- .github/workflows/docker.yml | 61 ++++++++++++++++----------- 4 files changed, 160 insertions(+), 60 deletions(-) create mode 100644 .github/docker/Dockerfile.usa delete mode 100644 .github/docker/files/config.json diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index c32bb844..b7a871f0 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -1,28 +1,61 @@ -# syntax=docker/dockerfile:1 -FROM --platform=$BUILDPLATFORM golang:alpine AS build +# syntax=docker/dockerfile:latest +FROM --platform=$BUILDPLATFORM golang:latest AS build + +# Build xray-core WORKDIR /src COPY . . ARG TARGETOS ARG TARGETARCH RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main -ADD https://github.com/v2fly/geoip/releases/latest/download/geoip.dat /v2fly/geoip.dat -ADD https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat /v2fly/geosite.dat -ADD https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat /loyalsoldier/geoip.dat -ADD https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat /loyalsoldier/geosite.dat -# chainguard/static contains only tzdata and ca-certificates, can be built with multiarch static binaries. -FROM --platform=linux/amd64 chainguard/static:latest -WORKDIR /var/log/xray -COPY .github/docker/files/config.json /etc/xray/config.json -COPY --from=build --chmod=755 /src/xray /usr/bin/xray +# Download geodat into a staging directory +ADD https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/geoip.dat /tmp/geodat/geoip.dat +ADD https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/geosite.dat /tmp/geodat/geosite.dat -USER root -WORKDIR /root -VOLUME /etc/xray -ARG TZ=Asia/Shanghai +RUN mkdir -p /tmp/empty + +# Create config files with empty JSON content +RUN mkdir -p /tmp/usr/local/etc/xray +RUN cat </tmp/usr/local/etc/xray/00_log.json +{ + "log": { + "error": "/var/log/xray/error.log", + "loglevel": "warning", + "access": "none", + "dnsLog": false + } +} +EOF +RUN echo '{}' >/tmp/usr/local/etc/xray/01_api.json +RUN echo '{}' >/tmp/usr/local/etc/xray/02_dns.json +RUN echo '{}' >/tmp/usr/local/etc/xray/03_routing.json +RUN echo '{}' >/tmp/usr/local/etc/xray/04_policy.json +RUN echo '{}' >/tmp/usr/local/etc/xray/05_inbounds.json +RUN echo '{}' >/tmp/usr/local/etc/xray/06_outbounds.json +RUN echo '{}' >/tmp/usr/local/etc/xray/07_transport.json +RUN echo '{}' >/tmp/usr/local/etc/xray/08_stats.json +RUN echo '{}' >/tmp/usr/local/etc/xray/09_reverse.json + +# Create log files +RUN mkdir -p /tmp/var/log/xray && touch \ + /tmp/var/log/xray/access.log \ + /tmp/var/log/xray/error.log + +# Build finally image +FROM gcr.io/distroless/static:nonroot + +COPY --from=build --chown=0:0 --chmod=755 /src/xray /usr/local/bin/xray +COPY --from=build --chown=0:0 --chmod=644 /tmp/geodat/*.dat /usr/local/share/xray/ +COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /usr/local/etc/xray +COPY --from=build --chown=0:0 --chmod=644 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/ +COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /var/log/xray +COPY --from=build --chown=65532:65532 --chmod=600 /tmp/var/log/xray/*.log /var/log/xray/ + +VOLUME /usr/local/etc/xray +VOLUME /var/log/xray + +ARG TZ=Etc/UTC ENV TZ=$TZ -ENTRYPOINT [ "/usr/bin/xray" ] -CMD [ "-confdir", "/etc/xray/" ] -ARG flavor=v2fly -COPY --from=build --chmod=644 /$flavor /usr/share/xray +ENTRYPOINT [ "/usr/local/bin/xray" ] +CMD [ "-confdir", "/usr/local/etc/xray/" ] diff --git a/.github/docker/Dockerfile.usa b/.github/docker/Dockerfile.usa new file mode 100644 index 00000000..5709e246 --- /dev/null +++ b/.github/docker/Dockerfile.usa @@ -0,0 +1,70 @@ +# syntax=docker/dockerfile:latest +FROM --platform=$BUILDPLATFORM golang:latest AS build + +# Build xray-core +WORKDIR /src +COPY . . +ARG TARGETOS +ARG TARGETARCH +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main + +# Download geodat into a staging directory +ADD https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/geoip.dat /tmp/geodat/geoip.dat +ADD https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/geosite.dat /tmp/geodat/geosite.dat + +RUN mkdir -p /tmp/empty + +# Create config files with empty JSON content +RUN mkdir -p /tmp/usr/local/etc/xray +RUN cat </tmp/usr/local/etc/xray/00_log.json +{ + "log": { + "error": "/var/log/xray/error.log", + "loglevel": "warning", + "access": "none", + "dnsLog": false + } +} +EOF +RUN echo '{}' >/tmp/usr/local/etc/xray/01_api.json +RUN echo '{}' >/tmp/usr/local/etc/xray/02_dns.json +RUN echo '{}' >/tmp/usr/local/etc/xray/03_routing.json +RUN echo '{}' >/tmp/usr/local/etc/xray/04_policy.json +RUN echo '{}' >/tmp/usr/local/etc/xray/05_inbounds.json +RUN echo '{}' >/tmp/usr/local/etc/xray/06_outbounds.json +RUN echo '{}' >/tmp/usr/local/etc/xray/07_transport.json +RUN echo '{}' >/tmp/usr/local/etc/xray/08_stats.json +RUN echo '{}' >/tmp/usr/local/etc/xray/09_reverse.json + +# Create log files +RUN mkdir -p /tmp/var/log/xray && touch \ + /tmp/var/log/xray/access.log \ + /tmp/var/log/xray/error.log + +# Build finally image +# Note on Distroless Base Image and Architecture Support: +# - The official 'gcr.io/distroless/static' image provided by Google only supports a limited set of architectures for Linux: +# - linux/amd64 +# - linux/arm/v7 +# - linux/arm64/v8 +# - linux/ppc64le +# - linux/s390x +# - Upon inspection, the blob contents of the Distroless images across these architectures are nearly identical, with only minor differences in metadata (e.g., 'Architecture' field in the manifest). +# - Due to this similarity in content, it is feasible to forcibly specify a single platform (e.g., '--platform=linux/amd64') for unsupported architectures, as the core image content remains compatible with statically compiled binaries like Go applications. +FROM --platform=linux/amd64 gcr.io/distroless/static:nonroot + +COPY --from=build --chown=0:0 --chmod=755 /src/xray /usr/local/bin/xray +COPY --from=build --chown=0:0 --chmod=644 /tmp/geodat/*.dat /usr/local/share/xray/ +COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /usr/local/etc/xray +COPY --from=build --chown=0:0 --chmod=644 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/ +COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /var/log/xray +COPY --from=build --chown=65532:65532 --chmod=600 /tmp/var/log/xray/*.log /var/log/xray/ + +VOLUME /usr/local/etc/xray +VOLUME /var/log/xray + +ARG TZ=Etc/UTC +ENV TZ=$TZ + +ENTRYPOINT [ "/usr/local/bin/xray" ] +CMD [ "-confdir", "/usr/local/etc/xray/" ] diff --git a/.github/docker/files/config.json b/.github/docker/files/config.json deleted file mode 100644 index 10675856..00000000 --- a/.github/docker/files/config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "inbounds": [{ - "port": 9000, - "protocol": "vmess", - "settings": { - "clients": [ - { - "id": "1eb6e917-774b-4a84-aff6-b058577c60a5", - "level": 1 - } - ] - } - }], - "outbounds": [{ - "protocol": "freedom", - "settings": {} - }] -} \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index c0945db3..dc7759cc 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,9 +3,6 @@ name: Build docker image on: release: types: [published] - push: - branches: - - main jobs: build-image: @@ -14,6 +11,7 @@ jobs: packages: write steps: - uses: actions/checkout@v4 + - name: Docker metadata id: meta uses: docker/metadata-action@v5 @@ -21,56 +19,73 @@ jobs: images: ghcr.io/${{ github.repository_owner }}/xray-core flavor: latest=auto tags: | - type=sha - type=ref,event=branch - type=ref,event=pr type=semver,pattern={{version}} - - name: Docker metadata Loyalsoldier flavor - id: loyalsoldier + + - name: Docker metadata (unsupported architectures) + id: metausa uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository_owner }}/xray-core flavor: | latest=auto - suffix=-ls,onlatest=true + suffix=-usa,onlatest=true tags: | - type=sha - type=ref,event=branch - type=ref,event=pr type=semver,pattern={{version}} + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Build and push uses: docker/build-push-action@v6 with: context: . platforms: | linux/amd64 - linux/arm64 - linux/loong64 - linux/riscv64 + linux/arm/v7 + linux/arm64/v8 + linux/ppc64le + linux/s390x provenance: false file: .github/docker/Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} - - name: Build and push Loyalsoldier flavor + + - name: Build and push (unsupported architectures) uses: docker/build-push-action@v6 with: context: . platforms: | - linux/amd64 - linux/arm64 - linux/loong64 + linux/386 + linux/arm/v6 linux/riscv64 + linux/loong64 provenance: false - file: .github/docker/Dockerfile - build-args: flavor=loyalsoldier + file: .github/docker/Dockerfile.usa push: true - tags: | - ${{ steps.loyalsoldier.outputs.tags }} + tags: ${{ steps.metausa.outputs.tags }} + + - name: Merge Multi-Arch Manifests + run: | + echo "Starting to merge multi-architecture manifests..." + + # Convert newlines to spaces and split into array + TAGS=($(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' ')) + + echo "Total tags to process: ${#TAGS[@]}" + for tag in "${TAGS[@]}"; do + echo "Merging tag: $tag with unsupported architectures ($tag-usa)" + docker buildx imagetools create --append --tag "$tag" "$tag-usa" + if [ $? -ne 0 ]; then + echo "Error: Failed to merge $tag-usa into $tag" + exit 1 + fi + done + + echo "Multi-architecture manifest merge completed successfully." From af7a76da67673222c3d7356462c3518c7af6282e Mon Sep 17 00:00:00 2001 From: Sergey Gorbunov Date: Fri, 6 Jun 2025 04:51:48 +0300 Subject: [PATCH 839/867] API: Add ListInbounds and ListOutbounds (#4723) --- app/commander/outbound.go | 11 + app/metrics/outbound.go | 11 + app/proxyman/command/command.go | 31 ++ app/proxyman/command/command.pb.go | 467 +++++++++++++++++------- app/proxyman/command/command.proto | 16 + app/proxyman/command/command_grpc.pb.go | 76 ++++ app/proxyman/inbound/always.go | 33 +- app/proxyman/inbound/dynamic.go | 15 + app/proxyman/inbound/inbound.go | 15 + app/proxyman/outbound/handler.go | 14 + app/proxyman/outbound/outbound.go | 15 + app/reverse/portal.go | 11 + features/inbound/inbound.go | 8 + features/outbound/outbound.go | 6 + main/commands/all/api/api.go | 2 + main/commands/all/api/inbounds_list.go | 44 +++ main/commands/all/api/outbounds_list.go | 43 +++ testing/mocks/outbound.go | 14 + testing/scenarios/command_test.go | 99 +++++ 19 files changed, 791 insertions(+), 140 deletions(-) create mode 100644 main/commands/all/api/inbounds_list.go create mode 100644 main/commands/all/api/outbounds_list.go diff --git a/app/commander/outbound.go b/app/commander/outbound.go index 001423ff..7f520d74 100644 --- a/app/commander/outbound.go +++ b/app/commander/outbound.go @@ -8,6 +8,7 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net/cnc" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/signal/done" "github.com/xtls/xray-core/transport" ) @@ -108,3 +109,13 @@ func (co *Outbound) Close() error { co.closed = true return co.listener.Close() } + +// SenderSettings implements outbound.Handler. +func (co *Outbound) SenderSettings() *serial.TypedMessage { + return nil +} + +// ProxySettings implements outbound.Handler. +func (co *Outbound) ProxySettings() *serial.TypedMessage { + return nil +} diff --git a/app/metrics/outbound.go b/app/metrics/outbound.go index 40f19383..e55b33fb 100644 --- a/app/metrics/outbound.go +++ b/app/metrics/outbound.go @@ -8,6 +8,7 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net/cnc" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/signal/done" "github.com/xtls/xray-core/transport" ) @@ -108,3 +109,13 @@ func (co *Outbound) Close() error { co.closed = true return co.listener.Close() } + +// SenderSettings implements outbound.Handler. +func (co *Outbound) SenderSettings() *serial.TypedMessage { + return nil +} + +// ProxySettings implements outbound.Handler. +func (co *Outbound) ProxySettings() *serial.TypedMessage { + return nil +} diff --git a/app/proxyman/command/command.go b/app/proxyman/command/command.go index ef710521..227a95c3 100644 --- a/app/proxyman/command/command.go +++ b/app/proxyman/command/command.go @@ -3,6 +3,7 @@ package command import ( "context" + "github.com/xtls/xray-core/app/commander" "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/protocol" @@ -99,6 +100,19 @@ func (s *handlerServer) AlterInbound(ctx context.Context, request *AlterInboundR return &AlterInboundResponse{}, operation.ApplyInbound(ctx, handler) } +func (s *handlerServer) ListInbounds(ctx context.Context, request *ListInboundsRequest) (*ListInboundsResponse, error) { + handlers := s.ihm.ListHandlers(ctx) + response := &ListInboundsResponse{} + for _, handler := range handlers { + response.Inbounds = append(response.Inbounds, &core.InboundHandlerConfig{ + Tag: handler.Tag(), + ReceiverSettings: handler.ReceiverSettings(), + ProxySettings: handler.ProxySettings(), + }) + } + return response, nil +} + func (s *handlerServer) GetInboundUsers(ctx context.Context, request *GetInboundUserRequest) (*GetInboundUserResponse, error) { handler, err := s.ihm.GetHandler(ctx, request.Tag) if err != nil { @@ -164,6 +178,23 @@ func (s *handlerServer) AlterOutbound(ctx context.Context, request *AlterOutboun return &AlterOutboundResponse{}, operation.ApplyOutbound(ctx, handler) } +func (s *handlerServer) ListOutbounds(ctx context.Context, request *ListOutboundsRequest) (*ListOutboundsResponse, error) { + handlers := s.ohm.ListHandlers(ctx) + response := &ListOutboundsResponse{} + for _, handler := range handlers { + // Ignore gRPC outbound + if _, ok := handler.(*commander.Outbound); ok { + continue + } + response.Outbounds = append(response.Outbounds, &core.OutboundHandlerConfig{ + Tag: handler.Tag(), + SenderSettings: handler.SenderSettings(), + ProxySettings: handler.ProxySettings(), + }) + } + return response, nil +} + func (s *handlerServer) mustEmbedUnimplementedHandlerServiceServer() {} type service struct { diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index a98da103..f4219d91 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -364,6 +364,87 @@ func (*AlterInboundResponse) Descriptor() ([]byte, []int) { return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{7} } +type ListInboundsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListInboundsRequest) Reset() { + *x = ListInboundsRequest{} + mi := &file_app_proxyman_command_command_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListInboundsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListInboundsRequest) ProtoMessage() {} + +func (x *ListInboundsRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_proxyman_command_command_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListInboundsRequest.ProtoReflect.Descriptor instead. +func (*ListInboundsRequest) Descriptor() ([]byte, []int) { + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{8} +} + +type ListInboundsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Inbounds []*core.InboundHandlerConfig `protobuf:"bytes,1,rep,name=inbounds,proto3" json:"inbounds,omitempty"` +} + +func (x *ListInboundsResponse) Reset() { + *x = ListInboundsResponse{} + mi := &file_app_proxyman_command_command_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListInboundsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListInboundsResponse) ProtoMessage() {} + +func (x *ListInboundsResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_proxyman_command_command_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListInboundsResponse.ProtoReflect.Descriptor instead. +func (*ListInboundsResponse) Descriptor() ([]byte, []int) { + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{9} +} + +func (x *ListInboundsResponse) GetInbounds() []*core.InboundHandlerConfig { + if x != nil { + return x.Inbounds + } + return nil +} + type GetInboundUserRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -375,7 +456,7 @@ type GetInboundUserRequest struct { func (x *GetInboundUserRequest) Reset() { *x = GetInboundUserRequest{} - mi := &file_app_proxyman_command_command_proto_msgTypes[8] + mi := &file_app_proxyman_command_command_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -387,7 +468,7 @@ func (x *GetInboundUserRequest) String() string { func (*GetInboundUserRequest) ProtoMessage() {} func (x *GetInboundUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[8] + mi := &file_app_proxyman_command_command_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -400,7 +481,7 @@ func (x *GetInboundUserRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetInboundUserRequest.ProtoReflect.Descriptor instead. func (*GetInboundUserRequest) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{8} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{10} } func (x *GetInboundUserRequest) GetTag() string { @@ -427,7 +508,7 @@ type GetInboundUserResponse struct { func (x *GetInboundUserResponse) Reset() { *x = GetInboundUserResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[9] + mi := &file_app_proxyman_command_command_proto_msgTypes[11] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -439,7 +520,7 @@ func (x *GetInboundUserResponse) String() string { func (*GetInboundUserResponse) ProtoMessage() {} func (x *GetInboundUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[9] + mi := &file_app_proxyman_command_command_proto_msgTypes[11] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -452,7 +533,7 @@ func (x *GetInboundUserResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetInboundUserResponse.ProtoReflect.Descriptor instead. func (*GetInboundUserResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{9} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{11} } func (x *GetInboundUserResponse) GetUsers() []*protocol.User { @@ -472,7 +553,7 @@ type GetInboundUsersCountResponse struct { func (x *GetInboundUsersCountResponse) Reset() { *x = GetInboundUsersCountResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[10] + mi := &file_app_proxyman_command_command_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -484,7 +565,7 @@ func (x *GetInboundUsersCountResponse) String() string { func (*GetInboundUsersCountResponse) ProtoMessage() {} func (x *GetInboundUsersCountResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[10] + mi := &file_app_proxyman_command_command_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -497,7 +578,7 @@ func (x *GetInboundUsersCountResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetInboundUsersCountResponse.ProtoReflect.Descriptor instead. func (*GetInboundUsersCountResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{10} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{12} } func (x *GetInboundUsersCountResponse) GetCount() int64 { @@ -517,7 +598,7 @@ type AddOutboundRequest struct { func (x *AddOutboundRequest) Reset() { *x = AddOutboundRequest{} - mi := &file_app_proxyman_command_command_proto_msgTypes[11] + mi := &file_app_proxyman_command_command_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -529,7 +610,7 @@ func (x *AddOutboundRequest) String() string { func (*AddOutboundRequest) ProtoMessage() {} func (x *AddOutboundRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[11] + mi := &file_app_proxyman_command_command_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -542,7 +623,7 @@ func (x *AddOutboundRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AddOutboundRequest.ProtoReflect.Descriptor instead. func (*AddOutboundRequest) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{11} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{13} } func (x *AddOutboundRequest) GetOutbound() *core.OutboundHandlerConfig { @@ -560,7 +641,7 @@ type AddOutboundResponse struct { func (x *AddOutboundResponse) Reset() { *x = AddOutboundResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[12] + mi := &file_app_proxyman_command_command_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -572,7 +653,7 @@ func (x *AddOutboundResponse) String() string { func (*AddOutboundResponse) ProtoMessage() {} func (x *AddOutboundResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[12] + mi := &file_app_proxyman_command_command_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -585,7 +666,7 @@ func (x *AddOutboundResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AddOutboundResponse.ProtoReflect.Descriptor instead. func (*AddOutboundResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{12} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{14} } type RemoveOutboundRequest struct { @@ -598,7 +679,7 @@ type RemoveOutboundRequest struct { func (x *RemoveOutboundRequest) Reset() { *x = RemoveOutboundRequest{} - mi := &file_app_proxyman_command_command_proto_msgTypes[13] + mi := &file_app_proxyman_command_command_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -610,7 +691,7 @@ func (x *RemoveOutboundRequest) String() string { func (*RemoveOutboundRequest) ProtoMessage() {} func (x *RemoveOutboundRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[13] + mi := &file_app_proxyman_command_command_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -623,7 +704,7 @@ func (x *RemoveOutboundRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveOutboundRequest.ProtoReflect.Descriptor instead. func (*RemoveOutboundRequest) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{13} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{15} } func (x *RemoveOutboundRequest) GetTag() string { @@ -641,7 +722,7 @@ type RemoveOutboundResponse struct { func (x *RemoveOutboundResponse) Reset() { *x = RemoveOutboundResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[14] + mi := &file_app_proxyman_command_command_proto_msgTypes[16] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -653,7 +734,7 @@ func (x *RemoveOutboundResponse) String() string { func (*RemoveOutboundResponse) ProtoMessage() {} func (x *RemoveOutboundResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[14] + mi := &file_app_proxyman_command_command_proto_msgTypes[16] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -666,7 +747,7 @@ func (x *RemoveOutboundResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RemoveOutboundResponse.ProtoReflect.Descriptor instead. func (*RemoveOutboundResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{14} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{16} } type AlterOutboundRequest struct { @@ -680,7 +761,7 @@ type AlterOutboundRequest struct { func (x *AlterOutboundRequest) Reset() { *x = AlterOutboundRequest{} - mi := &file_app_proxyman_command_command_proto_msgTypes[15] + mi := &file_app_proxyman_command_command_proto_msgTypes[17] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -692,7 +773,7 @@ func (x *AlterOutboundRequest) String() string { func (*AlterOutboundRequest) ProtoMessage() {} func (x *AlterOutboundRequest) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[15] + mi := &file_app_proxyman_command_command_proto_msgTypes[17] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -705,7 +786,7 @@ func (x *AlterOutboundRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AlterOutboundRequest.ProtoReflect.Descriptor instead. func (*AlterOutboundRequest) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{15} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{17} } func (x *AlterOutboundRequest) GetTag() string { @@ -730,7 +811,7 @@ type AlterOutboundResponse struct { func (x *AlterOutboundResponse) Reset() { *x = AlterOutboundResponse{} - mi := &file_app_proxyman_command_command_proto_msgTypes[16] + mi := &file_app_proxyman_command_command_proto_msgTypes[18] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -742,7 +823,7 @@ func (x *AlterOutboundResponse) String() string { func (*AlterOutboundResponse) ProtoMessage() {} func (x *AlterOutboundResponse) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[16] + mi := &file_app_proxyman_command_command_proto_msgTypes[18] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -755,7 +836,88 @@ func (x *AlterOutboundResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AlterOutboundResponse.ProtoReflect.Descriptor instead. func (*AlterOutboundResponse) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{16} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{18} +} + +type ListOutboundsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *ListOutboundsRequest) Reset() { + *x = ListOutboundsRequest{} + mi := &file_app_proxyman_command_command_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListOutboundsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListOutboundsRequest) ProtoMessage() {} + +func (x *ListOutboundsRequest) ProtoReflect() protoreflect.Message { + mi := &file_app_proxyman_command_command_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListOutboundsRequest.ProtoReflect.Descriptor instead. +func (*ListOutboundsRequest) Descriptor() ([]byte, []int) { + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{19} +} + +type ListOutboundsResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Outbounds []*core.OutboundHandlerConfig `protobuf:"bytes,1,rep,name=outbounds,proto3" json:"outbounds,omitempty"` +} + +func (x *ListOutboundsResponse) Reset() { + *x = ListOutboundsResponse{} + mi := &file_app_proxyman_command_command_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ListOutboundsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ListOutboundsResponse) ProtoMessage() {} + +func (x *ListOutboundsResponse) ProtoReflect() protoreflect.Message { + mi := &file_app_proxyman_command_command_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ListOutboundsResponse.ProtoReflect.Descriptor instead. +func (*ListOutboundsResponse) Descriptor() ([]byte, []int) { + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{20} +} + +func (x *ListOutboundsResponse) GetOutbounds() []*core.OutboundHandlerConfig { + if x != nil { + return x.Outbounds + } + return nil } type Config struct { @@ -766,7 +928,7 @@ type Config struct { func (x *Config) Reset() { *x = Config{} - mi := &file_app_proxyman_command_command_proto_msgTypes[17] + mi := &file_app_proxyman_command_command_proto_msgTypes[21] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -778,7 +940,7 @@ func (x *Config) String() string { func (*Config) ProtoMessage() {} func (x *Config) ProtoReflect() protoreflect.Message { - mi := &file_app_proxyman_command_command_proto_msgTypes[17] + mi := &file_app_proxyman_command_command_proto_msgTypes[21] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -791,7 +953,7 @@ func (x *Config) ProtoReflect() protoreflect.Message { // Deprecated: Use Config.ProtoReflect.Descriptor instead. func (*Config) Descriptor() ([]byte, []int) { - return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{17} + return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{21} } var File_app_proxyman_command_command_proto protoreflect.FileDescriptor @@ -831,61 +993,82 @@ var file_app_proxyman_command_command_proto_rawDesc = []byte{ 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x16, 0x0a, 0x14, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3f, 0x0a, 0x15, - 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x4a, 0x0a, - 0x16, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x22, 0x34, 0x0a, 0x1c, 0x47, 0x65, 0x74, - 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, - 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, - 0x52, 0x0a, 0x12, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, - 0x6f, 0x72, 0x65, 0x2e, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, - 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, - 0x75, 0x6e, 0x64, 0x22, 0x15, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, - 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x15, 0x52, 0x65, - 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x15, 0x0a, 0x13, + 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x22, 0x53, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, + 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x08, 0x69, + 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, + 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x22, 0x3f, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x49, + 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x74, 0x61, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x4a, 0x0a, 0x16, 0x47, 0x65, 0x74, + 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x05, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x05, + 0x75, 0x73, 0x65, 0x72, 0x73, 0x22, 0x34, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, + 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x52, 0x0a, 0x12, 0x41, + 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x3c, 0x0a, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, + 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x08, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x22, + 0x15, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x0a, 0x15, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, + 0x67, 0x22, 0x18, 0x0a, 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, 0x75, 0x74, 0x62, 0x6f, + 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x68, 0x0a, 0x14, 0x41, + 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x74, 0x61, 0x67, 0x22, 0x18, 0x0a, 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x4f, - 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x68, 0x0a, 0x14, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x3e, 0x0a, 0x09, 0x6f, 0x70, 0x65, - 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, - 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, - 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x17, 0x0a, 0x15, 0x41, 0x6c, 0x74, - 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xc5, 0x07, 0x0a, - 0x0e, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x6b, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2c, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, - 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x78, 0x72, + 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x3e, 0x0a, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, + 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x17, 0x0a, 0x15, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, + 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x16, + 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x57, 0x0a, 0x15, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x75, + 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x3e, 0x0a, 0x09, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x4f, + 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x48, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x52, 0x09, 0x6f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x22, + 0x08, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x32, 0xae, 0x09, 0x0a, 0x0e, 0x48, 0x61, + 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x6b, 0x0a, 0x0a, + 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2c, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, + 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, 0x0a, 0x0d, 0x52, 0x65, 0x6d, + 0x6f, 0x76, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2f, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x49, 0x6e, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x64, 0x64, 0x49, 0x6e, 0x62, 0x6f, 0x75, - 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, 0x0a, 0x0d, - 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, 0x2f, 0x2e, - 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, - 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, - 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, - 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, - 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x12, 0x71, 0x0a, 0x0c, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, - 0x6e, 0x64, 0x12, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, - 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x49, 0x6e, + 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x71, 0x0a, 0x0c, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x12, + 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, + 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, + 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x71, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, + 0x64, 0x73, 0x12, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, + 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, - 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, - 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x4c, + 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x78, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, @@ -924,14 +1107,22 @@ var file_app_proxyman_command_command_proto_rawDesc = []byte{ 0x1a, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x2e, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x42, 0x6d, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, - 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2f, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x19, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, - 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x74, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x75, 0x74, 0x62, + 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x12, 0x2f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, + 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4f, 0x75, 0x74, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x6d, 0x0a, 0x1d, 0x63, 0x6f, + 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x6d, 0x61, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x50, 0x01, 0x5a, 0x2e, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, + 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x70, 0x72, 0x6f, + 0x78, 0x79, 0x6d, 0x61, 0x6e, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0xaa, 0x02, 0x19, + 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x6d, 0x61, + 0x6e, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( @@ -946,7 +1137,7 @@ func file_app_proxyman_command_command_proto_rawDescGZIP() []byte { return file_app_proxyman_command_command_proto_rawDescData } -var file_app_proxyman_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 18) +var file_app_proxyman_command_command_proto_msgTypes = make([]protoimpl.MessageInfo, 22) var file_app_proxyman_command_command_proto_goTypes = []any{ (*AddUserOperation)(nil), // 0: xray.app.proxyman.command.AddUserOperation (*RemoveUserOperation)(nil), // 1: xray.app.proxyman.command.RemoveUserOperation @@ -956,49 +1147,59 @@ var file_app_proxyman_command_command_proto_goTypes = []any{ (*RemoveInboundResponse)(nil), // 5: xray.app.proxyman.command.RemoveInboundResponse (*AlterInboundRequest)(nil), // 6: xray.app.proxyman.command.AlterInboundRequest (*AlterInboundResponse)(nil), // 7: xray.app.proxyman.command.AlterInboundResponse - (*GetInboundUserRequest)(nil), // 8: xray.app.proxyman.command.GetInboundUserRequest - (*GetInboundUserResponse)(nil), // 9: xray.app.proxyman.command.GetInboundUserResponse - (*GetInboundUsersCountResponse)(nil), // 10: xray.app.proxyman.command.GetInboundUsersCountResponse - (*AddOutboundRequest)(nil), // 11: xray.app.proxyman.command.AddOutboundRequest - (*AddOutboundResponse)(nil), // 12: xray.app.proxyman.command.AddOutboundResponse - (*RemoveOutboundRequest)(nil), // 13: xray.app.proxyman.command.RemoveOutboundRequest - (*RemoveOutboundResponse)(nil), // 14: xray.app.proxyman.command.RemoveOutboundResponse - (*AlterOutboundRequest)(nil), // 15: xray.app.proxyman.command.AlterOutboundRequest - (*AlterOutboundResponse)(nil), // 16: xray.app.proxyman.command.AlterOutboundResponse - (*Config)(nil), // 17: xray.app.proxyman.command.Config - (*protocol.User)(nil), // 18: xray.common.protocol.User - (*core.InboundHandlerConfig)(nil), // 19: xray.core.InboundHandlerConfig - (*serial.TypedMessage)(nil), // 20: xray.common.serial.TypedMessage - (*core.OutboundHandlerConfig)(nil), // 21: xray.core.OutboundHandlerConfig + (*ListInboundsRequest)(nil), // 8: xray.app.proxyman.command.ListInboundsRequest + (*ListInboundsResponse)(nil), // 9: xray.app.proxyman.command.ListInboundsResponse + (*GetInboundUserRequest)(nil), // 10: xray.app.proxyman.command.GetInboundUserRequest + (*GetInboundUserResponse)(nil), // 11: xray.app.proxyman.command.GetInboundUserResponse + (*GetInboundUsersCountResponse)(nil), // 12: xray.app.proxyman.command.GetInboundUsersCountResponse + (*AddOutboundRequest)(nil), // 13: xray.app.proxyman.command.AddOutboundRequest + (*AddOutboundResponse)(nil), // 14: xray.app.proxyman.command.AddOutboundResponse + (*RemoveOutboundRequest)(nil), // 15: xray.app.proxyman.command.RemoveOutboundRequest + (*RemoveOutboundResponse)(nil), // 16: xray.app.proxyman.command.RemoveOutboundResponse + (*AlterOutboundRequest)(nil), // 17: xray.app.proxyman.command.AlterOutboundRequest + (*AlterOutboundResponse)(nil), // 18: xray.app.proxyman.command.AlterOutboundResponse + (*ListOutboundsRequest)(nil), // 19: xray.app.proxyman.command.ListOutboundsRequest + (*ListOutboundsResponse)(nil), // 20: xray.app.proxyman.command.ListOutboundsResponse + (*Config)(nil), // 21: xray.app.proxyman.command.Config + (*protocol.User)(nil), // 22: xray.common.protocol.User + (*core.InboundHandlerConfig)(nil), // 23: xray.core.InboundHandlerConfig + (*serial.TypedMessage)(nil), // 24: xray.common.serial.TypedMessage + (*core.OutboundHandlerConfig)(nil), // 25: xray.core.OutboundHandlerConfig } var file_app_proxyman_command_command_proto_depIdxs = []int32{ - 18, // 0: xray.app.proxyman.command.AddUserOperation.user:type_name -> xray.common.protocol.User - 19, // 1: xray.app.proxyman.command.AddInboundRequest.inbound:type_name -> xray.core.InboundHandlerConfig - 20, // 2: xray.app.proxyman.command.AlterInboundRequest.operation:type_name -> xray.common.serial.TypedMessage - 18, // 3: xray.app.proxyman.command.GetInboundUserResponse.users:type_name -> xray.common.protocol.User - 21, // 4: xray.app.proxyman.command.AddOutboundRequest.outbound:type_name -> xray.core.OutboundHandlerConfig - 20, // 5: xray.app.proxyman.command.AlterOutboundRequest.operation:type_name -> xray.common.serial.TypedMessage - 2, // 6: xray.app.proxyman.command.HandlerService.AddInbound:input_type -> xray.app.proxyman.command.AddInboundRequest - 4, // 7: xray.app.proxyman.command.HandlerService.RemoveInbound:input_type -> xray.app.proxyman.command.RemoveInboundRequest - 6, // 8: xray.app.proxyman.command.HandlerService.AlterInbound:input_type -> xray.app.proxyman.command.AlterInboundRequest - 8, // 9: xray.app.proxyman.command.HandlerService.GetInboundUsers:input_type -> xray.app.proxyman.command.GetInboundUserRequest - 8, // 10: xray.app.proxyman.command.HandlerService.GetInboundUsersCount:input_type -> xray.app.proxyman.command.GetInboundUserRequest - 11, // 11: xray.app.proxyman.command.HandlerService.AddOutbound:input_type -> xray.app.proxyman.command.AddOutboundRequest - 13, // 12: xray.app.proxyman.command.HandlerService.RemoveOutbound:input_type -> xray.app.proxyman.command.RemoveOutboundRequest - 15, // 13: xray.app.proxyman.command.HandlerService.AlterOutbound:input_type -> xray.app.proxyman.command.AlterOutboundRequest - 3, // 14: xray.app.proxyman.command.HandlerService.AddInbound:output_type -> xray.app.proxyman.command.AddInboundResponse - 5, // 15: xray.app.proxyman.command.HandlerService.RemoveInbound:output_type -> xray.app.proxyman.command.RemoveInboundResponse - 7, // 16: xray.app.proxyman.command.HandlerService.AlterInbound:output_type -> xray.app.proxyman.command.AlterInboundResponse - 9, // 17: xray.app.proxyman.command.HandlerService.GetInboundUsers:output_type -> xray.app.proxyman.command.GetInboundUserResponse - 10, // 18: xray.app.proxyman.command.HandlerService.GetInboundUsersCount:output_type -> xray.app.proxyman.command.GetInboundUsersCountResponse - 12, // 19: xray.app.proxyman.command.HandlerService.AddOutbound:output_type -> xray.app.proxyman.command.AddOutboundResponse - 14, // 20: xray.app.proxyman.command.HandlerService.RemoveOutbound:output_type -> xray.app.proxyman.command.RemoveOutboundResponse - 16, // 21: xray.app.proxyman.command.HandlerService.AlterOutbound:output_type -> xray.app.proxyman.command.AlterOutboundResponse - 14, // [14:22] is the sub-list for method output_type - 6, // [6:14] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 22, // 0: xray.app.proxyman.command.AddUserOperation.user:type_name -> xray.common.protocol.User + 23, // 1: xray.app.proxyman.command.AddInboundRequest.inbound:type_name -> xray.core.InboundHandlerConfig + 24, // 2: xray.app.proxyman.command.AlterInboundRequest.operation:type_name -> xray.common.serial.TypedMessage + 23, // 3: xray.app.proxyman.command.ListInboundsResponse.inbounds:type_name -> xray.core.InboundHandlerConfig + 22, // 4: xray.app.proxyman.command.GetInboundUserResponse.users:type_name -> xray.common.protocol.User + 25, // 5: xray.app.proxyman.command.AddOutboundRequest.outbound:type_name -> xray.core.OutboundHandlerConfig + 24, // 6: xray.app.proxyman.command.AlterOutboundRequest.operation:type_name -> xray.common.serial.TypedMessage + 25, // 7: xray.app.proxyman.command.ListOutboundsResponse.outbounds:type_name -> xray.core.OutboundHandlerConfig + 2, // 8: xray.app.proxyman.command.HandlerService.AddInbound:input_type -> xray.app.proxyman.command.AddInboundRequest + 4, // 9: xray.app.proxyman.command.HandlerService.RemoveInbound:input_type -> xray.app.proxyman.command.RemoveInboundRequest + 6, // 10: xray.app.proxyman.command.HandlerService.AlterInbound:input_type -> xray.app.proxyman.command.AlterInboundRequest + 8, // 11: xray.app.proxyman.command.HandlerService.ListInbounds:input_type -> xray.app.proxyman.command.ListInboundsRequest + 10, // 12: xray.app.proxyman.command.HandlerService.GetInboundUsers:input_type -> xray.app.proxyman.command.GetInboundUserRequest + 10, // 13: xray.app.proxyman.command.HandlerService.GetInboundUsersCount:input_type -> xray.app.proxyman.command.GetInboundUserRequest + 13, // 14: xray.app.proxyman.command.HandlerService.AddOutbound:input_type -> xray.app.proxyman.command.AddOutboundRequest + 15, // 15: xray.app.proxyman.command.HandlerService.RemoveOutbound:input_type -> xray.app.proxyman.command.RemoveOutboundRequest + 17, // 16: xray.app.proxyman.command.HandlerService.AlterOutbound:input_type -> xray.app.proxyman.command.AlterOutboundRequest + 19, // 17: xray.app.proxyman.command.HandlerService.ListOutbounds:input_type -> xray.app.proxyman.command.ListOutboundsRequest + 3, // 18: xray.app.proxyman.command.HandlerService.AddInbound:output_type -> xray.app.proxyman.command.AddInboundResponse + 5, // 19: xray.app.proxyman.command.HandlerService.RemoveInbound:output_type -> xray.app.proxyman.command.RemoveInboundResponse + 7, // 20: xray.app.proxyman.command.HandlerService.AlterInbound:output_type -> xray.app.proxyman.command.AlterInboundResponse + 9, // 21: xray.app.proxyman.command.HandlerService.ListInbounds:output_type -> xray.app.proxyman.command.ListInboundsResponse + 11, // 22: xray.app.proxyman.command.HandlerService.GetInboundUsers:output_type -> xray.app.proxyman.command.GetInboundUserResponse + 12, // 23: xray.app.proxyman.command.HandlerService.GetInboundUsersCount:output_type -> xray.app.proxyman.command.GetInboundUsersCountResponse + 14, // 24: xray.app.proxyman.command.HandlerService.AddOutbound:output_type -> xray.app.proxyman.command.AddOutboundResponse + 16, // 25: xray.app.proxyman.command.HandlerService.RemoveOutbound:output_type -> xray.app.proxyman.command.RemoveOutboundResponse + 18, // 26: xray.app.proxyman.command.HandlerService.AlterOutbound:output_type -> xray.app.proxyman.command.AlterOutboundResponse + 20, // 27: xray.app.proxyman.command.HandlerService.ListOutbounds:output_type -> xray.app.proxyman.command.ListOutboundsResponse + 18, // [18:28] is the sub-list for method output_type + 8, // [8:18] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_app_proxyman_command_command_proto_init() } @@ -1012,7 +1213,7 @@ func file_app_proxyman_command_command_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_app_proxyman_command_command_proto_rawDesc, NumEnums: 0, - NumMessages: 18, + NumMessages: 22, NumExtensions: 0, NumServices: 1, }, diff --git a/app/proxyman/command/command.proto b/app/proxyman/command/command.proto index 9a2d0142..4ff499eb 100644 --- a/app/proxyman/command/command.proto +++ b/app/proxyman/command/command.proto @@ -37,6 +37,12 @@ message AlterInboundRequest { message AlterInboundResponse {} +message ListInboundsRequest {} + +message ListInboundsResponse { + repeated core.InboundHandlerConfig inbounds = 1; +} + message GetInboundUserRequest { string tag = 1; string email = 2; @@ -69,6 +75,12 @@ message AlterOutboundRequest { message AlterOutboundResponse {} +message ListOutboundsRequest {} + +message ListOutboundsResponse { + repeated core.OutboundHandlerConfig outbounds = 1; +} + service HandlerService { rpc AddInbound(AddInboundRequest) returns (AddInboundResponse) {} @@ -76,6 +88,8 @@ service HandlerService { rpc AlterInbound(AlterInboundRequest) returns (AlterInboundResponse) {} + rpc ListInbounds(ListInboundsRequest) returns (ListInboundsResponse) {} + rpc GetInboundUsers(GetInboundUserRequest) returns (GetInboundUserResponse) {} rpc GetInboundUsersCount(GetInboundUserRequest) returns (GetInboundUsersCountResponse) {} @@ -85,6 +99,8 @@ service HandlerService { rpc RemoveOutbound(RemoveOutboundRequest) returns (RemoveOutboundResponse) {} rpc AlterOutbound(AlterOutboundRequest) returns (AlterOutboundResponse) {} + + rpc ListOutbounds(ListOutboundsRequest) returns (ListOutboundsResponse) {} } message Config {} diff --git a/app/proxyman/command/command_grpc.pb.go b/app/proxyman/command/command_grpc.pb.go index 7abbae8e..8bc48f0a 100644 --- a/app/proxyman/command/command_grpc.pb.go +++ b/app/proxyman/command/command_grpc.pb.go @@ -22,11 +22,13 @@ const ( HandlerService_AddInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddInbound" HandlerService_RemoveInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveInbound" HandlerService_AlterInbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterInbound" + HandlerService_ListInbounds_FullMethodName = "/xray.app.proxyman.command.HandlerService/ListInbounds" HandlerService_GetInboundUsers_FullMethodName = "/xray.app.proxyman.command.HandlerService/GetInboundUsers" HandlerService_GetInboundUsersCount_FullMethodName = "/xray.app.proxyman.command.HandlerService/GetInboundUsersCount" HandlerService_AddOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AddOutbound" HandlerService_RemoveOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/RemoveOutbound" HandlerService_AlterOutbound_FullMethodName = "/xray.app.proxyman.command.HandlerService/AlterOutbound" + HandlerService_ListOutbounds_FullMethodName = "/xray.app.proxyman.command.HandlerService/ListOutbounds" ) // HandlerServiceClient is the client API for HandlerService service. @@ -36,11 +38,13 @@ type HandlerServiceClient interface { AddInbound(ctx context.Context, in *AddInboundRequest, opts ...grpc.CallOption) (*AddInboundResponse, error) RemoveInbound(ctx context.Context, in *RemoveInboundRequest, opts ...grpc.CallOption) (*RemoveInboundResponse, error) AlterInbound(ctx context.Context, in *AlterInboundRequest, opts ...grpc.CallOption) (*AlterInboundResponse, error) + ListInbounds(ctx context.Context, in *ListInboundsRequest, opts ...grpc.CallOption) (*ListInboundsResponse, error) GetInboundUsers(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUserResponse, error) GetInboundUsersCount(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUsersCountResponse, error) AddOutbound(ctx context.Context, in *AddOutboundRequest, opts ...grpc.CallOption) (*AddOutboundResponse, error) RemoveOutbound(ctx context.Context, in *RemoveOutboundRequest, opts ...grpc.CallOption) (*RemoveOutboundResponse, error) AlterOutbound(ctx context.Context, in *AlterOutboundRequest, opts ...grpc.CallOption) (*AlterOutboundResponse, error) + ListOutbounds(ctx context.Context, in *ListOutboundsRequest, opts ...grpc.CallOption) (*ListOutboundsResponse, error) } type handlerServiceClient struct { @@ -81,6 +85,16 @@ func (c *handlerServiceClient) AlterInbound(ctx context.Context, in *AlterInboun return out, nil } +func (c *handlerServiceClient) ListInbounds(ctx context.Context, in *ListInboundsRequest, opts ...grpc.CallOption) (*ListInboundsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListInboundsResponse) + err := c.cc.Invoke(ctx, HandlerService_ListInbounds_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *handlerServiceClient) GetInboundUsers(ctx context.Context, in *GetInboundUserRequest, opts ...grpc.CallOption) (*GetInboundUserResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetInboundUserResponse) @@ -131,6 +145,16 @@ func (c *handlerServiceClient) AlterOutbound(ctx context.Context, in *AlterOutbo return out, nil } +func (c *handlerServiceClient) ListOutbounds(ctx context.Context, in *ListOutboundsRequest, opts ...grpc.CallOption) (*ListOutboundsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ListOutboundsResponse) + err := c.cc.Invoke(ctx, HandlerService_ListOutbounds_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // HandlerServiceServer is the server API for HandlerService service. // All implementations must embed UnimplementedHandlerServiceServer // for forward compatibility. @@ -138,11 +162,13 @@ type HandlerServiceServer interface { AddInbound(context.Context, *AddInboundRequest) (*AddInboundResponse, error) RemoveInbound(context.Context, *RemoveInboundRequest) (*RemoveInboundResponse, error) AlterInbound(context.Context, *AlterInboundRequest) (*AlterInboundResponse, error) + ListInbounds(context.Context, *ListInboundsRequest) (*ListInboundsResponse, error) GetInboundUsers(context.Context, *GetInboundUserRequest) (*GetInboundUserResponse, error) GetInboundUsersCount(context.Context, *GetInboundUserRequest) (*GetInboundUsersCountResponse, error) AddOutbound(context.Context, *AddOutboundRequest) (*AddOutboundResponse, error) RemoveOutbound(context.Context, *RemoveOutboundRequest) (*RemoveOutboundResponse, error) AlterOutbound(context.Context, *AlterOutboundRequest) (*AlterOutboundResponse, error) + ListOutbounds(context.Context, *ListOutboundsRequest) (*ListOutboundsResponse, error) mustEmbedUnimplementedHandlerServiceServer() } @@ -162,6 +188,9 @@ func (UnimplementedHandlerServiceServer) RemoveInbound(context.Context, *RemoveI func (UnimplementedHandlerServiceServer) AlterInbound(context.Context, *AlterInboundRequest) (*AlterInboundResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AlterInbound not implemented") } +func (UnimplementedHandlerServiceServer) ListInbounds(context.Context, *ListInboundsRequest) (*ListInboundsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListInbounds not implemented") +} func (UnimplementedHandlerServiceServer) GetInboundUsers(context.Context, *GetInboundUserRequest) (*GetInboundUserResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetInboundUsers not implemented") } @@ -177,6 +206,9 @@ func (UnimplementedHandlerServiceServer) RemoveOutbound(context.Context, *Remove func (UnimplementedHandlerServiceServer) AlterOutbound(context.Context, *AlterOutboundRequest) (*AlterOutboundResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AlterOutbound not implemented") } +func (UnimplementedHandlerServiceServer) ListOutbounds(context.Context, *ListOutboundsRequest) (*ListOutboundsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListOutbounds not implemented") +} func (UnimplementedHandlerServiceServer) mustEmbedUnimplementedHandlerServiceServer() {} func (UnimplementedHandlerServiceServer) testEmbeddedByValue() {} @@ -252,6 +284,24 @@ func _HandlerService_AlterInbound_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _HandlerService_ListInbounds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListInboundsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HandlerServiceServer).ListInbounds(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HandlerService_ListInbounds_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HandlerServiceServer).ListInbounds(ctx, req.(*ListInboundsRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _HandlerService_GetInboundUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetInboundUserRequest) if err := dec(in); err != nil { @@ -342,6 +392,24 @@ func _HandlerService_AlterOutbound_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _HandlerService_ListOutbounds_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListOutboundsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(HandlerServiceServer).ListOutbounds(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: HandlerService_ListOutbounds_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(HandlerServiceServer).ListOutbounds(ctx, req.(*ListOutboundsRequest)) + } + return interceptor(ctx, in, info, handler) +} + // HandlerService_ServiceDesc is the grpc.ServiceDesc for HandlerService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -361,6 +429,10 @@ var HandlerService_ServiceDesc = grpc.ServiceDesc{ MethodName: "AlterInbound", Handler: _HandlerService_AlterInbound_Handler, }, + { + MethodName: "ListInbounds", + Handler: _HandlerService_ListInbounds_Handler, + }, { MethodName: "GetInboundUsers", Handler: _HandlerService_GetInboundUsers_Handler, @@ -381,6 +453,10 @@ var HandlerService_ServiceDesc = grpc.ServiceDesc{ MethodName: "AlterOutbound", Handler: _HandlerService_AlterOutbound_Handler, }, + { + MethodName: "ListOutbounds", + Handler: _HandlerService_ListOutbounds_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "app/proxyman/command/command.proto", diff --git a/app/proxyman/inbound/always.go b/app/proxyman/inbound/always.go index ff585c87..f6a769fb 100644 --- a/app/proxyman/inbound/always.go +++ b/app/proxyman/inbound/always.go @@ -9,11 +9,13 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/mux" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/policy" "github.com/xtls/xray-core/features/stats" "github.com/xtls/xray-core/proxy" "github.com/xtls/xray-core/transport/internet" + "google.golang.org/protobuf/proto" ) func getStatCounter(v *core.Instance, tag string) (stats.Counter, stats.Counter) { @@ -42,10 +44,12 @@ func getStatCounter(v *core.Instance, tag string) (stats.Counter, stats.Counter) } type AlwaysOnInboundHandler struct { - proxy proxy.Inbound - workers []worker - mux *mux.Server - tag string + proxyConfig interface{} + receiverConfig *proxyman.ReceiverConfig + proxy proxy.Inbound + workers []worker + mux *mux.Server + tag string } func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig *proxyman.ReceiverConfig, proxyConfig interface{}) (*AlwaysOnInboundHandler, error) { @@ -59,9 +63,11 @@ func NewAlwaysOnInboundHandler(ctx context.Context, tag string, receiverConfig * } h := &AlwaysOnInboundHandler{ - proxy: p, - mux: mux.NewServer(ctx), - tag: tag, + receiverConfig: receiverConfig, + proxyConfig: proxyConfig, + proxy: p, + mux: mux.NewServer(ctx), + tag: tag, } uplinkCounter, downlinkCounter := getStatCounter(core.MustFromContext(ctx), tag) @@ -187,3 +193,16 @@ func (h *AlwaysOnInboundHandler) Tag() string { func (h *AlwaysOnInboundHandler) GetInbound() proxy.Inbound { return h.proxy } + +// ReceiverSettings implements inbound.Handler. +func (h *AlwaysOnInboundHandler) ReceiverSettings() *serial.TypedMessage { + return serial.ToTypedMessage(h.receiverConfig) +} + +// ProxySettings implements inbound.Handler. +func (h *AlwaysOnInboundHandler) ProxySettings() *serial.TypedMessage { + if v, ok := h.proxyConfig.(proto.Message); ok { + return serial.ToTypedMessage(v) + } + return nil +} diff --git a/app/proxyman/inbound/dynamic.go b/app/proxyman/inbound/dynamic.go index 9bf49717..f14a9952 100644 --- a/app/proxyman/inbound/dynamic.go +++ b/app/proxyman/inbound/dynamic.go @@ -10,10 +10,12 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/mux" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/task" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/proxy" "github.com/xtls/xray-core/transport/internet" + "google.golang.org/protobuf/proto" ) type DynamicInboundHandler struct { @@ -205,3 +207,16 @@ func (h *DynamicInboundHandler) GetRandomInboundProxy() (interface{}, net.Port, func (h *DynamicInboundHandler) Tag() string { return h.tag } + +// ReceiverSettings implements inbound.Handler. +func (h *DynamicInboundHandler) ReceiverSettings() *serial.TypedMessage { + return serial.ToTypedMessage(h.receiverConfig) +} + +// ProxySettings implements inbound.Handler. +func (h *DynamicInboundHandler) ProxySettings() *serial.TypedMessage { + if v, ok := h.proxyConfig.(proto.Message); ok { + return serial.ToTypedMessage(v) + } + return nil +} diff --git a/app/proxyman/inbound/inbound.go b/app/proxyman/inbound/inbound.go index 2148f423..5d64c5b2 100644 --- a/app/proxyman/inbound/inbound.go +++ b/app/proxyman/inbound/inbound.go @@ -89,6 +89,21 @@ func (m *Manager) RemoveHandler(ctx context.Context, tag string) error { return common.ErrNoClue } +// ListHandlers implements inbound.Manager. +func (m *Manager) ListHandlers(ctx context.Context) []inbound.Handler { + m.access.RLock() + defer m.access.RUnlock() + + var response []inbound.Handler + copy(m.untaggedHandler, response) + + for _, v := range m.taggedHandlers { + response = append(response, v) + } + + return response +} + // Start implements common.Runnable. func (m *Manager) Start() error { m.access.Lock() diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 9a91480f..45821b0c 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -16,6 +16,7 @@ import ( "github.com/xtls/xray-core/common/mux" "github.com/xtls/xray-core/common/net" "github.com/xtls/xray-core/common/net/cnc" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/core" "github.com/xtls/xray-core/features/outbound" @@ -27,6 +28,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" + "google.golang.org/protobuf/proto" ) func getStatCounter(v *core.Instance, tag string) (stats.Counter, stats.Counter) { @@ -59,6 +61,7 @@ type Handler struct { tag string senderSettings *proxyman.SenderConfig streamSettings *internet.MemoryStreamConfig + proxyConfig proto.Message proxy proxy.Outbound outboundManager outbound.Manager mux *mux.ClientManager @@ -101,6 +104,7 @@ func NewHandler(ctx context.Context, config *core.OutboundHandlerConfig) (outbou if err != nil { return nil, err } + h.proxyConfig = proxyConfig rawProxyHandler, err := common.CreateObject(ctx, proxyConfig) if err != nil { @@ -349,6 +353,16 @@ func (h *Handler) Close() error { return nil } +// SenderSettings implements outbound.Handler. +func (h *Handler) SenderSettings() *serial.TypedMessage { + return serial.ToTypedMessage(h.senderSettings) +} + +// ProxySettings implements outbound.Handler. +func (h *Handler) ProxySettings() *serial.TypedMessage { + return serial.ToTypedMessage(h.proxyConfig) +} + func ParseRandomIP(addr net.Address, prefix string) net.Address { _, ipnet, _ := gonet.ParseCIDR(addr.IP().String() + "/" + prefix) diff --git a/app/proxyman/outbound/outbound.go b/app/proxyman/outbound/outbound.go index 8660e6a5..ed47b778 100644 --- a/app/proxyman/outbound/outbound.go +++ b/app/proxyman/outbound/outbound.go @@ -145,6 +145,21 @@ func (m *Manager) RemoveHandler(ctx context.Context, tag string) error { return nil } +// ListHandlers implements outbound.Manager. +func (m *Manager) ListHandlers(ctx context.Context) []outbound.Handler { + m.access.RLock() + defer m.access.RUnlock() + + var response []outbound.Handler + copy(m.untaggedHandlers, response) + + for _, v := range m.taggedHandler { + response = append(response, v) + } + + return response +} + // Select implements outbound.HandlerSelector. func (m *Manager) Select(selectors []string) []string { diff --git a/app/reverse/portal.go b/app/reverse/portal.go index d57ac29a..818c5718 100644 --- a/app/reverse/portal.go +++ b/app/reverse/portal.go @@ -10,6 +10,7 @@ import ( "github.com/xtls/xray-core/common/errors" "github.com/xtls/xray-core/common/mux" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/common/session" "github.com/xtls/xray-core/common/task" "github.com/xtls/xray-core/features/outbound" @@ -111,6 +112,16 @@ func (o *Outbound) Close() error { return nil } +// SenderSettings implements outbound.Handler. +func (o *Outbound) SenderSettings() *serial.TypedMessage { + return nil +} + +// ProxySettings implements outbound.Handler. +func (o *Outbound) ProxySettings() *serial.TypedMessage { + return nil +} + type StaticMuxPicker struct { access sync.Mutex workers []*PortalWorker diff --git a/features/inbound/inbound.go b/features/inbound/inbound.go index adcf7571..1d3ba7b1 100644 --- a/features/inbound/inbound.go +++ b/features/inbound/inbound.go @@ -5,6 +5,7 @@ import ( "github.com/xtls/xray-core/common" "github.com/xtls/xray-core/common/net" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/features" ) @@ -15,6 +16,10 @@ type Handler interface { common.Runnable // The tag of this handler. Tag() string + // Returns the active receiver settings. + ReceiverSettings() *serial.TypedMessage + // Returns the active proxy settings. + ProxySettings() *serial.TypedMessage // Deprecated: Do not use in new code. GetRandomInboundProxy() (interface{}, net.Port, int) @@ -32,6 +37,9 @@ type Manager interface { // RemoveHandler removes a handler from Manager. RemoveHandler(ctx context.Context, tag string) error + + // ListHandlers returns a list of inbound.Handler. + ListHandlers(ctx context.Context) []Handler } // ManagerType returns the type of Manager interface. Can be used for implementing common.HasType. diff --git a/features/outbound/outbound.go b/features/outbound/outbound.go index ed875439..ecde6e1e 100644 --- a/features/outbound/outbound.go +++ b/features/outbound/outbound.go @@ -4,6 +4,7 @@ import ( "context" "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/common/serial" "github.com/xtls/xray-core/features" "github.com/xtls/xray-core/transport" ) @@ -15,6 +16,8 @@ type Handler interface { common.Runnable Tag() string Dispatch(ctx context.Context, link *transport.Link) + SenderSettings() *serial.TypedMessage + ProxySettings() *serial.TypedMessage } type HandlerSelector interface { @@ -35,6 +38,9 @@ type Manager interface { // RemoveHandler removes a handler from outbound.Manager. RemoveHandler(ctx context.Context, tag string) error + + // ListHandlers returns a list of outbound.Handler. + ListHandlers(ctx context.Context) []Handler } // ManagerType returns the type of Manager interface. Can be used to implement common.HasType. diff --git a/main/commands/all/api/api.go b/main/commands/all/api/api.go index 8188d071..14a7c564 100644 --- a/main/commands/all/api/api.go +++ b/main/commands/all/api/api.go @@ -21,6 +21,8 @@ var CmdAPI = &base.Command{ cmdAddOutbounds, cmdRemoveInbounds, cmdRemoveOutbounds, + cmdListInbounds, + cmdListOutbounds, cmdInboundUser, cmdInboundUserCount, cmdAddRules, diff --git a/main/commands/all/api/inbounds_list.go b/main/commands/all/api/inbounds_list.go new file mode 100644 index 00000000..e4267a6b --- /dev/null +++ b/main/commands/all/api/inbounds_list.go @@ -0,0 +1,44 @@ +package api + +import ( + handlerService "github.com/xtls/xray-core/app/proxyman/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdListInbounds = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api lsi [--server=127.0.0.1:8080]", + Short: "List inbounds", + Long: ` +List inbounds in Xray. + +Arguments: + + -s, -server + The API server address. Default 127.0.0.1:8080 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + +Example: + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 +`, + Run: executeListInbounds, +} + +func executeListInbounds(cmd *base.Command, args []string) { + setSharedFlags(cmd) + cmd.Flag.Parse(args) + + conn, ctx, close := dialAPIServer() + defer close() + + client := handlerService.NewHandlerServiceClient(conn) + + resp, err := client.ListInbounds(ctx, &handlerService.ListInboundsRequest{}) + if err != nil { + base.Fatalf("failed to list inbounds: %s", err) + } + showJSONResponse(resp) +} diff --git a/main/commands/all/api/outbounds_list.go b/main/commands/all/api/outbounds_list.go new file mode 100644 index 00000000..be7f077b --- /dev/null +++ b/main/commands/all/api/outbounds_list.go @@ -0,0 +1,43 @@ +package api + +import ( + handlerService "github.com/xtls/xray-core/app/proxyman/command" + "github.com/xtls/xray-core/main/commands/base" +) + +var cmdListOutbounds = &base.Command{ + CustomFlags: true, + UsageLine: "{{.Exec}} api lso [--server=127.0.0.1:8080]", + Short: "List outbounds", + Long: ` +List outbounds in Xray. + +Arguments: + + -s, -server + The API server address. Default 127.0.0.1:8080 + + -t, -timeout + Timeout in seconds for calling API. Default 3 + +Example: + + {{.Exec}} {{.LongName}} --server=127.0.0.1:8080 +`, + Run: executeListOutbounds, +} + +func executeListOutbounds(cmd *base.Command, args []string) { + setSharedFlags(cmd) + cmd.Flag.Parse(args) + + conn, ctx, close := dialAPIServer() + defer close() + + client := handlerService.NewHandlerServiceClient(conn) + resp, err := client.ListOutbounds(ctx, &handlerService.ListOutboundsRequest{}) + if err != nil { + base.Fatalf("failed to list outbounds: %s", err) + } + showJSONResponse(resp) +} diff --git a/testing/mocks/outbound.go b/testing/mocks/outbound.go index 4f1083cf..f6352bff 100644 --- a/testing/mocks/outbound.go +++ b/testing/mocks/outbound.go @@ -91,6 +91,20 @@ func (mr *OutboundManagerMockRecorder) GetHandler(arg0 interface{}) *gomock.Call return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetHandler", reflect.TypeOf((*OutboundManager)(nil).GetHandler), arg0) } +// ListHandlers mocks base method +func (m *OutboundManager) ListHandlers(arg0 context.Context) []outbound.Handler { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ListHandlers", arg0) + ret0, _ := ret[0].([]outbound.Handler) + return ret0 +} + +// ListHandlers indicates an expected call of ListHandlers +func (mr *OutboundManagerMockRecorder) ListHandlers(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListHandlers", reflect.TypeOf((*OutboundManager)(nil).ListHandlers), arg0) +} + // RemoveHandler mocks base method func (m *OutboundManager) RemoveHandler(arg0 context.Context, arg1 string) error { m.ctrl.T.Helper() diff --git a/testing/scenarios/command_test.go b/testing/scenarios/command_test.go index 037255a9..e562952b 100644 --- a/testing/scenarios/command_test.go +++ b/testing/scenarios/command_test.go @@ -31,6 +31,7 @@ import ( "github.com/xtls/xray-core/testing/servers/tcp" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + "google.golang.org/protobuf/testing/protocmp" ) func TestCommanderListenConfigurationItem(t *testing.T) { @@ -202,6 +203,104 @@ func TestCommanderRemoveHandler(t *testing.T) { } } +func TestCommanderListHandlers(t *testing.T) { + tcpServer := tcp.Server{ + MsgProcessor: xor, + } + dest, err := tcpServer.Start() + common.Must(err) + defer tcpServer.Close() + + clientPort := tcp.PickPort() + cmdPort := tcp.PickPort() + clientConfig := &core.Config{ + App: []*serial.TypedMessage{ + serial.ToTypedMessage(&commander.Config{ + Tag: "api", + Service: []*serial.TypedMessage{ + serial.ToTypedMessage(&command.Config{}), + }, + }), + serial.ToTypedMessage(&router.Config{ + Rule: []*router.RoutingRule{ + { + InboundTag: []string{"api"}, + TargetTag: &router.RoutingRule_Tag{ + Tag: "api", + }, + }, + }, + }), + }, + Inbound: []*core.InboundHandlerConfig{ + { + Tag: "d", + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(clientPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + }), + ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), + Networks: []net.Network{net.Network_TCP}, + }), + }, + { + Tag: "api", + ReceiverSettings: serial.ToTypedMessage(&proxyman.ReceiverConfig{ + PortList: &net.PortList{Range: []*net.PortRange{net.SinglePortRange(cmdPort)}}, + Listen: net.NewIPOrDomain(net.LocalHostIP), + }), + ProxySettings: serial.ToTypedMessage(&dokodemo.Config{ + Address: net.NewIPOrDomain(dest.Address), + Port: uint32(dest.Port), + Networks: []net.Network{net.Network_TCP}, + }), + }, + }, + Outbound: []*core.OutboundHandlerConfig{ + { + Tag: "default-outbound", + SenderSettings: serial.ToTypedMessage(&proxyman.SenderConfig{}), + ProxySettings: serial.ToTypedMessage(&freedom.Config{}), + }, + }, + } + + servers, err := InitializeServerConfigs(clientConfig) + common.Must(err) + defer CloseAllServers(servers) + + if err := testTCPConn(clientPort, 1024, time.Second*5)(); err != nil { + t.Fatal(err) + } + + cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()) + common.Must(err) + defer cmdConn.Close() + + hsClient := command.NewHandlerServiceClient(cmdConn) + inboundResp, err := hsClient.ListInbounds(context.Background(), &command.ListInboundsRequest{}) + common.Must(err) + if inboundResp == nil { + t.Error("unexpected nil response") + } + + if !cmp.Equal(inboundResp.Inbounds, clientConfig.Inbound, protocmp.Transform()) { + t.Fatal("inbound response doesn't match config") + } + + outboundResp, err := hsClient.ListOutbounds(context.Background(), &command.ListOutboundsRequest{}) + common.Must(err) + if outboundResp == nil { + t.Error("unexpected nil response") + } + + if !cmp.Equal(outboundResp.Outbounds, clientConfig.Outbound, protocmp.Transform()) { + t.Fatal("outbound response doesn't match config") + } +} + func TestCommanderAddRemoveUser(t *testing.T) { tcpServer := tcp.Server{ MsgProcessor: xor, From 028e1114e65db1c6ecd28b86fcfa49b59b845b0e Mon Sep 17 00:00:00 2001 From: Aubrey Yang Date: Fri, 6 Jun 2025 10:54:15 +0900 Subject: [PATCH 840/867] Outbound: Fix sendthrough srcip precheck (#4750) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- app/proxyman/outbound/handler.go | 26 +++++++++++++++----------- infra/conf/xray.go | 3 ++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/proxyman/outbound/handler.go b/app/proxyman/outbound/handler.go index 45821b0c..bc9c635b 100644 --- a/app/proxyman/outbound/handler.go +++ b/app/proxyman/outbound/handler.go @@ -279,11 +279,9 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connecti outbounds := session.OutboundsFromContext(ctx) ob := outbounds[len(outbounds)-1] - addr := h.senderSettings.Via.AsAddress() var domain string - if addr.Family().IsDomain() { - domain = addr.Domain() - } + addr := h.senderSettings.Via.AsAddress() + domain = h.senderSettings.Via.GetDomain() switch { case h.senderSettings.ViaCidr != "": ob.Gateway = ParseRandomIP(addr, h.senderSettings.ViaCidr) @@ -291,18 +289,24 @@ func (h *Handler) Dial(ctx context.Context, dest net.Destination) (stat.Connecti case domain == "origin": if inbound := session.InboundFromContext(ctx); inbound != nil { - origin, _, err := net.SplitHostPort(inbound.Conn.LocalAddr().String()) - if err == nil { - ob.Gateway = net.ParseAddress(origin) + if inbound.Conn != nil { + origin, _, err := net.SplitHostPort(inbound.Conn.LocalAddr().String()) + if err == nil { + ob.Gateway = net.ParseAddress(origin) + errors.LogDebug(ctx, "use receive package ip as snedthrough: ", origin) + } } - } case domain == "srcip": if inbound := session.InboundFromContext(ctx); inbound != nil { - srcip, _, err := net.SplitHostPort(inbound.Conn.RemoteAddr().String()) - if err == nil { - ob.Gateway = net.ParseAddress(srcip) + if inbound.Conn != nil { + clientaddr, _, err := net.SplitHostPort(inbound.Conn.RemoteAddr().String()) + if err == nil { + ob.Gateway = net.ParseAddress(clientaddr) + errors.LogDebug(ctx, "use client src ip as snedthrough: ", clientaddr) + } } + } //case addr.Family().IsDomain(): default: diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 4b084b56..42b8fa4d 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -292,7 +292,8 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) { senderSettings.ViaCidr = strings.Split(*c.SendThrough, "/")[1] } else { if address.Family().IsDomain() { - if address.Address.Domain() != "origin" { + domain := address.Address.Domain() + if domain != "origin" && domain != "srcip" { return nil, errors.New("unable to send through: " + address.String()) } } From 6232e230d9279cfb1b78ab80a16b86975c57ed5f Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Fri, 6 Jun 2025 05:29:16 +0330 Subject: [PATCH 841/867] DNS New Features: `disableCache`, `finalQuery`, `unexpectedIPs`, `"*"`, `UseSystem-queryStrategy`, `useSystemHosts` (#4666) --- app/dns/config.pb.go | 249 ++++++++++++++++++++-------------- app/dns/config.proto | 9 +- app/dns/dns.go | 45 +++++- app/dns/dns_test.go | 14 +- app/dns/nameserver.go | 117 ++++++++++------ app/router/condition_geoip.go | 26 ++++ infra/conf/dns.go | 173 ++++++++++++++++++----- 7 files changed, 444 insertions(+), 189 deletions(-) diff --git a/app/dns/config.pb.go b/app/dns/config.pb.go index 67fbd84e..d54142ce 100644 --- a/app/dns/config.pb.go +++ b/app/dns/config.pb.go @@ -80,6 +80,7 @@ const ( QueryStrategy_USE_IP QueryStrategy = 0 QueryStrategy_USE_IP4 QueryStrategy = 1 QueryStrategy_USE_IP6 QueryStrategy = 2 + QueryStrategy_USE_SYS QueryStrategy = 3 ) // Enum value maps for QueryStrategy. @@ -88,11 +89,13 @@ var ( 0: "USE_IP", 1: "USE_IP4", 2: "USE_IP6", + 3: "USE_SYS", } QueryStrategy_value = map[string]int32{ "USE_IP": 0, "USE_IP4": 1, "USE_IP6": 2, + "USE_SYS": 3, } ) @@ -128,16 +131,20 @@ type NameServer struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Address *net.Endpoint `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - ClientIp []byte `protobuf:"bytes,5,opt,name=client_ip,json=clientIp,proto3" json:"client_ip,omitempty"` - SkipFallback bool `protobuf:"varint,6,opt,name=skipFallback,proto3" json:"skipFallback,omitempty"` - PrioritizedDomain []*NameServer_PriorityDomain `protobuf:"bytes,2,rep,name=prioritized_domain,json=prioritizedDomain,proto3" json:"prioritized_domain,omitempty"` - Geoip []*router.GeoIP `protobuf:"bytes,3,rep,name=geoip,proto3" json:"geoip,omitempty"` - OriginalRules []*NameServer_OriginalRule `protobuf:"bytes,4,rep,name=original_rules,json=originalRules,proto3" json:"original_rules,omitempty"` - QueryStrategy QueryStrategy `protobuf:"varint,7,opt,name=query_strategy,json=queryStrategy,proto3,enum=xray.app.dns.QueryStrategy" json:"query_strategy,omitempty"` - AllowUnexpectedIPs bool `protobuf:"varint,8,opt,name=allowUnexpectedIPs,proto3" json:"allowUnexpectedIPs,omitempty"` - Tag string `protobuf:"bytes,9,opt,name=tag,proto3" json:"tag,omitempty"` - TimeoutMs uint64 `protobuf:"varint,10,opt,name=timeoutMs,proto3" json:"timeoutMs,omitempty"` + Address *net.Endpoint `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + ClientIp []byte `protobuf:"bytes,5,opt,name=client_ip,json=clientIp,proto3" json:"client_ip,omitempty"` + SkipFallback bool `protobuf:"varint,6,opt,name=skipFallback,proto3" json:"skipFallback,omitempty"` + PrioritizedDomain []*NameServer_PriorityDomain `protobuf:"bytes,2,rep,name=prioritized_domain,json=prioritizedDomain,proto3" json:"prioritized_domain,omitempty"` + ExpectedGeoip []*router.GeoIP `protobuf:"bytes,3,rep,name=expected_geoip,json=expectedGeoip,proto3" json:"expected_geoip,omitempty"` + OriginalRules []*NameServer_OriginalRule `protobuf:"bytes,4,rep,name=original_rules,json=originalRules,proto3" json:"original_rules,omitempty"` + QueryStrategy QueryStrategy `protobuf:"varint,7,opt,name=query_strategy,json=queryStrategy,proto3,enum=xray.app.dns.QueryStrategy" json:"query_strategy,omitempty"` + ActPrior bool `protobuf:"varint,8,opt,name=actPrior,proto3" json:"actPrior,omitempty"` + Tag string `protobuf:"bytes,9,opt,name=tag,proto3" json:"tag,omitempty"` + TimeoutMs uint64 `protobuf:"varint,10,opt,name=timeoutMs,proto3" json:"timeoutMs,omitempty"` + DisableCache bool `protobuf:"varint,11,opt,name=disableCache,proto3" json:"disableCache,omitempty"` + FinalQuery bool `protobuf:"varint,12,opt,name=finalQuery,proto3" json:"finalQuery,omitempty"` + UnexpectedGeoip []*router.GeoIP `protobuf:"bytes,13,rep,name=unexpected_geoip,json=unexpectedGeoip,proto3" json:"unexpected_geoip,omitempty"` + ActUnprior bool `protobuf:"varint,14,opt,name=actUnprior,proto3" json:"actUnprior,omitempty"` } func (x *NameServer) Reset() { @@ -198,9 +205,9 @@ func (x *NameServer) GetPrioritizedDomain() []*NameServer_PriorityDomain { return nil } -func (x *NameServer) GetGeoip() []*router.GeoIP { +func (x *NameServer) GetExpectedGeoip() []*router.GeoIP { if x != nil { - return x.Geoip + return x.ExpectedGeoip } return nil } @@ -219,9 +226,9 @@ func (x *NameServer) GetQueryStrategy() QueryStrategy { return QueryStrategy_USE_IP } -func (x *NameServer) GetAllowUnexpectedIPs() bool { +func (x *NameServer) GetActPrior() bool { if x != nil { - return x.AllowUnexpectedIPs + return x.ActPrior } return false } @@ -240,6 +247,34 @@ func (x *NameServer) GetTimeoutMs() uint64 { return 0 } +func (x *NameServer) GetDisableCache() bool { + if x != nil { + return x.DisableCache + } + return false +} + +func (x *NameServer) GetFinalQuery() bool { + if x != nil { + return x.FinalQuery + } + return false +} + +func (x *NameServer) GetUnexpectedGeoip() []*router.GeoIP { + if x != nil { + return x.UnexpectedGeoip + } + return nil +} + +func (x *NameServer) GetActUnprior() bool { + if x != nil { + return x.ActUnprior + } + return false +} + type Config struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -532,7 +567,7 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x2e, 0x64, 0x6e, 0x73, 0x1a, 0x1c, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x6e, 0x65, 0x74, 0x2f, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x61, 0x70, 0x70, 0x2f, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2f, 0x63, - 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x92, 0x05, 0x0a, 0x0a, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb6, 0x06, 0x0a, 0x0a, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x6e, 0x65, 0x74, 0x2e, 0x45, 0x6e, @@ -546,81 +581,92 @@ var file_app_dns_config_proto_rawDesc = []byte{ 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x52, 0x11, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x69, 0x7a, - 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x2c, 0x0a, 0x05, 0x67, 0x65, 0x6f, 0x69, - 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, - 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, - 0x05, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x4c, 0x0a, 0x0e, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, - 0x61, 0x6c, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x25, - 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, - 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, - 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, - 0x75, 0x6c, 0x65, 0x73, 0x12, 0x42, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, - 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, - 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, - 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, - 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x2e, 0x0a, 0x12, 0x61, 0x6c, 0x6c, 0x6f, - 0x77, 0x55, 0x6e, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x18, 0x08, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x55, 0x6e, 0x65, 0x78, 0x70, - 0x65, 0x63, 0x74, 0x65, 0x64, 0x49, 0x50, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, - 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, - 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x4d, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x4d, 0x73, 0x1a, 0x5e, 0x0a, 0x0e, 0x50, 0x72, 0x69, 0x6f, - 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, - 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, - 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x36, 0x0a, 0x0c, 0x4f, 0x72, 0x69, 0x67, - 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x75, 0x6c, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, - 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, - 0x22, 0x9c, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x39, 0x0a, 0x0b, 0x6e, - 0x61, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, - 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, - 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, - 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, 0x6c, 0x69, 0x65, 0x6e, - 0x74, 0x49, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x5f, 0x68, 0x6f, - 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, - 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, - 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x0b, 0x73, 0x74, 0x61, - 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, - 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, - 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, - 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x42, - 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, - 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, - 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, - 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, - 0x67, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, - 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x64, 0x69, 0x73, - 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x36, 0x0a, 0x16, - 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, - 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x64, 0x69, - 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x49, 0x66, 0x4d, - 0x61, 0x74, 0x63, 0x68, 0x1a, 0x92, 0x01, 0x0a, 0x0b, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, - 0x70, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, - 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, - 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x02, - 0x69, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x5f, 0x64, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x70, 0x72, 0x6f, 0x78, - 0x69, 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x2a, - 0x45, 0x0a, 0x12, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, - 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, 0x6c, 0x10, 0x00, 0x12, - 0x0d, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x10, 0x01, 0x12, 0x0b, - 0x0a, 0x07, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x52, - 0x65, 0x67, 0x65, 0x78, 0x10, 0x03, 0x2a, 0x35, 0x0a, 0x0d, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, - 0x50, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x01, - 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x02, 0x42, 0x46, 0x0a, - 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, - 0x73, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x61, - 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, 0x70, - 0x70, 0x2e, 0x44, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x3d, 0x0a, 0x0e, 0x65, 0x78, 0x70, 0x65, + 0x63, 0x74, 0x65, 0x64, 0x5f, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, 0x6f, 0x75, 0x74, + 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x0d, 0x65, 0x78, 0x70, 0x65, 0x63, 0x74, + 0x65, 0x64, 0x47, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x4c, 0x0a, 0x0e, 0x6f, 0x72, 0x69, 0x67, 0x69, + 0x6e, 0x61, 0x6c, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x25, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x4e, + 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, + 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x0d, 0x6f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, + 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x42, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, + 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, + 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x61, 0x63, 0x74, + 0x50, 0x72, 0x69, 0x6f, 0x72, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x61, 0x63, 0x74, + 0x50, 0x72, 0x69, 0x6f, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x61, 0x67, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x6f, + 0x75, 0x74, 0x4d, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, + 0x6f, 0x75, 0x74, 0x4d, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, + 0x43, 0x61, 0x63, 0x68, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x64, 0x69, 0x73, + 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x66, 0x69, 0x6e, + 0x61, 0x6c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x66, + 0x69, 0x6e, 0x61, 0x6c, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x41, 0x0a, 0x10, 0x75, 0x6e, 0x65, + 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x5f, 0x67, 0x65, 0x6f, 0x69, 0x70, 0x18, 0x0d, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x72, + 0x6f, 0x75, 0x74, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x6f, 0x49, 0x50, 0x52, 0x0f, 0x75, 0x6e, 0x65, + 0x78, 0x70, 0x65, 0x63, 0x74, 0x65, 0x64, 0x47, 0x65, 0x6f, 0x69, 0x70, 0x12, 0x1e, 0x0a, 0x0a, + 0x61, 0x63, 0x74, 0x55, 0x6e, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x0a, 0x61, 0x63, 0x74, 0x55, 0x6e, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x1a, 0x5e, 0x0a, 0x0e, + 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x34, + 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, + 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, + 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, + 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x36, 0x0a, 0x0c, + 0x4f, 0x72, 0x69, 0x67, 0x69, 0x6e, 0x61, 0x6c, 0x52, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, + 0x72, 0x75, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x75, 0x6c, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, + 0x73, 0x69, 0x7a, 0x65, 0x22, 0x9c, 0x04, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, + 0x39, 0x0a, 0x0b, 0x6e, 0x61, 0x6d, 0x65, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x18, 0x05, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, + 0x64, 0x6e, 0x73, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x0a, + 0x6e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x43, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x74, 0x69, + 0x63, 0x5f, 0x68, 0x6f, 0x73, 0x74, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, + 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, + 0x0b, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x48, 0x6f, 0x73, 0x74, 0x73, 0x12, 0x10, 0x0a, 0x03, + 0x74, 0x61, 0x67, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x74, 0x61, 0x67, 0x12, 0x22, + 0x0a, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, 0x68, 0x65, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x61, 0x63, + 0x68, 0x65, 0x12, 0x42, 0x0a, 0x0e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x5f, 0x73, 0x74, 0x72, 0x61, + 0x74, 0x65, 0x67, 0x79, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x78, 0x72, 0x61, + 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x53, + 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x0d, 0x71, 0x75, 0x65, 0x72, 0x79, 0x53, 0x74, + 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x28, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, + 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x12, 0x36, 0x0a, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, + 0x61, 0x63, 0x6b, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x16, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x49, 0x66, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x1a, 0x92, 0x01, 0x0a, 0x0b, 0x48, 0x6f, 0x73, + 0x74, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x34, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, + 0x70, 0x2e, 0x64, 0x6e, 0x73, 0x2e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, 0x63, + 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x16, + 0x0a, 0x06, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0c, 0x52, 0x02, 0x69, 0x70, 0x12, 0x25, 0x0a, 0x0e, 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, + 0x64, 0x5f, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, + 0x70, 0x72, 0x6f, 0x78, 0x69, 0x65, 0x64, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4a, 0x04, 0x08, + 0x07, 0x10, 0x08, 0x2a, 0x45, 0x0a, 0x12, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x4d, 0x61, 0x74, + 0x63, 0x68, 0x69, 0x6e, 0x67, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x46, 0x75, 0x6c, + 0x6c, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x75, 0x62, 0x64, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x4b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x10, 0x02, 0x12, + 0x09, 0x0a, 0x05, 0x52, 0x65, 0x67, 0x65, 0x78, 0x10, 0x03, 0x2a, 0x42, 0x0a, 0x0d, 0x51, 0x75, + 0x65, 0x72, 0x79, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x0a, 0x0a, 0x06, 0x55, + 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, + 0x50, 0x34, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, + 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x53, 0x59, 0x53, 0x10, 0x03, 0x42, 0x46, + 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x64, + 0x6e, 0x73, 0x50, 0x01, 0x5a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, + 0x61, 0x70, 0x70, 0x2f, 0x64, 0x6e, 0x73, 0xaa, 0x02, 0x0c, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x41, + 0x70, 0x70, 0x2e, 0x44, 0x6e, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -651,19 +697,20 @@ var file_app_dns_config_proto_goTypes = []any{ var file_app_dns_config_proto_depIdxs = []int32{ 7, // 0: xray.app.dns.NameServer.address:type_name -> xray.common.net.Endpoint 4, // 1: xray.app.dns.NameServer.prioritized_domain:type_name -> xray.app.dns.NameServer.PriorityDomain - 8, // 2: xray.app.dns.NameServer.geoip:type_name -> xray.app.router.GeoIP + 8, // 2: xray.app.dns.NameServer.expected_geoip:type_name -> xray.app.router.GeoIP 5, // 3: xray.app.dns.NameServer.original_rules:type_name -> xray.app.dns.NameServer.OriginalRule 1, // 4: xray.app.dns.NameServer.query_strategy:type_name -> xray.app.dns.QueryStrategy - 2, // 5: xray.app.dns.Config.name_server:type_name -> xray.app.dns.NameServer - 6, // 6: xray.app.dns.Config.static_hosts:type_name -> xray.app.dns.Config.HostMapping - 1, // 7: xray.app.dns.Config.query_strategy:type_name -> xray.app.dns.QueryStrategy - 0, // 8: xray.app.dns.NameServer.PriorityDomain.type:type_name -> xray.app.dns.DomainMatchingType - 0, // 9: xray.app.dns.Config.HostMapping.type:type_name -> xray.app.dns.DomainMatchingType - 10, // [10:10] is the sub-list for method output_type - 10, // [10:10] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name + 8, // 5: xray.app.dns.NameServer.unexpected_geoip:type_name -> xray.app.router.GeoIP + 2, // 6: xray.app.dns.Config.name_server:type_name -> xray.app.dns.NameServer + 6, // 7: xray.app.dns.Config.static_hosts:type_name -> xray.app.dns.Config.HostMapping + 1, // 8: xray.app.dns.Config.query_strategy:type_name -> xray.app.dns.QueryStrategy + 0, // 9: xray.app.dns.NameServer.PriorityDomain.type:type_name -> xray.app.dns.DomainMatchingType + 0, // 10: xray.app.dns.Config.HostMapping.type:type_name -> xray.app.dns.DomainMatchingType + 11, // [11:11] is the sub-list for method output_type + 11, // [11:11] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_app_dns_config_proto_init() } diff --git a/app/dns/config.proto b/app/dns/config.proto index 8935ffa8..4317d0d7 100644 --- a/app/dns/config.proto +++ b/app/dns/config.proto @@ -25,12 +25,16 @@ message NameServer { } repeated PriorityDomain prioritized_domain = 2; - repeated xray.app.router.GeoIP geoip = 3; + repeated xray.app.router.GeoIP expected_geoip = 3; repeated OriginalRule original_rules = 4; QueryStrategy query_strategy = 7; - bool allowUnexpectedIPs = 8; + bool actPrior = 8; string tag = 9; uint64 timeoutMs = 10; + bool disableCache = 11; + bool finalQuery = 12; + repeated xray.app.router.GeoIP unexpected_geoip = 13; + bool actUnprior = 14; } enum DomainMatchingType { @@ -44,6 +48,7 @@ enum QueryStrategy { USE_IP = 0; USE_IP4 = 1; USE_IP6 = 2; + USE_SYS = 3; } message Config { diff --git a/app/dns/dns.go b/app/dns/dns.go index a0b620c3..ddf4ac2e 100644 --- a/app/dns/dns.go +++ b/app/dns/dns.go @@ -28,6 +28,7 @@ type DNS struct { ctx context.Context domainMatcher strmatcher.IndexMatcher matcherInfos []*DomainMatcherInfo + checkSystem bool } // DomainMatcherInfo contains information attached to index returned by Server.domainMatcher @@ -47,6 +48,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) { } var ipOption dns.IPOption + checkSystem := false switch config.QueryStrategy { case QueryStrategy_USE_IP: ipOption = dns.IPOption{ @@ -54,6 +56,13 @@ func New(ctx context.Context, config *Config) (*DNS, error) { IPv6Enable: true, FakeEnable: false, } + case QueryStrategy_USE_SYS: + ipOption = dns.IPOption{ + IPv4Enable: true, + IPv6Enable: true, + FakeEnable: false, + } + checkSystem = true case QueryStrategy_USE_IP4: ipOption = dns.IPOption{ IPv4Enable: true, @@ -108,7 +117,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) { myClientIP = net.IP(ns.ClientIp) } - disableCache := config.DisableCache + disableCache := config.DisableCache || ns.DisableCache var tag = defaultTag if len(ns.Tag) > 0 { @@ -118,6 +127,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) { if !clientIPOption.IPv4Enable && !clientIPOption.IPv6Enable { return nil, errors.New("no QueryStrategy available for ", ns.Address) } + client, err := NewClient(ctx, ns, myClientIP, disableCache, tag, clientIPOption, &matcherInfos, updateDomain) if err != nil { return nil, errors.New("failed to create client").Base(err) @@ -139,6 +149,7 @@ func New(ctx context.Context, config *Config) (*DNS, error) { matcherInfos: matcherInfos, disableFallback: config.DisableFallback, disableFallbackIfMatch: config.DisableFallbackIfMatch, + checkSystem: checkSystem, }, nil } @@ -179,8 +190,14 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, uint32, er return nil, 0, errors.New("empty domain name") } - option.IPv4Enable = option.IPv4Enable && s.ipOption.IPv4Enable - option.IPv6Enable = option.IPv6Enable && s.ipOption.IPv6Enable + if s.checkSystem { + supportIPv4, supportIPv6 := checkSystemNetwork() + option.IPv4Enable = option.IPv4Enable && supportIPv4 + option.IPv6Enable = option.IPv6Enable && supportIPv6 + } else { + option.IPv4Enable = option.IPv4Enable && s.ipOption.IPv4Enable + option.IPv6Enable = option.IPv6Enable && s.ipOption.IPv6Enable + } if !option.IPv4Enable && !option.IPv6Enable { return nil, 0, dns.ErrEmptyResponse @@ -227,6 +244,9 @@ func (s *DNS) LookupIP(domain string, option dns.IPOption) ([]net.IP, uint32, er } errs = append(errs, err) + if client.IsFinalQuery() { + break + } } if len(errs) > 0 { @@ -302,3 +322,22 @@ func init() { return New(ctx, config.(*Config)) })) } + +func checkSystemNetwork() (supportIPv4 bool, supportIPv6 bool) { + conn4, err4 := net.Dial("udp4", "8.8.8.8:53") + if err4 != nil { + supportIPv4 = false + } else { + supportIPv4 = true + conn4.Close() + } + + conn6, err6 := net.Dial("udp6", "[2001:4860:4860::8888]:53") + if err6 != nil { + supportIPv6 = false + } else { + supportIPv6 = true + conn6.Close() + } + return +} diff --git a/app/dns/dns_test.go b/app/dns/dns_test.go index 7ea6fcf8..cb70b0b3 100644 --- a/app/dns/dns_test.go +++ b/app/dns/dns_test.go @@ -539,7 +539,7 @@ func TestIPMatch(t *testing.T) { }, Port: uint32(port), }, - Geoip: []*router.GeoIP{ + ExpectedGeoip: []*router.GeoIP{ { CountryCode: "local", Cidr: []*router.CIDR{ @@ -563,7 +563,7 @@ func TestIPMatch(t *testing.T) { }, Port: uint32(port), }, - Geoip: []*router.GeoIP{ + ExpectedGeoip: []*router.GeoIP{ { CountryCode: "test", Cidr: []*router.CIDR{ @@ -667,7 +667,7 @@ func TestLocalDomain(t *testing.T) { // Equivalent of dotless:localhost {Type: DomainMatchingType_Regex, Domain: "^[^.]*localhost[^.]*$"}, }, - Geoip: []*router.GeoIP{ + ExpectedGeoip: []*router.GeoIP{ { // Will match localhost, localhost-a and localhost-b, CountryCode: "local", Cidr: []*router.CIDR{ @@ -897,7 +897,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) { Domain: "google.com", }, }, - Geoip: []*router.GeoIP{ + ExpectedGeoip: []*router.GeoIP{ { // Will only match 8.8.8.8 and 8.8.4.4 Cidr: []*router.CIDR{ {Ip: []byte{8, 8, 8, 8}, Prefix: 32}, @@ -922,7 +922,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) { Domain: "google.com", }, }, - Geoip: []*router.GeoIP{ + ExpectedGeoip: []*router.GeoIP{ { // Will match 8.8.8.8 and 8.8.8.7, etc Cidr: []*router.CIDR{ {Ip: []byte{8, 8, 8, 7}, Prefix: 24}, @@ -946,7 +946,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) { Domain: "api.google.com", }, }, - Geoip: []*router.GeoIP{ + ExpectedGeoip: []*router.GeoIP{ { // Will only match 8.8.7.7 (api.google.com) Cidr: []*router.CIDR{ {Ip: []byte{8, 8, 7, 7}, Prefix: 32}, @@ -970,7 +970,7 @@ func TestMultiMatchPrioritizedDomain(t *testing.T) { Domain: "v2.api.google.com", }, }, - Geoip: []*router.GeoIP{ + ExpectedGeoip: []*router.GeoIP{ { // Will only match 8.8.7.8 (v2.api.google.com) Cidr: []*router.CIDR{ {Ip: []byte{8, 8, 7, 8}, Prefix: 32}, diff --git a/app/dns/nameserver.go b/app/dns/nameserver.go index 31681c4a..cf1b665b 100644 --- a/app/dns/nameserver.go +++ b/app/dns/nameserver.go @@ -26,14 +26,18 @@ type Server interface { // Client is the interface for DNS client. type Client struct { - server Server - skipFallback bool - domains []string - expectedIPs []*router.GeoIPMatcher - allowUnexpectedIPs bool - tag string - timeoutMs time.Duration - ipOption *dns.IPOption + server Server + skipFallback bool + domains []string + expectedIPs []*router.GeoIPMatcher + unexpectedIPs []*router.GeoIPMatcher + actPrior bool + actUnprior bool + tag string + timeoutMs time.Duration + finalQuery bool + ipOption *dns.IPOption + checkSystem bool } // NewServer creates a name server object according to the network destination url. @@ -150,13 +154,23 @@ func NewClient( } // Establish expected IPs - var matchers []*router.GeoIPMatcher - for _, geoip := range ns.Geoip { + var expectedMatchers []*router.GeoIPMatcher + for _, geoip := range ns.ExpectedGeoip { matcher, err := router.GlobalGeoIPContainer.Add(geoip) if err != nil { - return errors.New("failed to create ip matcher").Base(err).AtWarning() + return errors.New("failed to create expected ip matcher").Base(err).AtWarning() } - matchers = append(matchers, matcher) + expectedMatchers = append(expectedMatchers, matcher) + } + + // Establish unexpected IPs + var unexpectedMatchers []*router.GeoIPMatcher + for _, geoip := range ns.UnexpectedGeoip { + matcher, err := router.GlobalGeoIPContainer.Add(geoip) + if err != nil { + return errors.New("failed to create unexpected ip matcher").Base(err).AtWarning() + } + unexpectedMatchers = append(unexpectedMatchers, matcher) } if len(clientIP) > 0 { @@ -173,14 +187,20 @@ func NewClient( timeoutMs = time.Duration(ns.TimeoutMs) * time.Millisecond } + checkSystem := ns.QueryStrategy == QueryStrategy_USE_SYS + client.server = server client.skipFallback = ns.SkipFallback client.domains = rules - client.expectedIPs = matchers - client.allowUnexpectedIPs = ns.AllowUnexpectedIPs + client.expectedIPs = expectedMatchers + client.unexpectedIPs = unexpectedMatchers + client.actPrior = ns.ActPrior + client.actUnprior = ns.ActUnprior client.tag = tag client.timeoutMs = timeoutMs + client.finalQuery = ns.FinalQuery client.ipOption = &ipOption + client.checkSystem = checkSystem return nil }) return client, err @@ -191,10 +211,21 @@ func (c *Client) Name() string { return c.server.Name() } +func (c *Client) IsFinalQuery() bool { + return c.finalQuery +} + // QueryIP sends DNS query to the name server with the client's IP. func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption) ([]net.IP, uint32, error) { - option.IPv4Enable = option.IPv4Enable && c.ipOption.IPv4Enable - option.IPv6Enable = option.IPv6Enable && c.ipOption.IPv6Enable + if c.checkSystem { + supportIPv4, supportIPv6 := checkSystemNetwork() + option.IPv4Enable = option.IPv4Enable && supportIPv4 + option.IPv6Enable = option.IPv6Enable && supportIPv6 + } else { + option.IPv4Enable = option.IPv4Enable && c.ipOption.IPv4Enable + option.IPv6Enable = option.IPv6Enable && c.ipOption.IPv6Enable + } + if !option.IPv4Enable && !option.IPv6Enable { return nil, 0, dns.ErrEmptyResponse } @@ -212,39 +243,47 @@ func (c *Client) QueryIP(ctx context.Context, domain string, option dns.IPOption return nil, 0, dns.ErrEmptyResponse } - if len(c.expectedIPs) > 0 { - newIps := c.MatchExpectedIPs(domain, ips) - if len(newIps) == 0 { - if !c.allowUnexpectedIPs { - return nil, 0, dns.ErrEmptyResponse - } - } else { - ips = newIps + if len(c.expectedIPs) > 0 && !c.actPrior { + ips = router.MatchIPs(c.expectedIPs, ips, false) + errors.LogDebug(context.Background(), "domain ", domain, " expectedIPs ", ips, " matched at server ", c.Name()) + if len(ips) == 0 { + return nil, 0, dns.ErrEmptyResponse + } + } + + if len(c.unexpectedIPs) > 0 && !c.actUnprior { + ips = router.MatchIPs(c.unexpectedIPs, ips, true) + errors.LogDebug(context.Background(), "domain ", domain, " unexpectedIPs ", ips, " matched at server ", c.Name()) + if len(ips) == 0 { + return nil, 0, dns.ErrEmptyResponse + } + } + + if len(c.expectedIPs) > 0 && c.actPrior { + ipsNew := router.MatchIPs(c.expectedIPs, ips, false) + if len(ipsNew) > 0 { + ips = ipsNew + errors.LogDebug(context.Background(), "domain ", domain, " priorIPs ", ips, " matched at server ", c.Name()) + } + } + + if len(c.unexpectedIPs) > 0 && c.actUnprior { + ipsNew := router.MatchIPs(c.unexpectedIPs, ips, true) + if len(ipsNew) > 0 { + ips = ipsNew + errors.LogDebug(context.Background(), "domain ", domain, " unpriorIPs ", ips, " matched at server ", c.Name()) } } return ips, ttl, nil } -// MatchExpectedIPs matches queried domain IPs with expected IPs and returns matched ones. -func (c *Client) MatchExpectedIPs(domain string, ips []net.IP) []net.IP { - var newIps []net.IP - for _, ip := range ips { - for _, matcher := range c.expectedIPs { - if matcher.Match(ip) { - newIps = append(newIps, ip) - break - } - } - } - errors.LogDebug(context.Background(), "domain ", domain, " expectedIPs ", newIps, " matched at server ", c.Name()) - return newIps -} - func ResolveIpOptionOverride(queryStrategy QueryStrategy, ipOption dns.IPOption) dns.IPOption { switch queryStrategy { case QueryStrategy_USE_IP: return ipOption + case QueryStrategy_USE_SYS: + return ipOption case QueryStrategy_USE_IP4: return dns.IPOption{ IPv4Enable: ipOption.IPv4Enable, diff --git a/app/router/condition_geoip.go b/app/router/condition_geoip.go index 0140cdfb..38f7f0ce 100644 --- a/app/router/condition_geoip.go +++ b/app/router/condition_geoip.go @@ -116,3 +116,29 @@ func (c *GeoIPMatcherContainer) Add(geoip *GeoIP) (*GeoIPMatcher, error) { } var GlobalGeoIPContainer GeoIPMatcherContainer + +func MatchIPs(matchers []*GeoIPMatcher, ips []net.IP, reverse bool) []net.IP { + if len(matchers) == 0 { + panic("GeoIP matchers should not be empty to avoid ambiguity") + } + newIPs := make([]net.IP, 0, len(ips)) + var isFound bool + for _, ip := range ips { + isFound = false + for _, matcher := range matchers { + if matcher.Match(ip) { + isFound = true + break + } + } + if isFound && !reverse { + newIPs = append(newIPs, ip) + continue + } + if !isFound && reverse { + newIPs = append(newIPs, ip) + continue + } + } + return newIPs +} diff --git a/infra/conf/dns.go b/infra/conf/dns.go index 7baeda87..8a60bc00 100644 --- a/infra/conf/dns.go +++ b/infra/conf/dns.go @@ -1,7 +1,11 @@ package conf import ( + "bufio" "encoding/json" + "os" + "path/filepath" + "runtime" "sort" "strings" @@ -12,17 +16,19 @@ import ( ) type NameServerConfig struct { - Address *Address `json:"address"` - ClientIP *Address `json:"clientIp"` - Port uint16 `json:"port"` - SkipFallback bool `json:"skipFallback"` - Domains []string `json:"domains"` - ExpectedIPs StringList `json:"expectedIPs"` - ExpectIPs StringList `json:"expectIPs"` - QueryStrategy string `json:"queryStrategy"` - AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` - Tag string `json:"tag"` - TimeoutMs uint64 `json:"timeoutMs"` + Address *Address `json:"address"` + ClientIP *Address `json:"clientIp"` + Port uint16 `json:"port"` + SkipFallback bool `json:"skipFallback"` + Domains []string `json:"domains"` + ExpectedIPs StringList `json:"expectedIPs"` + ExpectIPs StringList `json:"expectIPs"` + QueryStrategy string `json:"queryStrategy"` + Tag string `json:"tag"` + TimeoutMs uint64 `json:"timeoutMs"` + DisableCache bool `json:"disableCache"` + FinalQuery bool `json:"finalQuery"` + UnexpectedIPs StringList `json:"unexpectedIPs"` } // UnmarshalJSON implements encoding/json.Unmarshaler.UnmarshalJSON @@ -34,17 +40,19 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { } var advanced struct { - Address *Address `json:"address"` - ClientIP *Address `json:"clientIp"` - Port uint16 `json:"port"` - SkipFallback bool `json:"skipFallback"` - Domains []string `json:"domains"` - ExpectedIPs StringList `json:"expectedIPs"` - ExpectIPs StringList `json:"expectIPs"` - QueryStrategy string `json:"queryStrategy"` - AllowUnexpectedIPs bool `json:"allowUnexpectedIps"` - Tag string `json:"tag"` - TimeoutMs uint64 `json:"timeoutMs"` + Address *Address `json:"address"` + ClientIP *Address `json:"clientIp"` + Port uint16 `json:"port"` + SkipFallback bool `json:"skipFallback"` + Domains []string `json:"domains"` + ExpectedIPs StringList `json:"expectedIPs"` + ExpectIPs StringList `json:"expectIPs"` + QueryStrategy string `json:"queryStrategy"` + Tag string `json:"tag"` + TimeoutMs uint64 `json:"timeoutMs"` + DisableCache bool `json:"disableCache"` + FinalQuery bool `json:"finalQuery"` + UnexpectedIPs StringList `json:"unexpectedIPs"` } if err := json.Unmarshal(data, &advanced); err == nil { c.Address = advanced.Address @@ -55,9 +63,11 @@ func (c *NameServerConfig) UnmarshalJSON(data []byte) error { c.ExpectedIPs = advanced.ExpectedIPs c.ExpectIPs = advanced.ExpectIPs c.QueryStrategy = advanced.QueryStrategy - c.AllowUnexpectedIPs = advanced.AllowUnexpectedIPs c.Tag = advanced.Tag c.TimeoutMs = advanced.TimeoutMs + c.DisableCache = advanced.DisableCache + c.FinalQuery = advanced.FinalQuery + c.UnexpectedIPs = advanced.UnexpectedIPs return nil } @@ -105,13 +115,38 @@ func (c *NameServerConfig) Build() (*dns.NameServer, error) { }) } - var expectedIPs = c.ExpectedIPs - if len(expectedIPs) == 0 { - expectedIPs = c.ExpectIPs + if len(c.ExpectedIPs) == 0 { + c.ExpectedIPs = c.ExpectIPs } - geoipList, err := ToCidrList(expectedIPs) + + actPrior := false + var newExpectedIPs StringList + for _, s := range c.ExpectedIPs { + if s == "*" { + actPrior = true + } else { + newExpectedIPs = append(newExpectedIPs, s) + } + } + + actUnprior := false + var newUnexpectedIPs StringList + for _, s := range c.UnexpectedIPs { + if s == "*" { + actUnprior = true + } else { + newUnexpectedIPs = append(newUnexpectedIPs, s) + } + } + + expectedGeoipList, err := ToCidrList(newExpectedIPs) if err != nil { - return nil, errors.New("invalid IP rule: ", expectedIPs).Base(err) + return nil, errors.New("invalid expected IP rule: ", c.ExpectedIPs).Base(err) + } + + unexpectedGeoipList, err := ToCidrList(newUnexpectedIPs) + if err != nil { + return nil, errors.New("invalid unexpected IP rule: ", c.UnexpectedIPs).Base(err) } var myClientIP []byte @@ -128,15 +163,19 @@ func (c *NameServerConfig) Build() (*dns.NameServer, error) { Address: c.Address.Build(), Port: uint32(c.Port), }, - ClientIp: myClientIP, - SkipFallback: c.SkipFallback, - PrioritizedDomain: domains, - Geoip: geoipList, - OriginalRules: originalRules, - QueryStrategy: resolveQueryStrategy(c.QueryStrategy), - AllowUnexpectedIPs: c.AllowUnexpectedIPs, - Tag: c.Tag, - TimeoutMs: c.TimeoutMs, + ClientIp: myClientIP, + SkipFallback: c.SkipFallback, + PrioritizedDomain: domains, + ExpectedGeoip: expectedGeoipList, + OriginalRules: originalRules, + QueryStrategy: resolveQueryStrategy(c.QueryStrategy), + ActPrior: actPrior, + Tag: c.Tag, + TimeoutMs: c.TimeoutMs, + DisableCache: c.DisableCache, + FinalQuery: c.FinalQuery, + UnexpectedGeoip: unexpectedGeoipList, + ActUnprior: actUnprior, }, nil } @@ -157,6 +196,7 @@ type DNSConfig struct { DisableCache bool `json:"disableCache"` DisableFallback bool `json:"disableFallback"` DisableFallbackIfMatch bool `json:"disableFallbackIfMatch"` + UseSystemHosts bool `json:"useSystemHosts"` } type HostAddress struct { @@ -378,6 +418,15 @@ func (c *DNSConfig) Build() (*dns.Config, error) { } config.StaticHosts = append(config.StaticHosts, staticHosts...) } + if c.UseSystemHosts { + systemHosts, err := readSystemHosts() + if err != nil { + return nil, errors.New("failed to read system hosts").Base(err) + } + for domain, ips := range systemHosts { + config.StaticHosts = append(config.StaticHosts, &dns.Config_HostMapping{Ip: ips, Domain: domain, Type: dns.DomainMatchingType_Full}) + } + } return config, nil } @@ -390,7 +439,57 @@ func resolveQueryStrategy(queryStrategy string) dns.QueryStrategy { return dns.QueryStrategy_USE_IP4 case "useip6", "useipv6", "use_ip6", "use_ipv6", "use_ip_v6", "use-ip6", "use-ipv6", "use-ip-v6": return dns.QueryStrategy_USE_IP6 + case "usesys", "usesystem", "use_sys", "use_system", "use-sys", "use-system": + return dns.QueryStrategy_USE_SYS default: return dns.QueryStrategy_USE_IP } } + +func readSystemHosts() (map[string][][]byte, error) { + var hostsPath string + switch runtime.GOOS { + case "windows": + hostsPath = filepath.Join(os.Getenv("SystemRoot"), "System32", "drivers", "etc", "hosts") + default: + hostsPath = "/etc/hosts" + } + + file, err := os.Open(hostsPath) + if err != nil { + return nil, err + } + defer file.Close() + + hostsMap := make(map[string][][]byte) + scanner := bufio.NewScanner(file) + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if i := strings.IndexByte(line, '#'); i >= 0 { + // Discard comments. + line = line[0:i] + } + f := strings.Fields(line) + if len(f) < 2 { + continue + } + addr := net.ParseAddress(f[0]) + if addr.Family().IsDomain() { + continue + } + ip := addr.IP() + for i := 1; i < len(f); i++ { + domain := strings.TrimSuffix(f[i], ".") + domain = strings.ToLower(domain) + if v, ok := hostsMap[domain]; ok { + hostsMap[domain] = append(v, ip) + } else { + hostsMap[domain] = [][]byte{ip} + } + } + } + if err := scanner.Err(); err != nil { + return nil, err + } + return hostsMap, nil +} From b80e3196554a7898279fcecbd182948e7a78fd7c Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 5 Jun 2025 22:04:17 -0400 Subject: [PATCH 842/867] README.md: Add Amnezia VPN to Others (#4718) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 577b9f4e..26bd3fa1 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ - [XrayR-release](https://github.com/XrayR-project/XrayR-release) - [XrayR-V2Board](https://github.com/missuo/XrayR-V2Board) - Cores + - [Amnezia VPN](https://github.com/amnezia-vpn) - [mihomo](https://github.com/MetaCubeX/mihomo) - [sing-box](https://github.com/SagerNet/sing-box) From ab0b9a6220a32040b81e376b951cfcc162a0a059 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 7 Jun 2025 08:59:39 +0000 Subject: [PATCH 843/867] REALITY practice: Detect & imitate target's post-handshake records Fixes https://github.com/XTLS/Xray-core/issues/4778 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f570b84d..fbd27311 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.1 - github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130 + github.com/xtls/reality v0.0.0-20250607082147-88910695ec9a go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.39.0 golang.org/x/net v0.41.0 diff --git a/go.sum b/go.sum index 50f1c1e7..aaadafb4 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4= github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130 h1:v/TVypWnLferyoaNHh6a8oyggj9APBUzfl1OOgXNbpw= -github.com/xtls/reality v0.0.0-20250527000105-e679ef7bb130/go.mod h1:bJdU3ExzfUlY40Xxfibq3THW9IHiE8mHu/tEzud5JWM= +github.com/xtls/reality v0.0.0-20250607082147-88910695ec9a h1:CiFWUVXNkcO9IR7Jv1lld7DM1+02a7N5U0SiH5pRH2c= +github.com/xtls/reality v0.0.0-20250607082147-88910695ec9a/go.mod h1:Rkdcxe9Yd8SWQRRP+LSvX6wxk1m4lmNkyUZEHzbPDZw= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= From 4e1a6f0fd167766b265443af27f8847b6dc09d9e Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Sat, 7 Jun 2025 12:31:57 +0330 Subject: [PATCH 844/867] Sniffer-destOverride: Remove `fakedns+others` option (#4739) https://github.com/XTLS/Xray-core/pull/4726#issuecomment-2886494540 --- infra/conf/xray.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 42b8fa4d..f1d9fb08 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -69,10 +69,8 @@ func (c *SniffingConfig) Build() (*proxyman.SniffingConfig, error) { p = append(p, "tls") case "quic": p = append(p, "quic") - case "fakedns": + case "fakedns", "fakedns+others": p = append(p, "fakedns") - case "fakedns+others": - p = append(p, "fakedns+others") default: return nil, errors.New("unknown protocol: ", protocol) } From 83e5fa4f3cf35631e3eadf23071e94e9366a638d Mon Sep 17 00:00:00 2001 From: vpainless Date: Sat, 7 Jun 2025 11:33:20 +0200 Subject: [PATCH 845/867] README.md: Add VPainLess to One Click (#4782) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26bd3fa1..b717aa1c 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ - [Hiddify](https://github.com/hiddify/Hiddify-Manager) - One Click - [Xray-REALITY](https://github.com/zxcvos/Xray-script), [xray-reality](https://github.com/sajjaddg/xray-reality), [reality-ezpz](https://github.com/aleskxyz/reality-ezpz) - - [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [XTool](https://github.com/LordPenguin666/XTool) + - [Xray_bash_onekey](https://github.com/hello-yunshu/Xray_bash_onekey), [XTool](https://github.com/LordPenguin666/XTool), [VPainLess](https://github.com/vpainless/vpainless) - [v2ray-agent](https://github.com/mack-a/v2ray-agent), [Xray_onekey](https://github.com/wulabing/Xray_onekey), [ProxySU](https://github.com/proxysu/ProxySU) - Magisk - [Xray4Magisk](https://github.com/Asterisk4Magisk/Xray4Magisk) From f67c70c4a2b044b276d8affd88d86b37ac213c05 Mon Sep 17 00:00:00 2001 From: lhear <121179341+lhear@users.noreply.github.com> Date: Sat, 7 Jun 2025 17:35:04 +0800 Subject: [PATCH 846/867] README.md: Add SimpleXray to Android Clients (#4761) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b717aa1c..62220553 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ - [v2rayNG](https://github.com/2dust/v2rayNG) - [X-flutter](https://github.com/XTLS/X-flutter) - [SaeedDev94/Xray](https://github.com/SaeedDev94/Xray) + - [SimpleXray](https://github.com/lhear/SimpleXray) - iOS & macOS arm64 - [Happ](https://apps.apple.com/app/happ-proxy-utility/id6504287215) - [Streisand](https://apps.apple.com/app/streisand/id6450534064) From bfbccc272177b8c74cf7558f3424fece1bfb115d Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 7 Jun 2025 11:22:12 +0000 Subject: [PATCH 847/867] Update github.com/xtls/reality to 20250607105625 https://github.com/XTLS/Xray-core/issues/4778#issuecomment-2952355740 https://github.com/XTLS/Xray-core/issues/4741#issuecomment-2919838784 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fbd27311..d10a5a54 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.1 - github.com/xtls/reality v0.0.0-20250607082147-88910695ec9a + github.com/xtls/reality v0.0.0-20250607105625-90e738a94c8c go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.39.0 golang.org/x/net v0.41.0 diff --git a/go.sum b/go.sum index aaadafb4..28bf3ad9 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4= github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/reality v0.0.0-20250607082147-88910695ec9a h1:CiFWUVXNkcO9IR7Jv1lld7DM1+02a7N5U0SiH5pRH2c= -github.com/xtls/reality v0.0.0-20250607082147-88910695ec9a/go.mod h1:Rkdcxe9Yd8SWQRRP+LSvX6wxk1m4lmNkyUZEHzbPDZw= +github.com/xtls/reality v0.0.0-20250607105625-90e738a94c8c h1:GiY3/SynO0ujSH3rQDEIrE4MTTZM9KHufR3zx3JLD3c= +github.com/xtls/reality v0.0.0-20250607105625-90e738a94c8c/go.mod h1:Rkdcxe9Yd8SWQRRP+LSvX6wxk1m4lmNkyUZEHzbPDZw= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= From 97fdcb4228450ad01092636c7a742c19e8c92352 Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Sat, 7 Jun 2025 16:50:06 +0330 Subject: [PATCH 848/867] New feature: Happy Eyeballs (RFC 8305) (#4667) Closes https://github.com/XTLS/Xray-core/issues/4473 --- infra/conf/transport_internet.go | 70 +++++--- infra/conf/transport_test.go | 31 ++-- transport/internet/config.pb.go | 231 +++++++++++++++++++-------- transport/internet/config.proto | 9 ++ transport/internet/dialer.go | 4 +- transport/internet/happy_eyeballs.go | 171 ++++++++++++++++++++ 6 files changed, 417 insertions(+), 99 deletions(-) create mode 100644 transport/internet/happy_eyeballs.go diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index b4ae0801..1a4175d8 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -699,25 +699,50 @@ type CustomSockoptConfig struct { Type string `json:"type"` } +type HappyEyeballsConfig struct { + PrioritizeIPv6 bool `json:"prioritizeIPv6"` + TryDelayMs uint64 `json:"tryDelayMs"` + Interleave uint32 `json:"interleave"` + MaxConcurrentTry uint32 `json:"maxConcurrentTry"` +} + +func (h *HappyEyeballsConfig) UnmarshalJSON(data []byte) error { + var innerHappyEyeballsConfig = struct { + PrioritizeIPv6 bool `json:"prioritizeIPv6"` + TryDelayMs uint64 `json:"tryDelayMs"` + Interleave uint32 `json:"interleave"` + MaxConcurrentTry uint32 `json:"maxConcurrentTry"` + }{PrioritizeIPv6: false, Interleave: 1, TryDelayMs: 0, MaxConcurrentTry: 4} + if err := json.Unmarshal(data, &innerHappyEyeballsConfig); err != nil { + return err + } + h.PrioritizeIPv6 = innerHappyEyeballsConfig.PrioritizeIPv6 + h.TryDelayMs = innerHappyEyeballsConfig.TryDelayMs + h.Interleave = innerHappyEyeballsConfig.Interleave + h.MaxConcurrentTry = innerHappyEyeballsConfig.MaxConcurrentTry + return nil +} + type SocketConfig struct { - Mark int32 `json:"mark"` - TFO interface{} `json:"tcpFastOpen"` - TProxy string `json:"tproxy"` - AcceptProxyProtocol bool `json:"acceptProxyProtocol"` - DomainStrategy string `json:"domainStrategy"` - DialerProxy string `json:"dialerProxy"` - TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"` - TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"` - TCPCongestion string `json:"tcpCongestion"` - TCPWindowClamp int32 `json:"tcpWindowClamp"` - TCPMaxSeg int32 `json:"tcpMaxSeg"` - Penetrate bool `json:"penetrate"` - TCPUserTimeout int32 `json:"tcpUserTimeout"` - V6only bool `json:"v6only"` - Interface string `json:"interface"` - TcpMptcp bool `json:"tcpMptcp"` - CustomSockopt []*CustomSockoptConfig `json:"customSockopt"` - AddressPortStrategy string `json:"addressPortStrategy"` + Mark int32 `json:"mark"` + TFO interface{} `json:"tcpFastOpen"` + TProxy string `json:"tproxy"` + AcceptProxyProtocol bool `json:"acceptProxyProtocol"` + DomainStrategy string `json:"domainStrategy"` + DialerProxy string `json:"dialerProxy"` + TCPKeepAliveInterval int32 `json:"tcpKeepAliveInterval"` + TCPKeepAliveIdle int32 `json:"tcpKeepAliveIdle"` + TCPCongestion string `json:"tcpCongestion"` + TCPWindowClamp int32 `json:"tcpWindowClamp"` + TCPMaxSeg int32 `json:"tcpMaxSeg"` + Penetrate bool `json:"penetrate"` + TCPUserTimeout int32 `json:"tcpUserTimeout"` + V6only bool `json:"v6only"` + Interface string `json:"interface"` + TcpMptcp bool `json:"tcpMptcp"` + CustomSockopt []*CustomSockoptConfig `json:"customSockopt"` + AddressPortStrategy string `json:"addressPortStrategy"` + HappyEyeballsSettings *HappyEyeballsConfig `json:"happyEyeballs"` } // Build implements Buildable. @@ -809,6 +834,14 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { return nil, errors.New("unsupported address and port strategy: ", c.AddressPortStrategy) } + var happyEyeballs = &internet.HappyEyeballsConfig{Interleave: 1, PrioritizeIpv6: false, TryDelayMs: 0, MaxConcurrentTry: 4} + if c.HappyEyeballsSettings != nil { + happyEyeballs.PrioritizeIpv6 = c.HappyEyeballsSettings.PrioritizeIPv6 + happyEyeballs.Interleave = c.HappyEyeballsSettings.Interleave + happyEyeballs.TryDelayMs = c.HappyEyeballsSettings.TryDelayMs + happyEyeballs.MaxConcurrentTry = c.HappyEyeballsSettings.MaxConcurrentTry + } + return &internet.SocketConfig{ Mark: c.Mark, Tfo: tfo, @@ -828,6 +861,7 @@ func (c *SocketConfig) Build() (*internet.SocketConfig, error) { TcpMptcp: c.TcpMptcp, CustomSockopt: customSockopts, AddressPortStrategy: addressPortStrategy, + HappyEyeballs: happyEyeballs, }, nil } diff --git a/infra/conf/transport_test.go b/infra/conf/transport_test.go index e7470082..87e5f920 100644 --- a/infra/conf/transport_test.go +++ b/infra/conf/transport_test.go @@ -26,6 +26,7 @@ func TestSocketConfig(t *testing.T) { Tfo: 256, DomainStrategy: internet.DomainStrategy_USE_IP, DialerProxy: "tag", + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -45,8 +46,9 @@ func TestSocketConfig(t *testing.T) { // test "tcpFastOpen": false, disabled TFO is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: -1, + Mark: 0, + Tfo: -1, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -63,8 +65,9 @@ func TestSocketConfig(t *testing.T) { // test "tcpFastOpen": 65535, queue length 65535 is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: 65535, + Mark: 0, + Tfo: 65535, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -81,8 +84,9 @@ func TestSocketConfig(t *testing.T) { // test "tcpFastOpen": -65535, disable TFO is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: -65535, + Mark: 0, + Tfo: -65535, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -99,8 +103,9 @@ func TestSocketConfig(t *testing.T) { // test "tcpFastOpen": 0, no operation is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: 0, + Mark: 0, + Tfo: 0, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -117,8 +122,9 @@ func TestSocketConfig(t *testing.T) { // test omit "tcpFastOpen", no operation is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: 0, + Mark: 0, + Tfo: 0, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { @@ -133,8 +139,9 @@ func TestSocketConfig(t *testing.T) { // test "tcpFastOpen": null, no operation is expected expectedOutput = &internet.SocketConfig{ - Mark: 0, - Tfo: 0, + Mark: 0, + Tfo: 0, + HappyEyeballs: &internet.HappyEyeballsConfig{Interleave: 1, TryDelayMs: 0, PrioritizeIpv6: false, MaxConcurrentTry: 4}, } runMultiTestCase(t, []TestCase{ { diff --git a/transport/internet/config.pb.go b/transport/internet/config.pb.go index 6aa11b3e..f974926e 100644 --- a/transport/internet/config.pb.go +++ b/transport/internet/config.pb.go @@ -511,24 +511,25 @@ type SocketConfig struct { Tproxy SocketConfig_TProxyMode `protobuf:"varint,3,opt,name=tproxy,proto3,enum=xray.transport.internet.SocketConfig_TProxyMode" json:"tproxy,omitempty"` // ReceiveOriginalDestAddress is for enabling IP_RECVORIGDSTADDR socket // option. This option is for UDP only. - ReceiveOriginalDestAddress bool `protobuf:"varint,4,opt,name=receive_original_dest_address,json=receiveOriginalDestAddress,proto3" json:"receive_original_dest_address,omitempty"` - BindAddress []byte `protobuf:"bytes,5,opt,name=bind_address,json=bindAddress,proto3" json:"bind_address,omitempty"` - BindPort uint32 `protobuf:"varint,6,opt,name=bind_port,json=bindPort,proto3" json:"bind_port,omitempty"` - AcceptProxyProtocol bool `protobuf:"varint,7,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` - DomainStrategy DomainStrategy `protobuf:"varint,8,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.transport.internet.DomainStrategy" json:"domain_strategy,omitempty"` - DialerProxy string `protobuf:"bytes,9,opt,name=dialer_proxy,json=dialerProxy,proto3" json:"dialer_proxy,omitempty"` - TcpKeepAliveInterval int32 `protobuf:"varint,10,opt,name=tcp_keep_alive_interval,json=tcpKeepAliveInterval,proto3" json:"tcp_keep_alive_interval,omitempty"` - TcpKeepAliveIdle int32 `protobuf:"varint,11,opt,name=tcp_keep_alive_idle,json=tcpKeepAliveIdle,proto3" json:"tcp_keep_alive_idle,omitempty"` - TcpCongestion string `protobuf:"bytes,12,opt,name=tcp_congestion,json=tcpCongestion,proto3" json:"tcp_congestion,omitempty"` - Interface string `protobuf:"bytes,13,opt,name=interface,proto3" json:"interface,omitempty"` - V6Only bool `protobuf:"varint,14,opt,name=v6only,proto3" json:"v6only,omitempty"` - TcpWindowClamp int32 `protobuf:"varint,15,opt,name=tcp_window_clamp,json=tcpWindowClamp,proto3" json:"tcp_window_clamp,omitempty"` - TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` - TcpMaxSeg int32 `protobuf:"varint,17,opt,name=tcp_max_seg,json=tcpMaxSeg,proto3" json:"tcp_max_seg,omitempty"` - Penetrate bool `protobuf:"varint,18,opt,name=penetrate,proto3" json:"penetrate,omitempty"` - TcpMptcp bool `protobuf:"varint,19,opt,name=tcp_mptcp,json=tcpMptcp,proto3" json:"tcp_mptcp,omitempty"` - CustomSockopt []*CustomSockopt `protobuf:"bytes,20,rep,name=customSockopt,proto3" json:"customSockopt,omitempty"` - AddressPortStrategy AddressPortStrategy `protobuf:"varint,21,opt,name=address_port_strategy,json=addressPortStrategy,proto3,enum=xray.transport.internet.AddressPortStrategy" json:"address_port_strategy,omitempty"` + ReceiveOriginalDestAddress bool `protobuf:"varint,4,opt,name=receive_original_dest_address,json=receiveOriginalDestAddress,proto3" json:"receive_original_dest_address,omitempty"` + BindAddress []byte `protobuf:"bytes,5,opt,name=bind_address,json=bindAddress,proto3" json:"bind_address,omitempty"` + BindPort uint32 `protobuf:"varint,6,opt,name=bind_port,json=bindPort,proto3" json:"bind_port,omitempty"` + AcceptProxyProtocol bool `protobuf:"varint,7,opt,name=accept_proxy_protocol,json=acceptProxyProtocol,proto3" json:"accept_proxy_protocol,omitempty"` + DomainStrategy DomainStrategy `protobuf:"varint,8,opt,name=domain_strategy,json=domainStrategy,proto3,enum=xray.transport.internet.DomainStrategy" json:"domain_strategy,omitempty"` + DialerProxy string `protobuf:"bytes,9,opt,name=dialer_proxy,json=dialerProxy,proto3" json:"dialer_proxy,omitempty"` + TcpKeepAliveInterval int32 `protobuf:"varint,10,opt,name=tcp_keep_alive_interval,json=tcpKeepAliveInterval,proto3" json:"tcp_keep_alive_interval,omitempty"` + TcpKeepAliveIdle int32 `protobuf:"varint,11,opt,name=tcp_keep_alive_idle,json=tcpKeepAliveIdle,proto3" json:"tcp_keep_alive_idle,omitempty"` + TcpCongestion string `protobuf:"bytes,12,opt,name=tcp_congestion,json=tcpCongestion,proto3" json:"tcp_congestion,omitempty"` + Interface string `protobuf:"bytes,13,opt,name=interface,proto3" json:"interface,omitempty"` + V6Only bool `protobuf:"varint,14,opt,name=v6only,proto3" json:"v6only,omitempty"` + TcpWindowClamp int32 `protobuf:"varint,15,opt,name=tcp_window_clamp,json=tcpWindowClamp,proto3" json:"tcp_window_clamp,omitempty"` + TcpUserTimeout int32 `protobuf:"varint,16,opt,name=tcp_user_timeout,json=tcpUserTimeout,proto3" json:"tcp_user_timeout,omitempty"` + TcpMaxSeg int32 `protobuf:"varint,17,opt,name=tcp_max_seg,json=tcpMaxSeg,proto3" json:"tcp_max_seg,omitempty"` + Penetrate bool `protobuf:"varint,18,opt,name=penetrate,proto3" json:"penetrate,omitempty"` + TcpMptcp bool `protobuf:"varint,19,opt,name=tcp_mptcp,json=tcpMptcp,proto3" json:"tcp_mptcp,omitempty"` + CustomSockopt []*CustomSockopt `protobuf:"bytes,20,rep,name=customSockopt,proto3" json:"customSockopt,omitempty"` + AddressPortStrategy AddressPortStrategy `protobuf:"varint,21,opt,name=address_port_strategy,json=addressPortStrategy,proto3,enum=xray.transport.internet.AddressPortStrategy" json:"address_port_strategy,omitempty"` + HappyEyeballs *HappyEyeballsConfig `protobuf:"bytes,22,opt,name=happy_eyeballs,json=happyEyeballs,proto3" json:"happy_eyeballs,omitempty"` } func (x *SocketConfig) Reset() { @@ -708,6 +709,82 @@ func (x *SocketConfig) GetAddressPortStrategy() AddressPortStrategy { return AddressPortStrategy_None } +func (x *SocketConfig) GetHappyEyeballs() *HappyEyeballsConfig { + if x != nil { + return x.HappyEyeballs + } + return nil +} + +type HappyEyeballsConfig struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + PrioritizeIpv6 bool `protobuf:"varint,1,opt,name=prioritize_ipv6,json=prioritizeIpv6,proto3" json:"prioritize_ipv6,omitempty"` + Interleave uint32 `protobuf:"varint,2,opt,name=interleave,proto3" json:"interleave,omitempty"` + TryDelayMs uint64 `protobuf:"varint,3,opt,name=try_delayMs,json=tryDelayMs,proto3" json:"try_delayMs,omitempty"` + MaxConcurrentTry uint32 `protobuf:"varint,4,opt,name=max_concurrent_try,json=maxConcurrentTry,proto3" json:"max_concurrent_try,omitempty"` +} + +func (x *HappyEyeballsConfig) Reset() { + *x = HappyEyeballsConfig{} + mi := &file_transport_internet_config_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *HappyEyeballsConfig) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HappyEyeballsConfig) ProtoMessage() {} + +func (x *HappyEyeballsConfig) ProtoReflect() protoreflect.Message { + mi := &file_transport_internet_config_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HappyEyeballsConfig.ProtoReflect.Descriptor instead. +func (*HappyEyeballsConfig) Descriptor() ([]byte, []int) { + return file_transport_internet_config_proto_rawDescGZIP(), []int{5} +} + +func (x *HappyEyeballsConfig) GetPrioritizeIpv6() bool { + if x != nil { + return x.PrioritizeIpv6 + } + return false +} + +func (x *HappyEyeballsConfig) GetInterleave() uint32 { + if x != nil { + return x.Interleave + } + return 0 +} + +func (x *HappyEyeballsConfig) GetTryDelayMs() uint64 { + if x != nil { + return x.TryDelayMs + } + return 0 +} + +func (x *HappyEyeballsConfig) GetMaxConcurrentTry() uint32 { + if x != nil { + return x.MaxConcurrentTry + } + return 0 +} + var File_transport_internet_config_proto protoreflect.FileDescriptor var file_transport_internet_config_proto_rawDesc = []byte{ @@ -766,7 +843,7 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6f, 0x70, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x22, 0xfd, 0x07, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, + 0x74, 0x79, 0x70, 0x65, 0x22, 0xd2, 0x08, 0x0a, 0x0c, 0x53, 0x6f, 0x63, 0x6b, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x6d, 0x61, 0x72, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x74, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x74, 0x66, 0x6f, 0x12, 0x48, 0x0a, 0x06, 0x74, @@ -827,37 +904,53 @@ var file_transport_internet_config_proto_rawDesc = []byte{ 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x52, 0x13, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, - 0x65, 0x67, 0x79, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x4d, 0x6f, 0x64, - 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x54, 0x50, - 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, - 0x63, 0x74, 0x10, 0x02, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, - 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x53, 0x5f, 0x49, 0x53, - 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x01, 0x12, 0x0b, - 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, 0x12, 0x0b, 0x0a, 0x07, 0x55, - 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, - 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, - 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, - 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, - 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x08, - 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x09, - 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x0a, - 0x2a, 0x97, 0x01, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x50, 0x6f, 0x72, 0x74, - 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x6f, 0x6e, 0x65, - 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, - 0x79, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x72, 0x76, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x72, 0x76, 0x50, 0x6f, - 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x03, 0x12, 0x0f, - 0x0a, 0x0b, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x04, 0x12, - 0x12, 0x0a, 0x0e, 0x54, 0x78, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, - 0x79, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, - 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x06, 0x42, 0x67, 0x0a, 0x1b, 0x63, 0x6f, - 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, - 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, - 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, 0x17, 0x58, 0x72, 0x61, 0x79, - 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, - 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x67, 0x79, 0x12, 0x53, 0x0a, 0x0e, 0x68, 0x61, 0x70, 0x70, 0x79, 0x5f, 0x65, 0x79, 0x65, + 0x62, 0x61, 0x6c, 0x6c, 0x73, 0x18, 0x16, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x78, 0x72, + 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x48, 0x61, 0x70, 0x70, 0x79, 0x45, 0x79, 0x65, 0x62, 0x61, + 0x6c, 0x6c, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0d, 0x68, 0x61, 0x70, 0x70, 0x79, + 0x45, 0x79, 0x65, 0x62, 0x61, 0x6c, 0x6c, 0x73, 0x22, 0x2f, 0x0a, 0x0a, 0x54, 0x50, 0x72, 0x6f, + 0x78, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x66, 0x66, 0x10, 0x00, 0x12, + 0x0a, 0x0a, 0x06, 0x54, 0x50, 0x72, 0x6f, 0x78, 0x79, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x52, + 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x10, 0x02, 0x22, 0xad, 0x01, 0x0a, 0x13, 0x48, 0x61, + 0x70, 0x70, 0x79, 0x45, 0x79, 0x65, 0x62, 0x61, 0x6c, 0x6c, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x12, 0x27, 0x0a, 0x0f, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x69, 0x7a, 0x65, 0x5f, + 0x69, 0x70, 0x76, 0x36, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x70, 0x72, 0x69, 0x6f, + 0x72, 0x69, 0x74, 0x69, 0x7a, 0x65, 0x49, 0x70, 0x76, 0x36, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6c, 0x65, 0x61, 0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6c, 0x65, 0x61, 0x76, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x72, + 0x79, 0x5f, 0x64, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x0a, 0x74, 0x72, 0x79, 0x44, 0x65, 0x6c, 0x61, 0x79, 0x4d, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x6d, + 0x61, 0x78, 0x5f, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x72, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x10, 0x6d, 0x61, 0x78, 0x43, 0x6f, 0x6e, 0x63, + 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x54, 0x72, 0x79, 0x2a, 0xa9, 0x01, 0x0a, 0x0e, 0x44, 0x6f, + 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x09, 0x0a, 0x05, + 0x41, 0x53, 0x5f, 0x49, 0x53, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x55, 0x53, 0x45, 0x5f, 0x49, + 0x50, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x10, 0x02, + 0x12, 0x0b, 0x0a, 0x07, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x10, 0x03, 0x12, 0x0c, 0x0a, + 0x08, 0x55, 0x53, 0x45, 0x5f, 0x49, 0x50, 0x34, 0x36, 0x10, 0x04, 0x12, 0x0c, 0x0a, 0x08, 0x55, + 0x53, 0x45, 0x5f, 0x49, 0x50, 0x36, 0x34, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x46, 0x4f, 0x52, + 0x43, 0x45, 0x5f, 0x49, 0x50, 0x10, 0x06, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, + 0x5f, 0x49, 0x50, 0x34, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, + 0x49, 0x50, 0x36, 0x10, 0x08, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, + 0x50, 0x34, 0x36, 0x10, 0x09, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4f, 0x52, 0x43, 0x45, 0x5f, 0x49, + 0x50, 0x36, 0x34, 0x10, 0x0a, 0x2a, 0x97, 0x01, 0x0a, 0x13, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x50, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x72, 0x61, 0x74, 0x65, 0x67, 0x79, 0x12, 0x08, 0x0a, + 0x04, 0x4e, 0x6f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x72, 0x76, 0x50, 0x6f, + 0x72, 0x74, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x01, 0x12, 0x12, 0x0a, 0x0e, 0x53, 0x72, 0x76, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, + 0x53, 0x72, 0x76, 0x50, 0x6f, 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x10, 0x03, 0x12, 0x0f, 0x0a, 0x0b, 0x54, 0x78, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x4f, 0x6e, + 0x6c, 0x79, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x54, 0x78, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x10, 0x05, 0x12, 0x15, 0x0a, 0x11, 0x54, 0x78, 0x74, 0x50, + 0x6f, 0x72, 0x74, 0x41, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x10, 0x06, 0x42, + 0x67, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x50, 0x01, + 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, + 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, + 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0xaa, 0x02, + 0x17, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -873,7 +966,7 @@ func file_transport_internet_config_proto_rawDescGZIP() []byte { } var file_transport_internet_config_proto_enumTypes = make([]protoimpl.EnumInfo, 3) -var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_transport_internet_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_transport_internet_config_proto_goTypes = []any{ (DomainStrategy)(0), // 0: xray.transport.internet.DomainStrategy (AddressPortStrategy)(0), // 1: xray.transport.internet.AddressPortStrategy @@ -883,24 +976,26 @@ var file_transport_internet_config_proto_goTypes = []any{ (*ProxyConfig)(nil), // 5: xray.transport.internet.ProxyConfig (*CustomSockopt)(nil), // 6: xray.transport.internet.CustomSockopt (*SocketConfig)(nil), // 7: xray.transport.internet.SocketConfig - (*serial.TypedMessage)(nil), // 8: xray.common.serial.TypedMessage - (*net.IPOrDomain)(nil), // 9: xray.common.net.IPOrDomain + (*HappyEyeballsConfig)(nil), // 8: xray.transport.internet.HappyEyeballsConfig + (*serial.TypedMessage)(nil), // 9: xray.common.serial.TypedMessage + (*net.IPOrDomain)(nil), // 10: xray.common.net.IPOrDomain } var file_transport_internet_config_proto_depIdxs = []int32{ - 8, // 0: xray.transport.internet.TransportConfig.settings:type_name -> xray.common.serial.TypedMessage - 9, // 1: xray.transport.internet.StreamConfig.address:type_name -> xray.common.net.IPOrDomain - 3, // 2: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig - 8, // 3: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage - 7, // 4: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig - 2, // 5: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode - 0, // 6: xray.transport.internet.SocketConfig.domain_strategy:type_name -> xray.transport.internet.DomainStrategy - 6, // 7: xray.transport.internet.SocketConfig.customSockopt:type_name -> xray.transport.internet.CustomSockopt - 1, // 8: xray.transport.internet.SocketConfig.address_port_strategy:type_name -> xray.transport.internet.AddressPortStrategy - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 9, // 0: xray.transport.internet.TransportConfig.settings:type_name -> xray.common.serial.TypedMessage + 10, // 1: xray.transport.internet.StreamConfig.address:type_name -> xray.common.net.IPOrDomain + 3, // 2: xray.transport.internet.StreamConfig.transport_settings:type_name -> xray.transport.internet.TransportConfig + 9, // 3: xray.transport.internet.StreamConfig.security_settings:type_name -> xray.common.serial.TypedMessage + 7, // 4: xray.transport.internet.StreamConfig.socket_settings:type_name -> xray.transport.internet.SocketConfig + 2, // 5: xray.transport.internet.SocketConfig.tproxy:type_name -> xray.transport.internet.SocketConfig.TProxyMode + 0, // 6: xray.transport.internet.SocketConfig.domain_strategy:type_name -> xray.transport.internet.DomainStrategy + 6, // 7: xray.transport.internet.SocketConfig.customSockopt:type_name -> xray.transport.internet.CustomSockopt + 1, // 8: xray.transport.internet.SocketConfig.address_port_strategy:type_name -> xray.transport.internet.AddressPortStrategy + 8, // 9: xray.transport.internet.SocketConfig.happy_eyeballs:type_name -> xray.transport.internet.HappyEyeballsConfig + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_transport_internet_config_proto_init() } @@ -914,7 +1009,7 @@ func file_transport_internet_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_transport_internet_config_proto_rawDesc, NumEnums: 3, - NumMessages: 5, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/transport/internet/config.proto b/transport/internet/config.proto index cb892c30..a40f0938 100644 --- a/transport/internet/config.proto +++ b/transport/internet/config.proto @@ -130,4 +130,13 @@ message SocketConfig { repeated CustomSockopt customSockopt = 20; AddressPortStrategy address_port_strategy = 21; + + HappyEyeballsConfig happy_eyeballs = 22; +} + +message HappyEyeballsConfig { + bool prioritize_ipv6 = 1; + uint32 interleave = 2; + uint64 try_delayMs = 3; + uint32 max_concurrent_try = 4; } diff --git a/transport/internet/dialer.go b/transport/internet/dialer.go index 74e5f0b6..5e403f67 100644 --- a/transport/internet/dialer.go +++ b/transport/internet/dialer.go @@ -255,9 +255,11 @@ func DialSystem(ctx context.Context, dest net.Destination, sockopt *SocketConfig if sockopt.DomainStrategy.forceIP() { return nil, err } - } else { + } else if sockopt.HappyEyeballs == nil || sockopt.HappyEyeballs.TryDelayMs == 0 || sockopt.HappyEyeballs.MaxConcurrentTry == 0 || len(ips) < 2 || len(sockopt.DialerProxy) > 0 || dest.Network != net.Network_TCP { dest.Address = net.IPAddress(ips[dice.Roll(len(ips))]) errors.LogInfo(ctx, "replace destination with "+dest.String()) + } else { + return TcpRaceDial(ctx, src, ips, dest.Port, sockopt) } } diff --git a/transport/internet/happy_eyeballs.go b/transport/internet/happy_eyeballs.go new file mode 100644 index 00000000..10adb235 --- /dev/null +++ b/transport/internet/happy_eyeballs.go @@ -0,0 +1,171 @@ +package internet + +import ( + "context" + "github.com/xtls/xray-core/common/net" + "time" +) + +type result struct { + err error + conn net.Conn + index int +} + +func TcpRaceDial(ctx context.Context, src net.Address, ips []net.IP, port net.Port, sockopt *SocketConfig) (net.Conn, error) { + if len(ips) < 2 { + panic("at least 2 ips is required to race dial") + } + + prioritizeIPv6 := sockopt.HappyEyeballs.PrioritizeIpv6 + interleave := sockopt.HappyEyeballs.Interleave + tryDelayMs := time.Duration(sockopt.HappyEyeballs.TryDelayMs) * time.Millisecond + maxConcurrentTry := sockopt.HappyEyeballs.MaxConcurrentTry + + ips = sortIPs(ips, prioritizeIPv6, interleave) + newCtx, cancel := context.WithCancel(ctx) + defer cancel() + var resultCh = make(chan *result, len(ips)) + nextTryIndex := 0 + activeNum := uint32(0) + timer := time.NewTimer(0) + var winConn net.Conn + for { + select { + case r := <-resultCh: + activeNum-- + select { + case <-ctx.Done(): + cancel() + timer.Stop() + if winConn != nil { + winConn.Close() + } + if r.conn != nil { + r.conn.Close() + } + if activeNum == 0 { + return nil, ctx.Err() + } + continue + default: + if r.conn != nil { + cancel() + timer.Stop() + if winConn == nil { + winConn = r.conn + } else { + r.conn.Close() + } + } + if winConn != nil && activeNum == 0 { + return winConn, nil + } + if winConn != nil { + continue + } + if nextTryIndex < len(ips) { + timer.Reset(0) + continue + } + if activeNum == 0 { + return nil, r.err + } + timer.Stop() + continue + } + + case <-timer.C: + if nextTryIndex == len(ips) || activeNum == maxConcurrentTry { + panic("impossible situation") + } + go tcpTryDial(newCtx, src, sockopt, ips[nextTryIndex], port, nextTryIndex, resultCh) + activeNum++ + nextTryIndex++ + if nextTryIndex == len(ips) || activeNum == maxConcurrentTry { + timer.Stop() + } else { + timer.Reset(tryDelayMs) + } + continue + } + } +} + +// sortIPs sort IPs according to rfc 8305. +func sortIPs(ips []net.IP, prioritizeIPv6 bool, interleave uint32) []net.IP { + if len(ips) == 0 { + return ips + } + var ip4 = make([]net.IP, 0, len(ips)) + var ip6 = make([]net.IP, 0, len(ips)) + for _, ip := range ips { + parsedIp := net.IPAddress(ip).IP() + if len(parsedIp) == net.IPv4len { + ip4 = append(ip4, parsedIp) + } else { + ip6 = append(ip6, parsedIp) + } + } + + if len(ip4) == 0 || len(ip6) == 0 { + return ips + } + + var newIPs = make([]net.IP, 0, len(ips)) + consumeIP4 := 0 + consumeIP6 := 0 + consumeTurn := uint32(0) + ip4turn := true + if prioritizeIPv6 { + ip4turn = false + } + for { + if ip4turn { + newIPs = append(newIPs, ip4[consumeIP4]) + consumeIP4++ + if consumeIP4 == len(ip4) { + newIPs = append(newIPs, ip6[consumeIP6:]...) + break + } + consumeTurn++ + if consumeTurn == interleave { + ip4turn = false + consumeTurn = uint32(0) + } + } else { + newIPs = append(newIPs, ip6[consumeIP6]) + consumeIP6++ + if consumeIP6 == len(ip6) { + newIPs = append(newIPs, ip4[consumeIP4:]...) + break + } + consumeTurn++ + if consumeTurn == interleave { + ip4turn = true + consumeTurn = uint32(0) + } + } + } + + return newIPs +} + +func tcpTryDial(ctx context.Context, src net.Address, sockopt *SocketConfig, ip net.IP, port net.Port, index int, resultCh chan<- *result) { + conn, err := effectiveSystemDialer.Dial(ctx, src, net.Destination{Address: net.IPAddress(ip), Network: net.Network_TCP, Port: port}, sockopt) + select { + case <-ctx.Done(): + if conn != nil { + conn.Close() + } + resultCh <- &result{err: ctx.Err(), index: index} + return + default: + if err != nil { + resultCh <- &result{err: err, index: index} + return + } + resultCh <- &result{conn: conn, index: index} + return + } +} From 402067d281febb813cea526b1fb83e0eb2a448f0 Mon Sep 17 00:00:00 2001 From: Meow <197331664+Meo597@users.noreply.github.com> Date: Sat, 7 Jun 2025 21:24:39 +0800 Subject: [PATCH 849/867] Tests: Fix TestCommanderListHandlers (#4789) --- testing/scenarios/command_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testing/scenarios/command_test.go b/testing/scenarios/command_test.go index e562952b..c7914752 100644 --- a/testing/scenarios/command_test.go +++ b/testing/scenarios/command_test.go @@ -286,8 +286,8 @@ func TestCommanderListHandlers(t *testing.T) { t.Error("unexpected nil response") } - if !cmp.Equal(inboundResp.Inbounds, clientConfig.Inbound, protocmp.Transform()) { - t.Fatal("inbound response doesn't match config") + if diff := cmp.Diff(inboundResp.Inbounds, clientConfig.Inbound, protocmp.Transform()); diff != "" { + t.Fatalf("inbound response doesn't match config (-want +got):\n%s", diff) } outboundResp, err := hsClient.ListOutbounds(context.Background(), &command.ListOutboundsRequest{}) @@ -296,8 +296,8 @@ func TestCommanderListHandlers(t *testing.T) { t.Error("unexpected nil response") } - if !cmp.Equal(outboundResp.Outbounds, clientConfig.Outbound, protocmp.Transform()) { - t.Fatal("outbound response doesn't match config") + if diff := cmp.Diff(outboundResp.Outbounds, clientConfig.Outbound, protocmp.Transform()); diff != "" { + t.Fatalf("outbound response doesn't match config (-want +got):\n%s", diff) } } From f38d3f786a47997533e4a2dd5283c63f0d4eefa0 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 7 Jun 2025 13:37:24 +0000 Subject: [PATCH 850/867] v25.6.7 Announcement of NFTs by Project X: #3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: #4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/core.go b/core/core.go index 03d00191..15405bb8 100644 --- a/core/core.go +++ b/core/core.go @@ -18,8 +18,8 @@ import ( var ( Version_x byte = 25 - Version_y byte = 5 - Version_z byte = 16 + Version_y byte = 6 + Version_z byte = 7 ) var ( From a576a4b183ba3206c2938d4adbb542af7a20760a Mon Sep 17 00:00:00 2001 From: Meow <197331664+Meo597@users.noreply.github.com> Date: Sun, 8 Jun 2025 12:47:04 +0800 Subject: [PATCH 851/867] Tests: Real fix for TestCommanderListHandlers (#4792) Completes https://github.com/XTLS/Xray-core/commit/402067d281febb813cea526b1fb83e0eb2a448f0 --- testing/scenarios/command_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/testing/scenarios/command_test.go b/testing/scenarios/command_test.go index c7914752..8ee9e4bf 100644 --- a/testing/scenarios/command_test.go +++ b/testing/scenarios/command_test.go @@ -286,7 +286,13 @@ func TestCommanderListHandlers(t *testing.T) { t.Error("unexpected nil response") } - if diff := cmp.Diff(inboundResp.Inbounds, clientConfig.Inbound, protocmp.Transform()); diff != "" { + if diff := cmp.Diff( + inboundResp.Inbounds, + clientConfig.Inbound, + protocmp.Transform(), + cmpopts.SortSlices(func(a, b *core.InboundHandlerConfig) bool { + return a.Tag < b.Tag + })); diff != "" { t.Fatalf("inbound response doesn't match config (-want +got):\n%s", diff) } @@ -296,7 +302,13 @@ func TestCommanderListHandlers(t *testing.T) { t.Error("unexpected nil response") } - if diff := cmp.Diff(outboundResp.Outbounds, clientConfig.Outbound, protocmp.Transform()); diff != "" { + if diff := cmp.Diff( + outboundResp.Outbounds, + clientConfig.Outbound, + protocmp.Transform(), + cmpopts.SortSlices(func(a, b *core.InboundHandlerConfig) bool { + return a.Tag < b.Tag + })); diff != "" { t.Fatalf("outbound response doesn't match config (-want +got):\n%s", diff) } } From 7d36cad3e0de986f4ef80576073d0b035477bdc6 Mon Sep 17 00:00:00 2001 From: Meow <197331664+Meo597@users.noreply.github.com> Date: Sun, 8 Jun 2025 12:49:26 +0800 Subject: [PATCH 852/867] Docker: Fix geodata directory permissions issue (#4790) Fixes https://github.com/XTLS/Xray-core/issues/4747#issuecomment-2953519012 --- .github/docker/Dockerfile | 1 + .github/docker/Dockerfile.usa | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/docker/Dockerfile b/.github/docker/Dockerfile index b7a871f0..0b6f2932 100644 --- a/.github/docker/Dockerfile +++ b/.github/docker/Dockerfile @@ -45,6 +45,7 @@ RUN mkdir -p /tmp/var/log/xray && touch \ FROM gcr.io/distroless/static:nonroot COPY --from=build --chown=0:0 --chmod=755 /src/xray /usr/local/bin/xray +COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /usr/local/share/xray COPY --from=build --chown=0:0 --chmod=644 /tmp/geodat/*.dat /usr/local/share/xray/ COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /usr/local/etc/xray COPY --from=build --chown=0:0 --chmod=644 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/ diff --git a/.github/docker/Dockerfile.usa b/.github/docker/Dockerfile.usa index 5709e246..b307bc4b 100644 --- a/.github/docker/Dockerfile.usa +++ b/.github/docker/Dockerfile.usa @@ -54,6 +54,7 @@ RUN mkdir -p /tmp/var/log/xray && touch \ FROM --platform=linux/amd64 gcr.io/distroless/static:nonroot COPY --from=build --chown=0:0 --chmod=755 /src/xray /usr/local/bin/xray +COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /usr/local/share/xray COPY --from=build --chown=0:0 --chmod=644 /tmp/geodat/*.dat /usr/local/share/xray/ COPY --from=build --chown=0:0 --chmod=755 /tmp/empty /usr/local/etc/xray COPY --from=build --chown=0:0 --chmod=644 /tmp/usr/local/etc/xray/*.json /usr/local/etc/xray/ From f4b23c65655ad7e934e70da86badc479d706939b Mon Sep 17 00:00:00 2001 From: TonyMa1 <103111895+TonyMa1@users.noreply.github.com> Date: Sun, 8 Jun 2025 11:51:10 +0700 Subject: [PATCH 853/867] README.md: Add DeepWiki badge to Contributing (#4777) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 62220553..29e41b95 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,8 @@ [Code of Conduct](https://github.com/XTLS/Xray-core/blob/main/CODE_OF_CONDUCT.md) +[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/XTLS/Xray-core) + ## Credits - [Xray-core v1.0.0](https://github.com/XTLS/Xray-core/releases/tag/v1.0.0) was forked from [v2fly-core 9a03cc5](https://github.com/v2fly/v2ray-core/commit/9a03cc5c98d04cc28320fcee26dbc236b3291256), and we have made & accumulated a huge number of enhancements over time, check [the release notes for each version](https://github.com/XTLS/Xray-core/releases). From e011b746dc8959df61996a7422b4dece965151c3 Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 8 Jun 2025 05:01:31 +0000 Subject: [PATCH 854/867] RAW transport hub.go: Call REALITY's DetectPostHandshakeRecordsLens() in advance https://github.com/XTLS/Xray-core/issues/4778#issuecomment-2953455751 --- transport/internet/tcp/hub.go | 1 + 1 file changed, 1 insertion(+) diff --git a/transport/internet/tcp/hub.go b/transport/internet/tcp/hub.go index 84e39163..8747fca2 100644 --- a/transport/internet/tcp/hub.go +++ b/transport/internet/tcp/hub.go @@ -72,6 +72,7 @@ func ListenTCP(ctx context.Context, address net.Address, port net.Port, streamSe } if config := reality.ConfigFromStreamSettings(streamSettings); config != nil { l.realityConfig = config.GetREALITYConfig() + go goreality.DetectPostHandshakeRecordsLens(l.realityConfig) } if tcpSettings.HeaderSettings != nil { From 18ab291e0c46e750b6e3b2f842b63b7222bbb6b2 Mon Sep 17 00:00:00 2001 From: Meow <197331664+Meo597@users.noreply.github.com> Date: Sun, 8 Jun 2025 21:43:55 +0800 Subject: [PATCH 855/867] REALITY: Add rate limiting to fallback handling via token bucket (#4553) https://github.com/XTLS/REALITY/pull/12 --- go.mod | 3 +- go.sum | 6 +- infra/conf/transport_internet.go | 18 +++ transport/internet/reality/config.go | 10 ++ transport/internet/reality/config.pb.go | 173 +++++++++++++++++++----- transport/internet/reality/config.proto | 9 ++ 6 files changed, 180 insertions(+), 39 deletions(-) diff --git a/go.mod b/go.mod index d10a5a54..2b589d1c 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/stretchr/testify v1.10.0 github.com/v2fly/ss-bloomring v0.0.0-20210312155135-28617310f63e github.com/vishvananda/netlink v1.3.1 - github.com/xtls/reality v0.0.0-20250607105625-90e738a94c8c + github.com/xtls/reality v0.0.0-20250608132114-50752aec6bfb go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.39.0 golang.org/x/net v0.41.0 @@ -41,6 +41,7 @@ require ( github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/pprof v0.0.0-20240528025155-186aa0362fba // indirect + github.com/juju/ratelimit v1.0.2 // indirect github.com/klauspost/compress v1.17.8 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/onsi/ginkgo/v2 v2.19.0 // indirect diff --git a/go.sum b/go.sum index 28bf3ad9..c0fb7cb8 100644 --- a/go.sum +++ b/go.sum @@ -34,6 +34,8 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364 h1:5XxdakFhqd9dnXoAZy1Mb2R/DZ6D1e+0bGC/JhucGYI= github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364/go.mod h1:eDJQioIyy4Yn3MVivT7rv/39gAJTrA7lgmYr8EW950c= +github.com/juju/ratelimit v1.0.2 h1:sRxmtRiajbvrcLQT7S+JbqU0ntsb9W2yhSdNN8tWfaI= +github.com/juju/ratelimit v1.0.2/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= @@ -76,8 +78,8 @@ github.com/vishvananda/netlink v1.3.1 h1:3AEMt62VKqz90r0tmNhog0r/PpWKmrEShJU0wJW github.com/vishvananda/netlink v1.3.1/go.mod h1:ARtKouGSTGchR8aMwmkzC0qiNPrrWO5JS/XMVl45+b4= github.com/vishvananda/netns v0.0.5 h1:DfiHV+j8bA32MFM7bfEunvT8IAqQ/NzSJHtcmW5zdEY= github.com/vishvananda/netns v0.0.5/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= -github.com/xtls/reality v0.0.0-20250607105625-90e738a94c8c h1:GiY3/SynO0ujSH3rQDEIrE4MTTZM9KHufR3zx3JLD3c= -github.com/xtls/reality v0.0.0-20250607105625-90e738a94c8c/go.mod h1:Rkdcxe9Yd8SWQRRP+LSvX6wxk1m4lmNkyUZEHzbPDZw= +github.com/xtls/reality v0.0.0-20250608132114-50752aec6bfb h1:X6ziJCMsFF8Ac/0F3W7+UbFdHZTu+r5nZ/smksHVxNQ= +github.com/xtls/reality v0.0.0-20250608132114-50752aec6bfb/go.mod h1:yD47RN65bDLZgyHWMfFDiqlzrq4usDMt/Xzsk6tMbhw= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 1a4175d8..d762be32 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -486,6 +486,12 @@ func (c *TLSConfig) Build() (proto.Message, error) { return config, nil } +type LimitFallback struct { + AfterBytes uint64 + BytesPerSec uint64 + BurstBytesPerSec uint64 +} + type REALITYConfig struct { MasterKeyLog string `json:"masterKeyLog"` Show bool `json:"show"` @@ -500,6 +506,9 @@ type REALITYConfig struct { MaxTimeDiff uint64 `json:"maxTimeDiff"` ShortIds []string `json:"shortIds"` + LimitFallbackUpload LimitFallback `json:"limitFallbackUpload"` + LimitFallbackDownload LimitFallback `json:"limitFallbackDownload"` + Fingerprint string `json:"fingerprint"` ServerName string `json:"serverName"` Password string `json:"password"` @@ -600,6 +609,15 @@ func (c *REALITYConfig) Build() (proto.Message, error) { config.Xver = c.Xver config.ServerNames = c.ServerNames config.MaxTimeDiff = c.MaxTimeDiff + + config.LimitFallbackUpload = new(reality.LimitFallback) + config.LimitFallbackUpload.AfterBytes = c.LimitFallbackUpload.AfterBytes + config.LimitFallbackUpload.BytesPerSec = c.LimitFallbackUpload.BytesPerSec + config.LimitFallbackUpload.BurstBytesPerSec = c.LimitFallbackUpload.BurstBytesPerSec + config.LimitFallbackDownload = new(reality.LimitFallback) + config.LimitFallbackDownload.AfterBytes = c.LimitFallbackDownload.AfterBytes + config.LimitFallbackDownload.BytesPerSec = c.LimitFallbackDownload.BytesPerSec + config.LimitFallbackDownload.BurstBytesPerSec = c.LimitFallbackDownload.BurstBytesPerSec } else { config.Fingerprint = strings.ToLower(c.Fingerprint) if config.Fingerprint == "unsafe" || config.Fingerprint == "hellogolang" { diff --git a/transport/internet/reality/config.go b/transport/internet/reality/config.go index 406494da..61674bb8 100644 --- a/transport/internet/reality/config.go +++ b/transport/internet/reality/config.go @@ -32,6 +32,16 @@ func (c *Config) GetREALITYConfig() *reality.Config { KeyLogWriter: KeyLogWriterFromConfig(c), } + if c.LimitFallbackUpload != nil { + config.LimitFallbackUpload.AfterBytes = c.LimitFallbackUpload.AfterBytes + config.LimitFallbackUpload.BytesPerSec = c.LimitFallbackUpload.BytesPerSec + config.LimitFallbackUpload.BurstBytesPerSec = c.LimitFallbackUpload.BurstBytesPerSec + } + if c.LimitFallbackDownload != nil { + config.LimitFallbackDownload.AfterBytes = c.LimitFallbackDownload.AfterBytes + config.LimitFallbackDownload.BytesPerSec = c.LimitFallbackDownload.BytesPerSec + config.LimitFallbackDownload.BurstBytesPerSec = c.LimitFallbackDownload.BurstBytesPerSec + } config.ServerNames = make(map[string]bool) for _, serverName := range c.ServerNames { config.ServerNames[serverName] = true diff --git a/transport/internet/reality/config.pb.go b/transport/internet/reality/config.pb.go index 81038552..c27c743b 100644 --- a/transport/internet/reality/config.pb.go +++ b/transport/internet/reality/config.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.35.1 -// protoc v5.28.2 +// protoc v5.29.4 // source: transport/internet/reality/config.proto package reality @@ -25,23 +25,25 @@ type Config struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Show bool `protobuf:"varint,1,opt,name=show,proto3" json:"show,omitempty"` - Dest string `protobuf:"bytes,2,opt,name=dest,proto3" json:"dest,omitempty"` - Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` - Xver uint64 `protobuf:"varint,4,opt,name=xver,proto3" json:"xver,omitempty"` - ServerNames []string `protobuf:"bytes,5,rep,name=server_names,json=serverNames,proto3" json:"server_names,omitempty"` - PrivateKey []byte `protobuf:"bytes,6,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` - MinClientVer []byte `protobuf:"bytes,7,opt,name=min_client_ver,json=minClientVer,proto3" json:"min_client_ver,omitempty"` - MaxClientVer []byte `protobuf:"bytes,8,opt,name=max_client_ver,json=maxClientVer,proto3" json:"max_client_ver,omitempty"` - MaxTimeDiff uint64 `protobuf:"varint,9,opt,name=max_time_diff,json=maxTimeDiff,proto3" json:"max_time_diff,omitempty"` - ShortIds [][]byte `protobuf:"bytes,10,rep,name=short_ids,json=shortIds,proto3" json:"short_ids,omitempty"` - Fingerprint string `protobuf:"bytes,21,opt,name=Fingerprint,proto3" json:"Fingerprint,omitempty"` - ServerName string `protobuf:"bytes,22,opt,name=server_name,json=serverName,proto3" json:"server_name,omitempty"` - PublicKey []byte `protobuf:"bytes,23,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` - ShortId []byte `protobuf:"bytes,24,opt,name=short_id,json=shortId,proto3" json:"short_id,omitempty"` - SpiderX string `protobuf:"bytes,25,opt,name=spider_x,json=spiderX,proto3" json:"spider_x,omitempty"` - SpiderY []int64 `protobuf:"varint,26,rep,packed,name=spider_y,json=spiderY,proto3" json:"spider_y,omitempty"` - MasterKeyLog string `protobuf:"bytes,27,opt,name=master_key_log,json=masterKeyLog,proto3" json:"master_key_log,omitempty"` + Show bool `protobuf:"varint,1,opt,name=show,proto3" json:"show,omitempty"` + Dest string `protobuf:"bytes,2,opt,name=dest,proto3" json:"dest,omitempty"` + Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"` + Xver uint64 `protobuf:"varint,4,opt,name=xver,proto3" json:"xver,omitempty"` + ServerNames []string `protobuf:"bytes,5,rep,name=server_names,json=serverNames,proto3" json:"server_names,omitempty"` + PrivateKey []byte `protobuf:"bytes,6,opt,name=private_key,json=privateKey,proto3" json:"private_key,omitempty"` + MinClientVer []byte `protobuf:"bytes,7,opt,name=min_client_ver,json=minClientVer,proto3" json:"min_client_ver,omitempty"` + MaxClientVer []byte `protobuf:"bytes,8,opt,name=max_client_ver,json=maxClientVer,proto3" json:"max_client_ver,omitempty"` + MaxTimeDiff uint64 `protobuf:"varint,9,opt,name=max_time_diff,json=maxTimeDiff,proto3" json:"max_time_diff,omitempty"` + ShortIds [][]byte `protobuf:"bytes,10,rep,name=short_ids,json=shortIds,proto3" json:"short_ids,omitempty"` + Fingerprint string `protobuf:"bytes,21,opt,name=Fingerprint,proto3" json:"Fingerprint,omitempty"` + ServerName string `protobuf:"bytes,22,opt,name=server_name,json=serverName,proto3" json:"server_name,omitempty"` + PublicKey []byte `protobuf:"bytes,23,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + ShortId []byte `protobuf:"bytes,24,opt,name=short_id,json=shortId,proto3" json:"short_id,omitempty"` + SpiderX string `protobuf:"bytes,25,opt,name=spider_x,json=spiderX,proto3" json:"spider_x,omitempty"` + SpiderY []int64 `protobuf:"varint,26,rep,packed,name=spider_y,json=spiderY,proto3" json:"spider_y,omitempty"` + MasterKeyLog string `protobuf:"bytes,27,opt,name=master_key_log,json=masterKeyLog,proto3" json:"master_key_log,omitempty"` + LimitFallbackUpload *LimitFallback `protobuf:"bytes,28,opt,name=limit_fallback_upload,json=limitFallbackUpload,proto3" json:"limit_fallback_upload,omitempty"` + LimitFallbackDownload *LimitFallback `protobuf:"bytes,29,opt,name=limit_fallback_download,json=limitFallbackDownload,proto3" json:"limit_fallback_download,omitempty"` } func (x *Config) Reset() { @@ -193,6 +195,81 @@ func (x *Config) GetMasterKeyLog() string { return "" } +func (x *Config) GetLimitFallbackUpload() *LimitFallback { + if x != nil { + return x.LimitFallbackUpload + } + return nil +} + +func (x *Config) GetLimitFallbackDownload() *LimitFallback { + if x != nil { + return x.LimitFallbackDownload + } + return nil +} + +type LimitFallback struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + AfterBytes uint64 `protobuf:"varint,1,opt,name=after_bytes,json=afterBytes,proto3" json:"after_bytes,omitempty"` + BytesPerSec uint64 `protobuf:"varint,2,opt,name=bytes_per_sec,json=bytesPerSec,proto3" json:"bytes_per_sec,omitempty"` + BurstBytesPerSec uint64 `protobuf:"varint,3,opt,name=burst_bytes_per_sec,json=burstBytesPerSec,proto3" json:"burst_bytes_per_sec,omitempty"` +} + +func (x *LimitFallback) Reset() { + *x = LimitFallback{} + mi := &file_transport_internet_reality_config_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *LimitFallback) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*LimitFallback) ProtoMessage() {} + +func (x *LimitFallback) ProtoReflect() protoreflect.Message { + mi := &file_transport_internet_reality_config_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use LimitFallback.ProtoReflect.Descriptor instead. +func (*LimitFallback) Descriptor() ([]byte, []int) { + return file_transport_internet_reality_config_proto_rawDescGZIP(), []int{1} +} + +func (x *LimitFallback) GetAfterBytes() uint64 { + if x != nil { + return x.AfterBytes + } + return 0 +} + +func (x *LimitFallback) GetBytesPerSec() uint64 { + if x != nil { + return x.BytesPerSec + } + return 0 +} + +func (x *LimitFallback) GetBurstBytesPerSec() uint64 { + if x != nil { + return x.BurstBytesPerSec + } + return 0 +} + var File_transport_internet_reality_config_proto protoreflect.FileDescriptor var file_transport_internet_reality_config_proto_rawDesc = []byte{ @@ -200,7 +277,7 @@ var file_transport_internet_reality_config_proto_rawDesc = []byte{ 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1f, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, - 0x65, 0x74, 0x2e, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x22, 0x82, 0x04, 0x0a, 0x06, 0x43, + 0x65, 0x74, 0x2e, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x22, 0xce, 0x05, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x68, 0x6f, 0x77, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x73, 0x68, 0x6f, 0x77, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x65, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, @@ -232,16 +309,37 @@ var file_transport_internet_reality_config_proto_rawDesc = []byte{ 0x0a, 0x08, 0x73, 0x70, 0x69, 0x64, 0x65, 0x72, 0x5f, 0x79, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x03, 0x52, 0x07, 0x73, 0x70, 0x69, 0x64, 0x65, 0x72, 0x59, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x6c, 0x6f, 0x67, 0x18, 0x1b, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, 0x42, - 0x7f, 0x0a, 0x23, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, + 0x09, 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x4b, 0x65, 0x79, 0x4c, 0x6f, 0x67, 0x12, + 0x62, 0x0a, 0x15, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x5f, 0x66, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x5f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x1c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, + 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, + 0x2e, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x52, 0x13, + 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x55, 0x70, 0x6c, + 0x6f, 0x61, 0x64, 0x12, 0x66, 0x0a, 0x17, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x5f, 0x66, 0x61, 0x6c, + 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x5f, 0x64, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x18, 0x1d, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x72, - 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, 0x2d, 0x63, - 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, 0x69, 0x6e, - 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0xaa, 0x02, - 0x1f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, - 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x46, 0x61, 0x6c, 0x6c, + 0x62, 0x61, 0x63, 0x6b, 0x52, 0x15, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x46, 0x61, 0x6c, 0x6c, 0x62, + 0x61, 0x63, 0x6b, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x83, 0x01, 0x0a, 0x0d, + 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x46, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x1f, 0x0a, + 0x0b, 0x61, 0x66, 0x74, 0x65, 0x72, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x0a, 0x61, 0x66, 0x74, 0x65, 0x72, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x22, + 0x0a, 0x0d, 0x62, 0x79, 0x74, 0x65, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x63, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, + 0x65, 0x63, 0x12, 0x2d, 0x0a, 0x13, 0x62, 0x75, 0x72, 0x73, 0x74, 0x5f, 0x62, 0x79, 0x74, 0x65, + 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x73, 0x65, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x10, 0x62, 0x75, 0x72, 0x73, 0x74, 0x42, 0x79, 0x74, 0x65, 0x73, 0x50, 0x65, 0x72, 0x53, 0x65, + 0x63, 0x42, 0x7f, 0x0a, 0x23, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x74, 0x72, + 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, + 0x2e, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, + 0x2d, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, 0x74, 0x2f, + 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2f, 0x72, 0x65, 0x61, 0x6c, 0x69, 0x74, 0x79, + 0xaa, 0x02, 0x1f, 0x58, 0x72, 0x61, 0x79, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x70, 0x6f, 0x72, + 0x74, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x2e, 0x52, 0x65, 0x61, 0x6c, 0x69, + 0x74, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -256,16 +354,19 @@ func file_transport_internet_reality_config_proto_rawDescGZIP() []byte { return file_transport_internet_reality_config_proto_rawDescData } -var file_transport_internet_reality_config_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_transport_internet_reality_config_proto_msgTypes = make([]protoimpl.MessageInfo, 2) var file_transport_internet_reality_config_proto_goTypes = []any{ - (*Config)(nil), // 0: xray.transport.internet.reality.Config + (*Config)(nil), // 0: xray.transport.internet.reality.Config + (*LimitFallback)(nil), // 1: xray.transport.internet.reality.LimitFallback } var file_transport_internet_reality_config_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: xray.transport.internet.reality.Config.limit_fallback_upload:type_name -> xray.transport.internet.reality.LimitFallback + 1, // 1: xray.transport.internet.reality.Config.limit_fallback_download:type_name -> xray.transport.internet.reality.LimitFallback + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_transport_internet_reality_config_proto_init() } @@ -279,7 +380,7 @@ func file_transport_internet_reality_config_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_transport_internet_reality_config_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 2, NumExtensions: 0, NumServices: 0, }, diff --git a/transport/internet/reality/config.proto b/transport/internet/reality/config.proto index 233f6e05..83bff69f 100644 --- a/transport/internet/reality/config.proto +++ b/transport/internet/reality/config.proto @@ -25,4 +25,13 @@ message Config { string spider_x = 25; repeated int64 spider_y = 26; string master_key_log = 27; + + LimitFallback limit_fallback_upload = 28; + LimitFallback limit_fallback_download = 29; +} + +message LimitFallback { + uint64 after_bytes = 1; + uint64 bytes_per_sec = 2; + uint64 burst_bytes_per_sec = 3; } From ca1c4b63f6199600c328ddbc8c7a4604be8f3213 Mon Sep 17 00:00:00 2001 From: Yury Kastov Date: Sun, 8 Jun 2025 16:47:23 +0300 Subject: [PATCH 856/867] README.md: Add xtls-sdk to Xray Wrapper (#4793) Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com> --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 29e41b95..5cf33e9e 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ - [xray-checker](https://github.com/kutovoys/xray-checker) - Xray Wrapper - [XTLS/libXray](https://github.com/XTLS/libXray) + - [xtls-sdk](https://github.com/remnawave/xtls-sdk) - [xtlsapi](https://github.com/hiddify/xtlsapi) - [AndroidLibXrayLite](https://github.com/2dust/AndroidLibXrayLite) - [Xray-core-python](https://github.com/LorenEteval/Xray-core-python) From 58c28b4aeb1669ac72ef5e97e914f5008f0b714e Mon Sep 17 00:00:00 2001 From: ketetefid Date: Sun, 8 Jun 2025 17:21:39 +0330 Subject: [PATCH 857/867] README.md: Add GorzRay to Linux Clients (#4767) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5cf33e9e..ffa4f547 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ - Linux - [v2rayA](https://github.com/v2rayA/v2rayA) - [Furious](https://github.com/LorenEteval/Furious) + - [GorzRay](https://github.com/ketetefid/GorzRay) ## Others that support VLESS, XTLS, REALITY, XUDP, PLUX... From fbae89d017aee5947598d0a82945b316fdc688ab Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sun, 8 Jun 2025 13:53:03 +0000 Subject: [PATCH 858/867] v25.6.8 Announcement of NFTs by Project X: https://github.com/XTLS/Xray-core/discussions/3633 Project X NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/1 XHTTP: Beyond REALITY: https://github.com/XTLS/Xray-core/discussions/4113 REALITY NFT: https://opensea.io/assets/ethereum/0x5ee362866001613093361eb8569d59c4141b76d1/2 --- core/core.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/core.go b/core/core.go index 15405bb8..99ed573e 100644 --- a/core/core.go +++ b/core/core.go @@ -19,7 +19,7 @@ import ( var ( Version_x byte = 25 Version_y byte = 6 - Version_z byte = 7 + Version_z byte = 8 ) var ( From 27742da2c607a02d2ac55040bdacefff0d4cd1c7 Mon Sep 17 00:00:00 2001 From: Jesus <75259437+Jolymmiles@users.noreply.github.com> Date: Mon, 23 Jun 2025 05:48:49 +0400 Subject: [PATCH 859/867] BurstObservatory: add option to set http method for burst check (#4835) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add options to set method for burst check. * chore: gen proto. * chore: change protoc-gen-go to latest. * revert --------- Co-authored-by: 风扇滑翔翼 --- app/observatory/burst/config.pb.go | 15 +++++++++++++-- app/observatory/burst/config.proto | 3 +++ app/observatory/burst/healthping.go | 14 ++++++++++++-- app/observatory/burst/ping.go | 15 ++++++++++++--- infra/conf/router_strategy.go | 9 +++++++++ 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/app/observatory/burst/config.pb.go b/app/observatory/burst/config.pb.go index ffbd0689..570384ae 100644 --- a/app/observatory/burst/config.pb.go +++ b/app/observatory/burst/config.pb.go @@ -90,6 +90,8 @@ type HealthPingConfig struct { SamplingCount int32 `protobuf:"varint,4,opt,name=samplingCount,proto3" json:"samplingCount,omitempty"` // ping timeout, int64 values of time.Duration Timeout int64 `protobuf:"varint,5,opt,name=timeout,proto3" json:"timeout,omitempty"` + // http method to make request + HttpMethod string `protobuf:"bytes,6,opt,name=httpMethod,proto3" json:"httpMethod,omitempty"` } func (x *HealthPingConfig) Reset() { @@ -157,6 +159,13 @@ func (x *HealthPingConfig) GetTimeout() int64 { return 0 } +func (x *HealthPingConfig) GetHttpMethod() string { + if x != nil { + return x.HttpMethod + } + return "" +} + var File_app_observatory_burst_config_proto protoreflect.FileDescriptor var file_app_observatory_burst_config_proto_rawDesc = []byte{ @@ -173,7 +182,7 @@ var file_app_observatory_burst_config_proto_rawDesc = []byte{ 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x62, 0x75, 0x72, 0x73, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0a, 0x70, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, - 0xb4, 0x01, 0x0a, 0x10, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6f, + 0xd4, 0x01, 0x0a, 0x10, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x50, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x22, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, @@ -184,7 +193,9 @@ var file_app_observatory_burst_config_proto_rawDesc = []byte{ 0x6e, 0x67, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0d, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x69, 0x6e, 0x67, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, - 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x42, 0x70, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, + 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x68, 0x74, 0x74, 0x70, 0x4d, 0x65, + 0x74, 0x68, 0x6f, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x68, 0x74, 0x74, 0x70, + 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x42, 0x70, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x2e, 0x62, 0x75, 0x72, 0x73, 0x74, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x78, 0x74, 0x6c, 0x73, 0x2f, 0x78, 0x72, 0x61, 0x79, diff --git a/app/observatory/burst/config.proto b/app/observatory/burst/config.proto index ead75478..a60978d5 100644 --- a/app/observatory/burst/config.proto +++ b/app/observatory/burst/config.proto @@ -26,4 +26,7 @@ message HealthPingConfig { int32 samplingCount = 4; // ping timeout, int64 values of time.Duration int64 timeout = 5; + // http method to make request + string httpMethod = 6; + } diff --git a/app/observatory/burst/healthping.go b/app/observatory/burst/healthping.go index 0d8cab9f..cb1c3402 100644 --- a/app/observatory/burst/healthping.go +++ b/app/observatory/burst/healthping.go @@ -19,6 +19,7 @@ type HealthPingSettings struct { Interval time.Duration `json:"interval"` SamplingCount int `json:"sampling"` Timeout time.Duration `json:"timeout"` + HttpMethod string `json:"httpMethod"` } // HealthPing is the health checker for balancers @@ -37,12 +38,21 @@ type HealthPing struct { func NewHealthPing(ctx context.Context, dispatcher routing.Dispatcher, config *HealthPingConfig) *HealthPing { settings := &HealthPingSettings{} if config != nil { + + var httpMethod string + if config.HttpMethod == "" { + httpMethod = "HEAD" + } else { + httpMethod = strings.TrimSpace(config.HttpMethod) + } + settings = &HealthPingSettings{ Connectivity: strings.TrimSpace(config.Connectivity), Destination: strings.TrimSpace(config.Destination), Interval: time.Duration(config.Interval), SamplingCount: int(config.SamplingCount), Timeout: time.Duration(config.Timeout), + HttpMethod: httpMethod, } } if settings.Destination == "" { @@ -164,7 +174,7 @@ func (h *HealthPing) doCheck(tags []string, duration time.Duration, rounds int) } time.AfterFunc(delay, func() { errors.LogDebug(h.ctx, "checking ", handler) - delay, err := client.MeasureDelay() + delay, err := client.MeasureDelay(h.Settings.HttpMethod) if err == nil { ch <- &rtt{ handler: handler, @@ -251,7 +261,7 @@ func (h *HealthPing) checkConnectivity() bool { h.Settings.Connectivity, h.Settings.Timeout, ) - if _, err := tester.MeasureDelay(); err != nil { + if _, err := tester.MeasureDelay(h.Settings.HttpMethod); err != nil { return false } return true diff --git a/app/observatory/burst/ping.go b/app/observatory/burst/ping.go index 5ea1433a..fcb40f1a 100644 --- a/app/observatory/burst/ping.go +++ b/app/observatory/burst/ping.go @@ -2,6 +2,7 @@ package burst import ( "context" + "io" "net/http" "time" @@ -51,20 +52,28 @@ func newHTTPClient(ctxv context.Context, dispatcher routing.Dispatcher, handler } // MeasureDelay returns the delay time of the request to dest -func (s *pingClient) MeasureDelay() (time.Duration, error) { +func (s *pingClient) MeasureDelay(httpMethod string) (time.Duration, error) { if s.httpClient == nil { panic("pingClient not initialized") } - req, err := http.NewRequest(http.MethodHead, s.destination, nil) + + req, err := http.NewRequest(httpMethod, s.destination, nil) if err != nil { return rttFailed, err } + start := time.Now() resp, err := s.httpClient.Do(req) if err != nil { return rttFailed, err } - // don't wait for body + if httpMethod == http.MethodGet { + _, err = io.Copy(io.Discard, resp.Body) + if err != nil { + return rttFailed, err + } + } resp.Body.Close() + return time.Since(start), nil } diff --git a/infra/conf/router_strategy.go b/infra/conf/router_strategy.go index 98bcc8d1..464cbcfb 100644 --- a/infra/conf/router_strategy.go +++ b/infra/conf/router_strategy.go @@ -2,6 +2,7 @@ package conf import ( "google.golang.org/protobuf/proto" + "strings" "github.com/xtls/xray-core/app/observatory/burst" "github.com/xtls/xray-core/app/router" @@ -51,15 +52,23 @@ type healthCheckSettings struct { Interval duration.Duration `json:"interval"` SamplingCount int `json:"sampling"` Timeout duration.Duration `json:"timeout"` + HttpMethod string `json:"httpMethod"` } func (h healthCheckSettings) Build() (proto.Message, error) { + var httpMethod string + if h.HttpMethod == "" { + httpMethod = "HEAD" + } else { + httpMethod = strings.TrimSpace(h.HttpMethod) + } return &burst.HealthPingConfig{ Destination: h.Destination, Connectivity: h.Connectivity, Interval: int64(h.Interval), Timeout: int64(h.Timeout), SamplingCount: int32(h.SamplingCount), + HttpMethod: httpMethod, }, nil } From b043db82602da05d7610521889a923f190f5e98f Mon Sep 17 00:00:00 2001 From: fL1pSt3r <54001312+fL1pSt3r@users.noreply.github.com> Date: Mon, 23 Jun 2025 05:57:02 +0400 Subject: [PATCH 860/867] API: Fix issue with inbounduser not finding emails with uppercase letters (#4818) --- proxy/trojan/validator.go | 1 + proxy/vless/validator.go | 1 + 2 files changed, 2 insertions(+) diff --git a/proxy/trojan/validator.go b/proxy/trojan/validator.go index bfe53812..7841a249 100644 --- a/proxy/trojan/validator.go +++ b/proxy/trojan/validator.go @@ -53,6 +53,7 @@ func (v *Validator) Get(hash string) *protocol.MemoryUser { // Get a trojan user with hashed key, nil if user doesn't exist. func (v *Validator) GetByEmail(email string) *protocol.MemoryUser { + email = strings.ToLower(email) u, _ := v.email.Load(email) if u != nil { return u.(*protocol.MemoryUser) diff --git a/proxy/vless/validator.go b/proxy/vless/validator.go index ddac6cbb..d1356c5f 100644 --- a/proxy/vless/validator.go +++ b/proxy/vless/validator.go @@ -63,6 +63,7 @@ func (v *MemoryValidator) Get(id uuid.UUID) *protocol.MemoryUser { // Get a VLESS user with email, nil if user doesn't exist. func (v *MemoryValidator) GetByEmail(email string) *protocol.MemoryUser { + email = strings.ToLower(email) u, _ := v.email.Load(email) if u != nil { return u.(*protocol.MemoryUser) From 38ed2cc3872ba28e588cf0f40b6ba221cbac8674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Mon, 23 Jun 2025 10:48:24 +0800 Subject: [PATCH 861/867] DNS: Add new nonIPQuery "reject" (#4824) --- infra/conf/dns_proxy.go | 2 +- proxy/dns/dns.go | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/infra/conf/dns_proxy.go b/infra/conf/dns_proxy.go index 3425f22e..e731ee7c 100644 --- a/infra/conf/dns_proxy.go +++ b/infra/conf/dns_proxy.go @@ -30,7 +30,7 @@ func (c *DNSOutboundConfig) Build() (proto.Message, error) { switch c.NonIPQuery { case "": c.NonIPQuery = "drop" - case "drop", "skip": + case "drop", "skip", "reject": default: return nil, errors.New(`unknown "nonIPQuery": `, c.NonIPQuery) } diff --git a/proxy/dns/dns.go b/proxy/dns/dns.go index 3308faef..a35854ef 100644 --- a/proxy/dns/dns.go +++ b/proxy/dns/dns.go @@ -187,6 +187,9 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet. if len(h.blockTypes) > 0 { for _, blocktype := range h.blockTypes { if blocktype == int32(qType) { + if h.nonIPQuery == "reject" { + go h.rejectNonIPQuery(id, qType, domain, writer) + } errors.LogInfo(ctx, "blocked type ", qType, " query for domain ", domain) return nil } @@ -199,6 +202,11 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, d internet. b.Release() continue } + if h.nonIPQuery == "reject" { + go h.rejectNonIPQuery(id, qType, domain, writer) + b.Release() + continue + } } if err := connWriter.WriteMessage(b); err != nil { @@ -317,6 +325,38 @@ func (h *Handler) handleIPQuery(id uint16, qType dnsmessage.Type, domain string, } } +func (h *Handler) rejectNonIPQuery(id uint16, qType dnsmessage.Type, domain string, writer dns_proto.MessageWriter) { + b := buf.New() + rawBytes := b.Extend(buf.Size) + builder := dnsmessage.NewBuilder(rawBytes[:0], dnsmessage.Header{ + ID: id, + RCode: dnsmessage.RCodeRefused, + RecursionAvailable: true, + RecursionDesired: true, + Response: true, + Authoritative: true, + }) + builder.EnableCompression() + common.Must(builder.StartQuestions()) + common.Must(builder.Question(dnsmessage.Question{ + Name: dnsmessage.MustNewName(domain), + Class: dnsmessage.ClassINET, + Type: qType, + })) + + msgBytes, err := builder.Finish() + if err != nil { + errors.LogInfoInner(context.Background(), err, "pack reject message") + b.Release() + return + } + b.Resize(0, int32(len(msgBytes))) + + if err := writer.WriteMessage(b); err != nil { + errors.LogInfoInner(context.Background(), err, "write reject answer") + } +} + type outboundConn struct { access sync.Mutex dialer func() (stat.Connection, error) From cb1afb33e68c56bf4510ad658ab86a0468b8c36c Mon Sep 17 00:00:00 2001 From: isluckys <152280768+isluckys@users.noreply.github.com> Date: Mon, 23 Jun 2025 20:47:27 +0800 Subject: [PATCH 862/867] common: fix task leak in timer (#4831) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit signal包里面SetTimeout方法并发时可能会出现task close以后执行start导致泄露 --- common/signal/timer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/signal/timer.go b/common/signal/timer.go index a7f59cd9..ece9f496 100644 --- a/common/signal/timer.go +++ b/common/signal/timer.go @@ -67,9 +67,9 @@ func (t *ActivityTimer) SetTimeout(timeout time.Duration) { t.checkTask.Close() } t.checkTask = checkTask - t.Unlock() t.Update() common.Must(checkTask.Start()) + t.Unlock() } func CancelAfterInactivity(ctx context.Context, cancel context.CancelFunc, timeout time.Duration) *ActivityTimer { From 486d005986f3f356e6056574edb541a2dae5d193 Mon Sep 17 00:00:00 2001 From: Jesus <75259437+Jolymmiles@users.noreply.github.com> Date: Fri, 11 Jul 2025 20:52:51 +0400 Subject: [PATCH 863/867] API: add option to fetch only tags from ListInbounds (#4870) * feat: add new method for get only inbound tags from core. ListTags. * refactor: simplify creating response. * refactor: move getting tags in already exist method via option. --- app/proxyman/command/command.go | 21 +++++++++++++++------ app/proxyman/command/command.pb.go | 15 +++++++++++++-- app/proxyman/command/command.proto | 4 +++- main/commands/all/api/inbounds_list.go | 7 +++++-- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/app/proxyman/command/command.go b/app/proxyman/command/command.go index 227a95c3..a86f0921 100644 --- a/app/proxyman/command/command.go +++ b/app/proxyman/command/command.go @@ -103,13 +103,22 @@ func (s *handlerServer) AlterInbound(ctx context.Context, request *AlterInboundR func (s *handlerServer) ListInbounds(ctx context.Context, request *ListInboundsRequest) (*ListInboundsResponse, error) { handlers := s.ihm.ListHandlers(ctx) response := &ListInboundsResponse{} - for _, handler := range handlers { - response.Inbounds = append(response.Inbounds, &core.InboundHandlerConfig{ - Tag: handler.Tag(), - ReceiverSettings: handler.ReceiverSettings(), - ProxySettings: handler.ProxySettings(), - }) + if request.GetIsOnlyTags() { + for _, handler := range handlers { + response.Inbounds = append(response.Inbounds, &core.InboundHandlerConfig{ + Tag: handler.Tag(), + }) + } + } else { + for _, handler := range handlers { + response.Inbounds = append(response.Inbounds, &core.InboundHandlerConfig{ + Tag: handler.Tag(), + ReceiverSettings: handler.ReceiverSettings(), + ProxySettings: handler.ProxySettings(), + }) + } } + return response, nil } diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index f4219d91..6c127960 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -368,6 +368,8 @@ type ListInboundsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + IsOnlyTags bool `protobuf:"varint,1,opt,name=isOnlyTags,proto3" json:"isOnlyTags,omitempty"` } func (x *ListInboundsRequest) Reset() { @@ -400,6 +402,13 @@ func (*ListInboundsRequest) Descriptor() ([]byte, []int) { return file_app_proxyman_command_command_proto_rawDescGZIP(), []int{8} } +func (x *ListInboundsRequest) GetIsOnlyTags() bool { + if x != nil { + return x.IsOnlyTags + } + return false +} + type ListInboundsResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -993,9 +1002,11 @@ var file_app_proxyman_command_command_proto_rawDesc = []byte{ 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x73, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x09, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x16, 0x0a, 0x14, 0x41, 0x6c, 0x74, 0x65, 0x72, 0x49, 0x6e, 0x62, - 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x15, 0x0a, 0x13, + 0x6f, 0x75, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x35, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x22, 0x53, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x54, 0x61, 0x67, + 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x4f, 0x6e, 0x6c, 0x79, 0x54, + 0x61, 0x67, 0x73, 0x22, 0x53, 0x0a, 0x14, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3b, 0x0a, 0x08, 0x69, 0x6e, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x78, 0x72, 0x61, 0x79, 0x2e, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x75, 0x6e, diff --git a/app/proxyman/command/command.proto b/app/proxyman/command/command.proto index 4ff499eb..71f8f0dc 100644 --- a/app/proxyman/command/command.proto +++ b/app/proxyman/command/command.proto @@ -37,7 +37,9 @@ message AlterInboundRequest { message AlterInboundResponse {} -message ListInboundsRequest {} +message ListInboundsRequest { + bool isOnlyTags = 1; +} message ListInboundsResponse { repeated core.InboundHandlerConfig inbounds = 1; diff --git a/main/commands/all/api/inbounds_list.go b/main/commands/all/api/inbounds_list.go index e4267a6b..6060074c 100644 --- a/main/commands/all/api/inbounds_list.go +++ b/main/commands/all/api/inbounds_list.go @@ -7,7 +7,7 @@ import ( var cmdListInbounds = &base.Command{ CustomFlags: true, - UsageLine: "{{.Exec}} api lsi [--server=127.0.0.1:8080]", + UsageLine: "{{.Exec}} api lsi [--server=127.0.0.1:8080] [--isOnlyTags=true]", Short: "List inbounds", Long: ` List inbounds in Xray. @@ -29,14 +29,17 @@ Example: func executeListInbounds(cmd *base.Command, args []string) { setSharedFlags(cmd) + var isOnlyTagsStr string + cmd.Flag.StringVar(&isOnlyTagsStr, "isOnlyTags", "", "") cmd.Flag.Parse(args) + isOnlyTags := isOnlyTagsStr == "true" conn, ctx, close := dialAPIServer() defer close() client := handlerService.NewHandlerServiceClient(conn) - resp, err := client.ListInbounds(ctx, &handlerService.ListInboundsRequest{}) + resp, err := client.ListInbounds(ctx, &handlerService.ListInboundsRequest{IsOnlyTags: isOnlyTags}) if err != nil { base.Fatalf("failed to list inbounds: %s", err) } From 409e4e8f120cff2d072f3485f533f7c8b57b890c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Jul 2025 12:54:33 -0400 Subject: [PATCH 864/867] Bump github.com/miekg/dns from 1.1.66 to 1.1.67 (#4880) Bumps [github.com/miekg/dns](https://github.com/miekg/dns) from 1.1.66 to 1.1.67. - [Changelog](https://github.com/miekg/dns/blob/master/Makefile.release) - [Commits](https://github.com/miekg/dns/compare/v1.1.66...v1.1.67) --- updated-dependencies: - dependency-name: github.com/miekg/dns dependency-version: 1.1.67 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2b589d1c..b11095b9 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/golang/mock v1.7.0-rc.1 github.com/google/go-cmp v0.7.0 github.com/gorilla/websocket v1.5.3 - github.com/miekg/dns v1.1.66 + github.com/miekg/dns v1.1.67 github.com/pelletier/go-toml v1.9.5 github.com/pires/go-proxyproto v0.8.1 github.com/quic-go/quic-go v0.52.0 diff --git a/go.sum b/go.sum index c0fb7cb8..06c1a11e 100644 --- a/go.sum +++ b/go.sum @@ -40,8 +40,8 @@ github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0N github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/miekg/dns v1.1.66 h1:FeZXOS3VCVsKnEAd+wBkjMC3D2K+ww66Cq3VnCINuJE= -github.com/miekg/dns v1.1.66/go.mod h1:jGFzBsSNbJw6z1HYut1RKBKHA9PBdxeHrZG8J+gC2WE= +github.com/miekg/dns v1.1.67 h1:kg0EHj0G4bfT5/oOys6HhZw4vmMlnoZ+gDu8tJ/AlI0= +github.com/miekg/dns v1.1.67/go.mod h1:fujopn7TB3Pu3JM69XaawiU0wqjpL9/8xGop5UrTPps= github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA= github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= From 6a8a85f83a5b57d6e8397966227903eb02bc9223 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Jul 2025 12:55:05 -0400 Subject: [PATCH 865/867] Bump golang.org/x/sync from 0.15.0 to 0.16.0 (#4881) Bumps [golang.org/x/sync](https://github.com/golang/sync) from 0.15.0 to 0.16.0. - [Commits](https://github.com/golang/sync/compare/v0.15.0...v0.16.0) --- updated-dependencies: - dependency-name: golang.org/x/sync dependency-version: 0.16.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b11095b9..b2c327b4 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( go4.org/netipx v0.0.0-20231129151722-fdeea329fbba golang.org/x/crypto v0.39.0 golang.org/x/net v0.41.0 - golang.org/x/sync v0.15.0 + golang.org/x/sync v0.16.0 golang.org/x/sys v0.33.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.73.0 diff --git a/go.sum b/go.sum index 06c1a11e..826dfa73 100644 --- a/go.sum +++ b/go.sum @@ -111,8 +111,8 @@ golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= -golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw= +golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= From 3ba733079e7f125fd07f014cc99aaa4af2e2c63b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Jul 2025 13:01:32 -0400 Subject: [PATCH 866/867] Bump golang.org/x/crypto from 0.39.0 to 0.40.0 (#4885) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.39.0 to 0.40.0. - [Commits](https://github.com/golang/crypto/compare/v0.39.0...v0.40.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-version: 0.40.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index b2c327b4..efe9ac45 100644 --- a/go.mod +++ b/go.mod @@ -22,10 +22,10 @@ require ( github.com/vishvananda/netlink v1.3.1 github.com/xtls/reality v0.0.0-20250608132114-50752aec6bfb go4.org/netipx v0.0.0-20231129151722-fdeea329fbba - golang.org/x/crypto v0.39.0 + golang.org/x/crypto v0.40.0 golang.org/x/net v0.41.0 golang.org/x/sync v0.16.0 - golang.org/x/sys v0.33.0 + golang.org/x/sys v0.34.0 golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 google.golang.org/grpc v1.73.0 google.golang.org/protobuf v1.36.6 @@ -51,9 +51,9 @@ require ( github.com/vishvananda/netns v0.0.5 // indirect go.uber.org/mock v0.5.0 // indirect golang.org/x/mod v0.25.0 // indirect - golang.org/x/text v0.26.0 // indirect + golang.org/x/text v0.27.0 // indirect golang.org/x/time v0.7.0 // indirect - golang.org/x/tools v0.33.0 // indirect + golang.org/x/tools v0.34.0 // indirect golang.zx2c4.com/wintun v0.0.0-20230126152724-0fa3db229ce2 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 826dfa73..e2958d66 100644 --- a/go.sum +++ b/go.sum @@ -99,8 +99,8 @@ go4.org/netipx v0.0.0-20231129151722-fdeea329fbba h1:0b9z3AuHCjxk0x/opv64kcgZLBs go4.org/netipx v0.0.0-20231129151722-fdeea329fbba/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= -golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= +golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= +golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w= golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= @@ -121,21 +121,21 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= -golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= +golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= -golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= +golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= +golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= -golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= -golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= +golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo= +golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 1976d02ec9aaff3d34221a18b4ec8869437e2dc6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Jul 2025 13:01:47 -0400 Subject: [PATCH 867/867] Bump golang.org/x/sys from 0.33.0 to 0.34.0 (#4882) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.33.0 to 0.34.0. - [Commits](https://github.com/golang/sys/compare/v0.33.0...v0.34.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-version: 0.34.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>