This commit is contained in:
Madeline
2022-09-26 22:41:21 +10:00
parent fcc0884e36
commit 99ee7e9400
280 changed files with 6800 additions and 3908 deletions
+8 -3
View File
@@ -3,7 +3,9 @@ import { distanceBetweenLocations, IPAnalysis } from "../utility/ipAddress";
export async function getVoiceRegions(ipAddress: string, vip: boolean) {
const regions = Config.get().regions;
const availableRegions = regions.available.filter((ar) => (vip ? true : !ar.vip));
const availableRegions = regions.available.filter((ar) =>
vip ? true : !ar.vip,
);
let optimalId = regions.default;
if (!regions.useDefaultAsOptimal) {
@@ -13,7 +15,10 @@ export async function getVoiceRegions(ipAddress: string, vip: boolean) {
for (let ar of availableRegions) {
//TODO the endpoint location should be saved in the database if not already present to prevent IPAnalysis call
const dist = distanceBetweenLocations(clientIpAnalysis, ar.location || (await IPAnalysis(ar.endpoint)));
const dist = distanceBetweenLocations(
clientIpAnalysis,
ar.location || (await IPAnalysis(ar.endpoint)),
);
if (dist < min) {
min = dist;
@@ -27,6 +32,6 @@ export async function getVoiceRegions(ipAddress: string, vip: boolean) {
name: ar.name,
custom: ar.custom,
deprecated: ar.deprecated,
optimal: ar.id === optimalId
optimal: ar.id === optimalId,
}));
}