Comments (14)
Will do!
As a hint for now: Resolver
(and subsequently StubResolver
) has a method query
that takes a question and returns a Query
which is just a future for the response. So, basically, the flow is the same as with, say, addresses but with query
instead of lookup_addr
.
from domain.
Thanks. How about sending an Update and waiting for a response? How does that fit into the existing library?
from domain.
It doesn’t fit too well at this point. If your updates are reasonably simple, you can probably do the sending using UDP sockets yourself taking inspiration from domain-resolv/src/stub/net/udp.rs. If you don’t need fail-over, it’ll be even more simple.
from domain.
Ok, thanks. I'll homebrew something. I want to add a timeout on the response too so I know to try another server. I'm going to run into this with Push Notifications too. They don't always look like queries but they are Messages.
from domain.
Also, FYI, Push Notifications don't always get a response.
from domain.
I feel like UPDATE support would be a good feature for a separate module. It may also be a good reason to factor out the networking code into its own module rather than have it in the resolver.
This currently is an issue with async functions not working in no_std
crates, but apparently that is being fixed with the next Rust release.
from domain.
Also interested in an example ... StubResolver::run
seems to be exactly what I need to perform a simple synchronous DNS query, but I haven't been able to write a closure that is acceptable to the compiler.
from domain.
I’ve added an example in #65 and, incidentally, also found an issue with starting the runtime. I’ll release a new version of domain-resolv
soon.
from domain.
Is there simple way to use also async version of raw queries?
I have made this function:
use domain::resolv::StubResolver;
use domain::base::question::Question;
use domain::base::name;
async fn get_root_soa(resolver: &StubResolver) {
let root = name::Dname::root();
let question = Question::new_in(root, Rtype::Soa);
match resolver.query(question).await {
Ok(answer) => {
match answer.answer() {
Ok(rrset) => println!("Root soa answer: {:?}", rrset),
Err(err) => println!("Error decoding root SOA answer: {}", err),
};
},
Err(err) => {
println!("Root soa resolution failed!");
}
};
}
But rust compiler complains with:
error[E0698]: type inside `async fn` body must be known in this context
--> src/main.rs:109:16
|
109 | let root = name::Dname::root();
| ^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Octets` declared on the struct `Dname`
|
note: the type is part of the `async fn` body because of this `await`
--> src/main.rs:111:35
|
111 | match resolver.query(question).await {
| ^^^^^^
I hoped Dname is just implementation detail. But I don't know how to define the full type in this case. And I just used root, not any parsed domain. Could be also working asynchronous variant of sync test added?
from domain.
I would ask on better channel, but I haven't found any. Reported on #133
from domain.
How do i get the StubResolver with the latest iteration? I'm trying to get domain records.
from domain.
@pemensik Sorry, I somehow missed your question (or maybe thought you would start a discussion as suggested in #133.)
The issue with Dname::root
is that is generic over the octets sequence type. So either you need to specify the desired type, e.g., through Dname::<&'static [u8]>::root()
, or you use one of the functions that only work for a specific type such as Dname::root_slice()
.
from domain.
@sigh-gone If you don’t care about any specific configuration, StubResolver::new()
should work. The examples directory in the repository has a few examples on how to do actual lookups with it.
from domain.
I’m closing the issue for now. Feel free to reopen it if you have a follow-up question.
from domain.
Related Issues (20)
- Domains
- Change `qr` bit HOT 3
- domain::zonefile::inplace::Zonefile adds two extra bytes to the public key of a DNSKEY record HOT 2
- Rename variants of `base::name::FromStrError`.
- `FoundSrvs::into_srvs` missing from v0.8.0
- function dname_from_addr HOT 3
- Difference between domain::base::name::Dname and domain::rdata::dname::Dname? HOT 2
- Make it easier to manipulate messages. HOT 4
- Ns record extraction HOT 2
- The TXT record concatenates and outputs all character strings HOT 4
- Reject empty TXT record data.
- Update the README
- Mistake in Dname::from_slice doc example HOT 1
- Stable/core RRSet type HOT 6
- serde_json round-trip of TXT record fails with spaces HOT 2
- ZoneRecordData should include CAA records HOT 1
- Change IANA types from an enum into a struct wrapping an integer.
- Switch `ToDname` et al. to have a `try_to_dname`/`to_dname` pair.
- idns: report redundant statistics
- Using pre-release version HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from domain.