Skip to content

Commit

Permalink
docs(autonat): Add documentation on where to get results of service (#…
Browse files Browse the repository at this point in the history
…2451)

Document AutoNAT service - how it works and where results can be found.

---------

Co-authored-by: Michael Cole <gitlab@michaelcole.com>
  • Loading branch information
MichaelJCole and Michael Cole authored Mar 28, 2024
1 parent a19a261 commit 82901e7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
16 changes: 14 additions & 2 deletions packages/protocol-autonat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,20 @@ repo and examine the changes made.
-->

Use the `autoNATService` function to add support for the [AutoNAT protocol](https://docs.libp2p.io/concepts/nat/autonat/)
to libp2p.
The AutoNAT service uses the [AutoNAT protocol](https://docs.libp2p.io/concepts/nat/autonat/).
The service confirms addresses are dialable by remote peers, and updates the list it advertises.

The service dials randomly selected peers with a request to verify it's external addresses.
The request includes a list of public multiaddrs (addressManager.getObservedAddrs()).
The remote peers dial that list and respond with the results.

The AutoNAT service uses those responses to either:

- addressManager.confirmObservedAddr(addr)
- addressManager.removeObservedAddr(addr)

The result list of candidates and confirmed addresses can be found
at addressManager.getObservedAddrs()

## Example

Expand Down
15 changes: 13 additions & 2 deletions packages/protocol-autonat/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
/**
* @packageDocumentation
*
* Use the `autoNATService` function to add support for the [AutoNAT protocol](https://docs.libp2p.io/concepts/nat/autonat/)
* to libp2p.
* The AutoNAT service uses the [AutoNAT protocol](https://docs.libp2p.io/concepts/nat/autonat/).
* The service confirms addresses are dialable by remote peers, and updates the list it advertises.
*
* The service dials randomly selected peers with a request to verify it's external addresses.
* The request includes a list of public multiaddrs (addressManager.getObservedAddrs()).
* The remote peers dial that list and respond with the results.
*
* The AutoNAT service uses those responses to either:
* - addressManager.confirmObservedAddr(addr)
* - addressManager.removeObservedAddr(addr)
*
* The result list of candidates and confirmed addresses can be found
* at addressManager.getObservedAddrs()
*
* @example
*
Expand Down

0 comments on commit 82901e7

Please # to comment.