From 868e4885300185975497f672898332c5e8d4e81d Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 4 Feb 2018 21:06:09 +0100 Subject: [PATCH] move examples to examples directory, update readme and changelog --- CHANGELOG.md | 1 + README.md | 16 ++++++++++++++-- example_tcp.js => examples/tcp.js | 0 example.js => examples/udp.js | 0 4 files changed, 15 insertions(+), 2 deletions(-) rename example_tcp.js => examples/tcp.js (100%) rename example.js => examples/udp.js (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99e0ed3..7f5477f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ # Version 4.0.0 - yyyy-mm-dd +- added `streamEncode` and `streamDecode` methods for encoding TCP packets. - Changed the decoded value of TXT records to an array of Buffers. This is to accomodate DNS-SD records which rely on the individual strings record being separated. - Renamed the `flag_trunc` and `flag_auth` to `flag_tc` and `flag_aa` to match the names of these in the dns standards. diff --git a/README.md b/README.md index 5242c71..18088f8 100644 --- a/README.md +++ b/README.md @@ -35,19 +35,31 @@ socket.on('message', function (message) { socket.send(buf, 0, buf.length, 53, '8.8.8.8') ``` +Also see [the UDP example](examples/udp.js). + ## TCP Usage While DNS has traditionally been used over a datagram transport, it is increasingly being carried over TCP for larger responses commonly including DNSSEC responses and TCP/TLS for privacy reasons. +See [the TCP example](examples/tcp.js). + ## API #### `var buf = packets.encode(packet, [buf], [offset])` -Encodes a DNS packet into a buffer. +Encodes a DNS packet into a buffer containing a UDP payload. #### `var packet = packets.decode(buf, [offset])` -Decode a DNS packet from a buffer +Decode a DNS packet from a buffer containing a UDP payload. + +#### `var buf = packets.streamEncode(packet, [buf], [offset])` + +Encodes a DNS packet into a buffer containing a TCP payload. + +#### `var packet = packets.streamDecode(buf, [offset])` + +Decode a DNS packet from a buffer containing a TCP payload. #### `var len = packets.encodingLength(packet)` diff --git a/example_tcp.js b/examples/tcp.js similarity index 100% rename from example_tcp.js rename to examples/tcp.js diff --git a/example.js b/examples/udp.js similarity index 100% rename from example.js rename to examples/udp.js