Skip to main content

Overview

Deprecated: Use NewAgentWithOptions with functional options instead. This struct will be removed in a future major release.
AgentConfig collects arguments for ICE Agent construction into a single structure. It provides backward compatibility but is less flexible than the functional options pattern.

Type Definition

Fields

Network Configuration

[]*stun.URI
List of STUN/TURN server URLs for gathering server reflexive and relay candidates.
uint16
default:"0"
Minimum UDP port for host candidates. 0 allows the OS to choose.
uint16
default:"0"
Maximum UDP port for host candidates. 0 allows the OS to choose.
[]NetworkType
Enabled network types for gathering. Empty enables all types (UDP4, UDP6, TCP4, TCP6).
[]CandidateType
Enabled candidate types. Default: host, server reflexive, and relay.

Credentials

string
Local username fragment. Must have at least 24 bits of entropy if specified.
string
Local password. Must have at least 128 bits of entropy if specified.

Timeouts

*time.Duration
default:"5s"
Duration before transitioning to disconnected state. Set to 0 to disable.
*time.Duration
default:"25s"
Duration after disconnected before transitioning to failed. Set to 0 to disable.
*time.Duration
default:"2s"
Interval for sending keepalive packets. Set to 0 to disable.
*time.Duration
default:"200ms"
How often to run connectivity checks while connecting.
*time.Duration
default:"5s"
Wait time for STUN server responses during gathering.

Candidate Acceptance

*time.Duration
default:"0"
Minimum wait before selecting host candidates.
*time.Duration
default:"500ms"
Minimum wait before selecting server reflexive candidates.
*time.Duration
default:"1s"
Minimum wait before selecting peer reflexive candidates.
*time.Duration
default:"2s"
Minimum wait before selecting relay candidates.

Multicast DNS

MulticastDNSMode
default:"QueryOnly"
Controls mDNS behavior for local candidate resolution.
string
Hostname for mDNS. Must end with “.local”. Auto-generated if empty.

Advanced Options

*uint16
default:"7"
Maximum binding requests before considering a candidate pair failed.
bool
default:"false"
Enable ICE-lite mode. Lite agents only gather host candidates and don’t perform connectivity checks.
bool
default:"false"
Include loopback addresses in candidate gathering.
bool
default:"false"
Disable creation of active TCP candidates.
*uint16
default:"27"
Value subtracted from TCP candidate priorities relative to UDP.
bool
default:"false"
Skip certificate verification for TLS/DTLS TURN connections.
bool
default:"false"
For lite agents, check priority before switching pairs on USE-CANDIDATE.

Deprecated Fields

[]string
Deprecated: Use WithAddressRewriteRules option instead.
List of public IP addresses for 1:1 NAT mapping.
CandidateType
Deprecated: Use WithAddressRewriteRules option instead.
Candidate type for NAT1To1IPs (host or srflx).
bool
Deprecated: Always enabled.
Accept aggressive nomination from peer.

Filters and Handlers

func(string) bool
Function to whitelist/blacklist network interfaces by name.
func(net.IP) bool
Function to whitelist/blacklist IP addresses.
func(*stun.Message, Candidate, Candidate, *CandidatePair) bool
Custom handler for incoming STUN binding requests.

Multiplexing

TCPMux
TCP multiplexer for ICE-TCP. See TCPMux.
UDPMux
UDP multiplexer for host candidates. See UDPMux.
UniversalUDPMux
UDP multiplexer for server reflexive candidates. See UniversalUDPMux.

Transport

transport.Net
Custom network implementation (for testing or virtual networks).
proxy.Dialer
Proxy dialer for TURN connections through corporate proxies.

Logging

logging.LoggerFactory
Logger factory for creating structured loggers.

Migration Guide