move examples to examples directory, update readme and changelog

This commit is contained in:
silverwind 2018-02-04 21:06:09 +01:00
parent 7904e095e9
commit 868e488530
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443
4 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,5 @@
# Version 4.0.0 - yyyy-mm-dd # 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. - 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. - Renamed the `flag_trunc` and `flag_auth` to `flag_tc` and `flag_aa` to match the names of these in the dns standards.

View File

@ -35,19 +35,31 @@ socket.on('message', function (message) {
socket.send(buf, 0, buf.length, 53, '8.8.8.8') socket.send(buf, 0, buf.length, 53, '8.8.8.8')
``` ```
Also see [the UDP example](examples/udp.js).
## TCP Usage ## 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. 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 ## API
#### `var buf = packets.encode(packet, [buf], [offset])` #### `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])` #### `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)` #### `var len = packets.encodingLength(packet)`