mirror of
https://github.com/v2board/v2board.git
synced 2025-01-11 00:29:09 +08:00
feature: server push status
This commit is contained in:
parent
4e2e3cd2a0
commit
cbe5882e01
@ -20,6 +20,7 @@ class ManageController extends Controller
|
|||||||
$serverService->getV2rayServers(),
|
$serverService->getV2rayServers(),
|
||||||
$serverService->getTrojanServers()
|
$serverService->getTrojanServers()
|
||||||
);
|
);
|
||||||
|
$serverService->mergeData($servers);
|
||||||
$tmp = array_column($servers, 'sort');
|
$tmp = array_column($servers, 'sort');
|
||||||
array_multisort($tmp, SORT_ASC, $servers);
|
array_multisort($tmp, SORT_ASC, $servers);
|
||||||
return response([
|
return response([
|
||||||
|
@ -74,6 +74,7 @@ class DeepbworkController extends Controller
|
|||||||
$data = file_get_contents('php://input');
|
$data = file_get_contents('php://input');
|
||||||
$data = json_decode($data, true);
|
$data = json_decode($data, true);
|
||||||
Cache::put(CacheKey::get('SERVER_V2RAY_ONLINE_USER', $server->id), count($data), 3600);
|
Cache::put(CacheKey::get('SERVER_V2RAY_ONLINE_USER', $server->id), count($data), 3600);
|
||||||
|
Cache::put(CacheKey::get('SERVER_V2RAY_LAST_PUSH_AT', $server->id), time(), 3600);
|
||||||
$userService = new UserService();
|
$userService = new UserService();
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
try {
|
try {
|
||||||
|
@ -40,6 +40,7 @@ class ShadowsocksTidalabController extends Controller
|
|||||||
abort(500, 'fail');
|
abort(500, 'fail');
|
||||||
}
|
}
|
||||||
Cache::put(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $server->id), time(), 3600);
|
Cache::put(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $server->id), time(), 3600);
|
||||||
|
Cache::put(CacheKey::get('SERVER_SHADOWSOCKS_LAST_PUSH_AT', $server->id), time(), 3600);
|
||||||
$serverService = new ServerService();
|
$serverService = new ServerService();
|
||||||
$users = $serverService->getAvailableUsers(json_decode($server->group_id));
|
$users = $serverService->getAvailableUsers(json_decode($server->group_id));
|
||||||
$result = [];
|
$result = [];
|
||||||
|
@ -40,6 +40,7 @@ class TrojanTidalabController extends Controller
|
|||||||
abort(500, 'fail');
|
abort(500, 'fail');
|
||||||
}
|
}
|
||||||
Cache::put(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $server->id), time(), 3600);
|
Cache::put(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $server->id), time(), 3600);
|
||||||
|
Cache::put(CacheKey::get('SERVER_TROJAN_LAST_PUSH_AT', $server->id), time(), 3600);
|
||||||
$serverService = new ServerService();
|
$serverService = new ServerService();
|
||||||
$users = $serverService->getAvailableUsers(json_decode($server->group_id));
|
$users = $serverService->getAvailableUsers(json_decode($server->group_id));
|
||||||
$result = [];
|
$result = [];
|
||||||
|
@ -298,13 +298,6 @@ class ServerService
|
|||||||
$server[$i]['tags'] = json_decode($server[$i]['tags']);
|
$server[$i]['tags'] = json_decode($server[$i]['tags']);
|
||||||
}
|
}
|
||||||
$server[$i]['group_id'] = json_decode($server[$i]['group_id']);
|
$server[$i]['group_id'] = json_decode($server[$i]['group_id']);
|
||||||
$server[$i]['online'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_ONLINE_USER', $server[$i]['parent_id'] ? $server[$i]['parent_id'] : $server[$i]['id']));
|
|
||||||
if ($server[$i]['parent_id']) {
|
|
||||||
$server[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $server[$i]['parent_id']));
|
|
||||||
} else {
|
|
||||||
$server[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $server[$i]['id']));
|
|
||||||
}
|
|
||||||
$server[$i]['available'] = (time() - 300) < $server[$i]['last_check_at'];
|
|
||||||
}
|
}
|
||||||
return $server->toArray();
|
return $server->toArray();
|
||||||
}
|
}
|
||||||
@ -327,13 +320,6 @@ class ServerService
|
|||||||
$server[$i]['ruleSettings'] = json_decode($server[$i]['ruleSettings']);
|
$server[$i]['ruleSettings'] = json_decode($server[$i]['ruleSettings']);
|
||||||
}
|
}
|
||||||
$server[$i]['group_id'] = json_decode($server[$i]['group_id']);
|
$server[$i]['group_id'] = json_decode($server[$i]['group_id']);
|
||||||
$server[$i]['online'] = Cache::get(CacheKey::get('SERVER_V2RAY_ONLINE_USER', $server[$i]['parent_id'] ? $server[$i]['parent_id'] : $server[$i]['id']));
|
|
||||||
if ($server[$i]['parent_id']) {
|
|
||||||
$server[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $server[$i]['parent_id']));
|
|
||||||
} else {
|
|
||||||
$server[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $server[$i]['id']));
|
|
||||||
}
|
|
||||||
$server[$i]['available'] = (time() - 300) < $server[$i]['last_check_at'];
|
|
||||||
}
|
}
|
||||||
return $server->toArray();
|
return $server->toArray();
|
||||||
}
|
}
|
||||||
@ -347,14 +333,29 @@ class ServerService
|
|||||||
$server[$i]['tags'] = json_decode($server[$i]['tags']);
|
$server[$i]['tags'] = json_decode($server[$i]['tags']);
|
||||||
}
|
}
|
||||||
$server[$i]['group_id'] = json_decode($server[$i]['group_id']);
|
$server[$i]['group_id'] = json_decode($server[$i]['group_id']);
|
||||||
$server[$i]['online'] = Cache::get(CacheKey::get('SERVER_TROJAN_ONLINE_USER', $server[$i]['parent_id'] ? $server[$i]['parent_id'] : $server[$i]['id']));
|
|
||||||
if ($server[$i]['parent_id']) {
|
|
||||||
$server[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $server[$i]['parent_id']));
|
|
||||||
} else {
|
|
||||||
$server[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $server[$i]['id']));
|
|
||||||
}
|
|
||||||
$server[$i]['available'] = (time() - 300) < $server[$i]['last_check_at'];
|
|
||||||
}
|
}
|
||||||
return $server->toArray();
|
return $server->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function mergeData(&$servers)
|
||||||
|
{
|
||||||
|
foreach ($servers as $k => $v) {
|
||||||
|
$serverType = strtoupper($servers[$k]['type']);
|
||||||
|
$servers[$k]['online'] = Cache::get(CacheKey::get("SERVER_{$serverType}_ONLINE_USER", $servers[$k]['parent_id'] ? $servers[$k]['parent_id'] : $servers[$k]['id']));
|
||||||
|
if ($servers[$k]['parent_id']) {
|
||||||
|
$servers[$k]['last_check_at'] = Cache::get(CacheKey::get("SERVER_{$serverType}_LAST_CHECK_AT", $servers[$k]['parent_id']));
|
||||||
|
$servers[$k]['last_push_at'] = Cache::get(CacheKey::get("SERVER_{$serverType}_LAST_PUSH_AT", $servers[$k]['parent_id']));
|
||||||
|
} else {
|
||||||
|
$servers[$k]['last_check_at'] = Cache::get(CacheKey::get("SERVER_{$serverType}_LAST_CHECK_AT", $servers[$k]['id']));
|
||||||
|
$servers[$k]['last_push_at'] = Cache::get(CacheKey::get("SERVER_{$serverType}_LAST_PUSH_AT", $servers[$k]['id']));
|
||||||
|
}
|
||||||
|
if ((time() - 300) >= $servers[$k]['last_check_at']) {
|
||||||
|
$servers[$k]['available_status'] = 0;
|
||||||
|
} else if ((time() - 300) >= $servers[$k]['last_push_at']) {
|
||||||
|
$servers[$k]['available_status'] = 1;
|
||||||
|
} else {
|
||||||
|
$servers[$k]['available_status'] = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,13 @@ class CacheKey
|
|||||||
'LAST_SEND_EMAIL_VERIFY_TIMESTAMP' => '最后一次发送邮箱验证码时间',
|
'LAST_SEND_EMAIL_VERIFY_TIMESTAMP' => '最后一次发送邮箱验证码时间',
|
||||||
'SERVER_V2RAY_ONLINE_USER' => '节点在线用户',
|
'SERVER_V2RAY_ONLINE_USER' => '节点在线用户',
|
||||||
'SERVER_V2RAY_LAST_CHECK_AT' => '节点最后检查时间',
|
'SERVER_V2RAY_LAST_CHECK_AT' => '节点最后检查时间',
|
||||||
|
'SERVER_V2RAY_LAST_PUSH_AT' => '节点最后推送时间',
|
||||||
'SERVER_TROJAN_ONLINE_USER' => 'trojan节点在线用户',
|
'SERVER_TROJAN_ONLINE_USER' => 'trojan节点在线用户',
|
||||||
'SERVER_TROJAN_LAST_CHECK_AT' => 'trojan节点最后检查时间',
|
'SERVER_TROJAN_LAST_CHECK_AT' => 'trojan节点最后检查时间',
|
||||||
|
'SERVER_TROJAN_LAST_PUSH_AT' => 'trojan节点最后推送时间',
|
||||||
'SERVER_SHADOWSOCKS_ONLINE_USER' => 'ss节点在线用户',
|
'SERVER_SHADOWSOCKS_ONLINE_USER' => 'ss节点在线用户',
|
||||||
'SERVER_SHADOWSOCKS_LAST_CHECK_AT' => 'ss节点最后检查时间',
|
'SERVER_SHADOWSOCKS_LAST_CHECK_AT' => 'ss节点最后检查时间',
|
||||||
|
'SERVER_SHADOWSOCKS_LAST_PUSH_AT' => 'ss节点最后推送时间',
|
||||||
'TEMP_TOKEN' => '临时令牌',
|
'TEMP_TOKEN' => '临时令牌',
|
||||||
'LAST_SEND_EMAIL_REMIND_TRAFFIC'
|
'LAST_SEND_EMAIL_REMIND_TRAFFIC'
|
||||||
];
|
];
|
||||||
|
@ -236,5 +236,5 @@ return [
|
|||||||
| The only modification by laravel config
|
| The only modification by laravel config
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
'version' => '1.5.1'
|
'version' => '1.5.1.1616569427547'
|
||||||
];
|
];
|
||||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user