install: allow region select via env var

pull/675/head
undefined 11 months ago
parent 65a503b3bd
commit bc19a3ca5a
No known key found for this signature in database

@ -582,11 +582,15 @@ ${nixConfBase}`);
async function main() { async function main() {
try { try {
console.log('Getting IP info to find best mirror:'); if (process.env.REGION) {
const res = await fetch('https://ipinfo.io', { headers: { accept: 'application/json' } }).then((r) => r.json()); if (process.env.REGION !== 'CN') CN = false;
delete res.readme; } else {
console.log(res); console.log('Getting IP info to find best mirror:');
if (res.country !== 'CN') CN = false; const res = await fetch('https://ipinfo.io', { headers: { accept: 'application/json' } }).then((r) => r.json());
delete res.readme;
console.log(res);
if (res.country !== 'CN') CN = false;
}
} catch (e) { } catch (e) {
console.error(e); console.error(e);
console.log('Cannot find the best mirror. Fallback to default.'); console.log('Cannot find the best mirror. Fallback to default.');

Loading…
Cancel
Save