diff options
| author | cbdev <cb@cbcdn.com> | 2019-06-08 11:25:19 +0200 |
|---|---|---|
| committer | cbdev <cb@cbcdn.com> | 2019-06-08 11:25:19 +0200 |
| commit | 3bb2d8fd96618c11f499c8dddb97a62015b1ea53 (patch) | |
| tree | cab1ebf146c717ac9de071efad615ced22725623 /websocksy.c | |
| parent | c9062e7d1a1d917f618b71ac3810b4f3e396ab0d (diff) | |
| download | websocksy-3bb2d8fd96618c11f499c8dddb97a62015b1ea53.tar.gz websocksy-3bb2d8fd96618c11f499c8dddb97a62015b1ea53.tar.bz2 websocksy-3bb2d8fd96618c11f499c8dddb97a62015b1ea53.zip | |
Implement configuration file parsing
Diffstat (limited to 'websocksy.c')
| -rw-r--r-- | websocksy.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/websocksy.c b/websocksy.c index f948727..33ee794 100644 --- a/websocksy.c +++ b/websocksy.c @@ -22,7 +22,6 @@ /* TODO * - TLS - * - config file * - pings */ @@ -44,8 +43,8 @@ char* xstr_lower(char* in){ /* Daemon configuration */ static ws_config config = { - .host = DEFAULT_HOST, - .port = DEFAULT_PORT, + .host = NULL, + .port = NULL, /* Assign the built-in defaultpeer backend by default */ .backend.init = backend_defaultpeer_init, .backend.config = backend_defaultpeer_configure, @@ -80,6 +79,7 @@ int client_register(websocket* ws){ return 0; } +/* Clean up and close all connections */ void client_cleanup(){ size_t n; for(n = 0; n < socks; n++){ @@ -201,6 +201,7 @@ static void signal_handler(int signum){ static int usage(char* fn){ fprintf(stderr, "\nwebsocksy v%s - Proxy between websockets and 'real' sockets\n", WEBSOCKSY_VERSION); fprintf(stderr, "Usage:\n"); + fprintf(stderr, "\t%s <configuration file>\n", fn); fprintf(stderr, "\t%s [-p <port>] [-l <listen address>] [-b <discovery backend>] [-c <option>=<value>]\n", fn); fprintf(stderr, "Arguments:\n"); fprintf(stderr, "\t-p <port>\t\tWebSocket listen port (Current: %s, Default: %s)\n", config.port, DEFAULT_PORT); @@ -297,7 +298,7 @@ int main(int argc, char** argv){ } //open listening socket - listen_fd = network_socket(config.host, config.port, SOCK_STREAM, 1); + listen_fd = network_socket(config.host ? config.host : DEFAULT_HOST, config.port ? config.port : DEFAULT_PORT, SOCK_STREAM, 1); if(listen_fd < 0){ exit(usage(argv[0])); } |
