Skip to content

Commit a0eead8

Browse files
author
zhangjiangbin
committed
修正当节点是单端口时用户配置信息错误
1 parent 472ff7a commit a0eead8

2 files changed

Lines changed: 28 additions & 57 deletions

File tree

‎app/Http/Controllers/AdminController.php‎

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -988,61 +988,43 @@ public function export(Request $request)
988988
$nodeList = SsNode::query()->paginate(10)->appends($request->except('page'));
989989
foreach ($nodeList as &$node) {
990990
// 生成ssr scheme
991+
$obfs_param = $node->single ? '' : base64_encode($user->obfs_param);
992+
$protocol_param = $node->single ? base64_encode($user->port . ':' . $user->passwd) : base64_encode($user->protocol_param);
993+
991994
$ssr_str = '';
992-
$ssr_str .= $node->server . ':' . $user->port;
993-
$ssr_str .= ':' . $user->protocol . ':' . $user->method;
994-
$ssr_str .= ':' . $user->obfs . ':' . $this->base64url_encode($user->passwd);
995-
$ssr_str .= '/?obfsparam=' . $this->base64url_encode($user->obfs_param);
996-
$ssr_str .= '&=protoparam' . $this->base64url_encode($user->protocol_param);
997-
$ssr_str .= '&remarks=' . $this->base64url_encode($node->name);
995+
$ssr_str .= $node->server . ':' . ($node->single ? $node->single_port : $user->port);
996+
$ssr_str .= ':' . ($node->single ? $node->single_protocol : $user->protocol) . ':' . ($node->single ? $node->single_method : $user->method);
997+
$ssr_str .= ':' . ($node->single ? 'tls1.2_ticket_auth' : $user->obfs) . ':' . ($node->single ? base64_encode($node->single_passwd) : base64_encode($user->passwd));
998+
$ssr_str .= '/?obfsparam=' . $obfs_param;
999+
$ssr_str .= '&protoparam=' . $protocol_param;
1000+
$ssr_str .= '&remarks=' . base64_encode($node->name);
1001+
$ssr_str .= '&group=' . base64_encode('节点');
1002+
//$ssr_str .= '&udpport=0';
1003+
//$ssr_str .= '&uot=0';
9981004
$ssr_str = $this->base64url_encode($ssr_str);
9991005
$ssr_scheme = 'ssr://' . $ssr_str;
10001006

10011007
// 生成ss scheme
10021008
$ss_str = '';
10031009
$ss_str .= $user->method . ':' . $user->passwd . '@';
10041010
$ss_str .= $node->server . ':' . $user->port;
1005-
$ss_str = $this->base64url_encode($ss_str) . '#VPN'; // 加入#VPN是为了shadowrocket和ssr安卓客户端扫描时带上节点名称,windows c#版无效
1011+
$ss_str = $this->base64url_encode($ss_str) . '#' . 'VPN'; // 加入#VPN是为了shadowrocket和ssr安卓客户端扫描时带上节点名称,windows c#版无效
10061012
$ss_scheme = 'ss://' . $ss_str;
10071013

1008-
// 生成json配置信息
1009-
$config = <<<CONFIG
1010-
{
1011-
"remarks" : "{$node->name}",
1012-
"server" : "{$node->server}",
1013-
"server_port" : {$user->port},
1014-
"server_udp_port" : 0,
1015-
"password" : "{$user->passwd}",
1016-
"method" : "{$user->method}",
1017-
"protocol" : "{$user->protocol}",
1018-
"protocolparam" : "{$user->protocol_param}",
1019-
"obfs" : "{$user->obfs}",
1020-
"obfsparam" : "{$user->obfs_param}",
1021-
"remarks_base64" : "",
1022-
"group" : "VPN",
1023-
"enable" : true,
1024-
"udp_over_tcp" : false
1025-
}
1026-
CONFIG;
1027-
10281014
// 生成文本配置信息
1029-
$txt = <<<TXT
1030-
服务器:{$node->server}
1031-
远程端口:{$user->port}
1032-
本地端口:1080
1033-
密码:{$user->passwd}
1034-
加密方法:{$user->method}
1035-
协议:{$user->protocol}
1036-
协议参数:{$user->protocol_param}
1037-
混淆方式:{$user->obfs}
1038-
混淆参数:{$user->obfs_param}
1039-
路由:绕过局域网及中国大陆地址
1040-
TXT;
1015+
$txt = "服务器:" . $node->server . "\r\n";
1016+
$txt .= "远程端口:" . ($node->single ? $node->single_port : $user->port) . "\r\n";
1017+
$txt .= "密码:" . ($node->single ? $node->single_passwd : $user->passwd) . "\r\n";
1018+
$txt .= "加密方法:" . ($node->single ? $node->single_method : $user->method) . "\r\n";
1019+
$txt .= "协议:" . ($node->single ? $node->single_protocol : $user->protocol) . "\r\n";
1020+
$txt .= "协议参数:" . ($node->single ? $user->port.':'.$user->passwd : $user->protocol_param) . "\r\n";
1021+
$txt .= "混淆方式:" . ($node->single ? 'tls1.2_ticket_auth' : $user->obfs) . "\r\n";
1022+
$txt .= "混淆参数:" . ($node->single ? '' : $user->obfs_param) . "\r\n";
1023+
$txt .= "本地端口:1080\r\n路由:绕过局域网及中国大陆地址";
10411024

10421025
$node->txt = $txt;
1043-
$node->json = $config;
10441026
$node->ssr_scheme = $ssr_scheme;
1045-
$node->ss_scheme = $ss_scheme;
1027+
$node->ss_scheme = $node->compatible ? $ss_scheme : ''; // 节点兼容原版才显示
10461028
}
10471029

