From f37b04a69052299fc1af756cfe1e4b250dda6663 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Tue, 18 Oct 2016 21:57:40 +0200 Subject: [PATCH] per connection stream settings --- tools/conf/transport_internet.go | 39 +++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/tools/conf/transport_internet.go b/tools/conf/transport_internet.go index 58a4b4421..628eb4349 100644 --- a/tools/conf/transport_internet.go +++ b/tools/conf/transport_internet.go @@ -154,9 +154,12 @@ func (this *TLSConfig) Build() (*loader.TypedSettings, error) { } type StreamConfig struct { - Network *Network `json:"network"` - Security string `json:"security"` - TLSSettings *TLSConfig `json:"tlsSettings"` + Network *Network `json:"network"` + Security string `json:"security"` + TLSSettings *TLSConfig `json:"tlsSettings"` + TCPSettings *TCPConfig `json:"tcpSettings"` + KCPSettings *KCPConfig `json:"kcpSettings"` + WSSettings *WebSocketConfig `json:"wsSettings"` } func (this *StreamConfig) Build() (*internet.StreamConfig, error) { @@ -177,5 +180,35 @@ func (this *StreamConfig) Build() (*internet.StreamConfig, error) { } config.SecuritySettings = append(config.SecuritySettings, ts) } + if this.TCPSettings != nil { + ts, err := this.TCPSettings.Build() + if err != nil { + return nil, errors.New("Failed to build TCP config: " + err.Error()) + } + config.NetworkSettings = append(config.NetworkSettings, &internet.NetworkSettings{ + Network: v2net.Network_TCP, + Settings: ts, + }) + } + if this.KCPSettings != nil { + ts, err := this.KCPSettings.Build() + if err != nil { + return nil, errors.New("Failed to build KCP config: " + err.Error()) + } + config.NetworkSettings = append(config.NetworkSettings, &internet.NetworkSettings{ + Network: v2net.Network_KCP, + Settings: ts, + }) + } + if this.WSSettings != nil { + ts, err := this.WSSettings.Build() + if err != nil { + return nil, errors.New("Failed to build WebSocket config: " + err.Error()) + } + config.NetworkSettings = append(config.NetworkSettings, &internet.NetworkSettings{ + Network: v2net.Network_WebSocket, + Settings: ts, + }) + } return config, nil }