Add zuccless random mode. - bitreich-httpd - Bitreich HTTPD service
 (HTM) git clone git://bitreich.org/bitreich-httpd git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/bitreich-httpd
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit a0590477c4c74d7111a031a4cb1c9e5d61ff3044
 (DIR) parent 0f24889dc4f0b3982034d9c4ff58e73f8abe3e16
 (HTM) Author: Christoph Lohmann <20h@r-36.net>
       Date:   Thu,  4 Aug 2022 21:13:33 +0200
       
       Add zuccless random mode.
       
       Diffstat:
         M bitreich-httpd.c                    |      27 ++++++++++++++++++---------
       
       1 file changed, 18 insertions(+), 9 deletions(-)
       ---
 (DIR) diff --git a/bitreich-httpd.c b/bitreich-httpd.c
       @@ -13,6 +13,7 @@
        #include <string.h>
        #include <sys/socket.h>
        #include <netdb.h>
       +#include <time.h>
        
        void *
        xmalloc(size_t size)
       @@ -109,6 +110,7 @@ main(int argc, char *argv[])
                int rlen;
                struct sockaddr_storage clt;
                socklen_t cltlen = sizeof(clt);
       +        time_t tim;
        
                wwwbase = "/bitreich/www";
                wwwindex = "index.html";
       @@ -164,17 +166,24 @@ main(int argc, char *argv[])
                        sleep(1);
                        asprintf(&path, "%s/s/yolo-css.css", wwwbase);
                        ctype = "text/css";
       -        } else if (strstr(request, "zucc-meat.webm")) {
       -                asprintf(&path, "%s/zucc-meat.webm", zuccbase);
       -                ctype = "video/webm";
                } else {
       -                if (strstr(request, "Host: www.zuccless.org"))
       -                        wwwbase = zuccbase;
       -                if (strstr(request, "Host: zuccless.org"))
       +                if (strstr(request, "zuccless.org")) {
       +                        tim = time(NULL);
       +                        srandom(tim);
                                wwwbase = zuccbase;
       -
       -                asprintf(&path, "%s/%s", wwwbase, wwwindex);
       -                ctype = "text/html";
       +                        switch (random() % 3) {
       +                        case 0:
       +                                asprintf(&path, "%s/zucc-job.webm", zuccbase);
       +                                break;
       +                        default:
       +                                asprintf(&path, "%s/zucc-meat.webm", zuccbase);
       +                                break;
       +                        }
       +                        ctype = "video/webm";
       +                } else {
       +                        asprintf(&path, "%s/%s", wwwbase, wwwindex);
       +                        ctype = "text/html";
       +                }
                }
        
                rlen = servefile(path, ctype, 1);