@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/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
@@ -1,4 +0,0 @@
1
- This project is dual licensed under MIT and Apache-2.0.
2
-
3
- MIT: https://www.opensource.org/licenses/mit
4
- Apache-2.0: https://www.apache.org/licenses/license-2.0