mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-02 10:39:56 +00:00
Fixed proxy info display incorrect
This commit is contained in:
@@ -176,11 +176,11 @@ class ClientController extends Controller
|
||||
return $this->succeed(null, null, [200, trans('user.home.attendance.success', ['data' => formatBytes($traffic)])]);
|
||||
}
|
||||
|
||||
public function proxyCheck(Request $request, ProxyService $proxyService): JsonResponse
|
||||
public function proxyCheck(Request $request): JsonResponse
|
||||
{
|
||||
$md5 = $request->get('md5', '');
|
||||
|
||||
$proxy = $proxyService->buildClientConfig('clash');
|
||||
$proxy = (new ProxyService())->buildClientConfig('clash');
|
||||
if (strtolower(md5(json_encode($proxy))) === strtolower($md5)) {
|
||||
return $this->succeed(false);
|
||||
}
|
||||
@@ -188,16 +188,17 @@ class ClientController extends Controller
|
||||
return $this->succeed(true, ['md5' => strtolower(md5(json_encode($proxy)))]);
|
||||
}
|
||||
|
||||
public function downloadProxies(Request $request, ProxyService $proxyService): string
|
||||
public function downloadProxies(Request $request): string
|
||||
{
|
||||
$flag = strtolower($request->input('flag') ?? ($request->userAgent() ?? ''));
|
||||
|
||||
return $proxyService->buildClientConfig($flag === 'v2rayng' ? 'v2rayng' : 'clash', $request->input('type'));
|
||||
return (new ProxyService())->buildClientConfig($flag === 'v2rayng' ? 'v2rayng' : 'clash', $request->input('type'));
|
||||
}
|
||||
|
||||
public function getProxyList(ProxyService $proxyService): JsonResponse
|
||||
public function getProxyList(): JsonResponse
|
||||
{
|
||||
$servers = [];
|
||||
$proxyService = new ProxyService();
|
||||
foreach ($proxyService->fetchAvailableNodes(null, false)->load('latestOnlineLog') as $node) {
|
||||
$server = $proxyService->generateNodeConfig($node);
|
||||
if ($server['type'] === 'shadowsocks' || $server['type'] === 'shadowsocksr') {
|
||||
|
||||
@@ -27,13 +27,13 @@ class NodeController extends Controller
|
||||
return view('user.services', compact('nodesGeo', 'nodes'));
|
||||
}
|
||||
|
||||
public function show(Request $request, Node $node, ProxyService $proxyServer): JsonResponse
|
||||
public function show(Request $request, Node $node): JsonResponse
|
||||
{ // 节点详细信息
|
||||
// 验证用户是否有权限访问该节点
|
||||
if (! auth()->user()->nodes()->where('node.id', $node->id)->exists()) {
|
||||
return response()->json(['status' => 'fail', 'message' => trans('http-statuses.401')]);
|
||||
}
|
||||
|
||||
return response()->json(['status' => 'success', 'data' => $proxyServer->getUserProxyConfig($node, $request->input('type') !== 'text')]);
|
||||
return response()->json(['status' => 'success', 'data' => (new ProxyService())->getUserProxyConfig($node, $request->input('type') !== 'text')]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ class SubscribeController extends Controller
|
||||
|
||||
private ?string $target;
|
||||
|
||||
private ProxyService $proxyServer;
|
||||
private ProxyService $proxyService;
|
||||
|
||||
public function __construct(ProxyService $proxyServer)
|
||||
public function __construct(ProxyService $proxyService)
|
||||
{
|
||||
$this->proxyServer = $proxyServer;
|
||||
$this->proxyService = $proxyService;
|
||||
}
|
||||
|
||||
public function index(Request $request, string $code): RedirectResponse|View
|
||||
@@ -100,7 +100,7 @@ class SubscribeController extends Controller
|
||||
}
|
||||
|
||||
// 设置用户并更新订阅信息
|
||||
$this->proxyServer->setUser($user);
|
||||
$this->proxyService->setUser($user);
|
||||
$subscribe->increment('times'); // 更新访问次数
|
||||
|
||||
// 记录订阅日志
|
||||
@@ -110,15 +110,15 @@ class SubscribeController extends Controller
|
||||
], JSON_THROW_ON_ERROR));
|
||||
|
||||
// 返回订阅内容
|
||||
return $this->proxyServer->buildClientConfig($this->target, self::$subType);
|
||||
return $this->proxyService->buildClientConfig($this->target, self::$subType);
|
||||
}
|
||||
|
||||
private function failed(string $text): string
|
||||
{ // 抛出错误的节点信息,用于兼容防止客户端订阅失败
|
||||
$this->proxyServer->failedProxyReturn($text, self::$subType ?? 0);
|
||||
$this->proxyService->failedProxyReturn($text, self::$subType ?? 0);
|
||||
|
||||
// 返回错误配置而不是空字符串,以确保客户端收到有效内容
|
||||
return $this->proxyServer->buildClientConfig($this->target, self::$subType);
|
||||
return $this->proxyService->buildClientConfig($this->target, self::$subType);
|
||||
}
|
||||
|
||||
private function subscribeLog(int $subscribeId, ?string $ip, string $headers): void
|
||||
|
||||
Reference in New Issue
Block a user