Skip to content

Commit 4a4710d

Browse files
authoredFeb 3, 2021
feat: dnsaddr support in peerMultiaddr (#35)
This bumps dependencies to the latest versions including js-multiaddr 8.x which shipped support for resolving /dnsaddr/ Peer addresses.
1 parent 7ab7125 commit 4a4710d

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multif
216216

217217
### `isIPFS.peerMultiaddr(addr)`
218218

219-
Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr) or `Uint8Array` represents a valid "IPFS Peer" multiaddr (matching [`IPFS` format from `mafmt`](https://github.com/multiformats/js-mafmt#api)) or `false` otherwise.
219+
Returns `true` if the provided `string`, [`Multiaddr`](https://github.com/multiformats/js-multiaddr) or `Uint8Array` represents a valid libp2p peer multiaddr (matching [`P2P` format from `mafmt`](https://github.com/multiformats/js-mafmt#api)) or `false` otherwise.
220220

221221
# License
222222

‎package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@
4141
"coverage-publish": "aegir coverage --upload"
4242
},
4343
"dependencies": {
44-
"cids": "^1.0.0",
45-
"iso-url": "~0.4.7",
46-
"mafmt": "^8.0.0",
47-
"multiaddr": "^8.0.0",
48-
"multibase": "^3.0.0",
44+
"cids": "^1.0.2",
45+
"iso-url": "^1.0.0",
46+
"mafmt": "^8.0.1",
47+
"multiaddr": "^8.1.1",
48+
"multibase": "^3.0.1",
4949
"multihashes": "^3.0.1",
5050
"uint8arrays": "^1.1.0"
5151
},
5252
"devDependencies": {
53-
"aegir": "^25.0.0",
53+
"aegir": "^28.1.0",
5454
"pre-commit": "^1.2.2"
5555
},
5656
"engines": {

‎src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function isMultiaddr (input) {
6060
}
6161

6262
function isPeerMultiaddr (input) {
63-
return isMultiaddr(input) && mafmt.IPFS.matches(input)
63+
return isMultiaddr(input) && mafmt.P2P.matches(input)
6464
}
6565

6666
function isIpfs (input, pattern, protocolMatch = defaultProtocolMatch, hashMatch = defaultHashMath) {

‎test/test-multiaddr.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ describe('ipfs multiaddr', () => {
1919
done()
2020
})
2121

22+
it('isIPFS.multiaddr should match a string with valid dnsaddr multiaddr', (done) => {
23+
const actual = isIPFS.multiaddr('/dnsaddr/bootstrap.libp2p.io')
24+
expect(actual).to.equal(true)
25+
done()
26+
})
27+
2228
it('isIPFS.multiaddr should match a valid Multiaddr instance', (done) => {
2329
const ma = new Multiaddr('/ip6/::1/udp/1234/http')
2430
const actual = isIPFS.multiaddr(ma)
@@ -90,6 +96,7 @@ describe('ipfs peerMultiaddr', () => {
9096
'/ip4/1.2.3.4/tcp/3456/ws/p2p-webrtc-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4',
9197
'/ip4/1.2.3.4/tcp/3456/ws/p2p-webrtc-star/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4',
9298
'/ip4/1.2.3.4/tcp/3456/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4',
99+
'/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN',
93100
'/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4/p2p-circuit',
94101
'/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4/p2p-circuit/ipfs/QmUjNmr8TgJCn1Ao7DvMy4cjoZU15b9bwSCBLE3vwXiwgj'
95102
].concat(goodCircuit)

0 commit comments

Comments
 (0)