Make app middlewares not require specific instances of app
diff --git a/src/g3log/generated_definitions.hpp b/src/g3log/generated_definitions.hpp
new file mode 100644
index 0000000..18433bb
--- /dev/null
+++ b/src/g3log/generated_definitions.hpp
@@ -0,0 +1,13 @@
+// AUTO GENERATED MACRO DEFINITIONS FOR G3LOG
+
+/** ==========================================================================
+* 2015 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes
+* with no warranties. This code is yours to share, use and modify with no
+* strings attached and no restrictions or obligations.
+*
+* For more information see g3log/LICENSE or refer refer to http://unlicense.org
+* ============================================================================*/
+#pragma once
+
+// CMake induced definitions below. See g3log/Options.cmake for details.
+
diff --git a/src/getvideo_main.cpp b/src/getvideo_main.cpp
index 2259b8c..182e8ad 100644
--- a/src/getvideo_main.cpp
+++ b/src/getvideo_main.cpp
@@ -39,14 +39,14 @@
std::cout << "Writing\n";
int status;
- /*
+
status = write(video_fd, reinterpret_cast<char*>(&image_info),
sizeof(image_info));
if (status != 0) {
std::cout << "Write failed. Return: " << status <<"\n";
perror("perror output:");
}
- */
+
std::cout << "Write done\n";
//std::this_thread::sleep_for(std::chrono::milliseconds(2000));
@@ -64,8 +64,9 @@
std::cout << std::hex << std::setfill('0') << std::setw(2)
<< int(*(pt + i)) << " ";
}
- std::cout << "\n";
- /*
+
+ std::cout << "\nprinting buffer\n";
+
for(int i = 0; i < 1024; i++){
if (i % 16 == 0){
std::cout << "\n";
@@ -73,7 +74,7 @@
std::cout << std::hex << std::setfill('0') << std::setw(2)
<< int(buffer[i]) << " ";
}
- */
+
buffer.resize(image_info.len);
std::ofstream f("/tmp/screen.jpg",std::ios::out | std::ios::binary);
diff --git a/src/security_headers_middleware_test.cpp b/src/security_headers_middleware_test.cpp
index 2364ab5..fc183e9 100644
--- a/src/security_headers_middleware_test.cpp
+++ b/src/security_headers_middleware_test.cpp
@@ -40,13 +40,13 @@
c.connect(asio::ip::tcp::endpoint(asio::ip::address::from_string("127.0.0.1"),
45451));
c.send(asio::buffer(sendmsg));
- auto received_count = c.receive(asio::buffer(buf));
+ c.receive(asio::buffer(buf));
c.close();
auto return_code = std::string(&buf[9], &buf[12]);
EXPECT_EQ("200", return_code);
std::string response(std::begin(buf), std::end(buf));
- // This is a routine to split strings until a newline is hit
+ // This is a routine to split strings until a blank is hit
// TODO(ed) this should really use the HTTP parser
std::vector<std::string> headers;
std::string::size_type pos = 0;
diff --git a/src/token_authorization_middleware_test.cpp b/src/token_authorization_middleware_test.cpp
index 68efe8f..00eed2f 100644
--- a/src/token_authorization_middleware_test.cpp
+++ b/src/token_authorization_middleware_test.cpp
@@ -24,7 +24,7 @@
c.connect(asio::ip::tcp::endpoint(
asio::ip::address::from_string("127.0.0.1"), 45451));
c.send(asio::buffer(sendmsg));
- auto received_count = c.receive(asio::buffer(buf, 2048));
+ c.receive(asio::buffer(buf, 2048));
c.close();
EXPECT_EQ("200", std::string(buf + 9, buf + 12));
}
@@ -66,7 +66,7 @@
}
}
c.send(asio::buffer(sendmsg));
- auto received_count = c.receive(asio::buffer(buf, 2048));
+ c.receive(asio::buffer(buf, 2048));
c.close();
EXPECT_EQ("401", std::string(buf + 9, buf + 12));
@@ -95,7 +95,7 @@
}
}
c.send(asio::buffer(sendmsg));
- auto received_count = c.receive(asio::buffer(buf, 2048));
+ c.receive(asio::buffer(buf, 2048));
c.close();
EXPECT_EQ("401", std::string(buf + 9, buf + 12));
@@ -118,7 +118,7 @@
c.connect(asio::ip::tcp::endpoint(
asio::ip::address::from_string("127.0.0.1"), 45451));
c.send(asio::buffer(sendmsg));
- auto received_count = c.receive(asio::buffer(buf));
+ c.receive(asio::buffer(buf));
c.close();
};
@@ -193,7 +193,7 @@
c.connect(asio::ip::tcp::endpoint(
asio::ip::address::from_string("127.0.0.1"), 45451));
c.send(asio::buffer(sendmsg));
- auto received_count = c.receive(asio::buffer(buf));
+ c.receive(asio::buffer(buf));
c.close();
};
diff --git a/src/udpclient.cpp b/src/udpclient.cpp
index 772739b..cf9f3d1 100644
--- a/src/udpclient.cpp
+++ b/src/udpclient.cpp
@@ -85,7 +85,7 @@
udp::endpoint sender_endpoint;
size_t len =
socket.receive_from(boost::asio::buffer(recv_buf), sender_endpoint);
-
+ std::cout << len;
for (auto character : recv_buf) {
std::cout << std::hex << static_cast<unsigned>(character) << " ";
}
diff --git a/src/webassets_test.cpp b/src/webassets_test.cpp
index 2157f03..8d0cfef 100644
--- a/src/webassets_test.cpp
+++ b/src/webassets_test.cpp
@@ -186,7 +186,6 @@
while ((pos = response.find("\r\n", prev)) != std::string::npos) {
auto this_string = response.substr(prev, pos - prev);
if (this_string == "") {
- prev = pos + 2;
break;
}
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index cf8500f..949bdc1 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -1,9 +1,7 @@
-#include <webassets.hpp>
#include <web_kvm.hpp>
+#include <webassets.hpp>
#include "ssl_key_handler.hpp"
-#include <crow/bmc_app_type.hpp>
-
#include "crow/app.h"
#include "crow/ci_map.h"
#include "crow/common.h"
@@ -26,15 +24,15 @@
#include "crow/utility.h"
#include "crow/websocket.h"
-
#include "color_cout_g3_sink.hpp"
#include "webassets.hpp"
+#include "security_headers_middleware.hpp"
+#include "token_authorization_middleware.hpp"
#include <boost/asio.hpp>
#include <boost/endian/arithmetic.hpp>
-
#include <iostream>
#include <memory>
#include <string>
@@ -52,13 +50,13 @@
std::string ssl_pem_file("server.pem");
ensuressl::ensure_openssl_key_present_and_valid(ssl_pem_file);
- BmcAppType app;
+ crow::App<crow::TokenAuthorizationMiddleware, crow::SecurityHeadersMiddleware>
+ app;
crow::webassets::request_routes(app);
crow::kvm::request_routes(app);
crow::logger::setLogLevel(crow::LogLevel::INFO);
- app.debug_print();
CROW_ROUTE(app, "/systeminfo")
([]() {
@@ -112,7 +110,7 @@
size_t len =
socket.receive_from(boost::asio::buffer(recv_buf), sender_endpoint);
// TODO(ed) THis is ugly. Find a way to not make a copy (ie, use
- // std::string::data() to
+ // std::string::data() to
std::string str(std::begin(recv_buf), std::end(recv_buf));
LOG(DEBUG) << "Got " << str << "back \n";
conn.send_binary(str);