-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4f7a5b
commit 8012ca3
Showing
5 changed files
with
122 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,8 @@ | |
"chalk": "^2.3.2", | ||
"loglevel": "^1.6.1", | ||
"native-dns": "^0.7.0" | ||
}, | ||
"devDependencies": { | ||
"uuid": "^3.2.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,72 @@ | ||
const dns = require('dns') | ||
const dnsliar = require('./index') | ||
const Client = require('./src/Client') | ||
|
||
const domains = [ | ||
'rebind.network', | ||
'A.192.168.1.1.rebind.network', | ||
'A.192.168.1.1.1time.rebind.network', | ||
'A.192.168.1.1.5times.10.0.0.1.1time.rebind.network' | ||
] | ||
const dns = require('dns') | ||
const assert = require('assert') | ||
const uuidv4 = require('uuid/v4') | ||
|
||
const { spawn } = require('child_process'); | ||
const dnsliar = spawn('node', ['index.js', '--help', 15354]) | ||
|
||
let running = false | ||
dnsliar.stdout.on('data', (data) => { | ||
console.log(`stdout: ${data}`) | ||
if (!running) { | ||
resolveRequests(requests) | ||
running = true | ||
} | ||
}) | ||
|
||
domains.forEach(domain => { | ||
let client = new Client(domain) | ||
while (true) { | ||
let ip = client.next() | ||
console.log(domain) | ||
console.log(ip) | ||
if (!ip) break | ||
} | ||
dnsliar.stderr.on('data', (data) => { | ||
console.log(`stderr: ${data}`); | ||
}) | ||
|
||
dnsliar.on('close', (code) => { | ||
console.log(`child process exited with code ${code}`) | ||
}) | ||
|
||
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'] | ||
] | ||
|
||
dns.setServers(['127.0.0.1:15354']) | ||
|
||
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) | ||
}) | ||
} | ||
} |