This project aims to implement a DNS library in rustlang based on, and only on, DNS-related RFCs. A DNS Client and a DNS resolver can be built using this library.
Implementation in progress.
- 1034 - Domain names, concepts and facilities.
- 1035 - Domain names, implementation and specification.
-
1123 - Requirements for Internet Hosts -- Application and Support
-
DNSSEC is not supported at the moment, but it will be eventually.
As this library is build it in rustlang, is mandatory to have Rust installed.
First to clone the repository:
git clone https://github.com/niclabs/dns-rust.git
Then to use the library there are three options:
-
Installing the library with
cargo install
. This option let us run the library with the commanddns_rust ...
, Install the library with the following command:cargo install --path <PATH>
With the library installed it can be run it with
dns_rust
followed by any necessary option.dns_rust [options]
-
Using the library through
cargo
with cargocargo run
, accompanied by any neccessary option.cargo run [options]
-
Using the library's code in your new project.
Fisrt you need to add the dependency to your Cargo.toml file:[dependencies] dns_rust = { path = <PATH> }
Then to use the Library in your Rust code Import the library at the beginning of your Rust file.
use std::net::IpAddr; use dns_rust::async_resolver::AsyncResolver; use dns_rust::async_resolver::config::ResolverConfig; async fn resolver()-> Vec<IpAddr> { let config = ResolverConfig::default(); let domain_name = "example.com"; let transport_protocol = "TCP"; let mut resolver = AsyncResolver::new(config); let ip_addresses = resolver.lookup_ip(domain_name, transport_protocol).await.unwrap(); ip_addresses }
Here it can be specified whether to run a client or a resolver :
Argument | Description |
---|---|
client |
Execute a client that connects to the server and sends requests. |
resolver |
Runs a DNS resolver |
-
For the client there is one argument:
Argument Description <HOST_NAME>
Host name to query for IP -
And three options:
Option Description --server <SERVER>
DNS server ip --qtype <QTYPE>
Query type [default: A] --qclass <QCLASS>
Query class [default: IN]
-
For the resolver there are two arguments:
Argument Description <HOST NAME>
Host name to query [NAMESERVER]...
Recursive servers -
And three options:
Option Description --bind-addr <BIND_ADDR>
Resolver bind address --qtype <QTYPE>
Query type [default: A] --protocol <PROTOCOL>
Protocol [default: UDP]
Additionally the client and resolver have the command -h
or --help
to print the description of the structure and its usage.
dns_rust resolver "example.com" "1.1.1.1" "8.8.8.8"
or
cargo run resolver "example.com" "1.1.1.1" "8.8.8.8"
These commands runs a query for example.com
running a resolver.
To improve code quality GitHub Actions has been implemented in the repository. GitHub Actions has been configured to trigger when a commit is pushed to the project repository, running "cargo build" and "cargo run", and then all tests, finally showing an "x" if any test fails or a "✓" if all tests pass.
Coming soon.
Javiera Alegria.
- github user @Javi801
- email javi@niclabs.cl