Repository navigation
Conversation
…addrinfo should work
|
|
||
| #[pyclass(subclass)] | ||
| pub struct CompioLoop { | ||
| dns: OwnedRefCell<Resolver<CompioRuntimeProvider>>, |
There was a problem hiding this comment.
It's cool that hickory has compio support! But I'm wild-guessing from my phone that it's the standard compio-runtime that is supported, not the Python-specific one that compio-py forged.
There was a problem hiding this comment.
@fantix
Yeah it's a limitation and the second limitation is that we have to come up with our own getaddrinfo function as most lookups I've done about how to do one are not excactly said in detail however with a bit of guessing I did manage to figure out how we could go about it as outlined in my original plan. Know that my rust skills are a bit flakey compared to my Cython and C skills so I'm limited on what my ideas here are.
async fn async_getaddrinfo<'py>(
r#loop: &CompioLoop,
host: String,
family: i32,
) -> PyResult<Vec<Lookup>> {
let dns = r#loop.dns()?;
let mut results = Vec::new();
if (family & AF_INET) > 0 || family == 0 {
let ipv4 = dns.ipv4_lookup(&host).await;
match ipv4 {
Ok(ipv4_result) => {results.push(ipv4_result)},
Err(e) => {return Err(PyOSError::new_err(e.to_string()));}
}
}
if (family & AF_INET6) > 0 || family == 0 {
let ipv6 = dns.ipv6_lookup(&host).await;
match ipv6 {
Ok(ipv6_result) => {results.push(ipv6_result)},
Err(e) => {return Err(PyOSError::new_err(e.to_string()));}
}
}
Ok(results)
}
``There was a problem hiding this comment.
If needed I can always ask hickory-dns maintainers to see if they would like to help us create something for implementing getaddrinfo and getnameinfo functions which would make this task a bit less of a headache than it needs to be. as AAAA ipv6 and A ipv4 is always done under the hood. The wiki article linked shows this although I havent fully skimmed through it yet.
Maybe there is an RFC on how a getaddrinfo function works which would be helpful to me if anybody finds me one. I love RFCs because they give me a clear blueprint and the keep all the details cut and dry. c-ares leaves me a bit clueless on how it works (probably due to how optimized it is)
This is still a rough draft as I have not found a safe and reliable way to wrap asynchronous rust functions yet but I have a general idea of how
getaddrinfoneeds to work.What I understand so far
AF_INETflag is set do ipv4_lookupAF_INET6is set do ipv6_lookupAF_UNSPECshould call both ipv6 and ipv4PR closes #17