mirror of
https://github.com/fluencelabs/js-mafmt
synced 2025-04-25 07:22:18 +00:00
feat: add WebRTC Direct support for filtering
This commit is contained in:
parent
d20d28ce52
commit
db00d97807
@ -39,7 +39,7 @@
|
||||
"pre-commit": "^1.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"multiaddr": "^2.1.1"
|
||||
"multiaddr": "^2.1.3"
|
||||
},
|
||||
"contributors": [
|
||||
"David Dias <daviddias.p@gmail.com>",
|
||||
|
@ -7,7 +7,9 @@ var TCP = and(IP, base('tcp'))
|
||||
var UDP = and(IP, base('udp'))
|
||||
var UTP = and(UDP, base('utp'))
|
||||
var WebSockets = and(TCP, base('ws'))
|
||||
var HTTP = and(TCP, base('http'))
|
||||
var WebRTCStar = and(base('libp2p-webrtc-star'), WebSockets, base('ipfs'))
|
||||
var WebRTCDirect = and(base('libp2p-webrtc-direct'), HTTP)
|
||||
var Reliable = or(WebSockets, TCP, UTP)
|
||||
|
||||
// required cause some transports are already IPFS aware (like WebRTCStar)
|
||||
@ -22,8 +24,10 @@ exports.IP = IP
|
||||
exports.TCP = TCP
|
||||
exports.UDP = UDP
|
||||
exports.UTP = UTP
|
||||
exports.HTTP = HTTP
|
||||
exports.WebSockets = WebSockets
|
||||
exports.WebRTCStar = WebRTCStar
|
||||
exports.WebRTCDirect = WebRTCDirect
|
||||
exports.Reliable = Reliable
|
||||
exports.IPFS = IPFS
|
||||
|
||||
|
@ -56,6 +56,11 @@ describe('multiaddr validation', function () {
|
||||
'/libp2p-webrtc-star/ip6/::/tcp/0/ws/ipfs/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSoooo5'
|
||||
]
|
||||
|
||||
var goodWebRTCDirect = [
|
||||
'/libp2p-webrtc-direct/ip4/1.2.3.4/tcp/3456/http',
|
||||
'/libp2p-webrtc-direct/ip6/::/tcp/0/http'
|
||||
]
|
||||
|
||||
var badWS = [
|
||||
'/ip4/0.0.0.0/tcp/12345/udp/2222/ws',
|
||||
'/ip6/::/ip4/0.0.0.0/udp/1234/ws'
|
||||
@ -120,6 +125,11 @@ describe('multiaddr validation', function () {
|
||||
assertMismatches(mafmt.WebRTCStar, goodIP, goodUDP, badWS)
|
||||
})
|
||||
|
||||
it('WebRTC-direct validation', function () {
|
||||
assertMatches(mafmt.WebRTCDirect, goodWebRTCDirect)
|
||||
assertMismatches(mafmt.WebRTCDirect, goodIP, goodUDP, badWS)
|
||||
})
|
||||
|
||||
it('IPFS validation', function () {
|
||||
assertMatches(mafmt.IPFS, goodIPFS)
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user