Merge pull request #3431 from Undeemiss/sing-connect-backdoor

Allowed ns.singularity.connect to connect to backdoored servers directly
This commit is contained in:
hydroflame 2022-04-13 12:22:17 -04:00 committed by GitHub
commit 96d76a84ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -580,6 +580,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
throw _ctx.helper.makeRuntimeErrorMsg(`Invalid hostname: '${hostname}'`); throw _ctx.helper.makeRuntimeErrorMsg(`Invalid hostname: '${hostname}'`);
} }
//Home case
if (hostname === "home") { if (hostname === "home") {
player.getCurrentServer().isConnectedTo = false; player.getCurrentServer().isConnectedTo = false;
player.currentServer = player.getHomeComputer().hostname; player.currentServer = player.getHomeComputer().hostname;
@ -588,6 +589,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
return true; return true;
} }
//Adjacent server case
const server = player.getCurrentServer(); const server = player.getCurrentServer();
for (let i = 0; i < server.serversOnNetwork.length; i++) { for (let i = 0; i < server.serversOnNetwork.length; i++) {
const other = getServerOnNetwork(server, i); const other = getServerOnNetwork(server, i);
@ -601,6 +603,17 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
} }
} }
//Backdoor case
const other = GetServer(hostname);
if (other !== null && other instanceof Server && other.backdoorInstalled) {
player.getCurrentServer().isConnectedTo = false;
player.currentServer = target.hostname;
player.getCurrentServer().isConnectedTo = true;
Terminal.setcwd("/");
return true;
}
//Failure case
return false; return false;
}, },
manualHack: (_ctx: NetscriptContext) => manualHack: (_ctx: NetscriptContext) =>