ascii-chat
Binary v0.16.50-198-g78f51665f
Library lib/v0.3.2-2240-g78f51665f
Video chat in your terminal
Loading...
Searching...
No Matches
network.c File Reference

Network protocol options. More...

Go to the source code of this file.

Variables

const registry_entry_t g_network_entries []

Detailed Description

Network protocol options.

Options for controlling ports, compression, discovery, WebRTC, and network connectivity.

Author
Zachary Fogg me@zf.nosp@m.o.gg
Date
January 2026

Definition in file lib/options/registry/network.c.

Variable Documentation

◆ g_network_entries

const registry_entry_t g_network_entries[]

Definition at line 50 of file lib/options/registry/network.c.

50 {{.long_name = "webtransport-public-url",
51 .type = OPTION_TYPE_STRING,
52 .offset = offsetof(options_t, webtransport_public_url),
53 .default_value_size = OPTIONS_BUFF_SIZE,
54 .help_text = "Public HTTPS WebTransport endpoint advertised after discovery authentication.",
55 .group = "NETWORK",
56 .env_var_name = "ASCII_CHAT_WEBTRANSPORT_PUBLIC_URL",
58 .metadata = {.input_type = OPTION_INPUT_STRING}},
59 {.long_name = "discovery-quic",
60 .type = OPTION_TYPE_BOOL,
61 .offset = offsetof(options_t, discovery_quic),
62 .default_value = &default_quic_audio_datagrams,
63 .default_value_size = sizeof(bool),
64 .help_text = "Connect to a disclosed discovery host using its advertised native QUIC endpoint.",
65 .group = "NETWORK",
66 .env_var_name = "ASCII_CHAT_DISCOVERY_QUIC",
67 .mode_bitmask = OPTION_MODE_DISCOVERY},
68 {.long_name = "quic-fallback-port",
69 .type = OPTION_TYPE_INT,
70 .offset = offsetof(options_t, quic_fallback_port),
71 .default_value_size = sizeof(int),
72 .help_text = "TCP fallback port after QUIC timeout (requires --server-key; 0 disables fallback).",
73 .group = "NETWORK",
74 .env_var_name = "ASCII_CHAT_QUIC_FALLBACK_PORT",
76 .metadata = {.numeric_range = {0, 65535, 1}, .input_type = OPTION_INPUT_NUMERIC}},
77 {.long_name = "quic-audio-datagrams",
78 .type = OPTION_TYPE_BOOL,
79 .offset = offsetof(options_t, quic_audio_datagrams),
80 .default_value = &default_quic_audio_datagrams,
81 .default_value_size = sizeof(bool),
82 .help_text = "Prefer QUIC datagrams for audio when negotiated; otherwise use reliable streams.",
83 .group = "NETWORK",
84 .env_var_name = "ASCII_CHAT_QUIC_AUDIO_DATAGRAMS",
86 {.long_name = "quic-visual-datagrams",
87 .type = OPTION_TYPE_BOOL,
88 .offset = offsetof(options_t, quic_visual_datagrams),
89 .default_value = &default_quic_audio_datagrams,
90 .default_value_size = sizeof(bool),
91 .help_text = "Prefer QUIC datagrams for visual media when negotiated; otherwise use reliable streams.",
92 .group = "NETWORK",
93 .env_var_name = "ASCII_CHAT_QUIC_VISUAL_DATAGRAMS",
95 {.long_name = "webtransport-bind-address",
96 .type = OPTION_TYPE_STRING,
97 .offset = offsetof(options_t, webtransport_bind_address),
98 .default_value_size = OPTIONS_BUFF_SIZE,
99 .help_text = "Enable a browser WebTransport listener on a concrete numeric IP address.",
100 .group = "NETWORK",
101 .env_var_name = "ASCII_CHAT_WEBTRANSPORT_BIND_ADDRESS",
103 .metadata = {.input_type = OPTION_INPUT_STRING}},
104 {.long_name = "webtransport-origin",
105 .type = OPTION_TYPE_STRING,
106 .offset = offsetof(options_t, webtransport_origin),
107 .default_value_size = OPTIONS_BUFF_SIZE,
108 .help_text = "Exact HTTPS origin allowed to connect to WebTransport.",
109 .group = "NETWORK",
110 .env_var_name = "ASCII_CHAT_WEBTRANSPORT_ORIGIN",
112 .metadata = {.input_type = OPTION_INPUT_STRING}},
113 {.long_name = "webtransport-path",
114 .type = OPTION_TYPE_STRING,
115 .offset = offsetof(options_t, webtransport_path),
116 .default_value = "/acip",
117 .default_value_size = OPTIONS_BUFF_SIZE,
118 .help_text = "WebTransport CONNECT path (default: /acip).",
119 .group = "NETWORK",
120 .env_var_name = "ASCII_CHAT_WEBTRANSPORT_PATH",
122 .metadata = {.input_type = OPTION_INPUT_STRING}},
123 {.long_name = "quic-bind-address",
124 .type = OPTION_TYPE_STRING,
125 .offset = offsetof(options_t, quic_bind_address),
126 .default_value_size = OPTIONS_BUFF_SIZE,
127 .help_text = "Enable the native QUIC listener on a concrete numeric IPv4 or IPv6 address.",
128 .group = "NETWORK",
129 .env_var_name = "ASCII_CHAT_QUIC_BIND_ADDRESS",
131 .metadata = {.input_type = OPTION_INPUT_STRING}},
132 {.long_name = "quic-port",
133 .type = OPTION_TYPE_INT,
134 .offset = offsetof(options_t, quic_port),
135 .default_value_size = sizeof(int),
136 .help_text = "Shared native QUIC and HTTP/3 UDP port (0 uses the server port).",
137 .group = "NETWORK",
138 .env_var_name = "ASCII_CHAT_QUIC_PORT",
140 .metadata = {.numeric_range = {0, 65535, 1}, .input_type = OPTION_INPUT_NUMERIC}},
141 {.long_name = "address",
142 .type = OPTION_TYPE_STRING,
143 .offset = offsetof(options_t, address),
144 .default_value = "127.0.0.1",
145 .default_value_size = OPTIONS_BUFF_SIZE,
146 .help_text = "MCP bind address (IPv4 or IPv6); also accepts positional bind addresses.",
147 .group = "NETWORK",
148 .env_var_name = "ASCII_CHAT_ADDRESS",
149 .parse_fn = parse_mcp_bind,
151 {.long_name = "address6",
152 .type = OPTION_TYPE_STRING,
153 .offset = offsetof(options_t, address6),
154 .default_value = "",
155 .default_value_size = OPTIONS_BUFF_SIZE,
156 .help_text = "Additional MCP IPv6 bind address.",
157 .group = "NETWORK",
158 .env_var_name = "ASCII_CHAT_ADDRESS6",
159 .parse_fn = parse_mcp_bind6,
161 // NETWORK GROUP - port and client management
162 {"port",
163 'p',
165 offsetof(options_t, port),
166 NULL, // Use mode_default_getter instead
167 sizeof(int),
168 "Port to host a server or discovery-service on, or port to connect to a server as a client (default: 27224 for "
169 "server/client, 27225 for discovery-service, 27228 for mcp-server).",
170 "NETWORK",
171 NULL,
172 false,
173 "ASCII_CHAT_PORT",
174 NULL,
176 false,
177 false,
179 {.numeric_range = {1, 65535, 1}, .input_type = OPTION_INPUT_NUMERIC},
181 {"tls-cert",
182 '\0',
184 offsetof(options_t, tls_cert),
185 NULL,
187 "TLS certificate file path for secure network listeners.",
188 "NETWORK",
189 NULL,
190 false,
191 "ASCII_CHAT_TLS_CERT",
192 NULL,
193 NULL,
194 false,
195 false,
197 {.input_type = OPTION_INPUT_STRING},
198 NULL},
199 {"tls-key",
200 '\0',
202 offsetof(options_t, tls_key),
203 NULL,
205 "TLS private key file path for secure network listeners.",
206 "NETWORK",
207 NULL,
208 false,
209 "ASCII_CHAT_TLS_KEY",
210 NULL,
211 NULL,
212 false,
213 false,
215 {.input_type = OPTION_INPUT_STRING},
216 NULL},
217 {"tls-key-password",
218 '\0',
220 offsetof(options_t, tls_key_password),
221 NULL,
223 "Password for password-protected TLS private key (use ASCII_CHAT_TLS_KEY_PASSWORD env var for "
224 "security).",
225 "NETWORK",
226 NULL,
227 false,
228 "ASCII_CHAT_TLS_KEY_PASSWORD",
229 NULL,
230 NULL,
231 false,
232 false,
234 {.input_type = OPTION_INPUT_STRING},
235 NULL},
236 {.long_name = "tls-ca-file",
237 .type = OPTION_TYPE_STRING,
238 .offset = offsetof(options_t, tls_ca_file),
239 .default_value_size = OPTIONS_BUFF_SIZE,
240 .help_text = "CA certificate file for secure network client verification (default: system trust).",
241 .group = "NETWORK",
242 .env_var_name = "ASCII_CHAT_TLS_CA_FILE",
244 .metadata = {.input_type = OPTION_INPUT_STRING}},
245 {"max-clients",
246 '\0',
248 offsetof(options_t, max_clients),
249 &default_max_clients_value,
250 sizeof(int),
251 "Maximum concurrent clients.",
252 "NETWORK",
253 NULL,
254 false,
255 "ASCII_CHAT_MAX_CLIENTS",
256 NULL,
257 NULL,
258 false,
259 false,
261 {.numeric_range = {1, 99, 1}, .examples = g_maxclients_examples, .input_type = OPTION_INPUT_NUMERIC},
262 NULL},
263 {"reconnect-attempts",
264 '\0',
266 offsetof(options_t, reconnect_attempts),
267 &default_reconnect_attempts_value,
268 sizeof(int),
269 "Number of reconnection attempts before giving up (-1=infinite, 0=none).",
270 "NETWORK",
271 NULL,
272 false,
273 "ASCII_CHAT_RECONNECT_ATTEMPTS",
274 NULL,
275 NULL,
276 false,
277 false,
279 {.numeric_range = {-1, 99, 1}, .examples = g_reconnect_examples, .input_type = OPTION_INPUT_NUMERIC},
280 NULL},
281 {"port-forwarding",
282 '\0',
284 offsetof(options_t, enable_upnp),
285 &default_enable_upnp_value,
286 sizeof(bool),
287 "Map active TCP/WebSocket listeners and native WebRTC UDP ports with UPnP/NAT-PMP (router support required).",
288 "NETWORK",
289 NULL,
290 false,
291 "ASCII_CHAT_PORT_FORWARDING",
292 NULL,
293 NULL,
294 false,
295 false,
297 {0},
298 NULL},
299 {"scan",
300 '\0',
302 offsetof(options_t, lan_discovery),
303 &default_lan_discovery_value,
304 sizeof(bool),
305 "Scan for servers on local network via mDNS.",
306 "NETWORK",
307 NULL,
308 false,
309 "ASCII_CHAT_SCAN",
310 NULL,
311 NULL,
312 false,
313 false,
315 {0},
316 NULL},
317
318 // NETWORK GROUP - compression options
319 {"compression-level",
320 '\0',
322 offsetof(options_t, compression_level),
323 &default_compression_level_value,
324 sizeof(int),
325 "zstd compression level (1-9).",
326 "NETWORK",
327 NULL,
328 false,
329 "ASCII_CHAT_COMPRESSION_LEVEL",
330 NULL,
331 NULL,
332 false,
333 false,
335 {.numeric_range = {1, 9, 1}, .examples = g_compression_examples, .input_type = OPTION_INPUT_NUMERIC},
336 NULL},
337 {"no-compress",
338 '\0',
340 offsetof(options_t, no_compress),
341 &default_no_compress_value,
342 sizeof(bool),
343 "Disable compression.",
344 "NETWORK",
345 NULL,
346 false,
347 "ASCII_CHAT_NO_COMPRESS",
348 NULL,
349 NULL,
350 false,
351 false,
353 {0},
354 NULL},
355
356 // NETWORK GROUP - discovery service options
357 {"discovery-service",
358 '\0',
360 offsetof(options_t, discovery_server),
362 0,
363 "Discovery service URL, including an optional port (for example, ws://host:27225 or wss://host:443).",
364 "NETWORK",
365 NULL,
366 false,
367 "ASCII_CHAT_DISCOVERY_SERVER",
368 NULL,
369 NULL,
370 false,
371 false,
373 {0},
374 NULL},
375 {"discovery-service-port",
376 '\0',
378 offsetof(options_t, discovery_port),
379 &default_discovery_port_value,
380 sizeof(int),
381 "Override the port in --discovery-service (1-65535).",
382 "NETWORK",
383 NULL,
384 false,
385 "ASCII_CHAT_DISCOVERY_SERVICE_PORT",
386 NULL,
387 NULL,
388 false,
389 false,
391 {.numeric_range = {1, 65535, 1}, .input_type = OPTION_INPUT_NUMERIC},
392 NULL},
393 {"discovery-expose-ip",
394 '\0',
396 offsetof(options_t, discovery_expose_ip),
397 &default_discovery_expose_ip_value,
398 sizeof(bool),
399 "Allow public IP disclosure in discovery sessions (requires confirmation).",
400 "NETWORK",
401 NULL,
402 false,
403 "ASCII_CHAT_DISCOVERY_EXPOSE_IP",
404 NULL,
405 NULL,
406 false,
407 false,
409 {0},
410 NULL},
411 {"discovery",
412 '\0',
414 offsetof(options_t, discovery),
415 &default_discovery_value,
416 sizeof(bool),
417 "Enable discovery session registration.",
418 "NETWORK",
419 NULL,
420 false,
421 "ASCII_CHAT_DISCOVERY",
422 NULL,
423 NULL,
424 false,
425 false,
427 {0},
428 NULL},
429
430 // NETWORK GROUP - WebRTC options
431 {.long_name = "webrtc-bind-address",
432 .type = OPTION_TYPE_STRING,
433 .offset = offsetof(options_t, webrtc_bind_address),
434 .default_value = "",
435 .default_value_size = OPTIONS_BUFF_SIZE,
436 .help_text = "Bind WebRTC ICE sockets to a local IPv4 or IPv6 address (default: all interfaces).",
437 .group = "NETWORK",
438 .env_var_name = "ASCII_CHAT_WEBRTC_BIND_ADDRESS",
439 .validate_fn = validate_webrtc_bind_address,
441 {"websocket-port",
442 '\0',
444 offsetof(options_t, websocket_port),
445 NULL, // Use mode_default_getter instead
446 sizeof(int),
447 "WebSocket server port (default: 27226 for server, 27227 for discovery-service, 443 when TLS cert+key provided).",
448 "NETWORK",
449 NULL,
450 false,
451 "ASCII_CHAT_WEBSOCKET_PORT",
452 NULL,
453 NULL,
454 false,
455 false,
457 {.numeric_range = {1, 65535, 1}, .input_type = OPTION_INPUT_NUMERIC},
459 {"no-webrtc",
460 '\0',
462 offsetof(options_t, no_webrtc),
463 &default_no_webrtc_value,
464 sizeof(bool),
465 "Disable WebRTC, use direct TCP only.",
466 "NETWORK",
467 NULL,
468 false,
469 "ASCII_CHAT_NO_WEBRTC",
470 NULL,
471 NULL,
472 false,
473 false,
475 {0},
476 NULL},
477 {"prefer-webrtc",
478 '\0',
480 offsetof(options_t, prefer_webrtc),
481 &default_prefer_webrtc_value,
482 sizeof(bool),
483 "Try WebRTC before direct TCP.",
484 "NETWORK",
485 NULL,
486 false,
487 "ASCII_CHAT_PREFER_WEBRTC",
488 NULL,
489 NULL,
490 false,
491 false,
493 {0},
494 NULL},
495 {"webrtc-relay-only",
496 '\0',
498 offsetof(options_t, webrtc_relay_only),
499 &default_webrtc_relay_only_value,
500 sizeof(bool),
501 "Require TURN relay for WebRTC connections (no direct connection or TCP fallback).",
502 "NETWORK",
503 NULL,
504 false,
505 "ASCII_CHAT_WEBRTC_RELAY_ONLY",
506 NULL,
507 NULL,
508 false,
509 false,
511 {0},
512 NULL},
513 {"webrtc-skip-stun",
514 '\0',
516 offsetof(options_t, webrtc_skip_stun),
517 &default_webrtc_skip_stun_value,
518 sizeof(bool),
519 "Skip WebRTC+STUN stage, go straight to TURN relay.",
520 "NETWORK",
521 NULL,
522 false,
523 "ASCII_CHAT_WEBRTC_SKIP_STUN",
524 NULL,
525 NULL,
526 false,
527 false,
529 {0},
530 NULL},
531 {"webrtc-disable-turn",
532 '\0',
534 offsetof(options_t, webrtc_disable_turn),
535 &default_webrtc_disable_turn_value,
536 sizeof(bool),
537 "Disable WebRTC+TURN relay, use STUN only.",
538 "NETWORK",
539 NULL,
540 false,
541 "ASCII_CHAT_WEBRTC_DISABLE_TURN",
542 NULL,
543 NULL,
544 false,
545 false,
547 {0},
548 NULL},
549 {"webrtc-skip-host",
550 '\0',
552 offsetof(options_t, webrtc_skip_host),
553 &default_webrtc_skip_host_value,
554 sizeof(bool),
555 "Skip host candidates, force STUN/TURN (for testing).",
556 "NETWORK",
557 NULL,
558 false,
559 "ASCII_CHAT_WEBRTC_SKIP_HOST",
560 NULL,
561 NULL,
562 false,
563 false,
565 {0},
566 NULL},
567 {"webrtc-ice-timeout",
568 '\0',
570 offsetof(options_t, webrtc_ice_timeout_ms),
571 &default_webrtc_ice_timeout_ms_value,
572 sizeof(int),
573 "ICE gathering timeout in milliseconds.",
574 "NETWORK",
575 NULL,
576 false,
577 "ASCII_CHAT_WEBRTC_ICE_TIMEOUT",
578 NULL,
579 NULL,
580 false,
581 false,
583 {0},
584 NULL},
585 {"stun-servers",
586 '\0',
588 offsetof(options_t, stun_servers),
590 0,
591 "Comma-separated list of WebRTC+STUN server URLs.",
592 "NETWORK",
593 NULL,
594 false,
595 "ASCII_CHAT_STUN_SERVERS",
596 NULL,
597 NULL,
598 false,
599 false,
601 {0},
602 NULL},
603 {"turn-servers",
604 '\0',
606 offsetof(options_t, turn_servers),
608 0,
609 "Comma-separated list of WebRTC+TURN server URLs.",
610 "NETWORK",
611 NULL,
612 false,
613 "ASCII_CHAT_TURN_SERVERS",
614 NULL,
615 NULL,
616 false,
617 false,
619 {0},
620 NULL},
621 {"turn-username",
622 '\0',
624 offsetof(options_t, turn_username),
626 0,
627 "Username for WebRTC+TURN authentication.",
628 "NETWORK",
629 NULL,
630 false,
631 "ASCII_CHAT_TURN_USERNAME",
632 NULL,
633 NULL,
634 false,
635 false,
637 {0},
638 NULL},
639 {"turn-credential",
640 '\0',
642 offsetof(options_t, turn_credential),
644 0,
645 "Credential/password for WebRTC+TURN authentication.",
646 "NETWORK",
647 NULL,
648 false,
649 "ASCII_CHAT_TURN_CREDENTIAL",
650 NULL,
651 NULL,
652 false,
653 false,
655 {0},
656 NULL},
657 {"turn-secret",
658 '\0',
660 offsetof(options_t, turn_secret),
661 "",
662 0,
663 "Shared secret for dynamic WebRTC+TURN credential generation (HMAC-SHA1).",
664 "NETWORK",
665 NULL,
666 false,
667 "ASCII_CHAT_TURN_SECRET",
668 NULL,
669 NULL,
670 false,
671 false,
673 {0},
674 NULL},
675
@ OPTION_INPUT_STRING
Free-form text input.
Definition builder.h:189
@ OPTION_INPUT_NUMERIC
Numeric value with optional min/max/step.
Definition builder.h:188
@ OPTION_TYPE_INT
Integer value (–count 42).
Definition builder.h:172
@ OPTION_TYPE_STRING
String value (–name foo).
Definition builder.h:173
@ OPTION_TYPE_CALLBACK
Custom parser function.
Definition builder.h:175
@ OPTION_TYPE_BOOL
Boolean flag (–flag, no value).
Definition builder.h:171
#define OPT_ENDPOINT_DISCOVERY_SERVICE
Default discovery service endpoint (what to connect to by default).
Definition options.h:555
struct options_state options_t
Immutable, RCU-published snapshot of the application's runtime configuration.
#define OPT_TURN_SERVERS_DEFAULT
Default TURN server URLs (comma-separated).
Definition options.h:663
#define OPT_STUN_SERVERS_DEFAULT
Default STUN server URLs (comma-separated).
Definition options.h:660
#define OPTIONS_BUFF_SIZE
Buffer size for option string values.
Definition options.h:305
#define OPT_TURN_CREDENTIAL_DEFAULT
Default TURN credential (empty = use ACDS credentials).
Definition options.h:695
#define OPT_TURN_USERNAME_DEFAULT
Default TURN username (empty = use ACDS credentials).
Definition options.h:692
@ OPTION_MODE_CLIENT
Client mode (bit 1).
Definition options.h:936
@ OPTION_MODE_API_SERVER
Definition options.h:941
@ OPTION_MODE_DISCOVERY
Discovery mode (bit 4).
Definition options.h:939
@ OPTION_MODE_SERVER
Server mode (bit 0).
Definition options.h:935
@ OPTION_MODE_MCP_SERVER
Definition options.h:940
@ OPTION_MODE_DISCOVERY_SVC
Discovery server mode (bit 3).
Definition options.h:938
#define REGISTRY_TERMINATOR()
Initialize a terminator entry (sentinel value for array end) Uses designated initializers to properly...
const char * g_compression_examples[]
Definition metadata.c:142
const char * g_reconnect_examples[]
Definition metadata.c:147
const char * g_maxclients_examples[]
Definition metadata.c:146
const void * get_default_websocket_port(asciichat_mode_t mode)
Get mode-specific default value for –websocket-port.
const void * get_default_port(asciichat_mode_t mode)
Get mode-specific default value for –port.
bool parse_port_option(const char *arg, void *dest, char **error_msg)
Parse and validate port option for CLI.
Definition parsers.c:447