github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/infra/conf/dns_proxy.go (about)

     1  package conf
     2  
     3  import (
     4  	"github.com/golang/protobuf/proto"
     5  	"v2ray.com/core/common/net"
     6  	"v2ray.com/core/proxy/dns"
     7  )
     8  
     9  type DnsOutboundConfig struct {
    10  	Network Network  `json:"network"`
    11  	Address *Address `json:"address"`
    12  	Port    uint16   `json:"port"`
    13  }
    14  
    15  func (c *DnsOutboundConfig) Build() (proto.Message, error) {
    16  	config := &dns.Config{
    17  		Server: &net.Endpoint{
    18  			Network: c.Network.Build(),
    19  			Port:    uint32(c.Port),
    20  		},
    21  	}
    22  	if c.Address != nil {
    23  		config.Server.Address = c.Address.Build()
    24  	}
    25  	return config, nil
    26  }