dns_proxy.go 618 B

12345678910111213141516171819202122232425262728
  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. UserLevel uint32 `json:"userLevel"`
  12. }
  13. func (c *DNSOutboundConfig) Build() (proto.Message, error) {
  14. config := &dns.Config{
  15. Server: &net.Endpoint{
  16. Network: c.Network.Build(),
  17. Port: uint32(c.Port),
  18. },
  19. UserLevel: c.UserLevel,
  20. }
  21. if c.Address != nil {
  22. config.Server.Address = c.Address.Build()
  23. }
  24. return config, nil
  25. }