stun

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2016 License: Apache-2.0, Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

go-stun is a STUN (RFC 3489 and RFC 5389) client implementation in golang.

It is extremely easy to use -- just one line of code.

nat, host, err := stun.NewClient().Discover()

More details please go to `example.go`.

Index

Constants

View Source
const (
	DefaultServerHost   = "stun1.voiceeclipse.net"
	DefaultServerPort   = 3478
	DefaultSoftwareName = "StunClient"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	LocalAddr string
	LocalPort int16
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) Discover

func (c *Client) Discover() (NATType, *Host, error)

Discover contacts the STUN server and gets the response of NAT type, host for UDP punching.

func (*Client) ServerAddr

func (c *Client) ServerAddr() string

func (*Client) SetServerAddr

func (c *Client) SetServerAddr(address string)

SetServerAddr allows user to set the transport layer STUN server address.

func (*Client) SetServerHost

func (c *Client) SetServerHost(host string, port int) error

SetServerHost allows user to set the STUN hostname and port.

func (*Client) SetSoftwareName

func (c *Client) SetSoftwareName(name string)

SetSoftwareName allows user to set the name of the software, which is used for logging purpose (NOT used in the current implementation).

func (*Client) SoftwareName

func (c *Client) SoftwareName() string

type Host

type Host struct {
	// contains filtered or unexported fields
}

func (*Host) Family

func (h *Host) Family() uint16

func (*Host) IP

func (h *Host) IP() string

func (*Host) Port

func (h *Host) Port() uint16

func (*Host) TransportAddr

func (h *Host) TransportAddr() string

type NATType

type NATType int
const (
	NAT_ERROR NATType = iota
	NAT_UNKNOWN
	NAT_NONE
	NAT_BLOCKED
	NAT_FULL
	NAT_SYMETRIC
	NAT_RESTRICTED
	NAT_PORT_RESTRICTED
	NAT_SYMETRIC_UDP_FIREWALL
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL