]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Also use the new incbin for rec and dnsdist
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 11 Dec 2020 11:18:12 +0000 (12:18 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 11 Dec 2020 11:18:12 +0000 (12:18 +0100)
pdns/dnsdist-web.cc
pdns/dnsdistdist/incfiles
pdns/recursordist/incfiles
pdns/ws-recursor.cc

index 4b5b63a5cd5b3764cc8faf8db71e0de32296f812..0dc9a19b22020c9bafc5be7ce676a44abc8ed130 100644 (file)
@@ -26,7 +26,6 @@
 #include <sys/resource.h>
 #include <thread>
 
-#include "ext/incbin/incbin.h"
 #include "ext/json11/json11.hpp"
 #include <yahttp/yahttp.hpp>
 
index 9dd02368672010c2aaa1129b81eed83996e72c8a..9f96afe59a714b27db6342eed460c3354ff13f72 100755 (executable)
@@ -11,7 +11,9 @@ fi
 for a in $(find ${DIR}html -type f | grep -v \~ | sort)
 do
        c=$(echo $a | sed s:${DIR}html/:: | tr "/.-" "___")
-       echo "INCBIN(${c}, \"$a\");"
+        echo "static const unsigned char g${c}Data[] = {"
+       od -v -t x1 "$a" | sed  's/^[0-7]*//' | sed 's/\([0-9a-f][0-9a-f]\)/0x\1,/g'
+       echo "};"
 done
 
 echo "static const map<string,string> s_urlmap={"
@@ -19,6 +21,6 @@ for a in $(find ${DIR}html -type f | grep -v \~ | sort)
 do
        b=$(echo $a | sed s:${DIR}html/::g)
        c=$(echo $b | tr "/.-" "___")
-       echo "{\"$b\", string((const char*)g${c}Data, g${c}Size)},"
+       echo "{\"$b\", string((const char*)g${c}Data, sizeof(g${c}Data))},"
 done
 echo "};"
index da127415f6dac6661e48ba451864738471bd8c92..a65909a53e814c6431836edb9ebef5b9350284a9 100755 (executable)
@@ -11,14 +11,16 @@ fi
 for a in $(find ${DIR}html -type f | grep -v \~ | sort)
 do
        c=$(echo $a | sed s:${DIR}html/:: | tr "/.-" "___")
-       echo "INCBIN(${c}, \"$a\");"
+        echo "static const unsigned char g${c}Data[] = {"
+       od -v -t x1 "$a" | sed  's/^[0-7]*//' | sed 's/\([0-9a-f][0-9a-f]\)/0x\1,/g'
+       echo "};"
 done
 
-echo "map<string,string> g_urlmap={"
+echo "static const map<string,string> g_urlmap={"
 for a in $(find ${DIR}html -type f | grep -v \~ | sort)
 do
        b=$(echo $a | sed s:${DIR}html/::g)
        c=$(echo $b | tr "/.-" "___")
-       echo "{\"$b\", string((const char*)g${c}Data, g${c}Size)},"
+       echo "{\"$b\", string((const char*)g${c}Data, sizeof(g${c}Data))},"
 done
 echo "};"
index 1c31c1f7face0294161b714a4bd46c07c7f8d076..8eac8adab190dca20b77cc1633fdb583e0991506 100644 (file)
@@ -39,7 +39,6 @@
 #include "webserver.hh"
 #include "ws-api.hh"
 #include "logger.hh"
-#include "ext/incbin/incbin.h"
 #include "rec-lua-conf.hh"
 #include "rpzloader.hh"
 #include "uuid-utils.hh"
@@ -500,8 +499,13 @@ static void serveStuff(HttpRequest* req, HttpResponse* resp)
   resp->headers["X-XSS-Protection"] = "1; mode=block";
   //  resp->headers["Content-Security-Policy"] = "default-src 'self'; style-src 'self' 'unsafe-inline'";
 
-  resp->body = g_urlmap[req->url.path.c_str()+1];
-  resp->status = 200;
+  if (g_urlmap.count(req->url.path.c_str()+1)) {
+    resp->body = g_urlmap.at(req->url.path.c_str()+1);
+    resp->status = 200;
+  } else {
+    resp->body = "Not Found";
+    resp->status = 404;
+  }
 }