Documentation ¶
Index ¶
- type AuthHandler
- type Client
- func (c *Client) Allocate() (net.PacketConn, error)
- func (c *Client) Close()
- func (c *Client) HandleInbound(data []byte, from net.Addr) (bool, error)
- func (c *Client) Listen() error
- func (c *Client) OnDeallocated(relayedAddr net.Addr)
- func (c *Client) PerformTransaction(msg *stun.Message, to net.Addr, dontWait bool) (client.TransactionResult, error)
- func (c *Client) Realm() stun.Realm
- func (c *Client) STUNServerAddr() net.Addr
- func (c *Client) SendBindingRequest() (net.Addr, error)
- func (c *Client) SendBindingRequestTo(to net.Addr) (net.Addr, error)
- func (c *Client) TURNServerAddr() net.Addr
- func (c *Client) Username() stun.Username
- func (c *Client) WriteTo(data []byte, to net.Addr) (int, error)
- type ClientConfig
- type Sender
- type Server
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthHandler ¶
AuthHandler is a callback used to handle incoming auth requests, allowing users to customize Pion TURN with custom behavior
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a STUN server client
func NewClient ¶
func NewClient(config *ClientConfig) (*Client, error)
NewClient returns a new Client instance. listeningAddress is the address and port to listen on, default "0.0.0.0:0"
func (*Client) Allocate ¶
func (c *Client) Allocate() (net.PacketConn, error)
Allocate sends a TURN allocation request to the given transport address
func (*Client) HandleInbound ¶
HandleInbound handles data received. This method handles incoming packet demultiplex it by the source address and the types of the message. This return a booleen (handled or not) and if there was an error. Caller should check if the packet was handled by this client or not. If not handled, it is assumed that the packet is application data. If an error is returned, the caller should discard the packet regardless.
func (*Client) Listen ¶
Listen will have this client start listening on the conn provided via the config. This is optional. If not used, you will need to call HandleInbound method to supply incoming data, instead.
func (*Client) OnDeallocated ¶
OnDeallocated is called when deallocation of relay address has been complete. (Called by UDPConn)
func (*Client) PerformTransaction ¶
func (c *Client) PerformTransaction(msg *stun.Message, to net.Addr, dontWait bool) (client.TransactionResult, error)
PerformTransaction performs STUN transaction
func (*Client) STUNServerAddr ¶
STUNServerAddr return the STUN server address
func (*Client) SendBindingRequest ¶
SendBindingRequest sends a new STUN request to the STUN server
func (*Client) SendBindingRequestTo ¶
SendBindingRequestTo sends a new STUN request to the given transport address
func (*Client) TURNServerAddr ¶
TURNServerAddr return the TURN server address
type ClientConfig ¶
type ClientConfig struct { STUNServerAddr string // STUN server address (e.g. "stun.abc.com:3478") TURNServerAddr string // TURN server addrees (e.g. "turn.abc.com:3478") Username string Password string Realm string Software string RTO time.Duration Conn net.PacketConn // Listening socket (net.PacketConn) LoggerFactory logging.LoggerFactory Net *vnet.Net }
ClientConfig is a bag of config parameters for Client.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an instance of the Pion TURN server
func NewServer ¶
func NewServer(config *ServerConfig) *Server
NewServer creates the Pion TURN server
func (*Server) AddExternalIPAddr ¶
AddExternalIPAddr adds a mapping to an external IP address. This is useful when the TURN server is behind a 1-to-1 NAT, or a D-NAT (which is typical when hosting on AWS EC2). The argument should be a dotted-decimal representation of external IP address. If there is more than on IP address, the argument should be a cancatenation of external IP and local IP delimited by a '/'. Ex 1: "185.199.108.153" Ex 2: "185.199.108.153/10.0.1.2" By default, no address mapping is used. This method must be called before calling Start().
func (*Server) AddListeningIPAddr ¶
AddListeningIPAddr adds a listening IP address. If not specified, it will automatically assigns the listening IP addresses from the system. This method must be called before calling Start().
func (*Server) AddRelayIPAddr ¶
AddRelayIPAddr adds a listening IP address. Note: current implementation can have only one relay IP address. If not specified, it will automatically assigns the relay IP addresses from the system. This method must be called before calling Start().
type ServerConfig ¶
type ServerConfig struct { // Realm sets the realm for this server Realm string // AuthHandler is the handler called on each incoming auth requests. AuthHandler AuthHandler // ChannelBindTimeout sets the lifetime of channel binding. Defaults to 10 minutes. ChannelBindTimeout time.Duration // ListeningPort sets the listening port number. Defaults to 3478. ListeningPort int // LoggerFactory must be set for logging from this server. LoggerFactory logging.LoggerFactory // Net is used by pion developers. Do not use in your application. Net *vnet.Net // Software is the STUN SOFTWARE attribute. Useful for debugging purpose. Software string // Sender is a custom implementation of the request Sender. Sender Sender }
ServerConfig is a bag of config parameters for Server.