dns_proxy.go 643 B

12345678910111213141516171819202122232425262728
  1. package conf
  2. import (
  3. "github.com/golang/protobuf/proto"
  4. "github.com/v2fly/v2ray-core/v4/infra/conf/cfgcommon"
  5. "github.com/v2fly/v2ray-core/v4/common/net"
  6. "github.com/v2fly/v2ray-core/v4/proxy/dns"
  7. )
  8. type DNSOutboundConfig struct {
  9. Network cfgcommon.Network `json:"network"`
  10. Address *cfgcommon.Address `json:"address"`
  11. Port uint16 `json:"port"`
  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. }
  20. if c.Address != nil {
  21. config.Server.Address = c.Address.Build()
  22. }
  23. return config, nil
  24. }