Skip to content

Commit 6cac241

Browse files
authored
Merge branch 'cedar2025:master' into master
2 parents f6abc36 + 76a800d commit 6cac241

179 files changed

Lines changed: 4569 additions & 95893 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.docker/supervisor/supervisord.conf

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,21 @@ stopwaitsecs=3
6161
stopsignal=TERM
6262
stopasgroup=true
6363
killasgroup=true
64-
priority=300
64+
priority=300
65+
66+
[program:ws-server]
67+
process_name=%(program_name)s_%(process_num)02d
68+
command=php /www/artisan ws-server start
69+
autostart=%(ENV_ENABLE_WS_SERVER)s
70+
autorestart=true
71+
user=www
72+
redirect_stderr=true
73+
stdout_logfile=/dev/stdout
74+
stdout_logfile_maxbytes=0
75+
stdout_logfile_backups=0
76+
numprocs=1
77+
stopwaitsecs=5
78+
stopsignal=SIGINT
79+
stopasgroup=true
80+
killasgroup=true
81+
priority=400

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
APP_NAME=XBoard
2-
APP_ENV=local
2+
APP_ENV=production
33
APP_KEY=base64:PZXk5vTuTinfeEVG5FpYv2l6WEhLsyvGpiWK7IgJJ60=
44
APP_DEBUG=false
55
APP_URL=http://localhost

.github/workflows/docker-publish.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5959
tags: |
6060
type=ref,event=branch
61-
type=sha,format=long
61+
type=sha,format=short,prefix=,enable=true
6262
type=raw,value=new,enable=${{ github.ref == 'refs/heads/master' }}
6363
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
6464
type=raw,value=${{ steps.get_version.outputs.version }}
@@ -98,12 +98,3 @@ jobs:
9898
allow: |
9999
network.host
100100
101-
- name: Install cosign
102-
uses: sigstore/cosign-installer@v3.4.0
103-
with:
104-
cosign-release: 'v2.2.2'
105-
106-
- name: Sign image
107-
if: steps.build-and-push.outputs.digest != ''
108-
run: |
109-
echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign --yes "{}@${{ steps.build-and-push.outputs.digest }}"

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "public/assets/admin"]
2+
path = public/assets/admin
3+
url = https://github.com/cedar2025/xboard-admin-dist.git

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,23 @@ RUN echo "Attempting to clone branch: ${BRANCH_NAME} from ${REPO_URL} with CACHE
2525
rm -rf ./* && \
2626
rm -rf .git && \
2727
git config --global --add safe.directory /www && \
28-
git clone --depth 1 --branch ${BRANCH_NAME} ${REPO_URL} .
28+
git clone --depth 1 --branch ${BRANCH_NAME} ${REPO_URL} . && \
29+
git submodule update --init --recursive --force
2930

3031
COPY .docker/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
3132

3233
RUN composer install --no-cache --no-dev \
3334
&& php artisan storage:link \
35+
&& cp -r plugins/ /opt/default-plugins/ \
3436
&& chown -R www:www /www \
3537
&& chmod -R 775 /www \
3638
&& mkdir -p /data \
3739
&& chown redis:redis /data
3840

3941
ENV ENABLE_WEB=true \
4042
ENABLE_HORIZON=true \
41-
ENABLE_REDIS=false
43+
ENABLE_REDIS=false \
44+
ENABLE_WS_SERVER=false
4245

4346
EXPOSE 7001
44-
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
47+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

app/Console/Commands/CheckCommission.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ public function payHandle($inviteUserId, Order $order)
104104
$commissionBalance = $order->commission_balance * ($commissionShareLevels[$l] / 100);
105105
if (!$commissionBalance) continue;
106106
if ((int)admin_setting('withdraw_close_enable', 0)) {
107-
$inviter->balance = $inviter->balance + $commissionBalance;
107+
$inviter->increment('balance', $commissionBalance);
108108
} else {
109-
$inviter->commission_balance = $inviter->commission_balance + $commissionBalance;
109+
$inviter->increment('commission_balance', $commissionBalance);
110110
}
111111
if (!$inviter->save()) {
112112
DB::rollBack();

app/Console/Commands/CheckOrder.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@ public function __construct()
4343
*/
4444
public function handle()
4545
{
46-
ini_set('memory_limit', -1);
47-
$orders = Order::whereIn('status', [Order::STATUS_PENDING, Order::STATUS_PROCESSING])
46+
Order::whereIn('status', [Order::STATUS_PENDING, Order::STATUS_PROCESSING])
4847
->orderBy('created_at', 'ASC')
49-
->get();
50-
foreach ($orders as $order) {
51-
OrderHandleJob::dispatch($order->trade_no);
52-
}
48+
->lazyById(200)
49+
->each(function ($order) {
50+
OrderHandleJob::dispatch($order->trade_no);
51+
});
5352
}
5453
}

