update 2024-10-26 08:49:15

This commit is contained in:
kenzok8 2024-10-26 08:49:15 +08:00
parent 7b20b848c6
commit ce763a2301
20 changed files with 944 additions and 2 deletions

View File

@ -0,0 +1,43 @@
# Copyright (C) 2020 Openwrt.org
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-unblockmusic
PKG_VERSION:=2.3.5
PKG_RELEASE:=21
PKG_LICENSE:=Apache-2.0
PKG_MAINTAINER:=lean <coolsnowwolf@gmail.com>
PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_UnblockNeteaseMusic_Go \
CONFIG_PACKAGE_$(PKG_NAME)_INCLUDE_UnblockNeteaseMusic_NodeJS
LUCI_TITLE:=LuCI support for Unblock NeteaseCloudMusic
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+dnsmasq-full +ipset +uclient-fetch \
+PACKAGE_$(PKG_NAME)_INCLUDE_UnblockNeteaseMusic_Go:UnblockNeteaseMusic-Go \
+PACKAGE_$(PKG_NAME)_INCLUDE_UnblockNeteaseMusic_NodeJS:UnblockNeteaseMusic
define Package/$(PKG_NAME)/config
config PACKAGE_$(PKG_NAME)_INCLUDE_UnblockNeteaseMusic_Go
bool "UnblockNeteaseMusic Golang Version"
default y if i386||x86_64||arm||aarch64
config PACKAGE_$(PKG_NAME)_INCLUDE_UnblockNeteaseMusic_NodeJS
bool "UnblockNeteaseMusic NodeJS Version"
depends on HAS_FPU || KERNEL_MIPS_FPU_EMULATOR || SOFT_FLOAT
default n
endef
define Package/$(PKG_NAME)/conffiles
/etc/config/unblockmusic
endef
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,19 @@
module("luci.controller.unblockmusic", package.seeall)
function index()
if not nixio.fs.access("/etc/config/unblockmusic") then
return
end
entry({"admin", "services", "unblockmusic"}, alias("admin", "services", "unblockmusic", "general"), _("Unblock Netease Music"), 50).dependent = true
entry({"admin", "services", "unblockmusic", "general"}, cbi("unblockmusic/unblockmusic"), _("Base Setting"), 1).leaf = true
entry({"admin", "services", "unblockmusic", "log"}, form("unblockmusic/unblockmusic_log"), _("Log"), 2).leaf = true
entry({"admin", "services", "unblockmusic", "status"}, call("act_status")).leaf = true
end
function act_status()
local e = {}
e.running = luci.sys.call("busybox ps -w | grep UnblockNeteaseMusic | grep -v grep | grep -v logcheck.sh >/dev/null") == 0
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end

View File

