fix: fix know issues

This commit is contained in:
xboard 2025-01-07 22:07:13 -05:00
parent 9d27e447d1
commit 6831b40e22
22 changed files with 393 additions and 367 deletions

View File

@ -39,11 +39,16 @@ class SendRemindMail extends Command
*/ */
public function handle() public function handle()
{ {
if (!(bool) admin_setting('remind_mail_enable', false)) {
return;
}
$users = User::all(); $users = User::all();
$mailService = new MailService(); $mailService = new MailService();
foreach ($users as $user) { foreach ($users as $user) {
if ($user->remind_expire) $mailService->remindExpire($user); if ($user->remind_expire)
if ($user->remind_traffic) $mailService->remindTraffic($user); $mailService->remindExpire($user);
if ($user->remind_traffic)
$mailService->remindTraffic($user);
} }
} }
} }

View File

@ -88,7 +88,10 @@ class UniProxyController extends Controller
'network_settings' => $protocolSettings['network_settings'], 'network_settings' => $protocolSettings['network_settings'],
'tls' => $protocolSettings['tls'], 'tls' => $protocolSettings['tls'],
'flow' => $protocolSettings['flow'], 'flow' => $protocolSettings['flow'],
'tls_settings' => $protocolSettings['tls_settings'] 'tls_settings' => match ((int) $protocolSettings['tls']) {
1 => $protocolSettings['tls_settings'],
2 => $protocolSettings['reality_settings']
}
], ],
'hysteria' => [ 'hysteria' => [
'version' => $protocolSettings['version'], 'version' => $protocolSettings['version'],

View File

@ -107,6 +107,7 @@ class ConfigController extends Controller
'show_protocol_to_server_enable' => (bool) admin_setting('show_protocol_to_server_enable', 0), 'show_protocol_to_server_enable' => (bool) admin_setting('show_protocol_to_server_enable', 0),
'default_remind_expire' => (bool) admin_setting('default_remind_expire', 1), 'default_remind_expire' => (bool) admin_setting('default_remind_expire', 1),
'default_remind_traffic' => (bool) admin_setting('default_remind_traffic', 1), 'default_remind_traffic' => (bool) admin_setting('default_remind_traffic', 1),
'remind_mail_enable' => (bool) admin_setting('remind_mail_enable', false),
], ],
'frontend' => [ 'frontend' => [

View File

@ -114,6 +114,7 @@ class ManageController extends Controller
{ {
$server = Server::find($request->input('id')); $server = Server::find($request->input('id'));
$server->show = 0; $server->show = 0;
$server->code = null;
if (!$server) { if (!$server) {
return $this->fail([400202, '服务器不存在']); return $this->fail([400202, '服务器不存在']);
} }

View File

@ -57,41 +57,131 @@ class StatController extends Controller
]; ];
} }
/**
* Get order statistics with filtering and pagination
*
* @param Request $request
* @return array
*/
public function getOrder(Request $request) public function getOrder(Request $request)
{ {
$statistics = Stat::where('record_type', 'd') $request->validate([
->limit(31) 'start_date' => 'nullable|date_format:Y-m-d',
->orderBy('record_at', 'DESC') 'end_date' => 'nullable|date_format:Y-m-d',
'type' => 'nullable|in:paid_total,paid_count,commission_total,commission_count',
'page' => 'nullable|integer|min:1',
'page_size' => 'nullable|integer|min:1|max:100'
]);
$query = Stat::where('record_type', 'd');
// Apply date filters
if ($request->input('start_date')) {
$query->where('record_at', '>=', strtotime($request->input('start_date')));
}
if ($request->input('end_date')) {
$query->where('record_at', '<=', strtotime($request->input('end_date') . ' 23:59:59'));
}
// Get total count for pagination
$total = $query->count();
// Apply pagination
$pageSize = $request->input('page_size', 31);
$page = $request->input('page', 1);
$statistics = $query->orderBy('record_at', 'DESC')
->forPage($page, $pageSize)
->get() ->get()
->toArray(); ->toArray();
$result = [];
$summary = [
'paid_total' => 0,
'paid_count' => 0,
'commission_total' => 0,
'commission_count' => 0,
'start_date' => $request->input('start_date', date('Y-m-d', strtotime('-30 days'))),
'end_date' => $request->input('end_date', date('Y-m-d')),
'avg_paid_amount' => 0,
'avg_commission_amount' => 0
];
$dailyStats = [];
foreach ($statistics as $statistic) { foreach ($statistics as $statistic) {
$date = date('m-d', $statistic['record_at']); $date = date('Y-m-d', $statistic['record_at']);
$result[] = [
'type' => '收款金额', // Update summary
$summary['paid_total'] += $statistic['paid_total'];
$summary['paid_count'] += $statistic['paid_count'];
$summary['commission_total'] += $statistic['commission_total'];
$summary['commission_count'] += $statistic['commission_count'];
// Calculate daily stats
$dailyData = [
'date' => $date, 'date' => $date,
'value' => $statistic['paid_total'] / 100 'paid_total' => $statistic['paid_total'],
'paid_count' => $statistic['paid_count'],
'commission_total' => $statistic['commission_total'],
'commission_count' => $statistic['commission_count'],
'avg_order_amount' => $statistic['paid_count'] > 0 ? round($statistic['paid_total'] / $statistic['paid_count'], 2) : 0,
'avg_commission_amount' => $statistic['commission_count'] > 0 ? round($statistic['commission_total'] / $statistic['commission_count'], 2) : 0
]; ];
$result[] = [
'type' => '收款笔数', if ($request->input('type')) {
$dailyStats[] = [
'date' => $date, 'date' => $date,
'value' => $statistic['paid_count'] 'value' => $statistic[$request->input('type')],
'type' => $this->getTypeLabel($request->input('type'))
]; ];
$result[] = [ } else {
'type' => '佣金金额(已发放)', $dailyStats[] = $dailyData;
'date' => $date, }
'value' => $statistic['commission_total'] / 100 }
];
$result[] = [ // Calculate averages for summary
'type' => '佣金笔数(已发放)', if ($summary['paid_count'] > 0) {
'date' => $date, $summary['avg_paid_amount'] = round($summary['paid_total'] / $summary['paid_count'], 2);
'value' => $statistic['commission_count'] }
if ($summary['commission_count'] > 0) {
$summary['avg_commission_amount'] = round($summary['commission_total'] / $summary['commission_count'], 2);
}
// Add percentage calculations to summary
$summary['commission_rate'] = $summary['paid_total'] > 0
? round(($summary['commission_total'] / $summary['paid_total']) * 100, 2)
: 0;
return [
'code' => 0,
'message' => 'success',
'data' => [
'list' => array_reverse($dailyStats),
'summary' => $summary,
'pagination' => [
'total' => $total,
'current_page' => $page,
'page_size' => $pageSize,
'total_pages' => ceil($total / $pageSize)
]
]
]; ];
} }
$result = array_reverse($result);
return [ /**
'data' => $result * Get human readable label for statistic type
]; *
* @param string $type
* @return string
*/
private function getTypeLabel(string $type): string
{
return match ($type) {
'paid_total' => '收款金额',
'paid_count' => '收款笔数',
'commission_total' => '佣金金额(已发放)',
'commission_count' => '佣金笔数(已发放)',
default => $type
};
} }
// 获取当日实时流量排行 // 获取当日实时流量排行
@ -281,8 +371,8 @@ class StatController extends Controller
$result[] = [ $result[] = [
'id' => (string) $data->id, 'id' => (string) $data->id,
'name' => $name, 'name' => $name,
'value' => round($data->value / (1024 * 1024 * 1024), 2), // Convert to GB 'value' => $data->value, // Convert to GB
'previousValue' => round($previousValue / (1024 * 1024 * 1024), 2), // Convert to GB 'previousValue' => $previousValue, // Convert to GB
'change' => $change, 'change' => $change,
'timestamp' => date('c', $endDate) 'timestamp' => date('c', $endDate)
]; ];

View File

@ -44,6 +44,7 @@ class ConfigSave extends FormRequest
'change_order_event_id' => '', 'change_order_event_id' => '',
'show_info_to_server_enable' => '', 'show_info_to_server_enable' => '',
'show_protocol_to_server_enable' => '', 'show_protocol_to_server_enable' => '',
'remind_mail_enable' => '',
// server // server
'server_token' => 'nullable|min:16', 'server_token' => 'nullable|min:16',
'server_pull_interval' => 'integer', 'server_pull_interval' => 'integer',
@ -91,8 +92,8 @@ class ConfigSave extends FormRequest
'password_limit_enable' => 'boolean', 'password_limit_enable' => 'boolean',
'password_limit_count' => 'integer', 'password_limit_count' => 'integer',
'password_limit_expire' => 'integer', 'password_limit_expire' => 'integer',
'default_remind_expire' => 'integer|boolean', 'default_remind_expire' => 'boolean',
'default_remind_traffic' => 'integer|boolean' 'default_remind_traffic' => 'boolean'
]; ];
/** /**
* Get the validation rules that apply to the request. * Get the validation rules that apply to the request.

View File

@ -72,7 +72,8 @@ class ServerSave extends FormRequest
'tls_settings.server_name' => 'nullable|string', 'tls_settings.server_name' => 'nullable|string',
'tls_settings.allow_insecure' => 'nullable|boolean', 'tls_settings.allow_insecure' => 'nullable|boolean',
'reality_settings.allow_insecure' => 'nullable|boolean', 'reality_settings.allow_insecure' => 'nullable|boolean',
'reality_settings.dest' => 'nullable|string', 'reality_settings.server_name' => 'nullable|string',
'reality_settings.server_port' => 'nullable|string',
'reality_settings.public_key' => 'nullable|string', 'reality_settings.public_key' => 'nullable|string',
'reality_settings.private_key' => 'nullable|string', 'reality_settings.private_key' => 'nullable|string',
'reality_settings.short_id' => 'nullable|string', 'reality_settings.short_id' => 'nullable|string',

View File

@ -88,7 +88,14 @@ class Server extends Model
'flow' => null, 'flow' => null,
'network' => null, 'network' => null,
'network_settings' => null, 'network_settings' => null,
'reality_settings' => null 'reality_settings' => [
'allow_insecure' => false,
'server_port' => null,
'server_name' => null,
'public_key' => null,
'private_key' => null,
'short_id' => null
]
], ],
self::TYPE_SHADOWSOCKS => [ self::TYPE_SHADOWSOCKS => [
'cipher' => null, 'cipher' => null,
@ -165,6 +172,8 @@ class Server extends Model
if (strpos($this->port, '-') !== false) { if (strpos($this->port, '-') !== false) {
$this->ports = $this->port; $this->ports = $this->port;
$this->port = Helper::randomPort($this->port); $this->port = Helper::randomPort($this->port);
} else {
$this->port = (int) $this->port;
} }
} }

View File

@ -1,35 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ServerHysteria extends Model
{
protected $table = 'v2_server_hysteria';
protected $dateFormat = 'U';
protected $guarded = ['id'];
protected $casts = [
'created_at' => 'timestamp',
'updated_at' => 'timestamp',
'group_id' => 'array',
'route_id' => 'array',
'tags' => 'array',
'ips' => 'array',
'excludes' => 'array'
];
// ALPN映射表
public static $alpnMap = [
0 => 'hysteria',
1 => 'http/1.1',
2 => 'h2',
3 => 'h3'
];
public function parent(): BelongsTo
{
return $this->belongsTo(self::class, 'parent_id', 'id');
}
}

View File

@ -1,28 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ServerTrojan extends Model
{
protected $table = 'v2_server_trojan';
protected $dateFormat = 'U';
protected $guarded = ['id'];
protected $casts = [
'created_at' => 'timestamp',
'updated_at' => 'timestamp',
'group_id' => 'array',
'route_id' => 'array',
'networkSettings' => 'array',
'tags' => 'array',
'excludes' => 'array',
'ips' => 'array'
];
public function parent(): BelongsTo
{
return $this->belongsTo(self::class, 'parent_id', 'id');
}
}

View File

@ -1,29 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ServerVless extends Model
{
protected $table = 'v2_server_vless';
protected $dateFormat = 'U';
protected $guarded = ['id'];
protected $casts = [
'created_at' => 'timestamp',
'updated_at' => 'timestamp',
'group_id' => 'array',
'route_id' => 'array',
'tls_settings' => 'array',
'network_settings' => 'array',
'tags' => 'array',
'excludes' => 'array',
'ips' => 'array'
];
public function parent(): BelongsTo
{
return $this->belongsTo(self::class, 'parent_id', 'id');
}
}

View File

@ -1,31 +0,0 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class ServerVmess extends Model
{
protected $table = 'v2_server_vmess';
protected $dateFormat = 'U';
protected $guarded = ['id'];
protected $casts = [
'created_at' => 'timestamp',
'updated_at' => 'timestamp',
'group_id' => 'array',
'route_id' => 'array',
'tlsSettings' => 'array',
'networkSettings' => 'array',
'dnsSettings' => 'array',
'ruleSettings' => 'array',
'tags' => 'array',
'excludes' => 'array',
'ips' => 'array'
];
public function parent(): BelongsTo
{
return $this->belongsTo(self::class, 'parent_id', 'id');
}
}

View File

@ -152,7 +152,7 @@ class Clash implements ProtocolInterface
if (data_get($protocol_settings, 'tls')) { if (data_get($protocol_settings, 'tls')) {
$array['tls'] = true; $array['tls'] = true;
$array['skip-cert-verify'] = data_get($protocol_settings, 'tls_settings.allow_insecure'); $array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'tls_settings.allow_insecure');
$array['servername'] = data_get($protocol_settings, 'tls_settings.server_name'); $array['servername'] = data_get($protocol_settings, 'tls_settings.server_name');
} }
@ -192,7 +192,7 @@ class Clash implements ProtocolInterface
$array['password'] = $password; $array['password'] = $password;
$array['udp'] = true; $array['udp'] = true;
$array['sni'] = data_get($protocol_settings, 'server_name'); $array['sni'] = data_get($protocol_settings, 'server_name');
$array['skip-cert-verify'] = data_get($protocol_settings, 'allow_insecure'); $array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'allow_insecure');
switch (data_get($protocol_settings, 'network')) { switch (data_get($protocol_settings, 'network')) {
case 'tcp': case 'tcp':

View File

@ -151,7 +151,7 @@ class ClashMeta implements ProtocolInterface
if (data_get($protocol_settings, 'tls')) { if (data_get($protocol_settings, 'tls')) {
$array['tls'] = true; $array['tls'] = true;
$array['skip-cert-verify'] = data_get($protocol_settings, 'tls_settings.allow_insecure', false); $array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'tls_settings.allow_insecure', false);
$array['servername'] = data_get($protocol_settings, 'tls_settings.server_name'); $array['servername'] = data_get($protocol_settings, 'tls_settings.server_name');
} }
@ -195,18 +195,18 @@ class ClashMeta implements ProtocolInterface
'alterId' => 0, 'alterId' => 0,
'cipher' => 'auto', 'cipher' => 'auto',
'udp' => true, 'udp' => true,
'flow' => data_get($server, 'flow') 'flow' => data_get($protocol_settings, 'flow')
]; ];
switch (data_get($protocol_settings, 'tls')) { switch (data_get($protocol_settings, 'tls')) {
case 1: case 1:
$array['tls'] = true; $array['tls'] = true;
$array['skip-cert-verify'] = data_get($protocol_settings, 'tls_settings.allow_insecure', false); $array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'tls_settings.allow_insecure', false);
$array['servername'] = data_get($protocol_settings, 'tls_settings.server_name'); $array['servername'] = data_get($protocol_settings, 'tls_settings.server_name');
break; break;
case 2: case 2:
$array['tls'] = true; $array['tls'] = true;
$array['skip-cert-verify'] = data_get($protocol_settings, 'reality_settings.allow_insecure', false); $array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'reality_settings.allow_insecure', false);
$array['servername'] = data_get($protocol_settings, 'reality_settings.server_name'); $array['servername'] = data_get($protocol_settings, 'reality_settings.server_name');
$array['reality-opts'] = [ $array['reality-opts'] = [
'public-key' => data_get($protocol_settings, 'reality_settings.public_key'), 'public-key' => data_get($protocol_settings, 'reality_settings.public_key'),
@ -257,7 +257,7 @@ class ClashMeta implements ProtocolInterface
'password' => $password, 'password' => $password,
'udp' => true, 'udp' => true,
'sni' => data_get($settings, 'server_name'), 'sni' => data_get($settings, 'server_name'),
'skip-cert-verify' => data_get($settings, 'allow_insecure', false) 'skip-cert-verify' => (bool) data_get($settings, 'allow_insecure', false)
]; ];
switch (data_get($settings, 'network')) { switch (data_get($settings, 'network')) {
@ -291,7 +291,7 @@ class ClashMeta implements ProtocolInterface
'sni' => data_get($protocol_settings, 'tls.server_name'), 'sni' => data_get($protocol_settings, 'tls.server_name'),
'up' => data_get($protocol_settings, 'bandwidth.up'), 'up' => data_get($protocol_settings, 'bandwidth.up'),
'down' => data_get($protocol_settings, 'bandwidth.down'), 'down' => data_get($protocol_settings, 'bandwidth.down'),
'skip-cert-verify' => data_get($protocol_settings, 'tls.allow_insecure', false), 'skip-cert-verify' => (bool) data_get($protocol_settings, 'tls.allow_insecure', false),
]; ];
if (isset($server['ports'])) { if (isset($server['ports'])) {
$array['ports'] = $server['ports']; $array['ports'] = $server['ports'];

View File

@ -127,7 +127,7 @@ class SingBox implements ProtocolInterface
'transport' => [], 'transport' => [],
'tls' => $protocol_settings['tls'] ? [ 'tls' => $protocol_settings['tls'] ? [
'enabled' => true, 'enabled' => true,
'insecure' => data_get($protocol_settings, 'tls_settings.allow_insecure'), 'insecure' => (bool) data_get($protocol_settings, 'tls_settings.allow_insecure'),
'server_name' => data_get($protocol_settings, 'tls_settings.server_name') 'server_name' => data_get($protocol_settings, 'tls_settings.server_name')
] : null ] : null
]; ];
@ -166,14 +166,14 @@ class SingBox implements ProtocolInterface
"server" => $server['host'], "server" => $server['host'],
"server_port" => $server['port'], "server_port" => $server['port'],
"uuid" => $password, "uuid" => $password,
"packet_encoding" => "xudp" "packet_encoding" => "xudp",
'flow' => data_get($protocol_settings, 'flow', ''),
]; ];
if ($protocol_settings['tls']) { if ($protocol_settings['tls']) {
$tlsConfig = [ $tlsConfig = [
'enabled' => true, 'enabled' => true,
'flow' => data_get($protocol_settings, 'flow', ''), 'insecure' => (bool) data_get($protocol_settings, 'tls_settings.allow_insecure'),
'insecure' => data_get($protocol_settings, 'tls_settings.allow_insecure'),
'server_name' => data_get($protocol_settings, 'tls_settings.server_name'), 'server_name' => data_get($protocol_settings, 'tls_settings.server_name'),
'utls' => [ 'utls' => [
'enabled' => true, 'enabled' => true,
@ -233,7 +233,7 @@ class SingBox implements ProtocolInterface
'password' => $password, 'password' => $password,
'tls' => [ 'tls' => [
'enabled' => true, 'enabled' => true,
'insecure' => data_get($protocol_settings, 'allow_insecure', false), 'insecure' => (bool) data_get($protocol_settings, 'allow_insecure', false),
'server_name' => data_get($protocol_settings, 'server_name') 'server_name' => data_get($protocol_settings, 'server_name')
] ]
]; ];
@ -255,7 +255,7 @@ class SingBox implements ProtocolInterface
return $array; return $array;
} }
protected function buildHysteria($password, $server, $user): array protected function buildHysteria($password, $server): array
{ {
$protocol_settings = $server['protocol_settings']; $protocol_settings = $server['protocol_settings'];
$baseConfig = [ $baseConfig = [
@ -264,7 +264,7 @@ class SingBox implements ProtocolInterface
'tag' => $server['name'], 'tag' => $server['name'],
'tls' => [ 'tls' => [
'enabled' => true, 'enabled' => true,
'insecure' => $protocol_settings['tls']['allow_insecure'], 'insecure' => (bool) $protocol_settings['tls']['allow_insecure'],
'server_name' => $protocol_settings['tls']['server_name'] 'server_name' => $protocol_settings['tls']['server_name']
] ]
]; ];
@ -272,7 +272,7 @@ class SingBox implements ProtocolInterface
'up_mbps' => $protocol_settings['bandwidth']['up'], 'up_mbps' => $protocol_settings['bandwidth']['up'],
'down_mbps' => $protocol_settings['bandwidth']['down'], 'down_mbps' => $protocol_settings['bandwidth']['down'],
]; ];
$versionConfig = match ($server['version'] ?? 1) { $versionConfig = match (data_get($protocol_settings, 'version', 1)) {
2 => [ 2 => [
'type' => 'hysteria2', 'type' => 'hysteria2',
'password' => $password, 'password' => $password,

View File

@ -119,9 +119,9 @@ class Helper
return $subscribeUrl ? rtrim($subscribeUrl, '/') . $path : url($path); return $subscribeUrl ? rtrim($subscribeUrl, '/') . $path : url($path);
} }
public static function randomPort($range) { public static function randomPort($range): int {
$portRange = explode('-', $range); $portRange = explode('-', $range);
return rand($portRange[0], $portRange[1]); return random_int($portRange[0], $portRange[1]);
} }
public static function base64EncodeUrlSafe($data) public static function base64EncodeUrlSafe($data)

View File

@ -29,7 +29,8 @@
"stripe/stripe-php": "^7.36.1", "stripe/stripe-php": "^7.36.1",
"symfony/http-client": "^6.4", "symfony/http-client": "^6.4",
"symfony/mailgun-mailer": "^6.4", "symfony/mailgun-mailer": "^6.4",
"symfony/yaml": "*" "symfony/yaml": "*",
"zoujingli/ip2region": "^2.0"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-debugbar": "^3.9", "barryvdh/laravel-debugbar": "^3.9",

View File

@ -59,8 +59,14 @@ return [
'strict' => true, 'strict' => true,
'engine' => null, 'engine' => null,
'options' => (extension_loaded('pdo_mysql') ? array_filter([ 'options' => (extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA') PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : []) + [ \PDO::ATTR_PERSISTENT => true ], PDO::ATTR_PERSISTENT => false,
]) : []),
'pool' => [
'min_connections' => 1,
'max_connections' => 10,
'idle_timeout' => 60,
],
], ],
'pgsql' => [ 'pgsql' => [

View File

@ -23,7 +23,7 @@ return new class extends Migration {
$table->integer('rate')->comment('Traffic Rate'); $table->integer('rate')->comment('Traffic Rate');
$table->json('tags')->nullable()->comment('Server Tags'); $table->json('tags')->nullable()->comment('Server Tags');
$table->string('host')->comment('Server Host'); $table->string('host')->comment('Server Host');
$table->integer('port')->comment('Client Port'); $table->string('port')->comment('Client Port');
$table->integer('server_port')->comment('Server Port'); $table->integer('server_port')->comment('Server Port');
$table->json('protocol_settings')->nullable(); $table->json('protocol_settings')->nullable();
$table->boolean('show')->default(false)->comment('Show in List'); $table->boolean('show')->default(false)->comment('Show in List');
@ -45,7 +45,7 @@ return new class extends Migration {
'rate' => (int) $server->rate, 'rate' => (int) $server->rate,
'tags' => $server->tags ?: "[]", 'tags' => $server->tags ?: "[]",
'host' => $server->host, 'host' => $server->host,
'port' => (int) $server->port, 'port' => $server->port,
'server_port' => $server->server_port, 'server_port' => $server->server_port,
'protocol_settings' => json_encode([ 'protocol_settings' => json_encode([
'allow_insecure' => $server->allow_insecure, 'allow_insecure' => $server->allow_insecure,
@ -73,7 +73,7 @@ return new class extends Migration {
'rate' => (int) $server->rate, 'rate' => (int) $server->rate,
'tags' => $server->tags ?: "[]", 'tags' => $server->tags ?: "[]",
'host' => $server->host, 'host' => $server->host,
'port' => (int) $server->port, 'port' => $server->port,
'server_port' => $server->server_port, 'server_port' => $server->server_port,
'protocol_settings' => json_encode([ 'protocol_settings' => json_encode([
'tls' => $server->tls, 'tls' => $server->tls,
@ -103,7 +103,7 @@ return new class extends Migration {
'rate' => (int) $server->rate, 'rate' => (int) $server->rate,
'tags' => $server->tags ?: "[]", 'tags' => $server->tags ?: "[]",
'host' => $server->host, 'host' => $server->host,
'port' => (int) $server->port, 'port' => $server->port,
'server_port' => $server->server_port, 'server_port' => $server->server_port,
'protocol_settings' => json_encode([ 'protocol_settings' => json_encode([
'tls' => $server->tls, 'tls' => $server->tls,
@ -114,7 +114,8 @@ return new class extends Migration {
'reality_settings' => ($tlsSettings && $tlsSettings->public_key && $tlsSettings->short_id && $tlsSettings->server_name) ? [ 'reality_settings' => ($tlsSettings && $tlsSettings->public_key && $tlsSettings->short_id && $tlsSettings->server_name) ? [
'public_key' => $tlsSettings->public_key, 'public_key' => $tlsSettings->public_key,
'short_id' => $tlsSettings->short_id, 'short_id' => $tlsSettings->short_id,
'dest' => $tlsSettings->server_name . ($tlsSettings->server_port ? ':' . $tlsSettings->server_port : ''), 'server_name' => $tlsSettings->server_name,
'server_port' => $tlsSettings->server_port,
'private_key' => $tlsSettings->private_key, 'private_key' => $tlsSettings->private_key,
] : null ] : null
]), ]),
@ -138,7 +139,7 @@ return new class extends Migration {
'rate' => (int) $server->rate, 'rate' => (int) $server->rate,
'tags' => $server->tags ?: "[]", 'tags' => $server->tags ?: "[]",
'host' => $server->host, 'host' => $server->host,
'port' => (int) $server->port, 'port' => $server->port,
'server_port' => $server->server_port, 'server_port' => $server->server_port,
'protocol_settings' => json_encode([ 'protocol_settings' => json_encode([
'cipher' => $server->cipher, 'cipher' => $server->cipher,
@ -153,7 +154,7 @@ return new class extends Migration {
} }
// Migrate Hysteria servers // Migrate Hysteria servers
$hysteriaServers = DB::table('v2_server_hysteria')->get(); $hysteriaServers = DB::table(table: 'v2_server_hysteria')->get();
foreach ($hysteriaServers as $server) { foreach ($hysteriaServers as $server) {
DB::table('v2_server')->insert([ DB::table('v2_server')->insert([
'type' => 'hysteria', 'type' => 'hysteria',
@ -445,8 +446,8 @@ return new class extends Migration {
'rate' => (string) $server->rate, 'rate' => (string) $server->rate,
'show' => $server->show, 'show' => $server->show,
'sort' => $server->sort, 'sort' => $server->sort,
'up' => $settings['bandwidth']['up'], 'up_mbps' => $settings['bandwidth']['up'],
'down' => $settings['bandwidth']['down'], 'down_mbps' => $settings['bandwidth']['down'],
'server_name' => $settings['tls']['server_name'], 'server_name' => $settings['tls']['server_name'],
'insecure' => $settings['tls']['allow_insecure'], 'insecure' => $settings['tls']['allow_insecure'],
'created_at' => $timestamp, 'created_at' => $timestamp,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long