portlist

package
v0.0.0-...-4bddf58 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package portlist provides functionality to fetch open ports in the current machine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type List

type List []Port

List is a list of Ports.

func (List) String

func (pl List) String() string

type Option

type Option func(cfg *config)

Option is used to configure the Poller.

func WithIncludeLocalhost

func WithIncludeLocalhost(includeLocalhost bool) Option

WithIncludeLocalhost allows to include/exclude localhost ports (false by default).

func WithProcMountPoint

func WithProcMountPoint(mountPoint string) Option

WithProcMountPoint allows to change the proc filesystem mount point (this is used mainly in tests).

type Poller

type Poller struct {
	// contains filtered or unexported fields
}

Poller scans the systems for listening ports.

func NewPoller

func NewPoller(opts ...Option) (*Poller, error)

NewPoller initializes a new Poller.

func (*Poller) OpenPorts

func (p *Poller) OpenPorts() (List, error)

OpenPorts returns the list of currently listening ports.

type Port

type Port struct {
	Proto   string // "tcp" or "udp"
	Port    uint16 // port number
	Process string // optional process name, if found (requires suitable permissions)
	Pid     int    // process ID, if known (requires suitable permissions)
}

Port is a listening port on the machine.

Jump to

Keyboard shortcuts

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