@ -0,0 +1,128 @@
local fs = require "nixio.fs"
mp = Map("unblockmusic")
mp.title = translate("解锁网易云灰色歌曲")
mp.description = translate("采用 [QQ/百度/酷狗/酷我/咪咕/JOOX]等音源,替换网易云变灰歌曲链接")
mp:section(SimpleSection).template = "unblockmusic/unblockmusic_status"
s = mp:section(TypedSection, "unblockmusic")
s.anonymous = true
s.addremove = false
enabled = s:option(Flag, "enabled", translate("启用"))
enabled.description = translate("启用后,路由器自动分流解锁,大部分设备无需设置代理")
enabled.default = 0
enabled.rmempty = false
apptype = s:option(ListValue, "apptype", translate("解锁程序选择"))
if nixio.fs.access("/usr/bin/UnblockNeteaseMusic") then
apptype:value("go", translate("Golang 版本"))
end
if nixio.fs.access("/usr/share/UnblockNeteaseMusic/app.js") then
apptype:value("nodejs", translate("NodeJS 版本"))
end
apptype:value("cloud", translate("云解锁( [CTCGFW] 云服务器)"))
speedtype = s:option(Value, "musicapptype", translate("音源选择"))
speedtype:value("default", translate("默认"))
speedtype:value("netease", translate("网易云音乐"))
speedtype:value("qq", translate("QQ音乐"))
speedtype:value("baidu", translate("百度音乐"))
speedtype:value("kugou", translate("酷狗音乐"))
speedtype:value("kuwo", translate("酷我音乐"))
speedtype:value("migu", translate("咪咕音乐"))
speedtype:value("joox", translate("JOOX音乐"))
speedtype.default = "kuwo"
speedtype:depends("apptype", "nodejs")
speedtype:depends("apptype", "go")
cloudserver = s:option(Value, "cloudserver", translate("服务器位置"))
cloudserver.description = translate("自定义服务器格式为 IP[域名]:HTTP端口:HTTPS端口<br />如果服务器为LAN内网IP需要将这个服务器IP放入例外客户端 (不代理HTTP和HTTPS)")
cloudserver.default = ""
cloudserver.rmempty = true
cloudserver:depends("apptype", "cloud")
search_limit = s:option(Value, "search_limit", translate("搜索结果限制"))
search_limit.description = translate("在搜索页面显示其他平台搜索结果个数可填0-3")
search_limit.default = "0"
search_limit:depends("apptype", "go")
flac = s:option(Flag, "flac_enabled", translate("启用无损音质"))
flac.description = translate("目前仅支持酷我、QQ、咪咕")
flac.default = "1"
flac.rmempty = false
flac:depends("apptype", "nodejs")
flac:depends("apptype", "go")
replace_music_source = s:option(ListValue, "replace_music_source", translate("强制音乐音源替换"))
replace_music_source:value("0", translate("不强制替换音乐音源"))
replace_music_source:value("192000", translate("当音质低于 192 Kbps"))
replace_music_source:value("320000", translate("当音质低于 320 Kbps"))
replace_music_source:value("600000", translate("当音质低于 999 Kbps无损"))
replace_music_source.description = translate("当音乐音质低于指定数值时,尝试强制使用其他平台的高音质版本进行替换")
replace_music_source.default = "0"
replace_music_source.rmempty = false
replace_music_source:depends("apptype", "nodejs")
local_vip = s:option(Flag, "local_vip", translate("启用本地 VIP"))
local_vip.description = translate("启用后,可以使用去广告、个性换肤、鲸云音效等本地功能")
local_vip.default = 0
local_vip.rmempty = false
local_vip:depends("apptype", "nodejs")
autoupdate = s:option(Flag, "autoupdate", translate("自动检查更新主程序"))
autoupdate.description = translate("每天自动检测并更新到最新版本")
autoupdate.default = "1"
autoupdate.rmempty = false
autoupdate:depends("apptype", "nodejs")
download_certificate = s:option(DummyValue, "opennewwindow", translate("HTTPS 证书"))
download_certificate.description = 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')\" /><br />Mac/iOS客户端需要安装 CA根证书并信任<br />iOS系统需要在“设置 -> 通用 -> 关于本机 -> 证书信任设置”中,信任 UnblockNeteaseMusic Root CA <br />Linux 设备请在启用时加入 --ignore-certificate-errors 参数")
local ver = fs.readfile("/usr/share/UnblockNeteaseMusic/core_ver") or "0.00"
restart = s:option(Button, "restart", translate("手动更新"))
restart.inputtitle = translate("更新核心版本")
restart.description = string.format(translate("NodeJS 解锁主程序版本") .. "<strong><font color=\"green\">: %s </font></strong>", ver)
restart.inputstyle = "reload"
restart.write = function()
luci.sys.exec("/usr/share/UnblockNeteaseMusic/update_core.sh luci_update 2>&1")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "unblockmusic"))
end
restart:depends("apptype", "nodejs")
acl_mode = s:option(ListValue, "acl_mode", translate("默认解锁模式"))
acl_mode:value(0, translate("解锁"))
acl_mode:value(1, translate("不解锁"))
acl_mode.default = 0
t = mp:section(TypedSection, "acl_rule")
t.title = translate("例外客户端规则")
t.description = translate("可以为局域网客户端分别设置不同的例外模式,默认无需设置")
t.template = "cbi/tblsection"
t.sortable = true
t.anonymous = true
t.addremove = true
ipaddr = t:option(Value, "ipaddr", translate("IP 地址"))
ipaddr.width = "40%"
ipaddr.datatype = "ip4addr"
ipaddr.placeholder = "0.0.0.0/0"
luci.ip.neighbors({ family = 4 }, function(entry)
if entry.reachable then
ipaddr:value(entry.dest:string())
end
end)
filter_mode = t:option(ListValue, "filter_mode", translate("例外协议"))
filter_mode.width = "40%"
filter_mode.default = "disable"
filter_mode.rmempty = false
filter_mode:value("disable", translate("不代理HTTP和HTTPS"))
filter_mode:value("http", translate("不代理HTTP"))
filter_mode:value("https", translate("不代理HTTPS"))
filter_mode:value("proxy_http", translate("代理HTTP"))
filter_mode:value("proxy_http_https", translate("代理HTTP和HTTPS"))
return mp

View File

