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

39 lines
953 B
Go
Raw Normal View History

2020-11-25 19:01:53 +08:00
package conf
import (
2024-06-29 14:32:57 -04:00
"github.com/xtls/xray-core/common/errors"
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"`
2024-11-09 14:16:11 +03:00
BlockTypes []int32 `json:"blockTypes"`
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 "", "reject", "drop", "skip":
default:
2024-06-29 14:32:57 -04:00
return nil, errors.New(`unknown "nonIPQuery": `, c.NonIPQuery)
}
2023-06-19 00:33:59 +00:00
config.Non_IPQuery = c.NonIPQuery
2024-09-15 12:21:51 +08:00
config.BlockTypes = c.BlockTypes
2020-11-25 19:01:53 +08:00
return config, nil
}