From 343bfc3e0a60932b00ed7dac934c3c9e7cefcf93 Mon Sep 17 00:00:00 2001 From: Toby Date: Wed, 11 May 2022 17:43:25 -0700 Subject: [PATCH] feat: protocol port aliases --- pkg/acl/entry.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/acl/entry.go b/pkg/acl/entry.go index db23128..bc345aa 100644 --- a/pkg/acl/entry.go +++ b/pkg/acl/entry.go @@ -25,6 +25,22 @@ const ( ProtocolUDP ) +var protocolPortAliases = map[string]string{ + "echo": "*/7", + "ftp-data": "*/20", + "ftp": "*/21", + "ssh": "*/22", + "telnet": "*/23", + "domain": "*/53", + "dns": "*/53", + "http": "*/80", + "sftp": "*/115", + "ntp": "*/123", + "https": "*/443", + "quic": "udp/443", + "socks": "*/1080", +} + type Entry struct { Action Action ActionArg string @@ -55,6 +71,9 @@ func (m *matcherBase) MatchProtocolPort(p Protocol, port uint16) bool { } func parseProtocolPort(s string) (Protocol, uint16, error) { + if protocolPortAliases[s] != "" { + s = protocolPortAliases[s] + } if len(s) == 0 || s == "*" { return ProtocolAll, 0, nil }