njord-ns-server 1.0.0 → 2.1.0
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/Makefile +2 -6
- package/README.md +82 -6
- package/RELEASE.md +177 -0
- package/docs/index.md +113 -4
- package/examples/app.js +11 -9
- package/examples/axfr.js +74 -0
- package/examples/cluster.js +47 -64
- package/examples/noanswer.js +18 -16
- package/examples/recursor.js +43 -0
- package/examples/reflect.js +34 -43
- package/lib/errors.js +50 -60
- package/lib/index.js +53 -64
- package/lib/protocol.js +476 -391
- package/lib/query.js +187 -146
- package/lib/records/a.js +17 -14
- package/lib/records/aaaa.js +17 -13
- package/lib/records/cname.js +15 -14
- package/lib/records/mx.js +20 -29
- package/lib/records/ns.js +15 -14
- package/lib/records/ptr.js +22 -0
- package/lib/records/record.js +19 -0
- package/lib/records/soa.js +29 -42
- package/lib/records/srv.js +24 -32
- package/lib/records/txt.js +17 -14
- package/lib/recursor.js +189 -0
- package/lib/server.js +298 -149
- package/lib/validators.js +89 -62
- package/package.json +7 -7
- package/test/dnsbuffer.js +29 -56
- package/test/named.test.js +270 -199
- package/test/protocol.test.js +222 -26
- package/test/query.test.js +111 -43
- package/test/records.test.js +84 -45
- package/test/recursor.test.js +226 -0
- package/test/tcp.test.js +247 -0
- package/test/validator.test.js +118 -73
- package/TODO.md +0 -5
- package/test/dig.js +0 -113
- package/test/helper.js +0 -50
package/examples/cluster.js
CHANGED
|
@@ -1,89 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
var cluster = require('cluster');
|
|
1
|
+
'use strict';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
|
-
*
|
|
6
|
-
* <div>
|
|
7
|
-
* Example that uses cluster (http://nodejs.org/api/cluster.html) to
|
|
4
|
+
* Example that uses cluster (http://nodejs.org/api/cluster.html) to
|
|
8
5
|
* spin up multiple workers to handle requests.
|
|
9
|
-
* </div>
|
|
10
6
|
*
|
|
11
|
-
* <div>
|
|
12
7
|
* You can test it like this: dig @localhost -p 9999 goodtimes.com
|
|
13
|
-
* </div>
|
|
14
8
|
*
|
|
15
|
-
* <div>
|
|
16
9
|
* Or using dnsperf:
|
|
17
|
-
* </div>
|
|
18
10
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* $ dnsperf -s localhost -p 9999 -d /tmp/f -l 300
|
|
22
|
-
* </pre>
|
|
11
|
+
* $ echo "goodtimes.com A" > /tmp/f
|
|
12
|
+
* $ dnsperf -s localhost -p 9999 -d /tmp/f -l 300
|
|
23
13
|
*
|
|
24
|
-
* <div>
|
|
25
14
|
* Unfortunately the surprise is that more workers (4) run slower (3711 qps),
|
|
26
|
-
* than a single worker (4084 qps).
|
|
27
|
-
*
|
|
15
|
+
* than a single worker (4084 qps), so a single worker is started by default.
|
|
16
|
+
* Set WORKERS to start more of them.
|
|
28
17
|
*
|
|
29
|
-
*
|
|
18
|
+
* Note that this does not run on Windows, where Node.js can not share a UDP
|
|
19
|
+
* socket between the workers of a cluster (it fails with ENOTSUP).
|
|
30
20
|
*
|
|
21
|
+
* @author Brian Hammond
|
|
31
22
|
*/
|
|
32
|
-
var ClusterDns = function() {
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
this.PORT = 9999;
|
|
36
|
-
this.LISTEN = '127.0.0.1';
|
|
37
|
-
this.SCALING = 1;
|
|
24
|
+
const cluster = require('cluster');
|
|
38
25
|
|
|
39
|
-
|
|
40
|
-
var numCPUs = require('os').cpus().length;
|
|
41
|
-
var workers = numCPUs * this.SCALING;
|
|
42
|
-
workers = 1;
|
|
26
|
+
const named = require('../lib');
|
|
43
27
|
|
|
44
|
-
|
|
28
|
+
const PORT = 9999;
|
|
29
|
+
const LISTEN = '127.0.0.1';
|
|
30
|
+
const WORKERS = Number(process.env.WORKERS) || 1;
|
|
31
|
+
const TTL = 0;
|
|
45
32
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
function randomOctet() {
|
|
34
|
+
return Math.floor(Math.random() * 252 + 1);
|
|
35
|
+
}
|
|
49
36
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
37
|
+
function randomAddress() {
|
|
38
|
+
return randomOctet() + '.' + randomOctet() + '.' + randomOctet() + '.' +
|
|
39
|
+
randomOctet();
|
|
40
|
+
}
|
|
54
41
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return r() + '.' + r() + '.' + r() + '.' + r();
|
|
58
|
-
};
|
|
42
|
+
function primary() {
|
|
43
|
+
console.log('starting %d workers', WORKERS);
|
|
59
44
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var server = named.createServer();
|
|
45
|
+
for (let i = 0; i < WORKERS; i++)
|
|
46
|
+
cluster.fork();
|
|
63
47
|
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
cluster.on('exit', (worker) => {
|
|
49
|
+
console.log('worker %d died', worker.process.pid);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
66
52
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
53
|
+
function worker() {
|
|
54
|
+
const server = named.createServer();
|
|
70
55
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
query.addAnswer( domain, new named.ARecord( thiz.randumb(), ttl ) );
|
|
76
|
-
server.send(query);
|
|
77
|
-
});
|
|
78
|
-
};
|
|
56
|
+
server.listen(PORT, LISTEN, () => {
|
|
57
|
+
console.log('DNS worker started on %s:%d, pid:%d', LISTEN, PORT,
|
|
58
|
+
process.pid);
|
|
59
|
+
});
|
|
79
60
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
};
|
|
61
|
+
server.on('query', (query) => {
|
|
62
|
+
const domain = query.name();
|
|
63
|
+
query.addAnswer(domain, new named.SOARecord(domain, {serial: 12345}), TTL);
|
|
64
|
+
query.addAnswer(domain, new named.ARecord(randomAddress()), TTL);
|
|
65
|
+
server.send(query);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
88
68
|
|
|
89
|
-
|
|
69
|
+
if (cluster.isPrimary)
|
|
70
|
+
primary();
|
|
71
|
+
else
|
|
72
|
+
worker();
|
package/examples/noanswer.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
var server = named.createServer();
|
|
1
|
+
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const named = require('../lib');
|
|
4
|
+
|
|
5
|
+
const PORT = 9999;
|
|
6
|
+
const server = named.createServer();
|
|
7
|
+
|
|
8
|
+
server.listen(PORT, '127.0.0.1', () => {
|
|
9
|
+
console.log('DNS server started on port %d', PORT);
|
|
6
10
|
});
|
|
7
11
|
|
|
8
|
-
server.on('query',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// you send a "404" to a DNS client
|
|
15
|
-
server.send(query);
|
|
12
|
+
server.on('query', (query) => {
|
|
13
|
+
console.log('DNS Query: (%s) %s', query.type(), query.name());
|
|
14
|
+
// If we do not add any answers to the query then the
|
|
15
|
+
// result will be a 'null-answer' message. This is how
|
|
16
|
+
// you send a "404" to a DNS client
|
|
17
|
+
server.send(query);
|
|
16
18
|
});
|
|
17
19
|
|
|
18
|
-
server.on('clientError',
|
|
19
|
-
|
|
20
|
+
server.on('clientError', (error) => {
|
|
21
|
+
console.log('there was a clientError: %s', error.message());
|
|
20
22
|
});
|
|
21
23
|
|
|
22
|
-
server.on('uncaughtException',
|
|
23
|
-
|
|
24
|
+
server.on('uncaughtException', (error) => {
|
|
25
|
+
console.log('there was an excepton: %s', error.message());
|
|
24
26
|
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A server that answers what it knows itself, and asks other DNS servers for
|
|
5
|
+
* everything else.
|
|
6
|
+
*
|
|
7
|
+
* You can test it like this:
|
|
8
|
+
*
|
|
9
|
+
* $ dig @127.0.0.1 -p 9999 local.test
|
|
10
|
+
* $ dig @127.0.0.1 -p 9999 nodejs.org MX
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const named = require('../lib');
|
|
14
|
+
|
|
15
|
+
const PORT = 9999;
|
|
16
|
+
const server = named.createServer();
|
|
17
|
+
|
|
18
|
+
// Without `servers` the DNS servers of the system are asked
|
|
19
|
+
const recursor = named.createRecursor({
|
|
20
|
+
// servers: ['1.1.1.1', '8.8.8.8'],
|
|
21
|
+
timeout: 2000,
|
|
22
|
+
tries: 2
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
server.listen(PORT, '127.0.0.1', () => {
|
|
26
|
+
console.log('DNS server started on port %d', PORT);
|
|
27
|
+
console.log('asking %s for what we do not know', recursor.servers());
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
server.on('query', (query) => {
|
|
31
|
+
const domain = query.name();
|
|
32
|
+
console.log('DNS Query: (%s) %s', query.type(), domain);
|
|
33
|
+
|
|
34
|
+
if (domain === 'local.test' && query.type() === 'A') {
|
|
35
|
+
query.addAnswer(domain, new named.ARecord('127.0.0.1'), 300);
|
|
36
|
+
server.send(query);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// adds the answers that are found, or sets the response code when the
|
|
41
|
+
// lookup fails
|
|
42
|
+
recursor.resolve(query, () => server.send(query));
|
|
43
|
+
});
|
package/examples/reflect.js
CHANGED
|
@@ -1,51 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
var server = named.createServer();
|
|
1
|
+
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const named = require('../lib');
|
|
4
|
+
|
|
5
|
+
const PORT = 9999;
|
|
6
|
+
const TTL = 300;
|
|
7
|
+
const server = named.createServer();
|
|
8
|
+
|
|
9
|
+
// answers each supported type of query with a fixed record
|
|
10
|
+
const records = {
|
|
11
|
+
A: () => new named.ARecord('127.0.0.1'),
|
|
12
|
+
AAAA: () => new named.AAAARecord('::1'),
|
|
13
|
+
CNAME: () => new named.CNAMERecord('cname.example.com'),
|
|
14
|
+
MX: () => new named.MXRecord('smtp.example.com'),
|
|
15
|
+
NS: () => new named.NSRecord('ns.example.com'),
|
|
16
|
+
SOA: () => new named.SOARecord('example.com'),
|
|
17
|
+
SRV: () => new named.SRVRecord('sip.example.com', 5060),
|
|
18
|
+
TXT: () => new named.TXTRecord('hello world')
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
server.listen(PORT, '127.0.0.1', () => {
|
|
22
|
+
console.log('DNS server started on port %d', PORT);
|
|
6
23
|
});
|
|
7
24
|
|
|
8
|
-
server.on('query',
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
case 'AAAA':
|
|
18
|
-
var record = new named.AAAARecord('::1');
|
|
19
|
-
query.addAnswer(domain, record, 300);
|
|
20
|
-
break;
|
|
21
|
-
case 'CNAME':
|
|
22
|
-
var record = new named.CNAMERecord('cname.example.com');
|
|
23
|
-
query.addAnswer(domain, record, 300);
|
|
24
|
-
break;
|
|
25
|
-
case 'MX':
|
|
26
|
-
var record = new named.MXRecord('smtp.example.com');
|
|
27
|
-
query.addAnswer(domain, record, 300);
|
|
28
|
-
break;
|
|
29
|
-
case 'SOA':
|
|
30
|
-
var record = new named.SOARecord('example.com');
|
|
31
|
-
query.addAnswer(domain, record, 300);
|
|
32
|
-
break;
|
|
33
|
-
case 'SRV':
|
|
34
|
-
var record = new named.SRVRecord('sip.example.com', 5060);
|
|
35
|
-
query.addAnswer(domain, record, 300);
|
|
36
|
-
break;
|
|
37
|
-
case 'TXT':
|
|
38
|
-
var record = new named.TXTRecord('hello world');
|
|
39
|
-
query.addAnswer(domain, record, 300);
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
server.send(query);
|
|
25
|
+
server.on('query', (query) => {
|
|
26
|
+
const domain = query.name();
|
|
27
|
+
const type = query.type();
|
|
28
|
+
console.log('DNS Query: (%s) %s', type, domain);
|
|
29
|
+
|
|
30
|
+
if (Object.hasOwn(records, type))
|
|
31
|
+
query.addAnswer(domain, records[type](), TTL);
|
|
32
|
+
|
|
33
|
+
server.send(query);
|
|
43
34
|
});
|
|
44
35
|
|
|
45
|
-
server.on('clientError',
|
|
46
|
-
|
|
36
|
+
server.on('clientError', (error) => {
|
|
37
|
+
console.log('there was a clientError: %s', error.message());
|
|
47
38
|
});
|
|
48
39
|
|
|
49
|
-
server.on('uncaughtException',
|
|
50
|
-
|
|
40
|
+
server.on('uncaughtException', (error) => {
|
|
41
|
+
console.log('there was an excepton: %s', error.message());
|
|
51
42
|
});
|
package/lib/errors.js
CHANGED
|
@@ -5,71 +5,61 @@
|
|
|
5
5
|
|
|
6
6
|
*/
|
|
7
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
|
-
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const CODES = {
|
|
11
|
+
DNS_NO_ERROR: 0,
|
|
12
|
+
DNS_PROTOCOL_ERROR: 1,
|
|
13
|
+
DNS_CANNOT_PROCESS: 2,
|
|
14
|
+
DNS_NO_NAME: 3,
|
|
15
|
+
DNS_NOT_IMPLEMENTED: 4,
|
|
16
|
+
DNS_REFUSED: 5,
|
|
17
|
+
DNS_EXCEPTION: 6
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// error name -> [code, default message]
|
|
21
|
+
const ERRORS = {
|
|
22
|
+
ProtocolError: [CODES.DNS_PROTOCOL_ERROR, 'Protocol Error'],
|
|
23
|
+
CannotProcessError: [CODES.DNS_CANNOT_PROCESS, 'Cannot Process'],
|
|
24
|
+
NoNameError: [CODES.DNS_NO_NAME, 'No Name'],
|
|
25
|
+
NotImplementedError: [CODES.DNS_NOT_IMPLEMENTED, 'Not Implemented'],
|
|
26
|
+
RefusedError: [CODES.DNS_REFUSED, 'Refused'],
|
|
27
|
+
ExceptionError: [CODES.DNS_EXCEPTION, 'Exception']
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class DnsError extends Error {
|
|
32
|
+
constructor(name, code, msg, caller) {
|
|
33
|
+
super();
|
|
34
|
+
|
|
35
|
+
if (Error.captureStackTrace)
|
|
36
|
+
Error.captureStackTrace(this, caller || DnsError);
|
|
37
|
+
|
|
38
|
+
this.code = code;
|
|
39
|
+
this.name = name;
|
|
40
|
+
|
|
41
|
+
// Note that, unlike a regular Error, the message is a function
|
|
42
|
+
this.message = function message() {
|
|
43
|
+
return msg || name;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
33
46
|
}
|
|
34
47
|
|
|
35
|
-
util.inherits(DnsError, Error);
|
|
36
48
|
|
|
49
|
+
module.exports = Object.assign({ DnsError: DnsError }, CODES);
|
|
37
50
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Object.keys(CODES).forEach(function (code) {
|
|
42
|
-
module.exports[code] = CODES[code];
|
|
43
|
-
|
|
44
|
-
if (CODES[code] === 0)
|
|
45
|
-
return;
|
|
46
|
-
|
|
47
|
-
var err = '', msg = '';
|
|
48
|
-
var pieces = code.split('_').slice(1);
|
|
49
|
-
for (var i in pieces) {
|
|
50
|
-
var lc = pieces[i].toLowerCase();
|
|
51
|
-
var key = lc.charAt(0).toUpperCase() + lc.slice(1);
|
|
52
|
-
err += key;
|
|
53
|
-
msg += key + (( i + 1 ) < pieces.length ? ' ' : '');
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (!/\w+Error$/.test(err))
|
|
57
|
-
err += 'Error';
|
|
58
|
-
|
|
59
|
-
module.exports[err] = function(message, caller) {
|
|
60
|
-
DnsError.call(this,
|
|
61
|
-
err,
|
|
62
|
-
CODES[code],
|
|
63
|
-
message || msg,
|
|
64
|
-
caller || module.exports[err]);
|
|
51
|
+
Object.keys(ERRORS).forEach(function (name) {
|
|
52
|
+
const code = ERRORS[name][0];
|
|
53
|
+
const defaultMessage = ERRORS[name][1];
|
|
65
54
|
|
|
55
|
+
// The computed key gives the class its name
|
|
56
|
+
const errors = {
|
|
57
|
+
[name]: class extends DnsError {
|
|
58
|
+
constructor(message, caller) {
|
|
59
|
+
super(name, code, message || defaultMessage, caller || errors[name]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
66
62
|
};
|
|
67
|
-
module.exports[err].constructor = module.exports[err];
|
|
68
|
-
util.inherits(module.exports[err], DnsError);
|
|
69
|
-
|
|
70
|
-
ERRORS[CODES[code]] = {
|
|
71
|
-
err: err,
|
|
72
|
-
message: msg
|
|
73
|
-
}
|
|
74
63
|
|
|
64
|
+
module.exports[name] = errors[name];
|
|
75
65
|
});
|
package/lib/index.js
CHANGED
|
@@ -1,77 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
var path = require('path');
|
|
1
|
+
'use strict';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
const bunyan = require('bunyan');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const Server = require('./server');
|
|
6
|
+
const Query = require('./query');
|
|
7
|
+
const Protocol = require('./protocol');
|
|
8
|
+
const Recursor = require('./recursor');
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
///--- Globals
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
return (out);
|
|
23
|
-
}
|
|
13
|
+
const BUNYAN_SERIALIZERS = {
|
|
14
|
+
err: bunyan.stdSerializers.err,
|
|
15
|
+
query: function serializeQuery(q) {
|
|
16
|
+
return {
|
|
17
|
+
domain: q.name(),
|
|
18
|
+
operation: q.operation(),
|
|
19
|
+
type: q.type()
|
|
20
|
+
};
|
|
21
|
+
}
|
|
24
22
|
};
|
|
25
23
|
|
|
26
24
|
|
|
27
|
-
|
|
28
25
|
///--- Exports
|
|
29
|
-
module.exports = {
|
|
30
|
-
|
|
31
|
-
createServer: function createServer(options) {
|
|
32
|
-
options = options || {};
|
|
33
|
-
if (typeof (options) !== 'object')
|
|
34
|
-
throw new TypeError('options (object) required');
|
|
35
|
-
|
|
36
26
|
|
|
37
|
-
|
|
38
|
-
name: options.name || 'named',
|
|
39
|
-
log: options.log || bunyan.createLogger({
|
|
40
|
-
name: 'named',
|
|
41
|
-
level: 'warn',
|
|
42
|
-
serializers: BUNYAN_SERIALIZERS
|
|
43
|
-
})
|
|
44
|
-
};
|
|
45
|
-
return (new Server(opts));
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
Query: Query,
|
|
49
|
-
|
|
50
|
-
Protocol: Protocol,
|
|
27
|
+
module.exports = {
|
|
51
28
|
|
|
52
|
-
|
|
29
|
+
createServer: function createServer(options) {
|
|
30
|
+
options = options || {};
|
|
31
|
+
if (typeof (options) !== 'object')
|
|
32
|
+
throw new TypeError('options (object) required');
|
|
33
|
+
|
|
34
|
+
return new Server({
|
|
35
|
+
name: options.name || 'named',
|
|
36
|
+
tcpTimeout: options.tcpTimeout,
|
|
37
|
+
log: options.log || bunyan.createLogger({
|
|
38
|
+
name: 'named',
|
|
39
|
+
level: 'warn',
|
|
40
|
+
serializers: BUNYAN_SERIALIZERS
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
createRecursor: function createRecursor(options) {
|
|
46
|
+
return new Recursor(options);
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
Query: Query,
|
|
50
|
+
|
|
51
|
+
Protocol: Protocol,
|
|
52
|
+
|
|
53
|
+
bunyan: { serializers: BUNYAN_SERIALIZERS },
|
|
54
|
+
|
|
55
|
+
// All the record types are exported at the top-level
|
|
56
|
+
ARecord: require('./records/a'),
|
|
57
|
+
AAAARecord: require('./records/aaaa'),
|
|
58
|
+
CNAMERecord: require('./records/cname'),
|
|
59
|
+
MXRecord: require('./records/mx'),
|
|
60
|
+
NSRecord: require('./records/ns'),
|
|
61
|
+
PTRRecord: require('./records/ptr'),
|
|
62
|
+
SOARecord: require('./records/soa'),
|
|
63
|
+
SRVRecord: require('./records/srv'),
|
|
64
|
+
TXTRecord: require('./records/txt')
|
|
53
65
|
|
|
54
66
|
};
|
|
55
|
-
|
|
56
|
-
// Export all the record types at the top-level
|
|
57
|
-
var subdir = path.join(__dirname, 'records');
|
|
58
|
-
fs.readdirSync(subdir).forEach(function (f) {
|
|
59
|
-
var name = path.basename(f);
|
|
60
|
-
if (/\w+\.js/.test(name)) {
|
|
61
|
-
var k = name.split('.').shift().toUpperCase() + 'Record';
|
|
62
|
-
module.exports[k] = require(path.join(subdir, f));
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
// [
|
|
66
|
-
// 'A',
|
|
67
|
-
// 'MX',
|
|
68
|
-
// 'SOA',
|
|
69
|
-
// 'SRV',
|
|
70
|
-
// 'TXT',
|
|
71
|
-
// 'AAAA',
|
|
72
|
-
// 'CNAME'
|
|
73
|
-
// ].forEach(function (r) {
|
|
74
|
-
// var lcr = r.toLowerCase();
|
|
75
|
-
// var k = lcr.charAt(0).toUpperCase() + lcr.slice(1) + 'Record';
|
|
76
|
-
// module.exports[k] = require(path.join(__dirname, 'records/' + lcr))[r];
|
|
77
|
-
// });
|