-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReducer.js
More file actions
46 lines (40 loc) · 1.09 KB
/
Reducer.js
File metadata and controls
46 lines (40 loc) · 1.09 KB
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
import { Writable } from "stream"
//import { ScanData } from "./libs/typedef.js";
[
{
"ip": "",
"services": [
{
"port": 80,
"protocol": "tcp",
"service_app": [ "openssh/7.1" ]
}
],
"deviceinfo": [ "webcam/hikvision" ],
"honeypot": [ "2222/kippo" ]
}
]
class Reducer extends Writable {
constructor(options) {
super({ objectMode: true });
}
/** @type {Map<string, Set<string>>} */
result = new Map();
/** @param {ScanData} scan_data */
_write(scan_data, encoding, callback) {
try {
//console.log("Result: ", scan_data);
const host_str = `${scan_data.host_info.ip}:${scan_data.host_info.port}`;
const tags = this.result.get(host_str) || new Set();
scan_data.tags.forEach(i=> tags.add(i));
if(tags.size > 0)
this.result.set(host_str, tags);
} catch(err) {
console.log("AnalyserInner: ", err);
}
callback();
}
};
export {
Reducer
};