Documentation ¶
Overview ¶
Package ice implements the Interactive Connectivity Establishment (ICE) protocol defined in rfc5245.
Index ¶
- Constants
- Variables
- type Agent
- func (a *Agent) AddLocalCandidate(c Candidate)
- func (a *Agent) AddRemoteCandidate(c Candidate)
- func (a *Agent) Close()
- func (a *Agent) HandleInbound(buf []byte, local *stun.TransportAddr, remote *net.UDPAddr)
- func (a *Agent) SelectedPair() (local *stun.TransportAddr, remote *net.UDPAddr)
- func (a *Agent) Start(isControlling bool, remoteUfrag, remotePwd string) error
- type Candidate
- type CandidateBase
- type CandidateHost
- type CandidatePair
- type CandidateSrflx
- type ConnectionState
- type GatheringState
- type ProtoType
- type SchemeType
- type URL
Constants ¶
const ( HostCandidatePreference uint16 = 126 SrflxCandidatePreference uint16 = 100 )
Preference enums when generate Priority
const ( // ConnectionStateNew ICE agent is gathering addresses ConnectionStateNew = iota + 1 // ConnectionStateChecking ICE agent has been given local and remote candidates, and is attempting to find a match ConnectionStateChecking // ConnectionStateConnected ICE agent has a pairing, but is still checking other pairs ConnectionStateConnected // ConnectionStateCompleted ICE agent has finished ConnectionStateCompleted // ConnectionStateFailed ICE agent never could successfully connect ConnectionStateFailed // ConnectionStateDisconnected ICE agent connected successfully, but has entered a failed state ConnectionStateDisconnected // ConnectionStateClosed ICE agent has finished and is no longer handling requests ConnectionStateClosed )
List of supported States
const Unknown = iota
Unknown defines default public constant to use for "enum" like struct comparisons when no value was defined.
Variables ¶
var ( // ErrUnknownType indicates an error with Unknown info. ErrUnknownType = errors.New("Unknown") // ErrSchemeType indicates the scheme type could not be parsed. ErrSchemeType = errors.New("unknown scheme type") // ErrSTUNQuery indicates query arguments are provided in a STUN URL. ErrSTUNQuery = errors.New("queries not supported in stun address") // ErrInvalidQuery indicates an malformed query is provided. ErrInvalidQuery = errors.New("invalid query") // ErrHost indicates malformed hostname is provided. ErrHost = errors.New("invalid hostname") // ErrPort indicates malformed port is provided. ErrPort = errors.New("invalid port") // ErrProtoType indicates an unsupported transport type was provided. ErrProtoType = errors.New("invalid transport protocol type") )
Functions ¶
This section is empty.
Types ¶
type Agent ¶ added in v1.1.0
type Agent struct { sync.RWMutex LocalUfrag string LocalPwd string LocalCandidates []Candidate // contains filtered or unexported fields }
Agent represents the ICE agent
func NewAgent ¶ added in v1.1.0
func NewAgent(notifier func(ConnectionState)) *Agent
NewAgent creates a new Agent
func (*Agent) AddLocalCandidate ¶ added in v1.1.0
AddLocalCandidate adds a new local candidate
func (*Agent) AddRemoteCandidate ¶ added in v1.1.0
AddRemoteCandidate adds a new remote candidate
func (*Agent) HandleInbound ¶ added in v1.1.0
HandleInbound processes traffic from a remote candidate
func (*Agent) SelectedPair ¶ added in v1.1.0
func (a *Agent) SelectedPair() (local *stun.TransportAddr, remote *net.UDPAddr)
SelectedPair gets the current selected pair's Addresses (or returns nil)
type Candidate ¶ added in v1.1.0
type Candidate interface { GetBase() *CandidateBase String() string }
Candidate represents an ICE candidate
type CandidateBase ¶ added in v1.1.0
type CandidateBase struct { Protocol ProtoType Address string Port int LastSent time.Time LastReceived time.Time Conn *ipv4.PacketConn // TODO: make private }
CandidateBase represents an ICE candidate, a base with enough attributes for host candidates, see CandidateSrflx and CandidateRelay for more
type CandidateHost ¶ added in v1.1.0
type CandidateHost struct {
CandidateBase
}
CandidateHost is a Candidate of typ Host
func (*CandidateHost) Address ¶ added in v1.1.0
func (c *CandidateHost) Address() string
Address for CandidateHost
func (*CandidateHost) GetBase ¶ added in v1.1.0
func (c *CandidateHost) GetBase() *CandidateBase
GetBase returns the CandidateBase, attributes shared between all Candidates
func (*CandidateHost) Port ¶ added in v1.1.0
func (c *CandidateHost) Port() int
Port for CandidateHost
func (*CandidateHost) String ¶ added in v1.1.1
func (c *CandidateHost) String() string
String makes the CandidateHost printable
type CandidatePair ¶ added in v1.1.0
type CandidatePair struct {
// contains filtered or unexported fields
}
CandidatePair represents a combination of a local and remote candidate
type CandidateSrflx ¶ added in v1.1.0
type CandidateSrflx struct { CandidateBase RemoteAddress string RemotePort int }
CandidateSrflx is a Candidate of typ Server-Reflexive
func (*CandidateSrflx) GetBase ¶ added in v1.1.0
func (c *CandidateSrflx) GetBase() *CandidateBase
GetBase returns the CandidateBase, attributes shared between all Candidates
func (*CandidateSrflx) String ¶ added in v1.1.1
func (c *CandidateSrflx) String() string
String makes the CandidateSrflx printable
type ConnectionState ¶
type ConnectionState int
ConnectionState is an enum showing the state of a ICE Connection
func (ConnectionState) String ¶
func (c ConnectionState) String() string
type GatheringState ¶ added in v1.1.0
type GatheringState int
GatheringState describes the state of the candidate gathering process
const ( // GatheringStateNew indicates candidate gatering is not yet started GatheringStateNew GatheringState = iota + 1 // GatheringStateGathering indicates candidate gatering is ongoing GatheringStateGathering // GatheringStateComplete indicates candidate gatering has been completed GatheringStateComplete )
func (GatheringState) String ¶ added in v1.1.0
func (t GatheringState) String() string
type ProtoType ¶ added in v1.1.0
type ProtoType int
ProtoType indicates the transport protocol type that is used in the ice.URL structure.
func NewProtoType ¶ added in v1.1.0
NewProtoType defines a procedure for creating a new ProtoType from a raw string naming the transport protocol type.
type SchemeType ¶ added in v1.1.0
type SchemeType int
SchemeType indicates the type of server used in the ice.URL structure.
const ( // SchemeTypeSTUN indicates the URL represents a STUN server. SchemeTypeSTUN SchemeType = iota + 1 // SchemeTypeSTUNS indicates the URL represents a STUNS (secure) server. SchemeTypeSTUNS // SchemeTypeTURN indicates the URL represents a TURN server. SchemeTypeTURN // SchemeTypeTURNS indicates the URL represents a TURNS (secure) server. SchemeTypeTURNS )
func NewSchemeType ¶ added in v1.1.0
func NewSchemeType(raw string) SchemeType
NewSchemeType defines a procedure for creating a new SchemeType from a raw string naming the scheme type.
func (SchemeType) String ¶ added in v1.1.0
func (t SchemeType) String() string
type URL ¶ added in v1.1.0
type URL struct { Scheme SchemeType Host string Port int Proto ProtoType }
URL represents a STUN (rfc7064) or TURN (rfc7065) URL
func ParseURL ¶ added in v1.1.0
ParseURL parses a STUN or TURN urls following the ABNF syntax described in https://tools.ietf.org/html/rfc7064 and https://tools.ietf.org/html/rfc7065 respectively.