update: add random port

This commit is contained in:
tokumeikoi 2022-02-17 03:17:05 +08:00
parent a1ada9183c
commit 766d1193c7
3 changed files with 17 additions and 14 deletions

View File

@ -27,18 +27,18 @@ 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 (strpos($v2ray[$i]['port'], '-') !== false) {
$v2ray[$i]['port'] = Helper::randomPort($v2ray[$i]['port']);
}
if (in_array($user->group_id, $groupId)) { 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 {
$v2ray[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$i]['id'])); $v2ray[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$i]['id']));
} }
}
array_push($servers, $v2ray[$i]->toArray()); array_push($servers, $v2ray[$i]->toArray());
} }
if (strpos($v2ray[$i]['port'], '-') !== false) {
$v2ray[$i]['port'] = Helper::randomPort($v2ray[$i]['port']);
}
}
return $servers; return $servers;
@ -55,18 +55,18 @@ 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 (strpos($trojan[$i]['port'], '-') !== false) {
$trojan[$i]['port'] = Helper::randomPort($trojan[$i]['port']);
}
if (in_array($user->group_id, $groupId)) { 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 {
$trojan[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $trojan[$i]['id'])); $trojan[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $trojan[$i]['id']));
} }
}
array_push($servers, $trojan[$i]->toArray()); array_push($servers, $trojan[$i]->toArray());
} }
if (strpos($trojan[$i]['port'], '-') !== false) {
$trojan[$i]['port'] = Helper::randomPort($trojan[$i]['port']);
}
}
return $servers; return $servers;
} }
@ -81,18 +81,18 @@ 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 (strpos($shadowsocks[$i]['port'], '-') !== false) {
$shadowsocks[$i]['port'] = Helper::randomPort($shadowsocks[$i]['port']);
}
if (in_array($user->group_id, $groupId)) { 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 {
$shadowsocks[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $shadowsocks[$i]['id'])); $shadowsocks[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_SHADOWSOCKS_LAST_CHECK_AT', $shadowsocks[$i]['id']));
} }
}
array_push($servers, $shadowsocks[$i]->toArray()); array_push($servers, $shadowsocks[$i]->toArray());
} }
if (strpos($shadowsocks[$i]['port'], '-') !== false) {
$shadowsocks[$i]['port'] = Helper::randomPort($shadowsocks[$i]['port']);
}
}
return $servers; return $servers;
} }

View File

@ -254,7 +254,7 @@ CREATE TABLE `v2_server_v2ray` (
`name` varchar(255) CHARACTER SET utf8mb4 NOT NULL, `name` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
`parent_id` int(11) DEFAULT NULL, `parent_id` int(11) DEFAULT NULL,
`host` varchar(255) NOT NULL, `host` varchar(255) NOT NULL,
`port` int(11) NOT NULL, `port` char(11) NOT NULL,
`server_port` int(11) NOT NULL, `server_port` int(11) NOT NULL,
`tls` tinyint(4) NOT NULL DEFAULT '0', `tls` tinyint(4) NOT NULL DEFAULT '0',
`tags` varchar(255) DEFAULT NULL, `tags` varchar(255) DEFAULT NULL,
@ -372,4 +372,4 @@ CREATE TABLE `v2_user` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 2022-02-07 07:04:34 -- 2022-02-16 19:16:57

View File

@ -486,3 +486,6 @@ ALTER TABLE `v2_notice`
ALTER TABLE `v2_order` ALTER TABLE `v2_order`
ADD `actual_commission_balance` int(11) NULL COMMENT '实际支付佣金' AFTER `commission_balance`; ADD `actual_commission_balance` int(11) NULL COMMENT '实际支付佣金' AFTER `commission_balance`;
ALTER TABLE `v2_server_v2ray`
CHANGE `port` `port` char(11) NOT NULL AFTER `host`;