123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- namespace App\Http\Controllers\Api\WebApi;
- use App\Models\Node;
- use Illuminate\Http\JsonResponse;
- class SSController extends BaseController
- {
- // 获取节点信息
- public function getNodeInfo(Node $node): JsonResponse
- {
- $data = [
- 'id' => $node->id,
- 'method' => $node->method,
- 'protocol' => $node->protocol,
- 'obfs' => $node->obfs,
- 'obfs_param' => $node->obfs_param ?? '',
- 'is_udp' => $node->is_udp,
- 'speed_limit' => $node->getRawOriginal('speed_limit'),
- 'client_limit' => $node->client_limit,
- 'sinlge' => $node->single,
- 'port' => $node->port,
- 'passwd' => $node->passwd ?? '',
- 'push_port' => $node->push_port
- ];
- // i['port'] = $node->port;
- // }f ($node->single) {
- // $data
- return $this->returnData('获取节点信息成功', 'success', 200, $data);
- }
- // 获取节点可用的用户列表
- public function getUserList(Node $node): JsonResponse
- {
- foreach ($node->users() as $user) {
- // $data[] = [
- // 'uid' => $user->id,
- // 'port' => $user->port,
- // 'passwd' => $node->passwd,
- // 'speed_limit' => $user->getRawOriginal('speed_limit'),
- // 'enable' => $user->enable,
- // ];
- $data[] = [
- 'uid' => $user->id,
- 'port' => $user->port,
- 'passwd' => $user->passwd,
- 'method' => $node->method,
- 'protocol' => $user->protocol,
- 'speed_limit' => $user->getRawOriginal('speed_limit'),
- 'enable' => $user->enable,
- 'client_limit' => $user->client_limit,
- ];
- }
- return $this->returnData('获取用户列表成功', 'success', 200, $data ?? [], ['updateTime' => time()]);
- }
- }
|