syslog added
This commit is contained in:
1 parent
5fbd56ef7a
commit
69f4c2e1ea
12 files changed
+225
-107
No files matched your search
@@ -23,4 +23,6 @@ add_executable(
|
|||||||
src/settings/ftp/ftp.cpp
|
src/settings/ftp/ftp.cpp
|
||||||
|
|
||||||
src/reboot/reboot.cpp
|
src/reboot/reboot.cpp
|
||||||
|
|
||||||
|
src/syslog/syslog.cpp
|
||||||
)
|
)
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "settings/dns/dns.hpp"
|
#include "settings/dns/dns.hpp"
|
||||||
#include "settings/ftp/ftp.hpp"
|
#include "settings/ftp/ftp.hpp"
|
||||||
#include "reboot/reboot.hpp"
|
#include "reboot/reboot.hpp"
|
||||||
|
#include "syslog/syslog.hpp"
|
||||||
|
|
||||||
#define CORS_ENABLE
|
#define CORS_ENABLE
|
||||||
#include "security/cors.hpp"
|
#include "security/cors.hpp"
|
||||||
@@ -37,6 +38,8 @@ int main() {
|
|||||||
|
|
||||||
srv.Post("/api/reboot", reboot);
|
srv.Post("/api/reboot", reboot);
|
||||||
|
|
||||||
|
srv.Get("/api/syslog", syslog);
|
||||||
|
|
||||||
srv.Options("/(.*)", set_cors_headers);
|
srv.Options("/(.*)", set_cors_headers);
|
||||||
|
|
||||||
srv.set_mount_point("/" , "../src/web");
|
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 JWT_SECRET_KEY "secret"
|
||||||
#define STRING403 R"({"status":"403"})"
|
#define STRING403 R"({"status":"403"})"
|
||||||
#define JSON_TYPE "application/json"
|
#define JSON_TYPE "application/json"
|
||||||
|
#define PLAIN_TEXT_TYPE "text/plain"
|
||||||
|
|
||||||
#endif // TYPES_H
|
#endif // TYPES_H
|
||||||
@@ -14,6 +14,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.adminpanel {
|
.adminpanel {
|
||||||
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
transform: scale(0.5);
|
transform: scale(0.5);
|
||||||
@@ -25,3 +26,7 @@ body {
|
|||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
@@ -66,10 +66,23 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.settingssection {
|
.settingssection {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
/* flex-direction: column; */
|
/* flex-direction: column; */
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
|
transition: 0.3s;
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settingssection.active {
|
||||||
|
opacity: 1;
|
||||||
|
pointer-events: all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settingrect {
|
.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/header.css">
|
||||||
<link rel="stylesheet" href="css/button.css">
|
<link rel="stylesheet" href="css/button.css">
|
||||||
<link rel="stylesheet" href="css/loader.css">
|
<link rel="stylesheet" href="css/loader.css">
|
||||||
|
<link rel="stylesheet" href="css/syslog.css">
|
||||||
<title>Openrouter Admin</title>
|
<title>Openrouter Admin</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -17,7 +18,8 @@
|
|||||||
<!-- header -->
|
<!-- header -->
|
||||||
<header class="header">
|
<header class="header">
|
||||||
<div class="links">
|
<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>
|
<button class="linkbutton" id="rebootbutton">Reboot</button>
|
||||||
</div>
|
</div>
|
||||||
<h1>Openrouter Admin</h1>
|
<h1>Openrouter Admin</h1>
|
||||||
@@ -28,120 +30,128 @@
|
|||||||
</header>
|
</header>
|
||||||
<!-- header -->
|
<!-- header -->
|
||||||
<!-- settings block -->
|
<!-- settings block -->
|
||||||
<section class="settingssection">
|
<div class="section">
|
||||||
<!-- telnet settings -->
|
<section class="settingssection">
|
||||||
<div class="settingrect">
|
<!-- telnet settings -->
|
||||||
<div class="settingrectheader">
|
<div class="settingrect">
|
||||||
<h2>Telnet</h2>
|
<div class="settingrectheader">
|
||||||
<div class="checkbox-wrapper-2">
|
<h2>Telnet</h2>
|
||||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="telnetenable">
|
<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>
|
</div>
|
||||||
<div class="settingrectbody telnetsettingbody">
|
<!-- telnet settings -->
|
||||||
<div style="display:flex;align-items:center;justify-content:space-between;">
|
<!-- DNS settings -->
|
||||||
<label for="telnetportinput" class="forminputlabel">Port</label>
|
<div class="settingrect">
|
||||||
<input type="text" id="telnetportinput" class="forminput">
|
<div class="settingrectheader">
|
||||||
|
<h2>DNS</h2>
|
||||||
|
<div class="checkbox-wrapper-2">
|
||||||
|
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="dnsenable">
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table class="telnetuserstable">
|
<div class="settingrectbody" id="dnssettingsbody">
|
||||||
<thead>
|
<table class="dnsservers">
|
||||||
<tr>
|
<thead>
|
||||||
<th>username</th>
|
<tr><th>DNS servers</th></tr>
|
||||||
<th>password</th>
|
</thead>
|
||||||
</tr>
|
<tbody id="dnsserverstablebody">
|
||||||
</thead>
|
</tbody>
|
||||||
<tbody>
|
</table>
|
||||||
<tr><th>No users</th></tr>
|
<h3>Domains Table</h3>
|
||||||
<!-- <tr>
|
<table class="domains">
|
||||||
<th>root</th>
|
<thead>
|
||||||
<th>2808</th>
|
<tr>
|
||||||
</tr> -->
|
<th class="three">IP</th>
|
||||||
</tbody>
|
<th class="three">Domain</th>
|
||||||
</table>
|
<!-- <th class="three">Del</th> -->
|
||||||
</div>
|
</tr>
|
||||||
<div class="settingrectfooter">
|
</thead>
|
||||||
<button class="settingrectfooterbutton hiddenbutton" id="add_telnet_user_button">Add telnet user</button>
|
<tbody id="domainsstablebody">
|
||||||
<button class="settingrectfooterbutton" id="set_telnet_settings">Confirm</button>
|
</tbody>
|
||||||
</div>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<!-- telnet settings -->
|
<div class="settingrectfooter">
|
||||||
<!-- DNS settings -->
|
<button id="add_local_domain_button" class="hiddenbutton settingrectfooterbutton">Add Local Domain</button>
|
||||||
<div class="settingrect">
|
<button id="add_dns_server_button" class="hiddenbutton settingrectfooterbutton">Add DNS server</button>
|
||||||
<div class="settingrectheader">
|
<button class="settingrectfooterbutton" id="set_dns_settings">Confirm</button>
|
||||||
<h2>DNS</h2>
|
|
||||||
<div class="checkbox-wrapper-2">
|
|
||||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="dnsenable">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="settingrectbody" id="dnssettingsbody">
|
<!-- DNS settings -->
|
||||||
<table class="dnsservers">
|
<!-- ftp settings -->
|
||||||
<thead>
|
<div class="settingrect">
|
||||||
<tr><th>DNS servers</th></tr>
|
<div class="settingrectheader">
|
||||||
</thead>
|
<h2>Ftp</h2>
|
||||||
<tbody id="dnsserverstablebody">
|
<div class="checkbox-wrapper-2">
|
||||||
</tbody>
|
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="ftpenable">
|
||||||
</table>
|
</div>
|
||||||
<h3>Domains Table</h3>
|
</div>
|
||||||
<table class="domains">
|
<div class="settingrectfooter">
|
||||||
<thead>
|
<!-- <button>Add Ftp server</button> -->
|
||||||
<tr>
|
<button class="settingrectfooterbutton" id="set_ftp_settings">Confirm</button>
|
||||||
<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">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="settingrectfooter">
|
<!-- ftp settings -->
|
||||||
<!-- <button>Add Ftp server</button> -->
|
<!-- ssh settings -->
|
||||||
<button class="settingrectfooterbutton" id="set_ftp_settings">Confirm</button>
|
<div class="settingrect">
|
||||||
</div>
|
<div class="settingrectheader">
|
||||||
</div>
|
<h2>SSH</h2>
|
||||||
<!-- ftp settings -->
|
<div class="checkbox-wrapper-2">
|
||||||
<!-- ssh settings -->
|
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="sshenable">
|
||||||
<div class="settingrect">
|
</div>
|
||||||
<div class="settingrectheader">
|
</div>
|
||||||
<h2>SSH</h2>
|
<div class="settingrectbody" id="sshsettingsbody">
|
||||||
<div class="checkbox-wrapper-2">
|
<div style="display:flex;align-items:center;justify-content:space-between;">
|
||||||
<input type="checkbox" class="sc-gJwTLC ikxBAC" id="sshenable">
|
<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>
|
</div>
|
||||||
<div class="settingrectbody" id="sshsettingsbody">
|
<!-- ssh settings -->
|
||||||
<div style="display:flex;align-items:center;justify-content:space-between;">
|
</section>
|
||||||
<label for="sshportinput" class="forminputlabel">Port</label>
|
<!-- syslog block -->
|
||||||
<input type="text" id="sshportinput" class="forminput">
|
<section class="syslogsection">
|
||||||
</div>
|
<h2 class="syslogheader">Syslog</h2>
|
||||||
<table class="sshkeys">
|
<div class="syslogdata"></div>
|
||||||
<thead>
|
</section>
|
||||||
<tr><th>SSH keys</th></tr>
|
<!-- syslog block -->
|
||||||
</thead>
|
</div>
|
||||||
<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>
|
|
||||||
<!-- settings block -->
|
<!-- settings block -->
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -219,6 +229,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- loader -->
|
<!-- loader -->
|
||||||
|
<script src="js/header.js"></script>
|
||||||
<script src="js/routes.js"></script>
|
<script src="js/routes.js"></script>
|
||||||
<script src="js/notification.js"></script>
|
<script src="js/notification.js"></script>
|
||||||
<script src="js/loader.js"></script>
|
<script src="js/loader.js"></script>
|
||||||
@@ -231,6 +242,7 @@
|
|||||||
<script src="js/settings/settings.js"></script>
|
<script src="js/settings/settings.js"></script>
|
||||||
|
|
||||||
<script src="js/reboot.js"></script>
|
<script src="js/reboot.js"></script>
|
||||||
|
<script src="js/syslog.js"></script>
|
||||||
<script src="js/login.js"></script>
|
<script src="js/login.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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: () => [host, prefix, 'settings', 'ftp', 'get'].join('/'),
|
||||||
ftp_status_set: () => [host, prefix, 'settings', 'ftp', 'set'].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('/'),
|
// all_users: () => [host, prefix, 'users', 'all'].join('/'),
|
||||||
// access: () => [host, prefix, 'access'].join('/'),
|
// access: () => [host, prefix, 'access'].join('/'),
|
||||||
// adduser: () => [host, prefix, 'users', 'add'].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