mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
Enhance DNS and Dialer (#341)
This commit is contained in:
parent
ad1807dd99
commit
db32ce6fd9
22 changed files with 682 additions and 290 deletions
|
@ -2,6 +2,7 @@ package conf
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/xtls/xray-core/transport/internet"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
|
@ -267,9 +268,22 @@ type OutboundDetourConfig struct {
|
|||
MuxSettings *MuxConfig `json:"mux"`
|
||||
}
|
||||
|
||||
func (c *OutboundDetourConfig) checkChainProxyConfig() error {
|
||||
if c.StreamSetting == nil || c.ProxySettings == nil || c.StreamSetting.SocketSettings == nil {
|
||||
return nil
|
||||
}
|
||||
if len(c.ProxySettings.Tag) > 0 && len(c.StreamSetting.SocketSettings.DialerProxy) > 0 {
|
||||
return newError("proxySettings.tag is conflicted with sockopt.dialerProxy").AtWarning()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Build implements Buildable.
|
||||
func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) {
|
||||
senderSettings := &proxyman.SenderConfig{}
|
||||
if err := c.checkChainProxyConfig(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if c.SendThrough != nil {
|
||||
address := c.SendThrough
|
||||
|
@ -295,6 +309,18 @@ func (c *OutboundDetourConfig) Build() (*core.OutboundHandlerConfig, error) {
|
|||
if err != nil {
|
||||
return nil, newError("invalid outbound detour proxy settings.").Base(err)
|
||||
}
|
||||
if ps.TransportLayerProxy {
|
||||
if senderSettings.StreamSettings != nil {
|
||||
if senderSettings.StreamSettings.SocketSettings != nil {
|
||||
senderSettings.StreamSettings.SocketSettings.DialerProxy = ps.Tag
|
||||
} else {
|
||||
senderSettings.StreamSettings.SocketSettings = &internet.SocketConfig{DialerProxy: ps.Tag}
|
||||
}
|
||||
} else {
|
||||
senderSettings.StreamSettings = &internet.StreamConfig{SocketSettings: &internet.SocketConfig{DialerProxy: ps.Tag}}
|
||||
}
|
||||
ps = nil
|
||||
}
|
||||
senderSettings.ProxySettings = ps
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue