Class TurnServer
A STUN and TURN server: answers Binding requests, and relays UDP between authenticated clients and their peers. Clients reach it over UDP, TCP or TLS; peers over UDP.
Implements
Inherited Members
Namespace: Uniform.Turn
Assembly: Uniform.Turn.dll
Syntax
public sealed class TurnServer : IAsyncDisposable
Remarks
It refuses to relay to DeniedPeers, by default every address that is not public, so it cannot be used to reach the server's own network. Data between two allocations of this server goes from one to the other directly, so clients behind the same router as the server need no NAT hairpinning.
- TurnServer.cs: listeners, relaying, expiry and status.
- TurnServer.Requests.cs: STUN and TURN requests, indications and channel data.
- TurnServer.Addresses.cs: UDP listeners per address, and following changes of the local and public addresses.
Constructors
| Edit this page View SourceTurnServer(TurnServerOptions, ITurnAuthenticator, ILogger<TurnServer>, TimeProvider?)
Create a server; StartAsync(CancellationToken) starts it.
Declaration
public TurnServer(TurnServerOptions options, ITurnAuthenticator authenticator, ILogger<TurnServer> logger, TimeProvider? time = null)
Parameters
| Type | Name | Description |
|---|---|---|
| TurnServerOptions | options | Where it listens and its limits. |
| ITurnAuthenticator | authenticator | Keys of the users' credentials. |
| ILogger<TurnServer> | logger | Log of allocations and errors; not of each packet. |
| TimeProvider | time | Clock of lifetimes and nonces. |
Properties
| Edit this page View SourceExternalAddress
The public address new allocations are given, once started; it follows ExternalAddressSource.
Declaration
public IPAddress ExternalAddress { get; }
Property Value
| Type | Description |
|---|---|
| IPAddress |
Status
Return what the server is doing.
Declaration
public TurnServerStatus Status { get; }
Property Value
| Type | Description |
|---|---|
| TurnServerStatus |
TcpEndPoint
The TCP address, once started, when listening over TCP.
Declaration
public IPEndPoint? TcpEndPoint { get; }
Property Value
| Type | Description |
|---|---|
| IPEndPoint |
TlsEndPoint
The TLS address, once started, when listening over TLS.
Declaration
public IPEndPoint? TlsEndPoint { get; }
Property Value
| Type | Description |
|---|---|
| IPEndPoint |
UdpEndPoint
The UDP and TCP address, once started; its port is the one chosen when Port is 0.
Declaration
public IPEndPoint? UdpEndPoint { get; }
Property Value
| Type | Description |
|---|---|
| IPEndPoint |
Methods
| Edit this page View SourceDisposeAsync()
Stop listening and end every allocation.
Declaration
public ValueTask DisposeAsync()
Returns
| Type | Description |
|---|---|
| ValueTask |
StartAsync(CancellationToken)
Bind the listeners and start serving; throw SocketException when a port is taken, and InvalidOperationException for settings that cannot work.
Declaration
public Task StartAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |