Transport: Add RAW as an alias of TCP (#3852)

This commit is contained in:
RPRX 2024-09-28 05:25:59 +00:00 committed by GitHub
parent 3632e83faa
commit d8485bd5af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -644,7 +644,7 @@ type TransportProtocol string
// Build implements Buildable. // Build implements Buildable.
func (p TransportProtocol) Build() (string, error) { func (p TransportProtocol) Build() (string, error) {
switch strings.ToLower(string(p)) { switch strings.ToLower(string(p)) {
case "tcp": case "raw", "tcp":
return "tcp", nil return "tcp", nil
case "kcp", "mkcp": case "kcp", "mkcp":
return "mkcp", nil return "mkcp", nil
@ -783,6 +783,7 @@ type StreamConfig struct {
Security string `json:"security"` Security string `json:"security"`
TLSSettings *TLSConfig `json:"tlsSettings"` TLSSettings *TLSConfig `json:"tlsSettings"`
REALITYSettings *REALITYConfig `json:"realitySettings"` REALITYSettings *REALITYConfig `json:"realitySettings"`
RAWSettings *TCPConfig `json:"rawSettings"`
TCPSettings *TCPConfig `json:"tcpSettings"` TCPSettings *TCPConfig `json:"tcpSettings"`
KCPSettings *KCPConfig `json:"kcpSettings"` KCPSettings *KCPConfig `json:"kcpSettings"`
WSSettings *WebSocketConfig `json:"wsSettings"` WSSettings *WebSocketConfig `json:"wsSettings"`
@ -839,10 +840,13 @@ func (c *StreamConfig) Build() (*internet.StreamConfig, error) {
default: default:
return nil, errors.New(`Unknown security "` + c.Security + `".`) return nil, errors.New(`Unknown security "` + c.Security + `".`)
} }
if c.TCPSettings == nil {
c.TCPSettings = c.RAWSettings
}
if c.TCPSettings != nil { if c.TCPSettings != nil {
ts, err := c.TCPSettings.Build() ts, err := c.TCPSettings.Build()
if err != nil { 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{ config.TransportSettings = append(config.TransportSettings, &internet.TransportConfig{
ProtocolName: "tcp", ProtocolName: "tcp",