-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
113 lines (88 loc) · 2.21 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# dns
The sample code to use the dns client:
DNS over UDP example:
#include <dns/dns.h>
#include <stdio.h>
int main(void)
{
struct request r = { "10.0.2.3", 53, udp, "github.com", DNS_TYPE_A, DNS_CLASS_IN };
struct response resp;
int result = resolv(r, &resp);
if (result != 0) {
perror("error");
} else {
print_response(resp);
free_response(resp);
}
return 0;
}
DNS over TLS example:
#include <dns/dns.h>
#include <stdio.h>
int main(void)
{
struct request r = { "dns.server", 853, tls, "github.com", DNS_TYPE_A, DNS_CLASS_IN, "rootCA.crt", "certificate.pem" };
struct response resp;
int result = resolv(r, &resp);
if (result != 0) {
perror("error");
} else {
print_response(resp);
free_response(resp);
}
return 0;
}
DNS over HTTPS example:
#include <dns/dns.h>
#include <stdio.h>
int main(void)
{
struct request r = { "dns.server", 443, https, "github.com", DNS_TYPE_A, DNS_CLASS_IN, "rootCA.crt", "certificate.pem" };
struct response resp;
int result = resolv(r, &resp);
if (result != 0) {
perror("error");
} else {
print_response(resp);
free_response(resp);
}
return 0;
}
The sample code to use the python package:
DNS over UDP example:
import dns
request = dns.Request()
request.Address = "10.0.2.3"
request.Port = 53
request.Protocol = dns.Protocol.UDP
request.Qname = "github.com"
request.Type = dns.DNS_TYPE_A
request.Class = dns.Class.IN
response = dns.Resolv(request)
print(response)
DNS over TLS example:
import dns
request = dns.Request()
request.Address = "dns.server"
request.Port = 853
request.Protocol = dns.Protocol.TLS
request.Qname = "github.com"
request.Type = dns.DNS_TYPE_A
request.Class = dns.Class.IN
request.Ca = "rootCA.crt"
request.Certificate = "certificate.pem"
response = dns.Resolv(request)
print(response)
DNS over HTTPS example:
import dns
request = dns.Request()
request.Address = "dns.server"
request.Port = 443
request.Protocol = dns.Protocol.HTTPS
request.Qname = "github.com"
request.Type = dns.DNS_TYPE_A
request.Class = dns.Class.IN
request.Ca = "rootCA.crt"
request.Certificate = "certificate.pem"
response = dns.Resolv(request)
print(response)