10481030
$view['nodeList'] = $nodeList;

‎resources/views/admin/export.blade.php‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@
3636
<tbody>
3737
@foreach ($nodeList as $node)
3838
<tr>
39-
<td> {{$node->name}} @if ($node->compatible) <span class="label label-warning"> 兼容 </span> @endif </td>
39+
<td>
40+
{{$node->name}}
41+
@if ($node->compatible) <span class="label label-info"> 兼 </span> @endif
42+
@if ($node->single) <span class="label label-danger"> 单 </span> @endif
43+
</td>
4044
<td>
4145
<a class="btn btn-sm green btn-outline" data-toggle="modal" href="#txt_{{$node->id}}"> 文本 </a>
4246
<a class="btn btn-sm green btn-outline" data-toggle="modal" href="#scheme_{{$node->id}}"> SCHEME </a>
43-
<a class="btn btn-sm green btn-outline" data-toggle="modal" href="#json_{{$node->id}}"> JSON </a>
4447
<a class="btn btn-sm green btn-outline" data-toggle="modal" href="#qrcode_{{$node->id}}"> 二维码 </a>
4548
</td>
4649
</tr>
@@ -91,19 +94,6 @@
9194
</div>
9295
</div>
9396
</div>
94-
<div class="modal fade draggable-modal" id="json_{{$node->id}}" tabindex="-1" role="basic" aria-hidden="true">
95-
<div class="modal-dialog">
96-
<div class="modal-content">
97-
<div class="modal-header">
98-
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
99-
<h4 class="modal-title">请复制以下信息,添加至gui-config.json</h4>
100-
</div>
101-
<div class="modal-body">
102-
<textarea class="form-control" rows="16" readonly="readonly"> {{$node->json}} </textarea>
103-
</div>
104-
</div>
105-
</div>
106-
</div>
10797
<div class="modal fade" id="qrcode_{{$node->id}}" tabindex="-1" role="dialog" aria-hidden="true">
10898
<div class="modal-dialog @if(!$node->compatible) modal-sm @endif">
10999
<div class="modal-content">
@@ -153,7 +143,6 @@
153143
@foreach($nodeList as $node)
154144
$("#txt_{{$node->id}}").draggable({handle: ".modal-header"});
155145
$("#scheme_{{$node->id}}").draggable({handle: ".modal-header"});
156-
$("#json_{{$node->id}}").draggable({handle: ".modal-header"});
157146
$("#qrcode_{{$node->id}}").draggable({handle: ".modal-header"});
158147
@endforeach
159148
};

0 commit comments

Comments
 (0)