forked from brannondorsey/whonow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
107 lines (95 loc) · 6.62 KB
/
test.js
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
const dns = require('dns')
const assert = require('assert')
const uuidv4 = require('uuid/v4')
const uuid = uuidv4()
const requests = [
// domain name, expected result
[`rebind.network`, '127.0.0.1'],
[`A.192.168.1.1.${uuid}.rebind.network`, '127.0.0.1'],
[`A.192.168.1.1.1time.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.1time.${uuid}.rebind.network`, '127.0.0.1'],
[`A.192.168.1.1.forever.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.forever.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.5times.10.0.0.1.1time.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.5times.10.0.0.1.1time.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.5times.10.0.0.1.1time.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.5times.10.0.0.1.1time.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.5times.10.0.0.1.1time.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.5times.10.0.0.1.1time.${uuid}.rebind.network`, '10.0.0.1'],
[`A.192.168.1.1.5times.10.0.0.1.1time.${uuid}.rebind.network`, '127.0.0.1'],
[`A.192.168.1.1.1time.192.168.1.2.1times.repeat.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.1time.192.168.1.2.1times.repeat.${uuid}.rebind.network`, '192.168.1.2'],
[`A.192.168.1.1.1time.192.168.1.2.1times.repeat.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.1time.192.168.1.2.1times.repeat.${uuid}.rebind.network`, '192.168.1.2'],
[`A.192.168.1.1.1time.192.168.1.2.2times.192.168.1.3.forever.${uuid}.rebind.network`, '192.168.1.1'],
[`A.192.168.1.1.1time.192.168.1.2.2times.192.168.1.3.forever.${uuid}.rebind.network`, '192.168.1.2'],
[`A.192.168.1.1.1time.192.168.1.2.2times.192.168.1.3.forever.${uuid}.rebind.network`, '192.168.1.2'],
[`A.192.168.1.1.1time.192.168.1.2.2times.192.168.1.3.forever.${uuid}.rebind.network`, '192.168.1.3'],
[`A.192.168.1.1.1time.192.168.1.2.2times.192.168.1.3.forever.${uuid}.rebind.network`, '192.168.1.3'],
[`A.192.168.1.1.1time.192.168.1.2.2times.192.168.1.3.forever.${uuid}.rebind.network`, '192.168.1.3'],
[`A.192.168.1.1.1time.192.168.1.2.2times.192.168.1.3.forever.${uuid}.rebind.network`, '192.168.1.3'],
[`A.192.168.1.1.1time.192.168.1.2.2times.192.168.1.3.forever.${uuid}.rebind.network`, '192.168.1.3'],
[`a.127.0.0.1.1time.192.168.1.0.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.1.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.2.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.3.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.4.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.5.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.6.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.7.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.8.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.9.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.10.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.11.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.12.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.13.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.14.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.15.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.16.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.17.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.18.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.19.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.20.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.21.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.22.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.23.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.24.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.25.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.26.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.27.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.28.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.29.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.30.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.31.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.32.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.33.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.34.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.35.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.36.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.37.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.38.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.39.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.40.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.41.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.42.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.43.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.44.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.45.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.46.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.47.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.48.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.49.forever.${uuid}.rebind.network`, `127.0.0.1`],
[`a.127.0.0.1.1time.192.168.1.50.forever.${uuid}.rebind.network`, `127.0.0.1`]
]
dns.setServers(['127.0.0.1:15353'])
resolveRequests(requests)
function resolveRequests(requests, index=0) {
if (index < requests.length) {
dns.resolve(requests[index][0], 'A', (err, result) => {
if (err) throw err
console.log(`${result.toString().padEnd(15)} ${requests[index][0]}`)
assert.equal(result, requests[index][1])
resolveRequests(requests, index + 1)
})
}
}