portmappertype
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package portmappertype defines the net/portmapper interface, which may or may not belinked into the binary.
Index¶
Constants¶
This section is empty.
Variables¶
var (ErrNoPortMappingServices =errors.New("no port mapping services were found")ErrGatewayRange =errors.New("skipping portmap; gateway range likely lacks support")ErrGatewayIPv6 =errors.New("skipping portmap; no IPv6 support for portmapping")ErrPortMappingDisabled =errors.New("port mapping is disabled"))
var HookNewPortMapperfeature.Hook[func(logflogger.Logf,bus *eventbus.Bus,netMon *netmon.Monitor,disableUPnPOrNil,onlyTCP443OrNil func()bool)Client]
HookNewPortMapper is a hook to install the portmapper creation function.It must be set by an init function when buildfeatures.HasPortmapper is true.
Functions¶
This section is empty.
Types¶
typeClient¶
type Client interface {// Probe returns a summary of which port mapping services are available on// the network.//// If a probe has run recently and there haven't been any network changes// since, the returned result might be server from the Client's cache,// without sending any network traffic.Probe(context.Context) (ProbeResult,error)// HaveMapping reports whether we have a current valid mapping.HaveMapping()bool// SetGatewayLookupFunc set the func that returns the machine's default// gateway IP, and the primary IP address for that gateway. It must be// called before the client is used. If not called,// interfaces.LikelyHomeRouterIP is used.SetGatewayLookupFunc(f func() (gw, myIPnetip.Addr, okbool))// NoteNetworkDown should be called when the network has transitioned to a down state.// It's too late to release port mappings at this point (the user might've just turned off// their wifi), but we can make sure we invalidate mappings for later when the network// comes back.NoteNetworkDown()// GetCachedMappingOrStartCreatingOne quickly returns with our current cached portmapping, if any.// If there's not one, it starts up a background goroutine to create one.// If the background goroutine ends up creating one, the onChange hook registered with the// NewClient constructor (if any) will fire.GetCachedMappingOrStartCreatingOne() (externalnetip.AddrPort, okbool)// SetLocalPort updates the local port number to which we want to port// map UDP trafficSetLocalPort(localPortuint16)Close()error}Client is the interface implemented by a portmapper client.
typeProbeResult¶
ProbeResult is the result of a portmapper probe, sayingwhich port mapping protocols were discovered.