55 Commits

Author SHA1 Message Date
777f92260e Bye buffer 2026-04-08 23:23:29 +08:00
Justin Fisher
a260a8386b Compatibility with older JS engines
- Fixed typo with Buffer.readUint8 vs readUInt8 that is incompatible with older js
- Removed usage of Object.entries and replaced with for (key in obj)
2026-04-06 17:18:07 +08:00
Justin Fisher
8c70ce60a5 Fixed linting errors 2026-04-06 17:17:44 +08:00
Justin Fisher
74972afbbf Added dohpath SvcParam 2026-04-06 17:17:32 +08:00
Justin Fisher
577e88a9d7 feat: added support for RR type 64 (SVCB)
* Added Service Binding RR support (type 64)

This is just using the exact same code as the HTTPS parser as they are formatted in the same manner.
2026-04-06 17:17:15 +08:00
Justin Fisher
ab3c5ca3f5 feat: add support for HTTPS SVCB (type 65)
* This commit adds support for HTTPS SVCB record, both encoding and decoding.
2026-04-06 17:17:03 +08:00
vulcainman
2f0d514df0 Remove the unused NOT_QU_MASK constant
The code using this constant was removed by the commit
a7a0b78b41219b40d28d71232f79f8170f528f30
2026-04-06 17:12:22 +08:00
vulcainman
8d78b4b53a Fix several lint issues
This commit includes several fixes that addess lint issues introduced by
commit a7a0b78b41219b40d28d71232f79f8170f528f30
2026-04-06 17:12:19 +08:00
vulcainman
dfe5e3f86b Implement QU bit support in question encoder/decoder
This commit fix current QU bit implementation that may be used in mDNS
protocol. Indeed, until now, if a packet with QU bit set is received,
it is decoded as:

{

  ...

  questions: [
    {
      name: '...',
      type: 'PTR',
      class: 'UNKNOWN_32769'
    },
    {
      name: '...',
      type: 'PTR',
      class: 'UNKNOWN_32769'
    }
  ],

  ...

}

Instead of :

{

  ...

  questions: [
    {
      name: '...',
      type: 'PTR',
      class: 'IN'
    },
    {
      name: '...',
      type: 'PTR',
      class: 'IN'
    }
  ],

  ...

}

This commit adds a proper QU bit support via the qu_bit field.
It enables:

