LuCI - OpenWrt Configuration Interface
Revisión | 4ae5772edc8f318149e3abd0438acc975849708e (tree) |
---|---|
Tiempo | 2023-03-19 21:08:10 |
Autor | Tianling Shen <cnsztl@immo...> |
Commiter | Tianling Shen |
luci-app-unblockneteasemusic: sync with upstream source
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
@@ -17,6 +17,10 @@ PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org> | ||
17 | 17 | |
18 | 18 | define Package/luci-app-unblockneteasemusic/conffiles |
19 | 19 | /etc/config/unblockneteasemusic |
20 | +/usr/share/unblockneteasemusic/core/ | |
21 | +/usr/share/unblockneteasemusic/core_local_ver | |
22 | +/usr/share/unblockneteasemusic/server.crt | |
23 | +/usr/share/unblockneteasemusic/server.key | |
20 | 24 | endef |
21 | 25 | |
22 | 26 | include ../../luci.mk |
@@ -251,10 +251,6 @@ return view.extend({ | ||
251 | 251 | o.rmempty = false; |
252 | 252 | o.depends('advanced_mode', '1'); |
253 | 253 | |
254 | - o = s.option(form.Flag, 'keep_core_when_upgrade', _('升级时保留核心程序')); | |
255 | - o.default = o.disabled; | |
256 | - o.depends('advanced_mode', '1'); | |
257 | - | |
258 | 254 | o = s.option(form.Flag, 'pub_access', _('部署到公网'), |
259 | 255 | _('默认仅放行局域网请求,如需提供公开访问请勾选此选项。')); |
260 | 256 | o.default = o.disabled; |
@@ -9,7 +9,6 @@ START=99 | ||
9 | 9 | STOP=10 |
10 | 10 | |
11 | 11 | NAME="unblockneteasemusic" |
12 | -UPGRADE_CONF="/lib/upgrade/keep.d/$NAME" | |
13 | 12 | UNM_DIR="/usr/share/$NAME" |
14 | 13 | RUN_DIR="/var/run/$NAME" |
15 | 14 |
@@ -154,10 +153,10 @@ start_service() { | ||
154 | 153 | |
155 | 154 | local netease_music_ips="$(uclient-fetch -qO- "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" |jsonfilter -e '@.data.*.ip.*')" |
156 | 155 | local netease_music_ips2="$(uclient-fetch -qO- "https://music.httpdns.c.163.com/d" --post-data="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" |jsonfilter -e '@.dns.*["ips"].*')" |
157 | - | |
158 | 156 | json_add_string acl_http_addr "$(echo -e "${acl_http_addr}" | sort -u)" |
159 | 157 | json_add_string acl_https_addr "$(echo -e "${acl_https_addr}" | sort -u)" |
160 | 158 | json_add_string neteasemusic_addr "$(echo -e "${netease_music_ips}\n${netease_music_ips2}" | sort -u)" |
159 | + | |
161 | 160 | json_dump > "$RUN_DIR/fw4.info" |
162 | 161 | utpl -F "$RUN_DIR/fw4.info" -S "$UNM_DIR/nftables.ut" > "$RUN_DIR/fw4.nft" |
163 | 162 |
@@ -221,20 +220,6 @@ stop_service() { | ||
221 | 220 | sed -i "/$NAME/d" "/etc/crontabs/root" |
222 | 221 | /etc/init.d/cron restart |
223 | 222 | |
224 | - rm -f "${UPGRADE_CONF}" | |
225 | - is_enabled "config" "keep_core_when_upgrade" && { | |
226 | - echo "$UNM_DIR/core/" >> "${UPGRADE_CONF}" | |
227 | - echo "$UNM_DIR/local_ver" >> "${UPGRADE_CONF}" | |
228 | - } | |
229 | - | |
230 | - local self_issue_cert_crt self_issue_cert_key | |
231 | - config_get "self_issue_cert_crt" "config" "self_issue_cert_crt" | |
232 | - config_get "self_issue_cert_key" "config" "self_issue_cert_key" | |
233 | - if [ -f "${self_issue_cert_crt}" ] && [ -f "${self_issue_cert_key}" ]; then | |
234 | - echo "${self_issue_cert_crt}" >> "${UPGRADE_CONF}" | |
235 | - echo "${self_issue_cert_key}" >> "${UPGRADE_CONF}" | |
236 | - fi | |
237 | - | |
238 | 223 | local chain settable |
239 | 224 | for chain in "netease_cloud_music_redir" "netease_cloud_music"; do |
240 | 225 | nft flush chain inet fw4 "$chain" 2>"/dev/null" |
@@ -6,6 +6,11 @@ if [ "$(uci -q get unblockneteasemusic.config.music_source)" = "default" ]; then | ||
6 | 6 | fi |
7 | 7 | |
8 | 8 | uci -q batch <<-EOF >"/dev/null" |
9 | + delete ucitrack.@unblockneteasemusic[-1] | |
10 | + commit ucitrack | |
11 | +EOF | |
12 | + | |
13 | +uci -q batch <<-EOF >"/dev/null" | |
9 | 14 | delete firewall.unblockneteasemusic |
10 | 15 | set firewall.unblockneteasemusic=include |
11 | 16 | set firewall.unblockneteasemusic.type=nftables |
@@ -71,8 +71,6 @@ echo -e "\n" | ||
71 | 71 | |
72 | 72 | [ -n "$is_stopped" ] || { |
73 | 73 | echo -e "Firewall info:" |
74 | - [ -e "/etc/nftables.d/90-$NAME-rules.nft" ] || echo -e "netease_cloud_music nft rule file not found." | |
75 | - echo -e "" | |
76 | 74 | nft list set inet fw4 "acl_neteasemusic_http" 2>&1 |
77 | 75 | echo -e "" |
78 | 76 | nft list set inet fw4 "acl_neteasemusic_https" 2>&1 |
@@ -34,11 +34,13 @@ set neteasemusic { | ||
34 | 34 | flags interval; |
35 | 35 | auto-merge; |
36 | 36 | |
37 | + {% if (neteasemusic_addr): %} | |
37 | 38 | elements = { |
38 | 39 | {% for (let addr in split(trim(neteasemusic_addr), '\n')): %} |
39 | 40 | {{ addr }}, |
40 | 41 | {% endfor %} |
41 | 42 | } |
43 | + {% endif %} | |
42 | 44 | } |
43 | 45 | |
44 | 46 | chain netease_cloud_music { |
@@ -25,18 +25,18 @@ clean_log(){ | ||
25 | 25 | |
26 | 26 | check_core_latest_version() { |
27 | 27 | core_latest_ver="$(uclient-fetch -qO- 'https://api.github.com/repos/UnblockNeteaseMusic/server/commits?sha=enhanced&path=precompiled' | jsonfilter -e '@[0].sha')" |
28 | - [ -n "${core_latest_ver}" ] || { echo -e "\nFailed to check latest core version, please try again later." >> "$LOG"; rm -f "$LOCK"; exit 1; } | |
28 | + [ -n "$core_latest_ver" ] || { echo -e "\nFailed to check latest core version, please try again later." >> "$LOG"; rm -f "$LOCK"; exit 1; } | |
29 | 29 | if [ ! -e "$$UNM_DIR/core_local_ver" ]; then |
30 | 30 | clean_log |
31 | - echo -e "Local version: NOT FOUND, latest version: ${core_latest_ver}." >> "$LOG" | |
31 | + echo -e "Local version: NOT FOUND, latest version: $core_latest_ver." >> "$LOG" | |
32 | 32 | update_core |
33 | 33 | else |
34 | - if [ "$(cat $UNM_DIR/core_local_ver)" != "${core_latest_ver}" ]; then | |
34 | + if [ "$(cat $UNM_DIR/core_local_ver)" != "$core_latest_ver" ]; then | |
35 | 35 | clean_log |
36 | - echo -e "Local version: $(cat $UNM_DIR/core_local_ver 2>"/dev/null"), latest version: ${core_latest_ver}." >> "$LOG" | |
36 | + echo -e "Local version: $(cat $UNM_DIR/core_local_ver 2>"/dev/null"), latest version: $core_latest_ver." >> "$LOG" | |
37 | 37 | update_core |
38 | 38 | else |
39 | - echo -e "\nLocal version: $(cat $UNM_DIR/core_local_ver 2>"/dev/null"), latest version: ${core_latest_ver}." >> "$LOG" | |
39 | + echo -e "\nLocal version: $(cat $UNM_DIR/core_local_ver 2>"/dev/null"), latest version: $core_latest_ver." >> "$LOG" | |
40 | 40 | echo -e "You're already using the latest version." >> "$LOG" |
41 | 41 | rm -f "$LOCK" |
42 | 42 | exit 3 |
@@ -62,7 +62,7 @@ update_core() { | ||
62 | 62 | |
63 | 63 | for cert in "ca.crt" "server.crt" "server.key" |
64 | 64 | do |
65 | - uclient-fetch "https://fastly.jsdelivr.net/gh/UnblockNeteaseMusic/server@enhanced/${cert}" -qO "$UNM_DIR/core/${cert}" | |
65 | + uclient-fetch "https://fastly.jsdelivr.net/gh/UnblockNeteaseMusic/server@$core_latest_ver/$cert" -qO "$UNM_DIR/core/$cert" | |
66 | 66 | [ -s "$UNM_DIR/core/${cert}" ] || { |
67 | 67 | echo -e "Failed to download ${cert}." >> "$LOG" |
68 | 68 | rm -f "$LOCK" |
@@ -70,11 +70,11 @@ update_core() { | ||
70 | 70 | } |
71 | 71 | done |
72 | 72 | |
73 | - echo -e "${core_latest_ver}" > "$UNM_DIR/core_local_ver" | |
74 | - [ -n "${non_restart}" ] || /etc/init.d/"$NAME" restart | |
73 | + echo -e "$core_latest_ver" > "$UNM_DIR/core_local_ver" | |
74 | + [ -n "$non_restart" ] || /etc/init.d/"$NAME" restart | |
75 | 75 | |
76 | 76 | echo -e "Succeeded in updating core." > "$LOG" |
77 | - echo -e "Current core version: ${core_latest_ver}.\n" >> "$LOG" | |
77 | + echo -e "Current core version: $core_latest_ver.\n" >> "$LOG" | |
78 | 78 | rm -f "$LOCK" |
79 | 79 | } |
80 | 80 |