Comparing version 0.3.0 to 0.4.0
@@ -25,5 +25,5 @@ #!/usr/bin/env node | ||
let inet6 = null; | ||
let tcp = null; | ||
let edns = null; | ||
let dnssec = null; | ||
let tcp = true; | ||
let edns = true; | ||
let dnssec = false; | ||
let debug = false; | ||
@@ -30,0 +30,0 @@ |
@@ -11,3 +11,3 @@ #!/usr/bin/env node | ||
const util = require('../lib/util'); | ||
const whois = require('../hints/whois.json'); | ||
const whois = require('../etc/whois.json'); | ||
@@ -14,0 +14,0 @@ function getServer(name) { |
@@ -15,3 +15,3 @@ /*! | ||
const encoding = require('./encoding'); | ||
const lazy = require('./lazy'); | ||
const lazy = require('./internal/lazy'); | ||
const openpgpkey = require('./openpgpkey'); | ||
@@ -46,2 +46,5 @@ const ResolvConf = require('./resolvconf'); | ||
if (options == null) | ||
options = {}; | ||
// Private | ||
@@ -220,2 +223,5 @@ this._create = create; | ||
if (type === types.SOA) | ||
return result[0]; | ||
return result; | ||
@@ -331,4 +337,4 @@ } | ||
return { | ||
priority: rd.preference, | ||
exchange: util.trimFQDN(rd.mx) | ||
exchange: util.trimFQDN(rd.mx), | ||
priority: rd.preference | ||
}; | ||
@@ -345,3 +351,3 @@ }); | ||
regexp: rd.regexp, | ||
replacement: rd.replacement, | ||
replacement: util.trimFQDN(rd.replacement), | ||
order: rd.order, | ||
@@ -384,6 +390,6 @@ preference: rd.preference | ||
return { | ||
name: util.trimFQDN(rd.target), | ||
port: rd.port, | ||
priority: rd.priority, | ||
weight: rd.weight, | ||
port: rd.port, | ||
name: util.trimFQDN(rd.target) | ||
weight: rd.weight | ||
}; | ||
@@ -407,46 +413,45 @@ }); | ||
return { | ||
type: 'A', | ||
address: rd.address, | ||
ttl: rr.ttl | ||
ttl: rr.ttl, | ||
type: 'A' | ||
}; | ||
case types.AAAA: | ||
return { | ||
type: 'AAAA', | ||
address: rd.address, | ||
ttl: rr.ttl | ||
ttl: rr.ttl, | ||
type: 'AAAA' | ||
}; | ||
case types.CNAME: | ||
return { | ||
type: 'CNAME', | ||
value: util.trimFQDN(rd.target) | ||
value: util.trimFQDN(rd.target), | ||
type: 'CNAME' | ||
}; | ||
case types.MX: | ||
return { | ||
type: 'MX', | ||
exchange: util.trimFQDN(rd.mx), | ||
priority: rd.preference, | ||
exchange: util.trimFQDN(rd.mx) | ||
type: 'MX' | ||
}; | ||
case types.NAPTR: | ||
return { | ||
type: 'NAPTR', | ||
flags: rd.flags, | ||
service: rd.service, | ||
regexp: rd.regexp, | ||
replacement: rd.replacement, | ||
replacement: util.trimFQDN(rd.replacement), | ||
order: rd.order, | ||
preference: rd.preference | ||
preference: rd.preference, | ||
type: 'NAPTR' | ||
}; | ||
case types.NS: | ||
return { | ||
type: 'NS', | ||
value: util.trimFQDN(rd.ns) | ||
value: util.trimFQDN(rd.ns), | ||
type: 'NS' | ||
}; | ||
case types.PTR: | ||
return { | ||
type: 'PTR', | ||
value: util.trimFQDN(rd.ptr) | ||
value: util.trimFQDN(rd.ptr), | ||
type: 'PTR' | ||
}; | ||
case types.SOA: | ||
return { | ||
type: 'SOA', | ||
nsname: util.trimFQDN(rd.ns), | ||
@@ -458,16 +463,17 @@ hostmaster: util.trimFQDN(rd.mbox), | ||
expire: rd.expire, | ||
minttl: rd.minttl | ||
minttl: rd.minttl, | ||
type: 'SOA' | ||
}; | ||
case types.SRV: | ||
return { | ||
type: 'SRV', | ||
name: util.trimFQDN(rd.target), | ||
port: rd.port, | ||
priority: rd.priority, | ||
weight: rd.weight, | ||
port: rd.port, | ||
name: util.trimFQDN(rd.target) | ||
type: 'SRV' | ||
}; | ||
case types.TXT: | ||
return { | ||
type: 'TXT', | ||
entries: rd.txt.slice() | ||
entries: rd.txt.slice(), | ||
type: 'TXT' | ||
}; | ||
@@ -588,3 +594,3 @@ default: | ||
const name = encoding.reverse(addr); | ||
const iana = lazy(require, './iana'); | ||
const iana = lazy('./internal/iana'); | ||
@@ -591,0 +597,0 @@ let ptrs; |
115
lib/bns.js
@@ -9,78 +9,39 @@ /*! | ||
const API = require('./api'); | ||
const Authority = require('./authority'); | ||
const AuthServer = require('./server/auth'); | ||
const Cache = require('./cache'); | ||
const constants = require('./constants'); | ||
const dane = require('./dane'); | ||
const dns = require('./dns'); | ||
const DNSResolver = require('./resolver/dns'); | ||
const DNSServer = require('./server/dns'); | ||
const dnssec = require('./dnssec'); | ||
const encoding = require('./encoding'); | ||
const DNSError = require('./error'); | ||
const Hints = require('./hints'); | ||
const Hosts = require('./hosts'); | ||
const hsig = require('./hsig'); | ||
const nsec3 = require('./nsec3'); | ||
const openpgpkey = require('./openpgpkey'); | ||
// const Ownership = require('./ownership'); | ||
const rdns = require('./rdns'); | ||
const RecursiveResolver = require('./resolver/recursive'); | ||
const RecursiveServer = require('./server/recursive'); | ||
const ResolvConf = require('./resolvconf'); | ||
const ROOT_HINTS = require('./roothints'); | ||
// const RootResolver = require('./resolver/root'); | ||
const sig0 = require('./sig0'); | ||
const smimea = require('./smimea'); | ||
const srv = require('./srv'); | ||
const sshfp = require('./sshfp'); | ||
const StubResolver = require('./resolver/stub'); | ||
const StubServer = require('./server/stub'); | ||
const tlsa = require('./tlsa'); | ||
const tsig = require('./tsig'); | ||
// const udns = require('./udns'); | ||
// const UnboundResolver = require('./resolver/unbound'); | ||
// const UnboundServer = require('./server/unbound'); | ||
const util = require('./util'); | ||
const wire = require('./wire'); | ||
const Zone = require('./zone'); | ||
exports.API = API; | ||
exports.Authority = Authority; | ||
exports.AuthServer = AuthServer; | ||
exports.Cache = Cache; | ||
exports.constants = constants; | ||
exports.dane = dane; | ||
exports.dns = dns; | ||
exports.DNSResolver = DNSResolver; | ||
exports.DNSServer = DNSServer; | ||
exports.dnssec = dnssec; | ||
exports.encoding = encoding; | ||
exports.DNSError = DNSError; | ||
exports.Hints = Hints; | ||
exports.Hosts = Hosts; | ||
exports.hsig = hsig; | ||
exports.nsec3 = nsec3; | ||
exports.openpgpkey = openpgpkey; | ||
// exports.Ownership = Ownership; | ||
exports.rdns = rdns; | ||
exports.RecursiveResolver = RecursiveResolver; | ||
exports.RecursiveServer = RecursiveServer; | ||
exports.ResolvConf = ResolvConf; | ||
exports.ROOT_HINTS = ROOT_HINTS; | ||
// exports.RootResolver = RootResolver; | ||
exports.sig0 = sig0; | ||
exports.smimea = smimea; | ||
exports.srv = srv; | ||
exports.sshfp = sshfp; | ||
exports.StubResolver = StubResolver; | ||
exports.StubServer = StubServer; | ||
exports.tlsa = tlsa; | ||
exports.tsig = tsig; | ||
// exports.udns = udns; | ||
// exports.UnboundResolver = UnboundResolver; | ||
// exports.UnboundServer = UnboundServer; | ||
exports.util = util; | ||
exports.wire = wire; | ||
exports.Zone = Zone; | ||
exports.API = require('./api'); | ||
exports.Authority = require('./authority'); | ||
exports.AuthServer = require('./server/auth'); | ||
exports.Cache = require('./cache'); | ||
exports.constants = require('./constants'); | ||
exports.dane = require('./dane'); | ||
exports.dns = require('./dns'); | ||
exports.DNSResolver = require('./resolver/dns'); | ||
exports.DNSServer = require('./server/dns'); | ||
exports.dnssec = require('./dnssec'); | ||
exports.encoding = require('./encoding'); | ||
exports.DNSError = require('./error'); | ||
exports.Hints = require('./hints'); | ||
exports.Hosts = require('./hosts'); | ||
exports.hsig = require('./hsig'); | ||
exports.nsec3 = require('./nsec3'); | ||
exports.openpgpkey = require('./openpgpkey'); | ||
exports.Ownership = require('./ownership'); | ||
exports.rdns = require('./rdns'); | ||
exports.RecursiveResolver = require('./resolver/recursive'); | ||
exports.RecursiveServer = require('./server/recursive'); | ||
exports.ResolvConf = require('./resolvconf'); | ||
exports.ROOT_HINTS = require('./roothints'); | ||
exports.RootResolver = require('./resolver/root'); | ||
exports.sig0 = require('./sig0'); | ||
exports.smimea = require('./smimea'); | ||
exports.srv = require('./srv'); | ||
exports.sshfp = require('./sshfp'); | ||
exports.StubResolver = require('./resolver/stub'); | ||
exports.StubServer = require('./server/stub'); | ||
exports.tlsa = require('./tlsa'); | ||
exports.tsig = require('./tsig'); | ||
exports.udns = require('./udns'); | ||
exports.UnboundResolver = require('./resolver/unbound'); | ||
exports.UnboundServer = require('./server/unbound'); | ||
exports.util = require('./util'); | ||
exports.wire = require('./wire'); | ||
exports.Zone = require('./zone'); |
@@ -599,3 +599,5 @@ /*! | ||
[algs.RSAMD5]: null, // Deprecated in RFC 6725 (introduced in rfc2537) | ||
[algs.DSA]: hashes.SHA1, | ||
[algs.RSASHA1]: hashes.SHA1, | ||
[algs.DSANSEC3SHA1]: hashes.SHA1, | ||
[algs.RSASHA1NSEC3SHA1]: hashes.SHA1, | ||
@@ -606,3 +608,4 @@ [algs.RSASHA256]: hashes.SHA256, | ||
[algs.RSASHA512]: hashes.SHA512, | ||
[algs.ED25519]: hashes.SHA256 | ||
[algs.ED25519]: hashes.SHA512, | ||
[algs.ED448]: hashes.SHA512 | ||
}; | ||
@@ -609,0 +612,0 @@ |
@@ -17,3 +17,3 @@ /*! | ||
const constants = require('./constants'); | ||
const crypto = require('./crypto'); | ||
const crypto = require('./internal/crypto'); | ||
const util = require('./util'); | ||
@@ -170,3 +170,3 @@ | ||
const hash = Buffer.from(hex.substring(1), 'hex'); | ||
const hash = Buffer.from(hex, 'hex'); | ||
@@ -173,0 +173,0 @@ if (hash.length !== 28) |
@@ -18,5 +18,5 @@ /*! | ||
const constants = require('./constants'); | ||
const crypto = require('./crypto'); | ||
const crypto = require('./internal/crypto'); | ||
const encoding = require('./encoding'); | ||
const keys = require('./keys'); | ||
const keys = require('./internal/keys'); | ||
const util = require('./util'); | ||
@@ -62,3 +62,5 @@ const wire = require('./wire'); | ||
[algs.RSAMD5]: crypto.md5, // Deprecated in RFC 6725 | ||
[algs.DSA]: crypto.sha1, | ||
[algs.RSASHA1]: crypto.sha1, | ||
[algs.DSANSEC3SHA1]: crypto.sha1, | ||
[algs.RSASHA1NSEC3SHA1]: crypto.sha1, | ||
@@ -69,3 +71,4 @@ [algs.RSASHA256]: crypto.sha256, | ||
[algs.RSASHA512]: crypto.sha512, | ||
[algs.ED25519]: crypto.sha256 | ||
[algs.ED25519]: crypto.sha512, | ||
[algs.ED448]: crypto.sha512 | ||
}; | ||
@@ -92,2 +95,3 @@ | ||
dnssec.createPrivate = keys.createPrivate; | ||
dnssec.createPrivateAsync = keys.createPrivateAsync; | ||
dnssec.createPublic = keys.createPublic; | ||
@@ -97,2 +101,18 @@ dnssec.encodePrivate = keys.encodePrivate; | ||
dnssec.readPrivate = keys.readPrivate; | ||
dnssec.readPrivateAsync = keys.readPrivateAsync; | ||
dnssec.readPublic = keys.readPublic; | ||
dnssec.readPublicAsync = keys.readPublicAsync; | ||
dnssec.writeKeys = keys.writeKeys; | ||
dnssec.writeKeysAsync = keys.writeKeysAsync; | ||
dnssec.writePrivate = keys.writePrivate; | ||
dnssec.writePrivateAsync = keys.writePrivateAsync; | ||
dnssec.writePublic = keys.writePublic; | ||
dnssec.writePublicAsync = keys.writePublicAsync; | ||
dnssec.makeKey = function makeKey(name, algorithm, priv, flags) { | ||
const pub = dnssec.createPublic(algorithm, priv); | ||
return dnssec.createKey(name, algorithm, pub, flags); | ||
}; | ||
dnssec.createKey = function createKey(name, algorithm, publicKey, flags) { | ||
@@ -126,2 +146,5 @@ if (flags == null) | ||
dnssec.createDS = function createDS(key, digestType) { | ||
if (digestType == null) | ||
digestType = hashes.SHA256; | ||
assert(key instanceof Record); | ||
@@ -258,3 +281,3 @@ assert(key.type === types.DNSKEY); | ||
case algs.DSANSEC3SHA1: | ||
throw new Error('Unsupported public key algorithm.'); | ||
return crypto.signDSA(hash, data, keybuf); | ||
case algs.RSAMD5: | ||
@@ -271,5 +294,5 @@ case algs.RSASHA1: | ||
case algs.ED25519: | ||
return crypto.signED25519(hash, data, keybuf); | ||
return crypto.signED25519(data, keybuf); | ||
case algs.ED448: | ||
throw new Error('Unsupported public key algorithm.'); | ||
return crypto.signED448(data, keybuf); | ||
} | ||
@@ -324,5 +347,5 @@ | ||
assert(sig instanceof Record); | ||
assert(sig.type === types.RRSIG); | ||
assert(sig.type === types.RRSIG || sig.type === types.SIG); | ||
assert(key instanceof Record); | ||
assert(key.type === types.DNSKEY); | ||
assert(key.type === types.DNSKEY || key.type === types.KEY); | ||
assert(Buffer.isBuffer(data)); | ||
@@ -341,3 +364,3 @@ assert((algorithm & 0xff) === algorithm); | ||
case algs.DSANSEC3SHA1: | ||
return false; | ||
return crypto.verifyDSA(hash, data, sigbuf, keybuf); | ||
case algs.RSAMD5: | ||
@@ -354,5 +377,5 @@ case algs.RSASHA1: | ||
case algs.ED25519: | ||
return crypto.verifyED25519(hash, data, sigbuf, keybuf); | ||
return crypto.verifyED25519(data, sigbuf, keybuf); | ||
case algs.ED448: | ||
return false; | ||
return crypto.verifyED448(data, sigbuf, keybuf); | ||
} | ||
@@ -359,0 +382,0 @@ |
@@ -172,5 +172,5 @@ /*! | ||
if (ptr) | ||
return this.map.get(ptr); | ||
return [this.map.get(ptr), true]; | ||
return this.map.get(key); | ||
return [this.map.get(key), false]; | ||
} | ||
@@ -182,3 +182,3 @@ | ||
const entry = this.lookup(name); | ||
const [entry, ptr] = this.lookup(name); | ||
@@ -190,12 +190,15 @@ if (!entry) | ||
if (type === types.PTR) { | ||
const rr = new Record(); | ||
const rd = new PTRRecord(); | ||
rr.name = name; | ||
rr.class = classes.IN; | ||
rr.ttl = 10800; | ||
rr.type = types.PTR; | ||
rr.data = rd; | ||
rd.ptr = entry.name; | ||
answer.push(rr); | ||
if (ptr) { | ||
if (type === types.PTR || type === types.ANY) { | ||
const rr = new Record(); | ||
const rd = new PTRRecord(); | ||
rr.name = name; | ||
rr.class = classes.IN; | ||
rr.ttl = 10800; | ||
rr.type = types.PTR; | ||
rr.data = rd; | ||
rd.ptr = entry.name; | ||
answer.push(rr); | ||
} | ||
return answer; | ||
@@ -202,0 +205,0 @@ } |
@@ -10,12 +10,6 @@ /*! | ||
const assert = require('bsert'); | ||
const wire = require('./wire'); | ||
const secp256k1 = require('bcrypto/lib/secp256k1'); | ||
const blake2b = require('bcrypto/lib/blake2b'); | ||
const sig0 = require('./sig0'); | ||
const { | ||
types, | ||
classes, | ||
Record, | ||
KEYRecord | ||
} = wire; | ||
/* | ||
@@ -33,27 +27,24 @@ * Constants | ||
hsig.createKey = function createKey(pub) { | ||
assert(Buffer.isBuffer(pub)); | ||
assert(pub.length === 33); | ||
hsig.createPrivate = function createPrivate() { | ||
return secp256k1.privateKeyGenerate(); | ||
}; | ||
const rr = new Record(); | ||
const rd = new KEYRecord(); | ||
hsig.createPrivateAsync = hsig.createPrivate; | ||
rr.name = '.'; | ||
rr.type = types.KEY; | ||
rr.class = classes.ANY; | ||
rr.ttl = 0; | ||
rr.data = rd; | ||
rd.flags = 0; | ||
rd.protocol = 0; | ||
rd.algorithm = sig0.algs.PRIVATEDNS; | ||
rd.publicKey = pub; | ||
hsig.createPublic = function createPublic(priv) { | ||
return secp256k1.publicKeyCreate(priv); | ||
}; | ||
return rr; | ||
hsig.makeKey = function makeKey(priv) { | ||
const pub = secp256k1.publicKeyCreate(priv); | ||
return hsig.createKey(pub); | ||
}; | ||
hsig.sign = function sign(msg, priv, blake2b, secp256k1) { | ||
hsig.createKey = function createKey(pub) { | ||
return sig0.createKey(sig0.algs.PRIVATEDNS, pub); | ||
}; | ||
hsig.sign = function sign(msg, priv) { | ||
assert(Buffer.isBuffer(msg)); | ||
assert(Buffer.isBuffer(priv) && priv.length === 32); | ||
assert(blake2b && typeof blake2b.digest === 'function'); | ||
assert(secp256k1 && typeof secp256k1.sign === 'function'); | ||
@@ -70,7 +61,5 @@ const pub = secp256k1.publicKeyCreate(priv, true); | ||
hsig.verify = function verify(msg, pub, blake2b, secp256k1) { | ||
hsig.verify = function verify(msg, pub) { | ||
assert(Buffer.isBuffer(msg)); | ||
assert(Buffer.isBuffer(pub) && pub.length === 33); | ||
assert(blake2b && typeof blake2b.digest === 'function'); | ||
assert(secp256k1 && typeof secp256k1.verify === 'function'); | ||
@@ -77,0 +66,0 @@ const key = hsig.createKey(pub); |
@@ -18,3 +18,3 @@ /*! | ||
const constants = require('./constants'); | ||
const crypto = require('./crypto'); | ||
const crypto = require('./internal/crypto'); | ||
const encoding = require('./encoding'); | ||
@@ -21,0 +21,0 @@ const wire = require('./wire'); |
@@ -12,3 +12,3 @@ /*! | ||
const constants = require('./constants'); | ||
const crypto = require('./crypto'); | ||
const crypto = require('./internal/crypto'); | ||
const dnssec = require('./dnssec'); | ||
@@ -745,3 +745,2 @@ const encoding = require('./encoding'); | ||
edns: true, | ||
ednsSize: 4096, | ||
dnssec: true, | ||
@@ -748,0 +747,0 @@ hosts: [ |
@@ -445,2 +445,3 @@ /*! | ||
} else { | ||
arg = option; | ||
name = arg; | ||
@@ -447,0 +448,0 @@ } |
@@ -15,3 +15,3 @@ /*! | ||
const encoding = require('../encoding'); | ||
const {Client} = require('../net'); | ||
const {Client} = require('../internal/net'); | ||
const util = require('../util'); | ||
@@ -18,0 +18,0 @@ const wire = require('../wire'); |
@@ -15,3 +15,3 @@ /*! | ||
const DNSError = require('../error'); | ||
const {Server} = require('../net'); | ||
const {Server} = require('../internal/net'); | ||
const wire = require('../wire'); | ||
@@ -175,3 +175,2 @@ | ||
const [qs] = req.question; | ||
const ds = this.dnssec && req.isDNSSEC(); | ||
@@ -208,3 +207,5 @@ | ||
if (!ds) { | ||
if (!ds && req.question.length > 0) { | ||
const [qs] = req.question; | ||
// If we're recursive, and the | ||
@@ -273,3 +274,3 @@ // query was ANY, do not remove. | ||
} else { | ||
const maxSize = this.edns | ||
const maxSize = this.edns && req | ||
? req.maxSize(this.ednsSize) | ||
@@ -313,3 +314,3 @@ : MAX_UDP_SIZE; | ||
this.send(req, res, rinfo); | ||
this.send(null, res, rinfo); | ||
@@ -316,0 +317,0 @@ return; |
@@ -41,2 +41,3 @@ /*! | ||
Record, | ||
KEYRecord, | ||
SIGRecord | ||
@@ -58,2 +59,49 @@ } = wire; | ||
sig0.filename = dnssec.filename; | ||
sig0.privFile = dnssec.privFile; | ||
sig0.pubFile = dnssec.pubFile; | ||
sig0.createPrivate = dnssec.createPrivate; | ||
sig0.createPrivateAsync = dnssec.createPrivateAsync; | ||
sig0.createPublic = dnssec.createPublic; | ||
sig0.encodePrivate = dnssec.encodePrivate; | ||
sig0.decodePrivate = dnssec.decodePrivate; | ||
sig0.readPrivate = dnssec.readPrivate; | ||
sig0.readPrivateAsync = dnssec.readPrivateAsync; | ||
sig0.readPublic = dnssec.readPublic; | ||
sig0.readPublicAsync = dnssec.readPublicAsync; | ||
sig0.writeKeys = dnssec.writeKeys; | ||
sig0.writeKeysAsync = dnssec.writeKeysAsync; | ||
sig0.writePrivate = dnssec.writePrivate; | ||
sig0.writePrivateAsync = dnssec.writePrivateAsync; | ||
sig0.writePublic = dnssec.writePublic; | ||
sig0.writePublicAsync = dnssec.writePublicAsync; | ||
sig0.makeKey = function makeKey(algorithm, priv) { | ||
const pub = sig0.createPublic(algorithm, priv); | ||
return sig0.createKey(algorithm, pub); | ||
}; | ||
sig0.createKey = function createKey(algorithm, publicKey) { | ||
assert((algorithm & 0xff) === algorithm); | ||
assert(Buffer.isBuffer(publicKey)); | ||
const rr = new Record(); | ||
const rd = new KEYRecord(); | ||
rr.name = '.'; | ||
rr.class = classes.ANY; | ||
rr.type = types.KEY; | ||
rr.ttl = 0; | ||
rr.data = rd; | ||
rd.flags = 0; | ||
rd.protocol = 0; | ||
rd.algorithm = algorithm; | ||
rd.publicKey = publicKey; | ||
return rr; | ||
}; | ||
sig0.sign = function sign(msg, key, priv, fudge, signer) { | ||
@@ -60,0 +108,0 @@ if (fudge == null) |
@@ -107,1 +107,9 @@ /*! | ||
}; | ||
/* | ||
* Expose | ||
*/ | ||
smimea.usages = usages; | ||
smimea.selectors = selectors; | ||
smimea.matchingTypes = matchingTypes; |
@@ -11,3 +11,3 @@ /*! | ||
const constants = require('./constants'); | ||
const crypto = require('./crypto'); | ||
const crypto = require('./internal/crypto'); | ||
const util = require('./util'); | ||
@@ -63,3 +63,3 @@ const wire = require('./wire'); | ||
assert(Buffer.isBuffer(key)); | ||
assert(typeof name === 'string'); | ||
assert((alg & 0xff) === alg); | ||
@@ -74,3 +74,3 @@ assert((digest & 0xff) === digest); | ||
rr.class = classes.IN; | ||
rr.ttl = 0; | ||
rr.ttl = 172800; | ||
rr.data = rd; | ||
@@ -77,0 +77,0 @@ rd.algorithm = alg; |
@@ -144,1 +144,9 @@ /*! | ||
}; | ||
/* | ||
* Expose | ||
*/ | ||
tlsa.usages = usages; | ||
tlsa.selectors = selectors; | ||
tlsa.matchingTypes = matchingTypes; |
@@ -15,3 +15,3 @@ /*! | ||
const constants = require('./constants'); | ||
const crypto = require('./crypto'); | ||
const crypto = require('./internal/crypto'); | ||
const encoding = require('./encoding'); | ||
@@ -100,2 +100,4 @@ const util = require('./util'); | ||
rd.mac = hash; | ||
const arcount = bio.readU16BE(pre, 10); | ||
@@ -150,6 +152,2 @@ const size = rr.getSize(); | ||
// Safe: the length is not secret. | ||
if (rd.mac.length !== hash.length) | ||
return false; | ||
// Constant time equals. | ||
@@ -156,0 +154,0 @@ return crypto.safeEqual(rd.mac, hash); |
@@ -305,3 +305,3 @@ /*! | ||
if (origin.length === 0) | ||
return false; | ||
return s; | ||
@@ -565,17 +565,37 @@ if (s === '@' || s.length === 0) | ||
util.timeOffset = 0; | ||
util.now = function now() { | ||
return Math.floor(Date.now() / 1000); | ||
return Math.floor(Date.now() / 1000) + util.timeOffset; | ||
}; | ||
util.digDate = function digDate(time) { | ||
let date; | ||
util.fakeTime = function fakeTime(time) { | ||
if (time == null) | ||
time = 0; | ||
if (time != null) { | ||
assert(Number.isSafeInteger(time)); | ||
assert(time >= 0); | ||
date = new Date(time * 1000); | ||
} else { | ||
date = new Date(); | ||
if (typeof time === 'string') | ||
time = Math.floor(Date.parse(time) / 1000); | ||
assert(Number.isSafeInteger(time)); | ||
assert(time >= 0); | ||
if (time === 0) { | ||
util.timeOffset = 0; | ||
return; | ||
} | ||
const now = Math.floor(Date.now() / 1000); | ||
util.timeOffset = time - now; | ||
}; | ||
util.digDate = function digDate(time) { | ||
if (time == null) | ||
time = util.now(); | ||
assert(Number.isSafeInteger(time)); | ||
assert(time >= 0); | ||
const date = new Date(time * 1000); | ||
// We need to replicate something like: | ||
@@ -582,0 +602,0 @@ // Tue Jun 12 21:27:00 PDT 2018 |
@@ -89,2 +89,3 @@ /*! | ||
if (rr.type !== types.A && rr.type !== types.AAAA) { | ||
// Skip check for A and AAAA due to glue. | ||
if (!util.isSubdomain(this.origin, rr.name)) | ||
@@ -136,2 +137,14 @@ throw new Error('Not a child of this zone.'); | ||
has(name, type) { | ||
assert(util.isFQDN(name)); | ||
assert((type & 0xffff) === type); | ||
const map = this.names.get(name); | ||
if (!map) | ||
return false; | ||
return map.rrs.has(type); | ||
} | ||
glue(name, an) { | ||
@@ -203,3 +216,3 @@ assert(util.isFQDN(name)); | ||
proveNoData(ns) { | ||
this.push(this.origin, types.NSEC, true, ns); | ||
this.push(this.origin, types.NSEC, ns); | ||
return this; | ||
@@ -212,3 +225,3 @@ } | ||
if (lower) | ||
this.push(lower, types.NSEC, true, ns); | ||
this.push(lower, types.NSEC, ns); | ||
@@ -226,5 +239,24 @@ this.proveNoData(ns); | ||
// Do we have an answer? | ||
if (an.length > 0) { | ||
const aa = util.equal(name, this.origin); | ||
return [an, [], ar, aa, true]; | ||
// Are we authoritative for this name? | ||
if (!this.has(name, types.SOA)) { | ||
// If we're not authoritative for this | ||
// name, this is probably a request | ||
// for a DS or NSEC record. | ||
if (type === types.NS) { | ||
// Exception: always send a | ||
// referral for an NS request. | ||
this.push(name, types.DS, an); | ||
return [[], an, ar, false, true]; | ||
} | ||
// Send the answer but do | ||
// not set the `aa` bit. | ||
return [an, [], ar, false, true]; | ||
} | ||
// We're authoritative. Send the | ||
// answer and set the `aa` bit. | ||
return [an, [], ar, true, true]; | ||
} | ||
@@ -234,2 +266,5 @@ | ||
// Are they requesting a child of our | ||
// origin? If not, handle the mishap | ||
// gracefully. | ||
if (this.origin !== '.') { | ||
@@ -239,3 +274,3 @@ const zone = util.from(name, labels, -this.count); | ||
// Refer them back to the root zone. | ||
if (this.origin !== zone) { | ||
if (!util.equal(zone, this.origin)) { | ||
const [ns, ar] = this.getHints(); | ||
@@ -246,2 +281,3 @@ return [[], ns, ar, false, true]; | ||
// Couldn't find anything. | ||
// Serve an SoA (no data). | ||
@@ -254,2 +290,5 @@ if (labels.length === this.count) { | ||
// Otherwise, they're requesting a | ||
// deeper subdomain of a name we | ||
// might have a referral for. | ||
const index = this.count + 1; | ||
@@ -259,2 +298,3 @@ const child = util.from(name, labels, -index); | ||
// Couldn't find any nameservers. | ||
// Serve an SoA (nxdomain). | ||
@@ -267,2 +307,3 @@ if (ns.length === 0) { | ||
// Send a referral, with DS records. | ||
this.push(child, types.DS, ns); | ||
@@ -269,0 +310,0 @@ |
{ | ||
"name": "bns", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "DNS bike-shed", | ||
@@ -38,17 +38,16 @@ "keywords": [ | ||
"dependencies": { | ||
"bcrypto": "~1.1.0", | ||
"bfile": "~0.1.1", | ||
"bheep": "~0.1.1", | ||
"binet": "~0.3.1", | ||
"bs32": "~0.1.1", | ||
"bcrypto": "~2.0.0", | ||
"bfile": "~0.1.2", | ||
"bheep": "~0.1.2", | ||
"binet": "~0.3.2", | ||
"bs32": "~0.1.2", | ||
"bsert": "~0.0.4", | ||
"btcp": "~0.1.1", | ||
"budp": "~0.1.1", | ||
"bufio": "~1.0.1" | ||
"btcp": "~0.1.2", | ||
"budp": "~0.1.2", | ||
"bufio": "~1.0.2" | ||
}, | ||
"optionalDependencies": { | ||
"unbound": "~0.1.0" | ||
"unbound": "~0.2.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^5.1.0", | ||
"mocha": "^5.2.0" | ||
@@ -60,5 +59,5 @@ }, | ||
"browser": { | ||
"./lib/lazy": "./lib/lazy-browser.js", | ||
"./lib/internal/lazy": "./lib/internal/lazy-browser.js", | ||
"./lib/resolver/unbound": "./lib/resolver/unbound-browser.js" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
665491
1
25533
+ Addedbcrypto@2.0.0(transitive)
+ Addednan@2.11.12.12.1(transitive)
+ Addedunbound@0.2.3(transitive)
- Removedbcrypto@1.1.0(transitive)
- Removednan@2.10.0(transitive)
- Removedunbound@0.1.0(transitive)
Updatedbcrypto@~2.0.0
Updatedbfile@~0.1.2
Updatedbheep@~0.1.2
Updatedbinet@~0.3.2
Updatedbs32@~0.1.2
Updatedbtcp@~0.1.2
Updatedbudp@~0.1.2
Updatedbufio@~1.0.2