github.com/v2fly/v2ray-core/v4@v4.45.2/infra/conf/dns_proxy.go (about)

     1  package conf
     2  
     3  import (
     4  	"github.com/golang/protobuf/proto"
     5  
     6  	"github.com/v2fly/v2ray-core/v4/common/net"
     7  	"github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
     8  	"github.com/v2fly/v2ray-core/v4/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  }