Bläddra i källkod

chore: v2ray添加SNI配置项,适配新版v2rayN和V2rayNG(订阅添加sni)

Bob 4 år sedan
förälder
incheckning
0627fcc553

+ 1 - 0
app/Components/Client/V2rayN.php

@@ -25,6 +25,7 @@ class V2rayN
             'host' => $server['v2_host'],
             'path' => $server['v2_path'],
             'tls' => $server['v2_tls'],
+            'sni' => $server['v2_sni'],
             'remark' => $server['name'],
         ];
 

+ 1 - 0
app/Http/Requests/Admin/NodeRequest.php

@@ -45,6 +45,7 @@ class NodeRequest extends FormRequest
             'v2_type' => 'required_if:type,2',
             'v2_host' => 'string|nullable',
             'v2_path' => 'string|nullable',
+            'v2_sni' => 'string|nullable',
             'v2_tls' => 'required_if:type,2|boolean',
             'tls_provider' => 'json|nullable',
             'is_relay' => 'required|boolean',

+ 1 - 0
app/Models/Node.php

@@ -143,6 +143,7 @@ class Node extends Model
                     'v2_host'     => $this->v2_host,
                     'v2_path'     => $this->v2_path,
                     'v2_tls'      => $this->v2_tls ? 'tls' : '',
+                    'v2_sni'      => $this->v2_sni,
                     'udp'         => $this->is_udp,
                 ]);
                 break;

+ 32 - 0
database/migrations/2021_06_27_174304_append_v2_sni_to_node_table.php

@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class AppendV2SniToNodeTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('node', function (Blueprint $table) {
+            $table->string('v2_sni', 191)->nullable()->comment('V2Ray的SNI配置');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::table('node', function (Blueprint $table) {
+            $table->dropColumn(['v2_sni']);
+        });
+    }
+}

+ 6 - 0
resources/views/admin/node/info.blade.php

@@ -313,6 +313,10 @@
                                             <label for="v2_path" class="col-md-3 col-form-label">路径 | 密钥</label>
                                             <input type="text" class="form-control col-md-4" name="v2_path" id="v2_path">
                                         </div>
+                                        <div class="form-group row">
+                                            <label for="v2_sni" class="col-md-3 col-form-label">SNI</label>
+                                            <input type="text" class="form-control col-md-4" name="v2_sni" id="v2_sni">
+                                        </div>
                                         <div class="form-group row">
                                             <label for="v2_tls" class="col-md-3 col-form-label">连接TLS</label>
                                             <div class="col-md-9">
@@ -470,6 +474,7 @@
             $('#v2_net').selectpicker('val', '{{$node->v2_net}}');
             $('#v2_type').selectpicker('val', '{{$node->v2_type}}');
             $('#v2_host').val('{{$node->v2_host}}');
+            $('#v2_sni').val('{{$node->v2_sni}}');
             v2_path.val('{{$node->v2_path}}');
             @if($node->v2_tls)
             $('#v2_tls').click();
@@ -552,6 +557,7 @@
                     v2_type: $('#v2_type').val(),
                     v2_host: $('#v2_host').val(),
                     v2_path: $('#v2_path').val(),
+                    v2_sni: $('#v2_sni').val(),
                     v2_tls: document.getElementById('v2_tls').checked ? 1 : 0,
                     tls_provider: $('#tls_provider').val(),
                     is_relay: document.getElementById('is_relay').checked ? 1 : 0,