diff --git a/app/Http/Controllers/V2/Admin/StatController.php b/app/Http/Controllers/V2/Admin/StatController.php index 61a5656..636d0d9 100644 --- a/app/Http/Controllers/V2/Admin/StatController.php +++ b/app/Http/Controllers/V2/Admin/StatController.php @@ -89,8 +89,8 @@ class StatController extends Controller 'paid_count' => 0, 'commission_total' => 0, 'commission_count' => 0, - 'start_date' => $request->input('start_date', date('Y-m-d', $statistics->last()->record_at)), - 'end_date' => $request->input('end_date', date('Y-m-d', $statistics->first()->record_at)), + 'start_date' => $request->input('start_date', date('Y-m-d', $statistics->last()?->record_at)), + 'end_date' => $request->input('end_date', date('Y-m-d', $statistics->first()?->record_at)), 'avg_paid_amount' => 0, 'avg_commission_amount' => 0 ]; diff --git a/app/Models/Server.php b/app/Models/Server.php index 0b89f1d..bed2e45 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -185,11 +185,12 @@ class Server extends Model $this->password = $user->uuid; - if (!isset($this->cipher) || !isset(self::CIPHER_CONFIGURATIONS[$this->cipher])) { + $cipher = data_get($this, 'protocol_settings.cipher'); + if (!$cipher || !isset(self::CIPHER_CONFIGURATIONS[$cipher])) { return; } - $config = self::CIPHER_CONFIGURATIONS[$this->cipher]; + $config = self::CIPHER_CONFIGURATIONS[$cipher]; $serverKey = Helper::getServerKey($this->created_at, $config['serverKeySize']); $userKey = Helper::uuidToBase64($user->uuid, $config['userKeySize']); $this->password = "{$serverKey}:{$userKey}"; diff --git a/app/Protocols/ClashMeta.php b/app/Protocols/ClashMeta.php index 271096a..f569c4b 100644 --- a/app/Protocols/ClashMeta.php +++ b/app/Protocols/ClashMeta.php @@ -130,7 +130,7 @@ class ClashMeta implements ProtocolInterface $array['server'] = $server['host']; $array['port'] = $server['port']; $array['cipher'] = data_get($server['protocol_settings'], 'cipher'); - $array['password'] = $password; + $array['password'] = data_get($server, 'password', $password); $array['udp'] = true; return $array; } diff --git a/app/Protocols/General.php b/app/Protocols/General.php index 4c4510b..fc73b85 100644 --- a/app/Protocols/General.php +++ b/app/Protocols/General.php @@ -53,6 +53,7 @@ class General implements ProtocolInterface { $protocol_settings = $server['protocol_settings']; $name = rawurlencode($server['name']); + $password = data_get($server, 'password', $password); $str = str_replace( ['+', '/', '='], ['-', '_', ''], diff --git a/app/Protocols/QuantumultX.php b/app/Protocols/QuantumultX.php index ce1bfbd..25cf6a3 100644 --- a/app/Protocols/QuantumultX.php +++ b/app/Protocols/QuantumultX.php @@ -44,6 +44,7 @@ class QuantumultX implements ProtocolInterface public static function buildShadowsocks($password, $server) { $protocol_settings = $server['protocol_settings']; + $password = data_get($server, 'password', $password); $config = [ "shadowsocks={$server['host']}:{$server['port']}", "method={$protocol_settings['cipher']}", diff --git a/app/Protocols/Shadowrocket.php b/app/Protocols/Shadowrocket.php index 599ec7d..328d3ad 100644 --- a/app/Protocols/Shadowrocket.php +++ b/app/Protocols/Shadowrocket.php @@ -60,6 +60,7 @@ class Shadowrocket implements ProtocolInterface { $protocol_settings = $server['protocol_settings']; $name = rawurlencode($server['name']); + $password = data_get($server, 'password', $password); $str = str_replace( ['+', '/', '='], ['-', '_', ''], diff --git a/app/Protocols/SingBox.php b/app/Protocols/SingBox.php index 4d7eacd..ddee22e 100644 --- a/app/Protocols/SingBox.php +++ b/app/Protocols/SingBox.php @@ -107,7 +107,7 @@ class SingBox implements ProtocolInterface $array['server'] = $server['host']; $array['server_port'] = $server['port']; $array['method'] = data_get($server, 'protocol_settings.cipher'); - $array['password'] = $password; + $array['password'] = data_get($server, 'password', $password); return $array; } diff --git a/app/Services/ServerService.php b/app/Services/ServerService.php index d63aa1c..d7319be 100644 --- a/app/Services/ServerService.php +++ b/app/Services/ServerService.php @@ -40,7 +40,9 @@ class ServerService $server->loadParentCreatedAt(); $server->handlePortAllocation(); $server->loadServerStatus(); - $server->server_key = Helper::getServerKey($server->created_at, 16); + if ($server->type === 'shadowsocks') { + $server->server_key = Helper::getServerKey($server->created_at, 16); + } $server->generateShadowsocksPassword($user); return $server; @@ -48,6 +50,10 @@ class ServerService ->toArray(); } + /** + * 加 + */ + /** * 根据权限组获取可用的用户列表 * @param array $groupIds