syslog added
This commit is contained in:
@@ -23,4 +23,6 @@ add_executable(
|
||||
src/settings/ftp/ftp.cpp
|
||||
|
||||
src/reboot/reboot.cpp
|
||||
|
||||
src/syslog/syslog.cpp
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "settings/dns/dns.hpp"
|
||||
#include "settings/ftp/ftp.hpp"
|
||||
#include "reboot/reboot.hpp"
|
||||
#include "syslog/syslog.hpp"
|
||||
|
||||
#define CORS_ENABLE
|
||||
#include "security/cors.hpp"
|
||||
@@ -37,6 +38,8 @@ int main() {
|
||||
|
||||
srv.Post("/api/reboot", reboot);
|
||||
|
||||
srv.Get("/api/syslog", syslog);
|
||||
|
||||
srv.Options("/(.*)", set_cors_headers);
|
||||
|
||||
srv.set_mount_point("/" , "../src/web");
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "syslog.hpp"
|
||||
#include <colors.h>
|
||||
#include "../types.hpp"
|
||||
#include "../routes.hpp"
|
||||
#include <json.hpp>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#define SYSLOG_FILE "/var/log/messages"
|
||||
|
||||
void syslog(const httplib::Request &request, httplib::Response &response) {
|
||||
std::stringstream responsedata;
|
||||
std::ifstream syslogfile(SYSLOG_FILE);
|
||||
responsedata << syslogfile.rdbuf();
|
||||
syslogfile.close();
|
||||
response.set_content(responsedata.str(), PLAIN_TEXT_TYPE);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef SYSLOG_HPP
|
||||
#define SYSLOG_HPP
|
||||
|
||||
#include <httplib.h>
|
||||
|
||||
void syslog(const httplib::Request &request, httplib::Response &response);
|
||||
|
||||
#endif //SYSLOG_HPP
|
||||
@@ -6,5 +6,6 @@
|
||||
#define JWT_SECRET_KEY "secret"
|
||||
#define STRING403 R"({"status":"403"})"
|
||||
#define JSON_TYPE "application/json"
|
||||
#define PLAIN_TEXT_TYPE "text/plain"
|
||||
|
||||
#endif // TYPES_H
|
||||
@@ -14,6 +14,7 @@ body {
|
||||
}
|
||||
|
||||
.adminpanel {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
transform: scale(0.5);
|
||||
@@ -25,3 +26,7 @@ body {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.section {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@@ -66,10 +66,23 @@
|
||||
}
|
||||
|
||||
.settingssection {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 10px;
|
||||
display: flex;
|
||||
/* flex-direction: column; */
|
||||
gap: 10px;
|
||||
transition: 0.3s;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.settingssection.active {
|
||||
opacity: 1;
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.settingrect {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
.syslogsection {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: 0.3s;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.syslogsection.active {
|
||||
opacity: 1;
|
||||
pointer-events: all;
|
||||
}
|
||||
|
||||
.syslogdata {
|
||||
width: 100%;
|
||||
max-height: 85vh;
|
||||
padding: 10px;
|
||||
border-radius: 10px;
|
||||
/* background-color: rgb(175, 175, 175); */
|
||||
margin: 10px 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
+118
-106
@@ -10,6 +10,7 @@
|
||||
<link rel="stylesheet" href="css/header.css">
|
||||
<link rel="stylesheet" href="css/button.css">
|
||||
<link rel="stylesheet" href="css/loader.css">
|
||||
<link rel="stylesheet" href="css/syslog.css">
|
||||
<title>Openrouter Admin</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -17,7 +18,8 @@
|
||||
<!-- header -->
|
||||
<header class="header">
|
||||
<div class="links">
|
||||
<button class="linkbutton">Settings</button>
|
||||
<button class="linkbutton" id="syslogbutton">Syslog</button>
|
||||
<button class="linkbutton" id="settingsbutton">Settings</button>
|
||||
<button class="linkbutton" id="rebootbutton">Reboot</button>
|
||||
</div>
|
||||
<h1>Openrouter Admin</h1>
|
||||
@@ -28,120 +30,128 @@
|
||||
</header>
|
||||
<!-- header -->
|
||||
<!-- settings block -->
|
||||
<section class="settingssection">
|
||||
<!-- telnet settings -->
|
||||
<div class="settingrect">
|
||||
<div class="settingrectheader">
|
||||
<h2>Telnet</h2>
|
||||
<div class="checkbox-wrapper-2">
|
||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="telnetenable">
|
||||
<div class="section">
|
||||
<section class="settingssection">
|
||||
<!-- telnet settings -->
|
||||
<div class="settingrect">
|
||||
<div class="settingrectheader">
|
||||
<h2>Telnet</h2>
|
||||
<div class="checkbox-wrapper-2">
|
||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="telnetenable">
|
||||
</div>
|
||||
</div>
|
||||
<div class="settingrectbody telnetsettingbody">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;">
|
||||
<label for="telnetportinput" class="forminputlabel">Port</label>
|
||||
<input type="text" id="telnetportinput" class="forminput">
|
||||
</div>
|
||||
<table class="telnetuserstable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>username</th>
|
||||
<th>password</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><th>No users</th></tr>
|
||||
<!-- <tr>
|
||||
<th>root</th>
|
||||
<th>2808</th>
|
||||
</tr> -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="settingrectfooter">
|
||||
<button class="settingrectfooterbutton hiddenbutton" id="add_telnet_user_button">Add telnet user</button>
|
||||
<button class="settingrectfooterbutton" id="set_telnet_settings">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settingrectbody telnetsettingbody">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;">
|
||||
<label for="telnetportinput" class="forminputlabel">Port</label>
|
||||
<input type="text" id="telnetportinput" class="forminput">
|
||||
<!-- telnet settings -->
|
||||
<!-- DNS settings -->
|
||||
<div class="settingrect">
|
||||
<div class="settingrectheader">
|
||||
<h2>DNS</h2>
|
||||
<div class="checkbox-wrapper-2">
|
||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="dnsenable">
|
||||
</div>
|
||||
</div>
|
||||
<table class="telnetuserstable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>username</th>
|
||||
<th>password</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><th>No users</th></tr>
|
||||
<!-- <tr>
|
||||
<th>root</th>
|
||||
<th>2808</th>
|
||||
</tr> -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="settingrectfooter">
|
||||
<button class="settingrectfooterbutton hiddenbutton" id="add_telnet_user_button">Add telnet user</button>
|
||||
<button class="settingrectfooterbutton" id="set_telnet_settings">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- telnet settings -->
|
||||
<!-- DNS settings -->
|
||||
<div class="settingrect">
|
||||
<div class="settingrectheader">
|
||||
<h2>DNS</h2>
|
||||
<div class="checkbox-wrapper-2">
|
||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="dnsenable">
|
||||
<div class="settingrectbody" id="dnssettingsbody">
|
||||
<table class="dnsservers">
|
||||
<thead>
|
||||
<tr><th>DNS servers</th></tr>
|
||||
</thead>
|
||||
<tbody id="dnsserverstablebody">
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>Domains Table</h3>
|
||||
<table class="domains">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="three">IP</th>
|
||||
<th class="three">Domain</th>
|
||||
<!-- <th class="three">Del</th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="domainsstablebody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="settingrectfooter">
|
||||
<button id="add_local_domain_button" class="hiddenbutton settingrectfooterbutton">Add Local Domain</button>
|
||||
<button id="add_dns_server_button" class="hiddenbutton settingrectfooterbutton">Add DNS server</button>
|
||||
<button class="settingrectfooterbutton" id="set_dns_settings">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settingrectbody" id="dnssettingsbody">
|
||||
<table class="dnsservers">
|
||||
<thead>
|
||||
<tr><th>DNS servers</th></tr>
|
||||
</thead>
|
||||
<tbody id="dnsserverstablebody">
|
||||
</tbody>
|
||||
</table>
|
||||
<h3>Domains Table</h3>
|
||||
<table class="domains">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="three">IP</th>
|
||||
<th class="three">Domain</th>
|
||||
<!-- <th class="three">Del</th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="domainsstablebody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="settingrectfooter">
|
||||
<button id="add_local_domain_button" class="hiddenbutton settingrectfooterbutton">Add Local Domain</button>
|
||||
<button id="add_dns_server_button" class="hiddenbutton settingrectfooterbutton">Add DNS server</button>
|
||||
<button class="settingrectfooterbutton" id="set_dns_settings">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- DNS settings -->
|
||||
<!-- ftp settings -->
|
||||
<div class="settingrect">
|
||||
<div class="settingrectheader">
|
||||
<h2>Ftp</h2>
|
||||
<div class="checkbox-wrapper-2">
|
||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="ftpenable">
|
||||
<!-- DNS settings -->
|
||||
<!-- ftp settings -->
|
||||
<div class="settingrect">
|
||||
<div class="settingrectheader">
|
||||
<h2>Ftp</h2>
|
||||
<div class="checkbox-wrapper-2">
|
||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="ftpenable">
|
||||
</div>
|
||||
</div>
|
||||
<div class="settingrectfooter">
|
||||
<!-- <button>Add Ftp server</button> -->
|
||||
<button class="settingrectfooterbutton" id="set_ftp_settings">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settingrectfooter">
|
||||
<!-- <button>Add Ftp server</button> -->
|
||||
<button class="settingrectfooterbutton" id="set_ftp_settings">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ftp settings -->
|
||||
<!-- ssh settings -->
|
||||
<div class="settingrect">
|
||||
<div class="settingrectheader">
|
||||
<h2>SSH</h2>
|
||||
<div class="checkbox-wrapper-2">
|
||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="sshenable">
|
||||
<!-- ftp settings -->
|
||||
<!-- ssh settings -->
|
||||
<div class="settingrect">
|
||||
<div class="settingrectheader">
|
||||
<h2>SSH</h2>
|
||||
<div class="checkbox-wrapper-2">
|
||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="sshenable">
|
||||
</div>
|
||||
</div>
|
||||
<div class="settingrectbody" id="sshsettingsbody">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;">
|
||||
<label for="sshportinput" class="forminputlabel">Port</label>
|
||||
<input type="text" id="sshportinput" class="forminput">
|
||||
</div>
|
||||
<table class="sshkeys">
|
||||
<thead>
|
||||
<tr><th>SSH keys</th></tr>
|
||||
</thead>
|
||||
<tbody id="sshkeystablebody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="settingrectfooter onebutton">
|
||||
<button id="add_ssh_key" class="hiddenbutton settingrectfooterbutton">Add SSH key</button>
|
||||
<button class="settingrectfooterbutton" id="set_ssh_settings">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settingrectbody" id="sshsettingsbody">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;">
|
||||
<label for="sshportinput" class="forminputlabel">Port</label>
|
||||
<input type="text" id="sshportinput" class="forminput">
|
||||
</div>
|
||||
<table class="sshkeys">
|
||||
<thead>
|
||||
<tr><th>SSH keys</th></tr>
|
||||
</thead>
|
||||
<tbody id="sshkeystablebody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="settingrectfooter onebutton">
|
||||
<button id="add_ssh_key" class="hiddenbutton settingrectfooterbutton">Add SSH key</button>
|
||||
<button class="settingrectfooterbutton" id="set_ssh_settings">Confirm</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- ssh settings -->
|
||||
</section>
|
||||
<!-- ssh settings -->
|
||||
</section>
|
||||
<!-- syslog block -->
|
||||
<section class="syslogsection">
|
||||
<h2 class="syslogheader">Syslog</h2>
|
||||
<div class="syslogdata"></div>
|
||||
</section>
|
||||
<!-- syslog block -->
|
||||
</div>
|
||||
<!-- settings block -->
|
||||
</section>
|
||||
|
||||
@@ -219,6 +229,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<!-- loader -->
|
||||
<script src="js/header.js"></script>
|
||||
<script src="js/routes.js"></script>
|
||||
<script src="js/notification.js"></script>
|
||||
<script src="js/loader.js"></script>
|
||||
@@ -231,6 +242,7 @@
|
||||
<script src="js/settings/settings.js"></script>
|
||||
|
||||
<script src="js/reboot.js"></script>
|
||||
<script src="js/syslog.js"></script>
|
||||
<script src="js/login.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
const settingssection = document.querySelector('.settingssection')
|
||||
const settingsbutton = document.querySelector('#settingsbutton')
|
||||
const syslogsection = document.querySelector('.syslogsection')
|
||||
const syslogbutton = document.querySelector('#syslogbutton')
|
||||
|
||||
settingsbutton.addEventListener('click', () => {
|
||||
settingssection.classList.add('active')
|
||||
syslogsection.classList.remove('active')
|
||||
})
|
||||
|
||||
syslogbutton.addEventListener('click', () => {
|
||||
syslogsection.classList.add('active')
|
||||
settingssection.classList.remove('active')
|
||||
get_syslog_data()
|
||||
})
|
||||
@@ -28,7 +28,8 @@ const routes = {
|
||||
ftp_status: () => [host, prefix, 'settings', 'ftp', 'get'].join('/'),
|
||||
ftp_status_set: () => [host, prefix, 'settings', 'ftp', 'set'].join('/'),
|
||||
|
||||
reboot: () => [host, prefix, 'reboot'].join('/')
|
||||
reboot: () => [host, prefix, 'reboot'].join('/'),
|
||||
syslog: () => [host, prefix, 'syslog'].join('/'),
|
||||
// all_users: () => [host, prefix, 'users', 'all'].join('/'),
|
||||
// access: () => [host, prefix, 'access'].join('/'),
|
||||
// adduser: () => [host, prefix, 'users', 'add'].join('/'),
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
const syslogdata = document.querySelector('.syslogdata')
|
||||
|
||||
const get_syslog_data = () => {
|
||||
console.log("get_syslog_data")
|
||||
fetch(routes.syslog(), {
|
||||
method: 'GET',
|
||||
// body: `{"token":"${localStorage.getItem("token")}"}`
|
||||
}).then(data => data.text()).then(textdata => {
|
||||
syslogdata.innerHTML = textdata.replace('/\n/g','<br>')
|
||||
}).catch((error) => {
|
||||
notification(`Ошибка на сервере: ${error}`, "error")
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user