mirror of
https://github.com/jo-inc/camofox-browser.git
synced 2026-10-02 04:14:41 +08:00
fix: bound proxy GeoIP setup
This commit is contained in:
@@ -1077,13 +1077,15 @@ function _countActiveHandles() {
|
||||
try { return process._getActiveHandles().length; } catch { return null; }
|
||||
}
|
||||
|
||||
const GEOIP_SETUP_TIMEOUT_MS = 10000;
|
||||
|
||||
function isCamoufoxGeoipError(err) {
|
||||
return /Invalid locale:|GeoLite|MaxMind|geolocation|public proxy IP address/i.test(err?.message || String(err || ''));
|
||||
return /Invalid locale:|GeoLite|MaxMind|geolocation|public proxy IP address|GeoIP setup timed out/i.test(err?.message || String(err || ''));
|
||||
}
|
||||
|
||||
async function buildLaunchOptionsWithGeoipFallback(baseOptions, attemptMeta) {
|
||||
try {
|
||||
return await launchOptions(baseOptions);
|
||||
return await withTimeout(launchOptions(baseOptions), GEOIP_SETUP_TIMEOUT_MS, 'GeoIP setup');
|
||||
} catch (err) {
|
||||
if (!baseOptions.geoip || !isCamoufoxGeoipError(err)) {
|
||||
throw err;
|
||||
|
||||
@@ -72,6 +72,8 @@ describe('launch compatibility source contract', () => {
|
||||
|
||||
expect(geoipFallback).toMatch(/GeoLite\|MaxMind\|geolocation/);
|
||||
expect(geoipFallback).toContain('public proxy IP address');
|
||||
expect(serverSource).toContain('GEOIP_SETUP_TIMEOUT_MS = 10000');
|
||||
expect(geoipFallback).toContain("withTimeout(launchOptions(baseOptions), GEOIP_SETUP_TIMEOUT_MS, 'GeoIP setup')");
|
||||
expect(geoipFallback).toContain('geoip: false');
|
||||
expect(launchBrowser).toContain('buildLaunchOptionsWithGeoipFallback');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user