-
Notifications
You must be signed in to change notification settings - Fork 6
/
app.js
executable file
·39 lines (29 loc) · 1.01 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
const version = require('./version.json');
const express = require('express');
var os = require('os');
var ifaces = os.networkInterfaces();
const app = express();
app.get('/', (req, res) => {
let result = `Hello world from TopSwagCode! We are currently running version: ${version.version}` + "<br/>";
Object.keys(ifaces).forEach(function (ifname) {
var alias = 0;
ifaces[ifname].forEach(function (iface) {
if ('IPv4' !== iface.family || iface.internal !== false) {
result += ifname + ':' + alias +"," +iface.address + " COUNT: " + alias +"<br/>";
}
if (alias >= 1) {
// this single interface has multiple ipv4 addresses
result +=ifname + ':' + alias +"," + iface.address+ " COUNT: " + alias + "<br/>";
} else {
// this interface has only one ipv4 adress
result += ifname + "," + iface.address+ " COUNT: " + alias + "<br/>";
}
++alias;
});
});
res.send(result);
});
app.listen(80, () => {
console.log('Example app listening on port 80!');
});