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