Documentation
¶
Index ¶
- Constants
- Variables
- type Action
- type Client
- func (c *Client) AddPeerMapping(protocol Protocol, internalPort, requestedExternalPort, remotePort uint16, ...) (err error)
- func (c *Client) AddPortMapping(protocol Protocol, internalPort, requestedExternalPort uint16, ...) (err error)
- func (c *Client) Announce() (err error)
- func (c *Client) Close()
- func (c *Client) DeletePeerMapping(internalPort uint16) (err error)
- func (c *Client) DeletePortMapping(internalPort uint16) (err error)
- func (c *Client) GetExternalAddress() (addr net.IP, err error)
- func (c *Client) GetGatewayAddress() (addr net.IP, err error)
- func (c *Client) GetInternalAddress() (addr net.IP, err error)
- func (c *Client) RefreshPeerMapping(internalPort uint16, lifetime uint32) (err error)
- func (c *Client) RefreshPortMapping(internalPort uint16, lifetime uint32) (err error)
- type ClientEpoch
- type Event
- type OpCode
- type OpDataMap
- type OpDataPeer
- type OptionOpCode
- type PCPOption
- type PeerMap
- type PortMap
- type Protocol
- type RefreshTime
- type RequestPacket
- type ResponsePacket
- type ResultCode
Constants ¶
const ( ActionReceivedAnnounce = iota ActionReceivedMapping ActionReceivedPeer ActionClose )
Not the greatest naming, but will do for now.
const (
DefaultLifetimeSeconds = 3600
)
Variables ¶
var ( ErrNoInternalAddress = errors.New("no internal address") ErrNoExternalAddress = errors.New("no external address") ErrGatewayNotFound = errors.New("gateway not found") ErrPacketTooLarge = errors.New("packet exceeds 1100 octet size limit") ErrUnsupportedVersion = errors.New("the specified version is not supported") ErrWrongPacketType = errors.New("the packet is not of the correct type") ErrAddressMismatch = errors.New("the sender and gateway addresses do not match") ErrPortNotSpecified = errors.New("you must specify a port") ErrNonceGeneration = errors.New("an error occured whilst generating nonce") ErrMapDataPayload = errors.New("could not create the map data payload") ErrPeerDataPayload = errors.New("could not create the peer data payload") ErrRequestDataPayload = errors.New("could not create the request data payload") ErrNetworkSend = errors.New("an error occured whilst sending the network request") ErrNetworkTimeout = errors.New("the connection timed out") ErrMappingNotFound = errors.New("mapping not found") ErrNoAddress = errors.New("no address specified") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
GatewayAddr net.IP
Event chan Event
Mappings map[uint16]PortMap
PeerMappings map[uint16]PeerMap
// contains filtered or unexported fields
}
func (*Client) AddPeerMapping ¶
func (*Client) AddPortMapping ¶
func (c *Client) AddPortMapping(protocol Protocol, internalPort, requestedExternalPort uint16, requestedAddr net.IP, lifetime uint32) (err error)
Need to add support for PCP options later.
func (*Client) Close ¶
func (c *Client) Close()
Closes connection to PCP server and returns close event
func (*Client) DeletePeerMapping ¶
func (*Client) DeletePortMapping ¶
func (*Client) RefreshPeerMapping ¶
type ClientEpoch ¶
type ClientEpoch struct {
// contains filtered or unexported fields
}
type OptionOpCode ¶
type OptionOpCode uint8
const ( OptionOpReserved OptionOpCode = iota OptionOpThirdParty OptionOpPreferFailure OptionOpFilter OptionOpNonce OptionOpAuthenticationTag OptionOpPaAuthenticationTag OptionOpEapPayload OptionOpPrf OptionOpMacAlgorithm OptionOpSessionLifetime OptionOpReceivedPak OptionOpIdIndicator OptionOpThirdPartyId )
func (OptionOpCode) String ¶
func (o OptionOpCode) String() string
type Protocol ¶
type Protocol uint8
At a later date it would be worth integrating with the IANA package to be fully compliant. For now, just implement common protocols
type RefreshTime ¶
Potentially add in progress bool
type RequestPacket ¶
type RequestPacket struct {
// contains filtered or unexported fields
}
type ResponsePacket ¶
type ResponsePacket struct {
// contains filtered or unexported fields
}
type ResultCode ¶
type ResultCode uint8
const ( ResultSuccess ResultCode = iota ResultUnsupportedVersion ResultNotAuthorised ResultMalformedRequest ResultUnsupportedOpcode ResultUnsupportedOption ResultMalformedOption ResultNetworkFailure ResultNoResources ResultUnsupportedProtocol ResultUserExceededQuota ResultCannotProvideExternal ResultAddressMismatch ResultExcessiveRemotePeers )
func (ResultCode) String ¶
func (r ResultCode) String() string