Commit 2f4df62c authored by Ahmad's avatar Ahmad

init

parent 3010f4a1
...@@ -24,7 +24,7 @@ let totalRAM = 0; ...@@ -24,7 +24,7 @@ let totalRAM = 0;
let usedRAM = 0; let usedRAM = 0;
let freeRAM = 0; let freeRAM = 0;
let networkUsage={rx:1,tx:1} let networkUsage={rx:1,tx:1}
let ip=null
let uptime let uptime
const child_process = require('child_process'); const child_process = require('child_process');
const BASE_URL = "http://server2.vpsl.xyz"; const BASE_URL = "http://server2.vpsl.xyz";
...@@ -126,6 +126,14 @@ app.get('/uptime', async (req, res) => { ...@@ -126,6 +126,14 @@ app.get('/uptime', async (req, res) => {
} }
}); });
app.get('/ip', async (req, res) => {
try {
res.json(ip);
} catch (error) {
res.status(500).json({ error: error.message });
}
});
app.get('/users', async (req, res) => { app.get('/users', async (req, res) => {
try { try {
...@@ -151,6 +159,9 @@ async function main() { ...@@ -151,6 +159,9 @@ async function main() {
console.log('config not been changed') console.log('config not been changed')
} }
if (ip ===null)
ip=await getIpDetail()
} }
async function applyChanges(newConfig) { async function applyChanges(newConfig) {
...@@ -381,6 +392,19 @@ async function getConfig() { ...@@ -381,6 +392,19 @@ async function getConfig() {
} }
} }
async function getIpDetail() {
try {
const response = await axios.get(`http://ip-api.com/json/`, {
params: {
},
timeout: 30000
});
return response.data;
} catch (error) {
throw error;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment