MCPcopy
hub / github.com/txthinking/brook / NewDialWithDNS

Function NewDialWithDNS

plugins/dialwithdns/dialwithdns.go:33–45  ·  view source on GitHub ↗
(dns, prefer string)

Source from the content-addressed store, hash-verified

31}
32
33func NewDialWithDNS(dns, prefer string) (*DialWithDNS, error) {
34 if prefer != "A" && prefer != "AAAA" {
35 return nil, errors.New("Invalid prefer")
36 }
37 if !strings.HasPrefix(dns, "https://") {
38 return &DialWithDNS{DNSClient: &brook.DNSClient{Server: dns}, Prefer: prefer}, nil
39 }
40 dc, err := brook.NewDOHClient(dns)
41 if err != nil {
42 return nil, err
43 }
44 return &DialWithDNS{DOHClient: dc, Prefer: prefer}, nil
45}
46
47func (p *DialWithDNS) IP(domain string) (net.IP, error) {
48 if p.Prefer == "A" {

Callers 1

mainFunction · 0.92

Calls 1

NewDOHClientFunction · 0.92

Tested by

no test coverage detected