github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/infra/conf/v4/dns_proxy.go (about) 1 package v4 2 3 import ( 4 "github.com/golang/protobuf/proto" 5 6 "github.com/v2fly/v2ray-core/v5/common/net" 7 "github.com/v2fly/v2ray-core/v5/infra/conf/cfgcommon" 8 "github.com/v2fly/v2ray-core/v5/proxy/dns" 9 ) 10 11 type DNSOutboundConfig struct { 12 Network cfgcommon.Network `json:"network"` 13 Address *cfgcommon.Address `json:"address"` 14 Port uint16 `json:"port"` 15 UserLevel uint32 `json:"userLevel"` 16 } 17 18 func (c *DNSOutboundConfig) Build() (proto.Message, error) { 19 config := &dns.Config{ 20 Server: &net.Endpoint{ 21 Network: c.Network.Build(), 22 Port: uint32(c.Port), 23 }, 24 UserLevel: c.UserLevel, 25 } 26 if c.Address != nil { 27 config.Server.Address = c.Address.Build() 28 } 29 return config, nil 30 }