nat

package
v0.0.0-...-129a086 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(provider DiscoverFunc)

Types

type Address

type Address struct {
	IP   net.IP
	Port int
}

Address is essentially net.TCPAddr yet is more general, and has a few helper methods which reduce boilerplate code.

func (Address) Equal

func (a Address) Equal(b Address) bool

func (Address) GoString

func (a Address) GoString() string

func (Address) String

func (a Address) String() string

type Device

type Device interface {
	ID() string
	GetLocalIPAddress() net.IP
	AddPortMapping(ctx context.Context, protocol Protocol, internalPort, externalPort int, description string, duration time.Duration) (int, error)
	GetExternalIPAddress(ctx context.Context) (net.IP, error)
}

type DiscoverFunc

type DiscoverFunc func(ctx context.Context, renewal, timeout time.Duration) []Device

type Mapping

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

func (*Mapping) Address

func (m *Mapping) Address() Address

func (*Mapping) ExternalAddresses

func (m *Mapping) ExternalAddresses() []Address

func (*Mapping) GoString

func (m *Mapping) GoString() string

func (*Mapping) OnChanged

func (m *Mapping) OnChanged(subscribed MappingChangeSubscriber)

func (*Mapping) Protocol

func (m *Mapping) Protocol() Protocol

func (*Mapping) String

func (m *Mapping) String() string

type MappingChangeSubscriber

type MappingChangeSubscriber func()

type Protocol

type Protocol string
const (
	TCP Protocol = "TCP"
	UDP Protocol = "UDP"
)

type Service

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

Service runs a loop for discovery of IGDs (Internet Gateway Devices) and setup/renewal of a port mapping.

func NewService

func NewService(id protocol.DeviceID, cfg config.Wrapper) *Service

func (*Service) CommitConfiguration

func (s *Service) CommitConfiguration(_, to config.Configuration) bool

func (*Service) NewMapping

func (s *Service) NewMapping(protocol Protocol, ip net.IP, port int) *Mapping

func (*Service) RemoveMapping

func (s *Service) RemoveMapping(mapping *Mapping)

RemoveMapping does not actually remove the mapping from the IGD, it just internally removes it which stops renewing the mapping. Also, it clears any existing mapped addresses from the mapping, which as a result should cause discovery to reannounce the new addresses.

func (*Service) Serve

func (s *Service) Serve(ctx context.Context) error

func (*Service) String

func (s *Service) String() string

Jump to

Keyboard shortcuts

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