30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
const { execSync } = require('child_process');
|
|
const ip = require('./utils/ip');
|
|
const { port, command } = require('./config');
|
|
|
|
const express = require('express')
|
|
const app = express()
|
|
|
|
|
|
app.get('/ip', async (req, res) => {
|
|
// let output = execSync(command, { encoding: "utf8" });
|
|
let output = `2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
|
|
inet6 240e:362:2245:9b00::68c/128 scope global dynamic noprefixroute
|
|
valid_lft 24426sec preferred_lft 24426sec
|
|
inet6 240e:362:2245:9b00:2e0:4cff:fe09:1f7f/64 scope global dynamic mngtmpaddr noprefixroute
|
|
valid_lft 222142sec preferred_lft 135742sec
|
|
inet6 240e:362:223c:2800:2e0:4cff:fe09:1f7f/64 scope global dynamic mngtmpaddr noprefixroute
|
|
valid_lft 221829sec preferred_lft 135429sec
|
|
inet6 fe80::2e0:4cff:fe09:1f7f/64 scope link
|
|
valid_lft forever preferred_lft forever`
|
|
res.json(await ip.parseNetworkInfo(output))
|
|
})
|
|
|
|
app.listen(port, () => {
|
|
console.log(`app listening on port: http://127.0.0.1:${port}`)
|
|
})
|
|
|
|
|
|
|
|
|