bitnode1
This commit is contained in:
@@ -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');
|
||||
}
|
||||
Reference in New Issue
Block a user