-
Notifications
You must be signed in to change notification settings - Fork 957
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
Figure out the design of nat_traversal and external addresses #794
Comments
Also:
|
It would make sense to me to not name this method As for real NAT traversal we would need more than reporting externally observed addresses. Many NATs perform address and port filtering which makes the address reported by some peer useless for other peers. This limitation may already produce many invalid addresses without peers acting maliciously. Some scoring algorithm could help filtering out those addresses.
At least it would harm connectivity, i.e. it would take longer to establish connections to peers. Otherwise it depends on how a node keeps and uses reported addresses.
It would help to make explicit what kind of malicious behaviour we want to protect against. Is it only the reporting of invalid or unreachable addresses? Are we concerned about DDOS attacks or what other kinds of bad behaviour? |
My two cents on this is that it's wise to keep |
The question also is: is
And that could be a problem if a node has 14 bad addresses and only one good one.
In this issue only about invalid/unreachable addresses. |
To start off simple we could store the addresses in a priority queue with counters reflecting the number of times we have seen an address reported to us and use them in priority order. Having seen an address multiple times from different peers makes it more likely that we would be able to reach it. |
Here is some context about NAT traversal in rust-libp2p in general. The mechanisms in play when it comes to addresses are:
Problems and things to improve:
|
Related: paritytech/substrate#1193 |
One way we could change the pub trait Transport {
type Output;
type Error: error::Error;
type Listener: Stream<Item = ListenerStreamEvent, Error = Self::Error>;
type ListenerUpgrade: Future<Item = Self::Output, Error = Self::Error>;
type Dial: Future<Item = Self::Output, Error = Self::Error>;
type ListenAddrsIter: Iterator<Item = Multiaddr>;
fn listen_on(self, addr: Multiaddr) -> Result<(Self::Listener, ListenAddrsIter), TransportError<Self::Error>>;
fn dial(self, addr: Multiaddr) -> Result<Self::Dial, TransportError<Self::Error>>;
}
enum ListenerStreamEvent<TListUpgr> {
Incoming(TListUpgr, Multiaddr),
NewAddress(Multiaddr),
AddressExpired(Multiaddr),
} In particular:
|
This is part of the proposed changes to the `Transport` trait as outlined in [1]. To allow transport implementations to listen on multiple addresses we now report all those addresses as a sequence of multi-addresses instead of supporting only a single one. Instead of making `Transport::listen_on` return a generic iterator a concrete type `MultiaddrSeq` is introduced to support non-emptiness. [1]: libp2p#794 (comment)
Now that #1052 is done, the next step, IMO, would be to add a struct that "manages" external addresses. Whenever a node reports our IP address to us, we notify this struct. The struct then manages them in some way to filter out expired and malicious reports. The |
I think this can be considered done. To help traversing NATs a lot more could be done obviously, but in regards to address handling I think we can close this issue. |
For paritytech/substrate#1193
cc #544
The following problems are unresolved:
nat_traversal()
be implemented byTransport
s, or maybe onMultiaddress
instead?The text was updated successfully, but these errors were encountered: