Skip to content

Commit

Permalink
Transport: Remove DomainSocket (#3757)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmray authored Sep 3, 2024
1 parent 9a953c0 commit c0a98f7
Show file tree
Hide file tree
Showing 15 changed files with 37 additions and 724 deletions.
12 changes: 0 additions & 12 deletions infra/conf/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
}
Expand Down
33 changes: 2 additions & 31 deletions infra/conf/transport_internet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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".`)
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 0 additions & 3 deletions infra/conf/xray.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
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 @@ -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"
Expand Down
117 changes: 0 additions & 117 deletions testing/scenarios/transport_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package scenarios

import (
"os"
"runtime"
"testing"
"time"

Expand All @@ -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"
)
Expand Down Expand Up @@ -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)
}
}

2 changes: 0 additions & 2 deletions transport/internet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
74 changes: 35 additions & 39 deletions transport/internet/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion transport/internet/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ enum TransportProtocol {
MKCP = 2;
WebSocket = 3;
HTTP = 4;
DomainSocket = 5;
HTTPUpgrade = 6;
SplitHTTP = 7;
}
Expand Down
Loading

0 comments on commit c0a98f7

Please sign in to comment.