update: server service

This commit is contained in:
tokumeikoi 2022-02-19 13:45:57 +08:00
parent 60b6a6177d
commit 23f98d7abc

View File

@ -27,10 +27,10 @@ class ServerService
for ($i = 0; $i < count($v2ray); $i++) { for ($i = 0; $i < count($v2ray); $i++) {
$v2ray[$i]['type'] = 'v2ray'; $v2ray[$i]['type'] = 'v2ray';
$groupId = $v2ray[$i]['group_id']; $groupId = $v2ray[$i]['group_id'];
if (!in_array($user->group_id, $groupId)) continue;
if (strpos($v2ray[$i]['port'], '-') !== false) { if (strpos($v2ray[$i]['port'], '-') !== false) {
$v2ray[$i]['port'] = Helper::randomPort($v2ray[$i]['port']); $v2ray[$i]['port'] = Helper::randomPort($v2ray[$i]['port']);
} }
if (in_array($user->group_id, $groupId)) {
if ($v2ray[$i]['parent_id']) { if ($v2ray[$i]['parent_id']) {
$v2ray[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$i]['parent_id'])); $v2ray[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$i]['parent_id']));
} else { } else {
@ -38,7 +38,6 @@ class ServerService
} }
array_push($servers, $v2ray[$i]->toArray()); array_push($servers, $v2ray[$i]->toArray());
} }
}
return $servers; return $servers;
@ -55,10 +54,10 @@ class ServerService
for ($i = 0; $i < count($trojan); $i++) { for ($i = 0; $i < count($trojan); $i++) {
$trojan[$i]['type'] = 'trojan'; $trojan[$i]['type'] = 'trojan';
$groupId = $trojan[$i]['group_id']; $groupId = $trojan[$i]['group_id'];
if (!in_array($user->group_id, $groupId)) continue;
if (strpos($trojan[$i]['port'], '-') !== false) { if (strpos($trojan[$i]['port'], '-') !== false) {
$trojan[$i]['port'] = Helper::randomPort($trojan[$i]['port']); $trojan[$i]['port'] = Helper::randomPort($trojan[$i]['port']);
} }
if (in_array($user->group_id, $groupId)) {
if ($trojan[$i]['parent_id']) { if ($trojan[$i]['parent_id']) {
$trojan[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $trojan[$i]['parent_id'])); $trojan[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $trojan[$i]['parent_id']));
} else { } else {
@ -66,7 +65,6 @@ class ServerService
} }
array_push($servers, $trojan[$i]->toArray()); array_push($servers, $trojan[$i]->toArray());
} }
}
return $servers; return $servers;
} }
@ -81,10 +79,10 @@ class ServerService
for ($i = 0; $i < count($shadowsocks); $i++) { for ($i = 0; $i < count($shadowsocks); $i++) {
$shadowsocks[$i]['type'] = 'shadowsocks'; $shadowsocks[$i]['type'] = 'shadowsocks';
$groupId = $shadowsocks[$i]['group_id']; $groupId = $shadowsocks[$i]['group_id'];
if (!in_array($user->group_id, $groupId)) continue;
if (strpos($shadowsocks[$i]['port'], '-') !== false) { if (strpos($shadowsocks[$i]['port'], '-') !== false) {
$shadowsocks[$i]['port'] = Helper::randomPort($shadowsocks[$i]['port']); $shadowsocks[$i]['port'] = Helper::randomPort($shadowsocks[$i]['port']);
} }
if (in_array($user->group_id, $groupId)) {
if ($shadowsocks[$i]['parent_id']) { if ($shadowsocks[$i]['parent_id']) {
$shadowsocks[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $shadowsocks[$i]['parent_id'])); $shadowsocks[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $shadowsocks[$i]['parent_id']));
} else { } else {
@ -92,7 +90,6 @@ class ServerService
} }
array_push($servers, $shadowsocks[$i]->toArray()); array_push($servers, $shadowsocks[$i]->toArray());
} }
}
return $servers; return $servers;
} }