2019-02-10 13:04:11 -05:00
|
|
|
package conf
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/golang/protobuf/proto"
|
2021-05-03 22:15:11 -04:00
|
|
|
"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
|
2021-02-16 15:31:50 -05:00
|
|
|
|
|
|
|
"github.com/v2fly/v2ray-core/v4/common/net"
|
|
|
|
"github.com/v2fly/v2ray-core/v4/proxy/dns"
|
2019-02-10 13:04:11 -05:00
|
|
|
)
|
|
|
|
|
2020-10-11 07:22:46 -04:00
|
|
|
type DNSOutboundConfig struct {
|
2021-05-03 22:15:11 -04:00
|
|
|
Network cfgcommon.Network `json:"network"`
|
|
|
|
Address *cfgcommon.Address `json:"address"`
|
|
|
|
Port uint16 `json:"port"`
|
2019-02-12 16:34:43 -05:00
|
|
|
}
|
2019-02-10 13:04:11 -05:00
|
|
|
|
2020-10-11 07:22:46 -04:00
|
|
|
func (c *DNSOutboundConfig) Build() (proto.Message, error) {
|
2019-02-12 16:34:43 -05: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 13:04:11 -05:00
|
|
|
}
|