-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.ts
37 lines (29 loc) · 917 Bytes
/
index.ts
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
import process from "process";
import express from "express";
import CapturePacketManager from "./capturePacket";
const app = express();
let {
networkInterfaceId = 'eth0',
removeOutdataInterval = 10000,
port = 3001,
verbose = 'false'
} = process.env;
const capturePacketManager = new CapturePacketManager(networkInterfaceId, ~~removeOutdataInterval, verbose === 'true');
app.get('/stats', (req, res)=>{
const {
log
} = req.query;
const currentUserAmount = Object.keys(capturePacketManager.statistic.activeUserList).length;
let returnData = {
currentUserAmount,
activeUserList: capturePacketManager.statistic.activeUserList,
log: <any>[]
};
if(log){
returnData.log = capturePacketManager.statistic.recentLogs;
}
return res.json(returnData);
})
app.listen(~~port, ()=>{
console.log(`server listen at port ${port}`);
})