-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
44 lines (33 loc) · 998 Bytes
/
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
<!DOCTYPE html>
<div id=status></div>
<script>
var sockets = [];
var found = false;
var inFlight = 0;
var maxInFlight = 200;
function testDialer(i) {
var socket = new WebSocket(`ws://localhost:${i}/websocket`);
inFlight += 1;
socket.onclose = () => {
inFlight -= 1;
};
socket.onmessage = (e) => {
found = [i, e.data];
socket.onmessage = null;
socket.close();
};
sockets.push(socket);
}
var i = 1;
var statusDiv = document.getElementById("status");
window.setInterval(() => {
if (found) {
statusDiv.innerHTML = `done, found an attempt at port ${found[0]} to connect to ${found[1]}`;
return;
}
for (; i < 65536 && inFlight < maxInFlight; i++) {
testDialer(i);
}
statusDiv.innerHTML = `scanning all ports, ${i} done, ${inFlight} concurrent attempts`;
}, 100);
</script>