Created
April 17, 2026 20:30
-
-
Save meoyawn/d16fdfa7e424ab4d8b05462c176fca92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bun | |
| const timeoutMs = 5_000; | |
| const sources = ["https://ipv4.icanhazip.com", "https://2ip.ru"] as const; | |
| const results = await Promise.all( | |
| sources.map((url) => | |
| fetch(url, { | |
| headers: { "User-Agent": "curl/8.0.0" }, | |
| signal: AbortSignal.timeout(timeoutMs), | |
| }).then(async (res) => { | |
| if (!res.ok) { | |
| throw new Error( | |
| `${new URL(url).host} responded with HTTP ${res.status}`, | |
| ); | |
| } | |
| return [url, await res.text()] as const; | |
| }), | |
| ), | |
| ); | |
| for (const [url, body] of results) { | |
| console.log(`${new URL(url).host.padEnd(20)} ${body.trim()}`); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment