mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
Merge branch 'cedar2025:dev' into dev
This commit is contained in:
commit
1d36069726
@ -13,7 +13,7 @@ class StatController extends Controller
|
||||
{
|
||||
public function getTrafficLog(Request $request)
|
||||
{
|
||||
$startDate = now()->startOfMonth();
|
||||
$startDate = now()->startOfMonth()->timestamp;
|
||||
$records = StatUser::query()
|
||||
->where('user_id', $request->user['id'])
|
||||
->where('record_at', '>=', $startDate)
|
||||
|
@ -26,6 +26,7 @@ class Server
|
||||
$request->validate([
|
||||
'token' => [
|
||||
"string",
|
||||
"required",
|
||||
function ($attribute, $value, $fail) {
|
||||
if ($value !== admin_setting('server_token')) {
|
||||
$fail('The ' . $attribute . ' is invalid.');
|
||||
@ -34,10 +35,11 @@ class Server
|
||||
],
|
||||
'node_id' => 'required',
|
||||
'node_type' => [
|
||||
'required',
|
||||
'nullable',
|
||||
'regex:/^(?i)(hysteria|hysteria2|vless|trojan|vmess|v2ray|tuic|shadowsocks|shadowsocks-plugin)$/',
|
||||
function ($attribute, $value, $fail) use ($aliasTypes, $request) {
|
||||
$request->merge([$attribute => strtolower(isset ($aliasTypes[$value]) ? $aliasTypes[$value] : $value)]);
|
||||
$request->merge([$attribute => strtolower(isset($aliasTypes[$value]) ? $aliasTypes[$value] : $value)]);
|
||||
},
|
||||
]
|
||||
], [
|
||||
|
@ -207,8 +207,8 @@ class ClashMeta
|
||||
$array['tls'] = true;
|
||||
if ($server['tls_settings']) {
|
||||
$tlsSettings = $server['tls_settings'];
|
||||
if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
|
||||
$array['skip-cert-verify'] = ($tlsSettings['allowInsecure'] ? true : false);
|
||||
if (isset($tlsSettings['allow_insecure']) && !empty($tlsSettings['allow_insecure']))
|
||||
$array['skip-cert-verify'] = ($tlsSettings['allow_insecure'] ? true : false);
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
|
||||
$array['servername'] = $tlsSettings['server_name'];
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ class Loon
|
||||
$server['host'],
|
||||
$server['port'],
|
||||
$password,
|
||||
$server['server_name'] ? "tls={$server['server_name']}" : "(null)"
|
||||
$server['server_name'] ? "sni={$server['server_name']}" : "(null)"
|
||||
];
|
||||
if ($server['insecure']) $config[] = "skip-cert-verify=true";
|
||||
$config[] = "download-bandwidth=" . ($user->speed_limit ? min($server['down_mbps'], $user->speed_limit) : $server['down_mbps']);
|
||||
|
@ -108,14 +108,14 @@ class StatisticalService
|
||||
/**
|
||||
* 获取指定用户的流量使用情况
|
||||
*/
|
||||
public function getStatUserByUserID($userId): array
|
||||
public function getStatUserByUserID(int|string $userId): array
|
||||
{
|
||||
|
||||
$stats = [];
|
||||
$statsUser = $this->redis->zrange($this->statUserKey, 0, -1, true);
|
||||
foreach ($statsUser as $member => $value) {
|
||||
list($rate, $uid, $type) = explode('_', $member);
|
||||
if ($uid !== $userId)
|
||||
if (intval($uid) !== intval($userId))
|
||||
continue;
|
||||
$key = "{$rate}_{$uid}";
|
||||
$stats[$key] = $stats[$key] ?? [
|
||||
|
Loading…
Reference in New Issue
Block a user