StunClientPool class

A class that manages a pool of STUN clients for improved reliability and NAT detection

Constructors

StunClientPool.new({List<({String host, int port})>? stunServers, Duration timeout = defaultTimeout, Duration healthCheckInterval = defaultHealthCheckInterval})
Creates a new STUN client pool

Properties

hashCode int
The hash code for this object.
no setterinherited
healthCheckInterval Duration
Health check interval
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
timeout Duration
Timeout for STUN requests
final

Methods

addServer(String host, int port) → void
Adds a new STUN server to the pool
behaviorToNatType(NatBehavior behavior) NatType
Maps NatBehavior to traditional NatType
detectNatType() Future<NatType>
Detects NAT type by comparing responses from multiple STUN servers
discover() Future<StunResponse>
Discovers external IP address and port using the pool of STUN servers
discoverNatBehavior() Future<NatBehavior>
Discovers detailed NAT behavior according to RFC 5780
dispose() → void
Disposes the STUN client pool
getServerHealthStatus() List<({int consecutiveFailures, int healthScore, String host, Duration? lastResponseTime, DateTime? lastSuccessTime, int port})>
Gets the current health status of all servers in the pool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeServer(String host, int port) → void
Removes a STUN server from the pool
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

defaultHealthCheckInterval → const Duration
Default health check interval
defaultStunServers → const List<({String host, int port})>
Default list of STUN servers to use
defaultTimeout → const Duration
Default timeout for STUN requests