#include <sys/resource.h>
#include <thread>
-#include "ext/incbin/incbin.h"
#include "ext/json11/json11.hpp"
#include <yahttp/yahttp.hpp>
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={"
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 "};"
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 "};"
#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"
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;
+ }
}