Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Unreleased

- feat(packet): encode name compression pointers (RFC 1035 §4.1.4)
- feat(server/udp): negotiated UDP payload size with TC=1 on oversize
- feat(server/tcp): pipeline support (RFC 7766 §6.2.1.1)
- feat(packet): EDNS extended RCODE supported
- fix(packet): EDNS default UDP payload size raised to 4096
- fix(packet): clamps TTLs to 2³¹−1
- fix(packet): Label and name length validation (RFC 1035 §2.3.4)
- fix(server/doh): accepts any (or absent) Accept header (RFC 8484 §4.1)
- fix(server/doh): DoH POST requires Content-Type: application/dns-message
- feat(server/doh): DoH responses include TTL-derived Cache-Control
- fix(packet): Packet.Header.toBuffer writes Z=0 (RFC 1035 §4.1.1)

### [2.3.0] - 2026-05-25

- fix(packet): IPv6 `::` compression for leading-zero address #123
Expand Down Expand Up @@ -57,5 +69,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
- fix(packet): ensure compressed IPv6 is valid #70
- doc(README): correct `server.listen` options

[2.3.0]: https://github.com/lsongdev/node-dns/releases/tag/v2.3.0
[2.2.0]: https://github.com/lsongdev/node-dns/releases/tag/v2.2.0
[2.2.1]: https://github.com/lsongdev/node-dns/releases/tag/v2.2.1
19 changes: 19 additions & 0 deletions lib/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ BufferWriter.prototype.writeBuffer = function(b) {
this.buffer = this.buffer.concat(b.buffer);
};

// Current write position, in bits.
BufferWriter.prototype.bitLength = function() {
return this.buffer.length;
};

// Current write position, in bytes. Defined when DNS encoding has stayed on
// byte boundaries (it always does at the points we expose this).
BufferWriter.prototype.byteLength = function() {
return this.buffer.length / 8;
};

// Overwrite `size` bits at `bitOffset` with `value`. Used to back-fill
// placeholders (e.g. RDLENGTH) once the field's contents have been written.
BufferWriter.prototype.patch = function(bitOffset, value, size) {
for (let i = 0; i < size; i++) {
this.buffer[bitOffset + i] = (value & Math.pow(2, size - i - 1)) ? 1 : 0;
}
};

/**
* [toBuffer description]
* @return {[type]} [description]
Expand Down
Loading