diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-04-04 01:38:05 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2025-04-04 01:38:05 +0000 |
| commit | 68df4fe5094af1e75b2f7e2b25887ea8c857caaa (patch) | |
| tree | ca6a61824e4a7279c8f70c7180ff87a87e565fc3 /src | |
| parent | 58cdddb0a09e74fe6447c99a34dfa2ce7f8b5dee (diff) | |
| download | tipidee-68df4fe5094af1e75b2f7e2b25887ea8c857caaa.tar.gz | |
Add rudimentary tarpit support
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/tipideed/tipideed-internal.h | 2 | ||||
| -rw-r--r-- | src/tipideed/tipideed.c | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/tipideed/tipideed-internal.h b/src/tipideed/tipideed-internal.h index eaa8341..e8cf102 100644 --- a/src/tipideed/tipideed-internal.h +++ b/src/tipideed/tipideed-internal.h @@ -32,6 +32,7 @@ struct global_s char const *indexnames[16] ; tipidee_response_header const *rhdr ; int p[2] ; + uint32_t tarpit ; uint32_t rhdrn ; uint32_t logv ; uint32_t maxrqbody ; @@ -55,6 +56,7 @@ struct global_s .cgitto = TAIN_ZERO, \ .defaulthost = "@", \ .indexnames = { 0 }, \ + .tarpit = 0, \ .rhdr = 0, \ .p = { -1, -1 }, \ .rhdrn = 0, \ diff --git a/src/tipideed/tipideed.c b/src/tipideed/tipideed.c index c3956ed..f0c6eac 100644 --- a/src/tipideed/tipideed.c +++ b/src/tipideed/tipideed.c @@ -302,6 +302,8 @@ static inline int serve (tipidee_rql *rql, char const *docroot, char *uribuf, ti tipidee_log_resource(g.logv, rql, fn, &ra, infopath) ; + if (g.tarpit) sleep(g.tarpit / 1000) ; + if (ra.flags & TIPIDEE_RA_FLAG_CGI) return respond_cgi(rql, docroot, fn, docrootlen, infopath, uribuf, hdr, &ra, body, bodylen) ; @@ -382,6 +384,8 @@ int main (int argc, char const *const *argv, char const *const *envp) if (!n) strerr_dief3x(102, "bad", " config value for ", "G:index_file") ; g.indexn = n-1 ; + x = getenv("TARPIT") ; + if (x) uint320_scan(x, &g.tarpit) ; x = tipidee_conf_get_responseheaders(&g.conf, "G:response_headers", &n, &g.rhdrn) ; if (!x) strerr_diefu3sys(102, "get", " config value for ", "G:response_headers") ; @@ -420,6 +424,7 @@ int main (int argc, char const *const *argv, char const *const *envp) tain_add_g(&deadline, &g.readtto) ; bodysa.len = 0 ; + if (g.tarpit) sleep(g.tarpit / 1000) ; e = tipidee_rql_read_g(buffer_0, uribuf, URI_BUFSIZE, 0, &rql, &deadline) ; switch (e) { |
