diff --git a/app/Components/IP.php b/app/Components/IP.php index bc5a7e9e..8bb35260 100644 --- a/app/Components/IP.php +++ b/app/Components/IP.php @@ -41,7 +41,7 @@ class IP return $response->json(); } - Log::warning('解析IPv6异常:'.$ip); + Log::warning('api.ip.sb解析'.$ip.'异常: '.$response->body()); return false; } diff --git a/app/Http/Controllers/Admin/NodeController.php b/app/Http/Controllers/Admin/NodeController.php index 0a0c41a8..d10ffa74 100644 --- a/app/Http/Controllers/Admin/NodeController.php +++ b/app/Http/Controllers/Admin/NodeController.php @@ -135,6 +135,7 @@ class NodeController extends Controller 'is_subscribe' => $info['is_subscribe'], 'is_ddns' => $info['is_ddns'], 'relay_node_id' => $info['relay_node_id'], + 'port' => $info['port'], 'push_port' => $info['push_port'], 'detection_type' => $info['detection_type'], 'sort' => $info['sort'], diff --git a/app/Http/Requests/Admin/NodeRequest.php b/app/Http/Requests/Admin/NodeRequest.php index 2ddf0b4f..43f0ff12 100644 --- a/app/Http/Requests/Admin/NodeRequest.php +++ b/app/Http/Requests/Admin/NodeRequest.php @@ -12,8 +12,8 @@ class NodeRequest extends FormRequest 'is_ddns' => 'required|boolean', 'name' => 'required|string', 'server' => 'required_if:is_ddns,1|nullable|ends_with:'.implode(',', config('domains')), - 'ip' => 'required_if:is_ddns,0|nullable|ipv4', - 'ipv6' => 'nullable|ipv6', + 'ip' => 'required_if:is_ddns,0|nullable', + 'ipv6' => 'nullable', 'push_port' => 'numeric|between:1,65535|different:port', 'traffic_rate' => 'required|numeric|min:0', 'level' => 'required|numeric|exists:level,level', diff --git a/app/Models/Node.php b/app/Models/Node.php index bfadeb3d..02f36ee2 100644 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -3,6 +3,7 @@ namespace App\Models; use App\Components\IP; +use Arr; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; @@ -100,7 +101,7 @@ class Node extends Model { $ip = $this->ips(); if ($ip !== []) { - $data = IP::IPSB($ip[0]); + $data = IP::IPSB($ip[0]); // 复数IP都以第一个为准 if ($data) { self::withoutEvents(function () use ($data) { @@ -139,53 +140,63 @@ class Node extends Model 'group' => sysConfig('website_name'), 'udp' => $this->is_udp, ]; - switch ($this->type) { - case 0: - $config = array_merge($config, [ - 'type' => 'shadowsocks', - 'passwd' => $user->passwd, - ], $this->profile); - if ($this->port) { - $config['port'] = $this->port; - } else { - $config['port'] = $user->port; - } - break; - case 2: - $config = array_merge($config, [ - 'type' => 'v2ray', - 'port' => $this->port, - 'uuid' => $user->vmess_id, - ], $this->profile); - break; - case 3: - $config = array_merge($config, [ - 'type' => 'trojan', - 'port' => $this->port, - 'passwd' => $user->passwd, - 'sni' => $this->relay_node_id ? $this->server : '', - ], $this->profile); - break; - case 1: - case 4: - $config = array_merge($config, [ - 'type' => 'shadowsocksr', - ], $this->profile); - if ($this->profile['passwd'] && $this->port) { - //单端口使用中转的端口 - $config['port'] = $this->port; - $config['protocol_param'] = $user->port.':'.$user->passwd; - } else { - $config['port'] = $user->port; - $config['passwd'] = $user->passwd; - if ($this->type === 1) { - $config['method'] = $user->method; - $config['protocol'] = $user->protocol; - $config['obfs'] = $user->obfs; - } - } - break; + if ($this->relay_node_id) { + $parentConfig = $this->relayNode->getConfig($user); + $config = array_merge($config, Arr::except($parentConfig, ['id', 'name', 'host', 'group', 'udp'])); + if ($parentConfig['type'] === 'trojan') { + $config['sni'] = $parentConfig['host']; + } + $config['port'] = $this->port; + } else { + switch ($this->type) { + case 0: + $config = array_merge($config, [ + 'type' => 'shadowsocks', + 'passwd' => $user->passwd, + ], $this->profile); + if ($this->port) { + $config['port'] = $this->port; + } else { + $config['port'] = $user->port; + } + break; + case 2: + $config = array_merge($config, [ + 'type' => 'v2ray', + 'port' => $this->port, + 'uuid' => $user->vmess_id, + ], $this->profile); + break; + case 3: + $config = array_merge($config, [ + 'type' => 'trojan', + 'port' => $this->port, + 'passwd' => $user->passwd, + 'sni' => '', + ], $this->profile); + break; + case 1: + case 4: + $config = array_merge($config, [ + 'type' => 'shadowsocksr', + ], $this->profile); + if ($this->profile['passwd'] && $this->port) { + //单端口使用中转的端口 + $config['port'] = $this->port; + $config['protocol_param'] = $user->port.':'.$user->passwd; + } else { + $config['port'] = $user->port; + $config['passwd'] = $user->passwd; + if ($this->type === 1) { + $config['method'] = $user->method; + $config['protocol'] = $user->protocol; + $config['obfs'] = $user->obfs; + } + } + + break; + } } return $config; diff --git a/resources/views/admin/node/info.blade.php b/resources/views/admin/node/info.blade.php index a26c2c37..22f1fb7a 100644 --- a/resources/views/admin/node/info.blade.php +++ b/resources/views/admin/node/info.blade.php @@ -146,196 +146,6 @@

扩展信息

-
- -
    -
  • -
    - - -
    -
  • -
  • -
    - - -
    -
  • -
  • -
    - - -
    -
  • -
  • -
    - - -
    -
  • -
  • -
    - - -
    -
  • -
-
-
- -
-
- - -
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- -
- 如果兼容请在服务端配置协议和混淆时加上_compatible -
-
-
-
-
- -
- -
-
- 如果启用请配置服务端的additional_ports信息 -
-
-
-
- - - 推荐80或443,服务端需要配置
- 严格模式:用户的端口无法连接,只能通过以下指定的端口进行连接(如何配置
-
-
- - -
-
-
- -
-
- - -
-
- - -
-
- - -
使用WebSocket传输协议时不要使用none
-
-
- - -
使用WebSocket传输协议时请启用TLS
-
-
- - -
-
- -
- -
-
- 伪装类型为http时多个伪装域名逗号隔开,使用WebSocket传输协议时只允许单个 -
-
-
- - -
-
- - -
-
- -
- -
-
-
- - -
不同后端配置不同: - VNET-V2Ray、 - V2Ray-Poseidon -
-
-
- -
-
- - -
-
- -
@@ -372,6 +182,7 @@
每30~60分钟随机进行节点阻断检测
+
+ +
+ +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • + +
    +
    + +
    +
    + + +
    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + +
    + 如果兼容请在服务端配置协议和混淆时加上_compatible +
    +
    +
    +
    +
    + +
    + +
    +
    + 如果启用请配置服务端的additional_ports信息 +
    +
    +
    +
    + + + 推荐80或443,服务端需要配置
    + 严格模式:用户的端口无法连接,只能通过以下指定的端口进行连接(如何配置
    +
    +
    + + +
    +
    +
    + +
    +
    + + +
    +
    + + +
    +
    + + +
    使用WebSocket传输协议时不要使用none
    +
    +
    + + +
    使用WebSocket传输协议时请启用TLS
    +
    +
    + + +
    +
    + +
    + +
    +
    + 伪装类型为http时多个伪装域名逗号隔开,使用WebSocket传输协议时只允许单个 +
    +
    +
    + + +
    +
    + + +
    +
    + +
    + +
    +
    +
    + + +
    不同后端配置不同: + VNET-V2Ray、 + V2Ray-Poseidon +
    +
    +
    + +
    +
    + + +
    +
    +
    +
    +
    + + +
    +
    @@ -438,34 +449,37 @@ $('#is_subscribe').click(); @endif $("input[name='detection_type'][value='{{$node->detection_type}}']").click(); - @if($node->profile['passwd'] && $node->port) + @if(!empty($node->profile['passwd']) && $node->port) $('#single').click(); $('#passwd').val('{{$node->profile['passwd']}}'); @endif $('input[name = port]').val('{{$node->port}}'); $("input[name='type'][value='{{$node->type}}']").click(); + @if(isset($node->relay_node_id)) + $('#relay_port').val('{{$node->port}}'); + @else @switch($node->type) @case(1) @case(4) - $('#protocol').selectpicker('val', '{{$node->profile['protocol']}}'); - $('#protocol_param').val('{{$node->profile['protocol_param']}}'); - $('#obfs').selectpicker('val', '{{$node->profile['obfs']}}'); - $('#obfs_param').val('{{$node->profile['obfs_param']}}'); + $('#protocol').selectpicker('val', '{{$node->profile['protocol'] ?? null}}'); + $('#protocol_param').val('{{$node->profile['protocol_param'] ?? null}}'); + $('#obfs').selectpicker('val', '{{$node->profile['obfs'] ?? null}}'); + $('#obfs_param').val('{{$node->profile['obfs_param'] ?? null}}'); @case(0) - $('#method').selectpicker('val', '{{$node->profile['method']}}'); + $('#method').selectpicker('val', '{{$node->profile['method'] ?? null}}'); @break @case(2) //V2Ray - $('#v2_alter_id').val('{{$node->profile['v2_alter_id']}}'); - $('#v2_method').selectpicker('val', '{{$node->profile['v2_method']}}'); - $('#v2_net').selectpicker('val', '{{$node->profile['v2_net']}}'); - $('#v2_type').selectpicker('val', '{{$node->profile['v2_type']}}'); - $('#v2_host').val('{{$node->profile['v2_host']}}'); + $('#v2_alter_id').val('{{$node->profile['v2_alter_id'] ?? null}}'); + $('#v2_method').selectpicker('val', '{{$node->profile['v2_method'] ?? null}}'); + $('#v2_net').selectpicker('val', '{{$node->profile['v2_net'] ?? null}}'); + $('#v2_type').selectpicker('val', '{{$node->profile['v2_type'] ?? null}}'); + $('#v2_host').val('{{$node->profile['v2_host'] ?? null}}'); $('#v2_port').val('{{$node->port}}'); - $('#v2_sni').val('{{$node->profile['v2_sni']}}'); - v2_path.val('{{$node->profile['v2_path']}}'); + $('#v2_sni').val('{{$node->profile['v2_sni'] ?? null}}'); + v2_path.val('{{$node->profile['v2_path'] ?? null}}'); @if($node->profile['v2_tls']) $('#v2_tls').click(); @endif @@ -477,6 +491,7 @@ @break @default @endswitch + @endif @else $('input[name=\'type\'][value=\'0\']').click(); @@ -655,6 +670,18 @@ } }); + $('#relay_node_id').on('changed.bs.select', function() { + const relay = $('.relay-config'); + const config = $('.proxy-config'); + if ($('#relay_node_id').val() === '') { + relay.hide(); + config.show(); + } else { + relay.show(); + config.hide(); + } + }); + // 设置V2Ray详细设置 $('#v2_net').on('changed.bs.select', function() { const type = $('.v2_type');