Documentation ¶
Overview ¶
Package resolver provides interface (and default implementation) to retrieve public network address.
Currently there are two default implementation of resolvers:
- Using STUN server
- No-op resolver which returns socket listen address
Usage:
var conn net.PacketConn // get connection anywhere r := resolver.NewStunResolver("") // Using default stun server publicAddr, _ := r.Resolve(conn) fmt.Println(publicAddr)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PublicAddressResolver ¶
type PublicAddressResolver interface { // Resolve returns public network address from given internal address. Resolve(address string) (string, error) }
PublicAddressResolver is network address resolver interface.
func NewExactResolver ¶
func NewExactResolver() PublicAddressResolver
NewExactResolver returns new no-op resolver.
func NewFixedAddressResolver ¶ added in v0.8.4
func NewFixedAddressResolver(publicAddress string) PublicAddressResolver
Click to show internal directories.
Click to hide internal directories.