@ -0,0 +1,15 @@
local fs = require "nixio.fs"
local conffile = "/tmp/music.log"
f = SimpleForm("logview")
t = f:field(TextValue, "conf")
t.rmempty = true
t.rows = 20
function t.cfgvalue()
luci.sys.exec("grep -B 1 'http' /tmp/unblockmusic.log | grep -v -e'running' -e'TLS' -e'Transport' -e'POST' -e'github' -e'consumed' -e'starting' -e'error' > /tmp/music.log")
return fs.readfile(conffile) or ""
end
t.readonly = "readonly"
return f

View File

@ -0,0 +1,22 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(3, '<%=url([[admin]], [[services]], [[unblockmusic]], [[status]])%>', null,
function(x, data) {
var tb = document.getElementById('unblockmusic_status');
if (data && tb) {
if (data.running) {
var links = '<em><b><font color=green>UnblockNeteaseMusic <%:RUNNING%></font></b></em>';
tb.innerHTML = links;
} else {
tb.innerHTML = '<em><b><font color=red>UnblockNeteaseMusic <%:NOT RUNNING%></font></b></em>';
}
}
}
);
//]]>
</script>
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
<fieldset class="cbi-section">
<p id="unblockmusic_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -0,0 +1,12 @@
msgid "Unblock Netease Music"
msgstr "解锁网易云灰色歌曲"
msgid "Base Setting"
msgstr "基本设置"
msgid "Log"
msgstr "日志"
msgid "Port"
msgstr "端口"

View File

@ -0,0 +1 @@
zh-cn

View File

@ -0,0 +1,8 @@
config unblockmusic
option musicapptype 'kuwo'
option autoupdate '1'
option endpoint 'http://music.163.com'
option enabled '0'
option apptype 'go'

View File

@ -0,0 +1,7 @@
#!/bin/sh
[ "$ACTION" = ifup ] || exit 0
sleep 10
ipset flush music 2>/dev/null
/usr/share/UnblockNeteaseMusic/getmusicip.sh

View File

