...

Package port

Overview ▾

func CheckAppPortsListening

func CheckAppPortsListening(
    ctx context.Context,
    execClient exec.Client,
    podName string,
    containerPortMapping map[string][]int,
    timeout time.Duration,
) error

CheckAppPortsListening checks whether all the specified ports are really opened and in LISTEN mode in each corresponding container of the pod specified. It does so by periodically looking inside the container for listening connections until it finds each of the specified ports, or until the specified timeout has elapsed.

func DetectRemotePortsBoundOnLoopback

func DetectRemotePortsBoundOnLoopback(ctx context.Context, execClient exec.Client, podName string, containerName string, ports []api.ForwardedPort) ([]api.ForwardedPort, error)

DetectRemotePortsBoundOnLoopback filters the given ports by returning only those that are actually bound to the loopback interface in the specified container.

type Connection

type Connection struct {
    LocalAddress  string
    LocalPort     int
    RemoteAddress string
    RemotePort    int
    State         string
}

func GetConnections

func GetConnections(ctx context.Context, execClient exec.Client, podName string, containerName string, statePredicate func(state int) bool) ([]Connection, error)

GetConnections retrieves information about connections in the specified container. It works by parsing information from the /proc/net/{tcp,tcp6,udp,udp6} files, and is able to parse both IPv4 and IPv6 addresses. See https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt for more information about the structure of these files. The specified predicate allows to filter the connections based on the state.

func GetListeningConnections

func GetListeningConnections(ctx context.Context, execClient exec.Client, podName string, containerName string) ([]Connection, error)

GetListeningConnections retrieves information about ports being listened and on which local address in the specified container. It works by parsing information from the /proc/net/{tcp,tcp6,udp,udp6} files, and is able to parse both IPv4 and IPv6 addresses. See https://www.kernel.org/doc/Documentation/networking/proc_net_tcp.txt for more information about the structure of these files.

func (Connection) String

func (c Connection) String() string