maxmind国家判断失效跳过
This commit is contained in:
@@ -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');
|
||||
|
||||
+7
-7
@@ -73,13 +73,13 @@ if (!function_exists('cloak_dbg_record')) {
|
||||
//$end_time = date("H:i:s");
|
||||
//echo "".$begin_time .' | '. $end_time."<br />";
|
||||
|
||||
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';
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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, [
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../../WhitelistGate.php';
|
||||
|
||||
//判断临时链接参数(Guard 之后、API/指纹 之前)
|
||||
if (!empty($GLOBALS['__cloak_simulation_on'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$whiteParamsMatched = WhitelistGate::matchesWhitelistParams();
|
||||
|
||||
if(empty($_SESSION["check_result"]) && !$whiteParamsMatched && SHOW_SITE_MODE_SWITCH == 'ip_check' && CLOAK_URL_ARGS_TIMEOUT > 0) {
|
||||
if ($__cloak_debug_on) {
|
||||
cloak_dbg_step(__LINE__,'临时链接参数', 'info', 'CLOAK_URL_ARGS_TIMEOUT=' . CLOAK_URL_ARGS_TIMEOUT . ' 分钟,开始检查');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user