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 STUNConn
- func (s *STUNConn) Close() error
- func (s *STUNConn) LocalAddr() net.Addr
- func (s *STUNConn) ReadFrom(p []byte) (n int, addr net.Addr, err error)
- func (s *STUNConn) SetDeadline(t time.Time) error
- func (s *STUNConn) SetReadDeadline(t time.Time) error
- func (s *STUNConn) SetWriteDeadline(t time.Time) error
- func (s *STUNConn) WriteTo(p []byte, addr net.Addr) (n int, err error)
- type Sender
- type Server
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthHandler ¶ added in v1.2.0
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 ¶ added in v1.2.0
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 ¶ added in v1.3.0
func (c *Client) Allocate() (net.PacketConn, error)
Allocate sends a TURN allocation request to the given transport address
func (*Client) HandleInbound ¶ added in v1.3.0
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 ¶ added in v1.3.0
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 ¶ added in v1.3.0
OnDeallocated is called when deallocation of relay address has been complete. (Called by UDPConn)
func (*Client) PerformTransaction ¶ added in v1.3.0
func (c *Client) PerformTransaction(msg *stun.Message, to net.Addr, dontWait bool) (client.TransactionResult, error)
PerformTransaction performs STUN transaction
func (*Client) STUNServerAddr ¶ added in v1.3.0
STUNServerAddr return the STUN server address
func (*Client) SendBindingRequest ¶ added in v1.3.0
SendBindingRequest sends a new STUN request to the STUN server
func (*Client) SendBindingRequestTo ¶ added in v1.3.0
SendBindingRequestTo sends a new STUN request to the given transport address
func (*Client) TURNServerAddr ¶ added in v1.3.0
TURNServerAddr return the TURN server address
type ClientConfig ¶ added in v1.2.0
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 STUNConn ¶ added in v1.4.0
type STUNConn struct {
// contains filtered or unexported fields
}
STUNConn wraps a net.Conn and implements net.PacketConn by being STUN aware and packetizing the stream
func NewSTUNConn ¶ added in v1.4.0
NewSTUNConn creates a STUNConn
func (*STUNConn) SetDeadline ¶ added in v1.4.0
SetDeadline implements SetDeadline from net.PacketConn
func (*STUNConn) SetReadDeadline ¶ added in v1.4.0
SetReadDeadline implements SetReadDeadline from net.PacketConn
func (*STUNConn) SetWriteDeadline ¶ added in v1.4.0
SetWriteDeadline implements SetWriteDeadline from net.PacketConn
type Sender ¶ added in v1.3.0
Sender is responsible for building a message and sending it to the given addr.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an instance of the Pion TURN server
func NewServer ¶ added in v1.2.0
func NewServer(config *ServerConfig) *Server
NewServer creates the Pion TURN server
func (*Server) AddExternalIPAddr ¶ added in v1.3.5
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 ¶ added in v1.2.0
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 ¶ added in v1.2.1
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 ¶ added in v1.2.0
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.