forked from lsongdev/node-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (43 loc) · 950 Bytes
/
index.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
const udp = require('dgram');
const Packet = require('./packet');
/**
* [DNS description]
* @docs https://tools.ietf.org/html/rfc1034
* @docs https://tools.ietf.org/html/rfc1035
*/
function DNS(options){
Object.assign(this, {
port: 53,
retries: 3,
timeout: 3,
nameServers: [
'8.8.8.8',
'8.8.4.4',
'114.114.114.114'
],
rootServers: [
'a','b','c','d','e','f',
'g','h','i','j','k','l','m'
].map(x => `${x}.root-servers.net`)
}, options);
return this;
}
DNS.prototype.query = function(domain, type){
return this.resolve(domain);
};
DNS.prototype.send = function(packet){
console.log(this.rootServers);
};
DNS.prototype.resolve = function(domain, type, ns){
// TODO:
};
/**
* [Server description]
* @type {[type]}
*/
DNS.Packet = Packet;
DNS.Server = require('./server');
DNS.createServer = function(options){
return new DNS.Server(options);
};
module.exports = DNS;