summaryrefslogtreecommitdiff
path: root/src/config
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-10-13 12:17:45 +0000
committerLaurent Bercot <ska@appnovation.com>2023-10-13 12:17:45 +0000
commitff9c276c144bc24c70f1d5b531a8fd412c34c3d9 (patch)
tree428e16ebf99802946e230853c76b2ae3b407c87b /src/config
parent8179edd85cd504058ec7c569ef87eebf5979646e (diff)
downloadtipidee-ff9c276c144bc24c70f1d5b531a8fd412c34c3d9.tar.xz
Improved logging system
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/config')
-rw-r--r--src/config/PARSING-config.txt30
-rw-r--r--src/config/PROTOCOL.txt1
-rw-r--r--src/config/defaults.c11
-rw-r--r--src/config/lexparse.c10
4 files changed, 12 insertions, 40 deletions
diff --git a/src/config/PARSING-config.txt b/src/config/PARSING-config.txt
index 688d93c..072a1fa 100644
--- a/src/config/PARSING-config.txt
+++ b/src/config/PARSING-config.txt
@@ -1,33 +1,3 @@
-global verbosity 1
-global read_timeout 60000
-global index_file index.cgi index.html
-
-content-type application/pdf .pdf
-content-type text/plain .c .h .txt
-
-
-domain example.com
-
-nph-prefix nph-
-
-redirect rickroll.html 307 https://www.youtube.com/watch?v=dQw4w9WgXcQ
-redirect community/ 308 https://example.org/
-
-cgi /cgi-bin/
-nph /cgi-bin/nph/
-
-cgi /some/script
-nph /some/otherscript
-
-noncgi /cgi-bin/file.html
-noncgi /cgi-bin/directory
-
-file-type /source/ text/plain
-file-type /source/file.html text/html
-
-basic-auth /protected.html
-basic-auth /protected/
-
class | 0 1 2 3 4
st\ev | \0 space # \n other
diff --git a/src/config/PROTOCOL.txt b/src/config/PROTOCOL.txt
index ffeb72f..f6cc304 100644
--- a/src/config/PROTOCOL.txt
+++ b/src/config/PROTOCOL.txt
@@ -1,6 +1,5 @@
* Globals
-G:verbosity -> 4 bytes
G:read_timeout -> 4 bytes exit if waiting on client input for read_timeout ms
G:write_timeout -> 4 bytes die if waiting on flush to client for write_timeout ms
G:cgi_timeout -> 4 bytes 504 if CGI hasn't finished answering / die if NPH hasn't finished reading
diff --git a/src/config/defaults.c b/src/config/defaults.c
index 1017d29..389d84d 100644
--- a/src/config/defaults.c
+++ b/src/config/defaults.c
@@ -16,14 +16,13 @@ struct defaults_s
#define REC(k, v, n) { .key = (k), .value = (v), .vlen = (n) }
#define RECS(k, v) REC(k, v, sizeof(v))
-#define RECU32(k, v) REC(k, (char const *)(uint32_t)UINT32_BIG(v), 4)
+#define RECU32(k, u) { .key = (k), .value = (char const [4]){ UINT32_BIG(u) >> 24 & 0xffu, UINT32_BIG(u) >> 16 & 0xffu, UINT32_BIG(u) >> 8 & 0xffu, UINT32_BIG(u) & 0xffu }, .vlen = 4 }
-struct defaults_s const defaults[] =
+static struct defaults_s const defaults[] =
{
- RECU32("G:verbosity", 1),
- RECU32("G:read_timeout", 0),
- RECU32("G:write_timeout", 0),
- RECU32("G:cgi_timeout", 0),
+ RECS("G:read_timeout", "\0\0\0"),
+ RECS("G:write_timeout", "\0\0\0"),
+ RECS("G:cgi_timeout", "\0\0\0"),
RECU32("G:max_request_body_length", 8192),
RECU32("G:max_cgi_body_length", 4194304),
RECS("G:index_file", "index.html"),
diff --git a/src/config/lexparse.c b/src/config/lexparse.c
index b048031..d7d9e1b 100644
--- a/src/config/lexparse.c
+++ b/src/config/lexparse.c
@@ -17,7 +17,6 @@
#include "tipidee-config-internal.h"
#define dietoobig() strerr_diefu1sys(100, "read configuration")
-#define BSEARCH(type, key, array) bsearch(key, (array), sizeof(array)/sizeof(type), sizeof(type), (int (*)(void const *, void const *))&strcmp)
typedef struct mdt_s mdt, *mdt_ref ;
struct mdt_s
@@ -65,6 +64,11 @@ struct directive_s
enum token_e token ;
} ;
+static int keycmp (void const *a, void const *b)
+{
+ return strcmp((char const *)a, ((struct directive_s const *)b)->s) ;
+}
+#define BSEARCH(type, key, array) bsearch(key, (array), sizeof(array)/sizeof(type), sizeof(type), (int (*)(void const *, void const *))&keycmp)
static void check_unique (char const *key, mdt const *md)
{
@@ -95,7 +99,6 @@ static inline void parse_global (char const *s, size_t const *word, size_t n, md
{ .name = "max_cgi_body_length", .key = "G:max_cgi_body_length", .type = 0 },
{ .name = "max_request_body_length", .key = "G:max_request_body_length", .type = 0 },
{ .name = "read_timeout", .key = "G:read_timeout", .type = 0 },
- { .name = "verbosity", .key = "G:verbosity", .type = 0 },
{ .name = "write_timeout", .key = "G:write_timeout", .type = 0 }
} ;
struct globalkey_s const *gl ;
@@ -135,6 +138,7 @@ static inline void parse_log (char const *s, size_t const *word, size_t n, mdt c
static struct logkey_s const logkeys[] =
{
{ .name = "answer", .value = TIPIDEE_LOG_ANSWER },
+ { .name = "answer_size", .value = TIPIDEE_LOG_SIZE },
{ .name = "debug", .value = TIPIDEE_LOG_DEBUG },
{ .name = "host_as_prefix", .value = TIPIDEE_LOG_HOSTASPREFIX },
{ .name = "hostname", .value = TIPIDEE_LOG_CLIENTHOST },
@@ -143,7 +147,6 @@ static inline void parse_log (char const *s, size_t const *word, size_t n, mdt c
{ .name = "referrer", .value = TIPIDEE_LOG_REFERRER },
{ .name = "request", .value = TIPIDEE_LOG_REQUEST },
{ .name = "resource", .value = TIPIDEE_LOG_RESOURCE },
- { .name = "response_size", .value = TIPIDEE_LOG_SIZE },
{ .name = "start", .value = TIPIDEE_LOG_START },
{ .name = "user-agent", .value = TIPIDEE_LOG_UA }
} ;
@@ -159,6 +162,7 @@ static inline void parse_log (char const *s, size_t const *word, size_t n, mdt c
else if (n == 1) v = 0 ;
else strerr_dief5x(1, "log nothing cannot be mixed with other log values", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ;
}
+
uint32_pack_big(pack, v) ;
add_unique("G:logv", pack, 4, md) ;
}