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
"ips" => [
"terms" => [
"field" => "clientip.keyword",
"size" => 200,
"size" => 50,
"order" => [
"_count" => "desc"
]
......@@ -64,25 +64,32 @@ class IpExceptionController extends Controller
if (empty($buckets)) {
return false;
}
$redis_ticker = \Yii::$app->redis_es;
$limit = \Yii::$app->params['api_ip_limit']['limit'];
$white_list = \Yii::$app->params['api_ip_limit']['white_list'];
$ips = '';
foreach ($buckets as $key => $val) {
if (in_array($val['key'], $white_list)) continue;
if ($val['doc_count'] > $limit){
foreach ($val['request']['buckets'] as $bucket) {
$redis_ticker->hmset($val['key'], $bucket['key'], $bucket['doc_count']);
if (!isset($val['request']['buckets'])) continue;
foreach ($val['request']['buckets'] as $b => $item) {
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);
if (!empty($ips)){
$file = fopen("/data_wallet/static/wallet_interface_ip_limit.txt","w");
if (!empty($ips)) {
$file = fopen("/data_wallet/static/wallet_interface_ip_limit.txt", "w");
$ip_arr = explode(',', $ips);
foreach ($ip_arr as $key => $ip){
fwrite($file,$ip."\n");
foreach ($ip_arr as $key => $ip) {
fwrite($file, $ip . "\n");
}
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