-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathdemo.html
70 lines (63 loc) · 1.95 KB
/
demo.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
67
68
69
70
<!doctype html>
<html>
<body>
<label>
<div>Hosts to scan</div>
<div>
<textarea rows=20 cols=50 id='h'>10.6.0.242
</textarea>
</div>
</label>
<button id='b' onclick='scan()'>Scan</button>
<div id='c' style='background:#000; color: #fff; font-family:monospace; padding: 5px; margin-top:0; display: none;'>
</div>
<script src='./src/utils.js'></script>
<script src='./src/db.js'></script>
<script src='./src/host_scan.js'></script>
<script src='./src/device_scan.js'></script>
<script>
function log(s) {
c.innerHTML += '<div>'+s+'</div>';
}
function scan() {
b.style.display = 'none';
c.style.display = 'block';
log('Scanning...');
lan.DeviceScan.start(h.value.trim().split(/\s+/), {
found: function(address, fingerprint) {
log("["+address+"] Found device: "+fingerprint);
},
complete: function(results) {
log("Scan complete.")
},
hostup: function(address) {
log("Host up: "+address);
},
hostdown: function(address) {
log("Host down: "+address);
}
});
// var range = function(ip, start, end) {
// var addrs = [];
// while (start <= end) addrs.push(ip+'.'+start++);
// return addrs;
// }
// var addrs = range('172.16.10', 1, 80).concat(range('172.16.10', 0, 50)).concat(range('10.6.0', 0, 255))
// new lan.HostScan(addrs, {batchSize: 1000, batchDelay: 500}).start({
// complete: function(responses, duration) {
// log('complete callback: '+duration/1000+'s');
// var results = {};
// lan.utils.each(responses, function(response) {
// results[response.state] = results[response.state] || 0;
// results[response.state]++;
// });
// log(JSON.stringify(results));
// },
// stream: function(addr, state, duration) {
// log(addr+" - " +state.toUpperCase() + "(" + duration + ")");
// }
// });
}
</script>
</body>
</html>