This commit is contained in:
2023-08-29 03:50:21 +02:00
parent af84e9b05f
commit 673abd49b2
9 changed files with 133 additions and 130 deletions
+31
View File
@@ -0,0 +1,31 @@
/** @param {import(".").NS } ns */
import { EXCLUDE_SERVERS } from "./constants.js";
export async function main(ns) {
ns.disableLog('ALL');
/**
* Recursively kill simple-hack.js running on servers in the network
* @async
* @param {string} currentServer server to scan
*/
function scanServer(currentServer, previousServer = currentServer, connectString = '', scanLevel = 0) {
let availableServers = ns.scan(currentServer);
let nextConnectString = connectString + `connect ${currentServer}; `;
ns.tprint(`${'┃ '.repeat(scanLevel)}${currentServer}: ${nextConnectString}`);
ns.write('scan.txt', `${'┃ '.repeat(scanLevel)}┣━${currentServer}: ${nextConnectString}`+'\n', 'a');
for (let i = 0; i < availableServers.length; ++i) {
let nextServer = availableServers[i];
if (nextServer != currentServer && nextServer != previousServer) {
scanServer(nextServer, currentServer, nextConnectString, scanLevel+1);
}
}
}
ns.tprint(`Running scan`);
ns.write('scan.txt', ``, 'w');
scanServer('home');
}