mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-13 22:45:13 +00:00
allow outbound to be proxied
This commit is contained in:
17 files changed
+222
-83
No files matched your search
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user