Documentation ¶
Overview ¶
Package upnp implements UPnP InternetGatewayDevice discovery, querying, and port mapping.
Index ¶
- func Discover(ctx context.Context, _, timeout time.Duration) []nat.Device
- type IGDService
- func (s *IGDService) AddPinhole(ctx context.Context, protocol nat.Protocol, intAddr nat.Address, ...) ([]net.IP, error)
- func (s *IGDService) AddPortMapping(ctx context.Context, protocol nat.Protocol, internalPort, externalPort int, ...) (int, error)
- func (s *IGDService) DeletePortMapping(ctx context.Context, protocol nat.Protocol, externalPort int) error
- func (s *IGDService) GetExternalIPv4Address(ctx context.Context) (net.IP, error)
- func (s *IGDService) GetLocalIPv4Address() net.IP
- func (s *IGDService) ID() string
- func (s *IGDService) SupportsIPVersion(version nat.IPVersion) bool
- type UnsupportedDeviceTypeError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IGDService ¶
type IGDService struct { UUID string Device upnpDevice ServiceID string URL string URN string LocalIPv4 net.IP Interface *net.Interface nat.Service }
An IGDService is a specific service provided by an IGD.
func (*IGDService) AddPinhole ¶ added in v1.27.2
func (s *IGDService) AddPinhole(ctx context.Context, protocol nat.Protocol, intAddr nat.Address, duration time.Duration) ([]net.IP, error)
AddPinhole adds an IPv6 pinhole in accordance to http://upnp.org/specs/gw/UPnP-gw-WANIPv6FirewallControl-v1-Service.pdf This is attempted for each IPv6 on the interface.
func (*IGDService) AddPortMapping ¶
func (s *IGDService) AddPortMapping(ctx context.Context, protocol nat.Protocol, internalPort, externalPort int, description string, duration time.Duration) (int, error)
AddPortMapping adds a port mapping to the specified IGD service.
func (*IGDService) DeletePortMapping ¶
func (s *IGDService) DeletePortMapping(ctx context.Context, protocol nat.Protocol, externalPort int) error
DeletePortMapping deletes a port mapping from the specified IGD service.
func (*IGDService) GetExternalIPv4Address ¶ added in v1.27.2
GetExternalIPv4Address queries the IGD service for its external IP address. Returns nil if the external IP address is invalid or undefined, along with any relevant errors
func (*IGDService) GetLocalIPv4Address ¶ added in v1.27.2
func (s *IGDService) GetLocalIPv4Address() net.IP
GetLocalIPv4Address returns local IP address used to contact this service
func (*IGDService) SupportsIPVersion ¶ added in v1.27.2
func (s *IGDService) SupportsIPVersion(version nat.IPVersion) bool
SupportsIPVersion checks whether this is a WANIPv6FirewallControl device, in which case pinholing instead of port mapping should be done
type UnsupportedDeviceTypeError ¶ added in v0.14.50
type UnsupportedDeviceTypeError struct {
// contains filtered or unexported fields
}
UnsupportedDeviceTypeError for unsupported UPnP device types (i.e upnp:rootdevice)
func (*UnsupportedDeviceTypeError) Error ¶ added in v0.14.50
func (e *UnsupportedDeviceTypeError) Error() string