Skip to content

Commit e91e5f5

Browse files
Merge pull request #4 from marten-seemann/master
add QUIC
2 parents f052f16 + 45f66a6 commit e91e5f5

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

patterns.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ var UDP = And(IP, Base(ma.P_UDP))
1818
// Define UTP as 'utp' on top of udp (on top of ipv4 or ipv6)
1919
var UTP = And(UDP, Base(ma.P_UTP))
2020

21+
// Define QUIC as 'quic' on top of udp (on top of ipv4 or ipv6)
22+
var QUIC = And(UDP, Base(ma.P_QUIC))
23+
2124
// Define unreliable transport as udp
2225
var Unreliable = Or(UDP)
2326

24-
// Now define a Reliable transport as either tcp or utp
25-
var Reliable = Or(TCP, UTP)
27+
// Now define a Reliable transport as either tcp or utp or quic
28+
var Reliable = Or(TCP, UTP, QUIC)
2629

2730
// IPFS can run over any reliable underlying transport protocol
2831
var IPFS = And(Reliable, Base(ma.P_IPFS))

patterns_test.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ func TestBasicMatching(t *testing.T) {
7979
"/utp",
8080
}
8181

82+
good_quic := []string{
83+
"/ip4/1.2.3.4/udp/1234/quic",
84+
"/ip6/::/udp/1234/quic",
85+
}
86+
87+
bad_quic := []string{
88+
"/ip4/0.0.0.0/tcp/12345/quic",
89+
"/ip6/1.2.3.4/ip4/0.0.0.0/udp/1234/quic",
90+
"/quic",
91+
}
92+
8293
good_ipfs := []string{
8394
"/ip4/1.2.3.4/tcp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
8495
"/ip6/::/tcp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
@@ -102,17 +113,20 @@ func TestBasicMatching(t *testing.T) {
102113
assertMismatches(t, TCP, bad_tcp, good_ip)
103114

104115
assertMatches(t, UDP, good_udp)
105-
assertMismatches(t, UDP, bad_udp, good_ip, good_tcp, good_ipfs, good_utp)
116+
assertMismatches(t, UDP, bad_udp, good_ip, good_tcp, good_ipfs, good_utp, good_quic)
106117

107118
assertMatches(t, UTP, good_utp)
108-
assertMismatches(t, UTP, bad_utp, good_ip, good_tcp, good_udp)
119+
assertMismatches(t, UTP, bad_utp, good_ip, good_tcp, good_udp, good_quic)
120+
121+
assertMatches(t, QUIC, good_quic)
122+
assertMismatches(t, QUIC, bad_quic, good_ip, good_tcp, good_udp, good_utp)
109123

110-
assertMatches(t, Reliable, good_utp, good_tcp)
124+
assertMatches(t, Reliable, good_utp, good_tcp, good_quic)
111125
assertMismatches(t, Reliable, good_ip, good_udp, good_ipfs)
112126

113127
assertMatches(t, Unreliable, good_udp)
114-
assertMismatches(t, Unreliable, good_ip, good_tcp, good_utp, good_ipfs)
128+
assertMismatches(t, Unreliable, good_ip, good_tcp, good_utp, good_ipfs, good_quic)
115129

116130
assertMatches(t, IPFS, good_ipfs)
117-
assertMismatches(t, IPFS, bad_ipfs, good_ip, good_tcp, good_utp, good_udp)
131+
assertMismatches(t, IPFS, bad_ipfs, good_ip, good_tcp, good_utp, good_udp, good_quic)
118132
}

0 commit comments

Comments
 (0)