Documentation
¶
Index ¶
- Constants
- Variables
- type Port
- func NewPort[PI PortInput](pi PI) (Port, error)
- func NewPortForType[PI PortInput](pi PI, pt portType) (Port, error)
- func NewPortForTypeRange[PI PortInput](pi PI, ptr *portTypeRange) (p Port, err error)
- func ParseAddress(s string) (string, Port, error)
- func ParseAddressForPortType(s string, pt portType) (string, Port, error)
- func ParseAddressForPortTypeRange(s string, ptr *portTypeRange) (address string, p Port, err error)
- type PortInput
Constants ¶
const ( System portType = iota // system or well-known ports Registered // registered ports Dynamic // dynamic, private or ephemeral ports )
const ( MaxSystem port = iota + 1023 MinRegistered )
const ( MaxRegistered port = iota + 49151 MinDynamic )
const ( MaxDynamic port = iota + 65535 Invalid )
const (
MinSystem port = iota
)
Variables ¶
var All = rangeOf(System, Dynamic)
var NonDynamic = rangeOf(System, Registered)
var NonSystem = rangeOf(Registered, Dynamic)
Functions ¶
This section is empty.
Types ¶
type Port ¶
type Port interface {
IsSet() bool
IsValid() bool
IsValidForType(portType) bool
IsValidForTypeRange(*portTypeRange) bool
Uint64() uint64
Addr(string) string
}
Port is an interface to ensure consistency - use NewPort(), NewPortForType() or NewPortForTypeRange() functions to obtain a valid Port
func NewPort ¶
NewPort returns a Port if the argument has a valid TCP/UDP port number (no limitation of port type or type range), error otherwise
func NewPortForType ¶
NewPortForType returns a Port if the argument has a valid TCP/UDP port number for the requested port type, error otherwise
func NewPortForTypeRange ¶
NewPortForTypeRange returns a Port if the argument has a valid TCP/UDP port number for the requested port type range, error otherwise
func ParseAddress ¶
ParseAddress parses the input string to validate the following:
- It has a mandatory IP address component in IPv4 dotted decimal, IPv6 or IPv4-mapped IPv6 form (see also net.ParseIP())
- It has an optional valid TCP/UDP port number (no limitation of port type or type range), separated from the address component by ':'
- If the port exists and the address is in IPv6 or IPv4-mapped IPv6 form, the address component MUST be enclosed by square brackets ('[' and ']'), e.g. "[2001:0db8:85a3::8a2e:0370:7334]:80"; in all other cases, the address component MAY be enclosed by square brackets
If all validations pass, the function returns the address component as a string and the Port; otherwise, an error is returned
func ParseAddressForPortType ¶
ParseAddressForPortType behaves like ParseAddress, only that the port validation (#2) is limited to the specified port type