-
Notifications
You must be signed in to change notification settings - Fork 1.1k
protocols/autonat: optionally use only global IPs #2618
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
Changes from 17 commits
3a214d7
dedb309
3df7e84
a9e64da
099b258
f2a51f3
9c2d901
b0f9713
99fec62
d3d9015
05d5f2d
5b3b909
f7d47da
b5a2c46
2954c1a
7035422
f027e09
202e0ad
1d6dbeb
36665ee
54c9681
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,16 +295,16 @@ impl<'a> AsServer<'a> { | |
.values() | ||
.find_map(|a| a.as_ref()) | ||
.ok_or_else(|| { | ||
let status_text = "no dial-request over relayed connections".to_string(); | ||
(status_text, ResponseError::DialError) | ||
let status_text = "refusing to dial peer with blocked observed address".to_string(); | ||
(status_text, ResponseError::DialRefused) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: the go implementation returns a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes. I think this is worth consolidating on. Mind driving it on libp2p/specs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Opened libp2p/specs#411. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also added 7035422, which does the same change for the case that |
||
})?; | ||
|
||
let mut addrs = Self::filter_valid_addrs(sender, request.addresses, observed_addr); | ||
addrs.truncate(self.config.max_peer_addresses); | ||
|
||
if addrs.is_empty() { | ||
let status_text = "no dialable addresses".to_string(); | ||
return Err((status_text, ResponseError::DialError)); | ||
return Err((status_text, ResponseError::DialRefused)); | ||
} | ||
|
||
Ok(addrs) | ||
|
@@ -316,10 +316,6 @@ impl<'a> AsServer<'a> { | |
demanded: Vec<Multiaddr>, | ||
observed_remote_at: &Multiaddr, | ||
) -> Vec<Multiaddr> { | ||
// Skip if the observed address is a relay address. | ||
if observed_remote_at.iter().any(|p| p == Protocol::P2pCircuit) { | ||
return Vec::new(); | ||
} | ||
let observed_ip = match observed_remote_at | ||
.into_iter() | ||
.find(|p| matches!(p, Protocol::Ip4(_) | Protocol::Ip6(_))) | ||
|
@@ -417,23 +413,4 @@ mod test { | |
.with(Protocol::P2p(peer_id.into())); | ||
assert_eq!(filtered, vec![expected_1, expected_2]); | ||
} | ||
|
||
#[test] | ||
fn skip_relayed_addr() { | ||
let peer_id = PeerId::random(); | ||
let observed_ip = random_ip(); | ||
// Observed address is relayed. | ||
let observed_addr = Multiaddr::empty() | ||
.with(observed_ip.clone()) | ||
.with(random_port()) | ||
.with(Protocol::P2p(PeerId::random().into())) | ||
.with(Protocol::P2pCircuit) | ||
.with(Protocol::P2p(peer_id.into())); | ||
let demanded = Multiaddr::empty() | ||
.with(random_ip()) | ||
.with(random_port()) | ||
.with(Protocol::P2p(peer_id.into())); | ||
let filtered = AsServer::filter_valid_addrs(peer_id, vec![demanded], &observed_addr); | ||
assert!(filtered.is_empty()); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.