diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2023-03-01 01:13:25 -0500 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2023-03-01 01:13:25 -0500 |
commit | b7676d06363f71b4a856c5f5815f75e2bf7ca8ec (patch) | |
tree | b7e188aa4e1abaa69b1b9ee4fb6cd5a0ad60637d /resolver/src/lib.rs | |
parent | gpl (diff) | |
download | wrapper-b7676d06363f71b4a856c5f5815f75e2bf7ca8ec.tar.gz wrapper-b7676d06363f71b4a856c5f5815f75e2bf7ca8ec.tar.bz2 wrapper-b7676d06363f71b4a856c5f5815f75e2bf7ca8ec.zip |
inital working dns
Diffstat (limited to 'resolver/src/lib.rs')
-rw-r--r-- | resolver/src/lib.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/resolver/src/lib.rs b/resolver/src/lib.rs new file mode 100644 index 0000000..d66ad5e --- /dev/null +++ b/resolver/src/lib.rs @@ -0,0 +1,33 @@ +use std::net::SocketAddr; +use server::handle_query; +use tokio::net::UdpSocket; +use packet::Result; + +mod server; +mod config; + +pub use config::Config as Config; + +pub struct DnsResolver { + config: Config +} + +impl DnsResolver { + + pub fn new(config: Config) -> Self { + Self { config } + } + + pub async fn bind(self, addr: SocketAddr) -> Result<()> { + + let socket = UdpSocket::bind(addr).await?; + + loop { + match handle_query(&socket, &self.config).await { + Ok(_) => {} + Err(e) => eprintln!("An error occurred: {}", e), + } + } + } + +}
\ No newline at end of file |