]> Nishi Git Mirror - tewi.git/commitdiff
recognizes listen/listenssl now
authorNishi <nishi@nishi.boats>
Fri, 13 Sep 2024 10:40:53 +0000 (10:40 +0000)
committerNishi <nishi@nishi.boats>
Fri, 13 Sep 2024 10:40:53 +0000 (10:40 +0000)
git-svn-id: file:///raid/svn-personal/tewi/trunk@7 8739d7e6-ffea-ec47-b151-bdff447c6205

Server/config.c
Server/tw_config.h

index 9f6df22c2ddcb1b7813291e1fe2f1e34971adeb0..83cb2699759ee0d095569721af6b5ba2ad8f5531 100644 (file)
@@ -3,6 +3,7 @@
 #include "tw_config.h"
 
 #include <stdio.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 
 
 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);
index 51d0c8f9126d63d0b9a27a6290048a2a1b630e3e..d3be0e061dea8bd447fd3e9b365e86feb22db55c 100644 (file)
@@ -3,9 +3,15 @@
 #ifndef __TW_CONFIG_H__
 #define __TW_CONFIG_H__
 
+#include <stdint.h>
+
+/* 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;
 };