diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 623d50fac..228d1197b 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -1167,6 +1167,10 @@ export const ns: InternalAPI = { helpers.log(ctx, () => `Invalid argument: hostname='${hostnameStr}'`); return ""; } + if (hostnameStr.startsWith("hacknet-node-") || hostnameStr.startsWith("hacknet-server-")) { + helpers.log(ctx, () => `Invalid argument: hostname='${hostnameStr}' is a reserved hostname.`); + return ""; + } if (Player.purchasedServers.length >= getPurchaseServerLimit()) { helpers.log( diff --git a/src/Server/ServerPurchases.ts b/src/Server/ServerPurchases.ts index b25114f32..7f0b8e8e6 100644 --- a/src/Server/ServerPurchases.ts +++ b/src/Server/ServerPurchases.ts @@ -65,6 +65,9 @@ export const renamePurchasedServer = (hostname: string, newName: string): void = if (!server) throw new Error(`Server '${hostname}' doesn't exists.`); if (GetServer(newName)) throw new Error(`Server '${newName}' already exists.`); if (!Player.purchasedServers.includes(hostname)) throw new Error(`Server '${hostname}' is not a player server.`); + if (newName.startsWith("hacknet-node-") || newName.startsWith("hacknet-server-")) { + throw new Error(`'${newName}' is a reserved hostname.`); + } const replace = (arr: string[], old: string, next: string): string[] => { return arr.map((v) => (v === old ? next : v)); }; @@ -122,6 +125,11 @@ export function purchaseServer(hostname: string, ram: number, cost: number): voi return; } + if (hostname.startsWith("hacknet-node-") || hostname.startsWith("hacknet-server-")) { + dialogBoxCreate(`'${hostname}' is a reserved hostname, please try again.`); + return; + } + // Create server const newServ = safelyCreateUniqueServer({ adminRights: true,