some review
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
#include "OpenRouter.hpp"
|
||||
#include <colors.h>
|
||||
#include "../settings/settings.hpp"
|
||||
#include "../system/system.hpp"
|
||||
#include <syslog.h>
|
||||
#include "../security/cors.hpp"
|
||||
|
||||
OpenRouter::OpenRouter() {
|
||||
this->srv.Post("/api/settings/telnet/get", settings::get_telnet);
|
||||
@@ -45,11 +50,9 @@ OpenRouter::OpenRouter() {
|
||||
this->srv.set_mount_point("/css", "../src/web/css");
|
||||
}
|
||||
|
||||
OpenRouter::~OpenRouter() {
|
||||
|
||||
}
|
||||
OpenRouter::~OpenRouter() = default;
|
||||
|
||||
int OpenRouter::serve(const std::string ip, int port, int socket_flags) {
|
||||
int OpenRouter::serve(const std::string *ip, int port, int socket_flags) {
|
||||
std::cout << GREEN << "Starting" << RESET << " server on [ " << YELLOW
|
||||
<< "0.0.0.0" << RESET << ":" << CYAN << "43244" << RESET << " ]" << std::endl;
|
||||
|
||||
|
||||
@@ -3,13 +3,8 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <httplib.h>
|
||||
#include <colors.h>
|
||||
#include "../settings/settings.hpp"
|
||||
#include "../system/system.hpp"
|
||||
#include <syslog.h>
|
||||
|
||||
#define CORS_ENABLE
|
||||
#include "../security/cors.hpp"
|
||||
|
||||
class OpenRouter {
|
||||
private:
|
||||
@@ -18,7 +13,7 @@ class OpenRouter {
|
||||
public:
|
||||
OpenRouter();
|
||||
~OpenRouter();
|
||||
int serve(const std::string ip, int port, int socket_flags = 0);
|
||||
int serve(const std::string *ip, int port, int socket_flags = 0);
|
||||
};
|
||||
|
||||
#endif // OPENROUTER_HPP
|
||||
@@ -5,12 +5,12 @@
|
||||
#include <json.hpp>
|
||||
#include "../types.hpp"
|
||||
|
||||
bool authenticate(std::string token) {
|
||||
bool authenticate(const std::string &token) {
|
||||
httplib::Client cli(AUTH_SERVICE);
|
||||
|
||||
std::stringstream body;
|
||||
body << R"({"token":")" << token << R"("})";
|
||||
httplib::Result res = cli.Post("/api/access", body.str().c_str(), JSON_TYPE);
|
||||
httplib::Result res = cli.Post("/api/access", body.str(), JSON_TYPE);
|
||||
if (res->status == httplib::OK_200) {
|
||||
nlohmann::json resjson = nlohmann::json::parse(res->body);
|
||||
if (resjson["access"] == "reject") {
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
bool authenticate(std::string token);
|
||||
bool authenticate(const std::string token);
|
||||
|
||||
#endif // AUTH_HPP
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "dns.hpp"
|
||||
#include <colors.h>
|
||||
#include <json.hpp>
|
||||
#include "../../routes.hpp"
|
||||
#include "../../types.hpp"
|
||||
#include <syslog.h>
|
||||
#include "../../auth/auth.hpp"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "dns.hpp"
|
||||
#include <colors.h>
|
||||
#include <json.hpp>
|
||||
#include "../../routes.hpp"
|
||||
#include "../../types.hpp"
|
||||
#include <syslog.h>
|
||||
#include "../../auth/auth.hpp"
|
||||
@@ -31,7 +30,7 @@ namespace settings {
|
||||
while (!domainsfile.eof()) {
|
||||
domainsfile >> ip_string;
|
||||
domainsfile >> domain_string;
|
||||
if (domain_string == "") {
|
||||
if (domain_string.empty()) {
|
||||
continue;
|
||||
}
|
||||
responsedata << R"({"ip":")" << ip_string << R"(","domain":")" << domain_string << R"("},)";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "dns.hpp"
|
||||
#include <colors.h>
|
||||
#include <json.hpp>
|
||||
#include "../../routes.hpp"
|
||||
#include "../../types.hpp"
|
||||
#include <syslog.h>
|
||||
#include "../../auth/auth.hpp"
|
||||
@@ -62,9 +61,9 @@ namespace settings {
|
||||
if (authenticate(json_body["token"])) {
|
||||
std::ofstream dnsserversfile("/etc/dnsmasq.conf.d/resolv.conf");
|
||||
nlohmann::json servers = json_body["servers"];
|
||||
for (nlohmann::json_abi_v3_11_3::json server : servers) {
|
||||
for (const nlohmann::json_abi_v3_11_3::json server : servers) {
|
||||
std::string srv = server;
|
||||
if (server == "") {
|
||||
if (server.empty()) {
|
||||
continue;
|
||||
}
|
||||
dnsserversfile << "nameserver " << srv << "\n";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "ftp.hpp"
|
||||
#include <colors.h>
|
||||
#include <json.hpp>
|
||||
#include "../../routes.hpp"
|
||||
#include "../../types.hpp"
|
||||
#include <syslog.h>
|
||||
#include "../../auth/auth.hpp"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "ssh.hpp"
|
||||
#include <colors.h>
|
||||
#include <json.hpp>
|
||||
#include "../../routes.hpp"
|
||||
#include "../../types.hpp"
|
||||
#include <syslog.h>
|
||||
#include "../../auth/auth.hpp"
|
||||
@@ -30,7 +29,7 @@ namespace settings {
|
||||
std::string key_string = "";
|
||||
int iter = 0;
|
||||
while (std::getline(keysfile, key_string)) {
|
||||
if (key_string == "") {
|
||||
if (key_string.empty()) {
|
||||
continue;
|
||||
}
|
||||
responsedata << R"(")" << key_string << R"(",)";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "ssh.hpp"
|
||||
#include <colors.h>
|
||||
#include "../../types.hpp"
|
||||
#include "../../routes.hpp"
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "ssh.hpp"
|
||||
#include <colors.h>
|
||||
#include <json.hpp>
|
||||
#include "../../routes.hpp"
|
||||
#include "../../types.hpp"
|
||||
#include <syslog.h>
|
||||
#include "../../auth/auth.hpp"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "telnet.hpp"
|
||||
#include <colors.h>
|
||||
#include "../../types.hpp"
|
||||
#include "../../routes.hpp"
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "telnet.hpp"
|
||||
#include <colors.h>
|
||||
#include "../../types.hpp"
|
||||
#include "../../routes.hpp"
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "wifi.hpp"
|
||||
#include <colors.h>
|
||||
#include "../../types.hpp"
|
||||
#include "../../routes.hpp"
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "wifi.hpp"
|
||||
#include <colors.h>
|
||||
#include "../../types.hpp"
|
||||
#include "../../routes.hpp"
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "wifi.hpp"
|
||||
#include <colors.h>
|
||||
#include "../../types.hpp"
|
||||
#include "../../routes.hpp"
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "wifi.hpp"
|
||||
#include <colors.h>
|
||||
#include <json.hpp>
|
||||
#include "../../routes.hpp"
|
||||
#include "../../types.hpp"
|
||||
#include <QR-Code-generator/qrcodegen.hpp>
|
||||
#include <QR-Code-generator/qrtosvg.hpp>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "wifi.hpp"
|
||||
#include <colors.h>
|
||||
#include <json.hpp>
|
||||
#include "../../routes.hpp"
|
||||
#include "../../types.hpp"
|
||||
#include <syslog.h>
|
||||
#include "../../auth/auth.hpp"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "reboot.hpp"
|
||||
#include <json.hpp>
|
||||
#include "../routes.hpp"
|
||||
#include <colors.h>
|
||||
#include "../types.hpp"
|
||||
#include "../../auth/auth.hpp"
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#include "syslog.hpp"
|
||||
#include <colors.h>
|
||||
#include "../types.hpp"
|
||||
#include "../routes.hpp"
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
Reference in New Issue
Block a user