feat: Update to multiaddr v3.0.1 - refactor: websocket{s => }-star (#19)

* chore: Update to multiaddr v3.0.1 - refactor: websocket{s => }-star

* fix: Some valid websocket-star addresses were filtered as invalid
This commit is contained in:
Maciej Krüger 2017-09-06 14:13:17 +02:00 committed by David Dias
parent 41a8a85e6a
commit 2f336e3873
3 changed files with 16 additions and 13 deletions

View File

@ -38,7 +38,7 @@
"pre-commit": "^1.2.2"
},
"dependencies": {
"multiaddr": "^3.0.0"
"multiaddr": "^3.0.1"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
@ -47,4 +47,4 @@
"dignifiedquire <dignifiedquire@gmail.com>",
"dmitriy ryajov <dryajov@dmitriys-MBP.HomeNET>"
]
}
}

View File

@ -44,10 +44,11 @@ const WebRTCStar = or(
and(WebSocketsSecure, base('p2p-webrtc-star'), base('ipfs'))
)
const WebSocketsStar = or(
and(WebSockets, base('p2p-websockets-star')),
and(WebSockets, base('p2p-websockets-star'), base('ipfs')),
and(WebSocketsSecure, base('p2p-websockets-star'), base('ipfs'))
const WebSocketStar = or(
and(WebSockets, base('p2p-websocket-star'), base('ipfs')),
and(WebSocketsSecure, base('p2p-websocket-star'), base('ipfs')),
and(WebSockets, base('p2p-websocket-star')),
and(WebSocketsSecure, base('p2p-websocket-star'))
)
const WebRTCDirect = and(HTTP, base('p2p-webrtc-direct'))
@ -102,7 +103,7 @@ exports.UTP = UTP
exports.HTTP = HTTP
exports.WebSockets = WebSockets
exports.WebSocketsSecure = WebSocketsSecure
exports.WebSocketsStar = WebSocketsStar
exports.WebSocketStar = WebSocketStar
exports.WebRTCStar = WebRTCStar
exports.WebRTCDirect = WebRTCDirect
exports.Reliable = Reliable

View File

@ -84,9 +84,11 @@ describe('multiaddr validation', function () {
'/ip6/::/tcp/0/http/p2p-webrtc-direct'
]
const goodWebSocketsStar = [
'/ip4/1.2.3.4/tcp/3456/ws/p2p-websockets-star',
'/ip6/::/tcp/0/ws/p2p-websockets-star'
const goodWebSocketStar = [
'/ip4/1.2.3.4/tcp/3456/ws/p2p-websocket-star',
'/ip6/::/tcp/0/ws/p2p-websocket-star',
'/dns/localhost/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4',
'/ip4/1.2.3.4/tcp/3456/ws/p2p-websocket-star/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo4'
]
const badWS = [
@ -186,9 +188,9 @@ describe('multiaddr validation', function () {
assertMismatches(mafmt.WebSocketsSecure, goodIP, badWSS, goodUDP, badWS)
})
it('WebSocketsStar validation', function () {
assertMatches(mafmt.WebSocketsStar, goodWebSocketsStar)
assertMismatches(mafmt.WebSocketsStar, goodIP, goodUDP, badWS)
it('WebSocketStar validation', function () {
assertMatches(mafmt.WebSocketStar, goodWebSocketStar)
assertMismatches(mafmt.WebSocketStar, goodIP, goodUDP, badWS)
})
it('WebRTCStar validation', function () {