Comparing version 2.7.0 to 2.7.1-2a3cec922
@@ -0,1 +1,2 @@ | ||
import { isNetworkAddress } from '@libp2p/utils/multiaddr/is-network-address'; | ||
import { isPrivate } from '@libp2p/utils/multiaddr/is-private'; | ||
@@ -28,3 +29,3 @@ export const defaultValues = { | ||
metadata = { | ||
verified: false, | ||
verified: !isNetworkAddress(multiaddr), | ||
expires: 0 | ||
@@ -80,6 +81,10 @@ }; | ||
toKey(ma) { | ||
const options = ma.toOptions(); | ||
return `${options.host}-${options.port}-${options.transport}`; | ||
if (isNetworkAddress(ma)) { | ||
// only works for dns/ip based addresses | ||
const options = ma.toOptions(); | ||
return `${options.host}-${options.port}-${options.transport}`; | ||
} | ||
return ma.toString(); | ||
} | ||
} | ||
//# sourceMappingURL=transport-addresses.js.map |
@@ -10,2 +10,7 @@ import type { Address } from '@libp2p/interface'; | ||
/** | ||
* Compare function for array.sort() that moves loopback addresses to the end | ||
* of the array. | ||
*/ | ||
export declare function loopbackAddressLast(a: Address, b: Address): -1 | 0 | 1; | ||
/** | ||
* Compare function for array.sort() that moves public addresses to the start | ||
@@ -12,0 +17,0 @@ * of the array. |
@@ -0,1 +1,2 @@ | ||
import { isLoopback } from '@libp2p/utils/multiaddr/is-loopback'; | ||
import { isPrivate } from '@libp2p/utils/multiaddr/is-private'; | ||
@@ -63,2 +64,17 @@ import { Circuit, WebSockets, WebSocketsSecure, WebRTC, WebRTCDirect, WebTransport, TCP } from '@multiformats/multiaddr-matcher'; | ||
/** | ||
* Compare function for array.sort() that moves loopback addresses to the end | ||
* of the array. | ||
*/ | ||
export function loopbackAddressLast(a, b) { | ||
const isALoopback = isLoopback(a.multiaddr); | ||
const isBLoopback = isLoopback(b.multiaddr); | ||
if (isALoopback && !isBLoopback) { | ||
return 1; | ||
} | ||
else if (!isALoopback && isBLoopback) { | ||
return -1; | ||
} | ||
return 0; | ||
} | ||
/** | ||
* Compare function for array.sort() that moves public addresses to the start | ||
@@ -111,4 +127,5 @@ * of the array. | ||
.sort(circuitRelayAddressesLast) | ||
.sort(publicAddressesFirst); | ||
.sort(publicAddressesFirst) | ||
.sort(loopbackAddressLast); | ||
} | ||
//# sourceMappingURL=address-sorter.js.map |
@@ -56,3 +56,3 @@ import { publicKeyFromProtobuf } from '@libp2p/crypto/keys'; | ||
const nodeInfoName = init.nodeInfo?.name ?? pkg.name; | ||
const nodeInfoVersion = init.nodeInfo?.version ?? pkg.name; | ||
const nodeInfoVersion = init.nodeInfo?.version ?? pkg.version; | ||
// @ts-expect-error defaultComponents is missing component types added later | ||
@@ -59,0 +59,0 @@ const components = this.components = defaultComponents({ |
@@ -1,3 +0,3 @@ | ||
export declare const version = "2.7.0"; | ||
export declare const version = "2.7.1-2a3cec922"; | ||
export declare const name = "js-libp2p"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -1,3 +0,3 @@ | ||
export const version = '2.7.0'; | ||
export const version = '2.7.1-2a3cec922'; | ||
export const name = 'js-libp2p'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "libp2p", | ||
"version": "2.7.0", | ||
"version": "2.7.1-2a3cec922", | ||
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack", | ||
@@ -95,11 +95,11 @@ "license": "Apache-2.0 OR MIT", | ||
"@chainsafe/netmask": "^2.0.0", | ||
"@libp2p/crypto": "^5.0.12", | ||
"@libp2p/interface": "^2.6.0", | ||
"@libp2p/interface-internal": "^2.3.2", | ||
"@libp2p/logger": "^5.1.9", | ||
"@libp2p/multistream-select": "^6.0.15", | ||
"@libp2p/peer-collections": "^6.0.18", | ||
"@libp2p/peer-id": "^5.0.13", | ||
"@libp2p/peer-store": "^11.0.18", | ||
"@libp2p/utils": "^6.5.2", | ||
"@libp2p/crypto": "5.0.12-2a3cec922", | ||
"@libp2p/interface": "2.6.0-2a3cec922", | ||
"@libp2p/interface-internal": "2.3.3-2a3cec922", | ||
"@libp2p/logger": "5.1.9-2a3cec922", | ||
"@libp2p/multistream-select": "6.0.15-2a3cec922", | ||
"@libp2p/peer-collections": "6.0.19-2a3cec922", | ||
"@libp2p/peer-id": "5.0.13-2a3cec922", | ||
"@libp2p/peer-store": "11.0.19-2a3cec922", | ||
"@libp2p/utils": "6.5.3-2a3cec922", | ||
"@multiformats/dns": "^1.0.6", | ||
@@ -120,3 +120,3 @@ "@multiformats/multiaddr": "^12.3.5", | ||
"race-event": "^1.3.0", | ||
"race-signal": "^1.1.0", | ||
"race-signal": "^1.1.2", | ||
"uint8arrays": "^5.1.0" | ||
@@ -123,0 +123,0 @@ }, |
@@ -11,6 +11,35 @@ <h1 align="center"> | ||
[](http://webchat.freenode.net/?channels=%23libp2p) | ||
[](https://discord.com/invite/Ae4TbahHaT) | ||
[](https://discord.com/invite/Ae4TbahHaT) | ||
[](https://codecov.io/gh/libp2p/js-libp2p) | ||
[](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amain) | ||
# About | ||
<!-- | ||
!IMPORTANT! | ||
Everything in this README between "# About" and "# Install" is automatically | ||
generated and will be overwritten the next time the doc generator is run. | ||
To make changes to this section, please update the @packageDocumentation section | ||
of src/index.js or src/index.ts | ||
To experiment with formatting, please run "npm run docs" from the root of this | ||
repo and examine the changes made. | ||
--> | ||
Use the `createLibp2p` function to create a libp2p node. | ||
## Example | ||
```typescript | ||
import { createLibp2p } from 'libp2p' | ||
const node = await createLibp2p({ | ||
// ...other options | ||
}) | ||
``` | ||
# Background | ||
@@ -17,0 +46,0 @@ |
@@ -0,1 +1,2 @@ | ||
import { isNetworkAddress } from '@libp2p/utils/multiaddr/is-network-address' | ||
import { isPrivate } from '@libp2p/utils/multiaddr/is-private' | ||
@@ -44,3 +45,3 @@ import type { AddressManagerComponents, AddressManagerInit } from './index.js' | ||
metadata = { | ||
verified: false, | ||
verified: !isNetworkAddress(multiaddr), | ||
expires: 0 | ||
@@ -113,6 +114,11 @@ } | ||
private toKey (ma: Multiaddr): string { | ||
const options = ma.toOptions() | ||
if (isNetworkAddress(ma)) { | ||
// only works for dns/ip based addresses | ||
const options = ma.toOptions() | ||
return `${options.host}-${options.port}-${options.transport}` | ||
return `${options.host}-${options.port}-${options.transport}` | ||
} | ||
return ma.toString() | ||
} | ||
} |
@@ -0,1 +1,2 @@ | ||
import { isLoopback } from '@libp2p/utils/multiaddr/is-loopback' | ||
import { isPrivate } from '@libp2p/utils/multiaddr/is-private' | ||
@@ -84,2 +85,19 @@ import { Circuit, WebSockets, WebSocketsSecure, WebRTC, WebRTCDirect, WebTransport, TCP } from '@multiformats/multiaddr-matcher' | ||
/** | ||
* Compare function for array.sort() that moves loopback addresses to the end | ||
* of the array. | ||
*/ | ||
export function loopbackAddressLast (a: Address, b: Address): -1 | 0 | 1 { | ||
const isALoopback = isLoopback(a.multiaddr) | ||
const isBLoopback = isLoopback(b.multiaddr) | ||
if (isALoopback && !isBLoopback) { | ||
return 1 | ||
} else if (!isALoopback && isBLoopback) { | ||
return -1 | ||
} | ||
return 0 | ||
} | ||
/** | ||
* Compare function for array.sort() that moves public addresses to the start | ||
@@ -138,2 +156,3 @@ * of the array. | ||
.sort(publicAddressesFirst) | ||
.sort(loopbackAddressLast) | ||
} |
@@ -70,3 +70,3 @@ import { publicKeyFromProtobuf } from '@libp2p/crypto/keys' | ||
const nodeInfoName = init.nodeInfo?.name ?? pkg.name | ||
const nodeInfoVersion = init.nodeInfo?.version ?? pkg.name | ||
const nodeInfoVersion = init.nodeInfo?.version ?? pkg.version | ||
@@ -73,0 +73,0 @@ // @ts-expect-error defaultComponents is missing component types added later |
@@ -1,2 +0,2 @@ | ||
export const version = '2.7.0' | ||
export const version = '2.7.1-2a3cec922' | ||
export const name = 'js-libp2p' |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
997238
12439
191
173
1
+ Added@libp2p/crypto@5.0.12-2a3cec922(transitive)
+ Added@libp2p/interface@2.6.0-2a3cec922(transitive)
+ Added@libp2p/interface-internal@2.3.3-2a3cec922(transitive)
+ Added@libp2p/logger@5.1.9-2a3cec922(transitive)
+ Added@libp2p/multistream-select@6.0.15-2a3cec922(transitive)
+ Added@libp2p/peer-collections@6.0.19-2a3cec922(transitive)
+ Added@libp2p/peer-id@5.0.13-2a3cec922(transitive)
+ Added@libp2p/peer-record@8.0.19-2a3cec922(transitive)
+ Added@libp2p/peer-store@11.0.19-2a3cec922(transitive)
+ Added@libp2p/utils@6.5.3-2a3cec922(transitive)
+ Addedrace-signal@1.1.3(transitive)
- Removed@libp2p/crypto@5.0.12(transitive)
- Removed@libp2p/interface-internal@2.3.4(transitive)
- Removed@libp2p/multistream-select@6.0.16(transitive)
- Removed@libp2p/peer-collections@6.0.20(transitive)
- Removed@libp2p/peer-id@5.0.13(transitive)
- Removed@libp2p/peer-record@8.0.20(transitive)
- Removed@libp2p/peer-store@11.0.20(transitive)
- Removed@libp2p/utils@6.5.4(transitive)
- Removedrace-signal@1.1.2(transitive)
Updatedrace-signal@^1.1.2