ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
Loading...
Searching...
No Matches
Server Main Entry Point

🚀 Server initialization, signal handling, and connection management More...

Files

file  main.c
 🖥️ Server main entry point: multi-client connection manager with per-client rendering threads (60fps video + 172fps audio)
 
file  main.h
 ascii-chat Server Mode Entry Point Header
 

Data Structures

struct  server_context_t
 Server context - encapsulates all server state. More...
 

Typedefs

typedef struct server_context_t server_context_t
 Server context - encapsulates all server state.
 

Variables

bool g_server_encryption_enabled = false
 Global flag indicating if server encryption is enabled.
 
private_key_t g_server_private_key = {0}
 Global server private key (first identity key, for backward compatibility)
 
private_key_t g_server_identity_keys [MAX_IDENTITY_KEYS] = {0}
 Global server identity keys array (multi-key support)
 
size_t g_num_server_identity_keys = 0
 Number of loaded server identity keys.
 
public_key_t g_client_whitelist [MAX_CLIENTS] = {0}
 Global client public key whitelist.
 
size_t g_num_whitelisted_clients = 0
 Number of whitelisted clients.
 

Detailed Description

🚀 Server initialization, signal handling, and connection management

Typedef Documentation

◆ server_context_t

#include <main.h>

Server context - encapsulates all server state.

This structure holds all server-wide state that was previously stored in global variables. It's passed to client handlers via tcp_server user_data, reducing global state and improving modularity.

DESIGN RATIONALE:

  • Reduces global state: All server state in one place
  • Improves testability: Can create multiple independent server instances
  • Better encapsulation: Clear ownership of resources
  • Thread-safe: Context is read-only after initialization

LIFETIME:

Variable Documentation

◆ g_client_whitelist

public_key_t g_client_whitelist[MAX_CLIENTS] = {0}

#include <main.c>

Global client public key whitelist.

Whitelist of allowed client public keys.

Array of public keys for clients that are authorized to connect to the server. Used for client authentication when whitelist mode is enabled. Sized to hold up to MAX_CLIENTS entries.

Note
Only used when client authentication is enabled
Accessed from crypto.c for client authentication

Definition at line 505 of file server/main.c.

505{0};

Referenced by server_crypto_handshake(), and server_main().

◆ g_num_server_identity_keys

size_t g_num_server_identity_keys = 0

#include <main.c>

Number of loaded server identity keys.

Number of server identity keys in use.

Tracks how many identity keys were successfully loaded from –key flags. Zero means server is running in simple mode (no identity key).

Definition at line 492 of file server/main.c.

Referenced by server_crypto_handshake().

◆ g_num_whitelisted_clients

size_t g_num_whitelisted_clients = 0

#include <main.c>

Number of whitelisted clients.

Tracks the current number of entries in g_client_whitelist that are valid and active. Used to iterate the whitelist and check authorization.

Definition at line 515 of file server/main.c.

Referenced by server_crypto_handshake(), and server_main().

◆ g_server_encryption_enabled

bool g_server_encryption_enabled = false

#include <main.c>

Global flag indicating if server encryption is enabled.

Server encryption enabled flag.

Set to true when the server is configured to use encryption and has successfully loaded a private key. Controls whether the server performs cryptographic handshakes with clients.

Note
Accessed from crypto.c for server-side crypto operations

Definition at line 456 of file server/main.c.

Referenced by server_crypto_handshake(), and server_main().

◆ g_server_identity_keys

private_key_t g_server_identity_keys[MAX_IDENTITY_KEYS] = {0}

#include <main.c>

Global server identity keys array (multi-key support)

Array of server identity keys.

Stores all server identity keys loaded from multiple –key flags. Enables servers to present different keys (SSH, GPG) based on client expectations. Server selects the appropriate key during handshake based on what the client downloaded from ACDS.

Note
g_server_private_key points to g_server_identity_keys[0] for compatibility

Definition at line 482 of file server/main.c.

482{0};

Referenced by server_crypto_handshake().

◆ g_server_private_key

private_key_t g_server_private_key = {0}

#include <main.c>

Global server private key (first identity key, for backward compatibility)

Server's private key.

Stores the server's primary private key loaded from the first –key flag. Used for cryptographic handshakes and packet encryption/decryption. Initialized during server startup from the configured key file path.

Note
This is an alias to g_server_identity_keys[0] for backward compatibility
Accessed from crypto.c for server-side crypto operations

Definition at line 469 of file server/main.c.

469{0};

Referenced by server_crypto_handshake(), and server_main().