This commit is contained in:
Xargana 2025-03-29 13:35:11 +03:00
parent 550a6f6c3f
commit 6d5bd3e507
2 changed files with 48 additions and 24 deletions

View file

@ -1,14 +1,9 @@
const express = require("express");
const cors = require("cors");
const fs = require("fs");
const https = require("https");
const path = require("path");
const ping = require("ping");
const app = express();
const PORT = 2589;
const key = "/etc/letsencrypt/live/blahaj.tr/privkey.pem"
const cert = "/etc/letsencrypt/live/blahaj.tr/fullchain.pem"
const router = express.Router();
const REMOTE_SERVERS = [
{ name: "blahaj.tr", host: "blahaj.tr" },
{ name: "xargana.com", host: "xargana.com" },
@ -26,8 +21,6 @@ REMOTE_SERVERS.forEach(server => {
};
});
app.use(cors());
async function checkServers() {
for (const server of REMOTE_SERVERS) {
const startTime = Date.now();
@ -46,21 +39,8 @@ async function checkServers() {
setInterval(checkServers, CHECK_INTERVAL);
checkServers();
app.get("/status", (req, res) => {
router.get("/", (req, res) => {
res.json(serversStatus);
});
// Load SSL Certificates
const sslOptions = {
key: fs.readFileSync(key),
cert: fs.readFileSync(cert),
};
// Start HTTPS Server
try {
https.createServer(sslOptions, app).listen(PORT, () => {
console.log(`API running at https://localhost:${PORT}`);
});
} catch (e) {
console.error("Error starting server:", e);
}
module.exports = router;