[GH-ISSUE #197] resolver should return directly, when use a ip address as a argument? #388

Closed
opened 2026-03-15 22:15:27 +03:00 by kerem · 11 comments
Owner

Originally created by @cssivision on GitHub (Sep 22, 2017).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/197

i do not see similar logic in the code, this can avoid useless dns query.

Originally created by @cssivision on GitHub (Sep 22, 2017). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/197 i do not see similar logic in the code, this can avoid useless dns query.
kerem 2026-03-15 22:15:27 +03:00
Author
Owner

@bluejekyll commented on GitHub (Sep 22, 2017):

I’m not sure if that is best practice or not. I understand the desire. Do you know how other resolvers deal with that case?

<!-- gh-comment-id:331472431 --> @bluejekyll commented on GitHub (Sep 22, 2017): I’m not sure if that is best practice or not. I understand the desire. Do you know how other resolvers deal with that case?
Author
Owner

@cssivision commented on GitHub (Sep 23, 2017):

extreme pursuit for performance...

<!-- gh-comment-id:331629168 --> @cssivision commented on GitHub (Sep 23, 2017): extreme pursuit for performance...
Author
Owner

@cssivision commented on GitHub (Sep 23, 2017):

if we decide to do this, i can fire a pr.

<!-- gh-comment-id:331640891 --> @cssivision commented on GitHub (Sep 23, 2017): if we decide to do this, i can fire a pr.
Author
Owner

@bluejekyll commented on GitHub (Sep 23, 2017):

So the reason I'm concerned about this is that it's not clear to me that it's the responsibility of the resolver. i.e. I feel like, if you ask for name resolution, you expect it to be resolved :)

One option is that we could restrict the interface to TryInto<Name>, which I've been thinking of doing. That might make this more clear? For example, reverse Ip lookups are restricted to IpAddr.

I'm open to it, I just want to know what other resolvers out there do in this case...

<!-- gh-comment-id:331643690 --> @bluejekyll commented on GitHub (Sep 23, 2017): So the reason I'm concerned about this is that it's not clear to me that it's the responsibility of the resolver. i.e. I feel like, if you ask for name resolution, you expect it to be resolved :) One option is that we could restrict the interface to `TryInto<Name>`, which I've been thinking of doing. That might make this more clear? For example, reverse Ip lookups are restricted to `IpAddr`. I'm open to it, I just want to know what other resolvers out there do in this case...
Author
Owner

@cssivision commented on GitHub (Sep 23, 2017):

Now, if i use ip addr as input will get None as a return value.

i investigate the golang std lib method net.LookupIP i found it actually not implement the query, it just return the ip directly.

<!-- gh-comment-id:331647954 --> @cssivision commented on GitHub (Sep 23, 2017): Now, if i use `ip addr` as input will get `None` as a return value. i investigate the golang std lib method `net.LookupIP` i found it actually not implement the query, it just return the `ip` directly.
Author
Owner

@cssivision commented on GitHub (Sep 23, 2017):

for example:

// variable `host` may be a `domain` or `ip addr`.
let look_up = resolver.lookup_ip(&host);
let pair = look_up
            .and_then(move |res| if let Some(addr) = res.iter().next() {
                future::ok(addr)
            } else {
                // this logic is annoying
                if let Ok(addr) = IpAddr::from_str(&host) {
                    future::ok(addr)
                } else {
                    future::err(io::Error::new(io::ErrorKind::Other, "invalid addr".to_string()))
                }
            })
            .and_then(move |addr| {
                TcpStream::connect(&SocketAddr::new(addr, port), &handle1).map(|c2| (c1, c2))
            });
<!-- gh-comment-id:331651215 --> @cssivision commented on GitHub (Sep 23, 2017): for example: ```rust // variable `host` may be a `domain` or `ip addr`. let look_up = resolver.lookup_ip(&host); let pair = look_up .and_then(move |res| if let Some(addr) = res.iter().next() { future::ok(addr) } else { // this logic is annoying if let Ok(addr) = IpAddr::from_str(&host) { future::ok(addr) } else { future::err(io::Error::new(io::ErrorKind::Other, "invalid addr".to_string())) } }) .and_then(move |addr| { TcpStream::connect(&SocketAddr::new(addr, port), &handle1).map(|c2| (c1, c2)) }); ```
Author
Owner

@bluejekyll commented on GitHub (Sep 24, 2017):

Ok. This makes sense. If you're still interested in putting that PR together, that would be awesome!

<!-- gh-comment-id:331687185 --> @bluejekyll commented on GitHub (Sep 24, 2017): Ok. This makes sense. If you're still interested in putting that PR together, that would be awesome!
Author
Owner

@cssivision commented on GitHub (Sep 24, 2017):

ok, i will spend some time on this.

<!-- gh-comment-id:331687232 --> @cssivision commented on GitHub (Sep 24, 2017): ok, i will spend some time on this.
Author
Owner

@cssivision commented on GitHub (Nov 27, 2017):

sorry for being so late

<!-- gh-comment-id:347107669 --> @cssivision commented on GitHub (Nov 27, 2017): sorry for being so late
Author
Owner

@bluejekyll commented on GitHub (Nov 27, 2017):

No worries! Thanks for putting it together!

<!-- gh-comment-id:347212752 --> @bluejekyll commented on GitHub (Nov 27, 2017): No worries! Thanks for putting it together!
Author
Owner

@bluejekyll commented on GitHub (Nov 28, 2017):

Fixed in #302

<!-- gh-comment-id:347405243 --> @bluejekyll commented on GitHub (Nov 28, 2017): Fixed in #302
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#388
No description provided.