fm.liveswitch.TurnServer Class Reference

An TURN/STUN server. More...

Public Member Functions

int getAllocationCount ()
 Gets the number of active allocations. More...
 
int getAllocationPortMax ()
 Gets the maximum allowed port to be used when allocating sockets. More...
 
int getAllocationPortMin ()
 Gets the minimum allowed port to be used when allocating sockets. More...
 
long getDefaultAllocateLifetime ()
 Gets the default lifetime for new allocations in seconds. More...
 
long getDefaultRefreshLifetime ()
 Gets the default lifetime for refreshed allocations in seconds. More...
 
boolean getDisableBypass ()
 Gets a value indicating whether to disable the in-memory bypass of the network when communicating between two relay candidates. More...
 
String[] getForbiddenPeerCidrs ()
 Gets the list of forbidden peer CIDRs. More...
 
boolean getForceDefaultAllocateLifetime ()
 Gets whether the server should force the default lifetime for new allocations (true) or allow clients to request their own lifetime within the min/max range (false). More...
 
boolean getForceDefaultRefreshLifetime ()
 Gets whether the server should force the default lifetime for refreshed allocations (true) or allow clients to request their own lifetime within the min/max range (false). More...
 
long getMaxAllocateLifetime ()
 Gets the maximum lifetime for new allocations in seconds. More...
 
long getMaxRefreshLifetime ()
 Gets the maximum lifetime for refreshed allocations in seconds. More...
 
long getMinAllocateLifetime ()
 Gets the minimum lifetime for new allocations in seconds. More...
 
long getMinRefreshLifetime ()
 Gets the minimum lifetime for refreshed allocations in seconds. More...
 
String getNonce ()
 Gets the current nonce. More...
 
String getRealm ()
 Gets the realm used for this server. More...
 
boolean getStaleNonceSecurity ()
 Gets whether the server should enforce stale-nonce security by sending a 438 Stale Nonce in response to allocate requests with a stale or non-existent nonce. More...
 
void setAllocationPortMax (int value)
 Sets the maximum allowed port to be used when allocating sockets. More...
 
void setAllocationPortMin (int value)
 Sets the minimum allowed port to be used when allocating sockets. More...
 
void setDefaultAllocateLifetime (long value)
 Sets the default lifetime for new allocations in seconds. More...
 
void setDefaultRefreshLifetime (long value)
 Sets the default lifetime for refreshed allocations in seconds. More...
 
void setDisableBypass (boolean value)
 Sets a value indicating whether to disable the in-memory bypass of the network when communicating between two relay candidates. More...
 
void setForbiddenPeerCidrs (String[] value)
 Sets the list of forbidden peer CIDRs. More...
 
void setForceDefaultAllocateLifetime (boolean value)
 Sets whether the server should force the default lifetime for new allocations (true) or allow clients to request their own lifetime within the min/max range (false). More...
 
void setForceDefaultRefreshLifetime (boolean value)
 Sets whether the server should force the default lifetime for refreshed allocations (true) or allow clients to request their own lifetime within the min/max range (false). More...
 
void setMaxAllocateLifetime (long value)
 Sets the maximum lifetime for new allocations in seconds. More...
 
void setMaxRefreshLifetime (long value)
 Sets the maximum lifetime for refreshed allocations in seconds. More...
 
void setRealm (String value)
 Sets the realm used for this server. More...
 
void setStaleNonceSecurity (boolean value)
 Sets whether the server should enforce stale-nonce security by sending a 438 Stale Nonce in response to allocate requests with a stale or non-existent nonce. More...
 
boolean start (fm.liveswitch.ServerAddress[] udpAddresses, fm.liveswitch.ServerAddress[] tcpAddresses, fm.liveswitch.ServerAddress[] tlsAddresses)
 Starts the server. More...
 
boolean stop ()
 Stops the server. More...
 
 TurnServer (fm.liveswitch.IFunction1< fm.liveswitch.TurnAuthArgs, fm.liveswitch.TurnAuthResult > authCallback)
 Initializes a new instance of the fm.liveswitch.TurnServer class. More...
 
- Public Member Functions inherited from fm.liveswitch.StunServer
fm.liveswitch.IFunction1< fm.liveswitch.DatagramSocketCreateArgs, fm.liveswitch.DatagramSocketgetCreateDatagramSocket ()
 Gets the create callback to create a datagram socket. More...
 
fm.liveswitch.IFunction1< fm.liveswitch.StreamSocketCreateArgs, fm.liveswitch.StreamSocketgetCreateStreamSocket ()
 Gets the create callback to create a stream socket. More...
 
boolean getDisableTcp ()
 Gets whether to prevent the server from listening for TCP requests. More...
 
boolean getDisableTls ()
 Gets whether to prevent the server from listening for TLS requests. More...
 
boolean getDisableUdp ()
 Gets whether to prevent the server from listening for UDP requests. More...
 
fm.liveswitch.ServerAddress getLocalTcpAddress ()
 Gets the local TCP address. More...
 
fm.liveswitch.ServerAddress[] getLocalTcpAddresses ()
 Gets the local TCP addresses. More...
 
fm.liveswitch.ServerAddress getLocalUdpAddress ()
 Gets the local UDP address. More...
 
fm.liveswitch.ServerAddress[] getLocalUdpAddresses ()
 Gets the local UDP addresses. More...
 
int getStreamSendTimeout ()
 Gets timeout for asynchronous data sending over stream sockets in ms. More...
 
fm.liveswitch.ServerAddress[] getTcpAddresses ()
 Gets the TCP server addresses. More...
 
fm.liveswitch.ServerAddress[] getTlsAddresses ()
 Gets the TLS server addresses. More...
 
fm.liveswitch.ServerAddress[] getUdpAddresses ()
 Gets the UDP server addresses. More...
 
void setCreateDatagramSocket (fm.liveswitch.IFunction1< fm.liveswitch.DatagramSocketCreateArgs, fm.liveswitch.DatagramSocket > value)
 Sets the create callback to create a datagram socket. More...
 
void setCreateStreamSocket (fm.liveswitch.IFunction1< fm.liveswitch.StreamSocketCreateArgs, fm.liveswitch.StreamSocket > value)
 Sets the create callback to create a stream socket. More...
 
void setDisableTcp (boolean value)
 Sets whether to prevent the server from listening for TCP requests. More...
 
void setDisableTls (boolean value)
 Sets whether to prevent the server from listening for TLS requests. More...
 
void setDisableUdp (boolean value)
 Sets whether to prevent the server from listening for UDP requests. More...
 
void setStreamSendTimeout (int value)
 Sets timeout for asynchronous data sending over stream sockets in ms. More...
 
boolean start ()
 Starts the server. More...
 
boolean start (fm.liveswitch.ServerAddress[] udpAddresses)
 Starts the server. More...
 
boolean start (fm.liveswitch.ServerAddress[] udpAddresses, fm.liveswitch.ServerAddress[] tcpAddresses)
 Starts the server. More...
 
 StunServer ()
 
- Public Member Functions inherited from fm.liveswitch.Dynamic
java.util.HashMap< String, Object > getDynamicProperties ()
 Gets all dynamic properties on this instance. More...
 
Object getDynamicValue (String key)
 Gets a property value from the local cache. More...
 
void setDynamicValue (String key, Object value)
 Sets a property value in the local cache. More...
 
boolean unsetDynamicValue (String key)
 Removes a property value from the local cache. More...
 

Protected Member Functions

fm.liveswitch.stun.Message createExceptionResponse (fm.liveswitch.stun.Message request, fm.liveswitch.TransportAddress remoteAddress, fm.liveswitch.stun.Error error)
 Creates an exception response. More...
 
String getLabel ()
 Gets the label. More...
 
fm.liveswitch.stun.Message process (fm.liveswitch.stun.Message request, fm.liveswitch.DatagramSocket udpServerSocket, fm.liveswitch.StreamSocket tcpServerSocket, fm.liveswitch.ServerAddress localAddress, fm.liveswitch.TransportAddress remoteAddress)
 Processes the specified request. More...
 
boolean processBuffer (fm.liveswitch.DataBuffer buffer, fm.liveswitch.DatagramSocket udpServerSocket, fm.liveswitch.StreamSocket tcpServerSocket, fm.liveswitch.ServerAddress localAddress, fm.liveswitch.TransportAddress remoteAddress, fm.liveswitch.IntegerHolder readLength)
 Processes the buffer. More...
 
- Protected Member Functions inherited from fm.liveswitch.StunServer
fm.liveswitch.stun.Message createErrorResponse (fm.liveswitch.stun.Message request, fm.liveswitch.TransportAddress remoteAddress, String errorMessage)
 Creates an error response with a ganeric Stun server error. More...
 
String getPrefix (boolean udp, boolean secure)
 Gets a prefix. More...
 
- Protected Member Functions inherited from fm.liveswitch.Dynamic
 Dynamic ()
 
- Protected Member Functions inherited from fm.liveswitch.Serializable
boolean getIsDirty ()
 Gets a value indicating whether this instance is dirty. More...
 
 Serializable ()
 Initializes a new instance of the fm.liveswitch.Serializable class. More...
 
