mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-13 23:58:40 +00:00
Add domain strategy for dns outbound
This commit is contained in:
parent
2e56fe11e1
commit
4a4e160a54
6 changed files with 133 additions and 31 deletions
|
@ -1,15 +1,18 @@
|
|||
package conf
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/xtls/xray-core/common/net"
|
||||
"github.com/xtls/xray-core/proxy/dns"
|
||||
)
|
||||
|
||||
type DNSOutboundConfig struct {
|
||||
Network Network `json:"network"`
|
||||
Address *Address `json:"address"`
|
||||
Port uint16 `json:"port"`
|
||||
Network Network `json:"network"`
|
||||
Address *Address `json:"address"`
|
||||
Port uint16 `json:"port"`
|
||||
DomainStrategy string `json:"domainStrategy"`
|
||||
}
|
||||
|
||||
func (c *DNSOutboundConfig) Build() (proto.Message, error) {
|
||||
|
@ -22,5 +25,12 @@ func (c *DNSOutboundConfig) Build() (proto.Message, error) {
|
|||
if c.Address != nil {
|
||||
config.Server.Address = c.Address.Build()
|
||||
}
|
||||
config.DomainStrategy = dns.Config_USE_ALL
|
||||
switch strings.ToLower(c.DomainStrategy) {
|
||||
case "useip", "use_ip", "use-ip":
|
||||
config.DomainStrategy = dns.Config_USE_IP
|
||||
case "fake", "fakedns":
|
||||
config.DomainStrategy = dns.Config_USE_FAKE
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ func TestDnsProxyConfig(t *testing.T) {
|
|||
Address: net.NewIPOrDomain(net.IPAddress([]byte{8, 8, 8, 8})),
|
||||
Port: 53,
|
||||
},
|
||||
DomainStrategy: dns.Config_USE_ALL,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue