@libp2p/tcp 8.0.12 → 8.0.13-05b52d69c
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/dist/index.min.js +1 -5
- package/dist/src/index.d.ts +6 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +19 -17
- package/dist/src/index.js.map +1 -1
- package/dist/src/listener.d.ts +3 -0
- package/dist/src/listener.d.ts.map +1 -1
- package/dist/src/listener.js +29 -22
- package/dist/src/listener.js.map +1 -1
- package/dist/src/socket-to-conn.d.ts +2 -0
- package/dist/src/socket-to-conn.d.ts.map +1 -1
- package/dist/src/socket-to-conn.js +8 -3
- package/dist/src/socket-to-conn.js.map +1 -1
- package/package.json +9 -9
- package/src/index.ts +22 -19
- package/src/listener.ts +31 -23
- package/src/socket-to-conn.ts +11 -4
- package/dist/typedoc-urls.json +0 -16
package/src/socket-to-conn.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { CodeError } from '@libp2p/interface/errors'
|
|
2
|
-
import { logger } from '@libp2p/logger'
|
|
3
2
|
import { ipPortToMultiaddr as toMultiaddr } from '@libp2p/utils/ip-port-to-multiaddr'
|
|
4
3
|
// @ts-expect-error no types
|
|
5
4
|
import toIterable from 'stream-to-it'
|
|
6
5
|
import { CLOSE_TIMEOUT, SOCKET_TIMEOUT } from './constants.js'
|
|
7
6
|
import { multiaddrToNetConfig } from './utils.js'
|
|
7
|
+
import type { ComponentLogger } from '@libp2p/interface'
|
|
8
8
|
import type { MultiaddrConnection } from '@libp2p/interface/connection'
|
|
9
9
|
import type { CounterGroup } from '@libp2p/interface/metrics'
|
|
10
10
|
import type { AbortOptions, Multiaddr } from '@multiformats/multiaddr'
|
|
11
11
|
import type { Socket } from 'net'
|
|
12
12
|
|
|
13
|
-
const log = logger('libp2p:tcp:socket')
|
|
14
|
-
|
|
15
13
|
interface ToConnectionOptions {
|
|
16
14
|
listeningAddr?: Multiaddr
|
|
17
15
|
remoteAddr?: Multiaddr
|
|
@@ -20,6 +18,7 @@ interface ToConnectionOptions {
|
|
|
20
18
|
socketCloseTimeout?: number
|
|
21
19
|
metrics?: CounterGroup
|
|
22
20
|
metricPrefix?: string
|
|
21
|
+
logger: ComponentLogger
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
/**
|
|
@@ -27,6 +26,7 @@ interface ToConnectionOptions {
|
|
|
27
26
|
* https://github.com/libp2p/interface-transport#multiaddrconnection
|
|
28
27
|
*/
|
|
29
28
|
export const toMultiaddrConnection = (socket: Socket, options: ToConnectionOptions): MultiaddrConnection => {
|
|
29
|
+
const log = options.logger.forComponent('libp2p:tcp:socket')
|
|
30
30
|
const metrics = options.metrics
|
|
31
31
|
const metricPrefix = options.metricPrefix ?? ''
|
|
32
32
|
const inactivityTimeout = options.socketInactivityTimeout ?? SOCKET_TIMEOUT
|
|
@@ -126,7 +126,14 @@ export const toMultiaddrConnection = (socket: Socket, options: ToConnectionOptio
|
|
|
126
126
|
return
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
if (options.signal == null) {
|
|
130
|
+
const signal = AbortSignal.timeout(closeTimeout)
|
|
131
|
+
|
|
132
|
+
options = {
|
|
133
|
+
...options,
|
|
134
|
+
signal
|
|
135
|
+
}
|
|
136
|
+
}
|
|
130
137
|
|
|
131
138
|
try {
|
|
132
139
|
log('%s closing socket', lOptsStr)
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"TCPComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPComponents.html",
|
|
3
|
-
".:TCPComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPComponents.html",
|
|
4
|
-
"TCPCreateListenerOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPCreateListenerOptions.html",
|
|
5
|
-
".:TCPCreateListenerOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPCreateListenerOptions.html",
|
|
6
|
-
"TCPDialOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPDialOptions.html",
|
|
7
|
-
".:TCPDialOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPDialOptions.html",
|
|
8
|
-
"TCPMetrics": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPMetrics.html",
|
|
9
|
-
".:TCPMetrics": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPMetrics.html",
|
|
10
|
-
"TCPOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPOptions.html",
|
|
11
|
-
".:TCPOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPOptions.html",
|
|
12
|
-
"TCPSocketOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPSocketOptions.html",
|
|
13
|
-
".:TCPSocketOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_tcp.TCPSocketOptions.html",
|
|
14
|
-
"tcp": "https://libp2p.github.io/js-libp2p/functions/_libp2p_tcp.tcp.html",
|
|
15
|
-
".:tcp": "https://libp2p.github.io/js-libp2p/functions/_libp2p_tcp.tcp.html"
|
|
16
|
-
}
|