r-bk / rsdns Goto Github PK
View Code? Open in Web Editor NEWDNS Client Library
License: Apache License 2.0
DNS Client Library
License: Apache License 2.0
Hello,
I'm currently trying to use this crate but it cannot be compiled due to the build script requiring rustfmt
, however this tool is not installed on the official Rust build images (https://hub.docker.com/_/rust), nor it is on many build environments.
I don't know if it can be called a bug or a misconception, as build scripts should not rely on such tools being present (nor even really care about formatting of the code).
In my case it's out of question to change anything in the build environment "just" to have some DNS resolution features.
I can only recommend you to remove this requirement for future users, otherwise this lib seems really to be a good tool, even if I'm a bit surprised by the way it is implemented.
Hello there,
I am trying to use the library in a project. I was trying to use default example showed in the doc.rs of this crate.
I got a curious error :
error[E0433]: failed to resolve: could not find `resolvers` in `rsdns`
--> src/main.rs:6:12
|
6 | use rsdns::resolvers::{std::Resolver, ResolverConfig};
| ^^^^^^^^^ could not find `resolvers` in `rsdns`
error[E0432]: unresolved import `rsdns::resolvers`
--> src/main.rs:6:12
|
6 | use rsdns::resolvers::{std::Resolver, ResolverConfig};
| ^^^^^^^^^ could not find `resolvers` in `rsdns`
error[E0433]: failed to resolve: use of undeclared type `Resolver`
--> src/main.rs:68:24
|
68 | let mut resolver = Resolver::new(ResolverConfig::with_nameserver(nameserver))?;
| ^^^^^^^^ use of undeclared type `Resolver`
Here is the code :
use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
// DNS client lib
use rsdns::{constants::Class, records::data::A};
use rsdns::clients::{std::net::Client, ClientConfig};
use std::net::SocketAddr;
...
fn resolve_query(
query: &str,
query_type: &str,
servers: Vec<String>,
) -> Result<Vec<A>, Box<dyn std::error::Error>> {
let nameserver = SocketAddr::from_str("192.168.33.205:53")?;
let mut client = Client::new(ClientConfig::with_nameserver(nameserver))?;
let rrset = client.query_rrset::<A>(query, Class::In)?;
Ok(rrset.rdata)
}
I checked source code and saw that your crate are well exported with rsdns::clients.
Any idea why it don't works on my machine ? =)
I like rsdns because it is simple, and I noticed that "Zero memory allocation for all essential data-types records" is a next feature.
Is it nesseray for a simple project? or "rsdns" has a bottle neck for it?
Hi, I am scanning the rsdns in the latest version with my own static analyzer tool.
Unsafe conversion found at: src/bytes/macros.rs#L5
macro_rules! r_be {
($self:ident, $t:ty) => {{
if $self.len() >= std::mem::size_of::<$t>() {
let buf = unsafe { $self.buf.get_unchecked($self.pos..) };
let ptr = buf.as_ptr() as *const $t;
let v = unsafe { ptr.read_unaligned() };
$self.pos += std::mem::size_of::<$t>();
Ok(v.to_be())
} else {
Err($self.bound_error())
}
}};
}
This unsound implementation would create a misalignment issues if the type size of buf
is smaller than the type size of $t
.
This would potentially cause undefined behaviors in Rust. If we further manipulate the problematic converted types, it would potentially lead to different consequences such as access out-of-bound. I am reporting this issue for your attention.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.