Versions in this module Expand all Collapse all v0 v0.0.2 Aug 27, 2023 Changes in this version + const CandidatePairStateFailed + const CandidatePairStateInProgress + const CandidatePairStateSucceeded + const CandidatePairStateWaiting + const ComponentRTCP + const ComponentRTP + const ProtoTypeTCP + const ProtoTypeUDP + const SchemeTypeSTUN + const SchemeTypeSTUNS + const SchemeTypeTURN + const SchemeTypeTURNS + 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 ErrDetermineNetworkType = errors.New("unable to determine networkType") + var ErrExternalMappedIPNotFound = errors.New("external mapped IP not found") + var ErrGetTransportAddress = errors.New("failed to get local transport address") + 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 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 ErrTCPRemoteAddrAlreadyExists = errors.New("conn with same remote addr already exists") + var ErrUnknownCandidateTyp = errors.New("unknown candidate typ") + 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") + var NewProtoType = stun.NewProtoType + var NewSchemeType = stun.NewSchemeType + var ParseURL = stun.ParseURI + type AddrPort [18]byte + 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) GetRemoteCandidates() ([]Candidate, 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 + AcceptAggressiveNomination bool + CandidateTypes []CandidateType + CheckInterval *time.Duration + DisableActiveTCP bool + DisconnectedTimeout *time.Duration + FailedTimeout *time.Duration + HostAcceptanceMinWait *time.Duration + IPFilter func(net.IP) bool + IncludeLoopback bool + 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 transport.Net + NetworkTypes []NetworkType + PortMax uint16 + PortMin uint16 + PrflxAcceptanceMinWait *time.Duration + ProxyDialer proxy.Dialer + RelayAcceptanceMinWait *time.Duration + SrflxAcceptanceMinWait *time.Duration + TCPMux TCPMux + TCPPriorityOffset *uint16 + UDPMux UDPMux + UDPMuxSrflx UniversalUDPMux + Urls []*stun.URI + type AllConnsGetter interface + GetAllConns func(ufrag string, isIPv6 bool, localIP net.IP) ([]net.PacketConn, error) + 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) TypePreference() uint16 + func (c *CandidateHost) Value(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) TypePreference() uint16 + func (c *CandidatePeerReflexive) Value(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) TypePreference() uint16 + func (c *CandidateRelay) Value(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) TypePreference() uint16 + func (c *CandidateServerReflexive) Value(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(time.Time) error + func (c *Conn) SetReadDeadline(time.Time) error + func (c *Conn) SetWriteDeadline(time.Time) error + func (c *Conn) Write(p []byte) (int, error) + type ConnectionState int + const ConnectionStateChecking + const ConnectionStateClosed + const ConnectionStateCompleted + const ConnectionStateConnected + const ConnectionStateDisconnected + const ConnectionStateFailed + const ConnectionStateNew + const ConnectionStateUnknown + func (c ConnectionState) String() string + type GatheringState int + const GatheringStateComplete + const GatheringStateGathering + const GatheringStateNew + const GatheringStateUnknown + func (t GatheringState) String() string + type MultiTCPMuxDefault struct + func NewMultiTCPMuxDefault(muxes ...TCPMux) *MultiTCPMuxDefault + func (m *MultiTCPMuxDefault) Close() error + func (m *MultiTCPMuxDefault) GetAllConns(ufrag string, isIPv6 bool, local net.IP) ([]net.PacketConn, error) + func (m *MultiTCPMuxDefault) GetConnByUfrag(ufrag string, isIPv6 bool, local net.IP) (net.PacketConn, error) + func (m *MultiTCPMuxDefault) RemoveConnByUfrag(ufrag string) + type MultiUDPMuxDefault struct + func NewMultiUDPMuxDefault(muxes ...UDPMux) *MultiUDPMuxDefault + func NewMultiUDPMuxFromPort(port int, opts ...UDPMuxFromPortOption) (*MultiUDPMuxDefault, error) + func (m *MultiUDPMuxDefault) Close() error + func (m *MultiUDPMuxDefault) GetConn(ufrag string, addr net.Addr) (net.PacketConn, error) + func (m *MultiUDPMuxDefault) GetListenAddresses() []net.Addr + func (m *MultiUDPMuxDefault) RemoveConnByUfrag(ufrag 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 = stun.ProtoType + 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 = stun.SchemeType + type TCPMux interface + GetConnByUfrag func(ufrag string, isIPv6 bool, local net.IP) (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, isIPv6 bool, local net.IP) (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 + WriteBufferSize 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, addr net.Addr) (net.PacketConn, error) + GetListenAddresses func() []net.Addr + RemoveConnByUfrag func(ufrag string) + type UDPMuxDefault struct + func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault + func (m *UDPMuxDefault) Close() error + func (m *UDPMuxDefault) GetConn(ufrag string, addr net.Addr) (net.PacketConn, error) + func (m *UDPMuxDefault) GetListenAddresses() []net.Addr + func (m *UDPMuxDefault) IsClosed() bool + func (m *UDPMuxDefault) LocalAddr() net.Addr + func (m *UDPMuxDefault) RemoveConnByUfrag(ufrag string) + type UDPMuxFromPortOption interface + func UDPMuxFromPortWithIPFilter(f func(ip net.IP) bool) UDPMuxFromPortOption + func UDPMuxFromPortWithInterfaceFilter(f func(string) bool) UDPMuxFromPortOption + func UDPMuxFromPortWithLogger(logger logging.LeveledLogger) UDPMuxFromPortOption + func UDPMuxFromPortWithLoopback() UDPMuxFromPortOption + func UDPMuxFromPortWithNet(n transport.Net) UDPMuxFromPortOption + func UDPMuxFromPortWithNetworks(networks ...NetworkType) UDPMuxFromPortOption + func UDPMuxFromPortWithReadBufferSize(size int) UDPMuxFromPortOption + func UDPMuxFromPortWithWriteBufferSize(size int) UDPMuxFromPortOption + type UDPMuxParams struct + Logger logging.LeveledLogger + Net transport.Net + UDPConn net.PacketConn + type URL = stun.URI + type UniversalUDPMux interface + GetConnForURL func(ufrag string, url string, addr net.Addr) (net.PacketConn, error) + GetRelayedAddr func(turnAddr net.Addr, deadline time.Duration) (*net.Addr, error) + GetXORMappedAddr func(stunAddr net.Addr, deadline time.Duration) (*stun.XORMappedAddress, error) + type UniversalUDPMuxDefault struct + func NewUniversalUDPMuxDefault(params UniversalUDPMuxParams) *UniversalUDPMuxDefault + func (m *UniversalUDPMuxDefault) GetConnForURL(ufrag string, url string, addr net.Addr) (net.PacketConn, error) + func (m *UniversalUDPMuxDefault) GetRelayedAddr(net.Addr, time.Duration) (*net.Addr, error) + func (m *UniversalUDPMuxDefault) GetXORMappedAddr(serverAddr net.Addr, deadline time.Duration) (*stun.XORMappedAddress, error) + type UniversalUDPMuxParams struct + Logger logging.LeveledLogger + Net transport.Net + UDPConn net.PacketConn + XORMappedAddrCacheTTL time.Duration + type UseCandidateAttr struct + func UseCandidate() UseCandidateAttr + func (UseCandidateAttr) AddTo(m *stun.Message) error + func (UseCandidateAttr) IsSet(m *stun.Message) bool