libp2p / libp2p/go-libp2p

Merge AutoNAT with the ObservedAddressManager

Open
#900 0 comments 2 reactions 1 assignee View on GitHub

@aarshkshah1992 is already working on this.

Since May 13, 2020.

kind/enhancement
Dominant language
Go
Stars
6.9k
Forks
1.3k
Avg merge
13d 21h
Merged PRs (30d)
1

Description

Currently:

1. We learn about potential addresses via identify. Once several peers tell us the same address, we treat it as "confirmed" and start advertising it.
2. Completely independently, we ask autonat services to confirm our external addresses and consider ourselves "reachable" when a peer tells us we're reachable.
3. Regardless of what AutoNAT tells us, we continue advertising these addresses.

Worse, the observed address manager has some nice logic for requiring observations from distinct observers (IP addresses). But AutoNAT doesn't use any of this this.

I believe the correct solution is to move all of the observed address manager logic into AutoNAT itself.

1. When a peer tells us about an observed address, identify emits an event saying "we learned about address X on connection Y".
2. When something like the NAT port mapping service creates a port mapping, it emits the same event. Unfortunately, NAT devices tend to lie so we should be confirming their results.
3. AutoNAT listens for "discovered address" events and tries to confirm them.
3. AutoNAT re-broadcasts these events, now markin
4. Now, instead of asking identify for our "public" addresses, we ask AutoNAT.

As part of this:

1. If AutoNAT sees a reported address on an inbound connection, it can trust it immediately and verify it in the background. If the observation was wrong, we can blacklist the source.
2. If AutoNAT sees several reports from outbound connections:
1. If we have no other public addresses, we should advertise these addresses immediately.
2. In the background, AutoNAT should try to confirm these addresses.
3. If we get a negative confirmation, we should stop advertising them.

```go
type EvtDiscoveredAddress struct {
// Discovered address.
Address ma.Multiaddr

// Connection from which the address was discovered. May be nil.
Connection network.Conn
// Confirmed is true if we've confirmed that the address appears to be reachable.
Confirmed bool
// Trusted means the address came from a trust-worthy source (e.g., NAT device, bootstrapper, etc.)
Trusted bool
}
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.