diff --git a/src/Server/AllServers.ts b/src/Server/AllServers.ts index baf2d6ac0..42a8b6150 100644 --- a/src/Server/AllServers.ts +++ b/src/Server/AllServers.ts @@ -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; }