app/Console/Commands/CheckTicket.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ public function __construct()
3838
*/
3939
public function handle()
4040
{
41-
ini_set('memory_limit', -1);
42-
$tickets = Ticket::where('status', 0)
41+
Ticket::where('status', 0)
4342
->where('updated_at', '<=', time() - 24 * 3600)
4443
->where('reply_status', 0)
45-
->get();
46-
foreach ($tickets as $ticket) {
47-
if ($ticket->user_id === $ticket->last_reply_user_id) continue;
48-
$ticket->status = Ticket::STATUS_CLOSED;
49-
$ticket->save();
50-
}
44+
->lazyById(200)
45+
->each(function ($ticket) {
46+
if ($ticket->user_id === $ticket->last_reply_user_id) return;
47+
$ticket->status = Ticket::STATUS_CLOSED;
48+
$ticket->save();
49+
});
5150
}
5251
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use App\Models\Server;
6+
use App\Models\User;
7+
use App\Services\NodeSyncService;
8+
use Illuminate\Console\Command;
9+
use Illuminate\Support\Facades\Redis;
10+
11+
class CheckTrafficExceeded extends Command
12+
{
13+
protected $signature = 'check:traffic-exceeded';
14+
protected $description = '检查流量超标用户并通知节点';
15+
16+
public function handle()
17+
{
18+
$count = Redis::scard('traffic:pending_check');
19+
if ($count <= 0) {
20+
return;
21+
}
22+
23+
$pendingUserIds = array_map('intval', Redis::spop('traffic:pending_check', $count));
24+
25+
$exceededUsers = User::toBase()
26+
->whereIn('id', $pendingUserIds)
27+
->whereRaw('u + d >= transfer_enable')
28+
->where('transfer_enable', '>', 0)
29+
->where('banned', 0)
30+
->select(['id', 'group_id'])
31+
->get();
32+
33+
if ($exceededUsers->isEmpty()) {
34+
return;
35+
}
36+
37+
$groupedUsers = $exceededUsers->groupBy('group_id');
38+
$notifiedCount = 0;
39+
40+
foreach ($groupedUsers as $groupId => $users) {
41+
if (!$groupId) {
42+
continue;
43+
}
44+
45+
$userIdsInGroup = $users->pluck('id')->toArray();
46+
$servers = Server::whereJsonContains('group_ids', (string) $groupId)->get();
47+
48+
foreach ($servers as $server) {
49+
if (!NodeSyncService::isNodeOnline($server->id)) {
50+
continue;
51+
}
52+
53+
NodeSyncService::push($server->id, 'sync.user.delta', [
54+
'action' => 'remove',
55+
'users' => array_map(fn($id) => ['id' => $id], $userIdsInGroup),
56+
]);
57+
$notifiedCount++;
58+
}
59+
}
60+
61+
$this->info("Checked " . count($pendingUserIds) . " users, notified {$notifiedCount} nodes for " . $exceededUsers->count() . " exceeded users.");
62+
}
63+
}

app/Console/Commands/CleanupExpiredOnlineStatus.php

Lines changed: 0 additions & 52 deletions
This file was deleted.

0 commit comments

Comments
 (0)