diff --git a/check_config/indBXSXX_config.php b/check_config/indBXSXX_config.php index a9dde26..ff31949 100755 --- a/check_config/indBXSXX_config.php +++ b/check_config/indBXSXX_config.php @@ -3,7 +3,7 @@ define('SHOW_SITE_IP', '' ); define('BLACKLIST_GROUP_ID', 0 ); define('WHITELIST_GROUP_ID', 0 ); - define('SHOW_SITE_COUNTRY', 'BR' ); + define('SHOW_SITE_COUNTRY', '' ); define('CLOAK_SHOW_CONTENT', '302'); define('DB_FP', array ( 0 => 'https://www.google.com/', @@ -19,12 +19,12 @@ define('SHOW_SITE_MOBILE', 0 ); define('SHOW_SITE_OUTPUT', 1 ); define('WRITE_LOG', 1 ); - define('CLOAK_ZH_ON', 'OFF'); + define('CLOAK_ZH_ON', 'ON'); define('CLOAK_OS_ON', 'OFF'); define('KEEP_PARAMS', 'OFF'); define('CLOAK_REDIRECT_METHOD', 'curl'); define('DB_ZP', 'https://worldhomenest.store'); - define('CLOAK_MOBILE_ON', 'ON'); + define('CLOAK_MOBILE_ON', 'OFF'); define('CLOAK_V_REFERER', 'OFF'); define('CLOAK_RISK_NUMBER', '68'); define('CLOAK_RISK_ENHANCED', 'ON'); diff --git a/ip_check.php b/ip_check.php index aa939c8..191d17f 100755 --- a/ip_check.php +++ b/ip_check.php @@ -73,13 +73,13 @@ if (!function_exists('cloak_dbg_record')) { //$end_time = date("H:i:s"); //echo "".$begin_time .' | '. $end_time."
"; - if( WRITE_LOG == "1") - { - $c_ip = $_SESSION["gcu_ip"]?$_SESSION["gcu_ip"]:$_SERVER['REMOTE_ADDR']; - $fp=fopen(dirname(__FILE__)."/jump.txt","a+"); - fwrite($fp,date("Y-m-d H:i:s").' | 来源判断 | ' . $reason . "|" . $_SESSION["check_result"].' | '.$config_name.' | '.$c_ip.' | '. get_SERVER_value('HTTP_REFERER') ."\n"); - fclose($fp); - } +// if( WRITE_LOG == "1") +// { +// $c_ip = $_SESSION["gcu_ip"]?$_SESSION["gcu_ip"]:$_SERVER['REMOTE_ADDR']; +// $fp=fopen(dirname(__FILE__)."/jump.txt","a+"); +// fwrite($fp,date("Y-m-d H:i:s").' | 来源判断 | ' . $reason . "|" . $_SESSION["check_result"].' | '.$config_name.' | '.$c_ip.' | '. get_SERVER_value('HTTP_REFERER') ."\n"); +// fclose($fp); +// } // get devices require_once dirname(__FILE__) . '/Mobile-Detect/src/MobileDetect.php'; diff --git a/jump.txt b/jump.txt index be8efa3..28ed6ca 100755 --- a/jump.txt +++ b/jump.txt @@ -121,3 +121,12 @@ 2026-06-16 03:17:42 | 写入数据库 | false | indBXSXX_test | async=1 2026-06-16 03:21:38 | 来源判断 | 无法识别访客国家|false | index | 0.0.0.0 | 2026-06-16 03:21:38 | 写入数据库 | false | indBXSXX_test | async=1 +2026-06-20 10:10:20 | 来源判断 | 判定拒绝(安全页)|false | indBXSXX | 127.0.0.1 | +2026-06-20 10:10:20 | 写入数据库 | false | indBXSXX | async=1 +2026-06-20 10:33:43 | 来源判断 | 判定拒绝(安全页)|false | indBXSXX | 127.0.0.1 | +2026-06-20 10:33:43 | 写入数据库 | false | indBXSXX | async=1 +2026-06-20 10:34:34 | 来源判断 | 无法识别访客国家|false | indBXSXX | 127.0.0.1 | +2026-06-20 10:34:34 | 写入数据库 | false | indBXSXX | async=1 +2026-06-20 10:45:40 | 写入数据库 | false | indBXSXX | async=1 +2026-06-20 10:46:58 | 写入数据库 | false | indBXSXX | async=1 +2026-06-20 10:47:37 | 写入数据库 | false | indBXSXX | async=1 diff --git a/lib/Cloak/Pipeline/stages/check_country_geoip.inc.php b/lib/Cloak/Pipeline/stages/check_country_geoip.inc.php index 381dd27..8482bcc 100755 --- a/lib/Cloak/Pipeline/stages/check_country_geoip.inc.php +++ b/lib/Cloak/Pipeline/stages/check_country_geoip.inc.php @@ -39,15 +39,24 @@ if ($countryCode !== null && $countryCode !== '') { } $allowlist = CountryAllowlist::parse(defined('SHOW_SITE_COUNTRY') ? SHOW_SITE_COUNTRY : ''); + +// MaxMind 查不到有效国家:跳过本地判定,继续走 byApi(已传 country_code 作兜底) +if ($countryCode === null || $countryCode === '') { + if (!empty($GLOBALS['__cloak_debug_on'])) { + cloak_dbg_step(__LINE__, 'GeoIP国家判定', 'skip', 'MaxMind 未识别国家,跳过本地判定,交由 byApi 兜底', [ + 'ip' => $ip, + 'allowlist' => $allowlist, + 'geo_source' => $geoSource, + ]); + } + return; +} + if (!CountryAllowlist::isAllowed($countryCode, $allowlist)) { $_SESSION['check_result'] = 'false'; - if ($countryCode === null || $countryCode === '') { - $reason = '无法识别访客国家'; - } else { - $reason = '国家不符:访客 ' . $countryCode; - if ($allowlist !== []) { - $reason .= ',允许 ' . implode(',', $allowlist); - } + $reason = '国家不符:访客 ' . $countryCode; + if ($allowlist !== []) { + $reason .= ',允许 ' . implode(',', $allowlist); } if (!empty($GLOBALS['__cloak_debug_on'])) { cloak_dbg_step(__LINE__, 'GeoIP国家判定', 'fail', $reason, [ diff --git a/lib/Cloak/Pipeline/stages/check_url_args_timeout.inc.php b/lib/Cloak/Pipeline/stages/check_url_args_timeout.inc.php index 45b4e8f..0c958a0 100755 --- a/lib/Cloak/Pipeline/stages/check_url_args_timeout.inc.php +++ b/lib/Cloak/Pipeline/stages/check_url_args_timeout.inc.php @@ -1,8 +1,13 @@ 0) { if ($__cloak_debug_on) { cloak_dbg_step(__LINE__,'临时链接参数', 'info', 'CLOAK_URL_ARGS_TIMEOUT=' . CLOAK_URL_ARGS_TIMEOUT . ' 分钟,开始检查'); diff --git a/lib/Cloak/VisitorInfo.php b/lib/Cloak/VisitorInfo.php index 51377e8..877225c 100755 --- a/lib/Cloak/VisitorInfo.php +++ b/lib/Cloak/VisitorInfo.php @@ -75,6 +75,7 @@ class visitorInfo $this->check_result = !empty($return['result']) ? "true" : "false"; if ($this->v_country === '' && !empty($return['country'])) { $this->v_country = (string) $return['country']; + $_SESSION['gcu_country'] = $this->v_country; } $this->v_reason = cloak_api_reason($return, $this->check_result); return $return; diff --git a/tools/verify_country_allowlist.php b/tools/verify_country_allowlist.php index 22f2ff8..ab1ad1b 100644 --- a/tools/verify_country_allowlist.php +++ b/tools/verify_country_allowlist.php @@ -34,6 +34,12 @@ $tests['resolved_config'] = CountryAllowlist::formatForConfig('us,gb') === Count $stage = file_get_contents($root . '/lib/Cloak/Pipeline/stages/check_country_geoip.inc.php'); $tests['stage_skips_when_disabled'] = strpos($stage, 'CountryAllowlist::isEnabled()') !== false; +$tests['stage_defers_unresolved_to_byapi'] = strpos($stage, '交由 byApi 兜底') !== false + && strpos($stage, '无法识别访客国家') === false; +$tests['visitor_info_syncs_api_country_session'] = strpos( + file_get_contents($root . '/lib/Cloak/VisitorInfo.php'), + "\$_SESSION['gcu_country'] = \$this->v_country;" +) !== false; $pipeline = file_get_contents($root . '/lib/Cloak/Pipeline/CheckPipeline.php'); $tests['pipeline_conditional_geo'] = strpos($pipeline, 'CountryAllowlist::isEnabled()') !== false;