Documentation ¶
Overview ¶
Package ice implements the Interactive Connectivity Establishment (ICE) protocol defined in rfc5245.
Package ice ...
Index ¶
- Constants
- Variables
- type AddrPort
- type Agent
- 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) GetSelectedCandidatePairStats() (CandidatePairStats, bool)
- func (a *Agent) GracefulClose() 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
- type AllConnsGetter
- type AttrControl
- type AttrControlled
- type AttrControlling
- type Candidate
- type CandidateHost
- 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
- type CandidatePair
- func (p *CandidatePair) CurrentRoundTripTime() float64
- func (p *CandidatePair) ResponsesReceived() uint64
- func (p *CandidatePair) String() string
- func (p *CandidatePair) TotalRoundTripTime() float64
- func (p *CandidatePair) UpdateRoundTripTime(rtt time.Duration)
- func (p *CandidatePair) Write(b []byte) (int, error)
- type CandidatePairState
- type CandidatePairStats
- type CandidatePeerReflexive
- 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
- type CandidateRelatedAddress
- type CandidateRelay
- 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
- type CandidateServerReflexive
- 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
- type CandidateStats
- type CandidateType
- type Conn
- 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
- type GatheringState
- type 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
- type MulticastDNSMode
- type NetworkType
- type PriorityAttr
- type ProtoTypedeprecated
- type Role
- type SchemeTypedeprecated
- type TCPMux
- type TCPMuxDefault
- type TCPMuxParams
- type TCPType
- type UDPMux
- type 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
- func UDPMuxFromPortWithIPFilter(f func(ip net.IP) (keep bool)) UDPMuxFromPortOption
- func UDPMuxFromPortWithInterfaceFilter(f func(string) (keep 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
- type URLdeprecated
- type UniversalUDPMux
- type 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
- type UseCandidateAttr
Constants ¶
const ( // ComponentRTP indicates that the candidate is used for RTP ComponentRTP uint16 = 1 // ComponentRTCP indicates that the candidate is used for RTCP ComponentRTCP )
const ( // SchemeTypeSTUN indicates the URL represents a STUN server. // // Deprecated: Please use pion/stun.SchemeTypeSTUN SchemeTypeSTUN = stun.SchemeTypeSTUN // SchemeTypeSTUNS indicates the URL represents a STUNS (secure) server. // // Deprecated: Please use pion/stun.SchemeTypeSTUNS SchemeTypeSTUNS = stun.SchemeTypeSTUNS // SchemeTypeTURN indicates the URL represents a TURN server. // // Deprecated: Please use pion/stun.SchemeTypeTURN SchemeTypeTURN = stun.SchemeTypeTURN // SchemeTypeTURNS indicates the URL represents a TURNS (secure) server. // // Deprecated: Please use pion/stun.SchemeTypeTURNS SchemeTypeTURNS = stun.SchemeTypeTURNS )
const ( // ProtoTypeUDP indicates the URL uses a UDP transport. // // Deprecated: Please use pion/stun.ProtoTypeUDP ProtoTypeUDP = stun.ProtoTypeUDP // ProtoTypeTCP indicates the URL uses a TCP transport. // // Deprecated: Please use pion/stun.ProtoTypeTCP ProtoTypeTCP = stun.ProtoTypeTCP )
const Unknown = 0
Unknown represents and unknown ProtoType or SchemeType
Deprecated: Please use pion/stun.SchemeTypeUnknown or pion/stun.ProtoTypeUnknown
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") // ErrLocalUfragInsufficientBits indicates local username fragment insufficient bits are provided. // Have to be at least 24 bits long ErrLocalUfragInsufficientBits = errors.New("local username fragment is less than 24 bits long") // ErrLocalPwdInsufficientBits indicates local password insufficient bits are provided. // Have to be at least 128 bits long ErrLocalPwdInsufficientBits = errors.New("local password is less than 128 bits long") // ErrProtoType indicates an unsupported transport type was provided. ErrProtoType = errors.New("invalid transport protocol type") // ErrClosed indicates the agent is closed ErrClosed = taskloop.ErrClosed // ErrNoCandidatePairs indicates agent does not have a valid candidate pair ErrNoCandidatePairs = errors.New("no candidate pairs available") // ErrCanceledByCaller indicates agent connection was canceled by the caller ErrCanceledByCaller = errors.New("connecting canceled by caller") // ErrMultipleStart indicates agent was started twice ErrMultipleStart = errors.New("attempted to start agent twice") // ErrRemoteUfragEmpty indicates agent was started with an empty remote ufrag ErrRemoteUfragEmpty = errors.New("remote ufrag is empty") // ErrRemotePwdEmpty indicates agent was started with an empty remote pwd ErrRemotePwdEmpty = errors.New("remote pwd is empty") // ErrNoOnCandidateHandler indicates agent was started without OnCandidate ErrNoOnCandidateHandler = errors.New("no OnCandidate provided") // ErrMultipleGatherAttempted indicates GatherCandidates has been called multiple times ErrMultipleGatherAttempted = errors.New("attempting to gather candidates during gathering state") // ErrUsernameEmpty indicates agent was give TURN URL with an empty Username ErrUsernameEmpty = errors.New("username is empty") // ErrPasswordEmpty indicates agent was give TURN URL with an empty Password ErrPasswordEmpty = errors.New("password is empty") // ErrAddressParseFailed indicates we were unable to parse a candidate address ErrAddressParseFailed = errors.New("failed to parse address") // ErrLiteUsingNonHostCandidates indicates non host candidates were selected for a lite agent ErrLiteUsingNonHostCandidates = errors.New("lite agents must only use host candidates") // ErrUselessUrlsProvided indicates that one or more URL was provided to the agent but no host // candidate required them ErrUselessUrlsProvided = errors.New("agent does not need URL with selected candidate types") // ErrUnsupportedNAT1To1IPCandidateType indicates that the specified NAT1To1IPCandidateType is // unsupported ErrUnsupportedNAT1To1IPCandidateType = errors.New("unsupported 1:1 NAT IP candidate type") // ErrInvalidNAT1To1IPMapping indicates that the given 1:1 NAT IP mapping is invalid ErrInvalidNAT1To1IPMapping = errors.New("invalid 1:1 NAT IP mapping") // ErrExternalMappedIPNotFound in NAT1To1IPMapping ErrExternalMappedIPNotFound = errors.New("external mapped IP not found") // ErrMulticastDNSWithNAT1To1IPMapping indicates that the mDNS gathering cannot be used along // with 1:1 NAT IP mapping for host candidate. ErrMulticastDNSWithNAT1To1IPMapping = errors.New("mDNS gathering cannot be used with 1:1 NAT IP mapping for host candidate") // ErrIneffectiveNAT1To1IPMappingHost indicates that 1:1 NAT IP mapping for host candidate is // requested, but the host candidate type is disabled. ErrIneffectiveNAT1To1IPMappingHost = errors.New("1:1 NAT IP mapping for host candidate ineffective") // ErrIneffectiveNAT1To1IPMappingSrflx indicates that 1:1 NAT IP mapping for srflx candidate is // requested, but the srflx candidate type is disabled. ErrIneffectiveNAT1To1IPMappingSrflx = errors.New("1:1 NAT IP mapping for srflx candidate ineffective") // ErrInvalidMulticastDNSHostName indicates an invalid MulticastDNSHostName ErrInvalidMulticastDNSHostName = errors.New("invalid mDNS HostName, must end with .local and can only contain a single '.'") // ErrRunCanceled indicates a run operation was canceled by its individual done ErrRunCanceled = errors.New("run was canceled by done") // ErrTCPRemoteAddrAlreadyExists indicates we already have the connection with same remote addr. ErrTCPRemoteAddrAlreadyExists = errors.New("conn with same remote addr already exists") // ErrUnknownCandidateTyp indicates that a candidate had a unknown type value. ErrUnknownCandidateTyp = errors.New("unknown candidate typ") // ErrDetermineNetworkType indicates that the NetworkType was not able to be parsed ErrDetermineNetworkType = errors.New("unable to determine networkType") )
var ErrGetTransportAddress = errors.New("failed to get local transport address")
ErrGetTransportAddress can't convert net.Addr to underlying type (UDPAddr or TCPAddr).
var NewProtoType = stun.NewProtoType //nolint:gochecknoglobals
NewProtoType defines a procedure for creating a new ProtoType from a raw string naming the transport protocol type.
Deprecated: Please use pion/stun.NewProtoType
var NewSchemeType = stun.NewSchemeType //nolint:gochecknoglobals
NewSchemeType defines a procedure for creating a new SchemeType from a raw string naming the scheme type.
Deprecated: Please use pion/stun.NewSchemeType
var ParseURL = stun.ParseURI //nolint:gochecknoglobals
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.
Deprecated: Please use pion/stun.ParseURI
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent represents the ICE agent
func (*Agent) Accept ¶
Accept connects to the remote agent, acting as the controlled ice agent. Accept blocks until at least one ice candidate pair has successfully connected.
func (*Agent) AddRemoteCandidate ¶
AddRemoteCandidate adds a new remote candidate
func (*Agent) Dial ¶
Dial connects to the remote agent, acting as the controlling ice agent. Dial blocks until at least one ice candidate pair has successfully connected.
func (*Agent) GatherCandidates ¶
GatherCandidates initiates the trickle based gathering process.
func (*Agent) GetCandidatePairsStats ¶
func (a *Agent) GetCandidatePairsStats() []CandidatePairStats
GetCandidatePairsStats returns a list of candidate pair stats
func (*Agent) GetLocalCandidates ¶
GetLocalCandidates returns the local candidates
func (*Agent) GetLocalCandidatesStats ¶
func (a *Agent) GetLocalCandidatesStats() []CandidateStats
GetLocalCandidatesStats returns a list of local candidates stats
func (*Agent) GetLocalUserCredentials ¶
GetLocalUserCredentials returns the local user credentials
func (*Agent) GetRemoteCandidates ¶
GetRemoteCandidates returns the remote candidates
func (*Agent) GetRemoteCandidatesStats ¶
func (a *Agent) GetRemoteCandidatesStats() []CandidateStats
GetRemoteCandidatesStats returns a list of remote candidates stats
func (*Agent) GetRemoteUserCredentials ¶
GetRemoteUserCredentials returns the remote user credentials
func (*Agent) GetSelectedCandidatePair ¶
func (a *Agent) GetSelectedCandidatePair() (*CandidatePair, error)
GetSelectedCandidatePair returns the selected pair or nil if there is none
func (*Agent) GetSelectedCandidatePairStats ¶ added in v4.0.2
func (a *Agent) GetSelectedCandidatePairStats() (CandidatePairStats, bool)
GetSelectedCandidatePairStats returns a candidate pair stats for selected candidate pair. Returns false if there is no selected pair
func (*Agent) GracefulClose ¶
GracefulClose cleans up the Agent and waits for any goroutines it started to complete. This is only safe to call outside of Agent callbacks or if in a callback, in its own goroutine.
func (*Agent) OnCandidate ¶
OnCandidate sets a handler that is fired when new candidates gathered. When the gathering process complete the last candidate is nil.
func (*Agent) OnConnectionStateChange ¶
func (a *Agent) OnConnectionStateChange(f func(ConnectionState)) error
OnConnectionStateChange sets a handler that is fired when the connection state changes
func (*Agent) OnSelectedCandidatePairChange ¶
OnSelectedCandidatePairChange sets a handler that is fired when the final candidate pair is selected
func (*Agent) Restart ¶
Restart restarts the ICE Agent with the provided ufrag/pwd If no ufrag/pwd is provided the Agent will generate one itself
If there is a gatherer routine currently running, Restart will cancel it. After a Restart, the user must then call GatherCandidates explicitly to start generating new ones.
func (*Agent) SetRemoteCredentials ¶
SetRemoteCredentials sets the credentials of the remote agent
type AgentConfig ¶
type AgentConfig struct { Urls []*stun.URI // PortMin and PortMax are optional. Leave them 0 for the default UDP port allocation strategy. PortMin uint16 PortMax uint16 // LocalUfrag and LocalPwd values used to perform connectivity // checks. The values MUST be unguessable, with at least 128 bits of // random number generator output used to generate the password, and // at least 24 bits of output to generate the username fragment. LocalUfrag string LocalPwd string // MulticastDNSMode controls mDNS behavior for the ICE agent MulticastDNSMode MulticastDNSMode // MulticastDNSHostName controls the hostname for this agent. If none is specified a random one will be generated MulticastDNSHostName string // DisconnectedTimeout defaults to 5 seconds when this property is nil. // If the duration is 0, the ICE Agent will never go to disconnected DisconnectedTimeout *time.Duration // FailedTimeout defaults to 25 seconds when this property is nil. // If the duration is 0, we will never go to failed. FailedTimeout *time.Duration // KeepaliveInterval determines how often should we send ICE // keepalives (should be less then connectiontimeout above) // when this is nil, it defaults to 10 seconds. // A keepalive interval of 0 means we never send keepalive packets KeepaliveInterval *time.Duration // CheckInterval controls how often our task loop runs when in the // connecting state. CheckInterval *time.Duration // NetworkTypes is an optional configuration for disabling or enabling // support for specific network types. NetworkTypes []NetworkType // CandidateTypes is an optional configuration for disabling or enabling // support for specific candidate types. CandidateTypes []CandidateType LoggerFactory logging.LoggerFactory // MaxBindingRequests is the max amount of binding requests the agent will send // over a candidate pair for validation or nomination, if after MaxBindingRequests // the candidate is yet to answer a binding request or a nomination we set the pair as failed MaxBindingRequests *uint16 // Lite agents do not perform connectivity check and only provide host candidates. Lite bool // NAT1To1IPCandidateType is used along with NAT1To1IPs to specify which candidate type // the 1:1 NAT IP addresses should be mapped to. // If unspecified or CandidateTypeHost, NAT1To1IPs are used to replace host candidate IPs. // If CandidateTypeServerReflexive, it will insert a srflx candidate (as if it was derived // from a STUN server) with its port number being the one for the actual host candidate. // Other values will result in an error. NAT1To1IPCandidateType CandidateType // NAT1To1IPs contains a list of public IP addresses that are to be used as a host // candidate or srflx candidate. This is used typically for servers that are behind // 1:1 D-NAT (e.g. AWS EC2 instances) and to eliminate the need of server reflexive // candidate gathering. NAT1To1IPs []string // HostAcceptanceMinWait specify a minimum wait time before selecting host candidates HostAcceptanceMinWait *time.Duration // SrflxAcceptanceMinWait specify a minimum wait time before selecting srflx candidates SrflxAcceptanceMinWait *time.Duration // PrflxAcceptanceMinWait specify a minimum wait time before selecting prflx candidates PrflxAcceptanceMinWait *time.Duration // RelayAcceptanceMinWait specify a minimum wait time before selecting relay candidates RelayAcceptanceMinWait *time.Duration // STUNGatherTimeout specify a minimum wait time for STUN responses STUNGatherTimeout *time.Duration // Net is the our abstracted network interface for internal development purpose only // (see https://github.com/pion/transport) Net transport.Net // InterfaceFilter is a function that you can use in order to whitelist or blacklist // the interfaces which are used to gather ICE candidates. InterfaceFilter func(string) (keep bool) // IPFilter is a function that you can use in order to whitelist or blacklist // the ips which are used to gather ICE candidates. IPFilter func(net.IP) (keep bool) // InsecureSkipVerify controls if self-signed certificates are accepted when connecting // to TURN servers via TLS or DTLS InsecureSkipVerify bool // TCPMux will be used for multiplexing incoming TCP connections for ICE TCP. // Currently only passive candidates are supported. This functionality is // experimental and the API might change in the future. TCPMux TCPMux // UDPMux is used for multiplexing multiple incoming UDP connections on a single port // when this is set, the agent ignores PortMin and PortMax configurations and will // defer to UDPMux for incoming connections UDPMux UDPMux // UDPMuxSrflx is used for multiplexing multiple incoming UDP connections of server reflexive candidates // on a single port when this is set, the agent ignores PortMin and PortMax configurations and will // defer to UDPMuxSrflx for incoming connections // It embeds UDPMux to do the actual connection multiplexing UDPMuxSrflx UniversalUDPMux // Proxy Dialer is a dialer that should be implemented by the user based on golang.org/x/net/proxy // dial interface in order to support corporate proxies ProxyDialer proxy.Dialer // Deprecated: AcceptAggressiveNomination always enabled. AcceptAggressiveNomination bool // Include loopback addresses in the candidate list. IncludeLoopback bool // TCPPriorityOffset is a number which is subtracted from the default (UDP) candidate type preference // for host, srflx and prfx candidate types. It helps to configure relative preference of UDP candidates // against TCP ones. Relay candidates for TCP and UDP are always 0 and not affected by this setting. // When this is nil, defaultTCPPriorityOffset is used. TCPPriorityOffset *uint16 // DisableActiveTCP can be used to disable Active TCP candidates. Otherwise when TCP is enabled // Active TCP candidates will be created when a new passive TCP remote candidate is added. DisableActiveTCP bool // BindingRequestHandler allows applications to perform logic on incoming STUN Binding Requests // This was implemented to allow users to // * Log incoming Binding Requests for debugging // * Implement draft-thatcher-ice-renomination // * Implement custom CandidatePair switching logic BindingRequestHandler func(m *stun.Message, local, remote Candidate, pair *CandidatePair) bool // EnableUseCandidateCheckPriority can be used to enable checking for equal or higher priority to // switch selected candidate pair if the peer requests USE-CANDIDATE and agent is a lite agent. // This is disabled by default, i. e. when peer requests USE-CANDIDATE, the selected pair will be // switched to that irrespective of relative priority between current selected pair // and priority of the pair being switched to. EnableUseCandidateCheckPriority bool }
AgentConfig collects the arguments to ice.Agent construction into a single structure, for future-proofness of the interface
type AllConnsGetter ¶
type AllConnsGetter interface {
GetAllConns(ufrag string, isIPv6 bool, localIP net.IP) ([]net.PacketConn, error)
}
AllConnsGetter allows multiple fixed TCP ports to be used, each of which is multiplexed like TCPMux. AllConnsGetter also acts as a TCPMux, in which case it will return a single connection for one of the ports.
type AttrControl ¶
AttrControl is helper that wraps ICE-{CONTROLLED,CONTROLLING}.
func (AttrControl) AddTo ¶
func (c AttrControl) AddTo(m *stun.Message) error
AddTo adds ICE-CONTROLLED or ICE-CONTROLLING attribute depending on Role.
func (*AttrControl) GetFrom ¶
func (c *AttrControl) GetFrom(m *stun.Message) error
GetFrom decodes Role and Tiebreaker value from message.
type AttrControlled ¶
type AttrControlled uint64
AttrControlled represents ICE-CONTROLLED attribute.
func (AttrControlled) AddTo ¶
func (c AttrControlled) AddTo(m *stun.Message) error
AddTo adds ICE-CONTROLLED to message.
func (*AttrControlled) GetFrom ¶
func (c *AttrControlled) GetFrom(m *stun.Message) error
GetFrom decodes ICE-CONTROLLED from message.
type AttrControlling ¶
type AttrControlling uint64
AttrControlling represents ICE-CONTROLLING attribute.
func (AttrControlling) AddTo ¶
func (c AttrControlling) AddTo(m *stun.Message) error
AddTo adds ICE-CONTROLLING to message.
func (*AttrControlling) GetFrom ¶
func (c *AttrControlling) GetFrom(m *stun.Message) error
GetFrom decodes ICE-CONTROLLING from message.
type Candidate ¶
type Candidate interface { // An arbitrary string used in the freezing algorithm to // group similar candidates. It is the same for two candidates that // have the same type, base IP address, protocol (UDP, TCP, etc.), // and STUN or TURN server. Foundation() string // ID is a unique identifier for just this candidate // Unlike the foundation this is different for each candidate ID() string // A component is a piece of a data stream. // An example is one for RTP, and one for RTCP Component() uint16 SetComponent(uint16) // The last time this candidate received traffic LastReceived() time.Time // The last time this candidate sent traffic LastSent() time.Time NetworkType() NetworkType Address() string Port() int Priority() uint32 // A transport address related to a // candidate, which is useful for diagnostics and other purposes RelatedAddress() *CandidateRelatedAddress String() string Type() CandidateType TCPType() TCPType Equal(other Candidate) bool Marshal() string // contains filtered or unexported methods }
Candidate represents an ICE candidate
func UnmarshalCandidate ¶
UnmarshalCandidate creates a Candidate from its string representation
type CandidateHost ¶
type CandidateHost struct {
// contains filtered or unexported fields
}
CandidateHost is a candidate of type host
func NewCandidateHost ¶
func NewCandidateHost(config *CandidateHostConfig) (*CandidateHost, error)
NewCandidateHost creates a new host candidate
func (*CandidateHost) Address ¶
func (c *CandidateHost) Address() string
Address returns Candidate Address
func (*CandidateHost) Component ¶
func (c *CandidateHost) Component() uint16
Component returns candidate component
func (*CandidateHost) Done ¶
func (c *CandidateHost) Done() <-chan struct{}
Done implements context.Context
func (*CandidateHost) Foundation ¶
func (c *CandidateHost) Foundation() string
func (*CandidateHost) LastReceived ¶
LastReceived returns a time.Time indicating the last time this candidate was received
func (*CandidateHost) LastSent ¶
LastSent returns a time.Time indicating the last time this candidate was sent
func (*CandidateHost) LocalPreference ¶
func (c *CandidateHost) LocalPreference() uint16
LocalPreference returns the local preference for this candidate
func (*CandidateHost) Marshal ¶
func (c *CandidateHost) Marshal() string
Marshal returns the string representation of the ICECandidate
func (*CandidateHost) NetworkType ¶
func (c *CandidateHost) NetworkType() NetworkType
NetworkType returns candidate NetworkType
func (*CandidateHost) Priority ¶
func (c *CandidateHost) Priority() uint32
Priority computes the priority for this ICE Candidate See: https://www.rfc-editor.org/rfc/rfc8445#section-5.1.2.1
func (*CandidateHost) RelatedAddress ¶
func (c *CandidateHost) RelatedAddress() *CandidateRelatedAddress
RelatedAddress returns *CandidateRelatedAddress
func (*CandidateHost) SetComponent ¶
func (c *CandidateHost) SetComponent(component uint16)
func (*CandidateHost) String ¶
func (c *CandidateHost) String() string
String makes the candidateBase printable
func (*CandidateHost) Type ¶
func (c *CandidateHost) Type() CandidateType
Type returns candidate type
func (*CandidateHost) TypePreference ¶
func (c *CandidateHost) TypePreference() uint16
TypePreference returns the type preference for this candidate
type CandidateHostConfig ¶
type CandidateHostConfig struct { CandidateID string Network string Address string Port int Component uint16 Priority uint32 Foundation string TCPType TCPType IsLocationTracked bool }
CandidateHostConfig is the config required to create a new CandidateHost
type CandidatePair ¶
type CandidatePair struct { Remote Candidate Local Candidate // contains filtered or unexported fields }
CandidatePair is a combination of a local and remote candidate
func (*CandidatePair) CurrentRoundTripTime ¶ added in v4.0.2
func (p *CandidatePair) CurrentRoundTripTime() float64
CurrentRoundTripTime returns the current round trip time in seconds https://www.w3.org/TR/webrtc-stats/#dom-rtcicecandidatepairstats-currentroundtriptime
func (*CandidatePair) ResponsesReceived ¶ added in v4.0.2
func (p *CandidatePair) ResponsesReceived() uint64
ResponsesReceived returns the total number of connectivity responses received https://www.w3.org/TR/webrtc-stats/#dom-rtcicecandidatepairstats-responsesreceived
func (*CandidatePair) String ¶
func (p *CandidatePair) String() string
func (*CandidatePair) TotalRoundTripTime ¶ added in v4.0.2
func (p *CandidatePair) TotalRoundTripTime() float64
TotalRoundTripTime returns the current round trip time in seconds https://www.w3.org/TR/webrtc-stats/#dom-rtcicecandidatepairstats-totalroundtriptime
func (*CandidatePair) UpdateRoundTripTime ¶ added in v4.0.2
func (p *CandidatePair) UpdateRoundTripTime(rtt time.Duration)
UpdateRoundTripTime sets the current round time of this pair and accumulates total round trip time and responses received
type CandidatePairState ¶
type CandidatePairState int
CandidatePairState represent the ICE candidate pair state
const ( // CandidatePairStateWaiting means a check has not been performed for // this pair CandidatePairStateWaiting CandidatePairState = iota + 1 // CandidatePairStateInProgress means a check has been sent for this pair, // but the transaction is in progress. CandidatePairStateInProgress // CandidatePairStateFailed means a check for this pair was already done // and failed, either never producing any response or producing an unrecoverable // failure response. CandidatePairStateFailed // CandidatePairStateSucceeded means a check for this pair was already // done and produced a successful result. CandidatePairStateSucceeded )
func (CandidatePairState) String ¶
func (c CandidatePairState) String() string
type CandidatePairStats ¶
type CandidatePairStats struct { // Timestamp is the timestamp associated with this object. Timestamp time.Time // LocalCandidateID is the ID of the local candidate LocalCandidateID string // RemoteCandidateID is the ID of the remote candidate RemoteCandidateID string // State represents the state of the checklist for the local and remote // candidates in a pair. State CandidatePairState // Nominated is true when this valid pair that should be used for media // if it is the highest-priority one amongst those whose nominated flag is set Nominated bool // PacketsSent represents the total number of packets sent on this candidate pair. PacketsSent uint32 // PacketsReceived represents the total number of packets received on this candidate pair. PacketsReceived uint32 // BytesSent represents the total number of payload bytes sent on this candidate pair // not including headers or padding. BytesSent uint64 // BytesReceived represents the total number of payload bytes received on this candidate pair // not including headers or padding. BytesReceived uint64 // LastPacketSentTimestamp represents the timestamp at which the last packet was // sent on this particular candidate pair, excluding STUN packets. LastPacketSentTimestamp time.Time // LastPacketReceivedTimestamp represents the timestamp at which the last packet // was received on this particular candidate pair, excluding STUN packets. LastPacketReceivedTimestamp time.Time // FirstRequestTimestamp represents the timestamp at which the first STUN request // was sent on this particular candidate pair. FirstRequestTimestamp time.Time // LastRequestTimestamp represents the timestamp at which the last STUN request // was sent on this particular candidate pair. The average interval between two // consecutive connectivity checks sent can be calculated with // (LastRequestTimestamp - FirstRequestTimestamp) / RequestsSent. LastRequestTimestamp time.Time // LastResponseTimestamp represents the timestamp at which the last STUN response // was received on this particular candidate pair. LastResponseTimestamp time.Time // TotalRoundTripTime represents the sum of all round trip time measurements // in seconds since the beginning of the session, based on STUN connectivity // check responses (ResponsesReceived), including those that reply to requests // that are sent in order to verify consent. The average round trip time can // be computed from TotalRoundTripTime by dividing it by ResponsesReceived. TotalRoundTripTime float64 // CurrentRoundTripTime represents the latest round trip time measured in seconds, // computed from both STUN connectivity checks, including those that are sent // for consent verification. CurrentRoundTripTime float64 // AvailableOutgoingBitrate is calculated by the underlying congestion control // by combining the available bitrate for all the outgoing RTP streams using // this candidate pair. The bitrate measurement does not count the size of the // IP or other transport layers like TCP or UDP. It is similar to the TIAS defined // in RFC 3890, i.e., it is measured in bits per second and the bitrate is calculated // over a 1 second window. AvailableOutgoingBitrate float64 // AvailableIncomingBitrate is calculated by the underlying congestion control // by combining the available bitrate for all the incoming RTP streams using // this candidate pair. The bitrate measurement does not count the size of the // IP or other transport layers like TCP or UDP. It is similar to the TIAS defined // in RFC 3890, i.e., it is measured in bits per second and the bitrate is // calculated over a 1 second window. AvailableIncomingBitrate float64 // CircuitBreakerTriggerCount represents the number of times the circuit breaker // is triggered for this particular 5-tuple, ceasing transmission. CircuitBreakerTriggerCount uint32 // RequestsReceived represents the total number of connectivity check requests // received (including retransmissions). It is impossible for the receiver to // tell whether the request was sent in order to check connectivity or check // consent, so all connectivity checks requests are counted here. RequestsReceived uint64 // RequestsSent represents the total number of connectivity check requests // sent (not including retransmissions). RequestsSent uint64 // ResponsesReceived represents the total number of connectivity check responses received. ResponsesReceived uint64 // ResponsesSent represents the total number of connectivity check responses sent. // Since we cannot distinguish connectivity check requests and consent requests, // all responses are counted. ResponsesSent uint64 // RetransmissionsReceived represents the total number of connectivity check // request retransmissions received. RetransmissionsReceived uint64 // RetransmissionsSent represents the total number of connectivity check // request retransmissions sent. RetransmissionsSent uint64 // ConsentRequestsSent represents the total number of consent requests sent. ConsentRequestsSent uint64 // ConsentExpiredTimestamp represents the timestamp at which the latest valid // STUN binding response expired. ConsentExpiredTimestamp time.Time }
CandidatePairStats contains ICE candidate pair statistics
type CandidatePeerReflexive ¶
type CandidatePeerReflexive struct {
// contains filtered or unexported fields
}
CandidatePeerReflexive ...
func NewCandidatePeerReflexive ¶
func NewCandidatePeerReflexive(config *CandidatePeerReflexiveConfig) (*CandidatePeerReflexive, error)
NewCandidatePeerReflexive creates a new peer reflective candidate
func (*CandidatePeerReflexive) Address ¶
func (c *CandidatePeerReflexive) Address() string
Address returns Candidate Address
func (*CandidatePeerReflexive) Component ¶
func (c *CandidatePeerReflexive) Component() uint16
Component returns candidate component
func (*CandidatePeerReflexive) Done ¶
func (c *CandidatePeerReflexive) Done() <-chan struct{}
Done implements context.Context
func (*CandidatePeerReflexive) Err ¶
func (c *CandidatePeerReflexive) Err() error
Err implements context.Context
func (*CandidatePeerReflexive) Foundation ¶
func (c *CandidatePeerReflexive) Foundation() string
func (*CandidatePeerReflexive) ID ¶
func (c *CandidatePeerReflexive) ID() string
ID returns Candidate ID
func (*CandidatePeerReflexive) LastReceived ¶
LastReceived returns a time.Time indicating the last time this candidate was received
func (*CandidatePeerReflexive) LastSent ¶
LastSent returns a time.Time indicating the last time this candidate was sent
func (*CandidatePeerReflexive) LocalPreference ¶
func (c *CandidatePeerReflexive) LocalPreference() uint16
LocalPreference returns the local preference for this candidate
func (*CandidatePeerReflexive) Marshal ¶
func (c *CandidatePeerReflexive) Marshal() string
Marshal returns the string representation of the ICECandidate
func (*CandidatePeerReflexive) NetworkType ¶
func (c *CandidatePeerReflexive) NetworkType() NetworkType
NetworkType returns candidate NetworkType
func (*CandidatePeerReflexive) Port ¶
func (c *CandidatePeerReflexive) Port() int
Port returns Candidate Port
func (*CandidatePeerReflexive) Priority ¶
func (c *CandidatePeerReflexive) Priority() uint32
Priority computes the priority for this ICE Candidate See: https://www.rfc-editor.org/rfc/rfc8445#section-5.1.2.1
func (*CandidatePeerReflexive) RelatedAddress ¶
func (c *CandidatePeerReflexive) RelatedAddress() *CandidateRelatedAddress
RelatedAddress returns *CandidateRelatedAddress
func (*CandidatePeerReflexive) SetComponent ¶
func (c *CandidatePeerReflexive) SetComponent(component uint16)
func (*CandidatePeerReflexive) String ¶
func (c *CandidatePeerReflexive) String() string
String makes the candidateBase printable
func (*CandidatePeerReflexive) Type ¶
func (c *CandidatePeerReflexive) Type() CandidateType
Type returns candidate type
func (*CandidatePeerReflexive) TypePreference ¶
func (c *CandidatePeerReflexive) TypePreference() uint16
TypePreference returns the type preference for this candidate
type CandidatePeerReflexiveConfig ¶
type CandidatePeerReflexiveConfig struct { CandidateID string Network string Address string Port int Component uint16 Priority uint32 Foundation string RelAddr string RelPort int }
CandidatePeerReflexiveConfig is the config required to create a new CandidatePeerReflexive
type CandidateRelatedAddress ¶
CandidateRelatedAddress convey transport addresses related to the candidate, useful for diagnostics and other purposes.
func (*CandidateRelatedAddress) Equal ¶
func (c *CandidateRelatedAddress) Equal(other *CandidateRelatedAddress) bool
Equal allows comparing two CandidateRelatedAddresses. The CandidateRelatedAddress are allowed to be nil.
func (*CandidateRelatedAddress) String ¶
func (c *CandidateRelatedAddress) String() string
String makes CandidateRelatedAddress printable
type CandidateRelay ¶
type CandidateRelay struct {
// contains filtered or unexported fields
}
CandidateRelay ...
func NewCandidateRelay ¶
func NewCandidateRelay(config *CandidateRelayConfig) (*CandidateRelay, error)
NewCandidateRelay creates a new relay candidate
func (*CandidateRelay) Address ¶
func (c *CandidateRelay) Address() string
Address returns Candidate Address
func (*CandidateRelay) Component ¶
func (c *CandidateRelay) Component() uint16
Component returns candidate component
func (*CandidateRelay) Done ¶
func (c *CandidateRelay) Done() <-chan struct{}
Done implements context.Context
func (*CandidateRelay) Foundation ¶
func (c *CandidateRelay) Foundation() string
func (*CandidateRelay) LastReceived ¶
LastReceived returns a time.Time indicating the last time this candidate was received
func (*CandidateRelay) LastSent ¶
LastSent returns a time.Time indicating the last time this candidate was sent
func (*CandidateRelay) LocalPreference ¶
func (c *CandidateRelay) LocalPreference() uint16
LocalPreference returns the local preference for this candidate
func (*CandidateRelay) Marshal ¶
func (c *CandidateRelay) Marshal() string
Marshal returns the string representation of the ICECandidate
func (*CandidateRelay) NetworkType ¶
func (c *CandidateRelay) NetworkType() NetworkType
NetworkType returns candidate NetworkType
func (*CandidateRelay) Priority ¶
func (c *CandidateRelay) Priority() uint32
Priority computes the priority for this ICE Candidate See: https://www.rfc-editor.org/rfc/rfc8445#section-5.1.2.1
func (*CandidateRelay) RelatedAddress ¶
func (c *CandidateRelay) RelatedAddress() *CandidateRelatedAddress
RelatedAddress returns *CandidateRelatedAddress
func (*CandidateRelay) RelayProtocol ¶
func (c *CandidateRelay) RelayProtocol() string
RelayProtocol returns the protocol used between the endpoint and the relay server.
func (*CandidateRelay) SetComponent ¶
func (c *CandidateRelay) SetComponent(component uint16)
func (*CandidateRelay) String ¶
func (c *CandidateRelay) String() string
String makes the candidateBase printable
func (*CandidateRelay) Type ¶
func (c *CandidateRelay) Type() CandidateType
Type returns candidate type
func (*CandidateRelay) TypePreference ¶
func (c *CandidateRelay) TypePreference() uint16
TypePreference returns the type preference for this candidate
type CandidateRelayConfig ¶
type CandidateRelayConfig struct { CandidateID string Network string Address string Port int Component uint16 Priority uint32 Foundation string RelAddr string RelPort int RelayProtocol string OnClose func() error }
CandidateRelayConfig is the config required to create a new CandidateRelay
type CandidateServerReflexive ¶
type CandidateServerReflexive struct {
// contains filtered or unexported fields
}
CandidateServerReflexive ...
func NewCandidateServerReflexive ¶
func NewCandidateServerReflexive(config *CandidateServerReflexiveConfig) (*CandidateServerReflexive, error)
NewCandidateServerReflexive creates a new server reflective candidate
func (*CandidateServerReflexive) Address ¶
func (c *CandidateServerReflexive) Address() string
Address returns Candidate Address
func (*CandidateServerReflexive) Component ¶
func (c *CandidateServerReflexive) Component() uint16
Component returns candidate component
func (*CandidateServerReflexive) Done ¶
func (c *CandidateServerReflexive) Done() <-chan struct{}
Done implements context.Context
func (*CandidateServerReflexive) Err ¶
func (c *CandidateServerReflexive) Err() error
Err implements context.Context
func (*CandidateServerReflexive) Foundation ¶
func (c *CandidateServerReflexive) Foundation() string
func (*CandidateServerReflexive) ID ¶
func (c *CandidateServerReflexive) ID() string
ID returns Candidate ID
func (*CandidateServerReflexive) LastReceived ¶
LastReceived returns a time.Time indicating the last time this candidate was received
func (*CandidateServerReflexive) LastSent ¶
LastSent returns a time.Time indicating the last time this candidate was sent
func (*CandidateServerReflexive) LocalPreference ¶
func (c *CandidateServerReflexive) LocalPreference() uint16
LocalPreference returns the local preference for this candidate
func (*CandidateServerReflexive) Marshal ¶
func (c *CandidateServerReflexive) Marshal() string
Marshal returns the string representation of the ICECandidate
func (*CandidateServerReflexive) NetworkType ¶
func (c *CandidateServerReflexive) NetworkType() NetworkType
NetworkType returns candidate NetworkType
func (*CandidateServerReflexive) Port ¶
func (c *CandidateServerReflexive) Port() int
Port returns Candidate Port
func (*CandidateServerReflexive) Priority ¶
func (c *CandidateServerReflexive) Priority() uint32
Priority computes the priority for this ICE Candidate See: https://www.rfc-editor.org/rfc/rfc8445#section-5.1.2.1
func (*CandidateServerReflexive) RelatedAddress ¶
func (c *CandidateServerReflexive) RelatedAddress() *CandidateRelatedAddress
RelatedAddress returns *CandidateRelatedAddress
func (*CandidateServerReflexive) SetComponent ¶
func (c *CandidateServerReflexive) SetComponent(component uint16)
func (*CandidateServerReflexive) String ¶
func (c *CandidateServerReflexive) String() string
String makes the candidateBase printable
func (*CandidateServerReflexive) Type ¶
func (c *CandidateServerReflexive) Type() CandidateType
Type returns candidate type
func (*CandidateServerReflexive) TypePreference ¶
func (c *CandidateServerReflexive) TypePreference() uint16
TypePreference returns the type preference for this candidate
type CandidateServerReflexiveConfig ¶
type CandidateServerReflexiveConfig struct { CandidateID string Network string Address string Port int Component uint16 Priority uint32 Foundation string RelAddr string RelPort int }
CandidateServerReflexiveConfig is the config required to create a new CandidateServerReflexive
type CandidateStats ¶
type CandidateStats struct { // Timestamp is the timestamp associated with this object. Timestamp time.Time // ID is the candidate ID ID string // NetworkType represents the type of network interface used by the base of a // local candidate (the address the ICE agent sends from). Only present for // local candidates; it's not possible to know what type of network interface // a remote candidate is using. // // Note: // This stat only tells you about the network interface used by the first "hop"; // it's possible that a connection will be bottlenecked by another type of network. // For example, when using Wi-Fi tethering, the networkType of the relevant candidate // would be "wifi", even when the next hop is over a cellular connection. NetworkType NetworkType // IP is the IP address of the candidate, allowing for IPv4 addresses and // IPv6 addresses, but fully qualified domain names (FQDNs) are not allowed. IP string // Port is the port number of the candidate. Port int // CandidateType is the "Type" field of the ICECandidate. CandidateType CandidateType // Priority is the "Priority" field of the ICECandidate. Priority uint32 // URL is the URL of the TURN or STUN server indicated in the that translated // this IP address. It is the URL address surfaced in an PeerConnectionICEEvent. URL string // RelayProtocol is the protocol used by the endpoint to communicate with the // TURN server. This is only present for local candidates. Valid values for // the TURN URL protocol is one of UDP, TCP, or TLS. RelayProtocol string // Deleted is true if the candidate has been deleted/freed. For host candidates, // this means that any network resources (typically a socket) associated with the // candidate have been released. For TURN candidates, this means the TURN allocation // is no longer active. // // Only defined for local candidates. For remote candidates, this property is not applicable. Deleted bool }
CandidateStats contains ICE candidate statistics related to the ICETransport objects.
type CandidateType ¶
type CandidateType byte
CandidateType represents the type of candidate
const ( CandidateTypeUnspecified CandidateType = iota CandidateTypeHost CandidateTypeServerReflexive CandidateTypePeerReflexive CandidateTypeRelay )
CandidateType enum
func (CandidateType) Preference ¶
func (c CandidateType) Preference() uint16
Preference returns the preference weight of a CandidateType
4.1.2.2. Guidelines for Choosing Type and Local Preferences The RECOMMENDED values are 126 for host candidates, 100 for server reflexive candidates, 110 for peer reflexive candidates, and 0 for relayed candidates.
func (CandidateType) String ¶
func (c CandidateType) String() string
String makes CandidateType printable
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents the ICE connection. At the moment the lifetime of the Conn is equal to the Agent.
func (*Conn) BytesReceived ¶
BytesReceived returns the number of bytes received
func (*Conn) Close ¶
Close implements the Conn Close method. It is used to close the connection. Any calls to Read and Write will be unblocked and return an error.
func (*Conn) LocalAddr ¶
LocalAddr returns the local address of the current selected pair or nil if there is none.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the remote address of the current selected pair or nil if there is none.
func (*Conn) SetReadDeadline ¶
SetReadDeadline is a stub
func (*Conn) SetWriteDeadline ¶
SetWriteDeadline is a stub
type ConnectionState ¶
type ConnectionState int
ConnectionState is an enum showing the state of a ICE Connection
const ( // ConnectionStateUnknown represents an unknown state ConnectionStateUnknown ConnectionState = iota // ConnectionStateNew ICE agent is gathering addresses ConnectionStateNew // 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
func (ConnectionState) String ¶
func (c ConnectionState) String() string
type GatheringState ¶
type GatheringState int
GatheringState describes the state of the candidate gathering process
const ( // GatheringStateUnknown represents an unknown state GatheringStateUnknown GatheringState = iota // GatheringStateNew indicates candidate gathering is not yet started GatheringStateNew // GatheringStateGathering indicates candidate gathering is ongoing GatheringStateGathering // GatheringStateComplete indicates candidate gathering has been completed GatheringStateComplete )
func (GatheringState) String ¶
func (t GatheringState) String() string
type MultiTCPMuxDefault ¶
type MultiTCPMuxDefault struct {
// contains filtered or unexported fields
}
MultiTCPMuxDefault implements both TCPMux and AllConnsGetter, allowing users to pass multiple TCPMux instances to the ICE agent configuration.
func NewMultiTCPMuxDefault ¶
func NewMultiTCPMuxDefault(muxes ...TCPMux) *MultiTCPMuxDefault
NewMultiTCPMuxDefault creates an instance of MultiTCPMuxDefault that uses the provided TCPMux instances.
func (*MultiTCPMuxDefault) Close ¶
func (m *MultiTCPMuxDefault) Close() error
Close the multi mux, no further connections could be created
func (*MultiTCPMuxDefault) GetAllConns ¶
func (m *MultiTCPMuxDefault) GetAllConns(ufrag string, isIPv6 bool, local net.IP) ([]net.PacketConn, error)
GetAllConns returns a PacketConn for each underlying TCPMux
func (*MultiTCPMuxDefault) GetConnByUfrag ¶
func (m *MultiTCPMuxDefault) GetConnByUfrag(ufrag string, isIPv6 bool, local net.IP) (net.PacketConn, error)
GetConnByUfrag returns a PacketConn given the connection's ufrag, network and local address creates the connection if an existing one can't be found. This, unlike GetAllConns, will only return a single PacketConn from the first mux that was passed in to NewMultiTCPMuxDefault.
func (*MultiTCPMuxDefault) RemoveConnByUfrag ¶
func (m *MultiTCPMuxDefault) RemoveConnByUfrag(ufrag string)
RemoveConnByUfrag stops and removes the muxed packet connection from all underlying TCPMux instances.
type MultiUDPMuxDefault ¶
type MultiUDPMuxDefault struct {
// contains filtered or unexported fields
}
MultiUDPMuxDefault implements both UDPMux and AllConnsGetter, allowing users to pass multiple UDPMux instances to the ICE agent configuration.
func NewMultiUDPMuxDefault ¶
func NewMultiUDPMuxDefault(muxes ...UDPMux) *MultiUDPMuxDefault
NewMultiUDPMuxDefault creates an instance of MultiUDPMuxDefault that uses the provided UDPMux instances.
func NewMultiUDPMuxFromPort ¶
func NewMultiUDPMuxFromPort(port int, opts ...UDPMuxFromPortOption) (*MultiUDPMuxDefault, error)
NewMultiUDPMuxFromPort creates an instance of MultiUDPMuxDefault that listen all interfaces on the provided port.
func (*MultiUDPMuxDefault) Close ¶
func (m *MultiUDPMuxDefault) Close() error
Close the multi mux, no further connections could be created
func (*MultiUDPMuxDefault) GetConn ¶
func (m *MultiUDPMuxDefault) GetConn(ufrag string, addr net.Addr) (net.PacketConn, error)
GetConn returns a PacketConn given the connection's ufrag and network creates the connection if an existing one can't be found.
func (*MultiUDPMuxDefault) GetListenAddresses ¶
func (m *MultiUDPMuxDefault) GetListenAddresses() []net.Addr
GetListenAddresses returns the list of addresses that this mux is listening on
func (*MultiUDPMuxDefault) RemoveConnByUfrag ¶
func (m *MultiUDPMuxDefault) RemoveConnByUfrag(ufrag string)
RemoveConnByUfrag stops and removes the muxed packet connection from all underlying UDPMux instances.
type MulticastDNSMode ¶
type MulticastDNSMode byte
MulticastDNSMode represents the different Multicast modes ICE can run in
const ( // MulticastDNSModeDisabled means remote mDNS candidates will be discarded, and local host candidates will use IPs MulticastDNSModeDisabled MulticastDNSMode = iota + 1 // MulticastDNSModeQueryOnly means remote mDNS candidates will be accepted, and local host candidates will use IPs MulticastDNSModeQueryOnly // MulticastDNSModeQueryAndGather means remote mDNS candidates will be accepted, and local host candidates will use mDNS MulticastDNSModeQueryAndGather )
MulticastDNSMode enum
type NetworkType ¶
type NetworkType int
NetworkType represents the type of network
const ( // NetworkTypeUDP4 indicates UDP over IPv4. NetworkTypeUDP4 NetworkType = iota + 1 // NetworkTypeUDP6 indicates UDP over IPv6. NetworkTypeUDP6 // NetworkTypeTCP4 indicates TCP over IPv4. NetworkTypeTCP4 // NetworkTypeTCP6 indicates TCP over IPv6. NetworkTypeTCP6 )
func (NetworkType) IsIPv4 ¶
func (t NetworkType) IsIPv4() bool
IsIPv4 returns whether the network type is IPv4 or not.
func (NetworkType) IsIPv6 ¶
func (t NetworkType) IsIPv6() bool
IsIPv6 returns whether the network type is IPv6 or not.
func (NetworkType) IsReliable ¶
func (t NetworkType) IsReliable() bool
IsReliable returns true if the network is reliable
func (NetworkType) IsTCP ¶
func (t NetworkType) IsTCP() bool
IsTCP returns true when network is TCP4 or TCP6.
func (NetworkType) IsUDP ¶
func (t NetworkType) IsUDP() bool
IsUDP returns true when network is UDP4 or UDP6.
func (NetworkType) NetworkShort ¶
func (t NetworkType) NetworkShort() string
NetworkShort returns the short network description
func (NetworkType) String ¶
func (t NetworkType) String() string
type PriorityAttr ¶
type PriorityAttr uint32
PriorityAttr represents PRIORITY attribute.
func (PriorityAttr) AddTo ¶
func (p PriorityAttr) AddTo(m *stun.Message) error
AddTo adds PRIORITY attribute to message.
func (*PriorityAttr) GetFrom ¶
func (p *PriorityAttr) GetFrom(m *stun.Message) error
GetFrom decodes PRIORITY attribute from message.
type ProtoType
deprecated
type ProtoType = stun.ProtoType
ProtoType indicates the transport protocol type that is used in the ice.URL structure.
Deprecated: TPlease use pion/stun.ProtoType
type Role ¶
type Role byte
Role represents ICE agent role, which can be controlling or controlled.
func (Role) MarshalText ¶
MarshalText implements TextMarshaler.
func (*Role) UnmarshalText ¶
UnmarshalText implements TextUnmarshaler.
type SchemeType
deprecated
type SchemeType = stun.SchemeType
SchemeType indicates the type of server used in the ice.URL structure.
Deprecated: Please use pion/stun.SchemeType
type TCPMux ¶
type TCPMux interface { io.Closer GetConnByUfrag(ufrag string, isIPv6 bool, local net.IP) (net.PacketConn, error) RemoveConnByUfrag(ufrag string) }
TCPMux is allows grouping multiple TCP net.Conns and using them like UDP net.PacketConns. The main implementation of this is TCPMuxDefault, and this interface exists to allow mocking in tests.
type TCPMuxDefault ¶
type TCPMuxDefault struct {
// contains filtered or unexported fields
}
TCPMuxDefault muxes TCP net.Conns into net.PacketConns and groups them by Ufrag. It is a default implementation of TCPMux interface.
func NewTCPMuxDefault ¶
func NewTCPMuxDefault(params TCPMuxParams) *TCPMuxDefault
NewTCPMuxDefault creates a new instance of TCPMuxDefault.
func (*TCPMuxDefault) Close ¶
func (m *TCPMuxDefault) Close() error
Close closes the listener and waits for all goroutines to exit.
func (*TCPMuxDefault) GetConnByUfrag ¶
func (m *TCPMuxDefault) GetConnByUfrag(ufrag string, isIPv6 bool, local net.IP) (net.PacketConn, error)
GetConnByUfrag retrieves an existing or creates a new net.PacketConn.
func (*TCPMuxDefault) LocalAddr ¶
func (m *TCPMuxDefault) LocalAddr() net.Addr
LocalAddr returns the listening address of this TCPMuxDefault.
func (*TCPMuxDefault) RemoveConnByUfrag ¶
func (m *TCPMuxDefault) RemoveConnByUfrag(ufrag string)
RemoveConnByUfrag closes and removes a net.PacketConn by Ufrag.
type TCPMuxParams ¶
type TCPMuxParams struct { Listener net.Listener Logger logging.LeveledLogger ReadBufferSize int // Maximum buffer size for write op. 0 means no write buffer, the write op will block until the whole packet is written // if the write buffer is full, the subsequent write packet will be dropped until it has enough space. // a default 4MB is recommended. WriteBufferSize int // A new established connection will be removed if the first STUN binding request is not received within this timeout, // avoiding the client with bad network or attacker to create a lot of empty connections. // Default 30s timeout will be used if not set. FirstStunBindTimeout time.Duration // TCPMux will create connection from STUN binding request with an unknown username, if // the connection is not used in the timeout, it will be removed to avoid resource leak / attack. // Default 30s timeout will be used if not set. AliveDurationForConnFromStun time.Duration }
TCPMuxParams are parameters for TCPMux.
type TCPType ¶
type TCPType int
TCPType is the type of ICE TCP candidate as described in https://tools.ietf.org/html/rfc6544#section-4.5
const ( // TCPTypeUnspecified is the default value. For example UDP candidates do not // need this field. TCPTypeUnspecified TCPType = iota // TCPTypeActive is active TCP candidate, which initiates TCP connections. TCPTypeActive // TCPTypePassive is passive TCP candidate, only accepts TCP connections. TCPTypePassive // TCPTypeSimultaneousOpen is like active and passive at the same time. TCPTypeSimultaneousOpen )
func NewTCPType ¶
NewTCPType creates a new TCPType from string.
type UDPMux ¶
type UDPMux interface { io.Closer GetConn(ufrag string, addr net.Addr) (net.PacketConn, error) RemoveConnByUfrag(ufrag string) GetListenAddresses() []net.Addr }
UDPMux allows multiple connections to go over a single UDP port
type UDPMuxDefault ¶
type UDPMuxDefault struct {
// contains filtered or unexported fields
}
UDPMuxDefault is an implementation of the interface
func NewUDPMuxDefault ¶
func NewUDPMuxDefault(params UDPMuxParams) *UDPMuxDefault
NewUDPMuxDefault creates an implementation of UDPMux
func (*UDPMuxDefault) Close ¶
func (m *UDPMuxDefault) Close() error
Close the mux, no further connections could be created
func (*UDPMuxDefault) GetConn ¶
func (m *UDPMuxDefault) GetConn(ufrag string, addr net.Addr) (net.PacketConn, error)
GetConn returns a PacketConn given the connection's ufrag and network address creates the connection if an existing one can't be found
func (*UDPMuxDefault) GetListenAddresses ¶
func (m *UDPMuxDefault) GetListenAddresses() []net.Addr
GetListenAddresses returns the list of addresses that this mux is listening on
func (*UDPMuxDefault) IsClosed ¶
func (m *UDPMuxDefault) IsClosed() bool
IsClosed returns true if the mux had been closed
func (*UDPMuxDefault) LocalAddr ¶
func (m *UDPMuxDefault) LocalAddr() net.Addr
LocalAddr returns the listening address of this UDPMuxDefault
func (*UDPMuxDefault) RemoveConnByUfrag ¶
func (m *UDPMuxDefault) RemoveConnByUfrag(ufrag string)
RemoveConnByUfrag stops and removes the muxed packet connection
type UDPMuxFromPortOption ¶
type UDPMuxFromPortOption interface {
// contains filtered or unexported methods
}
UDPMuxFromPortOption provide options for NewMultiUDPMuxFromPort
func UDPMuxFromPortWithIPFilter ¶
func UDPMuxFromPortWithIPFilter(f func(ip net.IP) (keep bool)) UDPMuxFromPortOption
UDPMuxFromPortWithIPFilter set the filter to filter out IP addresses that should not be used
func UDPMuxFromPortWithInterfaceFilter ¶
func UDPMuxFromPortWithInterfaceFilter(f func(string) (keep bool)) UDPMuxFromPortOption
UDPMuxFromPortWithInterfaceFilter set the filter to filter out interfaces that should not be used
func UDPMuxFromPortWithLogger ¶
func UDPMuxFromPortWithLogger(logger logging.LeveledLogger) UDPMuxFromPortOption
UDPMuxFromPortWithLogger set the logger for the created UDPMux
func UDPMuxFromPortWithLoopback ¶
func UDPMuxFromPortWithLoopback() UDPMuxFromPortOption
UDPMuxFromPortWithLoopback set loopback interface should be included
func UDPMuxFromPortWithNet ¶
func UDPMuxFromPortWithNet(n transport.Net) UDPMuxFromPortOption
UDPMuxFromPortWithNet sets the network transport to use.
func UDPMuxFromPortWithNetworks ¶
func UDPMuxFromPortWithNetworks(networks ...NetworkType) UDPMuxFromPortOption
UDPMuxFromPortWithNetworks set the networks that should be used. default is both IPv4 and IPv6
func UDPMuxFromPortWithReadBufferSize ¶
func UDPMuxFromPortWithReadBufferSize(size int) UDPMuxFromPortOption
UDPMuxFromPortWithReadBufferSize set the UDP connection read buffer size
func UDPMuxFromPortWithWriteBufferSize ¶
func UDPMuxFromPortWithWriteBufferSize(size int) UDPMuxFromPortOption
UDPMuxFromPortWithWriteBufferSize set the UDP connection write buffer size
type UDPMuxParams ¶
type UDPMuxParams struct { Logger logging.LeveledLogger UDPConn net.PacketConn UDPConnString string // Required for gathering local addresses // in case a un UDPConn is passed which does not // bind to a specific local address. Net transport.Net }
UDPMuxParams are parameters for UDPMux.
type URL
deprecated
type URL = stun.URI
URL represents a STUN (rfc7064) or TURN (rfc7065) URI
Deprecated: Please use pion/stun.URI
type UniversalUDPMux ¶
type UniversalUDPMux interface { UDPMux GetXORMappedAddr(stunAddr net.Addr, deadline time.Duration) (*stun.XORMappedAddress, error) GetRelayedAddr(turnAddr net.Addr, deadline time.Duration) (*net.Addr, error) GetConnForURL(ufrag string, url string, addr net.Addr) (net.PacketConn, error) }
UniversalUDPMux allows multiple connections to go over a single UDP port for host, server reflexive and relayed candidates. Actual connection muxing is happening in the UDPMux.
type UniversalUDPMuxDefault ¶
type UniversalUDPMuxDefault struct { *UDPMuxDefault // contains filtered or unexported fields }
UniversalUDPMuxDefault handles STUN and TURN servers packets by wrapping the original UDPConn overriding ReadFrom. It the passes packets to the UDPMux that does the actual connection muxing.
func NewUniversalUDPMuxDefault ¶
func NewUniversalUDPMuxDefault(params UniversalUDPMuxParams) *UniversalUDPMuxDefault
NewUniversalUDPMuxDefault creates an implementation of UniversalUDPMux embedding UDPMux
func (*UniversalUDPMuxDefault) GetConnForURL ¶
func (m *UniversalUDPMuxDefault) GetConnForURL(ufrag string, url string, addr net.Addr) (net.PacketConn, error)
GetConnForURL add uniques to the muxed connection by concatenating ufrag and URL (e.g. STUN URL) to be able to support multiple STUN/TURN servers and return a unique connection per server.
func (*UniversalUDPMuxDefault) GetRelayedAddr ¶
GetRelayedAddr creates relayed connection to the given TURN service and returns the relayed addr. Not implemented yet.
func (*UniversalUDPMuxDefault) GetXORMappedAddr ¶
func (m *UniversalUDPMuxDefault) GetXORMappedAddr(serverAddr net.Addr, deadline time.Duration) (*stun.XORMappedAddress, error)
GetXORMappedAddr returns *stun.XORMappedAddress if already present for a given STUN server. Makes a STUN binding request to discover mapped address otherwise. Blocks until the stun.XORMappedAddress has been discovered or deadline. Method is safe for concurrent use.
type UniversalUDPMuxParams ¶
type UniversalUDPMuxParams struct { Logger logging.LeveledLogger UDPConn net.PacketConn XORMappedAddrCacheTTL time.Duration Net transport.Net }
UniversalUDPMuxParams are parameters for UniversalUDPMux server reflexive.
type UseCandidateAttr ¶
type UseCandidateAttr struct{}
UseCandidateAttr represents USE-CANDIDATE attribute.
func UseCandidate ¶
func UseCandidate() UseCandidateAttr
UseCandidate is shorthand for UseCandidateAttr.
func (UseCandidateAttr) AddTo ¶
func (UseCandidateAttr) AddTo(m *stun.Message) error
AddTo adds USE-CANDIDATE attribute to message.
func (UseCandidateAttr) IsSet ¶
func (UseCandidateAttr) IsSet(m *stun.Message) bool
IsSet returns true if USE-CANDIDATE attribute is set.
Source Files ¶
- active_tcp.go
- addr.go
- agent.go
- agent_config.go
- agent_handlers.go
- agent_stats.go
- candidate.go
- candidate_base.go
- candidate_host.go
- candidate_peer_reflexive.go
- candidate_relay.go
- candidate_server_reflexive.go
- candidatepair.go
- candidatepair_state.go
- candidaterelatedaddress.go
- candidatetype.go
- errors.go
- external_ip_mapper.go
- gather.go
- ice.go
- icecontrol.go
- mdns.go
- net.go
- networktype.go
- priority.go
- rand.go
- role.go
- selection.go
- stats.go
- tcp_mux.go
- tcp_mux_multi.go
- tcp_packet_conn.go
- tcptype.go
- transport.go
- udp_mux.go
- udp_mux_multi.go
- udp_mux_universal.go
- udp_muxed_conn.go
- url.go
- usecandidate.go
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
ping-pong
Package main implements a simple example demonstrating a Pion-to-Pion ICE connection
|
Package main implements a simple example demonstrating a Pion-to-Pion ICE connection |
Package internal implements internal functionality for Pions ICE module
|
Package internal implements internal functionality for Pions ICE module |
atomic
Package atomic contains custom atomic types
|
Package atomic contains custom atomic types |
fakenet
Package fakenet contains fake network abstractions
|
Package fakenet contains fake network abstractions |
stun
Package stun contains ICE specific STUN code
|
Package stun contains ICE specific STUN code |
taskloop
Package taskloop implements a task loop to run tasks sequentially in a separate Goroutine.
|
Package taskloop implements a task loop to run tasks sequentially in a separate Goroutine. |