|
|
|
@ -16,9 +16,6 @@ type PortRange struct {
|
|
|
|
|
First, Last uint16 // inclusive
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PortRangeAny represents all TCP and UDP ports.
|
|
|
|
|
var PortRangeAny = PortRange{0, 65535}
|
|
|
|
|
|
|
|
|
|
func (pr PortRange) String() string {
|
|
|
|
|
if pr.First == 0 && pr.Last == 65535 {
|
|
|
|
|
return "*"
|
|
|
|
@ -34,10 +31,6 @@ func (pr PortRange) contains(port uint16) bool {
|
|
|
|
|
return port >= pr.First && port <= pr.Last
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NetAny matches all IP addresses.
|
|
|
|
|
// TODO: add ipv6.
|
|
|
|
|
var NetAny = []netaddr.IPPrefix{{IP: netaddr.IPv4(0, 0, 0, 0), Bits: 0}}
|
|
|
|
|
|
|
|
|
|
// NetPortRange combines an IP address prefix and PortRange.
|
|
|
|
|
type NetPortRange struct {
|
|
|
|
|
Net netaddr.IPPrefix
|
|
|
|
@ -48,9 +41,6 @@ func (npr NetPortRange) String() string {
|
|
|
|
|
return fmt.Sprintf("%v:%v", npr.Net, npr.Ports)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// NetPortRangeAny matches any IP and port.
|
|
|
|
|
var NetPortRangeAny = []NetPortRange{{Net: NetAny[0], Ports: PortRangeAny}}
|
|
|
|
|
|
|
|
|
|
// Match matches packets from any IP address in Srcs to any ip:port in
|
|
|
|
|
// Dsts.
|
|
|
|
|
type Match struct {
|
|
|
|
|