@libp2p/autonat 2.0.12 → 2.0.13
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 +1 -1
- package/dist/index.min.js +1 -1
- package/dist/src/autonat.d.ts +34 -7
- package/dist/src/autonat.d.ts.map +1 -1
- package/dist/src/autonat.js +389 -228
- package/dist/src/autonat.js.map +1 -1
- package/dist/src/constants.d.ts +1 -2
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +1 -2
- package/dist/src/constants.js.map +1 -1
- package/dist/src/index.d.ts +13 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/package.json +20 -18
- package/src/autonat.ts +489 -253
- package/src/constants.ts +1 -2
- package/src/index.ts +14 -1
- package/LICENSE +0 -4
package/src/constants.ts
CHANGED
|
@@ -13,7 +13,6 @@ export const PROTOCOL_NAME = 'autonat'
|
|
|
13
13
|
*/
|
|
14
14
|
export const PROTOCOL_VERSION = '1.0.0'
|
|
15
15
|
export const TIMEOUT = 30000
|
|
16
|
-
export const STARTUP_DELAY = 5000
|
|
17
|
-
export const REFRESH_INTERVAL = 60000
|
|
18
16
|
export const MAX_INBOUND_STREAMS = 1
|
|
19
17
|
export const MAX_OUTBOUND_STREAMS = 1
|
|
18
|
+
export const DEFAULT_CONNECTION_THRESHOLD = 80
|
package/src/index.ts
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
import { AutoNATService } from './autonat.js'
|
|
34
|
-
import type { ComponentLogger, PeerId } from '@libp2p/interface'
|
|
34
|
+
import type { ComponentLogger, Libp2pEvents, PeerId, PeerStore, TypedEventTarget } from '@libp2p/interface'
|
|
35
35
|
import type { AddressManager, ConnectionManager, RandomWalk, Registrar, TransportManager } from '@libp2p/interface-internal'
|
|
36
36
|
|
|
37
37
|
export interface AutoNATServiceInit {
|
|
@@ -64,6 +64,17 @@ export interface AutoNATServiceInit {
|
|
|
64
64
|
* How many parallel outbound autoNAT streams we allow per-connection
|
|
65
65
|
*/
|
|
66
66
|
maxOutboundStreams?: number
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* If the number of currently open connections is higher than this value as
|
|
70
|
+
* a percentage of the maximum number of allowed connections, automatically
|
|
71
|
+
* reverify previously verified addresses since auto nat peers may find it
|
|
72
|
+
* hard to dial and will report that the address is not dialable leading this
|
|
73
|
+
* node to delist it.
|
|
74
|
+
*
|
|
75
|
+
* @default 80
|
|
76
|
+
*/
|
|
77
|
+
connectionThreshold?: number
|
|
67
78
|
}
|
|
68
79
|
|
|
69
80
|
export interface AutoNATComponents {
|
|
@@ -74,6 +85,8 @@ export interface AutoNATComponents {
|
|
|
74
85
|
connectionManager: ConnectionManager
|
|
75
86
|
logger: ComponentLogger
|
|
76
87
|
randomWalk: RandomWalk
|
|
88
|
+
events: TypedEventTarget<Libp2pEvents>
|
|
89
|
+
peerStore: PeerStore
|
|
77
90
|
}
|
|
78
91
|
|
|
79
92
|
export function autoNAT (init: AutoNATServiceInit = {}): (components: AutoNATComponents) => unknown {
|
package/LICENSE
DELETED