dns-packet
Advanced tools
Comparing version 5.5.0 to 5.6.0
55
index.js
@@ -1412,2 +1412,56 @@ 'use strict' | ||
const rtlsa = exports.tlsa = {} | ||
rtlsa.encode = function (cert, buf, offset) { | ||
if (!buf) buf = Buffer.alloc(rtlsa.encodingLength(cert)) | ||
if (!offset) offset = 0 | ||
const oldOffset = offset | ||
const certdata = cert.certificate | ||
if (!Buffer.isBuffer(certdata)) { | ||
throw new Error('Certificate must be a Buffer') | ||
} | ||
offset += 2 // Leave space for length | ||
buf.writeUInt8(cert.usage, offset) | ||
offset += 1 | ||
buf.writeUInt8(cert.selector, offset) | ||
offset += 1 | ||
buf.writeUInt8(cert.matchingType, offset) | ||
offset += 1 | ||
certdata.copy(buf, offset, 0, certdata.length) | ||
offset += certdata.length | ||
rtlsa.encode.bytes = offset - oldOffset | ||
buf.writeUInt16BE(rtlsa.encode.bytes - 2, oldOffset) | ||
return buf | ||
} | ||
rtlsa.encode.bytes = 0 | ||
rtlsa.decode = function (buf, offset) { | ||
if (!offset) offset = 0 | ||
const oldOffset = offset | ||
const cert = {} | ||
const length = buf.readUInt16BE(offset) | ||
offset += 2 | ||
cert.usage = buf.readUInt8(offset) | ||
offset += 1 | ||
cert.selector = buf.readUInt8(offset) | ||
offset += 1 | ||
cert.matchingType = buf.readUInt8(offset) | ||
offset += 1 | ||
cert.certificate = buf.slice(offset, oldOffset + length + 2) | ||
offset += cert.certificate.length | ||
rtlsa.decode.bytes = offset - oldOffset | ||
return cert | ||
} | ||
rtlsa.decode.bytes = 0 | ||
rtlsa.encodingLength = function (cert) { | ||
return 5 + Buffer.byteLength(cert.certificate) | ||
} | ||
const renc = exports.record = function (type) { | ||
@@ -1437,2 +1491,3 @@ switch (type.toUpperCase()) { | ||
case 'NAPTR': return rnaptr | ||
case 'TLSA': return rtlsa | ||
} | ||
@@ -1439,0 +1494,0 @@ return runknown |
{ | ||
"name": "dns-packet", | ||
"version": "5.5.0", | ||
"version": "5.6.0", | ||
"description": "An abstract-encoding compliant module for encoding / decoding DNS packets", | ||
@@ -5,0 +5,0 @@ "author": "Mathias Buus", |
@@ -214,2 +214,18 @@ # dns-packet | ||
#### `NAPTR` | ||
``` js | ||
{ | ||
data: | ||
{ | ||
order: 100, | ||
preference: 10, | ||
flags: 's', | ||
services: 'SIP+D2U', | ||
regexp: '!^.*$!sip:customer-service@example.com!', | ||
replacement: '_sip._udp.example.com' | ||
} | ||
} | ||
``` | ||
#### `NS` | ||
@@ -362,23 +378,18 @@ | ||
#### `TXT` | ||
#### `TLSA` | ||
``` js | ||
{ | ||
data: 'text' || Buffer || [ Buffer || 'text' ] | ||
usage: 3, | ||
selector: 1, | ||
matchingType: 1, | ||
certificate: Buffer | ||
} | ||
``` | ||
#### `NAPTR` | ||
#### `TXT` | ||
``` js | ||
{ | ||
data: | ||
{ | ||
order: 100, | ||
preference: 10, | ||
flags: 's', | ||
services: 'SIP+D2U', | ||
regexp: '!^.*$!sip:customer-service@example.com!', | ||
replacement: '_sip._udp.example.com' | ||
} | ||
data: 'text' || Buffer || [ Buffer || 'text' ] | ||
} | ||
@@ -385,0 +396,0 @@ ``` |
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
60384
1672
403