Merge pull request #3129 from InDieTasten/fix-unique-ip-generation

Fix unique ip generation
This commit is contained in:
hydroflame 2022-03-16 14:53:34 -04:00 committed by GitHub
commit 9a385dad34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -78,12 +78,11 @@ export function ipExists(ip: string): boolean {
} }
export function createUniqueRandomIp(): string { export function createUniqueRandomIp(): string {
const ip = createRandomIp(); let ip: string;
// Repeat generating ip, until unique one is found
// If the Ip already exists, recurse to create a new one do {
if (ipExists(ip)) { ip = createRandomIp();
return createRandomIp(); } while (ipExists(ip));
}
return ip; return ip;
} }