Compare commits

..

2 Commits

Author SHA1 Message Date
xboard
70998d0c08 fix: sqlite stats queue and admin login redirect
Some checks are pending
Docker Build and Publish / build (push) Waiting to run
2025-01-09 21:15:57 +08:00
xboard
ed43ffc3f5 fix: vmess grpc 2025-01-09 20:02:19 +08:00
5 changed files with 44 additions and 26 deletions

View File

@ -82,7 +82,7 @@ class UniProxyController extends Controller
$baseConfig = [
'server_port' => $serverPort,
'network' => $protocolSettings['network'] ?? null,
'network_settings' => $protocolSettings['network_settings'] ?? null,
'networkSettings' => $protocolSettings['network_settings'] ?? null,
];
$response = match ($nodeType) {

View File

@ -52,21 +52,28 @@ class StatServerJob implements ShouldQueue
$u += $traffic[0];
$d += $traffic[1];
}
// Update or create traffic stats
DB::transaction(function () use ($u, $d, $recordAt) {
StatServer::updateOrCreate(
[
$stat = StatServer::lockForUpdate()
->where('record_at', $recordAt)
->where('server_id', $this->server['id'])
->where('server_type', $this->protocol)
->where('record_type', $this->recordType)
->first();
if ($stat) {
$stat->u += $u;
$stat->d += $d;
$stat->save();
} else {
StatServer::create([
'record_at' => $recordAt,
'server_id' => $this->server['id'],
'server_type' => $this->protocol,
'record_type' => $this->recordType,
],
[
'u' => DB::raw("COALESCE(u, 0) + $u"),
'd' => DB::raw("COALESCE(d, 0) + $d"),
]
);
'u' => $u,
'd' => $d,
]);
}
});
}
}

View File

@ -47,19 +47,30 @@ class StatUserJob implements ShouldQueue
: strtotime(date('Y-m-d'));
foreach ($this->data as $uid => $v) {
StatUser::updateOrCreate(
[
'user_id' => $uid,
'server_rate' => $this->server['rate'],
'record_at' => $recordAt,
'record_type' => $this->recordType,
],
[
'u' => DB::raw('COALESCE(u, 0) + ' . ($v[0] * $this->server['rate'])),
'd' => DB::raw('COALESCE(d, 0) + ' . ($v[1] * $this->server['rate'])),
't' => time(),
]
);
DB::transaction(function () use ($uid, $v, $recordAt) {
$stat = StatUser::lockForUpdate()
->where('user_id', $uid)
->where('server_rate', $this->server['rate'])
->where('record_at', $recordAt)
->where('record_type', $this->recordType)
->first();
if ($stat) {
$stat->u += ($v[0] * $this->server['rate']);
$stat->d += ($v[1] * $this->server['rate']);
$stat->t = time();
$stat->save();
} else {
StatUser::create([
'user_id' => $uid,
'server_rate' => $this->server['rate'],
'record_at' => $recordAt,
'record_type' => $this->recordType,
'u' => ($v[0] * $this->server['rate']),
'd' => ($v[1] * $this->server['rate']),
't' => time(),
]);
}
});
}
}
}

View File

@ -93,7 +93,7 @@ class General implements ProtocolInterface
break;
case 'grpc':
$config['type'] = 'grpc';
$config['service_name'] = data_get($protocol_settings, 'network_settings.serviceName');
$config['path'] = data_get($protocol_settings, 'network_settings.serviceName');
break;
default:
break;

File diff suppressed because one or more lines are too long