libp2p 0.46.17-fdcb801e → 0.46.18
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 +11 -11
- package/dist/src/connection-manager/dial-queue.d.ts.map +1 -1
- package/dist/src/connection-manager/dial-queue.js +21 -22
- package/dist/src/connection-manager/dial-queue.js.map +1 -1
- package/dist/src/identify/consts.d.ts +1 -1
- package/dist/src/identify/consts.d.ts.map +1 -1
- package/dist/src/identify/identify.d.ts.map +1 -1
- package/dist/src/identify/identify.js +6 -1
- package/dist/src/identify/identify.js.map +1 -1
- package/dist/src/upgrader.js +1 -1
- package/dist/src/upgrader.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.d.ts.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/typedoc-urls.json +71 -0
- package/package.json +21 -21
- package/src/connection-manager/dial-queue.ts +25 -26
- package/src/identify/identify.ts +8 -1
- package/src/upgrader.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -348,7 +348,7 @@ export class DialQueue {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
// resolve addresses - this can result in a one-to-many translation when dnsaddrs are resolved
|
|
351
|
-
|
|
351
|
+
let resolvedAddresses = (await Promise.all(
|
|
352
352
|
addrs.map(async addr => {
|
|
353
353
|
const result = await resolveMultiaddrs(addr.multiaddr, options)
|
|
354
354
|
|
|
@@ -364,6 +364,29 @@ export class DialQueue {
|
|
|
364
364
|
))
|
|
365
365
|
.flat()
|
|
366
366
|
|
|
367
|
+
// ensure the peer id is appended to the multiaddr
|
|
368
|
+
if (peerId != null) {
|
|
369
|
+
const peerIdMultiaddr = `/p2p/${peerId.toString()}`
|
|
370
|
+
resolvedAddresses = resolvedAddresses.map(addr => {
|
|
371
|
+
const lastProto = addr.multiaddr.protos().pop()
|
|
372
|
+
|
|
373
|
+
// do not append peer id to path multiaddrs
|
|
374
|
+
if (lastProto?.path === true) {
|
|
375
|
+
return addr
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// append peer id to multiaddr if it is not already present
|
|
379
|
+
if (addr.multiaddr.getPeerId() == null) {
|
|
380
|
+
return {
|
|
381
|
+
multiaddr: addr.multiaddr.encapsulate(peerIdMultiaddr),
|
|
382
|
+
isCertified: addr.isCertified
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
return addr
|
|
387
|
+
})
|
|
388
|
+
}
|
|
389
|
+
|
|
367
390
|
const filteredAddrs = resolvedAddresses.filter(addr => {
|
|
368
391
|
// filter out any multiaddrs that we do not have transports for
|
|
369
392
|
if (this.transportManager.transportForMultiaddr(addr.multiaddr) == null) {
|
|
@@ -396,7 +419,7 @@ export class DialQueue {
|
|
|
396
419
|
dedupedAddrs.set(maStr, addr)
|
|
397
420
|
}
|
|
398
421
|
|
|
399
|
-
|
|
422
|
+
const dedupedMultiaddrs = [...dedupedAddrs.values()]
|
|
400
423
|
|
|
401
424
|
if (dedupedMultiaddrs.length === 0 || dedupedMultiaddrs.length > this.maxPeerAddrsToDial) {
|
|
402
425
|
log('addresses for %p before filtering', peerId ?? 'unknown peer', resolvedAddresses.map(({ multiaddr }) => multiaddr.toString()))
|
|
@@ -413,30 +436,6 @@ export class DialQueue {
|
|
|
413
436
|
throw new CodeError('dial with more addresses than allowed', codes.ERR_TOO_MANY_ADDRESSES)
|
|
414
437
|
}
|
|
415
438
|
|
|
416
|
-
// ensure the peer id is appended to the multiaddr
|
|
417
|
-
if (peerId != null) {
|
|
418
|
-
const peerIdMultiaddr = `/p2p/${peerId.toString()}`
|
|
419
|
-
dedupedMultiaddrs = dedupedMultiaddrs.map(addr => {
|
|
420
|
-
const addressPeerId = addr.multiaddr.getPeerId()
|
|
421
|
-
const lastProto = addr.multiaddr.protos().pop()
|
|
422
|
-
|
|
423
|
-
// do not append peer id to path multiaddrs
|
|
424
|
-
if (lastProto?.path === true) {
|
|
425
|
-
return addr
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// append peer id to multiaddr if it is not already present
|
|
429
|
-
if (addressPeerId !== peerId.toString()) {
|
|
430
|
-
return {
|
|
431
|
-
multiaddr: addr.multiaddr.encapsulate(peerIdMultiaddr),
|
|
432
|
-
isCertified: addr.isCertified
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
return addr
|
|
437
|
-
})
|
|
438
|
-
}
|
|
439
|
-
|
|
440
439
|
const gatedAdrs: Address[] = []
|
|
441
440
|
|
|
442
441
|
for (const addr of dedupedMultiaddrs) {
|
package/src/identify/identify.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { logger } from '@libp2p/logger'
|
|
|
4
4
|
import { peerIdFromKeys } from '@libp2p/peer-id'
|
|
5
5
|
import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record'
|
|
6
6
|
import { type Multiaddr, multiaddr, protocols } from '@multiformats/multiaddr'
|
|
7
|
+
import { IP_OR_DOMAIN } from '@multiformats/multiaddr-matcher'
|
|
7
8
|
import { pbStream } from 'it-protobuf-stream'
|
|
8
9
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
|
|
9
10
|
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
|
|
@@ -345,6 +346,12 @@ export class DefaultIdentifyService implements Startable, IdentifyService {
|
|
|
345
346
|
signedPeerRecord = envelope.marshal().subarray()
|
|
346
347
|
}
|
|
347
348
|
|
|
349
|
+
let observedAddr: Uint8Array | undefined = connection.remoteAddr.bytes
|
|
350
|
+
|
|
351
|
+
if (!IP_OR_DOMAIN.matches(connection.remoteAddr)) {
|
|
352
|
+
observedAddr = undefined
|
|
353
|
+
}
|
|
354
|
+
|
|
348
355
|
const pb = pbStream(stream).pb(Identify)
|
|
349
356
|
|
|
350
357
|
await pb.write({
|
|
@@ -353,7 +360,7 @@ export class DefaultIdentifyService implements Startable, IdentifyService {
|
|
|
353
360
|
publicKey,
|
|
354
361
|
listenAddrs: multiaddrs.map(addr => addr.bytes),
|
|
355
362
|
signedPeerRecord,
|
|
356
|
-
observedAddr
|
|
363
|
+
observedAddr,
|
|
357
364
|
protocols: peerData.protocols
|
|
358
365
|
}, {
|
|
359
366
|
signal
|
package/src/upgrader.ts
CHANGED
|
@@ -432,7 +432,7 @@ export class DefaultUpgrader implements Upgrader {
|
|
|
432
432
|
throw new CodeError('Stream is not multiplexed', codes.ERR_MUXER_UNAVAILABLE)
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
log('%s: starting new stream on %s', direction, protocols)
|
|
435
|
+
log('%s-%s: starting new stream on %s', connection.id, direction, protocols)
|
|
436
436
|
const muxedStream = await muxer.newStream()
|
|
437
437
|
|
|
438
438
|
try {
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '0.46.
|
|
1
|
+
export const version = '0.46.18'
|
|
2
2
|
export const name = 'libp2p'
|