rustdns v0.1.0
rustdns is a simple, fast, and fully fledged DNS library for interacting with domain name services at a high or low level.
Features
- Parsing and generating the following record types:
- A,
- AAAA,
- CNAME,
- MX,
- NS,
- SOA,
- PTR,
- TXT, and
- SRV
- Extension Mechanisms for DNS (EDNS(0)).
- Support International Domain Names (IDNA) - Different scripts, alphabets, anhd even emojis!
- Sample
dig
style command line. - Fully tested, and fuzzed.
Usage (low-level library)
use Message;
use *;
use UdpSocket;
use Duration;
If successful something like the following will be printed:
;; ->>HEADER<<- opcode: Query, status: NoError, id: 44857
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
; bramp.net. IN A
; ANSWER SECTION:
bramp.net. 299 IN A 104.21.62.200
bramp.net. 299 IN A 172.67.138.196
Usage (cli)
To use the demo CLI:
$ cargo run A www.google.com
...
response: 8.8.8.8:53
00000000: 86 17 81 80 00 01 00 01 00 00 00 01 03 77 77 77 ..........www
00000010: 06 67 6F 6F 67 6C 65 03 63 6F 6D 00 00 01 00 01 .google.com.....
00000020: C0 0C 00 01 00 01 00 00 00 6E 00 04 8E FA 48 C4 À........n..úHÄ
00000030: 00 00 29 02 00 00 00 00 00 00 00 ..)........
;; ->>HEADER<<- opcode: Query, status: NoError, id: 34327
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
; www.google.com. IN A
; ANSWER SECTION:
www.google.com. 110 IN A 142.250.72.196
$ cargo run AAAA www.google.com
$ cargo run ANY www.google.com
$ cargo run CNAME code.google.com
$ cargo run MX google.com
$ cargo run PTR 4.4.8.8.in-addr.arpa
$ cargo run SOA google.com
$ cargo run SRV _ldap._tcp.google.com
$ cargo run TXT google.com
Testing
$ cargo test
# or the handy
$ cargo watch -- cargo test --lib -- --nocapture
The test suite is full of stored real life examples, from querying real DNS records.
This was generated with cargo run -p generate_tests
.
Fuzzing
The library has been extensively fuzzed. Try for yourself:
$ cargo fuzz run from_slice
Releasing
$ cargo readme > README.md
$ cargo publish --dry-run
$ cargo publish
TODO (in order of priority)
- UDP/TCP library
- Client side examples
- Server side examples
- DNS over TLS (DoT) and DNS over HTTPS (DoH)
- DNSSEC: Signing, validating and key generation for DSA, RSA, ECDSA and Ed25519
- RFC 1035 zone file parsing
- NSID, Cookies, AXFR/IXFR, TSIG, SIG(0)
- Refactoring to use https://github.com/tokio-rs/bytes
Reference
- rfc1034: DOMAIN NAMES - CONCEPTS AND FACILITIES
- rfc1035: DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION
- rfc6895: Domain Name System (DNS) IANA Considerations
- IANA Domain Name System (DNS) Parameters
- Computer Networks CPS365 FALL 2016
- miekg's Go DNS Library
License: Apache-2.0
Copyright 2021 Andrew Brampton (bramp.net)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.