dns_proxy.go 547 B

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