@ -0,0 +1,261 @@
#!/bin/sh /etc/rc.common
START=97
STOP=10
NAME=unblockmusic
uci_get_by_type() {
local ret=$(uci get $NAME.@$1[0].$2 2>/dev/null)
echo ${ret:=$3}
}
uci_get_by_name() {
local index=0
if [ -n $4 ]; then
index=$4
fi
local ret=$(uci get $NAME.@$1[$index].$2 2>/dev/null)
echo ${ret:=$3}
}
check_host() {
local host=$1
if echo $host | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then
hostip=$host
elif [ "$host" != "${host#*:[0-9a-fA-F]}" ]; then
hostip=$host
else
hostip=$(ping $host -W 1 -s 1 -c 1 | grep PING | cut -d'(' -f 2 | cut -d')' -f1)
if echo $hostip | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" >/dev/null; then
hostip=$hostip
else
hostip="127.0.0.1"
fi
fi
echo -e $hostip
}
ip_rule()
{
local icount=$(uci show unblockmusic | grep 'filter_mode' | wc -l)
let icount=icount-1
for i in $(seq 0 $icount)
do
local ip=$(uci_get_by_name acl_rule ipaddr '' $i)
local mode=$(uci_get_by_name acl_rule filter_mode '' $i)
case "$mode" in
http)
ipset -! add music_http $ip
;;
https)
ipset -! add music_https $ip
;;
disable)
ipset -! add music_http $ip
ipset -! add music_https $ip
;;
proxy_http)
ipset -! add music_proxy_http $ip
;;
proxy_http_https)
ipset -! add music_proxy_http $ip
ipset -! add music_proxy_https $ip
esac
done
}
ENABLE=$(uci_get_by_type unblockmusic enabled 0)
TYPE=$(uci_get_by_type unblockmusic musicapptype default)
AUTOUPDATE=$(uci_get_by_type unblockmusic autoupdate 0)
APPTYPE=$(uci_get_by_type unblockmusic apptype go)
SEARCHLIMIT=$(uci_get_by_type unblockmusic search_limit 0)
FLAC=$(uci_get_by_type unblockmusic flac_enabled 0)
REPLACE_MUSIC_SOURCE=$(uci_get_by_type unblockmusic replace_music_source 0)
LOCAL_VIP=$(uci_get_by_type unblockmusic local_vip 0)
ACLMODE=$(uci_get_by_type unblockmusic acl_mode 0)
CLOUD=$(uci_get_by_type unblockmusic cloudserver "127.0.0.1:5200:5201")
cloudadd=$(echo "$CLOUD" | awk -F ':' '{print $1}')
cloudhttp=$(echo "$CLOUD" | awk -F ':' '{print $2}')
cloudhttps=$(echo "$CLOUD" | awk -F ':' '{print $3}')
cloudip=$(check_host $cloudadd)
CRON_FILE=/etc/crontabs/root
ipt_n="iptables -t nat"
add_rule()
{
ipset -! -N music hash:ip
ipset -! -N music_http hash:ip
ipset -! -N music_https hash:ip
ipset -! -N music_proxy_http hash:ip
ipset -! -N music_proxy_https hash:ip
$ipt_n -N CLOUD_MUSIC
$ipt_n -A CLOUD_MUSIC -d 0.0.0.0/8 -j RETURN
$ipt_n -A CLOUD_MUSIC -d 10.0.0.0/8 -j RETURN
$ipt_n -A CLOUD_MUSIC -d 127.0.0.0/8 -j RETURN
$ipt_n -A CLOUD_MUSIC -d 169.254.0.0/16 -j RETURN
$ipt_n -A CLOUD_MUSIC -d 172.16.0.0/12 -j RETURN
$ipt_n -A CLOUD_MUSIC -d 192.168.0.0/16 -j RETURN
$ipt_n -A CLOUD_MUSIC -d 224.0.0.0/4 -j RETURN
$ipt_n -A CLOUD_MUSIC -d 240.0.0.0/4 -j RETURN
if [ "$APPTYPE" != "cloud" ]; then
$ipt_n -A CLOUD_MUSIC -p tcp -m set --match-set music_http src --dport 80 -j RETURN
$ipt_n -A CLOUD_MUSIC -p tcp -m set --match-set music_https src --dport 443 -j RETURN
$ipt_n -A CLOUD_MUSIC -p tcp -m set --match-set music_proxy_http src --dport 80 -j REDIRECT --to-ports 5200
$ipt_n -A CLOUD_MUSIC -p tcp -m set --match-set music_proxy_https src --dport 443 -j REDIRECT --to-ports 5201
if [ "$ACLMODE" == "0" ]; then
$ipt_n -A CLOUD_MUSIC -p tcp --dport 80 -j REDIRECT --to-ports 5200
$ipt_n -A CLOUD_MUSIC -p tcp --dport 443 -j REDIRECT --to-ports 5201
fi
else
local lan_addr
. /lib/functions/network.sh
network_flush_cache
network_get_ipaddr lanaddr "lan"
$ipt_n -A CLOUD_MUSIC -p tcp -m set --match-set music_http src --dport 80 -j RETURN
$ipt_n -A CLOUD_MUSIC -p tcp -m set --match-set music_https src --dport 443 -j RETURN
$ipt_n -A CLOUD_MUSIC -p tcp -m set --match-set music_proxy_http src --dport 80 -j DNAT --to $cloudip:$cloudhttp
$ipt_n -A CLOUD_MUSIC -p tcp -m set --match-set music_proxy_https src --dport 443 -j DNAT --to $cloudip:$cloudhttps
if [ "$ACLMODE" == "0" ]; then
$ipt_n -A CLOUD_MUSIC -p tcp --dport 80 -j DNAT --to $cloudip:$cloudhttp
$ipt_n -A CLOUD_MUSIC -p tcp --dport 443 -j DNAT --to $cloudip:$cloudhttps
fi
$ipt_n -I POSTROUTING -p tcp -m multiport --dport $cloudhttp,$cloudhttps -d $cloudip -j SNAT --to-source $lanaddr
fi
$ipt_n -I PREROUTING -p tcp -m set --match-set music dst -j CLOUD_MUSIC
iptables -I OUTPUT -d 223.252.199.10 -j DROP
ip_rule
}
del_rule(){
$ipt_n -D PREROUTING -p tcp -m set --match-set music dst -j CLOUD_MUSIC 2>/dev/null
if [ "$APPTYPE" == "cloud" ]; then
local lan_addr
. /lib/functions/network.sh
network_flush_cache
network_get_ipaddr lanaddr "lan"
$ipt_n -D POSTROUTING -p tcp -m multiport --dport $cloudhttp,$cloudhttps -d $cloudip -j SNAT --to-source $lanaddr 2>/dev/null
fi
$ipt_n -F CLOUD_MUSIC 2>/dev/null
$ipt_n -X CLOUD_MUSIC 2>/dev/null
iptables -D OUTPUT -d 223.252.199.10 -j DROP 2>/dev/null
ipset flush music 2>/dev/null
ipset -X music_http 2>/dev/null
ipset -X music_https 2>/dev/null
ipset -X music_proxy_http 2>/dev/null
ipset -X music_proxy_https 2>/dev/null
rm -f /tmp/dnsmasq.d/dnsmasq-163.conf
/etc/init.d/dnsmasq reload >/dev/null 2>&1
}
set_firewall(){
rm -f /tmp/dnsmasq.d/dnsmasq-163.conf
mkdir -p /tmp/dnsmasq.d
cat <<-EOF > "/tmp/dnsmasq.d/dnsmasq-163.conf"
ipset=/.music.163.com/music
ipset=/interface.music.163.com/music
ipset=/interface3.music.163.com/music
ipset=/apm.music.163.com/music
ipset=/apm3.music.163.com/music
ipset=/clientlog.music.163.com/music
ipset=/clientlog3.music.163.com/music
EOF
/etc/init.d/dnsmasq reload >/dev/null 2>&1
add_rule
mkdir -p /var/etc
echo -e "/etc/init.d/unblockmusic restart" > "/var/etc/unblockmusic.include"
}
add_cron()
{
if [ $AUTOUPDATE -eq 1 ]; then
sed -i '/update_core.sh/d' $CRON_FILE
echo '0 2 * * * /usr/share/UnblockNeteaseMusic/update_core.sh 2>&1' >> $CRON_FILE
crontab $CRON_FILE
fi
}
del_cron()
{
sed -i '/update_core.sh/d' $CRON_FILE
/etc/init.d/cron restart
}
start()
{
stop
[ $ENABLE -eq "0" ] && exit 0
rm -f /tmp/unblockmusic.log
echo "$(date -R) # Start UnblockNeteaseMusic" >/tmp/unblockmusic.log
if [ "$TYPE" = "default" ]; then
musictype=" "
else
musictype="-o $TYPE"
fi
if [ "$APPTYPE" == "nodejs" ]; then
if [ $FLAC -eq 1 ]; then
export ENABLE_FLAC=true
fi
if [ $REPLACE_MUSIC_SOURCE -ne 0 ]; then
export MIN_BR=$REPLACE_MUSIC_SOURCE
fi
if [ $LOCAL_VIP -eq 1 ]; then
export ENABLE_LOCAL_VIP=true
fi
node /usr/share/UnblockNeteaseMusic/app.js -p 5200 $musictype >>/tmp/unblockmusic.log 2>&1 &
node /usr/share/UnblockNeteaseMusic/app.js -e https://music.163.com -p 5203:5201 $musictype >>/tmp/unblockmusic.log 2>&1 &
add_cron
echo "$(date -R) # UnblockNeteaseMusic Nodejs Version (http:5200, https:5201)" >>/tmp/unblockmusic.log
elif [ "$APPTYPE" == "go" ]; then
if [ $FLAC -eq 1 ]; then
ENABLE_FLAC="-b "
fi
UnblockNeteaseMusic -o "kuwo:kugou" $ENABLE_FLAC -p 5200 -sp 5201 -c /usr/share/UnblockNeteaseMusicGo/server.crt -k /usr/share/UnblockNeteaseMusicGo/server.key -m 0 -e -sl ${SEARCHLIMIT} -l /tmp/unblockmusic.log &
echo "$(date -R) # UnblockNeteaseMusic Golang Version (http:5200, https:5201)" >>/tmp/unblockmusic.log
else
kill -9 $(busybox ps -w | grep 'sleep 60m' | grep -v grep | awk '{print $1}') >/dev/null 2>&1
/usr/bin/UnblockNeteaseMusicCloud >/dev/null 2>&1 &
echo "$(date -R) # UnblockNeteaseMusic Cloud Version - Server: $cloudip (http:$cloudhttp, https:$cloudhttps)" >>/tmp/unblockmusic.log
fi
set_firewall
if [ "$APPTYPE" != "cloud" ]; then
/usr/share/UnblockNeteaseMusic/logcheck.sh >/dev/null 2>&1 &
fi
}
stop()
{
kill -9 $(busybox ps -w | grep UnblockNeteaseMusic | grep -v grep | awk '{print $1}') >/dev/null 2>&1
kill -9 $(busybox ps -w | grep logcheck.sh | grep -v grep | awk '{print $1}') >/dev/null 2>&1
rm -f /tmp/unblockmusic.log
del_rule
del_cron
}

View File

@ -0,0 +1,18 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@unblockmusic[-1]
add ucitrack unblockmusic
set ucitrack.@unblockmusic[-1].init=unblockmusic
commit ucitrack
delete firewall.unblockmusic
set firewall.unblockmusic=include
set firewall.unblockmusic.type=script
set firewall.unblockmusic.path=/var/etc/unblockmusic.include
set firewall.unblockmusic.reload=1
commit firewall
EOF
rm -f /tmp/luci-indexcache
exit 0

View File

@ -0,0 +1,6 @@
/usr/share/UnblockNeteaseMusic/ca.crt
/usr/share/UnblockNeteaseMusic/server.crt
/usr/share/UnblockNeteaseMusic/server.key
/usr/share/UnblockNeteaseMusicGo/ca.crt
/usr/share/UnblockNeteaseMusicGo/server.crt
/usr/share/UnblockNeteaseMusicGo/server.key

View File

@ -0,0 +1,8 @@
#!/bin/sh
while true
do
ipset -! flush music
uclient-fetch -q -T 10 http://httpdns.n.netease.com/httpdns/v2/d?domain=music.163.com,interface.music.163.com,interface3.music.163.com,apm.music.163.com,apm3.music.163.com,clientlog.music.163.com,clientlog3.music.163.com -O- | grep -Eo '[0-9]+?\.[0-9]+?\.[0-9]+?\.[0-9]+?' | sort | uniq | awk '{print "ipset -! add music "$1}' | sh
sleep 60m
done

View File

@ -0,0 +1,4 @@
#!/bin/sh
ipset -! -N music hash:ip
uclient-fetch -q -T 10 http://httpdns.n.netease.com/httpdns/v2/d?domain=music.163.com,interface.music.163.com,interface3.music.163.com,apm.music.163.com,apm3.music.163.com,clientlog.music.163.com,clientlog3.music.163.com -O- | grep -Eo '[0-9]+?\.[0-9]+?\.[0-9]+?\.[0-9]+?' | sort | uniq | awk '{print "ipset -! add music "$1}' | sh

View File

@ -0,0 +1,19 @@
#!/bin/sh
log_max_size=100
log_file="/tmp/unblockmusic.log"
log_size=0
/usr/share/UnblockNeteaseMusic/getmusicip.sh
sleep 29s
while true
do
icount=`busybox ps -w | grep UnblockNeteaseMusic | grep -v grep | grep -v logcheck.sh`
if [ -z "$icount" ]; then
/etc/init.d/unblockmusic restart
fi
log_size=$(expr $(ls -l $log_file | awk '{print $5}') / 1024)
[ $log_size -ge $log_max_size ] && echo "$(date -R) # Start UnblockNeteaseMusic" >/tmp/unblockmusic.log
sleep 29s
done

View File

@ -0,0 +1,67 @@
#!/bin/sh
function check_if_already_running(){
running_tasks="$(ps |grep "unblockneteasemusic" |grep "update_core" |grep -v "grep" |awk '{print $1}' |wc -l)"
[ "${running_tasks}" -gt "2" ] && echo -e "\nA task is already running." >>/tmp/unblockmusic_update.log && exit 2
}
function clean_log(){
echo "" > /tmp/unblockmusic_update.log
}
function check_latest_version(){
latest_ver="$(uclient-fetch --no-check-certificate -O- https://github.com/UnblockNeteaseMusic/server/commits/enhanced |tr -d '\n' |grep -Eo 'commit\/[0-9a-z]+' |sed -n 1p |sed 's#commit/##g')"
[ -z "${latest_ver}" ] && echo -e "\nFailed to check latest version, please try again later." >>/tmp/unblockmusic_update.log && exit 1
if [ ! -e "/usr/share/UnblockNeteaseMusic/local_ver" ]; then
clean_log
echo -e "Local version: NOT FOUND, cloud version: ${latest_ver}." >>/tmp/unblockmusic_update.log
update_core
else
if [ "$(cat /usr/share/UnblockNeteaseMusic/local_ver)" != "${latest_ver}" ]; then
clean_log
update_core
else
echo -e "\nLocal version: $(cat /usr/share/UnblockNeteaseMusic/local_ver 2>/dev/null), cloud version: ${latest_ver}." >>/tmp/unblockmusic_update.log
echo -e "You're already using the latest version." >>/tmp/unblockmusic_update.log
[ "${luci_update}" == "n" ] && /etc/init.d/unblockmusic restart
exit 3
fi
fi
}
function update_core(){
echo -e "Updating core..." >>/tmp/unblockmusic_update.log
mkdir -p "/tmp/unblockneteasemusic/core" >/dev/null 2>&1
rm -rf /tmp/unblockneteasemusic/core/* >/dev/null 2>&1
uclient-fetch --no-check-certificate -T 10 -O /tmp/unblockneteasemusic/core/core.tar.gz "https://github.com/UnblockNeteaseMusic/server/archive/enhanced.tar.gz" >/dev/null 2>&1
tar -zxf "/tmp/unblockneteasemusic/core/core.tar.gz" -C "/tmp/unblockneteasemusic/core/" >/dev/null 2>&1
if [ -e "/usr/share/UnblockNeteaseMusic/ca.crt" ] && [ -e "/usr/share/UnblockNeteaseMusic/server.crt" ] && [ -e "/usr/share/UnblockNeteaseMusic/server.key" ] ; then
rm -f /tmp/unblockneteasemusic/core/server-enhanced/ca.crt /tmp/unblockneteasemusic/core/server-enhanced/server.crt /tmp/unblockneteasemusic/core/server-enhanced/server.key
fi
cp -a /tmp/unblockneteasemusic/core/server-enhanced/* "/usr/share/UnblockNeteaseMusic/"
rm -rf "/tmp/unblockneteasemusic" >/dev/null 2>&1
if [ ! -e "/usr/share/UnblockNeteaseMusic/app.js" ]; then
echo -e "Failed to download core." >>/tmp/unblockmusic_update.log
exit 1
else
echo -e "${latest_ver}" > /usr/share/UnblockNeteaseMusic/local_ver
cat /usr/share/UnblockNeteaseMusic/package.json | grep version |awk -F ':' '{print $2}' | sed -r 's/.*"(.+)".*/\1/' > /usr/share/UnblockNeteaseMusic/core_ver
fi
echo -e "Succeeded in updating core." >>/tmp/unblockmusic_update.log
echo -e "Local version: $(cat /usr/share/UnblockNeteaseMusic/local_ver 2>/dev/null), cloud version: ${latest_ver}.\n" >>/tmp/unblockmusic_update.log
/etc/init.d/unblockmusic restart
}
function main(){
check_if_already_running
check_latest_version
}
luci_update="n"
[ "$1" == "luci_update" ] && luci_update="y"
main

