Commit 7ab96be9 authored by shajiaiming's avatar shajiaiming

Merge branch 'feature/es' into 'master'

fix See merge request !387
parents b184efa6 40f69c61
...@@ -19,7 +19,7 @@ class IpExceptionController extends Controller ...@@ -19,7 +19,7 @@ class IpExceptionController extends Controller
"ips" => [ "ips" => [
"terms" => [ "terms" => [
"field" => "clientip.keyword", "field" => "clientip.keyword",
"size" => 200, "size" => 50,
"order" => [ "order" => [
"_count" => "desc" "_count" => "desc"
] ]
...@@ -64,25 +64,32 @@ class IpExceptionController extends Controller ...@@ -64,25 +64,32 @@ class IpExceptionController extends Controller
if (empty($buckets)) { if (empty($buckets)) {
return false; return false;
} }
$redis_ticker = \Yii::$app->redis_es; $redis_ticker = \Yii::$app->redis_es;
$limit = \Yii::$app->params['api_ip_limit']['limit']; $limit = \Yii::$app->params['api_ip_limit']['limit'];
$white_list = \Yii::$app->params['api_ip_limit']['white_list']; $white_list = \Yii::$app->params['api_ip_limit']['white_list'];
$ips = ''; $ips = '';
foreach ($buckets as $key => $val) { foreach ($buckets as $key => $val) {
if (in_array($val['key'], $white_list)) continue; if (in_array($val['key'], $white_list)) continue;
if ($val['doc_count'] > $limit){ if (!isset($val['request']['buckets'])) continue;
foreach ($val['request']['buckets'] as $bucket) { foreach ($val['request']['buckets'] as $b => $item) {
$redis_ticker->hmset($val['key'], $bucket['key'], $bucket['doc_count']); if (strpos($item['key'],'/interface/ticker/hot-ticker') !== false) {
if ($item['doc_count'] > $limit) {
foreach ($val['request']['buckets'] as $bucket) {
$redis_ticker->hmset($val['key'], $bucket['key'], $bucket['doc_count']);
}
$ips .= $val['key'] . ',';
}
} }
$ips.= $val['key'].',';
} }
} }
$ips = substr($ips, 0, -1); $ips = substr($ips, 0, -1);
if (!empty($ips)){ if (!empty($ips)) {
$file = fopen("/data_wallet/static/wallet_interface_ip_limit.txt","w"); $file = fopen("/data_wallet/static/wallet_interface_ip_limit.txt", "w");
$ip_arr = explode(',', $ips); $ip_arr = explode(',', $ips);
foreach ($ip_arr as $key => $ip){ foreach ($ip_arr as $key => $ip) {
fwrite($file,$ip."\n"); fwrite($file, $ip . "\n");
} }
fclose($file); fclose($file);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment