add UnblockNeteaseMusic
This commit is contained in:
parent
11de7d4f1b
commit
7a923b2997
51
package/cnsztl/UnblockNeteaseMusic-nondanee/Makefile
Normal file
51
package/cnsztl/UnblockNeteaseMusic-nondanee/Makefile
Normal file
@ -0,0 +1,51 @@
|
||||
#
|
||||
# Copyright (C) 2019 [CTCGFW]Project-OpenWRT
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=UnblockNeteaseMusic-nondanee
|
||||
PKG_VERSION:=latest
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=[CTCGFW]Project-OpenWRT
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Revive unavailable songs for Netease Cloud Music on OpenWRT
|
||||
URL:=https://github.com/nondanee/UnblockNeteaseMusic
|
||||
DEPENDS:=+node
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
Revive unavailable songs for Netease Cloud Music on OpenWRT
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
rm -f $(DL_DIR)/$(PKG_NAME).tar.gz
|
||||
wget https://github.com/nondanee/UnblockNeteaseMusic/archive/master.tar.gz -O $(DL_DIR)/$(PKG_NAME).tar.gz
|
||||
tar -xzf $(DL_DIR)/$(PKG_NAME).tar.gz -C $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/share/unblockneteasemusic
|
||||
cp -fpR $(PKG_BUILD_DIR)/UnblockNeteaseMusic-master/* $(1)/usr/share/unblockneteasemusic/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
21
package/cnsztl/luci-app-unblockneteasemusic/Makefile
Normal file
21
package/cnsztl/luci-app-unblockneteasemusic/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is a free software, use it under GNU General Public License v3.0.
|
||||
#
|
||||
# Created By [CTCGFW]Project-OpenWRT
|
||||
# https://github.com/project-openwrt
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for UnblockNeteaseMusic-nondanee
|
||||
LUCI_DEPENDS:=+UnblockNeteaseMusic-nondanee +bash +dnsmasq-full +ipset
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-unblockneteasemusic
|
||||
PKG_VERSION:=1.5
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=<https://github.com/project-openwrt/UnblockNeteaseMusic>
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@ -0,0 +1,25 @@
|
||||
-- This is a free software, use it under GNU General Public License v3.0.
|
||||
-- Created By [CTCGFW]Project OpenWRT
|
||||
-- https://github.com/project-openwrt
|
||||
|
||||
module("luci.controller.unblockneteasemusic", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/unblockneteasemusic") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "unblockneteasemusic"},firstchild(), _("解除网易云音乐播放限制"), 50).dependent = false
|
||||
|
||||
entry({"admin", "services", "unblockneteasemusic", "general"},cbi("unblockneteasemusic"), _("Base Setting"), 1)
|
||||
entry({"admin", "services", "unblockneteasemusic", "log"},form("unblockneteasemusiclog"), _("Log"), 2)
|
||||
|
||||
entry({"admin", "services", "unblockneteasemusic", "status"},call("act_status")).leaf=true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("ps |grep unblockneteasemusic |grep app.js |grep -v grep >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
@ -0,0 +1,100 @@
|
||||
|
||||
mp = Map("unblockneteasemusic", translate("解除网易云音乐播放限制"))
|
||||
mp.description = translate("原理:采用 [网易云旧链/QQ/虾米/百度/酷狗/酷我/咕咪/JOOX] 等音源,替换网易云音乐 无版权/收费 歌曲链接<br/>具体使用方法参见:https://github.com/project-openwrt/UnblockNeteaseMusic")
|
||||
|
||||
mp:section(SimpleSection).template = "unblockneteasemusic/unblockneteasemusic_status"
|
||||
|
||||
s = mp:section(TypedSection, "unblockneteasemusic")
|
||||
s.anonymous=true
|
||||
s.addremove=false
|
||||
|
||||
enabled = s:option(Flag, "enabled", translate("启用本插件"))
|
||||
enabled.description = translate("启用本插件以解除网易云音乐播放限制")
|
||||
enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
|
||||
account = s:option(Value, "http_port", translate("[HTTP] 监听端口"))
|
||||
account.description = translate("本插件监听的HTTP端口,不可与其他程序/HTTPS共用一个端口")
|
||||
account.placeholder = "5200"
|
||||
account.default = "5200"
|
||||
account.datatype = "port"
|
||||
account:depends("enabled", 1)
|
||||
|
||||
account = s:option(Value, "https_port", translate("[HTTPS] 监听端口"))
|
||||
account.description = translate("[如HTTP端口设置为80,请将HTTPS端口设置为443] 本插件监听的HTTPS端口,不可与其他程序/HTTP共用一个端口")
|
||||
account.placeholder = "5201"
|
||||
account.default = "5201"
|
||||
account.datatype = "port"
|
||||
account:depends("enabled", 1)
|
||||
|
||||
speedtype = s:option(ListValue, "musicapptype", translate("音源接口"))
|
||||
speedtype:value("default", translate("默认"))
|
||||
speedtype:value("netease", translate("网易云音乐"))
|
||||
speedtype:value("qq", translate("QQ音乐"))
|
||||
speedtype:value("xiami", translate("虾米音乐"))
|
||||
speedtype:value("baidu", translate("百度音乐"))
|
||||
speedtype:value("kugou", translate("酷狗音乐"))
|
||||
speedtype:value("kuwo", translate("酷我音乐"))
|
||||
speedtype:value("migu", translate("咕咪音乐"))
|
||||
speedtype:value("joox", translate("JOOX音乐"))
|
||||
speedtype:value("all", translate("所有平台"))
|
||||
speedtype.description = translate("音源调用接口")
|
||||
speedtype.default = "default"
|
||||
speedtype:depends("enabled", 1)
|
||||
|
||||
enabled = s:option(Flag, "enable_hijack", translate("启用劫持"))
|
||||
enabled.description = translate("开启后,网易云音乐相关请求会被强制劫持到本插件进行处理")
|
||||
account.default = 0
|
||||
enabled.rmempty = false
|
||||
enabled:depends("enabled", 1)
|
||||
|
||||
hijack = s:option(ListValue, "hijack_ways", translate("劫持方法"))
|
||||
hijack:value("use_ipset", translate("使用IPSet劫持"))
|
||||
hijack:value("use_hosts", translate("使用Hosts劫持"))
|
||||
hijack.description = translate("如果使用Hosts劫持,请将HTTP/HTTPS端口设置为80/443")
|
||||
hijack.default = "use_ipset"
|
||||
hijack:depends("enable_hijack", 1)
|
||||
|
||||
enabled = s:option(Flag, "advanced_mode", translate("启用进阶设置"))
|
||||
enabled.description = translate("仅推荐高级玩家使用")
|
||||
enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
enabled:depends("enabled", 1)
|
||||
|
||||
enabled = s:option(Flag, "pub_access", translate("部署到公网"))
|
||||
enabled.description = translate("默认仅监听局域网,如需提供公开访问请勾选此选项;与此同时,建议勾选“启用严格模式”")
|
||||
enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
enabled:depends("advanced_mode", 1)
|
||||
|
||||
enabled = s:option(Flag, "strict_mode", translate("启用严格模式"))
|
||||
enabled.description = translate("若将服务部署到公网,则强烈建议使用严格模式,此模式下仅放行网易云音乐所属域名的请求")
|
||||
enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
enabled:depends("advanced_mode", 1)
|
||||
|
||||
enabled = s:option(Flag, "set_netease_server_ip", translate("自定义网易云服务器IP"))
|
||||
enabled.description = translate("如手动更改了Hosts文件则必选,否则将会导致连接死循环")
|
||||
enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
enabled:depends("advanced_mode", 1)
|
||||
|
||||
account = s:option(Value, "netease_server_ip", translate("网易云服务器IP"))
|
||||
account.description = translate("通过 ping music.163.com 即可获得IP地址,仅限填写一个")
|
||||
account.default = "59.111.181.38"
|
||||
account.placeholder = "59.111.181.38"
|
||||
account.datatype = "ipaddr"
|
||||
account:depends("set_netease_server_ip", 1)
|
||||
|
||||
enabled = s:option(Flag, "enable_proxy", translate("使用代理服务器"))
|
||||
enabled.description = translate("如您的OpenWRT/LEDE系统部署在海外,则此选项必选,否则可能无法正常使用")
|
||||
enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
enabled:depends("advanced_mode", 1)
|
||||
|
||||
account = s:option(Value, "proxy_server_ip", translate("代理服务器IP"))
|
||||
account.description = translate("具体格式请参考:https://github.com/nondanee/UnblockNeteaseMusic")
|
||||
account.datatype = "string"
|
||||
account:depends("enable_proxy", 1)
|
||||
|
||||
return mp
|
||||
@ -0,0 +1,14 @@
|
||||
local fs = require "nixio.fs"
|
||||
local conffile = "/tmp/unblockneteasemusic.log"
|
||||
|
||||
f = SimpleForm("logview")
|
||||
|
||||
t = f:field(TextValue, "conf")
|
||||
t.rmempty = true
|
||||
t.rows = 15
|
||||
function t.cfgvalue()
|
||||
return fs.readfile(conffile) or ""
|
||||
end
|
||||
t.readonly="readonly"
|
||||
|
||||
return f
|
||||
@ -0,0 +1,22 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[unblockneteasemusic]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('unblockneteasemusic_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="unblockneteasemusic_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
||||
@ -0,0 +1,13 @@
|
||||
|
||||
config unblockneteasemusic
|
||||
option enabled '0'
|
||||
option http_port '5200'
|
||||
option https_port '5201'
|
||||
option musicapptype 'default'
|
||||
option enable_hijack '0'
|
||||
option hijack_ways 'use_ipset'
|
||||
option advanced_mode '0'
|
||||
option pub_access '0'
|
||||
option strict_mode '0'
|
||||
option set_netease_server_ip '0'
|
||||
option enable_proxy '0'
|
||||
127
package/cnsztl/luci-app-unblockneteasemusic/root/etc/init.d/unblockneteasemusic
Executable file
127
package/cnsztl/luci-app-unblockneteasemusic/root/etc/init.d/unblockneteasemusic
Executable file
@ -0,0 +1,127 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Created By [CTCGFW]Project OpenWRT
|
||||
# https://github.com/project-openwrt
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
|
||||
lan_addr="$(uci get network.lan.ipaddr)"
|
||||
|
||||
enable="$(uci get unblockneteasemusic.@unblockneteasemusic[0].enabled)"
|
||||
http_port="$(uci get unblockneteasemusic.@unblockneteasemusic[0].http_port)"
|
||||
https_port="$(uci get unblockneteasemusic.@unblockneteasemusic[0].https_port)"
|
||||
type="$(uci get unblockneteasemusic.@unblockneteasemusic[0].musicapptype)"
|
||||
[ "$(uci get unblockneteasemusic.@unblockneteasemusic[0].enable_hijack)" -eq "1" ] && hijack_ways="$(uci get unblockneteasemusic.@unblockneteasemusic[0].hijack_ways)"
|
||||
|
||||
[ "$(uci get unblockneteasemusic.@unblockneteasemusic[0].pub_access)" -ne "0" ] && addr="0.0.0.0" || addr="${lan_addr}"
|
||||
[ "$(uci get unblockneteasemusic.@unblockneteasemusic[0].strict_mode)" -eq "1" ] && strict_mode="-s"
|
||||
[ "$(uci get unblockneteasemusic.@unblockneteasemusic[0].set_netease_server_ip)" -ne "0" ] && netease_server_ip="-f $(uci get unblockneteasemusic.@unblockneteasemusic[0].netease_server_ip)"
|
||||
[ "$(uci get unblockneteasemusic.@unblockneteasemusic[0].enable_proxy)" -ne "0" ] && proxy_server_ip="-u $(uci get unblockneteasemusic.@unblockneteasemusic[0].proxy_server_ip)"
|
||||
|
||||
|
||||
set_ipset(){
|
||||
if [ "${set_type}" = "start" ]; then
|
||||
mkdir -p "/tmp/dnsmasq.d"
|
||||
rm -f "/tmp/dnsmasq.d/dnsmasq-unblockneteasemusic.conf"
|
||||
echo "dhcp-option=252,http://${lan_addr}:${http_port}/proxy.pac" > "/tmp/dnsmasq.d/dnsmasq-unblockneteasemusic.conf"
|
||||
echo "ipset=/.music.163.com/music" >> "/tmp/dnsmasq.d/dnsmasq-unblockneteasemusic.conf"
|
||||
echo "ipset=/interface.music.163.com/music" >> "/tmp/dnsmasq.d/dnsmasq-unblockneteasemusic.conf"
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
|
||||
mkdir -p /var/etc
|
||||
cat > "/var/etc/unblockneteasemusic.include" <<-EOF
|
||||
if ! ipset list music >/dev/null; then ipset create music hash:ip; fi
|
||||
iptables -t nat -N cloud_music
|
||||
iptables -t nat -A cloud_music -d 0.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A cloud_music -d 10.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A cloud_music -d 127.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A cloud_music -d 169.254.0.0/16 -j RETURN
|
||||
iptables -t nat -A cloud_music -d 172.16.0.0/12 -j RETURN
|
||||
iptables -t nat -A cloud_music -d 192.168.0.0/16 -j RETURN
|
||||
iptables -t nat -A cloud_music -d 224.0.0.0/4 -j RETURN
|
||||
iptables -t nat -A cloud_music -d 240.0.0.0/4 -j RETURN
|
||||
iptables -t nat -A cloud_music -i br-lan -p tcp --dport 80 -j DNAT --to ${lan_addr}:${http_port}
|
||||
iptables -t nat -A cloud_music -i br-lan -p tcp --dport 443 -j DNAT --to ${lan_addr}:${https_port}
|
||||
iptables -t nat -A prerouting_rule -i br-lan -p tcp -m set --match-set music dst -j cloud_music
|
||||
EOF
|
||||
/etc/init.d/firewall restart >/dev/null 2>&1
|
||||
elif [ "${set_type}" = "stop" ]; then
|
||||
echo "" > /var/etc/unblockneteasemusic.include
|
||||
/etc/init.d/firewall restart >/dev/null 2>&1
|
||||
|
||||
rm -f "/tmp/dnsmasq.d/dnsmasq-unblockneteasemusic.conf"
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
set_hosts(){
|
||||
if [ "${set_type}" = "start" ]; then
|
||||
cfg_name="$(uci add dhcp domain)"
|
||||
uci set dhcp."${cfg_name}".name='music.163.com'
|
||||
uci set dhcp."${cfg_name}".ip="$(uci get network.lan.ipaddr)"
|
||||
uci commit dhcp
|
||||
|
||||
cfg_name="$(uci add dhcp domain)"
|
||||
uci set dhcp."${cfg_name}".name='interface.music.163.com'
|
||||
uci set dhcp."${cfg_name}".ip="$(uci get network.lan.ipaddr)"
|
||||
uci commit dhcp
|
||||
|
||||
cfg_name="$(uci add dhcp domain)"
|
||||
uci set dhcp."${cfg_name}".name='music.httpdns.c.163.com'
|
||||
uci set dhcp."${cfg_name}".ip="127.0.0.1"
|
||||
uci commit dhcp
|
||||
|
||||
ip route add 223.252.199.10 dev lo
|
||||
elif [ "${set_type}" = "stop" ]; then
|
||||
music_id1="$(uci show dhcp| grep "interface.music.163.com"| grep -Eo "domain\[[0-9]+\]"| grep -Eo "[0-9]+")"
|
||||
uci delete dhcp.@domain["${music_id1}"]
|
||||
uci commit dhcp
|
||||
|
||||
music_id2="$(uci show dhcp| grep "music.httpdns.c.163.com"| grep -Eo "domain\[[0-9]+\]"| grep -Eo "[0-9]+")"
|
||||
uci delete dhcp.@domain["${music_id2}"]
|
||||
uci commit dhcp
|
||||
|
||||
music_id3="$(uci show dhcp| grep "music.163.com"| grep -Eo "domain\[[0-9]+\]"| grep -Eo "[0-9]+")"
|
||||
uci delete dhcp.@domain["${music_id3}"]
|
||||
uci commit dhcp
|
||||
|
||||
ip route del 223.252.199.10
|
||||
fi
|
||||
}
|
||||
|
||||
start()
|
||||
{
|
||||
stop
|
||||
|
||||
[ "${enable}" -eq "0" ] && exit 0
|
||||
|
||||
if [ "${type}" = "default" ]; then
|
||||
node /usr/share/unblockneteasemusic/app.js -a ${addr} -p ${http_port}:${https_port} ${netease_server_ip} ${proxy_server_ip} ${strict_mode} >/tmp/unblockneteasemusic.log 2>&1 &
|
||||
elif [ "${type}" = "all" ]; then
|
||||
node /usr/share/unblockneteasemusic/app.js -a ${addr} -p ${http_port}:${https_port} -o kuwo migu xiami kugou qq joox netease ${netease_server_ip} ${proxy_server_ip} ${strict_mode} >/tmp/unblockneteasemusic.log 2>&1 &
|
||||
else
|
||||
node /usr/share/unblockneteasemusic/app.js -a ${addr} -p ${http_port}:${https_port} -o ${type} ${netease_server_ip} ${proxy_server_ip} ${strict_mode} >/tmp/unblockneteasemusic.log 2>&1 &
|
||||
fi
|
||||
|
||||
if [ "*${hijack_ways}*" = "*use_ipset*" ]; then
|
||||
set_type="start"
|
||||
set_ipset
|
||||
elif [ "*${hijack_ways}*" = "*use_hosts*" ]; then
|
||||
set_type="start"
|
||||
set_hosts
|
||||
fi
|
||||
|
||||
/usr/share/unblockneteasemusic/logcheck.sh >/dev/null 2>&1 &
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
kill -9 "$(ps |grep unblockneteasemusic |grep app.js |grep -v grep |awk '{print $1}')" >/dev/null 2>&1
|
||||
kill -9 "$(ps |grep unblockneteasemusic |grep logcheck.sh |grep -v grep |awk '{print $1}')" >/dev/null 2>&1
|
||||
|
||||
rm -f /tmp/unblockneteasemusic.log
|
||||
|
||||
set_type="stop"
|
||||
set_ipset
|
||||
set_hosts
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@unblockneteasemusic[-1]
|
||||
add ucitrack unblockneteasemusic
|
||||
set ucitrack.@unblockneteasemusic[-1].init=unblockneteasemusic
|
||||
commit ucitrack
|
||||
delete firewall.unblockneteasemusic
|
||||
set firewall.unblockneteasemusic=include
|
||||
set firewall.unblockneteasemusic.type=script
|
||||
set firewall.unblockneteasemusic.path=/var/etc/unblockneteasemusic.include
|
||||
set firewall.unblockneteasemusic.reload=1
|
||||
commit firewall
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
# Created By [CTCGFW]Project OpenWRT
|
||||
# https://github.com/project-openwrt
|
||||
|
||||
log_max_size="4" #使用KB计算
|
||||
log_file="/tmp/unblockneteasemusic.log"
|
||||
|
||||
while true
|
||||
do
|
||||
(( log_size = "$(ls -l "${log_file}" | awk -F ' ' '{print $5}')" / "1024" ))
|
||||
(( "${log_size}" >= "${log_max_size}" )) && rm -f "${log_file}"
|
||||
sleep 5m
|
||||
done
|
||||
Loading…
Reference in New Issue
Block a user