Documentation ¶
Overview ¶
Package nat is a convenience package for manipulation of strings describing network ports.
Index ¶
- func ParsePort(rawPort string) (int, error)
- func ParsePortRange(ports string) (uint64, uint64, error)
- func ParsePortRangeToInt(rawPort string) (int, int, error)
- func ParsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding, error)
- func Sort(ports []Port, predicate func(i, j Port) bool)
- func SortPortMap(ports []Port, bindings PortMap)
- func SplitProtoPort(rawPort string) (string, string)
- type Port
- type PortBinding
- type PortMap
- type PortMapping
- type PortSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParsePortRange ¶
ParsePortRange parses and validates the specified string as a port-range (8000-9000)
func ParsePortRangeToInt ¶ added in v0.1.2
ParsePortRangeToInt parses the port range string and returns start/end ints
func ParsePortSpecs ¶
func ParsePortSpecs(ports []string) (map[Port]struct{}, map[Port][]PortBinding, error)
ParsePortSpecs receives port specs in the format of ip:public:private/proto and parses these in to the internal types
func Sort ¶
Sort sorts a list of ports using the provided predicate This function should compare `i` and `j`, returning true if `i` is considered to be less than `j`
func SortPortMap ¶
SortPortMap sorts the list of ports and their respected mapping. The ports will explicit HostPort will be placed first.
func SplitProtoPort ¶
SplitProtoPort splits a port in the format of proto/port
Types ¶
type Port ¶
type Port string
Port is a string containing port number and protocol in the format "80/tcp"
type PortBinding ¶
type PortBinding struct { // HostIP is the host IP Address HostIP string `json:"HostIp"` // HostPort is the host port number HostPort string }
PortBinding represents a binding between a Host IP address and a Host Port
type PortMap ¶
type PortMap map[Port][]PortBinding
PortMap is a collection of PortBinding indexed by Port
type PortMapping ¶ added in v0.2.1
type PortMapping struct { Port Port Binding PortBinding }
PortMapping is a data object mapping a Port to a PortBinding
func ParsePortSpec ¶ added in v0.2.1
func ParsePortSpec(rawPort string) ([]PortMapping, error)
ParsePortSpec parses a port specification string into a slice of PortMappings