From 1055823d091fd2b86429c80493b690603d1cfffc Mon Sep 17 00:00:00 2001 From: LI JIAHAO Date: Mon, 17 Apr 2017 19:09:29 +0800 Subject: [PATCH 01/11] finish clean-up function #683 --- app/Controllers/AdminController.php | 4 ++ resources/views/default/admin/sys.tpl | 55 ++++++++++++++++++++------- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/app/Controllers/AdminController.php b/app/Controllers/AdminController.php index db28f8aea..ab79a9a58 100755 --- a/app/Controllers/AdminController.php +++ b/app/Controllers/AdminController.php @@ -100,6 +100,10 @@ public function updateConfig($request, $response, $args) $res['msg'] = "更新成功"; return $response->getBody()->write(json_encode($res)); } + public function sysinfo($request, $response, $args) + { + return $this->view()->display('admin/sys.tpl'); + } public function cleanNodelog($request, $response, $args) { if($clean = NodeInfoLog::TRUNCATE()){ diff --git a/resources/views/default/admin/sys.tpl b/resources/views/default/admin/sys.tpl index b53a9f27a..5c6985d94 100755 --- a/resources/views/default/admin/sys.tpl +++ b/resources/views/default/admin/sys.tpl @@ -6,9 +6,26 @@ 系统维护 - +
+
+
+ + + +
+
@@ -62,10 +79,14 @@ url: "/admin/cleannodelog", dataType: "json", success: function (data) { - if (data.ret==1) { - alert("清理成功"); - }else{ - alert("发生错误"); + if (data.ret) { + $("#msg-error").hide(); + $("#msg-success").show(); + $("#msg-success-p").html(data.msg); + window.setTimeout("history.go(0)", 2000); + } else { + $("#msg-error").show(); + $("#msg-error-p").html(data.msg); } }, error: function (jqXHR) { @@ -83,10 +104,14 @@ url: "/admin/cleanonlinelog", dataType: "json", success: function (data) { - if (data.ret==1) { - alert("清理成功"); - }else{ - alert("发生错误"); + if (data.ret) { + $("#msg-error").hide(); + $("#msg-success").show(); + $("#msg-success-p").html(data.msg); + window.setTimeout("history.go(0)", 2000); + } else { + $("#msg-error").show(); + $("#msg-error-p").html(data.msg); } }, error: function (jqXHR) { @@ -104,10 +129,14 @@ url: "/admin/cleantrafficlog", dataType: "json", success: function (data) { - if (data.ret==1) { - alert("清理成功"); - }else{ - alert("发生错误"); + if (data.ret) { + $("#msg-error").hide(); + $("#msg-success").show(); + $("#msg-success-p").html(data.msg); + window.setTimeout("history.go(0)", 2000); + } else { + $("#msg-error").show(); + $("#msg-error-p").html(data.msg); } }, error: function (jqXHR) { From 8d5dd84f1c68454e3c1ae64cdaff83a201a76349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B9=B8=E7=A6=8F=E7=9A=84=E8=B7=AF=E7=97=B4?= Date: Wed, 28 Jun 2017 20:58:13 +0800 Subject: [PATCH 02/11] fix admin panel sys --- app/Controllers/AdminController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Controllers/AdminController.php b/app/Controllers/AdminController.php index fa0338fca..b69e1578d 100755 --- a/app/Controllers/AdminController.php +++ b/app/Controllers/AdminController.php @@ -154,5 +154,8 @@ public function cleantrafficlog($request, $response, $args) $res['ret'] = 0; return $response->getBody()->write(json_encode($res)); } - + public function sysinfo($request, $response, $args) + { + return $this->view()->display('admin/sys.tpl'); + } } From 64a6c95d6d1dc6bbc70c8ac14f3b928177e7bd38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B9=B8=E7=A6=8F=E7=9A=84=E8=B7=AF=E7=97=B4?= Date: Wed, 28 Jun 2017 21:22:42 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=9C=9F=E7=9A=84=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/User.php | 10 ++++++++++ resources/views/default/user/profile.tpl | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Models/User.php b/app/Models/User.php index 6b330f99b..4046cffc5 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -164,4 +164,14 @@ public function inviteCodes() return InviteCode::where('user_id', $uid)->get(); } + public function expireTime() + { + $expire = $this->attributes['expire_time']; + if($expire === 0){ + return '永不过期'; + } + else{ + return date('Y-m-d', $expire); + } + } } diff --git a/resources/views/default/user/profile.tpl b/resources/views/default/user/profile.tpl index 6718d722b..1590f3996 100755 --- a/resources/views/default/user/profile.tpl +++ b/resources/views/default/user/profile.tpl @@ -25,6 +25,8 @@
{$user->user_name}
邮箱
{$user->email}
+
有效期
+
{$user->expireTime()}
@@ -38,4 +40,4 @@
-{include file='user/footer.tpl'} \ No newline at end of file +{include file='user/footer.tpl'} From 4abff69199185ee268560fd161663f1180d5bc59 Mon Sep 17 00:00:00 2001 From: LI JIAHAO Date: Thu, 5 Jul 2018 22:04:32 +0800 Subject: [PATCH 04/11] :sparkles: add ssr and v2ray support Signed-off-by: LI JIAHAO --- app/Command/XCat.php | 29 ++ app/Controllers/Admin/NodeController.php | 51 ++- app/Controllers/Admin/UserController.php | 32 +- app/Controllers/AuthController.php | 10 +- app/Controllers/MuV2/NodeController.php | 33 +- app/Controllers/UserController.php | 230 ++++++++++- app/Models/Node.php | 75 +++- app/Models/User.php | 41 +- app/Services/V2RayGenerator.php | 85 ++++ app/Utils/EmptyClass.php | 7 + app/routes.php | 8 + bootstrap/app.php | 2 +- db-testing.sql | 19 + db.sql | 19 + resources/views/default/admin/node/create.tpl | 197 +++++++++- resources/views/default/admin/node/edit.tpl | 207 +++++++++- resources/views/default/admin/node/index.tpl | 6 + resources/views/default/admin/user/edit.tpl | 118 +++++- resources/views/default/admin/user/index.tpl | 12 + resources/views/default/user/edit.tpl | 252 +++++++++++- resources/views/default/user/index.tpl | 12 + resources/views/default/user/node.tpl | 42 +- resources/views/default/user/nodeinfo.tpl | 364 +++++++++++++----- 23 files changed, 1705 insertions(+), 146 deletions(-) create mode 100644 app/Services/V2RayGenerator.php create mode 100644 app/Utils/EmptyClass.php diff --git a/app/Command/XCat.php b/app/Command/XCat.php index c735a2d8a..b85617d30 100644 --- a/app/Command/XCat.php +++ b/app/Command/XCat.php @@ -29,6 +29,8 @@ public function boot() return $this->install(); case("createAdmin"): return $this->createAdmin(); + case("initV2ray"): + return $this->initV2ray(); case("resetTraffic"): return $this->resetTraffic(); case("sendDiaryMail"): @@ -77,17 +79,42 @@ public function createAdmin() $user->invite_num = Config::get('inviteNum'); $user->ref_by = 0; $user->is_admin = 1; + $user->v2ray_uuid = Tools::genUUID(); + $user->v2ray_level = 2; + $user->v2ray_alter_id = 64; if ($user->save()) { echo "Successful/添加成功!"; + return true; } echo "添加失败"; + return false; } echo "cancel"; + return false; } + public function initV2ray() + { + try { + $users = User::all(); + foreach ($users as $user) { + if (strlen($user->v2ray_uuid) == 0) { + $user->v2ray_uuid = Tools::genUUID(); + $user->save(); + } + } + } catch (\Exception $e) { + echo $e->getMessage(); + + return false; + } + echo "完成!"; + return true; + } + public function resetTraffic() { try { @@ -97,8 +124,10 @@ public function resetTraffic() ]); } catch (\Exception $e) { echo $e->getMessage(); + return false; } + return "reset traffic successful"; } } \ No newline at end of file diff --git a/app/Controllers/Admin/NodeController.php b/app/Controllers/Admin/NodeController.php index 15f716f05..971a9957c 100644 --- a/app/Controllers/Admin/NodeController.php +++ b/app/Controllers/Admin/NodeController.php @@ -16,7 +16,16 @@ public function index($request, $response, $args) public function create($request, $response, $args) { $method = Node::getCustomerMethod(); - return $this->view()->assign('method', $method)->display('admin/node/create.tpl'); + $ssrmethod = Node::getSSRMethod(); + $protocol = Node::getProtocolMethod(); + $obfs = Node::getObfsMethod(); + $v2rayprotocol = Node::getV2rayProtocol(); + return $this->view()->assign('method', $method) + ->assign('ssrmethod', $ssrmethod) + ->assign('protocol', $protocol) + ->assign('obfs', $obfs) + ->assign('v2rayprotocol', $v2rayprotocol) + ->display('admin/node/create.tpl'); } public function add($request, $response, $args) @@ -26,11 +35,25 @@ public function add($request, $response, $args) $node->server = $request->getParam('server'); $node->method = $request->getParam('method'); $node->custom_method = $request->getParam('custom_method'); + $node->custom_rss = $request->getParam('custom_rss'); $node->traffic_rate = $request->getParam('rate'); $node->info = $request->getParam('info'); $node->type = $request->getParam('type'); $node->status = $request->getParam('status'); + $node->ss = $request->getParam('ss'); + $node->ssr = $request->getParam('ssr'); $node->sort = $request->getParam('sort'); + $node->protocol = $request->getParam('protocol'); + $node->protocol_param = $request->getParam('protocol_param'); + $node->obfs = $request->getParam('obfs'); + $node->obfs_param = $request->getParam('obfs_param'); + $node->ssr_port = $request->getParam('ssr_port'); + $node->add_port_only = $request->getParam('add_port_only'); + $node->add_method = $request->getParam('add_method'); + $node->add_passwd = $request->getParam('add_passwd'); + $node->v2ray = $request->getParam('v2ray'); + $node->v2ray_port = $request->getParam('v2ray_port'); + $node->v2ray_protocol = $request->getParam('v2ray_protocol'); if (!$node->save()) { $rs['ret'] = 0; $rs['msg'] = "添加失败"; @@ -49,7 +72,17 @@ public function edit($request, $response, $args) } $method = Node::getCustomerMethod(); - return $this->view()->assign('node', $node)->assign('method', $method)->display('admin/node/edit.tpl'); + $ssrmethod = Node::getSSRMethod(); + $protocol = Node::getProtocolMethod(); + $obfs = Node::getObfsMethod(); + $v2rayprotocol = Node::getV2rayProtocol(); + return $this->view()->assign('node', $node) + ->assign('method', $method) + ->assign('ssrmethod', $ssrmethod) + ->assign('protocol', $protocol) + ->assign('obfs', $obfs) + ->assign('v2rayprotocol', $v2rayprotocol) + ->display('admin/node/edit.tpl'); } public function update($request, $response, $args) @@ -61,11 +94,25 @@ public function update($request, $response, $args) $node->server = $request->getParam('server'); $node->method = $request->getParam('method'); $node->custom_method = $request->getParam('custom_method'); + $node->custom_rss = $request->getParam('custom_rss'); $node->traffic_rate = $request->getParam('rate'); $node->info = $request->getParam('info'); $node->type = $request->getParam('type'); $node->status = $request->getParam('status'); + $node->ss = $request->getParam('ss'); + $node->ssr = $request->getParam('ssr'); $node->sort = $request->getParam('sort'); + $node->protocol = $request->getParam('protocol'); + $node->protocol_param = $request->getParam('protocol_param'); + $node->obfs = $request->getParam('obfs'); + $node->obfs_param = $request->getParam('obfs_param'); + $node->ssr_port = $request->getParam('ssr_port'); + $node->add_port_only = $request->getParam('add_port_only'); + $node->add_method = $request->getParam('add_method'); + $node->add_passwd = $request->getParam('add_passwd'); + $node->v2ray = $request->getParam('v2ray'); + $node->v2ray_port = $request->getParam('v2ray_port'); + $node->v2ray_protocol = $request->getParam('v2ray_protocol'); if (!$node->save()) { $rs['ret'] = 0; $rs['msg'] = "修改失败"; diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index 4402e2c01..e48ad4c4b 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -3,8 +3,8 @@ namespace App\Controllers\Admin; use App\Controllers\AdminController; -use App\Models\User; use App\Models\Node; +use App\Models\User; use App\Utils\Hash; use App\Utils\Tools; @@ -29,7 +29,11 @@ public function edit($request, $response, $args) } $method = Node::getCustomerMethod(); - return $this->view()->assign('user', $user)->assign('method', $method)->display('admin/user/edit.tpl'); + $protocol = Node::getProtocolMethod(); + $obfs = Node::getObfsMethod(); + + return $this->view()->assign('user', $user)->assign('method', $method) + ->assign('protocol', $protocol)->assign('obfs', $obfs)->display('admin/user/edit.tpl'); } public function update($request, $response, $args) @@ -49,6 +53,12 @@ public function update($request, $response, $args) $user->transfer_enable = Tools::toGB($request->getParam('transfer_enable')); $user->invite_num = $request->getParam('invite_num'); $user->method = $request->getParam('method'); + $user->protocol = $request->getParam('method'); + $user->protocol_param = $request->getParam('protocol_param'); + $user->obfs = $request->getParam('obfs'); + $user->obfs_param = $request->getParam('obfs_param'); + $user->v2ray_level = $request->getParam('v2ray_level'); + $user->v2ray_alter_id = $request->getParam('v2ray_alter_id'); $user->enable = $request->getParam('enable'); $user->is_admin = $request->getParam('is_admin'); $user->ref_by = $request->getParam('ref_by'); @@ -62,6 +72,24 @@ public function update($request, $response, $args) return $response->getBody()->write(json_encode($rs)); } + public function updateV2rayUUID($request, $response, $args) + { + $id = $args['id']; + $user = User::find($id); + + $user->v2ray_uuid = Tools::genUUID(); + if (!$user->save()) { + $rs['ret'] = 0; + $rs['msg'] = "修改失败"; + + return $response->getBody()->write(json_encode($rs)); + } + $rs['ret'] = 1; + $rs['msg'] = "修改成功"; + + return $response->getBody()->write(json_encode($rs)); + } + public function delete($request, $response, $args) { $id = $args['id']; diff --git a/app/Controllers/AuthController.php b/app/Controllers/AuthController.php index f1e3d9559..d5e585da6 100755 --- a/app/Controllers/AuthController.php +++ b/app/Controllers/AuthController.php @@ -163,6 +163,14 @@ public function registerHandle($request, $response, $args) $user->passwd = Tools::genRandomChar(6); $user->port = Tools::getLastPort() + 1; $user->t = 0; + $user->method = "aes-128-ctr"; + $user->protocol = "auth_aes128_md5"; + $user->protocol_param = ""; + $user->obfs = "tls1.2_ticket_auth"; + $user->obfs_param = "cloudfront.net"; + $user->v2ray_uuid = Tools::genUUID(); + $user->v2ray_level = 2; + $user->v2ray_alter_id = 64; $user->u = 0; $user->d = 0; $user->transfer_enable = Tools::toGB(Config::get('defaultTraffic')); @@ -218,4 +226,4 @@ public function logout($request, $response, $args) return $this->redirect($response, '/auth/login'); } -} \ No newline at end of file +} diff --git a/app/Controllers/MuV2/NodeController.php b/app/Controllers/MuV2/NodeController.php index c032135c8..274c2bfec 100644 --- a/app/Controllers/MuV2/NodeController.php +++ b/app/Controllers/MuV2/NodeController.php @@ -9,6 +9,7 @@ use App\Models\NodeOnlineLog; use App\Models\TrafficLog; use App\Models\User; +use App\Services\V2rayGenerator; use App\Utils\Tools; class NodeController extends BaseController @@ -17,10 +18,21 @@ class NodeController extends BaseController public function users($request, $response, $args) { $users = User::all(); + $data = []; + foreach ($users as $user) { + $user->v2ray_user = [ + "uuid" => $user->v2ray_uuid, + "email" => sprintf("%s@sspanel.xyz", $user->v2ray_uuid), + "alter_id" => $user->v2ray_alter_id, + "level" => $user->v2ray_level, + ]; + array_push($data, $user); + } $res = [ - "msg" => "ok", - "data" => $users + 'msg' => 'ok', + 'data' => $data, ]; + return $this->echoJson($response, $res); } @@ -105,4 +117,21 @@ public function postTraffic($request, $response, $args) ]; return $this->echoJson($response, $res); } + + public function v2rayUsers($request, $response, $args) + { + $node = Node::find($args['id']); + $users = User::all(); + $v = new V2rayGenerator(); + $v->setPort($node->v2ray_port); + foreach ($users as $user) { + if ($user->enable == 0) { + continue; + } + $email = sprintf("%s@sspanel.io", $user->v2ray_uuid); + $v->addUser($user->v2ray_uuid, $user->v2ray_level, $user->v2ray_alter_id, $email); + } + + return $this->echoJson($response, $v->getArr()); + } } \ No newline at end of file diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index d700c1c11..624d25f5a 100755 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -12,6 +12,11 @@ use App\Utils\Hash; use App\Utils\Tools; +function safe_base64_encode($str) +{ + return strtr(rtrim(base64_encode($str), '='), '+/=', + '-_,'); +} /** * HomeController @@ -46,7 +51,9 @@ public function node($request, $response, $args) $msg = DbConfig::get('user-node'); $user = Auth::getUser(); $nodes = Node::where('type', 1)->orderBy('sort')->get(); - return $this->view()->assign('nodes', $nodes)->assign('user', $user)->assign('msg', $msg)->display('user/node.tpl'); + + return $this->view()->assign('nodes', $nodes)->assign('user', $user)->assign('msg', + $msg)->display('user/node.tpl'); } @@ -67,14 +74,157 @@ public function nodeInfo($request, $response, $args) } $json = json_encode($ary); $json_show = json_encode($ary, JSON_PRETTY_PRINT); - $ssurl = $ary['method'] . ":" . $ary['password'] . "@" . $ary['server'] . ":" . $ary['server_port']; - $ssqr = "ss://" . base64_encode($ssurl); + $ssurl = $ary['method'].":".$ary['password']."@".$ary['server'].":".$ary['server_port']; + $ssqr = "ss://".base64_encode($ssurl); - $surge_base = Config::get('baseUrl') . "/downloads/ProxyBase.conf"; + $surge_base = Config::get('baseUrl')."/downloads/ProxyBase.conf"; $surge_proxy = "#!PROXY-OVERRIDE:ProxyBase.conf\n"; $surge_proxy .= "[Proxy]\n"; - $surge_proxy .= "Proxy = custom," . $ary['server'] . "," . $ary['server_port'] . "," . $ary['method'] . "," . $ary['password'] . "," . Config::get('baseUrl') . "/downloads/SSEncrypt.module"; - return $this->view()->assign('json', $json)->assign('json_show', $json_show)->assign('ssqr', $ssqr)->assign('surge_base', $surge_base)->assign('surge_proxy', $surge_proxy)->display('user/nodeinfo.tpl'); + $surge_proxy .= "Proxy = custom,".$ary['server'].",".$ary['server_port'].",".$ary['method'].",".$ary['password'].",".Config::get('baseUrl')."/downloads/SSEncrypt.module"; + + $ss = $node->ss; + $ssr = $node->ssr && !$node->add_port_only; + $ssr_add = $node->ssr && $node->ssr_port != 0; + $v2ray = $node->v2ray; + if ($ssr) { + $aryr['server'] = $node->server; + $aryr['protocol'] = $node->protocol; + $aryr['protocol_param'] = $node->protocol_param; + $aryr['obfs'] = $node->obfs; + $aryr['obfs_param'] = $node->obfs_param; + if ($node->custom_rss) { + $ary['protocol'] = $this->user->protocol; + $aryr['protocol_param'] = $this->user->protocol_param; + $aryr['obfs'] = $this->user->obfs; + $aryr['obfs_param'] = $this->user->obfs_param; + } + $aryr['server_port'] = $this->user->port; + $aryr['password'] = $this->user->passwd; + $aryr['method'] = $this->user->method; + $jsonr = json_encode($aryr); + $jsonr_show = json_encode($aryr, JSON_PRETTY_PRINT); + $ssrurl = $aryr['server'].":".$aryr['server_port'].":".$aryr['protocol'].":".$aryr['method'].":".$aryr['obfs'].":".safe_base64_encode($aryr['password']) + ."/?obfsparam=".safe_base64_encode($aryr['obfs_param'])."&protoparam=".safe_base64_encode($aryr['protocol_param'])."&udpport=1"; + $ssrqr = "ssr://".safe_base64_encode($ssrurl); + } + if ($ssr_add) { + $aryrd['server'] = $node->server; + $aryrd['server_port'] = $node->ssr_port; + $aryrd['password'] = $node->add_passwd; + $aryrd['method'] = $node->add_method; + $aryrd['protocol'] = $node->protocol; + $aryrd['protocol_param'] = strval($this->user->port).":".$this->user->passwd; + $aryrd['obfs'] = $node->obfs; + $aryrd['obfs_param'] = $node->obfs_param; + $jsonrd = json_encode($aryrd); + $jsonrd_show = json_encode($aryrd, JSON_PRETTY_PRINT); + $ssrdurl = $aryrd['server'].":".$aryrd['server_port'].":".$aryrd['protocol'].":".$aryrd['method'].":".$aryrd['obfs'].":".safe_base64_encode($aryrd['password']) + ."/?obfsparam=".safe_base64_encode($aryrd['obfs_param'])."&protoparam=".safe_base64_encode($aryrd['protocol_param'])."&udpport=1"; + $ssrdqr = "ssr://".safe_base64_encode($ssrdurl); + } + if ($v2ray) { + $arr = [ + "inbound" => [ + "port" => 1080, + "listen" => "127.0.0.1", + "protocol" => "socks", + "domainOverride" => ["tls", "http"], + "settings" => [ + "auth" => "noauth", + "udp" => false, + "ip" => "127.0.0.1", + ], + ], + "outbound" => [ + "protocol" => "vmess", + "settings" => [ + "vnext" => [ + [ + "address" => $node->server, + "port" => $node->v2ray_port, + "users" => [ + [ + "id" => $this->user->v2ray_uuid, + "alterId" => $this->user->v2ray_alter_id, + ], + ], + ], + ], + ], + "streamSettings" => [ + "network" => $node->v2ray_protocol + ] + ], + "inboundDetour" => [], + "outboundDetour" => [ + [ + "protocol" => "freedom", + "settings" => null, + "tag" => "direct", + ], + ], + "routing" => [ + "strategy" => "rules", + "settings" => [ + "rules" => [ + [ + "type" => "field", + "ip" => [ + "0.0.0.0/8", + "10.0.0.0/8", + "100.64.0.0/10", + "127.0.0.0/8", + "169.254.0.0/16", + "172.16.0.0/12", + "192.0.0.0/24", + "192.0.2.0/24", + "192.168.0.0/16", + "198.18.0.0/15", + "198.51.100.0/24", + "203.0.113.0/24", + "::1/128", + "fc00::/7", + "fe80::/10", + ], + "outboundTag" => "direct", + ], + ], + ], + ], + ]; + $ng = [ + "add" => $node->server, + "aid" => $this->user->v2ray_alter_id, + "id" => $this->user->v2ray_uuid, + "net" => $node->v2ray_protocol, + "port" => $node->v2ray_port, + "v" => 2, + "ps" => $node->name, + ]; + $jsonv = json_encode($arr); + $jsonv_show = json_encode($arr, JSON_PRETTY_PRINT); + $ngqr = "vmess://".base64_encode(json_encode($ng)); + } + + $user = Auth::getUser(); + if ($user->enable) { + $temp = $this->view()->assign('ss', $ss)->assign('ssr', $ssr)->assign('ssr_add', $ssr_add)->assign('v2ray', $v2ray) + ->assign('json', $json)->assign('json_show', $json_show)->assign('ssqr', $ssqr) + ->assign('surge_base', $surge_base)->assign('surge_proxy', $surge_proxy); + if ($ssr) { + $temp = $temp->assign('jsonr', $jsonr)->assign('jsonr_show', $jsonr_show)->assign('ssrqr', $ssrqr); + } + if ($ssr_add) { + $temp = $temp->assign('jsonrd', $jsonrd)->assign('jsonrd_show', $jsonrd_show)->assign('ssrdqr', $ssrdqr); + } + if ($v2ray) { + $temp = $temp->assign('jsonv', $jsonv)->assign('jsonv_show', $jsonv_show)->assign('ngqr', $ngqr); + } + + return $temp->display('user/nodeinfo.tpl'); + } else { + return $this->redirect($response, '/user'); + } } public function profile($request, $response, $args) @@ -85,7 +235,11 @@ public function profile($request, $response, $args) public function edit($request, $response, $args) { $method = Node::getCustomerMethod(); - return $this->view()->assign('method', $method)->display('user/edit.tpl'); + $protocol = Node::getProtocolMethod(); + $obfs = Node::getObfsMethod(); + + return $this->view()->assign('method', $method)->assign('protocol', $protocol)->assign('obfs', + $obfs)->display('user/edit.tpl'); } @@ -175,6 +329,68 @@ public function updateMethod($request, $response, $args) $method = strtolower($method); $user->updateMethod($method); $res['ret'] = 1; + + return $this->echoJson($response, $res); + } + + public function updateProtocol($request, $response, $args) + { + $user = Auth::getUser(); + $protocol = $request->getParam('protocol'); + $protocol = strtolower($protocol); + $user->updateProtocol($protocol); + $res['ret'] = 1; + + return $this->echoJson($response, $res); + } + + public function updateProtocolParam($request, $response, $args) + { + $user = Auth::getUser(); + $param = $request->getParam('protocol-param'); + $user->updateProtocolParam($param); + $res['ret'] = 1; + + return $this->echoJson($response, $res); + } + + public function updateObfs($request, $response, $args) + { + $user = Auth::getUser(); + $obfs = $request->getParam('obfs'); + $obfs = strtolower($obfs); + $user->updateObfs($obfs); + $res['ret'] = 1; + + return $this->echoJson($response, $res); + } + + public function updateObfsParam($request, $response, $args) + { + $user = Auth::getUser(); + $param = $request->getParam('obfs-param'); + $user->updateObfsParam($param); + $res['ret'] = 1; + + return $this->echoJson($response, $res); + } + + public function updateV2rayUUID($request, $response, $args) + { + $user = Auth::getUser(); + $user->updateV2rayUUID(); + $res['ret'] = 1; + + return $this->echoJson($response, $res); + } + + public function updateV2rayAlterID($request, $response, $args) + { + $user = Auth::getUser(); + $param = $request->getParam('v2ray-alterid'); + $user->updateV2rayAlterID($param); + $res['ret'] = 1; + return $this->echoJson($response, $res); } diff --git a/app/Models/Node.php b/app/Models/Node.php index efefa8571..d8ee89925 100755 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -74,6 +74,36 @@ function getTrafficFromLogs() public static function getCustomerMethod() { return [ + "aes-128-gcm" => "aes-128-gcm", + "aes-192-gcm" => "aes-192-gcm", + "aes-256-gcm" => "aes-256-gcm", + "chacha20-ietf-poly1305" => "chacha20-ietf-poly1305", + "chacha20-ietf" => "chacha20-ietf", + "salsa20" => "salsa20", + "chacha20" => "chacha20", + "aes-128-cfb" => "aes-128-cfb", + "aes-192-cfb" => "aes-192-cfb", + "aes-256-cfb" => "aes-256-cfb", + "aes-128-ctr" => "aes-128-ctr", + "aes-192-ctr" => "aes-192-ctr", + "aes-256-ctr" => "aes-256-ctr", + "camellia-128-cfb" => "camellia-128-cfb", + "camellia-192-cfb" => "camellia-192-cfb", + "camellia-256-cfb" => "camellia-256-cfb", + "bf-cfb" => "bf-cfb", + "rc4-md5" => "rc4-md5", + "rc4" => "rc4", + "table" => "table", + "none" => "none", + ]; + } + + public static function getSSRMethod() + { + return [ + "none" => "none", + "table" => "table", + "rc4" => "rc4", "rc4-md5" => "rc4-md5", "aes-128-cfb" => "aes-128-cfb", "aes-192-cfb" => "aes-192-cfb", @@ -81,19 +111,52 @@ public static function getCustomerMethod() "aes-128-ctr" => "aes-128-ctr", "aes-192-ctr" => "aes-192-ctr", "aes-256-ctr" => "aes-256-ctr", - "des-cfb" => "des-cfb", "bf-cfb" => "bf-cfb", - "cast5-cfb" => "cast5-cfb", "camellia-128-cfb" => "camellia-128-cfb", "camellia-192-cfb" => "camellia-192-cfb", "camellia-256-cfb" => "camellia-256-cfb", "chacha20" => "chacha20", "salsa20" => "salsa20", "chacha20-ietf" => "chacha20-ietf", - "aes-128-gcm" => "aes-128-gcm", - "aes-192-gcm" => "aes-192-gcm", - "aes-256-gcm" => "aes-256-gcm", - "chacha20-ietf-poly1305" => "chacha20-ietf-poly1305", + ]; + } + + public static function getProtocolMethod() + { + return [ + "origin" => "origin", + "verify_sha1" => "verify_sha1", + "auth_sha1" => "auth_sha1", + "auth_sha1_v2" => "auth_sha1_v2", + "auth_sha1_v4" => "auth_sha1_v4", + "auth_aes128_sha1" => "auth_aes128_sha1", + "auth_aes128_md5" => "auth_aes128_md5", + "auth_chain_a" => "auth_chain_a", + "auth_chain_b" => "auth_chain_b", + "auth_chain_c" => "auth_chain_c", + "auth_chain_d" => "auth_chain_d", + "auth_chain_e" => "auth_chain_e", + "auth_chain_f" => "auth_chain_f" + ]; + } + + public static function getObfsMethod() + { + return [ + "plain" => "plain", + "http_simple" => "http_simple", + "http_post" => "http_post", + "random_head" => "random_head", + "tls1.2_ticket_auth" => "tls1.2_ticket_auth" + ]; + } + + public static function getV2rayProtocol() + { + return [ + "TCP" => "tcp", + "mKCP" => "kcp", + "WebSocket" => "ws", ]; } } diff --git a/app/Models/User.php b/app/Models/User.php index 4046cffc5..afdbc17cc 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -87,6 +87,42 @@ public function updateMethod($method) $this->save(); } + public function updateProtocol($protocol) + { + $this->protocol = $protocol; + $this->save(); + } + + public function updateProtocolParam($protocol_param) + { + $this->protocol_param = $protocol_param; + $this->save(); + } + + public function updateObfs($obfs) + { + $this->obfs = $obfs; + $this->save(); + } + + public function updateObfsParam($obfs_param) + { + $this->obfs_param = $obfs_param; + $this->save(); + } + + public function updateV2rayUUID() + { + $this->v2ray_uuid = Tools::genUUID(); + $this->save(); + } + + public function updateV2rayAlterID($alter_id) + { + $this->v2ray_alter_id = $alter_id; + $this->save(); + } + public function addInviteCode() { $uid = $this->attributes['id']; @@ -167,10 +203,9 @@ public function inviteCodes() public function expireTime() { $expire = $this->attributes['expire_time']; - if($expire === 0){ + if ($expire === 0) { return '永不过期'; - } - else{ + } else { return date('Y-m-d', $expire); } } diff --git a/app/Services/V2RayGenerator.php b/app/Services/V2RayGenerator.php new file mode 100644 index 000000000..b64f75e88 --- /dev/null +++ b/app/Services/V2RayGenerator.php @@ -0,0 +1,85 @@ + [ + "access" => "/var/log/access.log", + "error" => "/var/log/error.log", + "loglevel" => "warning" + ], + "inbound" => [ + "port" => 8300, + "protocol" => "vmess", + "settings" => [ + "clients" => [ + ] + ] + ], + "outbound" => [ + "protocol" => "freedom", + // "settings" => , + ], + "inboundDetour" => [], + "outboundDetour" => [ + [ + "protocol" => "blackhole", + // "settings" => [], + "tag" => "blocked" + ] + ], + "routing" => [ + "strategy" => "rules", + "settings" => [ + "rules" => [ + [ + "type" => "field", + "ip" => [ + "0.0.0.0/8", + "10.0.0.0/8", + "100.64.0.0/10", + "127.0.0.0/8", + "169.254.0.0/16", + "172.16.0.0/12", + "192.0.0.0/24", + "192.0.2.0/24", + "192.168.0.0/16", + "198.18.0.0/15", + "198.51.100.0/24", + "203.0.113.0/24", + "::1/128", + "fc00::/7", + "fe80::/10" + ], + "outboundTag" => "blocked" + ] + ] + ] + ] + ]; + public function addUser($uuid, $level, $alertId, $email) + { + $user = [ + "id" => $uuid, + "level" => $level, + "alterId" => $alertId, + "email" => $email + ]; + array_push($this->arr["inbound"]['settings']['clients'], $user); + } + public function setPort($port) + { + $this->arr['inbound']['port'] = $port; + } + public function getArr() + { + return $this->arr; + } + public function __construct() + { + $this->arr["outbound"]["settings"] = new EmptyClass(); + $this->arr["outboundDetour"][0]["settings"] = new EmptyClass(); + } +} \ No newline at end of file diff --git a/app/Utils/EmptyClass.php b/app/Utils/EmptyClass.php new file mode 100644 index 000000000..d5cac0900 --- /dev/null +++ b/app/Utils/EmptyClass.php @@ -0,0 +1,7 @@ +post('/password', 'App\Controllers\UserController:updatePassword'); $this->post('/sspwd', 'App\Controllers\UserController:updateSsPwd'); $this->post('/method', 'App\Controllers\UserController:updateMethod'); + $this->post('/protocol', 'App\Controllers\UserController:updateProtocol'); + $this->post('/protocol-param', 'App\Controllers\UserController:updateProtocolParam'); + $this->post('/obfs', 'App\Controllers\UserController:updateObfs'); + $this->post('/obfs-param', 'App\Controllers\UserController:updateObfsParam'); + $this->post('/v2ray-uuid', 'App\Controllers\UserController:updateV2rayUUID'); + $this->post('/v2ray-alterid', 'App\Controllers\UserController:updateV2rayAlterID'); $this->get('/sys', 'App\Controllers\UserController:sys'); $this->get('/trafficlog', 'App\Controllers\UserController:trafficLog'); $this->get('/trafficlog/{nid}', 'App\Controllers\UserController:trafficLog'); @@ -105,6 +111,7 @@ $this->get('/user', 'App\Controllers\Admin\UserController:index'); $this->get('/user/{id}/edit', 'App\Controllers\Admin\UserController:edit'); $this->put('/user/{id}', 'App\Controllers\Admin\UserController:update'); + $this->patch('/user/{id}/v2ray-uuid', 'App\Controllers\Admin\UserController:updateV2rayUUID'); $this->delete('/user/{id}', 'App\Controllers\Admin\UserController:delete'); $this->get('/user/{id}/delete', 'App\Controllers\Admin\UserController:deleteGet'); @@ -139,6 +146,7 @@ $this->get('/users', 'App\Controllers\MuV2\UserController:index'); $this->post('/users/{id}/traffic', 'App\Controllers\MuV2\UserController:addTraffic'); $this->get('/nodes/{id}/users', 'App\Controllers\MuV2\NodeController:users'); + $this->get('/nodes/{id}/v2rayUsers', 'App\Controllers\MuV2\NodeController:v2rayUsers'); $this->post('/nodes/{id}/online_count', 'App\Controllers\MuV2\NodeController:onlineUserLog'); $this->post('/nodes/{id}/info', 'App\Controllers\MuV2\NodeController:info'); $this->post('/nodes/{id}/traffic', 'App\Controllers\MuV2\NodeController:postTraffic'); diff --git a/bootstrap/app.php b/bootstrap/app.php index 8acf87ad0..6777b28f1 100755 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -11,7 +11,7 @@ // BASE_PATH define('BASE_PATH', __DIR__ . '/../'); -define('VERSION', '3.4.6'); +define('VERSION', '3.5.0'); // Vendor Autoload require BASE_PATH . '/vendor/autoload.php'; diff --git a/db-testing.sql b/db-testing.sql index f5c52e4d0..a25d50aa0 100644 --- a/db-testing.sql +++ b/db-testing.sql @@ -60,11 +60,25 @@ CREATE TABLE `ss_node` ( `server` varchar(128) NOT NULL, `method` varchar(64) NOT NULL, `custom_method` tinyint(1) NOT NULL DEFAULT '0', + `custom_rss` tinyint(1) NOT NULL DEFAULT '0', `traffic_rate` float NOT NULL DEFAULT '1', `info` varchar(128) NOT NULL, `status` varchar(128) NOT NULL, `offset` int(11) NOT NULL DEFAULT '0', `sort` int(3) NOT NULL, + `ss` tinyint(4) NOT NULL DEFAULT '0', + `ssr` tinyint(4) NOT NULL DEFAULT '0', + `protocol` varchar(64), + `protocol_param` varchar(128), + `obfs` varchar(64), + `obfs_param` varchar(128), + `ssr_port` int(11) NOT NULL DEFAULT '0', + `add_port_only` tinyint(1) NOT NULL DEFAULT '0', + `add_method` varchar(64), + `add_passwd` varchar(16), + `v2ray` tinyint(4) NOT NULL DEFAULT '0', + `v2ray_port` int(11) NOT NULL DEFAULT '8100', + `v2ray_protocol` varchar(64) NOT NULL DEFAULT 'tcp', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; @@ -116,7 +130,12 @@ CREATE TABLE `user` ( `transfer_enable` bigint(20) NOT NULL, `port` int(11) NOT NULL, `protocol` varchar(32) NOT NULL DEFAULT 'origin', + `protocol_param` varchar(128) NULL DEFAULT NULL, `obfs` varchar(32) NOT NULL DEFAULT 'plain', + `obfs_param` varchar(128) NULL DEFAULT NULL, + `v2ray_uuid` varchar(36) NULL DEFAULT '', + `v2ray_level` int(8) NOT NULL DEFAULT '2', + `v2ray_alter_id` int(8) NOT NULL DEFAULT '64', `switch` tinyint(4) NOT NULL DEFAULT '1', `enable` tinyint(4) NOT NULL DEFAULT '1', `type` tinyint(4) NOT NULL DEFAULT '1', diff --git a/db.sql b/db.sql index 0a08d7958..bba8f7812 100644 --- a/db.sql +++ b/db.sql @@ -44,11 +44,25 @@ CREATE TABLE `ss_node` ( `server` varchar(128) NOT NULL, `method` varchar(64) NOT NULL, `custom_method` tinyint(1) NOT NULL DEFAULT '0', + `custom_rss` tinyint(1) NOT NULL DEFAULT '0', `traffic_rate` float NOT NULL DEFAULT '1', `info` varchar(128) NOT NULL, `status` varchar(128) NOT NULL, `offset` int(11) NOT NULL DEFAULT '0', `sort` int(3) NOT NULL, + `ss` tinyint(4) NOT NULL DEFAULT '0', + `ssr` tinyint(4) NOT NULL DEFAULT '0', + `protocol` varchar(64), + `protocol_param` varchar(128), + `obfs` varchar(64), + `obfs_param` varchar(128), + `ssr_port` int(11) NOT NULL DEFAULT '0', + `add_port_only` tinyint(1) NOT NULL DEFAULT '0', + `add_method` varchar(64), + `add_passwd` varchar(16), + `v2ray` tinyint(4) NOT NULL DEFAULT '0', + `v2ray_port` int(11) NOT NULL DEFAULT '8100', + `v2ray_protocol` varchar(64) NOT NULL DEFAULT 'tcp', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; @@ -98,7 +112,12 @@ CREATE TABLE `user` ( `transfer_enable` bigint(20) NOT NULL, `port` int(11) NOT NULL, `protocol` varchar(32) NOT NULL DEFAULT 'origin', + `protocol_param` varchar(128) NULL DEFAULT NULL, `obfs` varchar(32) NOT NULL DEFAULT 'plain', + `obfs_param` varchar(128) NULL DEFAULT NULL, + `v2ray_uuid` varchar(36) NULL DEFAULT '', + `v2ray_level` int(8) NOT NULL DEFAULT '2', + `v2ray_alter_id` int(8) NOT NULL DEFAULT '64', `switch` tinyint(4) NOT NULL DEFAULT '1', `enable` tinyint(4) NOT NULL DEFAULT '1', `type` tinyint(4) NOT NULL DEFAULT '1', diff --git a/resources/views/default/admin/node/create.tpl b/resources/views/default/admin/node/create.tpl index 4726cceaa..9fe96a414 100755 --- a/resources/views/default/admin/node/create.tpl +++ b/resources/views/default/admin/node/create.tpl @@ -36,6 +36,42 @@
+
+ 描述信息 +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+
+ + +
+ +
+
+
连接信息
@@ -72,7 +108,6 @@
-
@@ -97,38 +132,160 @@
- 描述信息 + SS 特性
- +
- + +
+ SSR 特性
- +
- +
- +
- + +

+ 单端口多用户模式该项无效。 +

+
- +
- + +
+
+ +
+ + +
+ +

+ 在 auth_chain_* 协议中表示最多允许同时连接的客户端数。 +

+
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +

+ 设置该项为 0 为多端口多用户模式,填入端口号来启用单端口多用户模式。 +

+
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+
+ V2Ray 特性 +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+
@@ -161,11 +318,25 @@ server: $("#server").val(), method: $("#method").val(), custom_method: $("#custom_method").val(), + custom_rss: $("#custom_rss").val(), rate: $("#rate").val(), info: $("#info").val(), type: $("#type").val(), status: $("#status").val(), - sort: $("#sort").val() + sort: $("#sort").val(), + ss: $("#ss").val(), + ssr: $("#ssr").val(), + protocol: $("#protocol").val(), + protocol_param: $("#protocol_param").val(), + obfs: $("#obfs").val(), + obfs_param: $("#obfs_param").val(), + ssr_port: $("#ssr_port").val(), + add_port_only: $("#add_port_only").val(), + add_method: $("#add_method").val(), + add_passwd: $("#add_passwd").val(), + v2ray: $("#v2ray").val(), + v2ray_port: $("#v2ray_port").val(), + v2ray_protocol: $("#v2ray_protocol").val(), }, success: function (data) { if (data.ret) { diff --git a/resources/views/default/admin/node/edit.tpl b/resources/views/default/admin/node/edit.tpl index d5e978b97..a2a3a35c6 100755 --- a/resources/views/default/admin/node/edit.tpl +++ b/resources/views/default/admin/node/edit.tpl @@ -36,6 +36,45 @@
+
+ 描述信息 +
+ + +
+ +
+
+ + +
+ + +
+ +
+
+ +
+ + +
+ +
+
+
+ + +
+ +
+
+
连接信息
@@ -60,9 +99,9 @@
+
@@ -96,41 +135,163 @@
- 描述信息 + SS 特性
- +
- + +
+ SSR 特性 +
+ + +
+ +
+
- +
- + +

+ 单端口多用户模式该项无效。 +

- +
- +
+
- +
- + +

+ 在 auth_chain_* 协议中表示最多允许同时连接的客户端数。 +

+
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +

+ 设置该项为 0 为多端口多用户模式,填入端口号来启用单端口多用户模式。 +

+
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+
+ V2Ray 特性 +
+ + +
+ +
+
+ +
+ + +
+ +
+
+ +
+ + +
+
@@ -162,11 +323,25 @@ server: $("#server").val(), method: $("#method").val(), custom_method: $("#custom_method").val(), + custom_rss: $("#custom_rss").val(), rate: $("#rate").val(), info: $("#info").val(), type: $("#type").val(), status: $("#status").val(), - sort: $("#sort").val() + sort: $("#sort").val(), + ss: $("#ss").val(), + ssr: $("#ssr").val(), + protocol: $("#protocol").val(), + protocol_param: $("#protocol_param").val(), + obfs: $("#obfs").val(), + obfs_param: $("#obfs_param").val(), + ssr_port: $("#ssr_port").val(), + add_port_only: $("#add_port_only").val(), + add_method: $("#add_method").val(), + add_passwd: $("#add_passwd").val(), + v2ray: $("#v2ray").val(), + v2ray_port: $("#v2ray_port").val(), + v2ray_protocol: $("#v2ray_protocol").val(), }, success: function (data) { if (data.ret) { diff --git a/resources/views/default/admin/node/index.tpl b/resources/views/default/admin/node/index.tpl index 8c3e738e4..3e160f028 100755 --- a/resources/views/default/admin/node/index.tpl +++ b/resources/views/default/admin/node/index.tpl @@ -23,6 +23,9 @@ 节点 加密 描述 + SS + SSR + V2Ray 排序 操作 @@ -32,6 +35,9 @@ {$node->name} {$node->method} {$node->info} + {$node->ss} + {$node->ssr} + {$node->v2ray} {$node->sort} 编辑 diff --git a/resources/views/default/admin/user/edit.tpl b/resources/views/default/admin/user/edit.tpl index e93f38228..a2d91a987 100644 --- a/resources/views/default/admin/user/edit.tpl +++ b/resources/views/default/admin/user/edit.tpl @@ -120,6 +120,90 @@
+ +
+ + +
+
+ +
+
+
+ +
+ + +
+
+ +
+

+ 在 auth_chain_* 协议中表示最多允许同时连接的客户端数。 +

+
+
+ +
+ + +
+
+ +
+
+
+ +
+ + +
+
+ +
+
+
+ +
+ + +
+
+ +
+ +
+
+
+
+ +
+ + +
+
+ +
+
+
+ +
+ + +
+
+ +
+
+
@@ -201,6 +285,12 @@ transfer_enable: $("#transfer_enable").val(), invite_num: $("#invite_num").val(), method: $("#method").val(), + protocol: $("#protocol").val(), + protocol_param: $("#protocol_param").val(), + obfs: $("#obfs").val(), + obfs_param: $("#obfs_param").val(), + v2ray_level: $("#v2ray-level").val(), + v2ray_alter_id: $("#v2ray-alterid").val(), enable: $("#enable").val(), is_admin: $("#is_admin").val(), ref_by: $("#ref_by").val() @@ -224,7 +314,30 @@ } }); } - + function submit_v2ray_uuid() { + $.ajax({ + type: "PATCH", + url: "/admin/user/{$user->id}/v2ray-uuid", + dataType: "json", + success: function (data) { + if (data.ret) { + $("#msg-error").hide(100); + $("#msg-success").show(100); + $("#msg-success-p").html(data.msg); + window.setTimeout("history.go(0)", 1000); + } else { + $("#msg-error").hide(10); + $("#msg-error").show(100); + $("#msg-error-p").html(data.msg); + } + }, + error: function (jqXHR) { + $("#msg-error").hide(10); + $("#msg-error").show(100); + $("#msg-error-p").html("发生错误:" + jqXHR.status); + } + }); + } $("html").keydown(function (event) { if (event.keyCode == 13) { login(); @@ -233,6 +346,9 @@ $("#submit").click(function () { submit(); }); + $("#v2ray-uuid-update").click(function () { + submit_v2ray_uuid(); + }); $("#ok-close").click(function () { $("#msg-success").hide(100); }); diff --git a/resources/views/default/admin/user/index.tpl b/resources/views/default/admin/user/index.tpl index 982c5110f..fae899ce2 100644 --- a/resources/views/default/admin/user/index.tpl +++ b/resources/views/default/admin/user/index.tpl @@ -40,6 +40,12 @@ 端口 状态 加密方式 + 协议插件 + 协议参数 + 混淆插件 + 混淆参数 + V2Ray Level + V2Ray AlterID 已用流量/总流量 最后在线时间 最后签到时间 @@ -55,6 +61,12 @@ {$user->port} {$user->enable} {$user->method} + {$user->protocol} + {$user->protocol_param} + {$user->obfs} + {$user->obfs_param} + {$user->v2ray_level} + {$user->v2ray_alter_id} {$user->usedTraffic()}/{$user->enableTraffic()} {$user->lastSsTime()} {$user->lastCheckInTime()} diff --git a/resources/views/default/user/edit.tpl b/resources/views/default/user/edit.tpl index 9919ebaa0..9670b2abe 100755 --- a/resources/views/default/user/edit.tpl +++ b/resources/views/default/user/edit.tpl @@ -91,7 +91,7 @@
-

Shadowsocks连接信息修改

+

连接信息修改

@@ -126,6 +126,95 @@
+
+ + +
+
+ +
+ +
+
+
+
+ +
+ + +
+
+ +
+ +
+
+

+ 在 auth_chain_* 协议中表示最多允许同时连接的客户端数。 +

+
+
+ +
+ + +
+
+ +
+ +
+
+
+
+ +
+ + +
+
+ +
+ +
+
+
+
+ +
+ + +
+
+ +
+ +
+
+
+
+ +
+ + +
+
+ +
+ +
+
+
+
+
@@ -231,5 +320,166 @@ }) + + + + + + + + + + + + {include file='user/footer.tpl'} \ No newline at end of file diff --git a/resources/views/default/user/index.tpl b/resources/views/default/user/index.tpl index 51d59935f..f0e642f6a 100755 --- a/resources/views/default/user/index.tpl +++ b/resources/views/default/user/index.tpl @@ -109,6 +109,18 @@
{$user->passwd}
自定义加密方式
{$user->method}
+
自定义协议插件
+
{$user->protocol}
+
自定义协议参数
+
{$user->protocol_param}
+
混淆插件
+
{$user->obfs}
+
混淆参数
+
{$user->obfs_param}
+
V2Ray UUID
+
{$user->v2ray_uuid}
+
V2Ray Alter ID
+
{$user->v2ray_alter_id}
上次使用
{$user->lastSsTime()}
diff --git a/resources/views/default/user/node.tpl b/resources/views/default/user/node.tpl index 25b2db1ac..648d24313 100755 --- a/resources/views/default/user/node.tpl +++ b/resources/views/default/user/node.tpl @@ -55,9 +55,32 @@
  • 加密方式 {if $node->custom_method == 1} {$user->method} {else} {$node->method} {/if}
  • -
  • 负载: {$node->getNodeLoad()} -
  • + {if $node->ssr} +
  • 连接协议: {if $node->custom_rss == 1 && $node->ssr_port == 0} {$user->protocol} {else} {$node->protocol} {/if} +
  • +
  • 连接端口: {if $node->ssr_port == 0} {$user->port} {else} {$node->ssr_port} {/if} +
  • + {if $node->v2ray} +
  • 负载: {$node->getNodeLoad()} +
  • + {/if} + {else} + {if $node->v2ray} +
  • 连接端口: {$node->v2ray_port} +
  • +
  • V2Ray UUID: {$user->v2ray_uuid} +
  • + {else} +
  • 负载: {$node->getNodeLoad()} +
  • + {/if} + {/if}
    @@ -71,9 +94,22 @@
  • 产生流量 {$node->getTrafficFromLogs()}
  • + {if $node->ssr && $node->v2ray} +
  • 连接端口: {$node->v2ray_port} +
  • +
  • V2Ray UUID: {$user->v2ray_uuid} +
  • + {/if}
  • Uptime: {$node->getNodeUptime()}
  • + {if $node->ssr ^ $node->v2ray} +
  • 负载: {$node->getNodeLoad()} +
  • + {/if}
    diff --git a/resources/views/default/user/nodeinfo.tpl b/resources/views/default/user/nodeinfo.tpl index 6080a750e..a4d94bfce 100755 --- a/resources/views/default/user/nodeinfo.tpl +++ b/resources/views/default/user/nodeinfo.tpl @@ -18,127 +18,315 @@

    配置文件以及二维码请勿泄露!

    -
    -
    -
    - + {if $ss} +
    +
    +
    + -

    配置Json

    +

    SS 配置Json

    +
    + +
    + +
    + +
    + +
    +
    + + +

    SS 配置地址

    +
    + +
    +
    + +
    + > +
    +
    +
    +
    - -
    - + +
    + +
    +
    +
    + + +

    SS 配置二维码

    +
    + +
    +
    +
    +
    +
    +
    - +
    - -
    -
    - + + {/if} +
    + {if $ssr} +
    +
    +
    +
    + + +

    SSR 配置Json

    +
    + +
    + +
    + +
    + +
    +
    + -

    配置地址

    +

    SSRR 配置地址

    +
    + +
    +
    + +
    + > +
    +
    +
    +
    - -
    -
    - -
    - > + +
    + + +
    +
    +
    + + +

    SSRR 配置二维码

    +
    + +
    +
    +
    +
    - +
    - +
    - + {/if} + {if $ssr_add} +
    +
    +
    +
    + -
    -
    -
    - +

    SSR 配置Json

    +
    + +
    + +
    + +
    + +
    +
    + -

    配置二维码

    +

    SSRR 配置地址

    +
    + +
    +
    + +
    + > +
    +
    +
    +
    - -
    -
    -
    + +
    + + +
    +
    +
    + + +

    SSRR 配置二维码

    + +
    +
    +
    +
    +
    +
    - +
    - +
    - -
    -
    -
    -
    -
    - + {/if} + {if $v2ray} +
    +
    +
    +
    + -

    Surge配置

    +

    V2Ray 配置Json

    +
    + +
    + +
    +
    -
    -
    -
    -

    Surge使用步骤

    - -

    基础配置只需要做一次: -

      -
    1. 打开 Surge ,点击右上角“Edit”,点击“Download Configuration from URL”
    2. -
    3. 输入基础配置的地址(或扫描二维码得到地址,复制后粘贴进来),点击“OK”
    4. -
    5. 注意:基础配置不要改名,不可以直接启用。
    6. -
    -

    -

    代理配置需要根据不同的节点进行添加: -

      -
    1. 点击“New Empty Configuration”
    2. -
    3. 在“NAME”里面输入一个配置文件的名称
    4. -
    5. 点击下方“Edit in Text Mode”
    6. -
    7. 输入代理配置的全部文字(或扫描二维码得到配置,复制后粘贴进来),点击“OK”
    8. -
    9. 直接启用代理配置即可科学上网。
    10. -
    -

    -
    -
    -

    基础配置

    + +
    +
    + -
    -
    +

    v2rayNG 配置地址

    +
    + +
    +
    + +
    + >
    -
    -
    -

    代理配置

    +
    + +
    + +
    + -
    -
    +
    +
    +
    + + +

    v2rayNG 配置二维码

    +
    + +
    +
    +
    +
    +
    + +
    + +
    + +
    + {/if} + {if $ss} +
    +
    +
    +
    + + +

    Surge配置

    +
    +
    +
    +
    +

    Surge使用步骤

    + +

    基础配置只需要做一次: +

      +
    1. 打开 Surge ,点击右上角“Edit”,点击“Download Configuration from URL”
    2. +
    3. 输入基础配置的地址(或扫描二维码得到地址,复制后粘贴进来),点击“OK”
    4. +
    5. 注意:基础配置不要改名,不可以直接启用。
    6. +
    +

    +

    代理配置需要根据不同的节点进行添加: +

      +
    1. 点击“New Empty Configuration”
    2. +
    3. 在“NAME”里面输入一个配置文件的名称
    4. +
    5. 点击下方“Edit in Text Mode”
    6. +
    7. 输入代理配置的全部文字(或扫描二维码得到配置,复制后粘贴进来),点击“OK”
    8. +
    9. 直接启用代理配置即可科学上网。
    10. +
    +

    +
    +
    +

    基础配置

    + +
    +
    +
    + +
    +
    +

    代理配置

    + +
    +
    +
    +
    -
    -
    - + + {/if} From f57db792bd743409036911ecd7d33960a4012914 Mon Sep 17 00:00:00 2001 From: LI JIAHAO Date: Fri, 6 Jul 2018 14:04:01 +0800 Subject: [PATCH 05/11] bugfix and better node display Signed-off-by: LI JIAHAO --- app/Controllers/UserController.php | 2 +- resources/views/default/user/node.tpl | 85 ++++++++++++++------------- 2 files changed, 45 insertions(+), 42 deletions(-) diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 624d25f5a..b6d9a4001 100755 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -93,7 +93,7 @@ public function nodeInfo($request, $response, $args) $aryr['obfs'] = $node->obfs; $aryr['obfs_param'] = $node->obfs_param; if ($node->custom_rss) { - $ary['protocol'] = $this->user->protocol; + $aryr['protocol'] = $this->user->protocol; $aryr['protocol_param'] = $this->user->protocol_param; $aryr['obfs'] = $this->user->obfs; $aryr['obfs_param'] = $this->user->obfs_param; diff --git a/resources/views/default/user/node.tpl b/resources/views/default/user/node.tpl index 648d24313..cc7beb7f8 100755 --- a/resources/views/default/user/node.tpl +++ b/resources/views/default/user/node.tpl @@ -50,51 +50,47 @@
    From 7212ddecce2733e8304f215927a4bbe7f439e3df Mon Sep 17 00:00:00 2001 From: LI JIAHAO Date: Mon, 19 Nov 2018 22:23:47 +0800 Subject: [PATCH 06/11] :beers: add v2ray ws path and tls --- app/Controllers/Admin/NodeController.php | 4 ++++ app/Controllers/UserController.php | 16 +++++++++++++ app/Models/Node.php | 2 ++ db-testing.sql | 2 ++ db.sql | 2 ++ resources/views/default/admin/node/create.tpl | 23 ++++++++++++++++++- resources/views/default/admin/node/edit.tpl | 23 ++++++++++++++++++- 7 files changed, 70 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Admin/NodeController.php b/app/Controllers/Admin/NodeController.php index 971a9957c..d223a320b 100644 --- a/app/Controllers/Admin/NodeController.php +++ b/app/Controllers/Admin/NodeController.php @@ -54,6 +54,8 @@ public function add($request, $response, $args) $node->v2ray = $request->getParam('v2ray'); $node->v2ray_port = $request->getParam('v2ray_port'); $node->v2ray_protocol = $request->getParam('v2ray_protocol'); + $node->v2ray_path = $request->getParam('v2ray_path'); + $node->v2ray_tls = $request->getParam('v2ray_tls'); if (!$node->save()) { $rs['ret'] = 0; $rs['msg'] = "添加失败"; @@ -113,6 +115,8 @@ public function update($request, $response, $args) $node->v2ray = $request->getParam('v2ray'); $node->v2ray_port = $request->getParam('v2ray_port'); $node->v2ray_protocol = $request->getParam('v2ray_protocol'); + $node->v2ray_path = $request->getParam('v2ray_path'); + $node->v2ray_tls = $request->getParam('v2ray_tls'); if (!$node->save()) { $rs['ret'] = 0; $rs['msg'] = "修改失败"; diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index b6d9a4001..ed79d29a9 100755 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -201,6 +201,22 @@ public function nodeInfo($request, $response, $args) "v" => 2, "ps" => $node->name, ]; + if ($node->v2ray_protocol == 'ws') { + $arr['outbound']['streamSettings']['wsSettings'] = [ + 'path' => $node->v2ray_path, + ]; + $ng['path'] = $node->v2ray_path; + } + if ($node->v2ray_protocol == 'http') { + $arr['outbound']['streamSettings']['httpSettings'] = [ + 'path' => $node->v2ray_path, + ]; + $ng['path'] = $node->v2ray_path; + } + if ($node->v2ray_tls) { + $arr['outbound']['streamSettings']['security'] = 'tls'; + $ng['tls'] = 'tls'; + } $jsonv = json_encode($arr); $jsonv_show = json_encode($arr, JSON_PRETTY_PRINT); $ngqr = "vmess://".base64_encode(json_encode($ng)); diff --git a/app/Models/Node.php b/app/Models/Node.php index d8ee89925..50dfab906 100755 --- a/app/Models/Node.php +++ b/app/Models/Node.php @@ -157,6 +157,8 @@ public static function getV2rayProtocol() "TCP" => "tcp", "mKCP" => "kcp", "WebSocket" => "ws", + "HTTP/2" => "http", + "DomainSocket" => "domainsocket", ]; } } diff --git a/db-testing.sql b/db-testing.sql index a25d50aa0..bff765f4e 100644 --- a/db-testing.sql +++ b/db-testing.sql @@ -79,6 +79,8 @@ CREATE TABLE `ss_node` ( `v2ray` tinyint(4) NOT NULL DEFAULT '0', `v2ray_port` int(11) NOT NULL DEFAULT '8100', `v2ray_protocol` varchar(64) NOT NULL DEFAULT 'tcp', + `v2ray_path` varchar(64) NOT NULL DEFAULT '/ray', + `v2ray_tls` int(3) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/db.sql b/db.sql index bba8f7812..c354efd10 100644 --- a/db.sql +++ b/db.sql @@ -63,6 +63,8 @@ CREATE TABLE `ss_node` ( `v2ray` tinyint(4) NOT NULL DEFAULT '0', `v2ray_port` int(11) NOT NULL DEFAULT '8100', `v2ray_protocol` varchar(64) NOT NULL DEFAULT 'tcp', + `v2ray_path` varchar(64) NOT NULL DEFAULT '/ray', + `v2ray_tls` int(3) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/resources/views/default/admin/node/create.tpl b/resources/views/default/admin/node/create.tpl index 9fe96a414..e6e108124 100755 --- a/resources/views/default/admin/node/create.tpl +++ b/resources/views/default/admin/node/create.tpl @@ -278,7 +278,7 @@
    - +
    + +
    + + +
    + +
    +
    + +
    + + +
    + +
    +
    @@ -337,6 +356,8 @@ v2ray: $("#v2ray").val(), v2ray_port: $("#v2ray_port").val(), v2ray_protocol: $("#v2ray_protocol").val(), + v2ray_path: $("#v2ray_path").val(), + v2ray_tls: $("#v2ray_tls").val(), }, success: function (data) { if (data.ret) { diff --git a/resources/views/default/admin/node/edit.tpl b/resources/views/default/admin/node/edit.tpl index a2a3a35c6..7acbba6dc 100755 --- a/resources/views/default/admin/node/edit.tpl +++ b/resources/views/default/admin/node/edit.tpl @@ -281,7 +281,7 @@
    - +
    + +
    + + +
    + +
    +
    + +
    + + +
    + +
    +
    @@ -342,6 +361,8 @@ v2ray: $("#v2ray").val(), v2ray_port: $("#v2ray_port").val(), v2ray_protocol: $("#v2ray_protocol").val(), + v2ray_path: $("#v2ray_path").val(), + v2ray_tls: $("#v2ray_tls").val(), }, success: function (data) { if (data.ret) { From bedf463f43b59b05f8fcf082c24bb2d8b08f0499 Mon Sep 17 00:00:00 2001 From: LI JIAHAO Date: Mon, 19 Nov 2018 22:39:55 +0800 Subject: [PATCH 07/11] :bookmark: tag new version --- bootstrap/app.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap/app.php b/bootstrap/app.php index 6777b28f1..1a9b01be7 100755 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -11,7 +11,7 @@ // BASE_PATH define('BASE_PATH', __DIR__ . '/../'); -define('VERSION', '3.5.0'); +define('VERSION', '3.5.1'); // Vendor Autoload require BASE_PATH . '/vendor/autoload.php'; From a6c1c72ff99a670c0f691724b67bc9f0021ea8c3 Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Mon, 24 Dec 2018 19:56:39 +0800 Subject: [PATCH 08/11] Update Auth.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 退出要清本地cookies,不然依然检索sessions会爆错,这么久没人发现? --- app/Services/Auth.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Services/Auth.php b/app/Services/Auth.php index 60fb05db1..1e4b621e3 100755 --- a/app/Services/Auth.php +++ b/app/Services/Auth.php @@ -69,7 +69,8 @@ public static function getUser() public static function logout() { + Cookie::set(['sid' => ''],0); $sid = Cookie::get('sid'); self::getCache()->del($sid); } -} \ No newline at end of file +} From 927ff21091e6bae55c21d5d8503d300e91958d8e Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Tue, 12 Mar 2019 15:46:49 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=BC=96=E8=BE=91=E7=94=A8=E6=88=B7=20protocol=20?= =?UTF-8?q?=E8=AF=BB=E5=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controllers/Admin/UserController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index e48ad4c4b..b7be54b0d 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -53,7 +53,7 @@ public function update($request, $response, $args) $user->transfer_enable = Tools::toGB($request->getParam('transfer_enable')); $user->invite_num = $request->getParam('invite_num'); $user->method = $request->getParam('method'); - $user->protocol = $request->getParam('method'); + $user->protocol = $request->getParam('protocol'); $user->protocol_param = $request->getParam('protocol_param'); $user->obfs = $request->getParam('obfs'); $user->obfs_param = $request->getParam('obfs_param'); @@ -112,4 +112,4 @@ public function deleteGet($request, $response, $args) $newResponse = $response->withStatus(302)->withHeader('Location', '/admin/user'); return $newResponse; } -} \ No newline at end of file +} From 35af5df7799904564d376070d6f529d99a57c443 Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Wed, 13 Mar 2019 19:28:22 +0800 Subject: [PATCH 10/11] fix user/edit page --- resources/views/default/user/edit.tpl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/resources/views/default/user/edit.tpl b/resources/views/default/user/edit.tpl index 9670b2abe..32e85034f 100755 --- a/resources/views/default/user/edit.tpl +++ b/resources/views/default/user/edit.tpl @@ -148,7 +148,7 @@
    - +
    @@ -181,13 +181,15 @@
    - +
    + +
    @@ -207,7 +209,7 @@
    - +
    @@ -482,4 +484,4 @@ -{include file='user/footer.tpl'} \ No newline at end of file +{include file='user/footer.tpl'} From da241a0a6e0ff88a68b00e7c35bd118783ea11ba Mon Sep 17 00:00:00 2001 From: Cp0204 Date: Wed, 13 Mar 2019 22:08:47 +0800 Subject: [PATCH 11/11] add v2ray-bfv qr --- app/Controllers/UserController.php | 4 +- resources/views/default/user/nodeinfo.tpl | 60 +++++++++++++++-------- 2 files changed, 42 insertions(+), 22 deletions(-) diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index ed79d29a9..df4370a52 100755 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -122,6 +122,7 @@ public function nodeInfo($request, $response, $args) ."/?obfsparam=".safe_base64_encode($aryrd['obfs_param'])."&protoparam=".safe_base64_encode($aryrd['protocol_param'])."&udpport=1"; $ssrdqr = "ssr://".safe_base64_encode($ssrdurl); } + if(empty($this->user->v2ray_uuid)) $v2ray=false; if ($v2ray) { $arr = [ "inbound" => [ @@ -220,6 +221,7 @@ public function nodeInfo($request, $response, $args) $jsonv = json_encode($arr); $jsonv_show = json_encode($arr, JSON_PRETTY_PRINT); $ngqr = "vmess://".base64_encode(json_encode($ng)); + $bfvqr = "bfv://{$node->server}:{$node->v2ray_port}/vmess/1?rtype=lanchina&dns=8.8.8.8&uid={$this->user->v2ray_uuid}&aid={$this->user->v2ray_alter_id}&sec=auto&tcp=header%3Dhttp%26req%3D#".str_replace('+','%20',urlencode($node->name)); } $user = Auth::getUser(); @@ -234,7 +236,7 @@ public function nodeInfo($request, $response, $args) $temp = $temp->assign('jsonrd', $jsonrd)->assign('jsonrd_show', $jsonrd_show)->assign('ssrdqr', $ssrdqr); } if ($v2ray) { - $temp = $temp->assign('jsonv', $jsonv)->assign('jsonv_show', $jsonv_show)->assign('ngqr', $ngqr); + $temp = $temp->assign('jsonv', $jsonv)->assign('jsonv_show', $jsonv_show)->assign('ngqr', $ngqr)->assign('bfvqr', $bfvqr); } return $temp->display('user/nodeinfo.tpl'); diff --git a/resources/views/default/user/nodeinfo.tpl b/resources/views/default/user/nodeinfo.tpl index a4d94bfce..82c082272 100755 --- a/resources/views/default/user/nodeinfo.tpl +++ b/resources/views/default/user/nodeinfo.tpl @@ -11,7 +11,7 @@
    -
    +

    注意!

    @@ -19,7 +19,7 @@
    {if $ss} -
    +
    @@ -28,7 +28,7 @@
    - +
    @@ -53,7 +53,7 @@
    -
    +
    @@ -75,7 +75,7 @@
    {if $ssr}
    -
    +
    @@ -93,7 +93,7 @@
    -

    SSRR 配置地址

    +

    SSR 配置地址

    @@ -110,12 +110,12 @@
    -
    +
    -

    SSRR 配置二维码

    +

    SSR 配置二维码

    @@ -131,8 +131,9 @@
    {/if} {if $ssr_add} +
    -
    +
    @@ -150,7 +151,7 @@
    -

    SSRR 配置地址

    +

    SSR 配置地址

    @@ -167,12 +168,12 @@
    -
    +
    -

    SSRR 配置二维码

    +

    SSR 配置二维码

    @@ -189,7 +190,7 @@ {/if} {if $v2ray}
    -
    +
    @@ -198,23 +199,30 @@
    - +
    +
    + + +
    - + -

    v2rayNG 配置地址

    +

    BifrostV 配置二维码&地址

    +
    +
    +
    - +
    - > + >
    @@ -224,18 +232,24 @@
    -
    +
    -

    v2rayNG 配置二维码

    +

    v2rayNG 配置二维码&地址

    +
    + +
    + > +
    +
    @@ -245,7 +259,7 @@
    {/if} {if $ss} -
    +
    @@ -319,6 +333,10 @@ jQuery('#ng-qr').qrcode({ "text": text_ngqrcode }); + var text_bfvqrcode = jQuery('#bfv-qr-text').val(); + jQuery('#bfv-qr').qrcode({ + "text": text_bfvqrcode + }); var text_surge_base = jQuery('#surge-base-text').val(); jQuery('#surge-base-qr').qrcode({ "text": text_surge_base