- The encoder to parse properly both the class and the QU bit
- THe decoder to encode a DNS packet with the QU bit set
2026-04-06 17:12:11 +08:00
Nihanth Subramanya
5b155e76d9 Add constant for NXDOMAIN
Trivially OR'ing 0x03 to the flags works to set NXDOMAIN in the response header. Exposing a constant for this makes it accessible and obvious.
2026-04-06 17:09:46 +08:00
Jack Bates
530d20bb93 Presentation format encoding
RFC 4034 specifies the presentation format of the DNSKEY public key,
RRSIG signature, and DS digest fields (base64, base64, and hexadecimal).
With this change, when fields are represented as such, the package will
use the corresponding encoding.
2026-04-06 17:09:15 +08:00
M4t7e
13f19d9b63
Proper Encoding/Decoding for Email Name Representation for SOA and RP Records (#93)
* Correct encode/decode for mail name representation

* Embeddedd `mail` in an option object

* Cleaner case distinction in decode function
2023-08-25 12:55:39 +02:00
Hasan Adams
f14f4838a8
Add TLSA support (#92)
* add tlsa record support

* add test for tlsa and update readme
2023-04-18 12:52:51 +02:00
xuhjbj
aca1ff751c
implement the NAPTR record (#89)
* implement the NAPTR record

* implement NAPTR record for readme

* update

* Update index.js

* Update index.js

* Update index.js

* fix test failed

* Add actual example values to README

* Update README.md

* Update README.md

---------

Co-authored-by: root <root@wxs1.fyre.ibm.com>
Co-authored-by: silverwind <me@silverwind.io>
2023-03-27 12:21:37 +02:00
wolfy1339
fab30b2588
Implement SSHFP records (#80)
* Add SSHFP record support

Use offset since we may receive a full dns packet
Account for maximum hash lengths for each hash type
fix: don't use the output of `Buffer#copy()`, instead use `Buffer#byteLength`
fix: normalize fingerprint string
fix: the offset pointer starts out at RDLENGTH
fix: account for the `RDLENGTH` field in `rsshfp.decode()`

* tests: add test for the SSHFP record type
2022-06-14 23:09:01 +02:00
Joachim Viide
1d42aadae7
Make name.decode stricter (#79)
* Add tests for name decoding corner cases

* Modify name.decode to throw an error in the following cases:
 * Not enough data for reading the full label
 * The label is too long (over 253 characters when dots are included)
  * A label must be either <= 63 bytes or a pointer
  * Pointers can only point to prior data (see RFC 1035, section 4.1.4)

In addition pointer jumps don't add extra dots in the names anymore.

* Make name_decoding tests more specific

* Make name.decode non-recursive

* Ensure name.decode can read the label header

* Fix name.decode error messages
2021-12-23 11:46:21 +01:00
Amith Mohanan
8e6d91c078
fix: Remove duplicate named export txt (#71) 2021-11-02 18:24:20 +01:00
Martin Heidegger
007a7c0634
fix: explicit Buffer reference for webpack (#68) 2021-07-05 12:12:40 +02:00
Martin Heidegger
30e54ea616
replacing ip with @leichtgewicht/ip-codec (#67) 2021-07-05 12:12:15 +02:00
Mathias Buus
fbaa906476 move all allocUnsafes to allocs for easier maintenance 2021-05-26 11:26:35 +02:00
Mathias Buus
bd84615252 check for .. also in encodingLength 2021-05-25 13:30:37 +02:00
Mathias Buus
25f15dd0fe do trim on encodingLength as well 2021-05-19 19:59:39 +02:00
Martin Kolárik
c61dd19846 Fix udpPayloadSize encoding 2019-03-26 13:25:30 +01:00
Joe Hildebrand
4932026f66 Add EDNS OPT de/encoding
* Add ECS processing.  See #46

* Add support for Padding.  Simplify ECS to not do CIDR parsing.

* Done implementing the EDNS0 options that make sense

* Default to string values from IANA for EDNSO option codes.  Add tests for mappings.

* Add a few more aliases for option codes

* Update README for EDNS0 options

* I think this is what is desired.  Happy to change it more if you want.

* Address code review comments from @silverwind
2019-02-21 23:25:17 +01:00
silverwind
985adc20b1
fix rp encode bytes 2019-01-23 00:16:23 +01:00
silverwind
2764de3e02
add fallback for RP mbox, add a few more tests 2019-01-22 22:48:57 +01:00
silverwind
b5c0ab3161
fix RP handling 2019-01-22 22:37:53 +01:00
Floyd Pink
4e25954bb4
add support for encoding RP records 2019-01-22 22:37:53 +01:00
Nick Johnson
8a6764b2b3 Remove accidental or in typebitmap.encodingLength (#41) 2018-09-05 18:52:59 +02:00
silverwind
db4e271a59
fix encoding of empty string in TXT data - fixes #39 2018-07-02 21:50:31 +02:00
silverwind
4c00781ed4
drop safe-buffer dependency, bump min node to 6 - fixes #20 2018-06-01 09:33:34 +02:00
Nick Johnson
4e540801ab Add support for DNSSEC types from RFC4034 (#38)
* Add support for DNSSEC types from RFC4034

* Fix bug with wrong signature length decoded

* Sort RRTypes in the Readme, and add new ones

* Add support for nsec3
2018-06-01 09:25:07 +02:00
Joe Hildebrand
f6db3d3d5f Add basic EDNS(0) OPT RR support
* Add EDNS(0) OPT RR for UDP payload size in query.

* Rework PR #34, fixes #36.  Add support for options in an OPT pseudo-RR.

* Include tweaks from @silverwind
2018-04-04 17:07:11 +02:00
Tom Pusateri
cd7caa6619 Fix buffer management for stream encoding. (#29)
* Fix buffer management for stream encoding.

* use slice() instead of Buffer.from() for Node v4
2018-03-27 20:53:57 +02:00
silverwind
087d59bb63
add MX record type
Fixes: https://github.com/mafintosh/dns-packet/issues/10
2018-02-11 11:07:58 +01:00
Tom Pusateri
7904e095e9 Add encoder for stream transports (TCP/TLS). (#23)
* Add encoder for stream transports (TCP/TLS).
Fixes #16.

* Add README text and return null on short buffer.
2018-02-04 19:58:34 +00:00
Richard Schneider
600d4acd90 fix: flush and class (#28) 2018-02-04 18:59:47 +00:00
silverwind
84589e7026
rename flag_auth,flag_trunc to flag_aa,flag_tc
Fixes: https://github.com/mafintosh/dns-packet/issues/27
2018-01-30 19:50:17 +01:00
Richard Schneider
d58cdb3419 Change TXT values to array of buffers (breaking) (#26)
* fix: txt data is an array of strings

* fix: a consistent API for TXT data

* docs: update TXT info

* feat: empty buffer is not allowed

* fix: allow empty strings and buffers

* fix: rnull is like old rtxt
2018-01-30 19:41:18 +01:00
silverwind
3b76b23221
Change class option to take strings and document it (#4)
This changes to class option to take strings instead of integers, so 1
becomes 'IN', 3 becomes 'CH' and so on. Also documented the class
option.
2018-01-12 21:20:38 +01:00
silverwind
6606c00fb3
convert to ES2015, tweak package.json 2018-01-11 21:34:58 +01:00
silverwind
3632f188fa
add .eslintrc, fix issues 2018-01-11 21:22:10 +01:00
Tom Pusateri
2e59f463e2
Fix encode/decode for root name ('.'). Add tests. Fixes #13. 2018-01-10 19:42:09 +01:00
Tom Pusateri
0e95e8e18d Convert Opcodes to/from strings. 2018-01-09 20:52:08 -05:00
Tom Pusateri
2474fead8f Add Q/R flag boolean and change other flags to boolean. 2018-01-09 20:51:50 -05:00
Tom Pusateri
eabaaa5156 Decode RCODE and other header flags. Fixes #11. 2018-01-09 20:50:00 -05:00
Tom Pusateri
5aaf0790d9 Finish adding SOA and NS record encoding/decoding. (#14)
* add ns record and soa record

* npm test with standard

* Complete SOA, NS decoding. Also add encoding and tests.

* updated travis CI tests to stable versions of node.
2018-01-05 18:42:16 +01:00
silverwind
e44b28c817
fix fallback for CAA flags 2017-08-12 22:09:43 +02:00
silverwind
03ca378b02
initialize caa flags to 0 when not given 2017-08-12 18:38:56 +02:00
kyleaedwards
c1e94b5d69
support CAA records 2017-08-12 18:25:09 +02:00