v2ray-core/infra/conf/dns_proxy.go

29 lines
643 B
Go
Raw Normal View History

2019-02-10 19:04:11 +01:00
package conf
import (
"github.com/golang/protobuf/proto"
2021-02-17 04:31:50 +08:00
"github.com/v2fly/v2ray-core/v4/common/net"
2021-05-04 21:52:35 +08:00
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
2021-02-17 04:31:50 +08:00
"github.com/v2fly/v2ray-core/v4/proxy/dns"
2019-02-10 19:04:11 +01:00
)
type DNSOutboundConfig struct {
Network cfgcommon.Network `json:"network"`
Address *cfgcommon.Address `json:"address"`
Port uint16 `json:"port"`
2019-02-12 22:34:43 +01:00
}
2019-02-10 19:04:11 +01:00
func (c *DNSOutboundConfig) Build() (proto.Message, error) {
2019-02-12 22:34:43 +01:00
config := &dns.Config{
Server: &net.Endpoint{
Network: c.Network.Build(),
Port: uint32(c.Port),
},
}
if c.Address != nil {
config.Server.Address = c.Address.Build()
}
return config, nil
2019-02-10 19:04:11 +01:00
}