Files
Xray-core/infra/conf/dns_proxy.go
T

38 lines
853 B
Go
Raw Normal View History

2020-11-25 19:01:53 +08:00
package conf
import (
2020-12-04 09:36:16 +08:00
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/proxy/dns"
"google.golang.org/protobuf/proto"
2020-11-25 19:01:53 +08:00
)
type DNSOutboundConfig struct {
Network Network `json:"network"`
Address *Address `json:"address"`
Port uint16 `json:"port"`
UserLevel uint32 `json:"userLevel"`
NonIPQuery string `json:"nonIPQuery"`
2020-11-25 19:01:53 +08:00
}
func (c *DNSOutboundConfig) Build() (proto.Message, error) {
config := &dns.Config{
Server: &net.Endpoint{
Network: c.Network.Build(),
Port: uint32(c.Port),
},
2021-10-16 21:02:51 +08:00
UserLevel: c.UserLevel,
2020-11-25 19:01:53 +08:00
}
if c.Address != nil {
config.Server.Address = c.Address.Build()
}
switch c.NonIPQuery {
case "":
c.NonIPQuery = "drop"
case "drop", "skip":
default:
return nil, newError(`unknown "nonIPQuery": `, c.NonIPQuery)
}
2023-06-19 00:33:59 +00:00
config.Non_IPQuery = c.NonIPQuery
2020-11-25 19:01:53 +08:00
return config, nil
}