mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
Merge pull request #3129 from InDieTasten/fix-unique-ip-generation
Fix unique ip generation
This commit is contained in:
commit
9a385dad34
@ -78,12 +78,11 @@ export function ipExists(ip: string): boolean {
|
||||
}
|
||||
|
||||
export function createUniqueRandomIp(): string {
|
||||
const ip = createRandomIp();
|
||||
|
||||
// If the Ip already exists, recurse to create a new one
|
||||
if (ipExists(ip)) {
|
||||
return createRandomIp();
|
||||
}
|
||||
let ip: string;
|
||||
// Repeat generating ip, until unique one is found
|
||||
do {
|
||||
ip = createRandomIp();
|
||||
} while (ipExists(ip));
|
||||
|
||||
return ip;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user