Versions in this module Expand all Collapse all v2 v2.1.20 Dec 11, 2021 v2.1.19 Dec 10, 2021 v2.1.18 Dec 9, 2021 v2.1.17 Dec 8, 2021 v2.1.16 Dec 8, 2021 Changes in this version + const CandidatePairStateFailed + const CandidatePairStateInProgress + const CandidatePairStateSucceeded + const CandidatePairStateWaiting + const ComponentRTCP + const ComponentRTP + const ConnectionStateChecking + const ConnectionStateClosed + const ConnectionStateCompleted + const ConnectionStateConnected + const ConnectionStateDisconnected + const ConnectionStateFailed + const ConnectionStateNew + const Unknown + var ErrAddressParseFailed = errors.New("failed to parse address") + var ErrCanceledByCaller = errors.New("connecting canceled by caller") + var ErrClosed = errors.New("the agent is closed") + var ErrExternalMappedIPNotFound = errors.New("external mapped IP not found") + var ErrHost = errors.New("invalid hostname") + var ErrIneffectiveNAT1To1IPMappingHost = errors.New("1:1 NAT IP mapping for host candidate ineffective") + var ErrIneffectiveNAT1To1IPMappingSrflx = errors.New("1:1 NAT IP mapping for srflx candidate ineffective") + var ErrInvalidMulticastDNSHostName = errors.New(...) + var ErrInvalidNAT1To1IPMapping = errors.New("invalid 1:1 NAT IP mapping") + var ErrInvalidQuery = errors.New("invalid query") + var ErrLiteUsingNonHostCandidates = errors.New("lite agents must only use host candidates") + var ErrLocalPwdInsufficientBits = errors.New("local password is less than 128 bits long") + var ErrLocalUfragInsufficientBits = errors.New("local username fragment is less than 24 bits long") + var ErrMulticastDNSWithNAT1To1IPMapping = errors.New("mDNS gathering cannot be used with 1:1 NAT IP mapping for host candidate") + var ErrMultipleGatherAttempted = errors.New("attempting to gather candidates during gathering state") + var ErrMultipleStart = errors.New("attempted to start agent twice") + var ErrNoCandidatePairs = errors.New("no candidate pairs available") + var ErrNoOnCandidateHandler = errors.New("no OnCandidate provided") + var ErrPasswordEmpty = errors.New("password is empty") + var ErrPort = errors.New("invalid port") + var ErrProtoType = errors.New("invalid transport protocol type") + var ErrRemotePwdEmpty = errors.New("remote pwd is empty") + var ErrRemoteUfragEmpty = errors.New("remote ufrag is empty") + var ErrRestartWhenGathering = errors.New("ICE Agent can not be restarted when gathering") + var ErrRunCanceled = errors.New("run was canceled by done") + var ErrSTUNQuery = errors.New("queries not supported in stun address") + var ErrSchemeType = errors.New("unknown scheme type") + var ErrTCPMuxNotInitialized = errors.New("TCPMux is not initialized") + var ErrTCPRemoteAddrAlreadyExists = errors.New("conn with same remote addr already exists") + var ErrUnknownType = errors.New("Unknown") + var ErrUnsupportedNAT1To1IPCandidateType = errors.New("unsupported 1:1 NAT IP candidate type") + var ErrUselessUrlsProvided = errors.New("agent does not need URL with selected candidate types") + var ErrUsernameEmpty = errors.New("username is empty") + type Agent struct + func NewAgent(config *AgentConfig) (*Agent, error) + func (a *Agent) Accept(ctx context.Context, remoteUfrag, remotePwd string) (*Conn, error) + func (a *Agent) AddRemoteCandidate(c Candidate) error + func (a *Agent) Close() error + func (a *Agent) Dial(ctx context.Context, remoteUfrag, remotePwd string) (*Conn, error) + func (a *Agent) GatherCandidates() error + func (a *Agent) GetCandidatePairsStats() []CandidatePairStats + func (a *Agent) GetLocalCandidates() ([]Candidate, error) + func (a *Agent) GetLocalCandidatesStats() []CandidateStats + func (a *Agent) GetLocalUserCredentials() (frag string, pwd string, err error) + func (a *Agent) GetRemoteCandidatesStats() []CandidateStats + func (a *Agent) GetRemoteUserCredentials() (frag string, pwd string, err error) + func (a *Agent) GetSelectedCandidatePair() (*CandidatePair, error) + func (a *Agent) OnCandidate(f func(Candidate)) error + func (a *Agent) OnConnectionStateChange(f func(ConnectionState)) error + func (a *Agent) OnSelectedCandidatePairChange(f func(Candidate, Candidate)) error + func (a *Agent) Restart(ufrag, pwd string) error + func (a *Agent) SetRemoteCredentials(remoteUfrag, remotePwd string) error + type AgentConfig struct + CandidateTypes []CandidateType + CheckInterval *time.Duration + DisconnectedTimeout *time.Duration + FailedTimeout *time.Duration + HostAcceptanceMinWait *time.Duration + InsecureSkipVerify bool + InterfaceFilter func(string) bool + KeepaliveInterval *time.Duration + Lite bool + LocalPwd string + LocalUfrag string + LoggerFactory logging.LoggerFactory + MaxBindingRequests *uint16 + MulticastDNSHostName string + MulticastDNSMode MulticastDNSMode + NAT1To1IPCandidateType CandidateType + NAT1To1IPs []string + Net *vnet.Net + NetworkTypes []NetworkType + PortMax uint16 + PortMin uint16 + PrflxAcceptanceMinWait *time.Duration + ProxyDialer proxy.Dialer + RelayAcceptanceMinWait *time.Duration + SrflxAcceptanceMinWait *time.Duration + TCPMux TCPMux + UDPMux UDPMux + Urls []*URL + type AttrControl struct + Role Role + Tiebreaker uint64 + func (c *AttrControl) GetFrom(m *stun.Message) error + func (c AttrControl) AddTo(m *stun.Message) error + type AttrControlled uint64 + func (c *AttrControlled) GetFrom(m *stun.Message) error + func (c AttrControlled) AddTo(m *stun.Message) error + type AttrControlling uint64 + func (c *AttrControlling) GetFrom(m *stun.Message) error + func (c AttrControlling) AddTo(m *stun.Message) error + type Candidate interface + Address func() string + Component func() uint16 + Equal func(other Candidate) bool + Foundation func() string + ID func() string + LastReceived func() time.Time + LastSent func() time.Time + Marshal func() string + NetworkType func() NetworkType + Port func() int + Priority func() uint32 + RelatedAddress func() *CandidateRelatedAddress + SetComponent func(uint16) + String func() string + TCPType func() TCPType + Type func() CandidateType + func UnmarshalCandidate(raw string) (Candidate, error) + type CandidateHost struct + func NewCandidateHost(config *CandidateHostConfig) (*CandidateHost, error) + func (c *CandidateHost) Address() string + func (c *CandidateHost) Component() uint16 + func (c *CandidateHost) Deadline() (deadline time.Time, ok bool) + func (c *CandidateHost) Done() <-chan struct{} + func (c *CandidateHost) Equal(other Candidate) bool + func (c *CandidateHost) Err() error + func (c *CandidateHost) Foundation() string + func (c *CandidateHost) ID() string + func (c *CandidateHost) LastReceived() time.Time + func (c *CandidateHost) LastSent() time.Time + func (c *CandidateHost) LocalPreference() uint16 + func (c *CandidateHost) Marshal() string + func (c *CandidateHost) NetworkType() NetworkType + func (c *CandidateHost) Port() int + func (c *CandidateHost) Priority() uint32 + func (c *CandidateHost) RelatedAddress() *CandidateRelatedAddress + func (c *CandidateHost) SetComponent(component uint16) + func (c *CandidateHost) String() string + func (c *CandidateHost) TCPType() TCPType + func (c *CandidateHost) Type() CandidateType + func (c *CandidateHost) Value(key interface{}) interface{} + type CandidateHostConfig struct + Address string + CandidateID string + Component uint16 + Foundation string + Network string + Port int + Priority uint32 + TCPType TCPType + type CandidatePair struct + Local Candidate + Remote Candidate + func (p *CandidatePair) String() string + func (p *CandidatePair) Write(b []byte) (int, error) + type CandidatePairState int + func (c CandidatePairState) String() string + type CandidatePairStats struct + AvailableIncomingBitrate float64 + AvailableOutgoingBitrate float64 + BytesReceived uint64 + BytesSent uint64 + CircuitBreakerTriggerCount uint32 + ConsentExpiredTimestamp time.Time + ConsentRequestsSent uint64 + CurrentRoundTripTime float64 + FirstRequestTimestamp time.Time + LastPacketReceivedTimestamp time.Time + LastPacketSentTimestamp time.Time + LastRequestTimestamp time.Time + LastResponseTimestamp time.Time + LocalCandidateID string + Nominated bool + PacketsReceived uint32 + PacketsSent uint32 + RemoteCandidateID string + RequestsReceived uint64 + RequestsSent uint64 + ResponsesReceived uint64 + ResponsesSent uint64 + RetransmissionsReceived uint64 + RetransmissionsSent uint64 + State CandidatePairState + Timestamp time.Time + TotalRoundTripTime float64 + type CandidatePeerReflexive struct + func NewCandidatePeerReflexive(config *CandidatePeerReflexiveConfig) (*CandidatePeerReflexive, error) + func (c *CandidatePeerReflexive) Address() string + func (c *CandidatePeerReflexive) Component() uint16 + func (c *CandidatePeerReflexive) Deadline() (deadline time.Time, ok bool) + func (c *CandidatePeerReflexive) Done() <-chan struct{} + func (c *CandidatePeerReflexive) Equal(other Candidate) bool + func (c *CandidatePeerReflexive) Err() error + func (c *CandidatePeerReflexive) Foundation() string + func (c *CandidatePeerReflexive) ID() string + func (c *CandidatePeerReflexive) LastReceived() time.Time + func (c *CandidatePeerReflexive) LastSent() time.Time + func (c *CandidatePeerReflexive) LocalPreference() uint16 + func (c *CandidatePeerReflexive) Marshal() string + func (c *CandidatePeerReflexive) NetworkType() NetworkType + func (c *CandidatePeerReflexive) Port() int + func (c *CandidatePeerReflexive) Priority() uint32 + func (c *CandidatePeerReflexive) RelatedAddress() *CandidateRelatedAddress + func (c *CandidatePeerReflexive) SetComponent(component uint16) + func (c *CandidatePeerReflexive) String() string + func (c *CandidatePeerReflexive) TCPType() TCPType + func (c *CandidatePeerReflexive) Type() CandidateType + func (c *CandidatePeerReflexive) Value(key interface{}) interface{} + type CandidatePeerReflexiveConfig struct + Address string + CandidateID string + Component uint16 + Foundation string + Network string + Port int + Priority uint32 + RelAddr string + RelPort int + type CandidateRelatedAddress struct + Address string + Port int + func (c *CandidateRelatedAddress) Equal(other *CandidateRelatedAddress) bool + func (c *CandidateRelatedAddress) String() string + type CandidateRelay struct + func NewCandidateRelay(config *CandidateRelayConfig) (*CandidateRelay, error) + func (c *CandidateRelay) Address() string + func (c *CandidateRelay) Component() uint16 + func (c *CandidateRelay) Deadline() (deadline time.Time, ok bool) + func (c *CandidateRelay) Done() <-chan struct{} + func (c *CandidateRelay) Equal(other Candidate) bool + func (c *CandidateRelay) Err() error + func (c *CandidateRelay) Foundation() string + func (c *CandidateRelay) ID() string + func (c *CandidateRelay) LastReceived() time.Time + func (c *CandidateRelay) LastSent() time.Time + func (c *CandidateRelay) LocalPreference() uint16 + func (c *CandidateRelay) Marshal() string + func (c *CandidateRelay) NetworkType() NetworkType + func (c *CandidateRelay) Port() int + func (c *CandidateRelay) Priority() uint32 + func (c *CandidateRelay) RelatedAddress() *CandidateRelatedAddress + func (c *CandidateRelay) RelayProtocol() string + func (c *CandidateRelay) SetComponent(component uint16) + func (c *CandidateRelay) String() string + func (c *CandidateRelay) TCPType() TCPType + func (c *CandidateRelay) Type() CandidateType + func (c *CandidateRelay) Value(key interface{}) interface{} + type CandidateRelayConfig struct + Address string + CandidateID string + Component uint16 + Foundation string + Network string + OnClose func() error + Port int + Priority uint32 + RelAddr string + RelPort int + RelayProtocol string + type CandidateServerReflexive struct + func NewCandidateServerReflexive(config *CandidateServerReflexiveConfig) (*CandidateServerReflexive, error) + func (c *CandidateServerReflexive) Address() string + func (c *CandidateServerReflexive) Component() uint16 + func (c *CandidateServerReflexive) Deadline() (deadline time.Time, ok bool) + func (c *CandidateServerReflexive) Done() <-chan struct{} + func (c *CandidateServerReflexive) Equal(other Candidate) bool + func (c *CandidateServerReflexive) Err() error + func (c *CandidateServerReflexive) Foundation() string + func (c *CandidateServerReflexive) ID() string + func (c *CandidateServerReflexive) LastReceived() time.Time + func (c *CandidateServerReflexive) LastSent() time.Time + func (c *CandidateServerReflexive) LocalPreference() uint16 + func (c *CandidateServerReflexive) Marshal() string + func (c *CandidateServerReflexive) NetworkType() NetworkType + func (c *CandidateServerReflexive) Port() int + func (c *CandidateServerReflexive) Priority() uint32 + func (c *CandidateServerReflexive) RelatedAddress() *CandidateRelatedAddress + func (c *CandidateServerReflexive) SetComponent(component uint16) + func (c *CandidateServerReflexive) String() string + func (c *CandidateServerReflexive) TCPType() TCPType + func (c *CandidateServerReflexive) Type() CandidateType + func (c *CandidateServerReflexive) Value(key interface{}) interface{} + type CandidateServerReflexiveConfig struct + Address string + CandidateID string + Component uint16 + Foundation string + Network string + Port int + Priority uint32 + RelAddr string + RelPort int + type CandidateStats struct + CandidateType CandidateType + Deleted bool + ID string + IP string + NetworkType NetworkType + Port int + Priority uint32 + RelayProtocol string + Timestamp time.Time + URL string + type CandidateType byte + const CandidateTypeHost + const CandidateTypePeerReflexive + const CandidateTypeRelay + const CandidateTypeServerReflexive + const CandidateTypeUnspecified + func (c CandidateType) Preference() uint16 + func (c CandidateType) String() string + type Conn struct + func (c *Conn) BytesReceived() uint64 + func (c *Conn) BytesSent() uint64 + func (c *Conn) Close() error + func (c *Conn) LocalAddr() net.Addr + func (c *Conn) Read(p []byte) (int, error) + func (c *Conn) RemoteAddr() net.Addr + func (c *Conn) SetDeadline(t time.Time) error + func (c *Conn) SetReadDeadline(t time.Time) error + func (c *Conn) SetWriteDeadline(t time.Time) error + func (c *Conn) Write(p []byte) (int, error) + type ConnectionState int + func (c ConnectionState) String() string + type GatheringState int + const GatheringStateComplete + const GatheringStateGathering + const GatheringStateNew + func (t GatheringState) String() string + type MulticastDNSMode byte + const MulticastDNSModeDisabled + const MulticastDNSModeQueryAndGather + const MulticastDNSModeQueryOnly + type NetworkType int + const NetworkTypeTCP4 + const NetworkTypeTCP6 + const NetworkTypeUDP4 + const NetworkTypeUDP6 + func (t NetworkType) IsIPv4() bool + func (t NetworkType) IsIPv6() bool + func (t NetworkType) IsReliable() bool + func (t NetworkType) IsTCP() bool + func (t NetworkType) IsUDP() bool + func (t NetworkType) NetworkShort() string + func (t NetworkType) String() string + type PriorityAttr uint32 + func (p *PriorityAttr) GetFrom(m *stun.Message) error + func (p PriorityAttr) AddTo(m *stun.Message) error + type ProtoType int + const ProtoTypeTCP + const ProtoTypeUDP + func NewProtoType(raw string) ProtoType + func (t ProtoType) String() string + type Role byte + const Controlled + const Controlling + func (r *Role) UnmarshalText(text []byte) error + func (r Role) MarshalText() (text []byte, err error) + func (r Role) String() string + type SchemeType int + const SchemeTypeSTUN + const SchemeTypeSTUNS + const SchemeTypeTURN + const SchemeTypeTURNS + func NewSchemeType(raw string) SchemeType + func (t SchemeType) String() string + type TCPMux interface + GetConnByUfrag func(ufrag string) (net.PacketConn, error) + RemoveConnByUfrag func(ufrag string) + type TCPMuxDefault struct + func NewTCPMuxDefault(params TCPMuxParams) *TCPMuxDefault + func (m *TCPMuxDefault) Close() error + func (m *TCPMuxDefault) GetConnByUfrag(ufrag string) (net.PacketConn, error) + func (m *TCPMuxDefault) LocalAddr() net.Addr + func (m *TCPMuxDefault) RemoveConnByUfrag(ufrag string) + type TCPMuxParams struct + Listener net.Listener + Logger logging.LeveledLogger + ReadBufferSize int + type TCPType int + const TCPTypeActive + const TCPTypePassive + const TCPTypeSimultaneousOpen + const TCPTypeUnspecified + func NewTCPType(value string) TCPType + func (t TCPType) String() string + type UDPMux interface + GetConn func(ufrag string) (net.PacketConn, error) + RemoveConnByUfrag func(ufrag string) + type UDPMuxDefault struct + func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault + func (m *UDPMuxDefault) Close() error + func (m *UDPMuxDefault) GetConn(ufrag string) (net.PacketConn, error) + func (m *UDPMuxDefault) IsClosed() bool + func (m *UDPMuxDefault) LocalAddr() net.Addr + func (m *UDPMuxDefault) RemoveConnByUfrag(ufrag string) + type UDPMuxParams struct + Logger logging.LeveledLogger + UDPConn net.PacketConn + type URL struct + Host string + Password string + Port int + Proto ProtoType + Scheme SchemeType + Username string + func ParseURL(raw string) (*URL, error) + func (u URL) IsSecure() bool + func (u URL) String() string + type UseCandidateAttr struct + func UseCandidate() UseCandidateAttr + func (UseCandidateAttr) AddTo(m *stun.Message) error + func (UseCandidateAttr) IsSet(m *stun.Message) bool