@libp2p/interface-internal 2.1.1 → 2.2.0-5c4a79e5a

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.
@@ -1,4 +1,53 @@
1
1
  import type { Multiaddr } from '@multiformats/multiaddr';
2
+ /**
3
+ * The type of address:
4
+ *
5
+ * - 'transport' a listen address supplied by a transport
6
+ * - 'announce' a pre-configured announce address
7
+ * - 'observed' a peer reported this as a public address
8
+ * - 'dns-mapping' a DNS address dynamically mapped to one or more public addresses
9
+ * - 'ip-mapping' an external IP address dynamically mapped to a LAN address
10
+ */
11
+ export type AddressType = 'transport' | 'announce' | 'observed' | 'dns-mapping' | 'ip-mapping';
12
+ /**
13
+ * An address that has been configured or detected
14
+ */
15
+ export interface NodeAddress {
16
+ /**
17
+ * The multiaddr that represents the address
18
+ */
19
+ multiaddr: Multiaddr;
20
+ /**
21
+ * Dynamically configured addresses such as observed or IP/DNS mapped ones
22
+ * must be verified as valid by AutoNAT or some other means before the current
23
+ * node will add them to it's peer record and share them with peers.
24
+ *
25
+ * When this value is true, it's safe to share the address.
26
+ */
27
+ verified: boolean;
28
+ /**
29
+ * The timestamp at which the address was last verified
30
+ */
31
+ lastVerified?: number;
32
+ /**
33
+ * A millisecond timestamp after which this address should be reverified
34
+ */
35
+ expires: number;
36
+ /**
37
+ * The source of this address
38
+ */
39
+ type: AddressType;
40
+ }
41
+ export interface ConfirmAddressOptions {
42
+ /**
43
+ * Override the TTL of the observed address verification
44
+ */
45
+ ttl?: number;
46
+ /**
47
+ * Allows hinting which type of address this is
48
+ */
49
+ type?: AddressType;
50
+ }
2
51
  export interface AddressManager {
3
52
  /**
4
53
  * Get peer listen multiaddrs
@@ -17,7 +66,7 @@ export interface AddressManager {
17
66
  * Signal that we have confidence an observed multiaddr is publicly dialable -
18
67
  * this will make it appear in the output of getAddresses()
19
68
  */
20
- confirmObservedAddr(addr: Multiaddr): void;
69
+ confirmObservedAddr(addr: Multiaddr, options?: ConfirmAddressOptions): void;
21
70
  /**
22
71
  * Signal that we do not have confidence an observed multiaddr is publicly dialable -
23
72
  * this will remove it from the output of getObservedAddrs()
@@ -33,6 +82,10 @@ export interface AddressManager {
33
82
  * Get the current node's addresses
34
83
  */
35
84
  getAddresses(): Multiaddr[];
85
+ /**
86
+ * Return all known addresses with metadata
87
+ */
88
+ getAddressesWithMetadata(): NodeAddress[];
36
89
  /**
37
90
  * Adds a mapping between one or more IP addresses and a domain name - when
38
91
  * `getAddresses` is invoked, where the IP addresses are present in a
@@ -44,5 +97,20 @@ export interface AddressManager {
44
97
  * Remove a mapping previously added with `addDNSMapping`.
45
98
  */
46
99
  removeDNSMapping(domain: string): void;
100
+ /**
101
+ * Add a publicly routable address/port/protocol tuple that this node is
102
+ * reachable on. Where this node listens on a link-local (e.g. LAN) address
103
+ * with the same protocol for any transport, an additional listen address will
104
+ * be added with the IP and port replaced with this IP and port.
105
+ *
106
+ * It's possible to add a IPv6 address here and have it added to the address
107
+ * list, this is for the case when a router has an external IPv6 address with
108
+ * port forwarding configured, but it does IPv6 -> IPv4 NAT.
109
+ */
110
+ addPublicAddressMapping(internalIp: string, internalPort: number, externalIp: string, externalPort?: number, protocol?: 'tcp' | 'udp'): void;
111
+ /**
112
+ * Remove a publicly routable address that this node is no longer reachable on
113
+ */
114
+ removePublicAddressMapping(internalIp: string, internalPort: number, externalIp: string, externalPort?: number, protocol?: 'tcp' | 'udp'): void;
47
115
  }
