GUACAMOLE-337: Limit public libguacd API to simply user handshake handling and SSL/TLS sockets.

This commit is contained in:
Michael Jumper 2017-06-10 19:16:22 -07:00
parent 7f3b985cc6
commit 6c484c1efd
5 changed files with 52 additions and 54 deletions

View File

@ -24,9 +24,11 @@ lib_LTLIBRARIES = libguacd.la
libguacdincdir = $(includedir)/libguacd libguacdincdir = $(includedir)/libguacd
libguacdinc_HEADERS = \ libguacdinc_HEADERS = \
libguacd/log.h \
libguacd/user.h libguacd/user.h
noinst_HEADERS = \
log.h
libguacd_la_SOURCES = \ libguacd_la_SOURCES = \
log.c \ log.c \
user.c user.c

View File

@ -46,40 +46,6 @@
*/ */
#define GUACD_CLIENT_MAX_CONNECTIONS 65536 #define GUACD_CLIENT_MAX_CONNECTIONS 65536
/**
* Parameters required by the user input thread.
*/
typedef struct guacd_user_input_thread_params {
/**
* The parser which will be used throughout the user's session.
*/
guac_parser* parser;
/**
* A reference to the connected user.
*/
guac_user* user;
} guacd_user_input_thread_params;
/**
* Starts the input/output threads of a new user. This function will block
* until the user disconnects. If an error prevents the input/output threads
* from starting, guac_user_stop() will be invoked on the given user.
*
* @param parser
* The guac_parser to use to handle all input from the given user.
*
* @param user
* The user whose associated I/O transfer threads should be started.
*
* @return
* Zero if the I/O threads started successfully and user has disconnected,
* or non-zero if the I/O threads could not be started.
*/
int guacd_user_start(guac_parser* parser, guac_user* user);
/** /**
* Handles the initial handshake of a user and all subsequent I/O. This * Handles the initial handshake of a user and all subsequent I/O. This
* function blocks until the user disconnects. * function blocks until the user disconnects.
@ -95,19 +61,5 @@ int guacd_user_start(guac_parser* parser, guac_user* user);
*/ */
int guacd_handle_user(guac_user* user); int guacd_handle_user(guac_user* user);
/**
* The thread which handles all user input, calling event handlers for received
* instructions.
*
* @param data
* A pointer to a guacd_user_input_thread_params structure describing the
* user whose input is being handled and the guac_parser with which to
* handle it.
*
* @return
* Always NULL.
*/
void* guacd_user_input_thread(void* data);
#endif #endif

View File

@ -18,7 +18,7 @@
*/ */
#include "config.h" #include "config.h"
#include "libguacd/log.h" #include "log.h"
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/error.h> #include <guacamole/error.h>

View File

@ -19,8 +19,8 @@
#include "config.h" #include "config.h"
#include "libguacd/log.h"
#include "libguacd/user.h" #include "libguacd/user.h"
#include "log.h"
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/error.h> #include <guacamole/error.h>
@ -33,6 +33,23 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
/**
* Parameters required by the user input thread.
*/
typedef struct guacd_user_input_thread_params {
/**
* The parser which will be used throughout the user's session.
*/
guac_parser* parser;
/**
* A reference to the connected user.
*/
guac_user* user;
} guacd_user_input_thread_params;
/** /**
* Copies the given array of mimetypes (strings) into a newly-allocated NULL- * Copies the given array of mimetypes (strings) into a newly-allocated NULL-
* terminated array of strings. Both the array and the strings within the array * terminated array of strings. Both the array and the strings within the array
@ -91,7 +108,19 @@ static void guacd_free_mimetypes(char** mimetypes) {
} }
void* guacd_user_input_thread(void* data) { /**
* The thread which handles all user input, calling event handlers for received
* instructions.
*
* @param data
* A pointer to a guacd_user_input_thread_params structure describing the
* user whose input is being handled and the guac_parser with which to
* handle it.
*
* @return
* Always NULL.
*/
static void* guacd_user_input_thread(void* data) {
guacd_user_input_thread_params* params = (guacd_user_input_thread_params*) data; guacd_user_input_thread_params* params = (guacd_user_input_thread_params*) data;
guac_user* user = params->user; guac_user* user = params->user;
@ -143,7 +172,22 @@ void* guacd_user_input_thread(void* data) {
} }
int guacd_user_start(guac_parser* parser, guac_user* user) { /**
* Starts the input/output threads of a new user. This function will block
* until the user disconnects. If an error prevents the input/output threads
* from starting, guac_user_stop() will be invoked on the given user.
*
* @param parser
* The guac_parser to use to handle all input from the given user.
*
* @param user
* The user whose associated I/O transfer threads should be started.
*
* @return
* Zero if the I/O threads started successfully and user has disconnected,
* or non-zero if the I/O threads could not be started.
*/
static int guacd_user_start(guac_parser* parser, guac_user* user) {
guacd_user_input_thread_params params = { guacd_user_input_thread_params params = {
.parser = parser, .parser = parser,