-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathomniScript-host.js
More file actions
38 lines (32 loc) · 948 Bytes
/
Copy pathomniScript-host.js
File metadata and controls
38 lines (32 loc) · 948 Bytes
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
export async function main(ns) {
function multiScan(hostname, prev, depth) {
var node = {
name: hostname,
children: []
};
var scans = ns.scan(hostname);
if (depth > 0) {
for (var i = 0; i < scans.length; i++) {
if (scans[i] == prev) {
continue;
}
node.children.push(multiScan(scans[i], hostname, depth - 1));
}
}
return node;
}
var start = ns.args[1] || "home";
var depth = ns.args[0] || 1;
var scans = multiScan(start, null, depth);
function display(node, depth) {
var line = "";
for (var i = 0; i < depth; i++) {
line += " ";
}
line += node.name;
ns.tprint(line);
for (var i = 0; i < node.children.length; i++)
display(node.children[i], depth + 1);
}
display(scans, 0);
}