dns-packet
Advanced tools
Comparing version 4.0.0 to 4.1.0
41
index.js
@@ -567,2 +567,42 @@ 'use strict' | ||
const rmx = exports.mx = {} | ||
rmx.encode = function (data, buf, offset) { | ||
if (!buf) buf = Buffer.allocUnsafe(rmx.encodingLength(data)) | ||
if (!offset) offset = 0 | ||
const oldOffset = offset | ||
offset += 2 | ||
buf.writeUInt16BE(data.preference || 0, offset) | ||
offset += 2 | ||
name.encode(data.exchange, buf, offset) | ||
offset += name.encode.bytes | ||
buf.writeUInt16BE(offset - oldOffset - 2, oldOffset) | ||
rmx.encode.bytes = offset - oldOffset | ||
return buf | ||
} | ||
rmx.encode.bytes = 0 | ||
rmx.decode = function (buf, offset) { | ||
if (!offset) offset = 0 | ||
const oldOffset = offset | ||
const data = {} | ||
offset += 2 | ||
data.preference = buf.readUInt16BE(offset) | ||
offset += 2 | ||
data.exchange = name.decode(buf, offset) | ||
offset += name.decode.bytes | ||
rmx.decode.bytes = offset - oldOffset | ||
return data | ||
} | ||
rmx.encodingLength = function (data) { | ||
return 4 + name.encodingLength(data.exchange) | ||
} | ||
const ra = exports.a = {} | ||
@@ -642,2 +682,3 @@ | ||
case 'SOA': return rsoa | ||
case 'MX': return rmx | ||
} | ||
@@ -644,0 +685,0 @@ return runknown |
{ | ||
"name": "dns-packet", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "An abstract-encoding compliant module for encoding / decoding DNS packets", | ||
@@ -5,0 +5,0 @@ "author": "Mathias Buus", |
@@ -248,2 +248,11 @@ # dns-packet | ||
#### `MX` | ||
``` js | ||
{ | ||
preference: 10, | ||
exchange: 'mail.example.net' | ||
} | ||
``` | ||
If you need another one, open an issue and we'll try to add it. | ||
@@ -250,0 +259,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
33553
894
262