json_dns.go 633 B

1234567891011121314151617181920
  1. package sub
  2. import (
  3. "github.com/mhsanaei/3x-ui/v3/internal/logger"
  4. "github.com/mhsanaei/3x-ui/v3/internal/xray/dnsconf"
  5. )
  6. // The subJsonDns setting holds either a full xray dns block or a bare array of
  7. // servers; dnsconf validates it against the parser the client runs.
  8. // SetDnsConfig overrides the dns block of every emitted document; an unusable
  9. // value is logged and ignored so a typo cannot take subscriptions down.
  10. func (s *SubJsonService) SetDnsConfig(raw string) {
  11. block, err := dnsconf.Parse(raw)
  12. if err != nil {
  13. logger.Warningf("subJsonDns: %v; keeping the template DNS", err)
  14. return
  15. }
  16. s.dnsBlock = block
  17. }