-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extracting SRV results from lookup_srv
#172
Comments
Hm. Looks like this broke at some point along the way. You could fix that particular error by using a double reference to I will have a closer look and provide a fix ASAP. |
The fix is now available in the
I’ve added a note to the documentation. We will revisit this for 0.8 via #175. On the chance that you actually want to get the SRV records itself rather than the resolved socket addresses, I also added a new method Can you give this a try and let me know if this now works for you? If so, I’ll release 0.7.2 tomorrow. |
As a side note: This line in your example code: let reldname = RelativeDname::from_slice(b"_caldav._tcp").unwrap(); will panic because your slice is not a validly encoded domain name. I’m not entirely sure why let reldname = RelativeDname::from_slice(b"\x07_caldav\0x04_tcp").unwrap(); or you could make an absolute name and convert it: let reldname = Dname::bytes_from_str("_caldav._tcp").unwrap().into_relative(); Neither is great, so we’ll fix that in 0.8, too. |
Many thanks for 4f52d6c! |
I'm failing to install the crate from the
But this fails to install:
The branch seems to exist on GitHub's UI, so I'm not sure what wrong, but it looks like cargo can't clone it. Fetching it via
|
You have a space at the end of the branch name: |
Darn, that was dumb. Thanks for pointing it out. |
However, the example given above:
Panicks:
|
Ah, the example above should read: let reldname = RelativeDname::from_slice(b"\x07_caldav\x04_tcp").unwrap(); There was an extra |
Sorry, yes, you are correct. These escape sequences are tricky … |
The new I can get the target hosts via: for srv in srvs.into_srvs() {
let target = std::str::from_utf8(srv.target()).unwrap();
// ...
} However, these bytes encodes the data as it is encoded in DNS; not a string with dots separating parts (e.g.: as the one I'd pass to an It seems the only way to get the "regular" string (e.g.: with the dots) is to copy this one and replace some bytes. It would be ideal if I could take ownership the different parts (target, port, etc) from the Uri has a good reference API for this in All that said, it seems I can work things out for now by just copying the returned value and replacing the separators with |
The canonical way to convert a domain name into its presentation format is by displaying it. If you need to keep the string, then the Converting the wire-format domain name into the presentation form in-place is tricky. For one, the latter can be longer if escape sequences are needed. For another, you would need to drop the first octet which isn’t always possible. Can you maybe just keep the |
Ah, I didn't have that in mind. I guess that pretty much rules out the idea of replacing in-plan. For a sample that doesn't have longer escape sequences, I managed to convert [a copy] in place with: for srv in srvs.into_srvs() {
let mut dot = 0;
let target = srv.target().as_slice();
let mut copy = vec![0; target.len()];
copy.copy_from_slice(target);
loop {
if usize::from(dot) >= target.len() {
break;
}
dot += std::mem::replace(&mut copy[usize::from(dot)], b'.') + 1;
}
let s = std::str::from_utf8(©[1..]).unwrap();
todo!("{:?}", s);
} Thanks for the hint on using |
I will update the documentation to make it more clear how to convert between wire and presentation formats. |
#180 :) |
I’ve now released 0.7.2 – sorry, forgot about it. Is there anything left or can we close the issue? |
Thanks! I've switched from |
I'm trying to do an srv lookup (basically the equivalent of
drill SRV _caldav._tcp.fastmail.com
). I can execute the query, but can't figure out how to extract data fromdomain::resolv::lookup::srv::FoundSrvs
.My code is basically:
But this won't work due to:
I don't fully grasp what that lifetime implies there. Are there any live examples out there that can help?
The text was updated successfully, but these errors were encountered: