OSDN Git Service

luci-app-unblockneteasemusic: bump to 2.12
authorTianling Shen <cnsztl@immortalwrt.org>
Thu, 4 Nov 2021 10:47:05 +0000 (18:47 +0800)
committerTianling Shen <cnsztl@immortalwrt.org>
Thu, 4 Nov 2021 10:47:05 +0000 (18:47 +0800)
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
applications/luci-app-unblockneteasemusic/Makefile
applications/luci-app-unblockneteasemusic/luasrc/controller/unblockneteasemusic.lua
applications/luci-app-unblockneteasemusic/luasrc/model/cbi/unblockneteasemusic/unblockneteasemusic.lua
applications/luci-app-unblockneteasemusic/root/etc/init.d/unblockneteasemusic
applications/luci-app-unblockneteasemusic/root/usr/bin/unm-debug [new file with mode: 0755]
applications/luci-app-unblockneteasemusic/root/usr/share/unblockneteasemusic/debugging.sh [new file with mode: 0755]
applications/luci-app-unblockneteasemusic/root/usr/share/unblockneteasemusic/update.sh

index ff3c199..3179942 100644 (file)
@@ -5,12 +5,13 @@
 include $(TOPDIR)/rules.mk
 
 LUCI_TITLE:=LuCI support for UnblockNeteaseMusic
-LUCI_DEPENDS:=+busybox +dnsmasq-full +ipset +jsonfilter +libustream-openssl +node +uclient-fetch
+LUCI_DEPENDS:=+busybox +dnsmasq-full +ipset +jsonfilter +node +uclient-fetch \
+       @(PACKAGE_libustream-mbedtls||PACKAGE_libustream-openssl||PACKAGE_libustream-wolfssl)
 LUCI_PKGARCH:=all
 
 PKG_NAME:=luci-app-unblockneteasemusic
-PKG_VERSION:=2.11
-PKG_RELEASE:=4
+PKG_VERSION:=2.12
+PKG_RELEASE:=1
 
 PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
 
index d4bda3f..ab919ed 100644 (file)
@@ -35,7 +35,7 @@ function update_core()
        if not core_cloud_ver or not core_cloud_ver_mini then
                return "1"
        else
-               core_local_ver=luci.sys.exec("cat '/usr/share/unblockneteasemusic/core_local_ver'")
+               core_local_ver=luci.sys.exec("cat '/usr/share/unblockneteasemusic/core_local_ver' 2>'/dev/null'")
                if not core_local_ver or (core_local_ver ~= core_cloud_ver) then
                        luci.sys.call("rm -f /usr/share/unblockneteasemusic/update_core_successfully")
                        luci.sys.call("/usr/share/unblockneteasemusic/update.sh update_core_from_luci")
index 7892f21..7919058 100644 (file)
@@ -1,11 +1,11 @@
 mp = Map("unblockneteasemusic", translate("解除网易云音乐播放限制"))
-mp.description = translate("原理:采用 [Bilibili/QQ/酷狗/酷我/咪咕/JOOX/Youtube] 等音源,替换网易云音乐 无版权/收费 歌曲链接<br/>具体使用方法参见:https://github.com/UnblockNeteaseMusic/luci-app-unblockneteasemusic")
+mp.description = translate("原理:采用 [Bilibili/JOOX/酷狗/酷我/咪咕/pyncmd/QQ/Youtube] 等音源,替换网易云音乐 无版权/收费 歌曲链接<br/>具体使用方法参见:<a href=\"https://github.com/UnblockNeteaseMusic/luci-app-unblockneteasemusic\" target=\"_blank\">GitHub @UnblockNeteaseMusic/luci-app-unblockneteasemusic</a>")
 
 mp:section(SimpleSection).template = "unblockneteasemusic/unblockneteasemusic_status"
 
 s = mp:section(TypedSection, "unblockneteasemusic")
-s.anonymous=true
-s.addremove=false
+s.anonymous = true
+s.addremove = false
 
 enable = s:option(Flag, "enable", translate("启用本插件"))
 enable.description = translate("启用本插件以解除网易云音乐播放限制")
@@ -34,15 +34,15 @@ local_vip.default = 0
 local_vip.rmempty = false
 
 enable_flac = s:option(Flag, "enable_flac", translate("启用无损音质"))
-enable_flac.description = translate("目前仅支持QQ、酷我、咪咕音源")
+enable_flac.description = translate("目前仅支持酷狗、酷我、咪咕、pyncmd、QQ 音源")
 enable_flac.default = 0
 enable_flac.rmempty = false
 
 replace_music_source = s:option(ListValue, "replace_music_source", translate("强制音乐音源替换"))
 replace_music_source:value("dont_replace", translate("不强制替换音乐音源"))
-replace_music_source:value("lower_than_192kbps", translate("当音质低于192Kbps(中)时"))
-replace_music_source:value("lower_than_320kbps", translate("当音质低于320Kbps(高)时"))
-replace_music_source:value("lower_than_999kbps", translate("当音质低于999Kbps(无损)时"))
+replace_music_source:value("lower_than_192kbps", translate("当音质低于 192 Kbps(中)时"))
+replace_music_source:value("lower_than_320kbps", translate("当音质低于 320 Kbps(高)时"))
+replace_music_source:value("lower_than_999kbps", translate("当音质低于 999 Kbps(无损)时"))
 replace_music_source:value("replace_all", translate("替换所有音乐音源"))
 replace_music_source.description = translate("当音乐音质低于指定数值时,尝试强制使用其他平台的高音质版本进行替换")
 replace_music_source.default = "dont_replace"
@@ -54,24 +54,24 @@ use_custom_cookie.default = 0
 use_custom_cookie.rmempty = false
 
 joox_cookie = s:option(Value, "joox_cookie", translate("JOOX Cookie"))
-joox_cookie.description = translate("在 joox.com 获取,需要wmid和session_key值")
+joox_cookie.description = translate("在 joox.com 获取,需要 wmid 和 session_key 值")
 joox_cookie.placeholder = "wmid=; session_key="
 joox_cookie.datatype = "string"
 joox_cookie:depends("use_custom_cookie", 1)
 
 migu_cookie = s:option(Value, "migu_cookie", translate("Migu Cookie"))
-migu_cookie.description = translate("通过抓包手机客户端请求获取,需要aversionid值")
+migu_cookie.description = translate("通过抓包手机客户端请求获取,需要 aversionid 值")
 migu_cookie.datatype = "string"
 migu_cookie:depends("use_custom_cookie", 1)
 
 qq_cookie = s:option(Value, "qq_cookie", translate("QQ Cookie"))
-qq_cookie.description = translate("在 y.qq.com 获取,需要uin和qm_keyst值")
+qq_cookie.description = translate("在 y.qq.com 获取,需要 uin 和 qm_keyst值 ")
 qq_cookie.placeholder = "uin=; qm_keyst="
 qq_cookie.datatype = "string"
 qq_cookie:depends("use_custom_cookie", 1)
 
 youtube_key = s:option(Value, "youtube_key", translate("Youtube API Key"))
-youtube_key.description = translate("API Key申请地址:https://developers.google.com/youtube/v3/getting-started#before-you-start")
+youtube_key.description = translate("API Key 申请地址:https://developers.google.com/youtube/v3/getting-started#before-you-start")
 youtube_key.datatype = "string"
 youtube_key:depends("use_custom_cookie", 1)
 
@@ -88,23 +88,45 @@ update_time.default = "3"
 update_time.description = translate("设定每天自动检查更新时间")
 update_time:depends("auto_update", 1)
 