48
116
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/address-manager/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,cAAc,IAAI,SAAS,EAAE,CAAA;IAE7B;;OAEG;IACH,gBAAgB,IAAI,SAAS,EAAE,CAAA;IAE/B;;;OAGG;IACH,gBAAgB,IAAI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AGG;IACH,gBAAgB,IAAI,SAAS,EAAE,CAAA;IAE/B;;;OAGG;IACH,mBAAmB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAA;IAE3E;;;OAGG;IACH,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAA;IAEzC;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAAA;IAEtC;;OAEG;IACH,YAAY,IAAI,SAAS,EAAE,CAAA;IAE3B;;OAEG;IACH,wBAAwB,IAAI,WAAW,EAAE,CAAA;IAEzC;;;;;OAKG;IACH,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAE1D;;OAEG;IACH,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAEtC;;;;;;;;;OASG;IACH,uBAAuB,CAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,IAAI,CAAA;IAE7I;;OAEG;IACH,0BAA0B,CAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,IAAI,CAAA;CACjJ"}
@@ -41,6 +41,11 @@ export interface ConnectionManager {
41
41
  * ```
42
42
  */
43
43
  getConnectionsMap(): PeerMap<Connection[]>;
44
+ /**
45
+ * Returns the configured maximum number of connections this connection
46
+ * manager will accept
47
+ */
48
+ getMaxConnections(): number;
44
49
  /**
45
50
  * Open a connection to a remote peer
46
51
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/index.ts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AC,OAAO,CAAC,CAAA;IAEvE;;OAEG;IACH,mBAAmB,IAAI,IAAI,CAAA;IAE3B;;;;;;;;OAQG;IACH,YAAY,IAAI,WAAW,EAAE,CAAA;IAE7B;;;;;;;;OAQG;IACH,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;CAC9F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/interface-internal",
3
- "version": "2.1.1",
3
+ "version": "2.2.0-5c4a79e5a",
4
4
  "description": "Interfaces implemented by internal libp2p components",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface-internal#readme",
@@ -48,14 +48,14 @@
48
48
  "build": "aegir build"
49
49
  },
50
50
  "dependencies": {
51
- "@libp2p/interface": "^2.2.1",
52
- "@libp2p/peer-collections": "^6.0.12",
53
- "@multiformats/multiaddr": "^12.2.3",
54
- "progress-events": "^1.0.0",
51
+ "@libp2p/interface": "2.3.0-5c4a79e5a",
52
+ "@libp2p/peer-collections": "6.0.13-5c4a79e5a",
53
+ "@multiformats/multiaddr": "^12.3.3",
54
+ "progress-events": "^1.0.1",
55
55
  "uint8arraylist": "^2.4.8"
56
56
  },
57
57
  "devDependencies": {
58
- "aegir": "^44.0.1"
58
+ "aegir": "^45.0.5"
59
59
  },
60
60
  "sideEffects": false
61
61
  }
@@ -1,5 +1,62 @@
1
1
  import type { Multiaddr } from '@multiformats/multiaddr'
2
2
 
3
+ /**
4
+ * The type of address:
5
+ *
6
+ * - 'transport' a listen address supplied by a transport
7
+ * - 'announce' a pre-configured announce address
8
+ * - 'observed' a peer reported this as a public address
9
+ * - 'dns-mapping' a DNS address dynamically mapped to one or more public addresses
10
+ * - 'ip-mapping' an external IP address dynamically mapped to a LAN address
11
+ */
12
+ export type AddressType = 'transport' | 'announce' | 'observed' | 'dns-mapping' | 'ip-mapping'
13
+
14
+ /**
15
+ * An address that has been configured or detected
16
+ */
17
+ export interface NodeAddress {
18
+ /**
19
+ * The multiaddr that represents the address
20
+ */
21
+ multiaddr: Multiaddr
22
+
23
+ /**
24
+ * Dynamically configured addresses such as observed or IP/DNS mapped ones
25
+ * must be verified as valid by AutoNAT or some other means before the current
26
+ * node will add them to it's peer record and share them with peers.
27
+ *
28
+ * When this value is true, it's safe to share the address.
29
+ */
30
+ verified: boolean
31
+
32
+ /**
33
+ * The timestamp at which the address was last verified
34
+ */
35
+ lastVerified?: number
36
+
37
+ /**
38
+ * A millisecond timestamp after which this address should be reverified
39
+ */
40
+ expires: number
41
+
42
+ /**
43
+ * The source of this address
44
+ */
45
+ type: AddressType
46
+ }
47
+
48
+ export interface ConfirmAddressOptions {
49
+ /**
50
+ * Override the TTL of the observed address verification
51
+ */
52
+ ttl?: number
53
+
54
+ /**
55
+ * Allows hinting which type of address this is
56
+ */
57
+ type?: AddressType
58
+ }
59
+
3
60
  export interface AddressManager {
4
61
  /**
5
62
  * Get peer listen multiaddrs
@@ -21,7 +78,7 @@ export interface AddressManager {
21
78
  * Signal that we have confidence an observed multiaddr is publicly dialable -
22
79
  * this will make it appear in the output of getAddresses()
23
80
  */
24
- confirmObservedAddr(addr: Multiaddr): void
81
+ confirmObservedAddr(addr: Multiaddr, options?: ConfirmAddressOptions): void
25
82
 
26
83
  /**
27
84
  * Signal that we do not have confidence an observed multiaddr is publicly dialable -
@@ -41,6 +98,11 @@ export interface AddressManager {
41
98
  */
42
99
  getAddresses(): Multiaddr[]
43
100
 
101
+ /**
102
+ * Return all known addresses with metadata
103
+ */
104
+ getAddressesWithMetadata(): NodeAddress[]
105
+
44
106
  /**
45
107
  * Adds a mapping between one or more IP addresses and a domain name - when
46
108
  * `getAddresses` is invoked, where the IP addresses are present in a
@@ -53,4 +115,21 @@ export interface AddressManager {
53
115
  * Remove a mapping previously added with `addDNSMapping`.
54
116
  */
55
117
  removeDNSMapping(domain: string): void
118
+
119
+ /**
120
+ * Add a publicly routable address/port/protocol tuple that this node is
121
+ * reachable on. Where this node listens on a link-local (e.g. LAN) address
122
+ * with the same protocol for any transport, an additional listen address will
123
+ * be added with the IP and port replaced with this IP and port.
124
+ *
125
+ * It's possible to add a IPv6 address here and have it added to the address
126
+ * list, this is for the case when a router has an external IPv6 address with
127
+ * port forwarding configured, but it does IPv6 -> IPv4 NAT.
128
+ */
129
+ addPublicAddressMapping (internalIp: string, internalPort: number, externalIp: string, externalPort?: number, protocol?: 'tcp' | 'udp'): void
130
+
131
+ /**
132
+ * Remove a publicly routable address that this node is no longer reachable on
133
+ */
134
+ removePublicAddressMapping (internalIp: string, internalPort: number, externalIp: string, externalPort?: number, protocol?: 'tcp' | 'udp'): void
56
135
  }
@@ -46,6 +46,12 @@ export interface ConnectionManager {
46
46
  */
47
47
  getConnectionsMap(): PeerMap<Connection[]>
48
48
 
49
+ /**
50
+ * Returns the configured maximum number of connections this connection
51
+ * manager will accept
52
+ */
53
+ getMaxConnections(): number
54
+
49
55
  /**
50
56
  * Open a connection to a remote peer
51
57
  *
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
@@ -1,15 +0,0 @@
1
- {
2
- "AddressManager": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.AddressManager.html",
3
- "ConnectionManager": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.ConnectionManager.html",
4
- "Envelope": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.Envelope.html",
5
- "IncomingStreamData": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.IncomingStreamData.html",
6
- "OpenConnectionOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.OpenConnectionOptions.html",
7
- "RandomWalk": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.RandomWalk.html",
8
- "Record": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.Record.html",
9
- "Registrar": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.Registrar.html",
10
- "StreamHandler": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.StreamHandler.html",
11
- "StreamHandlerOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.StreamHandlerOptions.html",
12
- "StreamHandlerRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.StreamHandlerRecord.html",
13
- "TransportManager": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.TransportManager.html",
14
- "TransportManagerDialOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface_internal.TransportManagerDialOptions.html"
15
- }