mirror of
https://github.com/safing/portmaster
synced 2025-09-01 18:19:12 +00:00
Add network name reference for endpoint lists
This commit is contained in:
parent
34f2beb8d4
commit
544ede719c
2 changed files with 93 additions and 12 deletions
78
network/reference/ports.go
Normal file
78
network/reference/ports.go
Normal file
|
@ -0,0 +1,78 @@
|
|||
package reference
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
portNames = map[uint16]string{
|
||||
20: "FTP-DATA",
|
||||
21: "FTP",
|
||||
22: "SSH",
|
||||
23: "TELNET",
|
||||
25: "SMTP",
|
||||
43: "WHOIS",
|
||||
53: "DNS",
|
||||
67: "DHCP-SERVER",
|
||||
68: "DHCP-CLIENT",
|
||||
69: "TFTP",
|
||||
80: "HTTP",
|
||||
110: "POP3",
|
||||
123: "NTP",
|
||||
143: "IMAP",
|
||||
161: "SNMP",
|
||||
179: "BGP",
|
||||
194: "IRC",
|
||||
389: "LDAP",
|
||||
443: "HTTPS",
|
||||
587: "SMTP-ALT",
|
||||
465: "SMTP-SSL",
|
||||
993: "IMAP-SSL",
|
||||
995: "POP3-SSL",
|
||||
}
|
||||
|
||||
portNumbers = map[string]uint16{
|
||||
"FTP-DATA": 20,
|
||||
"FTP": 21,
|
||||
"SSH": 22,
|
||||
"TELNET": 23,
|
||||
"SMTP": 25,
|
||||
"WHOIS": 43,
|
||||
"DNS": 53,
|
||||
"DHCP-SERVER": 67,
|
||||
"DHCP-CLIENT": 68,
|
||||
"TFTP": 69,
|
||||
"HTTP": 80,
|
||||
"POP3": 110,
|
||||
"NTP": 123,
|
||||
"IMAP": 143,
|
||||
"SNMP": 161,
|
||||
"BGP": 179,
|
||||
"IRC": 194,
|
||||
"LDAP": 389,
|
||||
"HTTPS": 443,
|
||||
"SMTP-ALT": 587,
|
||||
"SMTP-SSL": 465,
|
||||
"IMAP-SSL": 993,
|
||||
"POP3-SSL": 995,
|
||||
}
|
||||
)
|
||||
|
||||
// GetPortName returns the name of a port number.
|
||||
func GetPortName(port uint16) (name string) {
|
||||
name, ok := portNames[port]
|
||||
if ok {
|
||||
return name
|
||||
}
|
||||
return strconv.Itoa(int(port))
|
||||
}
|
||||
|
||||
// GetPortNumber returns the number of a port name.
|
||||
func GetPortNumber(port string) (number uint16, ok bool) {
|
||||
number, ok = portNumbers[strings.ToUpper(port)]
|
||||
if ok {
|
||||
return number, true
|
||||
}
|
||||
return 0, false
|
||||
}
|
|
@ -1,6 +1,9 @@
|
|||
package reference
|
||||
|
||||
import "strconv"
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
protocolNames = map[uint8]string{
|
||||
|
@ -9,20 +12,20 @@ var (
|
|||
6: "TCP",
|
||||
17: "UDP",
|
||||
27: "RDP",
|
||||
58: "ICMPv6",
|
||||
58: "ICMP6",
|
||||
33: "DCCP",
|
||||
136: "UDPLite",
|
||||
136: "UDP-LITE",
|
||||
}
|
||||
|
||||
protocolNumbers = map[string]uint8{
|
||||
"ICMP": 1,
|
||||
"IGMP": 2,
|
||||
"TCP": 6,
|
||||
"UDP": 17,
|
||||
"RDP": 27,
|
||||
"DCCP": 33,
|
||||
"ICMPv6": 58,
|
||||
"UDPLite": 136,
|
||||
"ICMP": 1,
|
||||
"IGMP": 2,
|
||||
"TCP": 6,
|
||||
"UDP": 17,
|
||||
"RDP": 27,
|
||||
"DCCP": 33,
|
||||
"ICMP6": 58,
|
||||
"UDP-LITE": 136,
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -37,7 +40,7 @@ func GetProtocolName(protocol uint8) (name string) {
|
|||
|
||||
// GetProtocolNumber returns the number of a IP protocol name.
|
||||
func GetProtocolNumber(protocol string) (number uint8, ok bool) {
|
||||
number, ok = protocolNumbers[protocol]
|
||||
number, ok = protocolNumbers[strings.ToUpper(protocol)]
|
||||
if ok {
|
||||
return number, true
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue