🐶 Sync 2022-12-25 06:15

This commit is contained in:
github-actions[bot] 2022-12-25 06:15:27 +08:00
parent 57cb000ca5
commit 083d72286f
18 changed files with 663 additions and 0 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 ../../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,121 @@
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")
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"))
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,223 @@
#!/bin/sh /etc/rc.common
. /lib/functions/network.sh
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
;;
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)
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)
network_flush_cache
network_get_ipaddr lanaddr "lan"
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
$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 REDIRECT --to-ports 5200
$ipt_n -A CLOUD_MUSIC -p tcp -m set ! --match-set music_https src --dport 443 -j REDIRECT --to-ports 5201
else
$ipt_n -A CLOUD_MUSIC -p tcp -m set ! --match-set music_http src --dport 80 -j DNAT --to $cloudip:$cloudhttp
$ipt_n -A CLOUD_MUSIC -p tcp -m set ! --match-set music_https src --dport 443 -j DNAT --to $cloudip:$cloudhttps
$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
$ipt_n -D POSTROUTING -p tcp -m multiport --dport $cloudhttp,$cloudhttps -d $cloudip -j SNAT --to-source $lanaddr 2>/dev/null
$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
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 -! -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
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" ]
}
}
}

59
smartdns/Makefile Normal file
View File

@ -0,0 +1,59 @@
#
# Copyright (c) 2018-2022 Nick Peng (pymumu@gmail.com)
# This is free software, licensed under the GNU General Public License v3.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=smartdns
PKG_VERSION:=1.2022.38.1
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://www.github.com/pymumu/smartdns.git
PKG_SOURCE_VERSION:=9bc857f628299573c7eca0833229d9812b1c1de4
PKG_MIRROR_HASH:=a202b765e6ce8355335c80214819add3ed72a82426b033d7d5adf1448b415063
PKG_MAINTAINER:=Nick Peng <pymumu@gmail.com>
PKG_LICENSE:=GPL-3.0-or-later
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
MAKE_VARS += VER=$(PKG_VERSION)
MAKE_PATH:=src
define Package/smartdns
SECTION:=net
CATEGORY:=Network
TITLE:=smartdns server
DEPENDS:=+libpthread +libopenssl
URL:=https://www.github.com/pymumu/smartdns/
endef
define Package/smartdns/description
SmartDNS is a local DNS server which accepts DNS query requests from local network clients,
gets DNS query results from multiple upstream DNS servers concurrently, and returns the fastest IP to clients.
Unlike dnsmasq's all-servers, smartdns returns the fastest IP.
endef
define Package/smartdns/conffiles
/etc/config/smartdns
/etc/smartdns/address.conf
/etc/smartdns/blacklist-ip.conf
/etc/smartdns/custom.conf
endef
define Package/smartdns/install
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d $(1)/etc/smartdns
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/smartdns $(1)/usr/sbin/smartdns
$(INSTALL_BIN) $(PKG_BUILD_DIR)/package/openwrt/files/etc/init.d/smartdns $(1)/etc/init.d/smartdns
$(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/address.conf $(1)/etc/smartdns/address.conf
$(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/blacklist-ip.conf $(1)/etc/smartdns/blacklist-ip.conf
$(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/custom.conf $(1)/etc/smartdns/custom.conf
$(INSTALL_CONF) $(PKG_BUILD_DIR)/package/openwrt/files/etc/config/smartdns $(1)/etc/config/smartdns
endef
$(eval $(call BuildPackage,smartdns))