network

package
v0.0.0-...-8ff1004 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortPortRanges

func SortPortRanges(portRanges []PortRange)

SortPortRanges sorts the given ports, first by protocol, then by number.

Types

type Port

type Port struct {
	Protocol string
	Number   int
}

Port identifies a network port number for a particular protocol.

NOTE(dimitern): This is deprecated and should be removed, use PortRange instead. There are a few places which still use Port, especially in apiserver/params, so it can't be removed yet.

func (Port) GoString

func (p Port) GoString() string

GoString implements fmt.GoStringer.

func (Port) String

func (p Port) String() string

String implements Stringer.

type PortRange

type PortRange struct {
	FromPort int
	ToPort   int
	Protocol string
}

PortRange represents a single range of ports.

func CollapsePorts

func CollapsePorts(ports []Port) (result []PortRange)

CollapsePorts collapses a slice of ports into port ranges.

NOTE(dimitern): This is deprecated and should be removed when possible. It still exists, because in a few places slices of Ports are converted to PortRanges internally.

func CombinePortRanges

func CombinePortRanges(ranges ...PortRange) []PortRange

CombinePortRanges groups together all port ranges according to protocol, and then combines then into contiguous port ranges. NOTE: Juju only allows its model to contain non-overlapping port ranges. This method operates on that assumption.

func MustParsePortRange

func MustParsePortRange(portRange string) PortRange

MustParsePortRange converts a raw port-range string into a PortRange. If the string is invalid, the function panics.

func ParsePortRange

func ParsePortRange(inPortRange string) (PortRange, error)

ParsePortRange builds a PortRange from the provided string. If the string does not include a protocol then "tcp" is used. Validate() gets called on the result before returning. If validation fails the invalid PortRange is still returned. Example strings: "80/tcp", "443", "12345-12349/udp", "icmp".

func (PortRange) ConflictsWith

func (a PortRange) ConflictsWith(b PortRange) bool

ConflictsWith determines if the two port ranges conflict.

func (PortRange) GoString

func (p PortRange) GoString() string

func (PortRange) String

func (p PortRange) String() string

func (PortRange) Validate

func (p PortRange) Validate() error

IsValid determines if the port range is valid.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL