Skip to content

Commit 4842948

Browse files
Merge pull request #1 from sheerun/unreliable
Add unreliable protocol family
2 parents 8f444fb + 0ceb139 commit 4842948

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

patterns.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ 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 unreliable transport as udp
22+
var Unreliable = Or(UDP)
23+
2124
// Now define a Reliable transport as either tcp or utp
2225
var Reliable = Or(TCP, UTP)
2326

patterns_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ func TestBasicMatching(t *testing.T) {
110110
assertMatches(t, Reliable, good_utp, good_tcp)
111111
assertMismatches(t, Reliable, good_ip, good_udp, good_ipfs)
112112

113+
assertMatches(t, Unreliable, good_udp)
114+
assertMismatches(t, Unreliable, good_ip, good_tcp, good_utp, good_ipfs)
115+
113116
assertMatches(t, IPFS, good_ipfs)
114117
assertMismatches(t, IPFS, bad_ipfs, good_ip, good_tcp, good_utp, good_udp)
115118
}

0 commit comments

Comments
 (0)