Paraslash Audio Streaming | |
About News Download Documentation Development |
Common server data structures. More...
Data Structures | |
struct | sender_command_data |
Arguments for the sender command. More... | |
struct | misc_meta_data |
Miscellaneous data for communication between server and command handlers. More... | |
Macros | |
#define | MMD_INFO_SIZE 16384 |
Size of the selector_info and audio_file info strings of struct misc_meta_data. More... | |
#define | OPT_RESULT(_name) |
Get the parse result of an option to para_server. More... | |
#define | OPT_GIVEN(_name) (lls_opt_given(OPT_RESULT(_name))) |
How many times a server option was given. More... | |
#define | OPT_STRING_VAL(_name) (lls_string_val(0, OPT_RESULT(_name))) |
The (first) argument to a server option of type string. More... | |
#define | OPT_UINT32_VAL(_name) (lls_uint32_val(0, OPT_RESULT(_name))) |
The (first) argument to a server option of type uint32. More... | |
#define | OPT_INT32_VAL(_name) (lls_int32_val(0, OPT_RESULT(_name))) |
The (first) argument to a server option of type int32. More... | |
Functions | |
int | handle_connect (int fd) |
Perform user authentication and execute a command. More... | |
void | parse_config_or_die (bool reload) |
(Re-)read the server configuration files. More... | |
char * | server_get_tasks (void) |
Return the list of tasks for the server process. More... | |
bool | process_is_command_handler (void) |
Tell whether the executing process is a command handler. More... | |
void | free_lpr (void) |
Deallocate all lopsub parse results. More... | |
Variables | |
pid_t | afs_pid |
The process id of the audio file selector process. More... | |
struct lls_parse_result * | server_lpr |
The active value for all config options of para_server. More... | |
Common server data structures.
#define MMD_INFO_SIZE 16384 |
Size of the selector_info and audio_file info strings of struct misc_meta_data.
#define OPT_RESULT | ( | _name | ) |
Get the parse result of an option to para_server.
#define OPT_GIVEN | ( | _name | ) | (lls_opt_given(OPT_RESULT(_name))) |
How many times a server option was given.
#define OPT_STRING_VAL | ( | _name | ) | (lls_string_val(0, OPT_RESULT(_name))) |
The (first) argument to a server option of type string.
#define OPT_UINT32_VAL | ( | _name | ) | (lls_uint32_val(0, OPT_RESULT(_name))) |
The (first) argument to a server option of type uint32.
#define OPT_INT32_VAL | ( | _name | ) | (lls_int32_val(0, OPT_RESULT(_name))) |
The (first) argument to a server option of type int32.
int handle_connect | ( | int | fd | ) |
Perform user authentication and execute a command.
fd | The file descriptor to send output to. |
Whenever para_server accepts an incoming tcp connection on the port it listens on, it forks and the resulting child calls this function.
An RSA-based challenge/response is used to authenticate the peer. If the authentication succeeds, a random session key is generated and sent back to the peer, encrypted with its RSA public key. From this point on, all transfers are encrypted with this session key using a stream cipher.
Next it is checked if the peer supplied a valid server command or a command for the audio file selector. If yes, and if the user has sufficient permissions to execute this command, the function calls the corresponding command handler which performs argument checking and further processing.
To cope with DOS attacks, a timer is set up right after the fork. If the connection was still not authenticated when the timeout expires, the child process is terminated.
References APC_CHALLENGE_SIZE, stream_cipher_context::fd, HANDSHAKE_BUFSIZE, HASH2_SIZE, command_context::scc, SESSION_KEY_LEN, and command_context::u.
void parse_config_or_die | ( | bool | reload | ) |
(Re-)read the server configuration files.
reload | Whether config file overrides command line. |
This function also re-opens the logfile and the user list. On SIGHUP it is called from both server and afs context.
References MCF_DONT_FREE, and server_lpr.
char* server_get_tasks | ( | void | ) |
Return the list of tasks for the server process.
This is called from com_tasks(). The helper is necessary since command handlers can not access the scheduler structure directly.
References get_task_list().
bool process_is_command_handler | ( | void | ) |
Tell whether the executing process is a command handler.
Cleanup on exit must be performed differently for command handlers.
References afs_pid.
Referenced by shutdown_client(), and vss_shutdown().
void free_lpr | ( | void | ) |
Deallocate all lopsub parse results.
The server allocates a parse result for command line options and optionally a second parse result for the effective configuration, defined by merging the command line options with the options stored in the configuration file. This function frees both structures.
References CMD_PTR, and server_lpr.
|
extern |
The process id of the audio file selector process.
Referenced by process_is_command_handler().
|
extern |
The active value for all config options of para_server.
It is computed by merging the parse result of the command line options with the parse result of the config file.
Referenced by free_lpr(), and parse_config_or_die().