allow outbound to be proxied

This commit is contained in:
Darien Raymond committed 2016-11-10 23:41:28 +01:00
1 parent e30f466424
commit 5dc05d6352
17 files changed
+222 -83

No files matched your search

+13
View File
@@ -230,3 +230,16 @@ func (this *StreamConfig) Build() (*internet.StreamConfig, error) {
}
return config, nil
}
type ProxyConfig struct {
Tag string `json:"tag"`
}
func (this *ProxyConfig) Build() (*internet.ProxyConfig, error) {
if len(this.Tag) == 0 {
return nil, errors.New("Proxy tag is not set.")
}
return &internet.ProxyConfig{
Tag: this.Tag,
}, nil
}
+17
View File
@@ -74,6 +74,7 @@ type OutboundConnectionConfig struct {
Protocol string `json:"protocol"`
SendThrough *Address `json:"sendThrough"`
StreamSetting *StreamConfig `json:"streamSettings"`
ProxySettings *ProxyConfig `json:"proxySettings"`
Settings json.RawMessage `json:"settings"`
}
@@ -103,6 +104,13 @@ func (this *OutboundConnectionConfig) Build() (*core.OutboundConnectionConfig, e
}
config.StreamSettings = ss
}
if this.ProxySettings != nil {
ps, err := this.ProxySettings.Build()
if err != nil {
return nil, errors.New("Outbound: invalid proxy settings: " + err.Error())
}
config.ProxySettings = ps
}
return config, nil
}
@@ -198,6 +206,7 @@ type OutboundDetourConfig struct {
Tag string `json:"tag"`
Settings json.RawMessage `json:"settings"`
StreamSetting *StreamConfig `json:"streamSettings"`
ProxySettings *ProxyConfig `json:"proxySettings"`
}
func (this *OutboundDetourConfig) Build() (*core.OutboundConnectionConfig, error) {
@@ -228,6 +237,14 @@ func (this *OutboundDetourConfig) Build() (*core.OutboundConnectionConfig, error
if err != nil {
return nil, err
}
if this.ProxySettings != nil {
ps, err := this.ProxySettings.Build()
if err != nil {
return nil, errors.New("OutboundDetour: invalid proxy settings: " + err.Error())
}
config.ProxySettings = ps
}
config.Settings = ts
return config, nil
}