github.com/eagleql/xray-core@v1.4.4/infra/conf/dns_proxy.go (about)

     1  package conf
     2  
     3  import (
     4  	"github.com/eagleql/xray-core/common/net"
     5  	"github.com/eagleql/xray-core/proxy/dns"
     6  	"github.com/golang/protobuf/proto"
     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  }