luci-app-unblockmusic: sync source
This commit is contained in:
parent
d8e7895815
commit
db295bd79f
@ -16,7 +16,7 @@ LUCI_DEPENDS:=+node +bash +dnsmasq-full +ipset
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-unblockmusic
|
||||
PKG_VERSION:=1.4
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_MAINTAINER:=<https://github.com/project-openwrt/luci-app-unblockmusic>
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
|
||||
enabled = s:option(Flag, "enable_ipset_forward", translate("启用IPSet劫持相关请求"))
|
||||
enabled.description = translate("开启后,所有网易云音乐流量都会被劫持到UnblockNeteaseMusic进行处理")
|
||||
enabled.description = translate("开启后,网易云音乐相关请求会被强制劫持到UnblockNeteaseMusic进行处理")
|
||||
enabled.default = 1
|
||||
enabled.rmempty = false
|
||||
enabled:depends("enabled", 1)
|
||||
@ -70,7 +70,7 @@ enabled.rmempty = false
|
||||
enabled:depends("advanced_mode", 1)
|
||||
|
||||
enabled = s:option(Flag, "ipset_forward_nohttps", translate("[IPSet] 不劫持HTTPS请求"))
|
||||
enabled.description = translate("默认同时劫持HTTP&HTTPS两种请求,如您无相关需求,可勾选此选项")
|
||||
enabled.description = translate("默认同时劫持HTTP&HTTPS两种请求,如无相关需求,可勾选此选项")
|
||||
enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
enabled:depends("advanced_mode", 1)
|
||||
|
||||
@ -20,7 +20,7 @@ set_firewall(){
|
||||
|
||||
mkdir -p /var/etc
|
||||
lan_addr="$(uci get network.lan.ipaddr)"
|
||||
[ "$(uci get unblockmusic.@unblockmusic[0].ipset_forward_nohttps)" -eq "0" ] && forward_https="iptables -t nat -A cloud_music -i br-lan -p tcp --dport 443 -j DNAT --to ${lan_addr}:${https_port}"
|
||||
[ "$(uci get unblockmusic.@unblockmusic[0].ipset_forward_nohttps)" -ne "0" ] || forward_https="iptables -t nat -A cloud_music -i br-lan -p tcp --dport 443 -j DNAT --to ${lan_addr}:${https_port}"
|
||||
cat > "/var/etc/unblockmusic.include" <<-EOF
|
||||
if ! ipset list music >/dev/null; then ipset create music hash:ip; fi
|
||||
iptables -t nat -N cloud_music
|
||||
@ -48,14 +48,27 @@ set_hosts(){
|
||||
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"| 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"| grep -Eo "domain\[[0-9]+\]"| grep -Eo "[0-9]+")"
|
||||
music_id2="$(uci show dhcp| grep "httpdns"| 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"| 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
|
||||
}
|
||||
|
||||
@ -72,7 +85,7 @@ start()
|
||||
else
|
||||
node /usr/share/unblockmusic/app.js -a ${addr} -p ${http_port}:${https_port} -o ${type} ${netease_server_ip} ${proxy_server_ip} ${strict_mode} >/tmp/unblockmusic.log 2>&1 &
|
||||
fi
|
||||
|
||||
|
||||
[ "$(uci get unblockmusic.@unblockmusic[0].enable_ipset_forward)" -ne "0" ] && set_type="start" && set_firewall
|
||||
[ "$(uci get unblockmusic.@unblockmusic[0].use_hosts)" -ne "0" ] && set_type="start" && set_hosts
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user