Package nat is a convenience package for manipulation of strings describing network ports.



    This section is empty.


    This section is empty.


    func ParsePort

    func ParsePort(rawPort string) (int, error)

      ParsePort parses the port number string and returns an int

      func ParsePortRange

      func ParsePortRange(ports string) (uint64, uint64, error)

        ParsePortRange parses and validates the specified string as a port-range (8000-9000)

        func ParsePortRangeToInt

        func ParsePortRangeToInt(rawPort string) (int, int, error)

          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 PartParser

            func PartParser(template, data string) (map[string]string, error)

              PartParser parses and validates the specified string (data) using the specified template e.g. ip:public:private -> DEPRECATED: do not use, this function may be removed in a future version

              func Sort

              func Sort(ports []Port, predicate func(i, j Port) bool)

                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

                func SortPortMap(ports []Port, bindings PortMap)

                  SortPortMap sorts the list of ports and their respected mapping. The ports will explicit HostPort will be placed first.

                  func SplitProtoPort

                  func SplitProtoPort(rawPort string) (string, string)

                    SplitProtoPort splits a port in the format of proto/port


                    type Port

                    type Port string

                      Port is a string containing port number and protocol in the format "80/tcp"

                      func NewPort

                      func NewPort(proto, port string) (Port, error)

                        NewPort creates a new instance of a Port given a protocol and port number or port range

                        func (Port) Int

                        func (p Port) Int() int

                          Int returns the port number of a Port as an int

                          func (Port) Port

                          func (p Port) Port() string

                            Port returns the port number of a Port

                            func (Port) Proto

                            func (p Port) Proto() string

                              Proto returns the protocol of a Port

                              func (Port) Range

                              func (p Port) Range() (int, int, error)

                                Range returns the start/end port numbers of a Port range as ints

                                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

                                    type PortMapping struct {
                                    	Port    Port
                                    	Binding PortBinding

                                      PortMapping is a data object mapping a Port to a PortBinding

                                      func ParsePortSpec

                                      func ParsePortSpec(rawPort string) ([]PortMapping, error)

                                        ParsePortSpec parses a port specification string into a slice of PortMappings

                                        type PortSet

                                        type PortSet map[Port]struct{}

                                          PortSet is a collection of structs indexed by Port