Skip to content

Commit

Permalink
Transport: Remove QUIC (#3754)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmray authored Sep 3, 2024
1 parent ab3c00e commit 9a953c0
Show file tree
Hide file tree
Showing 15 changed files with 0 additions and 1,348 deletions.
12 changes: 0 additions & 12 deletions infra/conf/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
Expand Down
56 changes: 0 additions & 56 deletions infra/conf/transport_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ 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"
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"
"github.com/xtls/xray-core/transport/internet/splithttp"
"github.com/xtls/xray-core/transport/internet/tcp"
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
Expand Down
19 changes: 0 additions & 19 deletions infra/conf/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ 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"
"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/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"
Expand Down Expand Up @@ -203,12 +200,6 @@ func TestTransportConfig(t *testing.T) {
"wsSettings": {
"path": "/t"
},
"quicSettings": {
"key": "abcd",
"header": {
"type": "dtls"
}
},
"grpcSettings": {
"serviceName": "name",
"multiMode": true
Expand Down Expand Up @@ -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{
Expand Down
1 change: 0 additions & 1 deletion main/distro/all/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
139 changes: 0 additions & 139 deletions testing/scenarios/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
}
}
48 changes: 0 additions & 48 deletions transport/internet/quic/config.go

This file was deleted.

Loading

0 comments on commit 9a953c0

Please sign in to comment.