From 6a90dfd259a2eac0ba3ba445c50e7287e8c977ed Mon Sep 17 00:00:00 2001 From: Nishi Date: Fri, 13 Sep 2024 10:40:53 +0000 Subject: [PATCH] recognizes listen/listenssl now git-svn-id: file:///raid/svn-personal/tewi/trunk@7 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Server/config.c | 18 +++++++++++++++++- Server/tw_config.h | 6 ++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Server/config.c b/Server/config.c index 9f6df22..83cb269 100644 --- a/Server/config.c +++ b/Server/config.c @@ -3,6 +3,7 @@ #include "tw_config.h" #include +#include #include #include @@ -11,7 +12,12 @@ struct tw_config config; -void tw_config_init(void) {} +void tw_config_init(void) { + int i; + for(i = 0; i < MAX_PORTS + 1; i++) { + config.ports[i] = -1; + } +} int tw_config_read(const char* path) { cm_log("Config", "Reading %s", path); @@ -59,6 +65,16 @@ int tw_config_read(const char* path) { free(vhost); vhost = NULL; } + } else if(cm_strcaseequ(r[0], "Listen") || cm_strcaseequ(r[0], "ListenSSL")) { + for(i = 1; r[i] != NULL; i++) { + uint64_t port = atoi(r[i]); + cm_log("Config", "Going to listen at port %d%s", (int)port, cm_strcaseequ(r[0], "ListenSSL") ? " with SSL" : ""); + if(cm_strcaseequ(r[0], "ListenSSL")) port |= (1ULL << 32); + int j; + for(j = 0; config.ports[j] != -1; j++) + ; + config.ports[j] = port; + } } else { if(r[0] != NULL) { cm_log("Config", "Unknown directive `%s' at line %d", r[0], ln); diff --git a/Server/tw_config.h b/Server/tw_config.h index 51d0c8f..d3be0e0 100644 --- a/Server/tw_config.h +++ b/Server/tw_config.h @@ -3,9 +3,15 @@ #ifndef __TW_CONFIG_H__ #define __TW_CONFIG_H__ +#include + +/* I don't think you would listen to 1024 ports */ +#define MAX_PORTS 1024 + struct tw_config_entry {}; struct tw_config { + uint64_t ports[MAX_PORTS + 1]; /* If port & (1 << 32) is non-zero, it is SSL */ struct tw_config_entry root; };