libp2p 0.45.9-d2f1eff4 → 0.45.9-daeb43d8
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 +96 -77
- package/dist/index.min.js +28 -28
- package/dist/src/address-manager/index.d.ts +5 -5
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/autonat/index.d.ts +6 -6
- package/dist/src/autonat/index.d.ts.map +1 -1
- package/dist/src/autonat/index.js +3 -3
- package/dist/src/circuit-relay/index.d.ts +1 -1
- package/dist/src/circuit-relay/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.d.ts +3 -3
- package/dist/src/circuit-relay/server/advert-service.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/advert-service.js +1 -1
- package/dist/src/circuit-relay/server/advert-service.js.map +1 -1
- package/dist/src/circuit-relay/server/index.d.ts +7 -7
- package/dist/src/circuit-relay/server/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/index.js +9 -9
- package/dist/src/circuit-relay/server/index.js.map +1 -1
- package/dist/src/circuit-relay/server/reservation-store.d.ts +3 -3
- package/dist/src/circuit-relay/server/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/server/reservation-voucher.d.ts +2 -2
- package/dist/src/circuit-relay/transport/discovery.d.ts +8 -8
- package/dist/src/circuit-relay/transport/discovery.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/discovery.js +3 -4
- package/dist/src/circuit-relay/transport/discovery.js.map +1 -1
- package/dist/src/circuit-relay/transport/index.d.ts +10 -10
- package/dist/src/circuit-relay/transport/index.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/index.js +7 -7
- package/dist/src/circuit-relay/transport/index.js.map +1 -1
- package/dist/src/circuit-relay/transport/listener.d.ts +2 -2
- package/dist/src/circuit-relay/transport/listener.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/listener.js +3 -3
- package/dist/src/circuit-relay/transport/listener.js.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.d.ts +7 -7
- package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +1 -1
- package/dist/src/circuit-relay/transport/reservation-store.js +2 -2
- package/dist/src/circuit-relay/transport/reservation-store.js.map +1 -1
- package/dist/src/circuit-relay/utils.d.ts +1 -1
- package/dist/src/components.d.ts +15 -14
- package/dist/src/components.d.ts.map +1 -1
- package/dist/src/components.js +2 -2
- package/dist/src/components.js.map +1 -1
- package/dist/src/config/connection-gater.browser.d.ts +1 -1
- package/dist/src/config/connection-gater.d.ts +1 -1
- package/dist/src/config.d.ts +1 -2
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +2 -2
- package/dist/src/config.js.map +1 -1
- package/dist/src/connection/index.d.ts +4 -4
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js +3 -3
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/connection-manager/auto-dial.d.ts +5 -5
- package/dist/src/connection-manager/auto-dial.d.ts.map +1 -1
- package/dist/src/connection-manager/connection-pruner.d.ts +4 -4
- package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.d.ts +7 -8
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +6 -6
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/connection-manager/index.d.ts +10 -11
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +6 -6
- package/dist/src/connection-manager/index.js.map +1 -1
- package/dist/src/content-routing/index.d.ts +5 -5
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +1 -1
- package/dist/src/content-routing/index.js.map +1 -1
- package/dist/src/content-routing/utils.d.ts +2 -2
- package/dist/src/content-routing/utils.js +1 -1
- package/dist/src/content-routing/utils.js.map +1 -1
- package/dist/src/fetch/index.d.ts +5 -5
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +1 -1
- package/dist/src/fetch/index.js.map +1 -1
- package/dist/src/get-peer.d.ts +1 -1
- package/dist/src/get-peer.js +2 -2
- package/dist/src/get-peer.js.map +1 -1
- package/dist/src/identify/identify.d.ts +4 -4
- package/dist/src/identify/identify.d.ts.map +1 -1
- package/dist/src/identify/identify.js +3 -3
- package/dist/src/identify/identify.js.map +1 -1
- package/dist/src/identify/index.d.ts +7 -7
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/index.d.ts +11 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/insecure/index.d.ts +1 -1
- package/dist/src/insecure/index.js +1 -1
- package/dist/src/insecure/index.js.map +1 -1
- package/dist/src/libp2p.d.ts +11 -11
- package/dist/src/libp2p.d.ts.map +1 -1
- package/dist/src/libp2p.js +5 -5
- package/dist/src/libp2p.js.map +1 -1
- package/dist/src/peer-routing.d.ts +5 -5
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +1 -1
- package/dist/src/peer-routing.js.map +1 -1
- package/dist/src/ping/index.d.ts +4 -4
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +1 -1
- package/dist/src/ping/index.js.map +1 -1
- package/dist/src/pnet/index.d.ts +1 -1
- package/dist/src/pnet/index.js +1 -1
- package/dist/src/pnet/index.js.map +1 -1
- package/dist/src/registrar.d.ts +7 -6
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +7 -11
- package/dist/src/registrar.js.map +1 -1
- package/dist/src/transport-manager.d.ts +9 -9
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +4 -4
- package/dist/src/transport-manager.js.map +1 -1
- package/dist/src/upgrader.d.ts +12 -12
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +1 -1
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/upnp-nat/index.d.ts +4 -4
- package/dist/src/upnp-nat/index.d.ts.map +1 -1
- package/dist/src/upnp-nat/index.js +1 -1
- package/dist/src/upnp-nat/index.js.map +1 -1
- package/dist/src/utils/peer-job-queue.d.ts +1 -1
- package/dist/src/utils/peer-job-queue.js +1 -1
- package/dist/src/utils/peer-job-queue.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/package.json +39 -64
- package/src/address-manager/index.ts +5 -5
- package/src/autonat/index.ts +12 -12
- package/src/circuit-relay/index.ts +1 -1
- package/src/circuit-relay/server/advert-service.ts +3 -3
- package/src/circuit-relay/server/index.ts +17 -17
- package/src/circuit-relay/server/reservation-store.ts +3 -3
- package/src/circuit-relay/server/reservation-voucher.ts +2 -2
- package/src/circuit-relay/transport/discovery.ts +10 -11
- package/src/circuit-relay/transport/index.ts +17 -18
- package/src/circuit-relay/transport/listener.ts +7 -7
- package/src/circuit-relay/transport/reservation-store.ts +9 -9
- package/src/circuit-relay/utils.ts +1 -1
- package/src/components.ts +16 -15
- package/src/config/connection-gater.browser.ts +1 -1
- package/src/config/connection-gater.ts +1 -1
- package/src/config.ts +3 -4
- package/src/connection/index.ts +6 -6
- package/src/connection-manager/auto-dial.ts +5 -5
- package/src/connection-manager/connection-pruner.ts +4 -4
- package/src/connection-manager/dial-queue.ts +13 -14
- package/src/connection-manager/index.ts +16 -17
- package/src/content-routing/index.ts +6 -6
- package/src/content-routing/utils.ts +3 -3
- package/src/fetch/index.ts +7 -7
- package/src/get-peer.ts +3 -3
- package/src/identify/identify.ts +12 -13
- package/src/identify/index.ts +7 -7
- package/src/index.ts +11 -12
- package/src/insecure/index.ts +3 -3
- package/src/libp2p.ts +14 -14
- package/src/peer-routing.ts +6 -6
- package/src/ping/index.ts +7 -7
- package/src/pnet/index.ts +2 -2
- package/src/registrar.ts +14 -17
- package/src/transport-manager.ts +12 -12
- package/src/upgrader.ts +13 -14
- package/src/upnp-nat/index.ts +5 -5
- package/src/utils/peer-job-queue.ts +2 -2
- package/src/version.ts +1 -1
- package/dist/src/pubsub/dummy-pubsub.d.ts +0 -18
- package/dist/src/pubsub/dummy-pubsub.d.ts.map +0 -1
- package/dist/src/pubsub/dummy-pubsub.js +0 -38
- package/dist/src/pubsub/dummy-pubsub.js.map +0 -1
- package/src/pubsub/dummy-pubsub.ts +0 -53
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventEmitter } from '@libp2p/
|
|
1
|
+
import { EventEmitter } from '@libp2p/interface/events'
|
|
2
2
|
import { logger } from '@libp2p/logger'
|
|
3
3
|
import { PeerMap } from '@libp2p/peer-collections'
|
|
4
4
|
import { multiaddr } from '@multiformats/multiaddr'
|
|
@@ -8,13 +8,13 @@ import { DEFAULT_RESERVATION_CONCURRENCY, RELAY_TAG, RELAY_V2_HOP_CODEC } from '
|
|
|
8
8
|
import { HopMessage, Status } from '../pb/index.js'
|
|
9
9
|
import { getExpirationMilliseconds } from '../utils.js'
|
|
10
10
|
import type { Reservation } from '../pb/index.js'
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import type {
|
|
11
|
+
import type { Libp2pEvents } from '@libp2p/interface'
|
|
12
|
+
import type { Connection } from '@libp2p/interface/connection'
|
|
13
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
14
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
15
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
16
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
17
|
+
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
18
18
|
|
|
19
19
|
const log = logger('libp2p:circuit-relay:transport:reservation-store')
|
|
20
20
|
|
|
@@ -237,7 +237,7 @@ export class ReservationStore extends EventEmitter<ReservationStoreEvents> imple
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
async #createReservation (connection: Connection): Promise<Reservation> {
|
|
240
|
-
log('requesting reservation from %
|
|
240
|
+
log('requesting reservation from %p', connection.remotePeer)
|
|
241
241
|
const stream = await connection.newStream(RELAY_V2_HOP_CODEC)
|
|
242
242
|
const pbstr = pbStream(stream)
|
|
243
243
|
const hopstr = pbstr.pb(HopMessage)
|
|
@@ -5,7 +5,7 @@ import { CID } from 'multiformats/cid'
|
|
|
5
5
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
6
6
|
import { DEFAULT_DATA_LIMIT, DEFAULT_DURATION_LIMIT } from './constants.js'
|
|
7
7
|
import type { Limit } from './pb/index.js'
|
|
8
|
-
import type { Stream } from '@libp2p/interface
|
|
8
|
+
import type { Stream } from '@libp2p/interface/connection'
|
|
9
9
|
import type { Source } from 'it-stream-types'
|
|
10
10
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
11
11
|
|
package/src/components.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/
|
|
2
|
-
import { isStartable, type Startable } from '@libp2p/
|
|
3
|
-
import type {
|
|
4
|
-
import type { ConnectionProtector } from '@libp2p/interface
|
|
5
|
-
import type { ConnectionGater } from '@libp2p/interface
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
|
+
import { isStartable, type Startable } from '@libp2p/interface/startable'
|
|
3
|
+
import type { Libp2pEvents } from '@libp2p/interface'
|
|
4
|
+
import type { ConnectionProtector } from '@libp2p/interface/connection'
|
|
5
|
+
import type { ConnectionGater } from '@libp2p/interface/connection-gater'
|
|
6
|
+
import type { ContentRouting } from '@libp2p/interface/content-routing'
|
|
7
|
+
import type { EventEmitter } from '@libp2p/interface/events'
|
|
8
|
+
import type { Metrics } from '@libp2p/interface/metrics'
|
|
9
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
10
|
+
import type { PeerRouting } from '@libp2p/interface/peer-routing'
|
|
11
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
12
|
+
import type { Upgrader } from '@libp2p/interface/transport'
|
|
13
|
+
import type { AddressManager } from '@libp2p/interface-internal/address-manager'
|
|
14
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
15
|
+
import type { Registrar } from '@libp2p/interface-internal/registrar'
|
|
16
|
+
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
16
17
|
import type { Datastore } from 'interface-datastore'
|
|
17
18
|
|
|
18
19
|
export interface Components extends Record<string, any>, Startable {
|
package/src/config.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
|
+
import { FaultTolerance } from '@libp2p/interface/transport'
|
|
3
3
|
import { publicAddressesFirst } from '@libp2p/utils/address-sort'
|
|
4
4
|
import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers'
|
|
5
5
|
import mergeOptions from 'merge-options'
|
|
6
6
|
import { codes, messages } from './errors.js'
|
|
7
7
|
import type { Libp2pInit } from './index.js'
|
|
8
|
-
import type { ServiceMap } from '@libp2p/interface
|
|
9
|
-
import type { RecursivePartial } from '@libp2p/interfaces'
|
|
8
|
+
import type { ServiceMap, RecursivePartial } from '@libp2p/interface'
|
|
10
9
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
11
10
|
|
|
12
11
|
const DefaultConfig: Partial<Libp2pInit> = {
|
package/src/connection/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { symbol } from '@libp2p/interface
|
|
2
|
-
import { OPEN, CLOSING, CLOSED } from '@libp2p/interface
|
|
3
|
-
import { CodeError } from '@libp2p/
|
|
1
|
+
import { symbol } from '@libp2p/interface/connection'
|
|
2
|
+
import { OPEN, CLOSING, CLOSED } from '@libp2p/interface/connection/status'
|
|
3
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
4
4
|
import { logger } from '@libp2p/logger'
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
5
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
6
|
+
import type { Connection, ConnectionStat, Stream } from '@libp2p/interface/connection'
|
|
7
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
8
8
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
9
9
|
|
|
10
10
|
const log = logger('libp2p:connection')
|
|
@@ -2,11 +2,11 @@ import { logger } from '@libp2p/logger'
|
|
|
2
2
|
import { PeerMap, PeerSet } from '@libp2p/peer-collections'
|
|
3
3
|
import { PeerJobQueue } from '../utils/peer-job-queue.js'
|
|
4
4
|
import { AUTO_DIAL_CONCURRENCY, AUTO_DIAL_INTERVAL, AUTO_DIAL_MAX_QUEUE_LENGTH, AUTO_DIAL_PRIORITY, MIN_CONNECTIONS } from './constants.js'
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type { PeerStore } from '@libp2p/interface
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
5
|
+
import type { Libp2pEvents } from '@libp2p/interface'
|
|
6
|
+
import type { EventEmitter } from '@libp2p/interface/events'
|
|
7
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
8
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
9
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
10
10
|
|
|
11
11
|
const log = logger('libp2p:connection-manager:auto-dial')
|
|
12
12
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { logger } from '@libp2p/logger'
|
|
2
2
|
import { PeerMap } from '@libp2p/peer-collections'
|
|
3
3
|
import { MAX_CONNECTIONS } from './constants.js'
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type { PeerStore } from '@libp2p/interface
|
|
7
|
-
import type {
|
|
4
|
+
import type { Libp2pEvents } from '@libp2p/interface'
|
|
5
|
+
import type { EventEmitter } from '@libp2p/interface/events'
|
|
6
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
7
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
8
8
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
9
9
|
|
|
10
10
|
const log = logger('libp2p:connection-manager:connection-pruner')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setMaxListeners } from 'events'
|
|
2
|
-
import { AbortError, CodeError } from '@libp2p/
|
|
2
|
+
import { AbortError, CodeError } from '@libp2p/interface/errors'
|
|
3
3
|
import { logger } from '@libp2p/logger'
|
|
4
4
|
import { publicAddressesFirst } from '@libp2p/utils/address-sort'
|
|
5
5
|
import { type Multiaddr, type Resolver, resolvers } from '@multiformats/multiaddr'
|
|
@@ -16,14 +16,13 @@ import {
|
|
|
16
16
|
MAX_PEER_ADDRS_TO_DIAL
|
|
17
17
|
} from './constants.js'
|
|
18
18
|
import { combineSignals, resolveMultiaddrs } from './utils.js'
|
|
19
|
-
import type {
|
|
20
|
-
import type {
|
|
21
|
-
import type {
|
|
22
|
-
import type { Metric, Metrics } from '@libp2p/interface
|
|
23
|
-
import type { PeerId } from '@libp2p/interface
|
|
24
|
-
import type { Address, PeerStore } from '@libp2p/interface
|
|
25
|
-
import type { TransportManager } from '@libp2p/interface-transport'
|
|
26
|
-
import type { AbortOptions } from '@libp2p/interfaces'
|
|
19
|
+
import type { AddressSorter, AbortOptions } from '@libp2p/interface'
|
|
20
|
+
import type { Connection } from '@libp2p/interface/connection'
|
|
21
|
+
import type { ConnectionGater } from '@libp2p/interface/connection-gater'
|
|
22
|
+
import type { Metric, Metrics } from '@libp2p/interface/metrics'
|
|
23
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
24
|
+
import type { Address, PeerStore } from '@libp2p/interface/peer-store'
|
|
25
|
+
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
27
26
|
|
|
28
27
|
const log = logger('libp2p:connection-manager:dial-queue')
|
|
29
28
|
|
|
@@ -419,13 +418,13 @@ export class DialQueue {
|
|
|
419
418
|
// let any signal abort the dial
|
|
420
419
|
const signal = combineSignals(controller.signal, options.signal)
|
|
421
420
|
signal.addEventListener('abort', () => {
|
|
422
|
-
log('dial to %
|
|
421
|
+
log('dial to %a aborted', addr)
|
|
423
422
|
})
|
|
424
423
|
const deferred = pDefer<Connection>()
|
|
425
424
|
|
|
426
425
|
await peerDialQueue.add(async () => {
|
|
427
426
|
if (signal.aborted) {
|
|
428
|
-
log('dial to %
|
|
427
|
+
log('dial to %a was aborted before reaching the head of the peer dial queue', addr)
|
|
429
428
|
deferred.reject(new AbortError())
|
|
430
429
|
return
|
|
431
430
|
}
|
|
@@ -434,7 +433,7 @@ export class DialQueue {
|
|
|
434
433
|
await this.queue.add(async () => {
|
|
435
434
|
try {
|
|
436
435
|
if (signal.aborted) {
|
|
437
|
-
log('dial to %
|
|
436
|
+
log('dial to %a was aborted before reaching the head of the dial queue', addr)
|
|
438
437
|
deferred.reject(new AbortError())
|
|
439
438
|
return
|
|
440
439
|
}
|
|
@@ -469,13 +468,13 @@ export class DialQueue {
|
|
|
469
468
|
}
|
|
470
469
|
})
|
|
471
470
|
|
|
472
|
-
log('dial to %
|
|
471
|
+
log('dial to %a succeeded', addr)
|
|
473
472
|
|
|
474
473
|
// resolve the connection promise
|
|
475
474
|
deferred.resolve(conn)
|
|
476
475
|
} catch (err: any) {
|
|
477
476
|
// something only went wrong if our signal was not aborted
|
|
478
|
-
log.error('error during dial of %
|
|
477
|
+
log.error('error during dial of %a', addr, err)
|
|
479
478
|
deferred.reject(err)
|
|
480
479
|
}
|
|
481
480
|
}, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
|
+
import { KEEP_ALIVE } from '@libp2p/interface/peer-store/tags'
|
|
3
3
|
import { logger } from '@libp2p/logger'
|
|
4
4
|
import { PeerMap } from '@libp2p/peer-collections'
|
|
5
5
|
import { publicAddressesFirst } from '@libp2p/utils/address-sort'
|
|
@@ -12,17 +12,16 @@ import { AutoDial } from './auto-dial.js'
|
|
|
12
12
|
import { ConnectionPruner } from './connection-pruner.js'
|
|
13
13
|
import { AUTO_DIAL_CONCURRENCY, AUTO_DIAL_MAX_QUEUE_LENGTH, AUTO_DIAL_PRIORITY, DIAL_TIMEOUT, INBOUND_CONNECTION_THRESHOLD, MAX_CONNECTIONS, MAX_INCOMING_PENDING_CONNECTIONS, MAX_PARALLEL_DIALS, MAX_PEER_ADDRS_TO_DIAL, MIN_CONNECTIONS } from './constants.js'
|
|
14
14
|
import { DialQueue } from './dial-queue.js'
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import type {
|
|
18
|
-
import type {
|
|
19
|
-
import type { Metrics } from '@libp2p/interface
|
|
20
|
-
import type { PeerId } from '@libp2p/interface
|
|
21
|
-
import type { Peer, PeerStore } from '@libp2p/interface
|
|
22
|
-
import type {
|
|
23
|
-
import type {
|
|
24
|
-
import type {
|
|
25
|
-
import type { Startable } from '@libp2p/interfaces/startable'
|
|
15
|
+
import type { PendingDial, AddressSorter, Libp2pEvents, AbortOptions } from '@libp2p/interface'
|
|
16
|
+
import type { Connection, MultiaddrConnection } from '@libp2p/interface/connection'
|
|
17
|
+
import type { ConnectionGater } from '@libp2p/interface/connection-gater'
|
|
18
|
+
import type { EventEmitter } from '@libp2p/interface/events'
|
|
19
|
+
import type { Metrics } from '@libp2p/interface/metrics'
|
|
20
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
21
|
+
import type { Peer, PeerStore } from '@libp2p/interface/peer-store'
|
|
22
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
23
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
24
|
+
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
26
25
|
|
|
27
26
|
const log = logger('libp2p:connection-manager')
|
|
28
27
|
|
|
@@ -548,7 +547,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
|
|
|
548
547
|
})
|
|
549
548
|
|
|
550
549
|
if (denyConnection) {
|
|
551
|
-
log('connection from %
|
|
550
|
+
log('connection from %a refused - connection remote address was in deny list', maConn.remoteAddr)
|
|
552
551
|
return false
|
|
553
552
|
}
|
|
554
553
|
|
|
@@ -565,7 +564,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
|
|
|
565
564
|
|
|
566
565
|
// check pending connections
|
|
567
566
|
if (this.incomingPendingConnections === this.maxIncomingPendingConnections) {
|
|
568
|
-
log('connection from %
|
|
567
|
+
log('connection from %a refused - incomingPendingConnections exceeded by host', maConn.remoteAddr)
|
|
569
568
|
return false
|
|
570
569
|
}
|
|
571
570
|
|
|
@@ -575,7 +574,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
|
|
|
575
574
|
try {
|
|
576
575
|
await this.inboundConnectionRateLimiter.consume(host, 1)
|
|
577
576
|
} catch {
|
|
578
|
-
log('connection from %
|
|
577
|
+
log('connection from %a refused - inboundConnectionThreshold exceeded by host %s', maConn.remoteAddr, host)
|
|
579
578
|
return false
|
|
580
579
|
}
|
|
581
580
|
}
|
|
@@ -586,7 +585,7 @@ export class DefaultConnectionManager implements ConnectionManager, Startable {
|
|
|
586
585
|
return true
|
|
587
586
|
}
|
|
588
587
|
|
|
589
|
-
log('connection from %
|
|
588
|
+
log('connection from %a refused - maxConnections exceeded', maConn.remoteAddr)
|
|
590
589
|
return false
|
|
591
590
|
}
|
|
592
591
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
2
|
import merge from 'it-merge'
|
|
3
3
|
import { pipe } from 'it-pipe'
|
|
4
4
|
import { messages, codes } from '../errors.js'
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
uniquePeers,
|
|
8
8
|
requirePeers
|
|
9
9
|
} from './utils.js'
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type { Startable } from '@libp2p/
|
|
10
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
11
|
+
import type { ContentRouting } from '@libp2p/interface/content-routing'
|
|
12
|
+
import type { PeerInfo } from '@libp2p/interface/peer-info'
|
|
13
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
14
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
15
15
|
import type { CID } from 'multiformats/cid'
|
|
16
16
|
|
|
17
17
|
export interface CompoundContentRoutingInit {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
2
|
import filter from 'it-filter'
|
|
3
3
|
import map from 'it-map'
|
|
4
|
-
import type { PeerInfo } from '@libp2p/interface
|
|
5
|
-
import type { PeerStore } from '@libp2p/interface
|
|
4
|
+
import type { PeerInfo } from '@libp2p/interface/peer-info'
|
|
5
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
6
6
|
import type { Source } from 'it-stream-types'
|
|
7
7
|
|
|
8
8
|
/**
|
package/src/fetch/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setMaxListeners } from 'events'
|
|
2
|
-
import { CodeError } from '@libp2p/
|
|
2
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
3
3
|
import { logger } from '@libp2p/logger'
|
|
4
4
|
import { abortableDuplex } from 'abortable-iterator'
|
|
5
5
|
import first from 'it-first'
|
|
@@ -10,12 +10,12 @@ import { toString as uint8arrayToString } from 'uint8arrays/to-string'
|
|
|
10
10
|
import { codes } from '../errors.js'
|
|
11
11
|
import { PROTOCOL_NAME, PROTOCOL_VERSION } from './constants.js'
|
|
12
12
|
import { FetchRequest, FetchResponse } from './pb/proto.js'
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type { PeerId } from '@libp2p/interface
|
|
16
|
-
import type {
|
|
17
|
-
import type {
|
|
18
|
-
import type {
|
|
13
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
14
|
+
import type { Stream } from '@libp2p/interface/connection'
|
|
15
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
16
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
17
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
18
|
+
import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar'
|
|
19
19
|
|
|
20
20
|
const log = logger('libp2p:fetch')
|
|
21
21
|
|
package/src/get-peer.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
|
+
import { isPeerId } from '@libp2p/interface/peer-id'
|
|
3
3
|
import { logger } from '@libp2p/logger'
|
|
4
4
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
5
5
|
import { isMultiaddr } from '@multiformats/multiaddr'
|
|
6
6
|
import { codes } from './errors.js'
|
|
7
|
-
import type { PeerId } from '@libp2p/interface
|
|
7
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
8
8
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
9
9
|
|
|
10
10
|
const log = logger('libp2p:get-peer')
|
package/src/identify/identify.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setMaxListeners } from 'events'
|
|
2
|
-
import { CodeError } from '@libp2p/
|
|
2
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
3
3
|
import { logger } from '@libp2p/logger'
|
|
4
4
|
import { peerIdFromKeys } from '@libp2p/peer-id'
|
|
5
5
|
import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record'
|
|
@@ -24,16 +24,15 @@ import {
|
|
|
24
24
|
} from './consts.js'
|
|
25
25
|
import { Identify } from './pb/message.js'
|
|
26
26
|
import type { IdentifyServiceComponents, IdentifyServiceInit } from './index.js'
|
|
27
|
-
import type {
|
|
28
|
-
import type { Connection, Stream } from '@libp2p/interface
|
|
29
|
-
import type {
|
|
30
|
-
import type {
|
|
31
|
-
import type {
|
|
32
|
-
import type {
|
|
33
|
-
import type {
|
|
34
|
-
import type {
|
|
35
|
-
import type {
|
|
36
|
-
import type { Startable } from '@libp2p/interfaces/startable'
|
|
27
|
+
import type { Libp2pEvents, IdentifyResult, SignedPeerRecord, AbortOptions } from '@libp2p/interface'
|
|
28
|
+
import type { Connection, Stream } from '@libp2p/interface/connection'
|
|
29
|
+
import type { EventEmitter } from '@libp2p/interface/events'
|
|
30
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
31
|
+
import type { Peer, PeerStore } from '@libp2p/interface/peer-store'
|
|
32
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
33
|
+
import type { AddressManager } from '@libp2p/interface-internal/address-manager'
|
|
34
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
35
|
+
import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar'
|
|
37
36
|
|
|
38
37
|
const log = logger('libp2p:identify')
|
|
39
38
|
|
|
@@ -323,11 +322,11 @@ export class DefaultIdentifyService implements Startable {
|
|
|
323
322
|
const cleanObservedAddr = getCleanMultiaddr(observedAddr)
|
|
324
323
|
|
|
325
324
|
log('identify completed for peer %p and protocols %o', id, protocols)
|
|
326
|
-
log('our observed address is %
|
|
325
|
+
log('our observed address is %a', cleanObservedAddr)
|
|
327
326
|
|
|
328
327
|
if (cleanObservedAddr != null &&
|
|
329
328
|
this.addressManager.getObservedAddrs().length < (this.maxObservedAddresses ?? Infinity)) {
|
|
330
|
-
log('storing our observed address %
|
|
329
|
+
log('storing our observed address %a', cleanObservedAddr)
|
|
331
330
|
this.addressManager.addObservedAddr(cleanObservedAddr)
|
|
332
331
|
}
|
|
333
332
|
|
package/src/identify/index.ts
CHANGED
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
} from './consts.js'
|
|
5
5
|
import { DefaultIdentifyService } from './identify.js'
|
|
6
6
|
import { Identify } from './pb/message.js'
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
7
|
+
import type { Libp2pEvents } from '@libp2p/interface'
|
|
8
|
+
import type { EventEmitter } from '@libp2p/interface/events'
|
|
9
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
10
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
11
|
+
import type { AddressManager } from '@libp2p/interface-internal/address-manager'
|
|
12
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
13
|
+
import type { Registrar } from '@libp2p/interface-internal/registrar'
|
|
14
14
|
|
|
15
15
|
export interface IdentifyServiceInit {
|
|
16
16
|
/**
|
package/src/index.ts
CHANGED
|
@@ -19,18 +19,17 @@ import type { AddressManagerInit } from './address-manager/index.js'
|
|
|
19
19
|
import type { Components } from './components.js'
|
|
20
20
|
import type { ConnectionManagerInit } from './connection-manager/index.js'
|
|
21
21
|
import type { TransportManagerInit } from './transport-manager.js'
|
|
22
|
-
import type {
|
|
23
|
-
import type {
|
|
24
|
-
import type {
|
|
25
|
-
import type {
|
|
26
|
-
import type {
|
|
27
|
-
import type { Metrics } from '@libp2p/interface
|
|
28
|
-
import type { PeerDiscovery } from '@libp2p/interface
|
|
29
|
-
import type { PeerId } from '@libp2p/interface
|
|
30
|
-
import type { PeerRouting } from '@libp2p/interface
|
|
31
|
-
import type { StreamMuxerFactory } from '@libp2p/interface
|
|
32
|
-
import type { Transport } from '@libp2p/interface
|
|
33
|
-
import type { RecursivePartial } from '@libp2p/interfaces'
|
|
22
|
+
import type { Libp2p, ServiceMap, RecursivePartial } from '@libp2p/interface'
|
|
23
|
+
import type { ConnectionProtector } from '@libp2p/interface/connection'
|
|
24
|
+
import type { ConnectionEncrypter } from '@libp2p/interface/connection-encrypter'
|
|
25
|
+
import type { ConnectionGater } from '@libp2p/interface/connection-gater'
|
|
26
|
+
import type { ContentRouting } from '@libp2p/interface/content-routing'
|
|
27
|
+
import type { Metrics } from '@libp2p/interface/metrics'
|
|
28
|
+
import type { PeerDiscovery } from '@libp2p/interface/peer-discovery'
|
|
29
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
30
|
+
import type { PeerRouting } from '@libp2p/interface/peer-routing'
|
|
31
|
+
import type { StreamMuxerFactory } from '@libp2p/interface/stream-muxer'
|
|
32
|
+
import type { Transport } from '@libp2p/interface/transport'
|
|
34
33
|
import type { KeyChainInit } from '@libp2p/keychain'
|
|
35
34
|
import type { PersistentPeerStoreInit } from '@libp2p/peer-store'
|
|
36
35
|
import type { Datastore } from 'interface-datastore'
|
package/src/insecure/index.ts
CHANGED
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import { UnexpectedPeerError, InvalidCryptoExchangeError } from '@libp2p/interface
|
|
25
|
+
import { UnexpectedPeerError, InvalidCryptoExchangeError } from '@libp2p/interface/errors'
|
|
26
26
|
import { logger } from '@libp2p/logger'
|
|
27
27
|
import { peerIdFromBytes, peerIdFromKeys } from '@libp2p/peer-id'
|
|
28
28
|
import { handshake } from 'it-handshake'
|
|
29
29
|
import * as lp from 'it-length-prefixed'
|
|
30
30
|
import map from 'it-map'
|
|
31
31
|
import { Exchange, KeyType } from './pb/proto.js'
|
|
32
|
-
import type { ConnectionEncrypter, SecuredConnection } from '@libp2p/interface
|
|
33
|
-
import type { PeerId } from '@libp2p/interface
|
|
32
|
+
import type { ConnectionEncrypter, SecuredConnection } from '@libp2p/interface/connection-encrypter'
|
|
33
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
34
34
|
import type { Duplex, Source } from 'it-stream-types'
|
|
35
35
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
36
36
|
|
package/src/libp2p.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { setMaxListeners } from 'events'
|
|
2
2
|
import { unmarshalPublicKey } from '@libp2p/crypto/keys'
|
|
3
|
-
import { type ContentRouting, contentRouting } from '@libp2p/interface
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { type ContentRouting, contentRouting } from '@libp2p/interface/content-routing'
|
|
4
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
5
|
+
import { EventEmitter, CustomEvent } from '@libp2p/interface/events'
|
|
6
|
+
import { peerDiscovery } from '@libp2p/interface/peer-discovery'
|
|
7
|
+
import { type PeerRouting, peerRouting } from '@libp2p/interface/peer-routing'
|
|
8
8
|
import { DefaultKeyChain } from '@libp2p/keychain'
|
|
9
9
|
import { logger } from '@libp2p/logger'
|
|
10
10
|
import { PeerSet } from '@libp2p/peer-collections'
|
|
@@ -29,15 +29,15 @@ import { DefaultTransportManager } from './transport-manager.js'
|
|
|
29
29
|
import { DefaultUpgrader } from './upgrader.js'
|
|
30
30
|
import type { Components } from './components.js'
|
|
31
31
|
import type { Libp2p, Libp2pInit, Libp2pOptions } from './index.js'
|
|
32
|
-
import type {
|
|
33
|
-
import type {
|
|
34
|
-
import type {
|
|
35
|
-
import type { Metrics } from '@libp2p/interface
|
|
36
|
-
import type { PeerId } from '@libp2p/interface
|
|
37
|
-
import type { PeerInfo } from '@libp2p/interface
|
|
38
|
-
import type { PeerStore } from '@libp2p/interface
|
|
39
|
-
import type {
|
|
40
|
-
import type {
|
|
32
|
+
import type { Libp2pEvents, PendingDial, ServiceMap, AbortOptions } from '@libp2p/interface'
|
|
33
|
+
import type { Connection, Stream } from '@libp2p/interface/connection'
|
|
34
|
+
import type { KeyChain } from '@libp2p/interface/keychain'
|
|
35
|
+
import type { Metrics } from '@libp2p/interface/metrics'
|
|
36
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
37
|
+
import type { PeerInfo } from '@libp2p/interface/peer-info'
|
|
38
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
39
|
+
import type { Topology } from '@libp2p/interface/topology'
|
|
40
|
+
import type { StreamHandler, StreamHandlerOptions } from '@libp2p/interface-internal/registrar'
|
|
41
41
|
import type { Datastore } from 'interface-datastore'
|
|
42
42
|
|
|
43
43
|
const log = logger('libp2p')
|
package/src/peer-routing.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/
|
|
1
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
2
2
|
import { logger } from '@libp2p/logger'
|
|
3
3
|
import filter from 'it-filter'
|
|
4
4
|
import first from 'it-first'
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
requirePeers
|
|
11
11
|
} from './content-routing/utils.js'
|
|
12
12
|
import { codes, messages } from './errors.js'
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import type {
|
|
13
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
14
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
15
|
+
import type { PeerInfo } from '@libp2p/interface/peer-info'
|
|
16
|
+
import type { PeerRouting } from '@libp2p/interface/peer-routing'
|
|
17
|
+
import type { PeerStore } from '@libp2p/interface/peer-store'
|
|
18
18
|
|
|
19
19
|
const log = logger('libp2p:peer-routing')
|
|
20
20
|
|
package/src/ping/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { setMaxListeners } from 'events'
|
|
2
2
|
import { randomBytes } from '@libp2p/crypto'
|
|
3
|
-
import { CodeError } from '@libp2p/
|
|
3
|
+
import { CodeError } from '@libp2p/interface/errors'
|
|
4
4
|
import { logger } from '@libp2p/logger'
|
|
5
5
|
import { abortableDuplex } from 'abortable-iterator'
|
|
6
6
|
import { anySignal } from 'any-signal'
|
|
@@ -9,12 +9,12 @@ import { pipe } from 'it-pipe'
|
|
|
9
9
|
import { equals as uint8ArrayEquals } from 'uint8arrays/equals'
|
|
10
10
|
import { codes } from '../errors.js'
|
|
11
11
|
import { PROTOCOL_PREFIX, PROTOCOL_NAME, PING_LENGTH, PROTOCOL_VERSION, TIMEOUT, MAX_INBOUND_STREAMS, MAX_OUTBOUND_STREAMS } from './constants.js'
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type { PeerId } from '@libp2p/interface
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import type {
|
|
12
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
13
|
+
import type { Stream } from '@libp2p/interface/connection'
|
|
14
|
+
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
15
|
+
import type { Startable } from '@libp2p/interface/startable'
|
|
16
|
+
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
17
|
+
import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar'
|
|
18
18
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
19
19
|
|
|
20
20
|
const log = logger('libp2p:ping')
|