ice

package
v0.0.0-...-b172891 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

README

Implementation of the Internet Connectivity Exchange (ICE) protocol, following RFC 5245bis (https://tools.ietf.org/html/draft-ietf-ice-rfc5245bis-20).

Documentation

Index

Constants

View Source
const (
	TCP TransportProtocol = "tcp"
	UDP TransportProtocol = "udp"

	Unresolved AddressFamily = 0
	IPv4       AddressFamily = 4
	IPv6       AddressFamily = 6
)

Variables

View Source
var ErrReadTimeout = errors.New("read timeout")

Functions

This section is empty.

Types

type AddressFamily

type AddressFamily int

Address family is either IPv4, IPv6, or Unresolved (indicating that the stored IPAddress hasn't actually been resolved yet).

type Agent

type Agent struct {
	sync.Mutex
	// contains filtered or unexported fields
}

In the language of the above specification, this is a Full implementation of a Controlled ICE agent, supporting a single component of a single data stream.

func NewAgent

func NewAgent() *Agent

func (*Agent) Configure

func (a *Agent) Configure(mid, username, localPassword, remotePassword string)

func (*Agent) GetDataStream

func (a *Agent) GetDataStream(ctx context.Context) (*DataStream, error)

GetDataStream waits for a connection to be established.

func (*Agent) Start

func (a *Agent) Start(ctx context.Context, rcand <-chan Candidate) <-chan Candidate

Begin the ICE protocol to negotiate a peer-to-peer connection. Remote candidates are passed in through rcand, and local candidates are delivered through the returned channel (to be passed on to the signaling server).

type Attribute

type Attribute struct {
	// contains filtered or unexported fields
}

type Base

type Base struct {
	net.PacketConn
	// contains filtered or unexported fields
}

[RFC8445] defines a base to be "The transport address that an ICE agent sends from for a particular candidate." It is represented here by a UDP connection, listening on a single port.

type Candidate

type Candidate struct {
	// contains filtered or unexported fields
}

An ICE candidate (either local or remote). See [RFC8445 §5.3] for a definition of fields.

func ParseCandidate

func ParseCandidate(desc, sdpMid string) (c Candidate, err error)

An ICE candidate line is a string of the form

candidate:{foundation} {component-id} {transport} {priority} {connection-address} {port} typ {cand-type} ...

See https://tools.ietf.org/html/draft-ietf-mmusic-ice-sip-sdp-24#section-4.1

func (*Candidate) Mid

func (c *Candidate) Mid() string

func (Candidate) String

func (c Candidate) String() string

type CandidatePair

type CandidatePair struct {
	// contains filtered or unexported fields
}

func (*CandidatePair) Priority

func (p *CandidatePair) Priority() uint64

TODO: Handle case where we're the controlling agent.

func (*CandidatePair) String

func (p *CandidatePair) String() string

type CandidatePairState

type CandidatePairState int

Candidate pair states

const (
	Frozen CandidatePairState = iota
	Waiting
	InProgress
	Succeeded
	Failed
)

func (CandidatePairState) String

func (state CandidatePairState) String() string

type Checklist

type Checklist struct {
	// contains filtered or unexported fields
}

type DataStream

type DataStream struct {
	// contains filtered or unexported fields
}

A DataStream represents an active connection between two peers. ICE control packets are filtered out and handled by the ICE agent, so reads and writes deal exclusively with the data-level protocol.

func (*DataStream) Close

func (s *DataStream) Close() error

func (*DataStream) Done

func (s *DataStream) Done() <-chan struct{}

Return a channel that fires when the data session is severed.

func (*DataStream) Err

func (s *DataStream) Err() error

func (*DataStream) LocalAddr

func (s *DataStream) LocalAddr() net.Addr

func (*DataStream) Read

func (s *DataStream) Read(b []byte) (int, error)

func (*DataStream) RemoteAddr

func (s *DataStream) RemoteAddr() net.Addr

func (*DataStream) SetDeadline

func (s *DataStream) SetDeadline(t time.Time) error

func (*DataStream) SetReadDeadline

func (s *DataStream) SetReadDeadline(t time.Time) error

See net.Conn#SetReadDeadline for semantics.

func (*DataStream) SetWriteDeadline

func (s *DataStream) SetWriteDeadline(t time.Time) error

func (*DataStream) Write

func (s *DataStream) Write(b []byte) (int, error)

type IPAddress

type IPAddress string

The net package represents an IP address as a byte slice, either 4 bytes for an IPv4 address or 16 bytes for IPv6. But []byte cannot be compared with ==, and for simplicity we want TransportAddress instances to be comparable. So instead we represent an IP address a string (which is really just an immutable byte slice), with the understanding that it will have length 4 for IPv4, length 16 for IPv6, or end with ".local" for unresolved ephemeral mDNS hostnames.

type PriorityTable

type PriorityTable struct {
	// contains filtered or unexported fields
}

type TransportAddress

type TransportAddress struct {
	// contains filtered or unexported fields
}

func (TransportAddress) String

func (ta TransportAddress) String() string

type TransportProtocol

type TransportProtocol string

Transport protocol is either "udp" or "tcp" (support for the latter is currently incomplete).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL