ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
Turn

Functions

struct __attribute__ ((packed))
 TURN server configuration with credentials.
 

Variables

 turn_server_t
 

TURN Protocol Constants

#define TURN_DEFAULT_PORT   3478
 Standard TURN port (RFC 5766)
 
#define TURN_TLS_DEFAULT_PORT   5349
 TURN over TLS port (RFC 5766)
 
#define TURN_MAX_URL_LEN   64
 Maximum TURN URL length.
 
#define TURN_MAX_USERNAME_LEN   32
 Maximum TURN username length.
 
#define TURN_MAX_CREDENTIAL_LEN   64
 Maximum TURN credential length.
 
#define TURN_CREDENTIAL_EXPIRY_SECS   (24 * 60 * 60)
 Recommended credential expiration time (seconds)
 

Detailed Description

This module defines TURN server configuration structures for WebRTC connectivity. TURN servers act as relay servers when direct peer-to-peer connections are not possible due to restrictive NAT or firewalls.

RFC 5766: Traversal Using Relays around NAT (TURN) RFC 8656: TURN Extensions for IPv6

TURN SERVER ROLE:

USAGE IN ACDS:

SECURITY CONSIDERATIONS:

Note
All structures are packed with attribute((packed)) for wire format
Author
Zachary Fogg me@zf.nosp@m.o.gg
Date
January 2026
Version
1.0

Macro Definition Documentation

◆ TURN_CREDENTIAL_EXPIRY_SECS

#define TURN_CREDENTIAL_EXPIRY_SECS   (24 * 60 * 60)

#include <turn.h>

Recommended credential expiration time (seconds)

Definition at line 125 of file turn.h.

◆ TURN_DEFAULT_PORT

#define TURN_DEFAULT_PORT   3478

#include <turn.h>

Standard TURN port (RFC 5766)

Definition at line 110 of file turn.h.

◆ TURN_MAX_CREDENTIAL_LEN

#define TURN_MAX_CREDENTIAL_LEN   64

#include <turn.h>

Maximum TURN credential length.

Definition at line 122 of file turn.h.

◆ TURN_MAX_URL_LEN

#define TURN_MAX_URL_LEN   64

#include <turn.h>

Maximum TURN URL length.

Definition at line 116 of file turn.h.

◆ TURN_MAX_USERNAME_LEN

#define TURN_MAX_USERNAME_LEN   32

#include <turn.h>

Maximum TURN username length.

Definition at line 119 of file turn.h.

◆ TURN_TLS_DEFAULT_PORT

#define TURN_TLS_DEFAULT_PORT   5349

#include <turn.h>

TURN over TLS port (RFC 5766)

Definition at line 113 of file turn.h.

Function Documentation

◆ __attribute__()

struct __attribute__ ( (packed)  )

#include <turn.h>

TURN server configuration with credentials.

Used in ACDS SESSION_CREATED response to provide WebRTC relay information. Includes time-limited credentials for secure TURN access.

Protocol Format:

  • url_len: 1 byte (length of URL string)
  • url: 64 bytes (null-terminated TURN URL)
  • username_len: 1 byte (length of username)
  • username: 32 bytes (null-terminated username)
  • credential_len: 1 byte (length of credential)
  • credential: 64 bytes (null-terminated time-limited credential)

URL Format Examples:

  • turn:discovery.ascii.chat:3478 (standard TURN)
  • turns:discovery.ascii.chat:5349 (TURN over TLS)
  • turn:relay.example.com:3478?transport=udp (UDP transport)
  • turn:relay.example.com:3478?transport=tcp (TCP transport)

Credential Types:

  • Short-term: Simple username/password (less secure)
  • Long-term: HMAC-based with timestamp (recommended)
  • OAuth: Token-based authentication

Wire Format (163 bytes total):

+---------+----------------+---------------+----------------+--------------+
| url_len | url[64] | username_len | username[32] |credential_len|
+---------+----------------+---------------+----------------+--------------+
| 1 byte | 64 bytes | 1 byte | 32 bytes | 1 byte |
+---------+----------------+---------------+----------------+--------------+
| credential[64] |
+--------------------------------------------------------------------------+
| 64 bytes |
+--------------------------------------------------------------------------+

< Length of URL string (actual length)

< TURN server URL (e.g., "turn:discovery.ascii.chat:3478")

< Length of username string

< TURN authentication username

< Length of credential string

< Time-limited TURN credential/password

Definition at line 1 of file turn.h.

94 {
95 uint8_t url_len;
96 char url[64];
97 uint8_t username_len;
98 char username[32];
99 uint8_t credential_len;
100 char credential[64];
unsigned char uint8_t
Definition common.h:56
turn_server_t
Definition turn.h:101

Variable Documentation

◆ turn_server_t

turn_server_t

#include <turn.h>

Definition at line 101 of file turn.h.