gateway

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0 Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gateway implements bounded, egress-bound gateway control protocols.

Index

Constants

View Source
const (
	WANIPv1         = "urn:schemas-upnp-org:service:WANIPConnection:1"
	WANIPv2         = "urn:schemas-upnp-org:service:WANIPConnection:2"
	WANPPP          = "urn:schemas-upnp-org:service:WANPPPConnection:1"
	WANIPv6Firewall = "urn:schemas-upnp-org:service:WANIPv6FirewallControl:1"
)
View Source
const MaxDHCPWorkers = 2
View Source
const MaxDiscoveryEntries = 16
View Source
const MaxPCPServerAddresses = 8
View Source
const MaxPCPServers = 8

Variables

This section is empty.

Functions

func DatagramExchange

func DatagramExchange(ctx context.Context, local netip.Addr, server netip.AddrPort, request []byte) ([]byte, error)

DatagramExchange uses a connected UDP socket so replies from a different gateway/source port cannot be mistaken for a control response.

func Defaults

func Defaults(snapshot networkstate.Snapshot) []r.Gateway

Defaults uses only OS-reported default routers. DHCP/configured PCP groups can replace this fallback using DiscoverPCP; nothing scans guessed subnets.

func EgressID

func EgressID(index int) string

Types

type AutoUPnP

type AutoUPnP struct {
	Gateway      netip.Addr
	Egress       string
	ControlLocal netip.Addr
	Discover     func(context.Context, netip.Addr, netip.Addr, string) ([]Service, error)
	HTTP         HTTPDo
}

func (*AutoUPnP) Create

func (a *AutoUPnP) Create(ctx context.Context, request r.Request) (r.Lease, error)

func (*AutoUPnP) Delete

func (a *AutoUPnP) Delete(ctx context.Context, request r.Request, lease r.Lease) error

func (*AutoUPnP) Renew

func (a *AutoUPnP) Renew(ctx context.Context, request r.Request, lease r.Lease) (r.Lease, error)

type DHCPOptions

type DHCPOptions struct {
	V4 []byte
	V6 [][]byte
}

type DHCPSource

type DHCPSource interface {
	Acquire(context.Context, networkstate.Address) (DHCPOptions, error)
}

type Discovery

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

Discovery belongs to the process, not an attempt. A blocking OS DHCP call retains its capacity slot until the call really returns, even after retirement.

func NewDiscovery

func NewDiscovery(source DHCPSource) *Discovery

func (*Discovery) Changes

func (d *Discovery) Changes() <-chan struct{}

func (*Discovery) Close

func (d *Discovery) Close()

func (*Discovery) Gateways

func (d *Discovery) Gateways(snapshot networkstate.Snapshot) []r.Gateway

type Exchange

type Exchange func(context.Context, netip.Addr, netip.AddrPort, []byte) ([]byte, error)

type HTTPDo

type HTTPDo func(*http.Request) (*http.Response, error)

type NATPMP

type NATPMP struct {
	Server   netip.AddrPort
	Egress   string
	Exchange Exchange
}

func (*NATPMP) Create

func (p *NATPMP) Create(ctx context.Context, request r.Request) (r.Lease, error)

func (*NATPMP) Delete

func (p *NATPMP) Delete(ctx context.Context, request r.Request, lease r.Lease) error

func (*NATPMP) Renew

func (p *NATPMP) Renew(ctx context.Context, request r.Request, lease r.Lease) (r.Lease, error)

type PCP

type PCP struct {
	Server   netip.AddrPort
	Egress   string
	Exchange Exchange
	Nonce    func([]byte) (int, error)
}

func (*PCP) Create

func (p *PCP) Create(ctx context.Context, request r.Request) (r.Lease, error)

func (*PCP) Delete

func (p *PCP) Delete(ctx context.Context, request r.Request, lease r.Lease) error

func (*PCP) Renew

func (p *PCP) Renew(ctx context.Context, request r.Request, lease r.Lease) (r.Lease, error)

type PCPDiscovery

type PCPDiscovery struct {
	Configured     []PCPServer
	DHCPv4         []byte
	DHCPv6         [][]byte
	DefaultRouters []netip.Addr
	Egress         string
}

type PCPServer

type PCPServer struct {
	Egress    string
	Addresses []netip.Addr
}

Each group is one logical PCP server; addresses inside it are alternatives. Multiple groups are independent servers and must never be flattened together.

func DiscoverPCP

func DiscoverPCP(input PCPDiscovery) ([]PCPServer, error)

type Service

type Service struct {
	URL          string
	Type         string
	Gateway      netip.Addr
	Egress       string
	ControlLocal netip.Addr
}

func DiscoverUPnP

func DiscoverUPnP(ctx context.Context, local, gateway netip.Addr, egress string) ([]Service, error)

func ParseDescription

func ParseDescription(reader io.Reader, location string, gateway netip.Addr, egress string) ([]Service, error)

type SystemDHCPSource

type SystemDHCPSource struct{}

func (SystemDHCPSource) Acquire

No portable OS DHCP cache API exposes repeated RFC7291 options. Unsupported platforms retain the standard default-router fallback and configured sources.

type UPnP

type UPnP struct {
	Service Service
	HTTP    HTTPDo
}

func (*UPnP) Create

func (u *UPnP) Create(ctx context.Context, request r.Request) (r.Lease, error)

func (*UPnP) Delete

func (u *UPnP) Delete(ctx context.Context, request r.Request, lease r.Lease) error

func (*UPnP) Renew

func (u *UPnP) Renew(ctx context.Context, request r.Request, lease r.Lease) (r.Lease, error)

Jump to

Keyboard shortcuts

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