Documentation ¶
Index ¶
- func GetRandomEvenPort() (int, error)
- type Allocation
- func (a *Allocation) AddChannelBind(c *ChannelBind) error
- func (a *Allocation) AddPermission(p *Permission)
- func (a *Allocation) GetChannelByAddr(addr net.Addr) *ChannelBind
- func (a *Allocation) GetChannelByID(id uint16) *ChannelBind
- func (a *Allocation) GetPermission(addr net.Addr) *Permission
- func (a *Allocation) Refresh(lifetime uint32)
- func (a *Allocation) RemoveChannelBind(id uint16) bool
- func (a *Allocation) RemovePermission(addr net.Addr) bool
- type ChannelBind
- type FiveTuple
- type Manager
- type Permission
- type Protocol
- type ReservationManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRandomEvenPort ¶
GetRandomEvenPort returns a random un-allocated udp4 port
Types ¶
type Allocation ¶
type Allocation struct { RelayAddr net.Addr Protocol Protocol TurnSocket ipnet.PacketConn RelaySocket ipnet.PacketConn // contains filtered or unexported fields }
Allocation is tied to a FiveTuple and relays traffic use CreateAllocation and GetAllocation to operate
func (*Allocation) AddChannelBind ¶
func (a *Allocation) AddChannelBind(c *ChannelBind) error
AddChannelBind adds a new ChannelBind to the allocation, it also updates the permissions needed for this ChannelBind
func (*Allocation) AddPermission ¶
func (a *Allocation) AddPermission(p *Permission)
AddPermission adds a new permission to the allocation
func (*Allocation) GetChannelByAddr ¶
func (a *Allocation) GetChannelByAddr(addr net.Addr) *ChannelBind
GetChannelByAddr gets the ChannelBind from this allocation by net.Addr
func (*Allocation) GetChannelByID ¶
func (a *Allocation) GetChannelByID(id uint16) *ChannelBind
GetChannelByID gets the ChannelBind from this allocation by id
func (*Allocation) GetPermission ¶
func (a *Allocation) GetPermission(addr net.Addr) *Permission
GetPermission gets the Permission from the allocation
func (*Allocation) Refresh ¶
func (a *Allocation) Refresh(lifetime uint32)
Refresh updates the allocations lifetime
func (*Allocation) RemoveChannelBind ¶
func (a *Allocation) RemoveChannelBind(id uint16) bool
RemoveChannelBind removes the ChannelBind from this allocation by id
func (*Allocation) RemovePermission ¶
func (a *Allocation) RemovePermission(addr net.Addr) bool
RemovePermission removes the net.Addr from the allocation's permissions
type ChannelBind ¶
ChannelBind represents a TURN Channel https://tools.ietf.org/html/rfc5766#section-2.5
type FiveTuple ¶
FiveTuple is the combination (client IP address and port, server IP address and port, and transport protocol (currently one of UDP, TCP, or TLS)) used to communicate between the client and the server. The 5-tuple uniquely identifies this communication stream. The 5-tuple also uniquely identifies the Allocation on the server.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is used to hold active allocations
func (*Manager) CreateAllocation ¶
func (m *Manager) CreateAllocation(fiveTuple *FiveTuple, turnSocket ipnet.PacketConn, requestedPort int, lifetime uint32) (*Allocation, error)
CreateAllocation creates a new allocation and starts relaying
func (*Manager) DeleteAllocation ¶
DeleteAllocation removes an allocation
func (*Manager) GetAllocation ¶
func (m *Manager) GetAllocation(fiveTuple *FiveTuple) *Allocation
GetAllocation fetches the allocation matching the passed FiveTuple
type Permission ¶
Permission represents a TURN permission. TURN permissions mimic the address-restricted filtering mechanism of NATs that comply with [RFC4787]. https://tools.ietf.org/html/rfc5766#section-2.3
type ReservationManager ¶
type ReservationManager struct {
// contains filtered or unexported fields
}
ReservationManager is used to manage reservations
func (*ReservationManager) CreateReservation ¶
func (m *ReservationManager) CreateReservation(reservationToken string, port int)
CreateReservation stores the reservation for the token+port
func (*ReservationManager) GetReservation ¶
func (m *ReservationManager) GetReservation(reservationToken string) (int, bool)
GetReservation returns the port for a given reservation if it exists