diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-07-16 01:51:04 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2024-07-16 01:51:04 +0000 |
commit | d1c4602f80e395d1d6ab0453b8f0a6cc10aefadf (patch) | |
tree | 9e1410955b66e99d2284b0baa207d32264669716 /src/config | |
parent | 8b435b76d68dd8f11808f0cff4d8998d2be48f4c (diff) | |
download | shibari-d1c4602f80e395d1d6ab0453b8f0a6cc10aefadf.tar.xz |
Refactor dcache, add prep for shibari-cache
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/config')
-rw-r--r-- | src/config/defaults.c | 1 | ||||
-rw-r--r-- | src/config/lexparse.c | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/config/defaults.c b/src/config/defaults.c index 14fce76..d4ff2a8 100644 --- a/src/config/defaults.c +++ b/src/config/defaults.c @@ -18,6 +18,7 @@ struct defaults_s static struct defaults_s const defaults[] = { RECU32("G:logv", 1), + RECU32("G:maxtcp", 256), REC("G:listen4", "\0\0\0\0\0\35", 6), REC("G:listen6", "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\35", 18), diff --git a/src/config/lexparse.c b/src/config/lexparse.c index 9987fbd..f1b3600 100644 --- a/src/config/lexparse.c +++ b/src/config/lexparse.c @@ -38,6 +38,7 @@ struct namevalue_s enum directivevalue_e { T_VERBOSITY, + T_MAXTCP, T_LISTEN, T_SERVER, T_FORWARD, @@ -87,6 +88,20 @@ static inline void parse_verbosity (char const *s, size_t const *word, size_t n, add_unique("G:logv", pack, 4, md) ; } +static inline void parse_maxtcp (char const *s, size_t const *word, size_t n, mdt const *md) +{ + uint32_t max ; + char pack[4] ; + if (n != 1) + strerr_dief8x(1, "too ", n ? "many" : "few", " arguments to directive ", "maxtcp", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ; + if (!uint320_scan(s + word[0], &max)) + strerr_dief7x(1, " argument to directive ", "maxtcp", " must be an integer ", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ; + if (max > 4000) + strerr_dief7x(1, " argument to directive ", "maxtcp", " must be 4000 or less ", " in file ", g.storage.s + md->filepos, " line ", md->linefmt) ; + uint32_pack_big(pack, max) ; + add_unique("G:maxtcp", pack, 4, md) ; +} + static inline void parse_listen (char const *s, size_t const *word, size_t n, mdt const *md) { if (!n) @@ -140,8 +155,10 @@ static inline void process_line (char const *s, size_t const *word, size_t n, md { static struct namevalue_s const directives[] = { + { .name = "accept", .value = T_ACCEPT }, { .name = "forward", .value = T_FORWARD }, { .name = "listen", .value = T_LISTEN }, + { .name = "maxtcp", .value = T_MAXTCP }, { .name = "server", .value = T_SERVER }, { .name = "verbosity", .value = T_VERBOSITY }, } ; @@ -157,9 +174,15 @@ static inline void process_line (char const *s, size_t const *word, size_t n, md case T_VERBOSITY : parse_verbosity(s, word, n, md) ; break ; + case T_MAXTCP : + parse_maxtcp(s, word, n, md) ; + break ; case T_LISTEN : parse_listen(s, word, n, md) ; break ; + case T_ACCEPT : + parse_accept(s, word, n, md) ; + break ; case T_SERVER : parse_server(s, word, n, md, 0) ; break ; @@ -227,4 +250,5 @@ void conf_lexparse (buffer *b, char const *ifile) } genalloc_free(size_t, &words) ; stralloc_free(&sa) ; + default_accept() ; } |