-
Notifications
You must be signed in to change notification settings - Fork 128
Conversation
debug!("Failed to get public IP: {}", e); | ||
debug!("Failed to get public IP via UPNP: {}", e); | ||
debug!("Trying with public_ip DNS/HTTP resolvers"); | ||
if let Some(v) = public_ip::addr().await { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any way to get and print specific error, not None
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can, however the crate tries various resolvers to try and get the external IP address on a best effort basis. The error would be resolver specific and in worst case would be a collection of errors of all resolvers tried (connection/networking errors).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would look something like this
let mut errors = vec![];
let ip = public_ip::resolve(public_ip::ALL, public_ip::Version::Any)
.filter_map(|result| std::future::ready( result.map_err(|e| errors.push(e)).ok() ))
.next()
.await
.map(|(addr, _)| addr);
if let Some(v) = ip {
debug!("Discovered public IP: {}", v);
node_endpoint.write().address = Ip(v);
} else {
debug!("Failed to get public IP via DNS/HTTP resolvers: {:?}", errors);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Fixes #244