void setIsDirty (boolean value)
 Sets a value indicating whether this instance is dirty. More...
 

Detailed Description

An TURN/STUN server.

Constructor & Destructor Documentation

◆ TurnServer()

fm.liveswitch.TurnServer.TurnServer ( fm.liveswitch.IFunction1< fm.liveswitch.TurnAuthArgs, fm.liveswitch.TurnAuthResult authCallback)

Initializes a new instance of the fm.liveswitch.TurnServer class.

Parameters
authCallbackThe authentication callback.

Member Function Documentation

◆ createExceptionResponse()

fm.liveswitch.stun.Message fm.liveswitch.TurnServer.createExceptionResponse ( fm.liveswitch.stun.Message  request,
fm.liveswitch.TransportAddress  remoteAddress,
fm.liveswitch.stun.Error  error 
)
protected

Creates an exception response.

Parameters
requestThe request.
remoteAddressThe remote address.
errorThe error.

Reimplemented from fm.liveswitch.StunServer.

◆ getAllocationCount()

int fm.liveswitch.TurnServer.getAllocationCount ( )

Gets the number of active allocations.

◆ getAllocationPortMax()

int fm.liveswitch.TurnServer.getAllocationPortMax ( )

Gets the maximum allowed port to be used when allocating sockets.

The default value is 65535.

◆ getAllocationPortMin()

int fm.liveswitch.TurnServer.getAllocationPortMin ( )

Gets the minimum allowed port to be used when allocating sockets.

The default value is 49152.

◆ getDefaultAllocateLifetime()

long fm.liveswitch.TurnServer.getDefaultAllocateLifetime ( )

Gets the default lifetime for new allocations in seconds.

Defaults to 600 (10 minutes).

◆ getDefaultRefreshLifetime()

long fm.liveswitch.TurnServer.getDefaultRefreshLifetime ( )

Gets the default lifetime for refreshed allocations in seconds.

Defaults to 600 (10 minutes).

◆ getDisableBypass()

boolean fm.liveswitch.TurnServer.getDisableBypass ( )

Gets a value indicating whether to disable the in-memory bypass of the network when communicating between two relay candidates.

◆ getForbiddenPeerCidrs()

String [] fm.liveswitch.TurnServer.getForbiddenPeerCidrs ( )

Gets the list of forbidden peer CIDRs.

Addresses matching this list are banned from receiving relayed data packets.

◆ getForceDefaultAllocateLifetime()

boolean fm.liveswitch.TurnServer.getForceDefaultAllocateLifetime ( )

Gets whether the server should force the default lifetime for new allocations (true) or allow clients to request their own lifetime within the min/max range (false).

Defaults to false.

◆ getForceDefaultRefreshLifetime()

boolean fm.liveswitch.TurnServer.getForceDefaultRefreshLifetime ( )

Gets whether the server should force the default lifetime for refreshed allocations (true) or allow clients to request their own lifetime within the min/max range (false).

Defaults to false.

◆ getLabel()

String fm.liveswitch.TurnServer.getLabel ( )
protected

Gets the label.

Reimplemented from fm.liveswitch.StunServer.

◆ getMaxAllocateLifetime()

long fm.liveswitch.TurnServer.getMaxAllocateLifetime ( )

Gets the maximum lifetime for new allocations in seconds.

Defaults to 3600 (1 hour).

◆ getMaxRefreshLifetime()

long fm.liveswitch.TurnServer.getMaxRefreshLifetime ( )

Gets the maximum lifetime for refreshed allocations in seconds.

Defaults to 3600 (1 hour).

◆ getMinAllocateLifetime()

long fm.liveswitch.TurnServer.getMinAllocateLifetime ( )

Gets the minimum lifetime for new allocations in seconds.

Equal to 600 (10 minutes).

◆ getMinRefreshLifetime()

long fm.liveswitch.TurnServer.getMinRefreshLifetime ( )

Gets the minimum lifetime for refreshed allocations in seconds.

Equal to 600 (10 minutes).

◆ getNonce()

String fm.liveswitch.TurnServer.getNonce ( )

Gets the current nonce.

◆ getRealm()

String fm.liveswitch.TurnServer.getRealm ( )

Gets the realm used for this server.

◆ getStaleNonceSecurity()

boolean fm.liveswitch.TurnServer.getStaleNonceSecurity ( )

Gets whether the server should enforce stale-nonce security by sending a 438 Stale Nonce in response to allocate requests with a stale or non-existent nonce.

◆ process()

