Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stunner ¶
type Stunner struct { // Send sends a packet. // It will typically be a PacketConn.WriteTo method value. Send func([]byte, net.Addr) (int, error) // sends a packet // Endpoint is called whenever a STUN response is received. // The server is the STUN server that replied, endpoint is the ip:port // from the STUN response, and d is the duration that the STUN request // took on the wire (not including DNS lookup time. Endpoint func(server, endpoint string, d time.Duration) Servers []string // STUN servers to contact // DNSCache optionally specifies a DNSCache to use. // If nil, a DNS cache is not used. DNSCache *dnscache.Resolver // Logf optionally specifies a log function. If nil, logging is disabled. Logf func(format string, args ...interface{}) // OnlyIPv6 controls whether IPv6 is exclusively used. // If false, only IPv4 is used. There is currently no mixed mode. OnlyIPv6 bool // contains filtered or unexported fields }
Stunner sends a STUN request to several servers and handles a response.
It is designed to used on a connection owned by other code and so does not directly reference a net.Conn of any sort. Instead, the user should provide Send function to send packets, and call Receive when a new STUN response is received.
In response, a Stunner will call Endpoint with any endpoints determined for the connection. (An endpoint may be reported multiple times if multiple servers are provided.)
Click to show internal directories.
Click to hide internal directories.