mirror of
https://github.com/fluencelabs/js-mafmt
synced 2025-04-25 18:42:24 +00:00
add validator for webrtc-star-check
This commit is contained in:
parent
bb32f0068d
commit
eefa364ed6
@ -39,7 +39,7 @@
|
|||||||
"pre-commit": "^1.1.2"
|
"pre-commit": "^1.1.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"multiaddr": "^2.0.0"
|
"multiaddr": "^2.0.2"
|
||||||
},
|
},
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"David Dias <daviddias.p@gmail.com>",
|
"David Dias <daviddias.p@gmail.com>",
|
||||||
|
@ -7,6 +7,7 @@ var TCP = and(IP, base('tcp'))
|
|||||||
var UDP = and(IP, base('udp'))
|
var UDP = and(IP, base('udp'))
|
||||||
var UTP = and(UDP, base('utp'))
|
var UTP = and(UDP, base('utp'))
|
||||||
var WebSockets = and(TCP, base('ws'))
|
var WebSockets = and(TCP, base('ws'))
|
||||||
|
var WebRTCStar = and(base('libp2p-webrtc-star'), WebSockets)
|
||||||
var Reliable = or(TCP, UTP)
|
var Reliable = or(TCP, UTP)
|
||||||
var IPFS = and(Reliable, base('ipfs'))
|
var IPFS = and(Reliable, base('ipfs'))
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ exports.TCP = TCP
|
|||||||
exports.UDP = UDP
|
exports.UDP = UDP
|
||||||
exports.UTP = UTP
|
exports.UTP = UTP
|
||||||
exports.WebSockets = WebSockets
|
exports.WebSockets = WebSockets
|
||||||
|
exports.WebRTCStar = WebRTCStar
|
||||||
exports.Reliable = Reliable
|
exports.Reliable = Reliable
|
||||||
exports.IPFS = IPFS
|
exports.IPFS = IPFS
|
||||||
|
|
||||||
|
@ -51,6 +51,11 @@ describe('multiaddr validation', function () {
|
|||||||
'/ip6/::/tcp/0/ws'
|
'/ip6/::/tcp/0/ws'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
var goodWebRTCStar = [
|
||||||
|
'/libp2p-webrtc-star/ip4/1.2.3.4/tcp/3456/ws',
|
||||||
|
'/libp2p-webrtc-star/ip6/::/tcp/0/ws'
|
||||||
|
]
|
||||||
|
|
||||||
var badWS = [
|
var badWS = [
|
||||||
'/ip4/0.0.0.0/tcp/12345/udp/2222/ws',
|
'/ip4/0.0.0.0/tcp/12345/udp/2222/ws',
|
||||||
'/ip6/::/ip4/0.0.0.0/udp/1234/ws'
|
'/ip6/::/ip4/0.0.0.0/udp/1234/ws'
|
||||||
@ -91,5 +96,8 @@ describe('multiaddr validation', function () {
|
|||||||
|
|
||||||
assertMatches(mafmt.WebSockets, goodWS)
|
assertMatches(mafmt.WebSockets, goodWS)
|
||||||
assertMismatches(mafmt.WebSockets, goodIP, goodUDP, badWS)
|
assertMismatches(mafmt.WebSockets, goodIP, goodUDP, badWS)
|
||||||
|
|
||||||
|
assertMatches(mafmt.WebRTCStar, goodWebRTCStar)
|
||||||
|
assertMismatches(mafmt.WebRTCStar, goodIP, goodUDP, badWS)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user