add validator for webrtc-star-check

This commit is contained in:
David Dias 2016-05-21 19:57:26 +01:00
parent bb32f0068d
commit eefa364ed6
3 changed files with 12 additions and 2 deletions

View File

@ -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>",
@ -47,4 +47,4 @@
"Jeromy Johnson <why@ipfs.io>", "Jeromy Johnson <why@ipfs.io>",
"dignifiedquire <dignifiedquire@gmail.com>" "dignifiedquire <dignifiedquire@gmail.com>"
] ]
} }

View File

@ -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

View File

@ -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)
}) })
}) })