Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions patterns.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ var TCP = And(IP, Base(ma.P_TCP))
// Define UDP as 'udp' on top of either ipv4 or ipv6
var UDP = And(IP, Base(ma.P_UDP))

// Define DTLS as 'dtls' on top of udp (on top of ipv4 or ipv6)
var DTLS = And(UDP, Base(ma.P_DTLS))

// Define UTP as 'utp' on top of udp (on top of ipv4 or ipv6)
var UTP = And(UDP, Base(ma.P_UTP))

Expand Down
14 changes: 14 additions & 0 deletions patterns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ func TestBasicMatching(t *testing.T) {
"/ip6/::/udp/0",
}

good_dtls := []string{
"/ip4/0.0.7.6/udp/1234/dtls",
"/ip6/::/udp/0/dtls",
}

bad_dtls := []string{
"/ip4/0.0.0.0/tcp/12345/dtls",
"/ip6/1.2.3.4/ip4/0.0.0.0/udp/1234/dtls",
"/dtls",
}

bad_udp := []string{
"/udp/12345",
"/ip6/fc00::/tcp/5523/udp/9543",
Expand Down Expand Up @@ -115,6 +126,9 @@ func TestBasicMatching(t *testing.T) {
assertMatches(t, UDP, good_udp)
assertMismatches(t, UDP, bad_udp, good_ip, good_tcp, good_ipfs, good_utp, good_quic)

assertMatches(t, DTLS, good_dtls)
assertMismatches(t, DTLS, bad_dtls, good_udp, good_ip, good_tcp, good_ipfs, good_utp, good_quic)

assertMatches(t, UTP, good_utp)
assertMismatches(t, UTP, bad_utp, good_ip, good_tcp, good_udp, good_quic)

Expand Down