dns2 2.0.0 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +16 -0
- package/.github/FUNDING.yml +12 -12
- package/.github/workflows/lint.js.yml +17 -0
- package/.github/workflows/node.js.yml +29 -30
- package/LICENSE +18 -18
- package/README.md +227 -196
- package/SECURITY.md +21 -21
- package/client/doh.js +50 -42
- package/client/google.js +27 -27
- package/client/tcp.js +34 -34
- package/client/udp.js +39 -39
- package/example/client/doh.js +12 -12
- package/example/client/google.js +7 -8
- package/example/client/tcp-custom-dns.js +10 -10
- package/example/client/tcp.js +12 -12
- package/example/client/udp-custom-dns.js +11 -11
- package/example/client/udp-default.js +8 -8
- package/example/client/udp-subnet.js +11 -11
- package/example/client/udp.js +8 -8
- package/example/server/dns.js +46 -0
- package/example/server/doh.js +30 -28
- package/example/server/secret.key +28 -28
- package/example/server/server.crt +22 -22
- package/example/server/tcp.js +19 -19
- package/example/server/udp.js +23 -23
- package/index.js +97 -89
- package/lib/reader.js +53 -55
- package/lib/writer.js +42 -42
- package/package.json +42 -34
- package/packet.js +873 -857
- package/server/dns.js +94 -0
- package/server/doh.js +146 -143
- package/server/index.js +31 -24
- package/server/tcp.js +34 -26
- package/server/udp.js +47 -41
- package/test/index.js +395 -244
- package/test/test.js +34 -27
- package/.travis.yml +0 -4
package/.eslintrc
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "semistandard",
|
|
3
|
+
"rules": {
|
|
4
|
+
"space-before-function-paren": ["error", "never"],
|
|
5
|
+
"no-multi-spaces": ["error"],
|
|
6
|
+
"array-bracket-spacing": ["error", "always"],
|
|
7
|
+
"key-spacing": ["error", {
|
|
8
|
+
"align": {
|
|
9
|
+
"beforeColon": true,
|
|
10
|
+
"afterColon": true,
|
|
11
|
+
"on": "colon"
|
|
12
|
+
}
|
|
13
|
+
}],
|
|
14
|
+
"comma-dangle": ["error", "always-multiline"]
|
|
15
|
+
}
|
|
16
|
+
}
|
package/.github/FUNDING.yml
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# These are supported funding model platforms
|
|
2
|
-
|
|
3
|
-
github: song940
|
|
4
|
-
patreon: song940
|
|
5
|
-
open_collective: song940
|
|
6
|
-
ko_fi: # Replace with a single Ko-fi username
|
|
7
|
-
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
8
|
-
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
-
liberapay: # Replace with a single Liberapay username
|
|
10
|
-
issuehunt: # Replace with a single IssueHunt username
|
|
11
|
-
otechie: # Replace with a single Otechie username
|
|
12
|
-
custom: https://git.io/fjRcB
|
|
1
|
+
# These are supported funding model platforms
|
|
2
|
+
|
|
3
|
+
github: song940
|
|
4
|
+
patreon: song940
|
|
5
|
+
open_collective: song940
|
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
|
7
|
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
|
11
|
+
otechie: # Replace with a single Otechie username
|
|
12
|
+
custom: https://git.io/fjRcB
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Linting
|
|
5
|
+
|
|
6
|
+
on: [push, pull_request]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v2
|
|
13
|
+
- uses: actions/setup-node@v1
|
|
14
|
+
with:
|
|
15
|
+
node-version: 16
|
|
16
|
+
- run: npm i
|
|
17
|
+
- run: npm run lint
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
2
|
-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
-
|
|
4
|
-
name: Node.js CI
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
push:
|
|
8
|
-
branches: [ master ]
|
|
9
|
-
pull_request:
|
|
10
|
-
branches: [ master ]
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
build:
|
|
14
|
-
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
|
|
17
|
-
strategy:
|
|
18
|
-
matrix:
|
|
19
|
-
node-version: [10.x, 12.x, 14.x,
|
|
20
|
-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
21
|
-
|
|
22
|
-
steps:
|
|
23
|
-
- uses: actions/checkout@v2
|
|
24
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
25
|
-
uses: actions/setup-node@v1
|
|
26
|
-
with:
|
|
27
|
-
node-version: ${{ matrix.node-version }}
|
|
28
|
-
- run: npm ci
|
|
29
|
-
- run: npm
|
|
30
|
-
- run: npm test
|
|
1
|
+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Node.js CI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
pull_request:
|
|
10
|
+
branches: [ master ]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
node-version: [10.x, 12.x, 14.x, 16.x]
|
|
20
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
21
|
+
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v2
|
|
24
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
25
|
+
uses: actions/setup-node@v1
|
|
26
|
+
with:
|
|
27
|
+
node-version: ${{ matrix.node-version }}
|
|
28
|
+
- run: npm ci
|
|
29
|
+
- run: npm test
|
package/LICENSE
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
Copyright (c) 2016 lsong
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
in the Software without restriction, including without limitation the rights
|
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in
|
|
11
|
-
all copies or substantial portions of the Software.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1
|
+
Copyright (c) 2016 lsong
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,196 +1,227 @@
|
|
|
1
|
-
# dns2
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
[![
|
|
5
|
-
|
|
6
|
-
> A DNS Server and Client Implementation in Pure JavaScript with no dependencies.
|
|
7
|
-
|
|
8
|
-
### Features
|
|
9
|
-
|
|
10
|
-
+ Server and Client
|
|
11
|
-
+ Lot of Type Supported
|
|
12
|
-
+ Extremely lightweight
|
|
13
|
-
+ DNS over UDP, TCP, HTTPS Supported
|
|
14
|
-
|
|
15
|
-
### Installation
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
$ npm install dns2
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
### DNS Client (default UDP)
|
|
22
|
-
|
|
23
|
-
Lookup any records available for the domain `lsong.org`.
|
|
24
|
-
DNS client will use UDP by default.
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
const dns2 = require('dns2');
|
|
28
|
-
|
|
29
|
-
const options = {
|
|
30
|
-
// available options
|
|
31
|
-
// dns: dns server ip address or hostname (string),
|
|
32
|
-
// port: dns server port (number),
|
|
33
|
-
// recursive: Recursion Desired flag (boolean, default true, since > v1.4.2)
|
|
34
|
-
};
|
|
35
|
-
const dns = new dns2(options);
|
|
36
|
-
|
|
37
|
-
(async () => {
|
|
38
|
-
const result = await dns.resolveA('google.com');
|
|
39
|
-
console.log(result.answers);
|
|
40
|
-
})();
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Another way to instanciate dns2 UDP Client:
|
|
44
|
-
|
|
45
|
-
```js
|
|
46
|
-
const { UDPClient } = require('dns2');
|
|
47
|
-
|
|
48
|
-
const resolve = UDPClient();
|
|
49
|
-
|
|
50
|
-
(async () => {
|
|
51
|
-
const response = await resolve('google.com')
|
|
52
|
-
console.log(response.answers);
|
|
53
|
-
})();
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### DNS Client (TCP)
|
|
57
|
-
|
|
58
|
-
Lookup any records available for the domain `lsong.org`. By default, DNS requests will use UDP.
|
|
59
|
-
|
|
60
|
-
```js
|
|
61
|
-
const { TCPClient } = require('dns2');
|
|
62
|
-
|
|
63
|
-
const resolve = TCPClient();
|
|
64
|
-
|
|
65
|
-
(async () => {
|
|
66
|
-
try {
|
|
67
|
-
const response = await resolve('lsong.org')
|
|
68
|
-
console.log(response.answers);
|
|
69
|
-
} catch(error) {
|
|
70
|
-
// some DNS servers (i.e cloudflare 1.1.1.1, 1.0.0.1)
|
|
71
|
-
// may send an empty response when using TCP
|
|
72
|
-
console.log(error);
|
|
73
|
-
}
|
|
74
|
-
})();
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### Client Custom DNS Server
|
|
78
|
-
|
|
79
|
-
You can pass your own DNS Server.
|
|
80
|
-
|
|
81
|
-
```js
|
|
82
|
-
const { TCPClient } = require('dns2');
|
|
83
|
-
|
|
84
|
-
const resolve = TCPClient({
|
|
85
|
-
dns: '1.1.1.1'
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
(async () => {
|
|
89
|
-
try {
|
|
90
|
-
const result = await resolve('google.com');
|
|
91
|
-
console.log(result.answers);
|
|
92
|
-
} catch(error) {
|
|
93
|
-
console.log(error);
|
|
94
|
-
}
|
|
95
|
-
})();
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### System DNS Server
|
|
99
|
-
|
|
100
|
-
You can use the first DNS server from your OS with native node dns.
|
|
101
|
-
|
|
102
|
-
```js
|
|
103
|
-
const dns = require('dns');
|
|
104
|
-
const { TCPClient } = require('dns2');
|
|
105
|
-
|
|
106
|
-
const resolve = TCPClient({
|
|
107
|
-
dns: dns.getServers()[0]
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
(async () => {
|
|
111
|
-
try {
|
|
112
|
-
const result = await resolve('google.com');
|
|
113
|
-
console.log(result.answers);
|
|
114
|
-
} catch(error) {
|
|
115
|
-
console.log(error);
|
|
116
|
-
}
|
|
117
|
-
})();
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### Example Server
|
|
121
|
-
|
|
122
|
-
```js
|
|
123
|
-
const dns2 = require('dns2');
|
|
124
|
-
|
|
125
|
-
const { Packet } = dns2;
|
|
126
|
-
|
|
127
|
-
const server = dns2.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
name
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
1
|
+
# dns2
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
[](https://github.com/song940/node-dns/actions/workflows/node.js.yml)
|
|
5
|
+
|
|
6
|
+
> A DNS Server and Client Implementation in Pure JavaScript with no dependencies.
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
+ Server and Client
|
|
11
|
+
+ Lot of Type Supported
|
|
12
|
+
+ Extremely lightweight
|
|
13
|
+
+ DNS over UDP, TCP, HTTPS Supported
|
|
14
|
+
|
|
15
|
+
### Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
$ npm install dns2
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### DNS Client (default UDP)
|
|
22
|
+
|
|
23
|
+
Lookup any records available for the domain `lsong.org`.
|
|
24
|
+
DNS client will use UDP by default.
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
const dns2 = require('dns2');
|
|
28
|
+
|
|
29
|
+
const options = {
|
|
30
|
+
// available options
|
|
31
|
+
// dns: dns server ip address or hostname (string),
|
|
32
|
+
// port: dns server port (number),
|
|
33
|
+
// recursive: Recursion Desired flag (boolean, default true, since > v1.4.2)
|
|
34
|
+
};
|
|
35
|
+
const dns = new dns2(options);
|
|
36
|
+
|
|
37
|
+
(async () => {
|
|
38
|
+
const result = await dns.resolveA('google.com');
|
|
39
|
+
console.log(result.answers);
|
|
40
|
+
})();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Another way to instanciate dns2 UDP Client:
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const { UDPClient } = require('dns2');
|
|
47
|
+
|
|
48
|
+
const resolve = UDPClient();
|
|
49
|
+
|
|
50
|
+
(async () => {
|
|
51
|
+
const response = await resolve('google.com')
|
|
52
|
+
console.log(response.answers);
|
|
53
|
+
})();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### DNS Client (TCP)
|
|
57
|
+
|
|
58
|
+
Lookup any records available for the domain `lsong.org`. By default, DNS requests will use UDP.
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
const { TCPClient } = require('dns2');
|
|
62
|
+
|
|
63
|
+
const resolve = TCPClient();
|
|
64
|
+
|
|
65
|
+
(async () => {
|
|
66
|
+
try {
|
|
67
|
+
const response = await resolve('lsong.org')
|
|
68
|
+
console.log(response.answers);
|
|
69
|
+
} catch(error) {
|
|
70
|
+
// some DNS servers (i.e cloudflare 1.1.1.1, 1.0.0.1)
|
|
71
|
+
// may send an empty response when using TCP
|
|
72
|
+
console.log(error);
|
|
73
|
+
}
|
|
74
|
+
})();
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Client Custom DNS Server
|
|
78
|
+
|
|
79
|
+
You can pass your own DNS Server.
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
const { TCPClient } = require('dns2');
|
|
83
|
+
|
|
84
|
+
const resolve = TCPClient({
|
|
85
|
+
dns: '1.1.1.1'
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
(async () => {
|
|
89
|
+
try {
|
|
90
|
+
const result = await resolve('google.com');
|
|
91
|
+
console.log(result.answers);
|
|
92
|
+
} catch(error) {
|
|
93
|
+
console.log(error);
|
|
94
|
+
}
|
|
95
|
+
})();
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### System DNS Server
|
|
99
|
+
|
|
100
|
+
You can use the first DNS server from your OS with native node dns.
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
const dns = require('dns');
|
|
104
|
+
const { TCPClient } = require('dns2');
|
|
105
|
+
|
|
106
|
+
const resolve = TCPClient({
|
|
107
|
+
dns: dns.getServers()[0]
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
(async () => {
|
|
111
|
+
try {
|
|
112
|
+
const result = await resolve('google.com');
|
|
113
|
+
console.log(result.answers);
|
|
114
|
+
} catch(error) {
|
|
115
|
+
console.log(error);
|
|
116
|
+
}
|
|
117
|
+
})();
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Example Server
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
const dns2 = require('dns2');
|
|
124
|
+
|
|
125
|
+
const { Packet } = dns2;
|
|
126
|
+
|
|
127
|
+
const server = dns2.createServer({
|
|
128
|
+
udp: true,
|
|
129
|
+
handle: (request, send, rinfo) => {
|
|
130
|
+
const response = Packet.createResponseFromRequest(request);
|
|
131
|
+
const [ question ] = request.questions;
|
|
132
|
+
const { name } = question;
|
|
133
|
+
response.answers.push({
|
|
134
|
+
name,
|
|
135
|
+
type: Packet.TYPE.A,
|
|
136
|
+
class: Packet.CLASS.IN,
|
|
137
|
+
ttl: 300,
|
|
138
|
+
address: '8.8.8.8'
|
|
139
|
+
});
|
|
140
|
+
send(response);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
server.on('request', (request, response, rinfo) => {
|
|
145
|
+
console.log(request.header.id, request.questions[0]);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
server.on('requestError', (error) => {
|
|
149
|
+
console.log('Client sent an invalid request', error);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
server.on('listening', () => {
|
|
153
|
+
console.log(server.addresses());
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
server.on('close', () => {
|
|
157
|
+
console.log('server closed');
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
server.listen({
|
|
161
|
+
// Optionally specify port, address and/or the family of socket() for udp server:
|
|
162
|
+
udp: {
|
|
163
|
+
port: 5333,
|
|
164
|
+
address: "127.0.0.1",
|
|
165
|
+
type: "udp4", // IPv4 or IPv6 (Must be either "udp4" or "udp6")
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
// Optionally specify port and/or address for tcp server:
|
|
169
|
+
tcp: {
|
|
170
|
+
port: 5333,
|
|
171
|
+
address: "127.0.0.1",
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// eventually
|
|
176
|
+
server.close();
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Then you can test your DNS server:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
$ dig @127.0.0.1 -p5333 lsong.org
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Note that when implementing your own lookups, the contents of the query
|
|
186
|
+
will be found in `request.questions[0].name`.
|
|
187
|
+
|
|
188
|
+
### Relevant Specifications
|
|
189
|
+
|
|
190
|
+
+ [RFC-1034 - Domain Names - Concepts and Facilities](https://tools.ietf.org/html/rfc1034)
|
|
191
|
+
+ [RFC-1035 - Domain Names - Implementation and Specification](https://tools.ietf.org/html/rfc1035)
|
|
192
|
+
+ [RFC-2782 - A DNS RR for specifying the location of services (DNS SRV)](https://tools.ietf.org/html/rfc2782)
|
|
193
|
+
+ [RFC-7766 - DNS Transport over TCP - Implementation Requirements](https://tools.ietf.org/html/rfc7766)
|
|
194
|
+
+ [RFC-8484 - DNS Queries over HTTPS (DoH)](https://tools.ietf.org/html/rfc8484)
|
|
195
|
+
|
|
196
|
+
### Contributing
|
|
197
|
+
|
|
198
|
+
- Fork this Repo first
|
|
199
|
+
- Clone your Repo
|
|
200
|
+
- Install dependencies by `$ npm install`
|
|
201
|
+
- Checkout a feature branch
|
|
202
|
+
- Feel free to add your features
|
|
203
|
+
- Make sure your features are fully tested
|
|
204
|
+
- Publish your local branch, Open a pull request
|
|
205
|
+
- Enjoy hacking <3
|
|
206
|
+
|
|
207
|
+
### MIT license
|
|
208
|
+
|
|
209
|
+
Copyright (c) 2016 LIU SONG <song940@gmail.com> & [contributors](https://github.com/song940/node-dns/graphs/contributors).
|
|
210
|
+
|
|
211
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
212
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
213
|
+
in the Software without restriction, including without limitation the rights
|
|
214
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
215
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
216
|
+
furnished to do so, subject to the following conditions:
|
|
217
|
+
|
|
218
|
+
The above copyright notice and this permission notice shall be included in
|
|
219
|
+
all copies or substantial portions of the Software.
|
|
220
|
+
|
|
221
|
+
THE SOFTWARE IS PROVIDED "AS IS," WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
222
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
223
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
224
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
225
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
226
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
227
|
+
THE SOFTWARE.
|
package/SECURITY.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
# Security Policy
|
|
2
|
-
|
|
3
|
-
## Supported Versions
|
|
4
|
-
|
|
5
|
-
Use this section to tell people about which versions of your project are
|
|
6
|
-
currently being supported with security updates.
|
|
7
|
-
|
|
8
|
-
| Version | Supported |
|
|
9
|
-
| ------- | ------------------ |
|
|
10
|
-
| 5.1.x | :white_check_mark: |
|
|
11
|
-
| 5.0.x | :x: |
|
|
12
|
-
| 4.0.x | :white_check_mark: |
|
|
13
|
-
| < 4.0 | :x: |
|
|
14
|
-
|
|
15
|
-
## Reporting a Vulnerability
|
|
16
|
-
|
|
17
|
-
Use this section to tell people how to report a vulnerability.
|
|
18
|
-
|
|
19
|
-
Tell them where to go, how often they can expect to get an update on a
|
|
20
|
-
reported vulnerability, what to expect if the vulnerability is accepted or
|
|
21
|
-
declined, etc.
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
Use this section to tell people about which versions of your project are
|
|
6
|
+
currently being supported with security updates.
|
|
7
|
+
|
|
8
|
+
| Version | Supported |
|
|
9
|
+
| ------- | ------------------ |
|
|
10
|
+
| 5.1.x | :white_check_mark: |
|
|
11
|
+
| 5.0.x | :x: |
|
|
12
|
+
| 4.0.x | :white_check_mark: |
|
|
13
|
+
| < 4.0 | :x: |
|
|
14
|
+
|
|
15
|
+
## Reporting a Vulnerability
|
|
16
|
+
|
|
17
|
+
Use this section to tell people how to report a vulnerability.
|
|
18
|
+
|
|
19
|
+
Tell them where to go, how often they can expect to get an update on a
|
|
20
|
+
reported vulnerability, what to expect if the vulnerability is accepted or
|
|
21
|
+
declined, etc.
|