mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-02-02 07:28:13 -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)
|
public function getTrafficLog(Request $request)
|
||||||
{
|
{
|
||||||
$startDate = now()->startOfMonth();
|
$startDate = now()->startOfMonth()->timestamp;
|
||||||
$records = StatUser::query()
|
$records = StatUser::query()
|
||||||
->where('user_id', $request->user['id'])
|
->where('user_id', $request->user['id'])
|
||||||
->where('record_at', '>=', $startDate)
|
->where('record_at', '>=', $startDate)
|
||||||
|
@ -26,6 +26,7 @@ class Server
|
|||||||
$request->validate([
|
$request->validate([
|
||||||
'token' => [
|
'token' => [
|
||||||
"string",
|
"string",
|
||||||
|
"required",
|
||||||
function ($attribute, $value, $fail) {
|
function ($attribute, $value, $fail) {
|
||||||
if ($value !== admin_setting('server_token')) {
|
if ($value !== admin_setting('server_token')) {
|
||||||
$fail('The ' . $attribute . ' is invalid.');
|
$fail('The ' . $attribute . ' is invalid.');
|
||||||
@ -34,6 +35,7 @@ class Server
|
|||||||
],
|
],
|
||||||
'node_id' => 'required',
|
'node_id' => 'required',
|
||||||
'node_type' => [
|
'node_type' => [
|
||||||
|
'required',
|
||||||
'nullable',
|
'nullable',
|
||||||
'regex:/^(?i)(hysteria|hysteria2|vless|trojan|vmess|v2ray|tuic|shadowsocks|shadowsocks-plugin)$/',
|
'regex:/^(?i)(hysteria|hysteria2|vless|trojan|vmess|v2ray|tuic|shadowsocks|shadowsocks-plugin)$/',
|
||||||
function ($attribute, $value, $fail) use ($aliasTypes, $request) {
|
function ($attribute, $value, $fail) use ($aliasTypes, $request) {
|
||||||
|
@ -207,8 +207,8 @@ class ClashMeta
|
|||||||
$array['tls'] = true;
|
$array['tls'] = true;
|
||||||
if ($server['tls_settings']) {
|
if ($server['tls_settings']) {
|
||||||
$tlsSettings = $server['tls_settings'];
|
$tlsSettings = $server['tls_settings'];
|
||||||
if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
|
if (isset($tlsSettings['allow_insecure']) && !empty($tlsSettings['allow_insecure']))
|
||||||
$array['skip-cert-verify'] = ($tlsSettings['allowInsecure'] ? true : false);
|
$array['skip-cert-verify'] = ($tlsSettings['allow_insecure'] ? true : false);
|
||||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
|
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
|
||||||
$array['servername'] = $tlsSettings['server_name'];
|
$array['servername'] = $tlsSettings['server_name'];
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ class Loon
|
|||||||
$server['host'],
|
$server['host'],
|
||||||
$server['port'],
|
$server['port'],
|
||||||
$password,
|
$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";
|
if ($server['insecure']) $config[] = "skip-cert-verify=true";
|
||||||
$config[] = "download-bandwidth=" . ($user->speed_limit ? min($server['down_mbps'], $user->speed_limit) : $server['down_mbps']);
|
$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 = [];
|
$stats = [];
|
||||||
$statsUser = $this->redis->zrange($this->statUserKey, 0, -1, true);
|
$statsUser = $this->redis->zrange($this->statUserKey, 0, -1, true);
|
||||||
foreach ($statsUser as $member => $value) {
|
foreach ($statsUser as $member => $value) {
|
||||||
list($rate, $uid, $type) = explode('_', $member);
|
list($rate, $uid, $type) = explode('_', $member);
|
||||||
if ($uid !== $userId)
|
if (intval($uid) !== intval($userId))
|
||||||
continue;
|
continue;
|
||||||
$key = "{$rate}_{$uid}";
|
$key = "{$rate}_{$uid}";
|
||||||
$stats[$key] = $stats[$key] ?? [
|
$stats[$key] = $stats[$key] ?? [
|
||||||
|
Loading…
Reference in New Issue
Block a user