-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
66 lines (62 loc) · 1.99 KB
/
index.html
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html>
<head>
<title>NodeJs Network Monitor</title>
<link rel="stylesheet" type="text/css" href="/style.css" />
<link
href="https://fonts.googleapis.com/css2?family=Syne+Mono&display=swap"
rel="stylesheet"
/>
<link rel="icon" href="/logo copy.png" />
</head>
<body>
<header>
<div class="container">
<h1>Nodejs Network Monitor</h1>
<button onclick="viewPackets();">View Packets</button>
<button onclick="viewWiFi();">View WiFi</button>
</div>
</header>
<div class="container">
<h2>New Local Network Device Alerts</h2>
<ul id="new-local-devices"></ul>
<h2>All Local Network Devices</h2>
<ul id="all-local-devices"></ul>
</div>
<script src="/socket.io/socket.io.js"></script>
<script>
function viewPackets() {
window.location.href = "/packets";
}
function viewWiFi() {
window.location.href = "/wifi";
}
const socket = io();
socket.emit("startLocalNetworkMonitoring");
socket.on("allLocalDevices", (allDevices) => {
const list = document.getElementById("all-local-devices");
list.innerHTML = "";
allDevices.forEach((device) => {
const item = document.createElement("li");
item.textContent = `IP: ${device.ip}, MAC: ${device.mac}`;
list.appendChild(item);
});
});
socket.on("newLocalDeviceAlert", (newDevices) => {
const list = document.getElementById("new-local-devices");
list.innerHTML = "";
if (newDevices.length === 0) {
const item = document.createElement("li");
item.textContent = "No new devices";
list.appendChild(item);
} else {
newDevices.forEach((device) => {
const item = document.createElement("li");
item.textContent = `IP: ${device.ip}, MAC: ${device.mac}`;
list.appendChild(item);
});
}
});
</script>
</body>
</html>