@libp2p/autonat-v2 0.0.0-2d6079bc1 → 0.0.0-d2dc12c7d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -7
- package/dist/index.min.js.map +2 -2
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# @libp2p/autonat
|
|
2
|
+
|
|
1
3
|
# @libp2p/autonat-v2
|
|
2
4
|
|
|
3
5
|
[](http://libp2p.io/)
|
|
@@ -5,7 +7,7 @@
|
|
|
5
7
|
[](https://codecov.io/gh/libp2p/js-libp2p)
|
|
6
8
|
[](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amain)
|
|
7
9
|
|
|
8
|
-
> Implementation of the
|
|
10
|
+
> Implementation of the Autonat Protocol v2
|
|
9
11
|
|
|
10
12
|
# About
|
|
11
13
|
|
|
@@ -24,22 +26,31 @@ repo and examine the changes made.
|
|
|
24
26
|
|
|
25
27
|
-->
|
|
26
28
|
|
|
27
|
-
The
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
The AutoNAT service uses the [AutoNAT protocol](https://docs.libp2p.io/concepts/nat/autonat/).
|
|
30
|
+
The service confirms addresses are dialable by remote peers, and updates the list it advertises.
|
|
31
|
+
|
|
32
|
+
The service dials randomly selected peers with a request to verify it's external addresses.
|
|
33
|
+
The request includes a list of public multiaddrs (addressManager.getObservedAddrs()).
|
|
34
|
+
The remote peers dial that list and respond with the results.
|
|
35
|
+
|
|
36
|
+
The AutoNAT service uses those responses to either:
|
|
37
|
+
|
|
38
|
+
- addressManager.confirmObservedAddr(addr)
|
|
39
|
+
- addressManager.removeObservedAddr(addr)
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
The result list of candidates and confirmed addresses can be found
|
|
42
|
+
at addressManager.getObservedAddrs()
|
|
32
43
|
|
|
33
44
|
## Example
|
|
34
45
|
|
|
35
46
|
```typescript
|
|
36
47
|
import { createLibp2p } from 'libp2p'
|
|
37
|
-
import {
|
|
48
|
+
import { autoNAT } from '@libp2p/autonat'
|
|
38
49
|
|
|
39
50
|
const node = await createLibp2p({
|
|
40
51
|
// ...other options
|
|
41
52
|
services: {
|
|
42
|
-
autoNAT:
|
|
53
|
+
autoNAT: autoNAT()
|
|
43
54
|
}
|
|
44
55
|
})
|
|
45
56
|
```
|