| 346 | const units = isBytes |
| 347 | ? ["B", "KB", "MB", "GB", "TB"] |
| 348 | : ["bps", "Kbps", "Mbps", "Gbps", "Tbps"]; |
| 349 | if (!isBytes) value *= 8; |
| 350 | while (value >= power && unitIndex < units.length - 1) { |
| 351 | value /= power; |
| 352 | unitIndex++; |
| 353 | } |
| 354 | return `${Math.round(value * 100) / 100}${units[unitIndex]}`; |
| 355 | } |
| 356 | |
| 357 | async function getIpApi(ip: string) { |
| 358 | try { |
| 359 | const response = await axios.get(`http://ip-api.com/json/${ip}?fields=as,countryCode`); |
| 360 | const data = response.data; |
| 361 | const asInfo = data.as?.split(" ")[0] || ""; |
| 362 | const ccFlag = data.countryCode |
| 363 | ? String.fromCodePoint( |
| 364 | ...data.countryCode |