From 63932814a071d8211a85ba4b57cace4b2314984c Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Tue, 10 Jul 2018 10:26:09 +0200 Subject: [PATCH] It is working --- CppNet | 2 +- Makefile | 9 ++++++++- run.sh | 2 +- src/client.cpp | 8 ++++---- src/necronda-server.cpp | 45 ++++++++--------------------------------- src/necronda-server.h | 8 -------- 6 files changed, 22 insertions(+), 52 deletions(-) diff --git a/CppNet b/CppNet index e51933f..5a61a16 160000 --- a/CppNet +++ b/CppNet @@ -1 +1 @@ -Subproject commit e51933f03c96a1dd74ca662035a6358c62ede4c2 +Subproject commit 5a61a165c4a6957a8396f27c36c51511e25b94c1 diff --git a/Makefile b/Makefile index 6b3e0eb..d67b56e 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,18 @@ packages: sudo apt-get install g++ libmagic-dev libssl-dev php-cgi @echo "Finished downloading!" +update: + @echo "Updating imported git repos..." + cd CppNet + git pull + cd .. + @echo "Finished updating!" + compile: @echo "Compiling..." @mkdir -p bin g++ src/necronda-server.cpp -o bin/necronda-server -std=c++17 -fPIC -pthread -lz -lmagic -lssl -ldl -lcrypto @echo "Finished compiling!" -install: | packages compile +install: | packages update compile @echo "Finished!" diff --git a/run.sh b/run.sh index a599718..6a869b5 100644 --- a/run.sh +++ b/run.sh @@ -1,6 +1,6 @@ #!/bin/bash echo "-- Building and starting Necronda Server..." -make compile && \ +make update && make compile && \ echo -e "-- Successfully finished compiling!\n" && \ sleep 0.0625 && \ echo -e "-- Starting Server...\n" && \ diff --git a/src/client.cpp b/src/client.cpp index 2813b64..41fbe06 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -14,11 +14,11 @@ #include #include -#include "network/Socket.h" -#include "network/http/HttpRequest.h" -#include "network/http/HttpConnection.h" +#include "../CppNet/src/network/Socket.h" +#include "../CppNet/src/network/http/HttpRequest.h" +#include "../CppNet/src/network/http/HttpConnection.h" #include "necronda-server.h" -#include "network/http/HttpStatusCode.h" +#include "../CppNet/src/network/http/HttpStatusCode.h" #include "URI.h" #include "procopen.h" diff --git a/src/necronda-server.cpp b/src/necronda-server.cpp index f7c02d5..da2ba5a 100644 --- a/src/necronda-server.cpp +++ b/src/necronda-server.cpp @@ -20,18 +20,6 @@ using namespace std; const char* webroot = "/srv/necronda/"; - -/** - * Returns UNIX time in microseconds - * @return UNIX time [µs] - */ -unsigned long getMicros() { - struct timeval tv; - gettimeofday(&tv, nullptr); - return (unsigned long) (1000000 * tv.tv_sec + tv.tv_usec); -} - - string getMimeType(string path) { unsigned long pos = path.find_last_of('.'); @@ -63,24 +51,6 @@ string getMimeType(string path) { * Sun, 06 Nov 1994 08:49:37 GMT * @return */ -string getHttpDate() { - time_t rawtime; - time(&rawtime); - return getHttpDate(rawtime); -} - -string getHttpDate(string filename) { - struct stat attrib; - stat(filename.c_str(), &attrib); - return getHttpDate(attrib.st_ctime); -} - -string getHttpDate(time_t time) { - char buffer[64]; - struct tm *timeinfo = gmtime(&time); - strftime(buffer, sizeof(buffer), "%a, %d %b %Y %H:%M:%S GMT", timeinfo); - return string(buffer); -} std::string getTimestamp(string path) { struct stat attrib; @@ -210,14 +180,15 @@ string read_line(FILE* file) { #include "procopen.cpp" -#include "network/Address.cpp" -#include "network/Socket.cpp" +#include "../CppNet/src/network/Address.cpp" +#include "../CppNet/src/network/Socket.cpp" #include "URI.cpp" -#include "network/http/HttpStatusCode.cpp" -#include "network/http/HttpHeader.cpp" -#include "network/http/HttpRequest.cpp" -#include "network/http/HttpResponse.cpp" -#include "network/http/HttpConnection.cpp" +#include "../CppNet/src/network/http/Http.cpp" +#include "../CppNet/src/network/http/HttpStatusCode.cpp" +#include "../CppNet/src/network/http/HttpHeader.cpp" +#include "../CppNet/src/network/http/HttpRequest.cpp" +#include "../CppNet/src/network/http/HttpResponse.cpp" +#include "../CppNet/src/network/http/HttpConnection.cpp" string getWebRoot(string host) { if (host == "www.necronda.net") { diff --git a/src/necronda-server.h b/src/necronda-server.h index 452911e..550ad9b 100644 --- a/src/necronda-server.h +++ b/src/necronda-server.h @@ -7,8 +7,6 @@ #ifndef NECRONDA_SERVER #define NECRONDA_SERVER -#define CHUNK 16384 - using namespace std; unsigned long getMicros(); @@ -21,12 +19,6 @@ string getWebRoot(string host); string getMimeType(string path); -string getHttpDate(time_t time); - -string getHttpDate(); - -string getHttpDate(string filename); - string getTimestamp(string path); string getTimestamp(time_t time);