fm.liveswitch.stun.Message fm.liveswitch.TurnServer.process ( fm.liveswitch.stun.Message  request,
fm.liveswitch.DatagramSocket  udpServerSocket,
fm.liveswitch.StreamSocket  tcpServerSocket,
fm.liveswitch.ServerAddress  localAddress,
fm.liveswitch.TransportAddress  remoteAddress 
)
protected

Processes the specified request.

Parameters
requestThe request.
udpServerSocketThe UDP server socket.
tcpServerSocketThe TCP server socket.
localAddressThe local address.
remoteAddressThe remote address.

Reimplemented from fm.liveswitch.StunServer.

◆ processBuffer()

boolean fm.liveswitch.TurnServer.processBuffer ( fm.liveswitch.DataBuffer  buffer,
fm.liveswitch.DatagramSocket  udpServerSocket,
fm.liveswitch.StreamSocket  tcpServerSocket,
fm.liveswitch.ServerAddress  localAddress,
fm.liveswitch.TransportAddress  remoteAddress,
fm.liveswitch.IntegerHolder  readLength 
)
protected

Processes the buffer.

Parameters
bufferThe buffer.
udpServerSocketThe UDP server socket.
tcpServerSocketThe TCP server socket.
localAddressThe local address.
remoteAddressThe remote address.
readLengthLength of the read.

Reimplemented from fm.liveswitch.StunServer.

◆ setAllocationPortMax()

void fm.liveswitch.TurnServer.setAllocationPortMax ( int  value)

Sets the maximum allowed port to be used when allocating sockets.

The default value is 65535.

◆ setAllocationPortMin()

void fm.liveswitch.TurnServer.setAllocationPortMin ( int  value)

Sets the minimum allowed port to be used when allocating sockets.

The default value is 49152.

◆ setDefaultAllocateLifetime()

void fm.liveswitch.TurnServer.setDefaultAllocateLifetime ( long  value)

Sets the default lifetime for new allocations in seconds.

Defaults to 600 (10 minutes).

◆ setDefaultRefreshLifetime()

void fm.liveswitch.TurnServer.setDefaultRefreshLifetime ( long  value)

Sets the default lifetime for refreshed allocations in seconds.

Defaults to 600 (10 minutes).

◆ setDisableBypass()

void fm.liveswitch.TurnServer.setDisableBypass ( boolean  value)

Sets a value indicating whether to disable the in-memory bypass of the network when communicating between two relay candidates.

◆ setForbiddenPeerCidrs()

void fm.liveswitch.TurnServer.setForbiddenPeerCidrs ( String[]  value)

Sets the list of forbidden peer CIDRs.

Addresses matching this list are banned from receiving relayed data packets.

◆ setForceDefaultAllocateLifetime()

void fm.liveswitch.TurnServer.setForceDefaultAllocateLifetime ( boolean  value)

Sets whether the server should force the default lifetime for new allocations (true) or allow clients to request their own lifetime within the min/max range (false).

Defaults to false.

◆ setForceDefaultRefreshLifetime()

void fm.liveswitch.TurnServer.setForceDefaultRefreshLifetime ( boolean  value)

Sets whether the server should force the default lifetime for refreshed allocations (true) or allow clients to request their own lifetime within the min/max range (false).

Defaults to false.

◆ setMaxAllocateLifetime()

void fm.liveswitch.TurnServer.setMaxAllocateLifetime ( long  value)

Sets the maximum lifetime for new allocations in seconds.

Defaults to 3600 (1 hour).

◆ setMaxRefreshLifetime()

void fm.liveswitch.TurnServer.setMaxRefreshLifetime ( long  value)

Sets the maximum lifetime for refreshed allocations in seconds.

Defaults to 3600 (1 hour).

◆ setRealm()

void fm.liveswitch.TurnServer.setRealm ( String  value)

Sets the realm used for this server.

◆ setStaleNonceSecurity()

void fm.liveswitch.TurnServer.setStaleNonceSecurity ( boolean  value)

Sets whether the server should enforce stale-nonce security by sending a 438 Stale Nonce in response to allocate requests with a stale or non-existent nonce.

◆ start()

boolean fm.liveswitch.TurnServer.start ( fm.liveswitch.ServerAddress[]  udpAddresses,
fm.liveswitch.ServerAddress[]  tcpAddresses,
fm.liveswitch.ServerAddress[]  tlsAddresses 
)

Starts the server.

Parameters
udpAddressesThe UDP addresses to listen on.
tcpAddressesThe TCP addresses to listen on.
tlsAddressesThe TLS addresses to listen on.

Reimplemented from fm.liveswitch.StunServer.

◆ stop()

boolean fm.liveswitch.TurnServer.stop ( )

Stops the server.

Reimplemented from fm.liveswitch.StunServer.