Merge Lean's source

This commit is contained in:
CN_SZTL 2020-02-17 16:48:23 +08:00
parent 8d3b3f5ccb
commit 6f5dde6014
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
5 changed files with 40 additions and 31 deletions

View File

@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-unblockmusic
PKG_VERSION:=2.3.1
PKG_RELEASE:=7
PKG_RELEASE:=8
PKG_LICENSE:=Apache-2.0
@ -20,5 +20,16 @@ PKG_MAINTAINER:=lean
include $(TOPDIR)/feeds/luci/luci.mk
define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
( . /etc/uci-defaults/unblockmusic ) && rm -f /etc/uci-defaults/unblockmusic
rm -f /tmp/luci-indexcache
/bin/sh /etc/ppp/ip-up.d/unblockmusic.sh &
/etc/init.d/unblockmusic disable >/dev/null 2>&1
fi
exit 0
endef
# call BuildPackage - OpenWrt buildroot signature

View File

@ -13,11 +13,6 @@ enabled.default = 0
enabled.rmempty = false
enabled.description = translate("启用后,路由器自动分流解锁,大部分设备无需设置代理")
proxy = s:option(Flag, "proxy", translate("开启独立的HTTP代理服务"))
proxy.default = 0
proxy.rmempty = false
proxy.description = translate("某些PC版本客户端不能自动解锁需要手动设置 HTTP代理 为 路由器IP:5200端口 ")
speedtype = s:option(ListValue, "musicapptype", translate("音源选择"))
speedtype:value("default", translate("默认"))
speedtype:value("netease", translate("网易云音乐"))
@ -30,9 +25,9 @@ speedtype:value("migu", translate("咕咪音乐"))
speedtype:value("joox", translate("JOOX音乐"))
endpoint = s:option(Value, "endpoint", translate("转发HTTPS音源地址"))
endpoint.default = "https://music.163.com"
endpoint.default = "http://music.163.com"
endpoint.rmempty = true
endpoint.description = translate("默认为 https://music.163.com")
endpoint.description = translate("默认为 http://music.163.com")
o = s:option(Button,"certificate",translate("HTTPS 证书"))
o.inputtitle = translate("下载 CA 根证书")
@ -76,4 +71,4 @@ o.write = function()
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "unblockmusic"))
end
return mp
return mp

View File

@ -2,7 +2,6 @@
config unblockmusic
option musicapptype 'default'
option autoupdate '1'
option endpoint 'https://music.163.com'
option proxy '1'
option endpoint 'http://music.163.com'
option enabled '0'

View File

@ -0,0 +1,6 @@
#!/bin/sh
[ "${ACTION}" = "ifup" ] && {
sleep 10
wget 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

@ -25,8 +25,8 @@ add_rule()
$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
$ipt_n -A cloud_music -p tcp --dport 80 -j REDIRECT --to-ports 5201
$ipt_n -A cloud_music -p tcp --dport 443 -j REDIRECT --to-ports 5202
$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
$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
}
@ -42,27 +42,29 @@ del_rule(){
}
set_firewall(){
rm -f /tmp/dnsmasq.d/dnsmasq-163.conf
mkdir -p /tmp/dnsmasq.d
echo "ipset=/music.163.com/music" >> /tmp/dnsmasq.d/dnsmasq-163.conf
echo "ipset=/interface.music.163.com/music" >> /tmp/dnsmasq.d/dnsmasq-163.conf
echo "ipset=/interface3.music.163.com/music" >> /tmp/dnsmasq.d/dnsmasq-163.conf
echo "ipset=/apm.music.163.com/music" >> /tmp/dnsmasq.d/dnsmasq-163.conf
echo "ipset=/apm3.music.163.com/music" >> /tmp/dnsmasq.d/dnsmasq-163.conf
/etc/init.d/dnsmasq restart >/dev/null 2>&1
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
cat > "/var/etc/unblockmusic.include" <<-EOF
/etc/init.d/unblockmusic restart
EOF
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
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
@ -95,15 +97,11 @@ start()
musictype="-o $TYPE"
fi
node /usr/share/UnblockNeteaseMusic/app.js $endponintset -p 5201:5202 $musictype >>/tmp/unblockmusic.log 2>&1 &
if [ $PROXY -eq "1" ]; then
node /usr/share/UnblockNeteaseMusic/app.js -p 5200 $musictype >>/tmp/unblockmusic.log 2>&1 &
fi
node /usr/share/UnblockNeteaseMusic/app.js $endponintset -p 5200:5201 $musictype >>/tmp/unblockmusic.log 2>&1 &
set_firewall
add_cron
/usr/share/UnblockNeteaseMusic/logcheck.sh >/dev/null 2>&1 &
}