mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-12 23:48:53 +00:00
1. 全面改写项目-管理面板的路由; 2. 拆分过于Contoller; 3. 优化了按钮过多的图表的显示; 4. 初步应用 Laravel的 表单验证功能; 5. 初步应用 Laravel的 component 功能 拆分/模块化前端代码; 6. 优化部分系统的判断逻辑; 7. 针对2.4.0以前的面板,追加辅助矫正数据库的sql文件;
80 lines
2.4 KiB
PHP
80 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\VNet;
|
|
|
|
use GuzzleHttp\Client;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Log;
|
|
|
|
class reloadNode implements ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
private $nodes;
|
|
|
|
public function __construct($nodes)
|
|
{
|
|
$this->nodes = $nodes;
|
|
}
|
|
|
|
public function handle(): bool
|
|
{
|
|
$allSuccess = true;
|
|
foreach ($this->nodes as $node) {
|
|
$ret = $this->send(($node->server ?: $node->ip).':'.$node->push_port, $node->auth->secret, [
|
|
'id' => $node->id,
|
|
'port' => (string) $node->port,
|
|
'passwd' => $node->passwd ?: '',
|
|
'method' => $node->method,
|
|
'protocol' => $node->protocol,
|
|
'obfs' => $node->obfs,
|
|
'protocol_param' => $node->protocol_param,
|
|
'obfs_param' => $node->obfs_param ?: '',
|
|
'push_port' => $node->push_port,
|
|
'single' => $node->single,
|
|
'secret' => $node->auth->secret,
|
|
// 'is_udp' => $node->is_udp,
|
|
// 'speed_limit' => $node->speed_limit,
|
|
// 'client_limit' => $node->client_limit,
|
|
// 'redirect_url' => (string) sysConfig('redirect_url')
|
|
]);
|
|
|
|
if (!$ret) {
|
|
$allSuccess = false;
|
|
}
|
|
}
|
|
|
|
return $allSuccess;
|
|
}
|
|
|
|
public function send($host, $secret, $data): bool
|
|
{
|
|
$client = new Client([
|
|
'base_uri' => $host,
|
|
'timeout' => 15,
|
|
'headers' => ['secret' => $secret],
|
|
]);
|
|
|
|
$ret = $client->post('api/v2/node/reload', ['json' => $data]);
|
|
if ($ret->getStatusCode() == 200) {
|
|
$message = json_decode($ret->getBody(), true);
|
|
if (array_key_exists('success', $message) && array_key_exists('content', $message)) {
|
|
if ($message['success']) {
|
|
return true;
|
|
}
|
|
Log::error('重载节点失败:'.$host.' 反馈:'.$message['content']);
|
|
}
|
|
}
|
|
Log::error('重载节点失败url: '.$host);
|
|
|
|
return false;
|
|
}
|
|
}
|