View File

@ -0,0 +1,11 @@
{
"luci-app-unblockmusic": {
"description": "Grant UCI access for luci-app-unblockmusic",
"read": {
"uci": [ "unblockmusic" ]
},
"write": {
"uci": [ "unblockmusic" ]
}
}
}

49
luci-lib-fs/Makefile Normal file
View File

@ -0,0 +1,49 @@
#
# Copyright (C) 2009 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-lib-fs
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/luci-lib-fs
SUBMENU:=Lua
SECTION:=lang
CATEGORY:=Languages
TITLE:=luci-lib-fs
PKGARCH:=all
URL:=https://github.com/lbthomsen/openwrt-luci
DEPENDS:=+luci-lib-nixio
endef
define Package/luci-lib-fs/description
luci-lib-fs
endef
define Build/Configure
endef
define Build/Compile
endef
define Build/Install
endef
define Package/luci-lib-fs/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
$(CP) ./files/*.lua $(1)/usr/lib/lua/luci
endef
$(eval $(call BuildPackage,luci-lib-fs))

244
luci-lib-fs/files/fs.lua Normal file
View File

@ -0,0 +1,244 @@
--[[
LuCI - Filesystem tools
Description:
A module offering often needed filesystem manipulation functions
FileId:
$Id$
License:
Copyright 2008 Steven Barth <steven@midlink.org>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
]]--
local io = require "io"
local os = require "os"
local ltn12 = require "luci.ltn12"
local fs = require "nixio.fs"
local nutil = require "nixio.util"
local type = type
--- LuCI filesystem library.
module "luci.fs"
--- Test for file access permission on given path.
-- @class function
-- @name access
-- @param str String value containing the path
-- @return Number containing the return code, 0 on sucess or nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
access = fs.access
--- Evaluate given shell glob pattern and return a table containing all matching
-- file and directory entries.
-- @class function
-- @name glob
-- @param filename String containing the path of the file to read
-- @return Table containing file and directory entries or nil if no matches
-- @return String containing the error description (if no matches)
-- @return Number containing the os specific errno (if no matches)
function glob(...)
local iter, code, msg = fs.glob(...)
if iter then
return nutil.consume(iter)
else
return nil, code, msg
end
end
--- Checks wheather the given path exists and points to a regular file.
-- @param filename String containing the path of the file to test
-- @return Boolean indicating wheather given path points to regular file
function isfile(filename)
return fs.stat(filename, "type") == "reg"
end
--- Checks wheather the given path exists and points to a directory.
-- @param dirname String containing the path of the directory to test
-- @return Boolean indicating wheather given path points to directory
function isdirectory(dirname)
return fs.stat(dirname, "type") == "dir"
end
--- Read the whole content of the given file into memory.
-- @param filename String containing the path of the file to read
-- @return String containing the file contents or nil on error
-- @return String containing the error message on error
readfile = fs.readfile
--- Write the contents of given string to given file.
-- @param filename String containing the path of the file to read
-- @param data String containing the data to write
-- @return Boolean containing true on success or nil on error
-- @return String containing the error message on error
writefile = fs.writefile
--- Copies a file.
-- @param source Source file
-- @param dest Destination
-- @return Boolean containing true on success or nil on error
copy = fs.datacopy
--- Renames a file.
-- @param source Source file
-- @param dest Destination
-- @return Boolean containing true on success or nil on error
rename = fs.move
--- Get the last modification time of given file path in Unix epoch format.
-- @param path String containing the path of the file or directory to read
-- @return Number containing the epoch time or nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
function mtime(path)
return fs.stat(path, "mtime")
end
--- Set the last modification time of given file path in Unix epoch format.
-- @param path String containing the path of the file or directory to read
-- @param mtime Last modification timestamp
-- @param atime Last accessed timestamp
-- @return 0 in case of success nil on error
-- @return String containing the error description (if any)
-- @return Number containing the os specific errno (if any)
function utime(path, mtime, atime)
return fs.utimes(path, atime, mtime)
end
--- Return the last element - usually the filename - from the given path with
-- the directory component stripped.
-- @class function
-- @name basename
-- @param path String containing the path to strip
-- @return String containing the base name of given path
-- @see dirname
basename = fs.basename
--- Return the directory component of the given path with the last element
-- stripped of.
-- @class function
-- @name dirname
-- @param path String containing the path to strip
-- @return String containing the directory component of given path
-- @see basename
dirname = fs.dirname
--- Return a table containing all entries of the specified directory.
-- @class function
-- @name dir
-- @param path String containing the path of the directory to scan
-- @return Table containing file and directory entries or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function dir(...)
local iter, code, msg = fs.dir(...)
if iter then
local t = nutil.consume(iter)
t[#t+1] = "."
t[#t+1] = ".."
return t
else
return nil, code, msg
end
end
--- Create a new directory, recursively on demand.
-- @param path String with the name or path of the directory to create
-- @param recursive Create multiple directory levels (optional, default is true)
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function mkdir(path, recursive)
return recursive and fs.mkdirr(path) or fs.mkdir(path)
end
--- Remove the given empty directory.
-- @class function
-- @name rmdir
-- @param path String containing the path of the directory to remove
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
rmdir = fs.rmdir
local stat_tr = {
reg = "regular",
dir = "directory",
lnk = "link",
chr = "character device",
blk = "block device",
fifo = "fifo",
sock = "socket"
}
--- Get information about given file or directory.
-- @class function
-- @name stat
-- @param path String containing the path of the directory to query
-- @return Table containing file or directory properties or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function stat(path, key)
local data, code, msg = fs.stat(path)
if data then
data.mode = data.modestr
data.type = stat_tr[data.type] or "?"
end
return key and data and data[key] or data, code, msg
end
--- Set permissions on given file or directory.
-- @class function
-- @name chmod
-- @param path String containing the path of the directory
-- @param perm String containing the permissions to set ([ugoa][+-][rwx])
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
chmod = fs.chmod
--- Create a hard- or symlink from given file (or directory) to specified target
-- file (or directory) path.
-- @class function
-- @name link
-- @param path1 String containing the source path to link
-- @param path2 String containing the destination path for the link
-- @param symlink Boolean indicating wheather to create a symlink (optional)
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
function link(src, dest, sym)
return sym and fs.symlink(src, dest) or fs.link(src, dest)
end
--- Remove the given file.
-- @class function
-- @name unlink
-- @param path String containing the path of the file to remove
-- @return Number with the return code, 0 on sucess or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
unlink = fs.unlink
--- Retrieve target of given symlink.
-- @class function
-- @name readlink
-- @param path String containing the path of the symlink to read
-- @return String containing the link target or nil on error
-- @return String containing the error description on error
-- @return Number containing the os specific errno on error
readlink = fs.readlink

View File

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=lucky
PKG_VERSION:=2.10.8
PKG_VERSION:=2.13.4
PKG_RELEASE:=1
PKGARCH:=all
@ -45,7 +45,7 @@ PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=GDY666 <gdy666@foxmail.com>
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_HASH:=6c096825c4d35d30878283e61bdb5a94c571ef29c5b92a7fe38987127dd281b4
PKG_HASH:=e8064a2e257dad42a991bd691adba56b398142b7fb618d7a4fa1b7a892bc4418
include $(INCLUDE_DIR)/package.mk