-download_cert = s:option(DummyValue, "opennewwindow", translate("<input type=\"button\" class=\"btn cbi-button cbi-button-apply\" value=\"下载CA根证书\" onclick=\"window.open('https://raw.githubusercontent.com/UnblockNeteaseMusic/server/enhanced/ca.crt')\" />"))
-download_cert.description = translate("Linux/iOS/MacOSX在信任根证书后方可正常使用")
+download_cert = s:option(Button,"certificate", translate("HTTPS 证书"))
+download_cert.inputtitle = translate("下载 CA 根证书")
+download_cert.description = translate("Linux/iOS/MacOSX 在信任根证书后方可正常使用")
+download_cert.inputstyle = "reload"
+download_cert.write = function()
+       act_download_cert()
+end
+
+function act_download_cert()
+       local t,e
+       t=nixio.open("/usr/share/unblockneteasemusic/core/ca.crt","r")
+       luci.http.header('Content-Disposition','attachment; filename="ca.crt"')
+       luci.http.prepare_content("application/octet-stream")
+       while true do
+               e=t:read(nixio.const.buffersize)
+               if(not e)or(#e==0)then
+                       break
+               else
+                       luci.http.write(e)
+               end
+       end
+       t:close()
+       luci.http.close()
+end
 
 advanced_mode = s:option(Flag, "advanced_mode", translate("启用进阶设置"))
-advanced_mode.description = translate("仅推荐高级玩家使用")
+advanced_mode.description = translate("非必要不推荐使用")
 advanced_mode.default = 0
 advanced_mode.rmempty = false
 
 http_port = s:option(Value, "http_port", translate("HTTP 监听端口"))
-http_port.description = translate("程序监听的HTTP端口,不可与 其他程序/HTTPS 共用一个端口")
+http_port.description = translate("程序监听的 HTTP 端口,不可与 其他程序/HTTPS 共用一个端口")
 http_port.placeholder = "5200"
 http_port.default = "5200"
 http_port.datatype = "port"
 http_port:depends("advanced_mode", 1)
 
 https_port = s:option(Value, "https_port", translate("HTTPS 监听端口"))
-https_port.description = translate("程序监听的HTTPS端口,不可与 其他程序/HTTP 共用一个端口")
+https_port.description = translate("程序监听的 HTTPS 端口,不可与 其他程序/HTTP 共用一个端口")
 https_port.placeholder = "5201"
 https_port.default = "5201"
 https_port.datatype = "port"
@@ -119,14 +141,14 @@ endpoint_url:depends("advanced_mode", 1)
 
 hijack = s:option(ListValue, "hijack_ways", translate("劫持方法"))
 hijack:value("dont_hijack", translate("不开启劫持"))
-hijack:value("use_ipset", translate("使用IPSet劫持"))
-hijack:value("use_hosts", translate("使用Hosts劫持"))
-hijack.description = translate("如果使用Hosts劫持,程序监听的HTTP/HTTPS端口将被锁定为80/443")
+hijack:value("use_ipset", translate("使用 IPSet 劫持"))
+hijack:value("use_hosts", translate("使用 Hosts 劫持"))
+hijack.description = translate("如果使用Hosts劫持,程序监听的 HTTP/HTTPS 端口将被锁定为 80/443")
 hijack.default = "dont_hijack"
 hijack:depends("advanced_mode", 1)
 
 keep_core_when_upgrade = s:option(Flag, "keep_core_when_upgrade", translate("升级时保留核心程序"))
-keep_core_when_upgrade.description = translate("默认情况下,在OpenWrt升级后会导致核心程序丢失,开启此选项后会保留当前下载的核心程序")
+keep_core_when_upgrade.description = translate("默认情况下,在系统升级后会导致核心程序丢失,开启此选项后会保留当前下载的核心程序")
 keep_core_when_upgrade.default = 0
 keep_core_when_upgrade.rmempty = false
 keep_core_when_upgrade:depends("advanced_mode", 1)
@@ -143,8 +165,8 @@ strict_mode.default = 0
 strict_mode.rmempty = false
 strict_mode:depends("advanced_mode", 1)
 
-netease_server_ip = s:option(Value, "netease_server_ip", translate("网易云服务器IP"))
-netease_server_ip.description = translate("通过 ping music.163.com 即可获得IP地址,仅限填写一个")
+netease_server_ip = s:option(Value, "netease_server_ip", translate("网易云服务器 IP"))
+netease_server_ip.description = translate("通过 ping music.163.com 即可获得 IP 地址,仅限填写一个")
 netease_server_ip.placeholder = "59.111.181.38"
 netease_server_ip.datatype = "ipaddr"
 netease_server_ip:depends("advanced_mode", 1)
@@ -156,13 +178,13 @@ proxy_server_ip.datatype = "string"
 proxy_server_ip:depends("advanced_mode", 1)
 
 self_issue_cert_crt = s:option(Value, "self_issue_cert_crt", translate("自签发证书公钥位置"))
-self_issue_cert_crt.description = translate("[公钥] 默认使用UnblockNeteaseMusic项目提供的CA证书,您可以指定为您自己的证书")
+self_issue_cert_crt.description = translate("[公钥] 默认使用 UnblockNeteaseMusic 项目提供的 CA 证书,您可以指定为您自己的证书")
 self_issue_cert_crt.placeholder = "/usr/share/unblockneteasemusic/core/server.crt"
 self_issue_cert_crt.datatype = "file"
 self_issue_cert_crt:depends("advanced_mode", 1)
 
 self_issue_cert_key = s:option(Value, "self_issue_cert_key", translate("自签发证书私钥位置"))
-self_issue_cert_key.description = translate("[私钥] 默认使用UnblockNeteaseMusic项目提供的CA证书,您可以指定为您自己的证书")
+self_issue_cert_key.description = translate("[私钥] 默认使用 UnblockNeteaseMusic 项目提供的 CA 证书,您可以指定为您自己的证书")
 self_issue_cert_key.placeholder = "/usr/share/unblockneteasemusic/core/server.key"
 self_issue_cert_key.datatype = "file"
 self_issue_cert_key:depends("advanced_mode", 1)
@@ -187,8 +209,8 @@ acl_filter_mode = acl_rule:option(ListValue, "filter_mode", translate("规则"))
 acl_filter_mode.width = "40%"
 acl_filter_mode.default = "disable_all"
 acl_filter_mode.rmempty = false
-acl_filter_mode:value("disable_all", translate("不代理HTTP和HTTPS"))
-acl_filter_mode:value("disable_http", translate("不代理HTTP"))
-acl_filter_mode:value("disable_https", translate("不代理HTTPS"))
+acl_filter_mode:value("disable_all", translate("不代理 HTTP 和 HTTPS"))
+acl_filter_mode:value("disable_http", translate("不代理 HTTP"))
+acl_filter_mode:value("disable_https", translate("不代理 HTTPS"))
 
 return mp
index 753d29d..1efc3be 100755 (executable)
@@ -57,8 +57,8 @@ start_service()
        echo "*/5 * * * * /usr/share/$NAME/log_check.sh" >> "/etc/crontabs/root"
        /etc/init.d/cron restart
 
-       [ ! -e "/usr/share/$NAME/core/app.js" ] && { rm -f "/usr/share/$NAME/local_ver"; sh "/usr/share/$NAME/update.sh" "update_core_non_restart"; }
-       [ ! -e "/usr/share/$NAME/core/app.js" ] && { echo "Core Not Found, please download it before starting." >> "/tmp/$NAME.log"; exit 1; }
+       [ ! -s "/usr/share/$NAME/core/app.js" ] && { rm -f "/usr/share/$NAME/local_ver"; sh "/usr/share/$NAME/update.sh" "update_core_non_restart"; }
+       [ ! -s "/usr/share/$NAME/core/app.js" ] && { echo "Core Not Found, please download it before starting." >> "/tmp/$NAME.log"; exit 1; }
 
        procd_open_instance "$NAME"
        procd_set_param command node "/usr/share/$NAME/core/app.js"
diff --git a/applications/luci-app-unblockneteasemusic/root/usr/bin/unm-debug b/applications/luci-app-unblockneteasemusic/root/usr/bin/unm-debug
new file mode 100755 (executable)
index 0000000..11cb264
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2021 Tianling Shen <cnsztl@immortalwrt.org>
+
+mkdir -p "/tmp"
+/usr/share/unblockneteasemusic/debugging.sh 2>&1 | tee "/tmp/unm-debugging-output.txt"
+
+catbox_link="$(curl -fsS -F "reqtype=fileupload" -F "time=72h" -F "fileToUpload=@/tmp/unm-debugging-output.txt" "https://litterbox.catbox.moe/resources/internals/api.php")"
+transfer_link="$(curl -fsS --upload-file "/tmp/unm-debugging-output.txt" "https://transfer.sh/unm-debugging-output.txt")"
+echo -e "\n"
+echo -e "Log is available at:"
+echo -e "$catbox_link"
+echo -e "$transfer_link"
+
+rm -f "/tmp/unm-debugging-output.txt"
diff --git a/applications/luci-app-unblockneteasemusic/root/usr/share/unblockneteasemusic/debugging.sh b/applications/luci-app-unblockneteasemusic/root/usr/share/unblockneteasemusic/debugging.sh
new file mode 100755 (executable)
index 0000000..567a61b
--- /dev/null
@@ -0,0 +1,81 @@
+#!/bin/sh
+# Copyright (C) 2021 Tianling Shen <cnsztl@immortalwrt.org>
+
+. /lib/functions.sh
+
+command -v "curl" >"/dev/null" || { echo -e "curl is not found."; exit 1; }
+
+echo -e "Launching luci-app-unblockneteasmusic Debugging Tool..."
+echo -e "\n"
+
+echo -e "OpenWrt info:"
+cat "/etc/openwrt_release"
+echo -e "\n"
+
+echo -e "uclient-fetch info:"
+opkg info uclient-fetch
+opkg info libustream-*
+uclient-fetch -O- 'https://api.github.com/repos/UnblockNeteaseMusic/server/commits?sha=enhanced&path=precompiled' | jsonfilter -e '@[0].sha' || echo -e "Failed to connect to GitHub with uclient-fetch."
+echo -e "\n"
+
+echo -e "Node.js info:"
+opkg info node
+echo -e "Node.js is placed at $(command -v node || echo "Not Found")"
+echo -e "Node.js version: $(node -v 2>"/dev/null" || echo "Not Found")"
+echo -e "\n"
+
+echo -e "luci-app-unblockneteasmusic info:"
+opkg info "luci-app-unblockneteasemusic"
+ls -lh "/etc/config/unblockneteasemusic" "/etc/init.d/unblockneteasemusic" "/usr/share/unblockneteasemusic"
+cat "/etc/config/unblockneteasemusic" | sed -e "s,joox_cookie .*,joox_cookie 'set',g" \
+       -e "s,migu_cookie .*,migu_cookie 'set',g" \
+       -e "s,qq_cookie .*,qq_cookie 'set',g" \
+       -e "s,youtube_key .*,youtube_key 'set',g" \
+       -e "s,proxy_server_ip .*,proxy_server_ip 'set',g"
+echo -e "\n"
+
+echo -e "UnblockNeteaseMusic Node.js info:"
+echo -e "Git HEAD version: $(cat "/usr/share/unblockneteasemusic/core_local_ver" 2>"/dev/null" || echo "Not Found")"
+echo -e "Core version: $(node "/usr/share/unblockneteasemusic/core/app.js" -v 2>"/dev/null" || echo "Not Found")"
+ls -lh "/usr/share/unblockneteasemusic/core" 2>"/dev/null"
+echo -e "\n"
+
+echo -e "Netease networking info:"
+curl -fsv "http://music.163.com/song/media/outer/url?id=641644.mp3" 2>&1 | grep "Location" || echo -e "Cannot connect to NeteaseMusic."
+curl -sSL "http://httpdns.n.netease.com/httpdns/v2/d?domain=music.163.com" || echo -e "Cannot connect to Netease HTTPDNS."
+config_load "unblockneteasemusic"
+config_get custom_proxy "config" "proxy_server_ip"
+[ -n "$custom_proxy" ] && { curl -sL -x "$custom_proxy" "http://music.163.com/song/media/outer/url?id=641644.mp3" 2>&1 | grep "Location" || echo -e "Cannot connect to NeteaseMusic via proxy."; }
+echo -e "\n"
+
+echo -e "Running info:"
+procd_running_status="$(/etc/init.d/unblockneteasemusic status)"
+echo -e "PROCD running status: $procd_running_status"
+[ "$procd_running_status" = "running" ] && { ps | grep "unblockneteasemusic" | grep "app\.js" || echo -e "Thread is not found."; }
+echo -e "\n"
+
+[ "$procd_running_status" != "running" ] || {
+       echo -e "Firewall info:"
+       iptables -t "nat" -L "netease_cloud_music" 2>"/dev/null" || echo -e 'Chain "netease_cloud_music" not found.'
+       echo -e ""
+       ipset list "neteasemusic" 2>"/dev/null" || echo -e 'Table "neteasemusic" not found.'
+       echo -e ""
+       ipset list "acl_neteasemusic_http" 2>"/dev/null" || echo -e 'Table "acl_neteasemusic_http" not found.'
+       echo -e ""
+       ipset list "acl_neteasemusic_https" 2>"/dev/null" || echo -e 'Table "acl_neteasemusic_https" not found.'
+       echo -e ""
+       cat "/tmp/dnsmasq.d/dnsmasq-unblockneteasemusic.conf"
+       echo -e "\n"
+
+       echo -e "Testing source replacing..."
+       lan_ip="$(uci -q get "network.lan.ipaddr" || echo "127.0.0.1")"
+       config_get unm_port "config" "http_port" "5200"
+       [ "x$(config_get "config" "hijack_ways")" = "xuse_hosts" ] && unm_port="80"
+
+       echo -n "" > "/tmp/unblockneteasemusic.log"
+       curl -sSL -X "POST" "https://music.163.com/weapi/song/enhance/player/url/v1?csrf_token=" --data "params=bf3kf%2BOyalbxNS%2FeHAXquH8D2nt2YrhBzww4zy5rj2H%2BeAhdOIaGh4HHHzcoREFcu9Ve35LUgc%2BGE1YJD1HxrJ87ucm5zK%2FFn1lLvHFv1A8ZAuyU1afjG28s2Xja6zpfg00T0EcCeqkK61OpTfAaqw%3D%3D&encSecKey=6bab0dfa7ee3b292f9263a7af466636731cdbbd1d8747c9178c17477e70be899b7788c4a4e315c9fdb8c6e787603db6f9dff62c356f164d35b16b7f2d9ad5ede3cc7336130605521a8f916d308ce86b15c32b81c883ae2ba9c244444d91e1683be93fa0ea3e2a85207c9d693b86b5bb31adb002dd56c0bbcce9c73ec3bf5c105"
+       echo -e ""
+       curl -ksSL -X "POST" -x "http://$lan_ip:$unm_port" "https://music.163.com/weapi/song/enhance/player/url/v1?csrf_token=" --data "params=bf3kf%2BOyalbxNS%2FeHAXquH8D2nt2YrhBzww4zy5rj2H%2BeAhdOIaGh4HHHzcoREFcu9Ve35LUgc%2BGE1YJD1HxrJ87ucm5zK%2FFn1lLvHFv1A8ZAuyU1afjG28s2Xja6zpfg00T0EcCeqkK61OpTfAaqw%3D%3D&encSecKey=6bab0dfa7ee3b292f9263a7af466636731cdbbd1d8747c9178c17477e70be899b7788c4a4e315c9fdb8c6e787603db6f9dff62c356f164d35b16b7f2d9ad5ede3cc7336130605521a8f916d308ce86b15c32b81c883ae2ba9c244444d91e1683be93fa0ea3e2a85207c9d693b86b5bb31adb002dd56c0bbcce9c73ec3bf5c105"
+       echo -e ""
+       cat "/tmp/unblockneteasemusic.log"
+}
index 737f367..412f5b0 100755 (executable)
@@ -44,13 +44,14 @@ update_core(){
        do
                {
                        uclient-fetch "${mirror}${core_latest_ver}/precompiled/app.js" -qO "/usr/share/$NAME/core/app.js"
+                       uclient-fetch "${mirror}enhanced/ca.crt" -qO "/usr/share/$NAME/core/ca.crt"
                        uclient-fetch "${mirror}enhanced/server.crt" -qO "/usr/share/$NAME/core/server.crt"
                        uclient-fetch "${mirror}enhanced/server.key" -qO "/usr/share/$NAME/core/server.key"
                } > "/dev/null" 2>&1 && break
        done
 
        local file
-       for file in "app.js" "server.crt" "server.key"
+       for file in "app.js" "ca.crt" "server.crt" "server.key"
        do
                [ -s "/usr/share/$NAME/core/${file}" ] || {
                        echo -e "Failed to download ${file}." >> "/tmp/$NAME.log"