(p, ip, signal)
| 96 | |
| 97 | // Query a single provider, throw unless it yields a usable result |
| 98 | const tryProvider = async (p, ip, signal) => { |
| 99 | const parsed = p.parse(await getJson(p.url(ip), signal)); |
| 100 | if (!parsed?.country_code) throw new Error('no usable data'); |
| 101 | log.debug(`${p.name} resolved ${ip} to ${parsed.country_code}`); |
| 102 | return parsed; |
| 103 | }; |
| 104 | |
| 105 | // Race all providers, first successful result wins, abort the rest |
| 106 | const lookupGeo = async (ip) => { |