From 3e0abe93ab9706c12d1d7e652edda9e58c57c680 Mon Sep 17 00:00:00 2001 From: coldice945 Date: Sun, 13 Nov 2022 23:54:47 +0800 Subject: [PATCH 1/3] feature: add a subscription information panel to Surge and Surfboard for easy viewing --- app/Http/Controllers/Client/Protocols/Surfboard.php | 8 ++++++++ app/Http/Controllers/Client/Protocols/Surge.php | 8 ++++++++ resources/rules/default.surfboard.conf | 3 +++ resources/rules/default.surge.conf | 3 +++ 4 files changed, 22 insertions(+) diff --git a/app/Http/Controllers/Client/Protocols/Surfboard.php b/app/Http/Controllers/Client/Protocols/Surfboard.php index 1864a409..918ff7db 100644 --- a/app/Http/Controllers/Client/Protocols/Surfboard.php +++ b/app/Http/Controllers/Client/Protocols/Surfboard.php @@ -64,6 +64,14 @@ class Surfboard $config = str_replace('$subs_domain', $subsDomain, $config); $config = str_replace('$proxies', $proxies, $config); $config = str_replace('$proxy_group', rtrim($proxyGroup, ', '), $config); + + $upload = round($user['u'] / (1024*1024*1024), 2); + $download = round($user['d'] / (1024*1024*1024), 2); + $totalTraffic = round($user['transfer_enable'] / (1024*1024*1024), 2); + $expireDate = $user['expired_at'] === NULL ? '长期有效' : date('Y-m-d H:i:s', $user['expired_at']); + $subscribeInfo = "title=\"{$appName}订阅信息\", content=\"上传流量:{$upload}GB\\n下载流量:{$download}GB\\n已用总流量:{$totalTraffic}GB\\n到期时间:{$expireDate}\""; + $config = str_replace('$subscribe_info', $subscribeInfo, $config); + return $config; } diff --git a/app/Http/Controllers/Client/Protocols/Surge.php b/app/Http/Controllers/Client/Protocols/Surge.php index c41edbed..dfdeedce 100644 --- a/app/Http/Controllers/Client/Protocols/Surge.php +++ b/app/Http/Controllers/Client/Protocols/Surge.php @@ -64,6 +64,14 @@ class Surge $config = str_replace('$subs_domain', $subsDomain, $config); $config = str_replace('$proxies', $proxies, $config); $config = str_replace('$proxy_group', rtrim($proxyGroup, ', '), $config); + + $upload = round($user['u'] / (1024*1024*1024), 2); + $download = round($user['d'] / (1024*1024*1024), 2); + $totalTraffic = round($user['transfer_enable'] / (1024*1024*1024), 2); + $expireDate = $user['expired_at'] === NULL ? '长期有效' : date('Y-m-d H:i:s', $user['expired_at']); + $subscribeInfo = "title=\"{$appName}订阅信息\", content=\"上传流量:{$upload}GB\\n下载流量:{$download}GB\\n已用总流量:{$totalTraffic}GB\\n到期时间:{$expireDate}\""; + $config = str_replace('$subscribe_info', $subscribeInfo, $config); + return $config; } diff --git a/resources/rules/default.surfboard.conf b/resources/rules/default.surfboard.conf index 8d0cd515..e0d1bc17 100644 --- a/resources/rules/default.surfboard.conf +++ b/resources/rules/default.surfboard.conf @@ -12,6 +12,9 @@ test-timeout = 5 internet-test-url = http://bing.com proxy-test-url = http://bing.com +[Panel] +SubscribeInfo = $subscribe_info, style=info + # Surfboard 的服务器和策略组配置方式与 Surge 类似, 可以参考 Surge 的规则配置手册: https://manual.nssurge.com/ [Proxy] diff --git a/resources/rules/default.surge.conf b/resources/rules/default.surge.conf index 501822e7..1560bbe3 100644 --- a/resources/rules/default.surge.conf +++ b/resources/rules/default.surge.conf @@ -36,6 +36,9 @@ hide-crashlytics-request = true use-keyword-filter = false hide-udp = false +[Panel] +SubscribeInfo = $subscribe_info, style=info + # ----------------------------- # Surge 的几种策略配置规范,请参考 https://manual.nssurge.com/policy/proxy.html # 不同的代理策略有*很多*可选参数,请参考上方连接的 Parameters 一段,根据需求自行添加参数。 From 858e68399aca4a4164076bdf6c765e328bd8927a Mon Sep 17 00:00:00 2001 From: coldice945 Date: Fri, 16 Dec 2022 20:08:33 +0800 Subject: [PATCH 2/3] =?UTF-8?q?Surge=EF=BC=8CSurfboard=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=9D=A2=E6=9D=BF=E6=B5=81=E9=87=8F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8E=BB=E6=8E=89=E5=86=85=E9=83=A8=E6=B2=A1?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E5=BC=95=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Client/Protocols/Surfboard.php | 2 +- app/Http/Controllers/Client/Protocols/Surge.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Client/Protocols/Surfboard.php b/app/Http/Controllers/Client/Protocols/Surfboard.php index 918ff7db..57a9421e 100644 --- a/app/Http/Controllers/Client/Protocols/Surfboard.php +++ b/app/Http/Controllers/Client/Protocols/Surfboard.php @@ -69,7 +69,7 @@ class Surfboard $download = round($user['d'] / (1024*1024*1024), 2); $totalTraffic = round($user['transfer_enable'] / (1024*1024*1024), 2); $expireDate = $user['expired_at'] === NULL ? '长期有效' : date('Y-m-d H:i:s', $user['expired_at']); - $subscribeInfo = "title=\"{$appName}订阅信息\", content=\"上传流量:{$upload}GB\\n下载流量:{$download}GB\\n已用总流量:{$totalTraffic}GB\\n到期时间:{$expireDate}\""; + $subscribeInfo = "title={$appName}订阅信息, content=上传流量:{$upload}GB\\n下载流量:{$download}GB\\n已用总流量:{$totalTraffic}GB\\n到期时间:{$expireDate}"; $config = str_replace('$subscribe_info', $subscribeInfo, $config); return $config; diff --git a/app/Http/Controllers/Client/Protocols/Surge.php b/app/Http/Controllers/Client/Protocols/Surge.php index dfdeedce..8b12000b 100644 --- a/app/Http/Controllers/Client/Protocols/Surge.php +++ b/app/Http/Controllers/Client/Protocols/Surge.php @@ -69,7 +69,7 @@ class Surge $download = round($user['d'] / (1024*1024*1024), 2); $totalTraffic = round($user['transfer_enable'] / (1024*1024*1024), 2); $expireDate = $user['expired_at'] === NULL ? '长期有效' : date('Y-m-d H:i:s', $user['expired_at']); - $subscribeInfo = "title=\"{$appName}订阅信息\", content=\"上传流量:{$upload}GB\\n下载流量:{$download}GB\\n已用总流量:{$totalTraffic}GB\\n到期时间:{$expireDate}\""; + $subscribeInfo = "title={$appName}订阅信息, content=上传流量:{$upload}GB\\n下载流量:{$download}GB\\n已用总流量:{$totalTraffic}GB\\n到期时间:{$expireDate}"; $config = str_replace('$subscribe_info', $subscribeInfo, $config); return $config; From 358d036e3358473174810d0e9fcbdedcdad9a3ce Mon Sep 17 00:00:00 2001 From: coldice945 Date: Sat, 17 Dec 2022 18:59:45 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Surge=20=E9=9D=A2=E6=9D=BF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=A2=9E=E5=8A=A0=E5=89=A9=E4=BD=99=E6=B5=81=E9=87=8F?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Client/Protocols/Surfboard.php | 3 ++- app/Http/Controllers/Client/Protocols/Surge.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Client/Protocols/Surfboard.php b/app/Http/Controllers/Client/Protocols/Surfboard.php index 57a9421e..930f2f91 100644 --- a/app/Http/Controllers/Client/Protocols/Surfboard.php +++ b/app/Http/Controllers/Client/Protocols/Surfboard.php @@ -67,9 +67,10 @@ class Surfboard $upload = round($user['u'] / (1024*1024*1024), 2); $download = round($user['d'] / (1024*1024*1024), 2); + $useTraffic = $upload + $download; $totalTraffic = round($user['transfer_enable'] / (1024*1024*1024), 2); $expireDate = $user['expired_at'] === NULL ? '长期有效' : date('Y-m-d H:i:s', $user['expired_at']); - $subscribeInfo = "title={$appName}订阅信息, content=上传流量:{$upload}GB\\n下载流量:{$download}GB\\n已用总流量:{$totalTraffic}GB\\n到期时间:{$expireDate}"; + $subscribeInfo = "title={$appName}订阅信息, content=上传流量:{$upload}GB\\n下载流量:{$download}GB\\n剩余流量:{$useTraffic}GB\\n套餐流量:{$totalTraffic}GB\\n到期时间:{$expireDate}"; $config = str_replace('$subscribe_info', $subscribeInfo, $config); return $config; diff --git a/app/Http/Controllers/Client/Protocols/Surge.php b/app/Http/Controllers/Client/Protocols/Surge.php index 8b12000b..e745354b 100644 --- a/app/Http/Controllers/Client/Protocols/Surge.php +++ b/app/Http/Controllers/Client/Protocols/Surge.php @@ -67,9 +67,10 @@ class Surge $upload = round($user['u'] / (1024*1024*1024), 2); $download = round($user['d'] / (1024*1024*1024), 2); + $useTraffic = $upload + $download; $totalTraffic = round($user['transfer_enable'] / (1024*1024*1024), 2); $expireDate = $user['expired_at'] === NULL ? '长期有效' : date('Y-m-d H:i:s', $user['expired_at']); - $subscribeInfo = "title={$appName}订阅信息, content=上传流量:{$upload}GB\\n下载流量:{$download}GB\\n已用总流量:{$totalTraffic}GB\\n到期时间:{$expireDate}"; + $subscribeInfo = "title={$appName}订阅信息, content=上传流量:{$upload}GB\\n下载流量:{$download}GB\\n剩余流量:{$useTraffic}GB\\n套餐流量:{$totalTraffic}GB\\n到期时间:{$expireDate}"; $config = str_replace('$subscribe_info', $subscribeInfo, $config); return $config;