upnp

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProtocolUDP is the UDP Protocol.
	ProtocolUDP = corev1.ProtocolUDP
	// ProtocolTCP is the TCP Protocol.
	ProtocolTCP = corev1.ProtocolTCP
)

Variables

View Source
var (
	// ErrNoClients is returned when no UPnP clients are found.
	ErrNoClients = errors.New("no clients found")
)

Functions

func WithAnyConnection

func WithAnyConnection(opts *NewClientOpts)

func WithIG1WANIP1Connection1

func WithIG1WANIP1Connection1(opts *NewClientOpts)

func WithIG1WANPPP1Connection1

func WithIG1WANPPP1Connection1(opts *NewClientOpts)

func WithIG2WANIPConnection1

func WithIG2WANIPConnection1(opts *NewClientOpts)

func WithIG2WANIPConnection2

func WithIG2WANIPConnection2(opts *NewClientOpts)

func WithIG2WANPPPConnection1

func WithIG2WANPPPConnection1(opts *NewClientOpts)

Types

type Client

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

Client is a wrapper around any goupnp client to standardize the API for doing UPnP operations.

func NewClient

func NewClient(ctx context.Context, opts ...NewClientOpt) (*Client, error)

func (*Client) AddPortMapping

func (c *Client) AddPortMapping(ctx context.Context, pm *PortMapping) error

GetExternalIPAddress adds the port mapping via UPnP.

func (*Client) GetExternalIPAddress

func (c *Client) GetExternalIPAddress(ctx context.Context) (net.IP, error)

GetExternalIPAddress gets the external IP address via UPnP.

func (*Client) GetServiceIPAddress

func (c *Client) GetServiceIPAddress(context.Context) (net.IP, error)

GetServiceIPAddress gets the IP address of the router.

func (*Client) GetSourceIPAddress

func (c *Client) GetSourceIPAddress(context.Context) net.IP

GetSourceIPAddress gets the IP address of the client.

type GoUPnPClient

type GoUPnPClient interface {
	GetExternalIPAddressCtx(context.Context) (string, error)
	GetServiceClient() *goupnp.ServiceClient
	AddPortMappingCtx(
		context.Context,
		string,
		uint16,
		string,
		uint16,
		string,
		bool,
		string,
		uint32,
	) error
	DeletePortMappingCtx(
		context.Context,
		string,
		uint16,
		string,
	) error
}

type NewClientOpt

type NewClientOpt func(*NewClientOpts)

func WithGoUPnPClient

func WithGoUPnPClient(client GoUPnPClient) NewClientOpt

type NewClientOpts

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

type PortMapping

type PortMapping struct {
	RemoteHost     string
	ExternalPort   int32
	Protocol       Protocol
	InternalPort   int32
	InternalClient net.IP
	Enabled        bool
	Description    string
	LeaseDuration  time.Duration
}

PortMapping is the mapping of an external port to an internal address.

type Protocol

type Protocol corev1.Protocol

Protocol is the protocol of a port.

Jump to

Keyboard shortcuts

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