Compare commits

...
27 Commits
Author SHA1 Message Date
kiddin9 9534d467e6 Update luci-theme-footstrap.patch
Merge-upstream / merge (push) Canceled after 0s
2026-08-23 04:27:00 +08:00
github-actions[bot] 9cea2cda79 🗽 Sync 2026-08-23 04:21:21 2026-08-23 04:21:21 +08:00
kiddin9 69677c3a2c Update ssr-plus.patch 2026-08-23 04:19:27 +08:00
kiddin9 9144781d4d Update luci-app-passwall2.patch 2026-08-23 04:18:44 +08:00
kiddin9 21f112ec93 Update luci-app-passwall.patch 2026-08-23 04:17:57 +08:00
kiddin9 775ba09ce3 Update upstream.yml 2026-08-23 04:05:00 +08:00
kiddin9 08894271d3 Update upstream.yml 2026-08-23 04:01:14 +08:00
kiddin9 a634f22688 Update upstream.yml 2026-08-23 03:53:11 +08:00
kiddin9 b4995a5406 Update upstream.yml 2026-08-23 03:47:17 +08:00
github-actions[bot] d52488b5e4 🐤 Sync 2026-08-23 03:36:27 2026-08-23 03:36:27 +08:00
kiddin9 927801e4d4 Update ssr-plus.patch 2026-08-23 03:34:31 +08:00
kiddin9 0e12dc7181 Update luci-app-passwall.patch 2026-08-23 03:33:56 +08:00
kiddin9 c0a27cf1c0 Update luci-app-passwall2.patch 2026-08-23 03:33:34 +08:00
github-actions[bot] a1c990abb0 💋 Sync 2026-08-23 03:27:51 2026-08-23 03:27:51 +08:00
kiddin9 e2649ca068 Update luci-app-passwall.patch 2026-08-23 03:25:39 +08:00
kiddin9 be6c172c5c Update ssr-plus.patch 2026-08-23 03:24:30 +08:00
kiddin9 6d9fb15446 Update luci-app-passwall2.patch 2026-08-23 03:23:32 +08:00
github-actions[bot] 7c2a43f834 🎄 Sync 2026-08-23 03:16:04 2026-08-23 03:16:04 +08:00
kiddin9 5a79bf68df Update ssr-plus.patch 2026-08-23 03:13:57 +08:00
kiddin9 03d753ac18 Update luci-app-passwall2.patch 2026-08-23 03:11:16 +08:00
github-actions[bot] 519574f670 🛸 Sync 2026-08-23 03:07:41 2026-08-23 03:07:41 +08:00
kiddin9 19082ade16 Update luci-app-passwall.patch 2026-08-23 03:05:28 +08:00
kiddin9 892c31204e Update luci-app-passwall.patch 2026-08-23 02:20:29 +08:00
github-actions[bot] 7746d18420 🌴 Sync 2026-08-23 02:02:03 2026-08-23 02:02:03 +08:00
kiddin9 2e456e0234 Update luci-theme-footstrap.patch 2026-08-23 02:00:00 +08:00
github-actions[bot] 26deccb203 Sync 2026-08-23 01:32:54 2026-08-23 01:32:54 +08:00
github-actions[bot] 0518f32579 Sync 2026-08-22 23:43:25 2026-08-22 23:43:25 +08:00
56 changed files with 1338 additions and 1428 deletions
+7 -2
View File
@@ -251,7 +251,7 @@ new file mode 100644
index 000000000000..a00fff9c79b3 index 000000000000..a00fff9c79b3
--- /dev/null --- /dev/null
+++ b/luci-app-passwall/luasrc/view/passwall/global/status_bottom.htm +++ b/luci-app-passwall/luasrc/view/passwall/global/status_bottom.htm
@@ -0,0 +1,126 @@ @@ -0,0 +1,131 @@
+<style> +<style>
+.pure-img { +.pure-img {
+ max-height: 100%; + max-height: 100%;
@@ -329,10 +329,13 @@ index 000000000000..a00fff9c79b3
+const _ASSETS = '/luci-static/passwall/'; +const _ASSETS = '/luci-static/passwall/';
+const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[passwall]], [[ip]])%>'; +const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[passwall]], [[ip]])%>';
+ +
+let mainContent = document.getElementById("maincontent");
+let statusBar = document.querySelector(".status-bar"); +let statusBar = document.querySelector(".status-bar");
+ +
+function resize() { +function resize() {
+ statusBar.style.width = document.getElementById("maincontent").offsetWidth + 'px'; + wW = window.innerWidth;
+ let lw = document.querySelector(".main-left, :root[data-layout='sidebar'] .fs-sidebar")?.offsetWidth ?? 5;
+ statusBar.style.width = (wW - lw) + 'px';
+ let flagElement = statusBar.querySelector(".flag"); + let flagElement = statusBar.querySelector(".flag");
+ flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px'; + flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px';
+ +
@@ -376,7 +379,9 @@ index 000000000000..a00fff9c79b3
+}); +});
+ +
+window.addEventListener('resize', resize); +window.addEventListener('resize', resize);
+if (mainContent && window.getComputedStyle(mainContent).getPropertyValue("contain")=== "paint") {
+document.body.appendChild(statusBar); +document.body.appendChild(statusBar);
+}
+</script> +</script>
--- a/luci-app-passwall/root/usr/share/passwall/0_default_config --- a/luci-app-passwall/root/usr/share/passwall/0_default_config
+7 -2
View File
@@ -128,7 +128,7 @@ new file mode 100644
index 000000000000..a00fff9c79b3 index 000000000000..a00fff9c79b3
--- /dev/null --- /dev/null
+++ b/luci-app-passwall2/luasrc/view/passwall2/global/status_bottom.htm +++ b/luci-app-passwall2/luasrc/view/passwall2/global/status_bottom.htm
@@ -0,0 +1,129 @@ @@ -0,0 +1,134 @@
+<style> +<style>
+.pure-img { +.pure-img {
+ max-height: 100%; + max-height: 100%;
@@ -209,10 +209,13 @@ index 000000000000..a00fff9c79b3
+const _ASSETS = '/luci-static/passwall2/'; +const _ASSETS = '/luci-static/passwall2/';
+const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[passwall2]], [[ip]])%>'; +const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[passwall2]], [[ip]])%>';
+ +
+let mainContent = document.getElementById("maincontent");
+let statusBar = document.querySelector(".status-bar"); +let statusBar = document.querySelector(".status-bar");
+ +
+function resize() { +function resize() {
+ statusBar.style.width = document.getElementById("maincontent").offsetWidth + 'px'; + wW = window.innerWidth;
+ let lw = document.querySelector(".main-left, :root[data-layout='sidebar'] .fs-sidebar")?.offsetWidth ?? 5;
+ statusBar.style.width = (wW - lw) + 'px';
+ let flagElement = statusBar.querySelector(".flag"); + let flagElement = statusBar.querySelector(".flag");
+ flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px'; + flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px';
+ +
@@ -256,5 +259,7 @@ index 000000000000..a00fff9c79b3
+}); +});
+ +
+window.addEventListener('resize', resize); +window.addEventListener('resize', resize);
+if (mainContent && window.getComputedStyle(mainContent).getPropertyValue("contain")=== "paint") {
+document.body.appendChild(statusBar); +document.body.appendChild(statusBar);
+}
+</script> +</script>
@@ -1,6 +1,6 @@
--- a/luci-theme-footstrap/root/etc/config/footstrap --- a/luci-theme-footstrap/root/etc/config/footstrap
+++ b/luci-theme-footstrap/root/etc/config/footstrap +++ b/luci-theme-footstrap/root/etc/config/footstrap
@@ -1,2 +1,6 @@ @@ -1,2 +1,7 @@
config footstrap 'settings' config footstrap 'settings'
+ option pattern 'a583df0ec986a6b8454f7be514e8cb32' + option pattern 'a583df0ec986a6b8454f7be514e8cb32'
+7 -2
View File
@@ -129,7 +129,7 @@ new file mode 100644
index 000000000000..a00fff9c79b3 index 000000000000..a00fff9c79b3
--- /dev/null --- /dev/null
+++ b/luci-app-ssr-plus/luasrc/view/shadowsocksr/status_bottom.htm +++ b/luci-app-ssr-plus/luasrc/view/shadowsocksr/status_bottom.htm
@@ -0,0 +1,129 @@ @@ -0,0 +1,134 @@
+<style> +<style>
+.pure-img { +.pure-img {
+ max-height: 100%; + max-height: 100%;
@@ -210,10 +210,13 @@ index 000000000000..a00fff9c79b3
+const _ASSETS = '/luci-static/shadowsocksr/'; +const _ASSETS = '/luci-static/shadowsocksr/';
+const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[shadowsocksr]], [[ip]])%>'; +const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[shadowsocksr]], [[ip]])%>';
+ +
+let mainContent = document.getElementById("maincontent");
+let statusBar = document.querySelector(".status-bar"); +let statusBar = document.querySelector(".status-bar");
+ +
+function resize() { +function resize() {
+ statusBar.style.width = document.getElementById("maincontent").offsetWidth + 'px'; + wW = window.innerWidth;
+ let lw = document.querySelector(".main-left, :root[data-layout='sidebar'] .fs-sidebar")?.offsetWidth ?? 5;
+ statusBar.style.width = (wW - lw) + 'px';
+ let flagElement = statusBar.querySelector(".flag"); + let flagElement = statusBar.querySelector(".flag");
+ flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px'; + flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px';
+ +
@@ -257,7 +260,9 @@ index 000000000000..a00fff9c79b3
+}); +});
+ +
+window.addEventListener('resize', resize); +window.addEventListener('resize', resize);
+if (mainContent && window.getComputedStyle(mainContent).getPropertyValue("contain")=== "paint") {
+document.body.appendChild(statusBar); +document.body.appendChild(statusBar);
+}
+</script> +</script>
--- a/luci-app-ssr-plus/root/etc/uci-defaults/luci-ssr-plus --- a/luci-app-ssr-plus/root/etc/uci-defaults/luci-ssr-plus
+1 -1
View File
@@ -448,7 +448,7 @@ jobs:
- name: Apply patches - name: Apply patches
run: | run: |
find ".github/diy/patches" -type f -name '*.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "patch -d './' --no-backup-if-mismatch -p1 -F 1 -i '%'" || (curl -k --data chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" --data "text=❌ 软件包更新失败 😂 https://github.com/kiddin9/openwrt-packages/actions" "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage";exit 1) find ".github/diy/patches" -type f -name '*.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "patch -d './' --no-backup-if-mismatch -p1 -F 1 -i '%'" || (curl -k --data chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" --data "text=❌ 软件包更新失败 😂 https://github.com/kiddin9/openwrt-packages/actions" "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage";exit 1)
#find ".github/diy/patches" -type f -name '*.patch' -print0 | sort -z | xargs -0 -t -n 1 git apply -p1 --recount --ignore-whitespace --unsafe-paths --verbose
- name: Modify - name: Modify
run: | run: |
shopt -s extglob shopt -s extglob
+3 -3
View File
@@ -5,10 +5,10 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=dae PKG_NAME:=dae
PKG_VERSION:=2026.08.13 PKG_VERSION:=2026.08.21
PKG_RELEASE:=36 PKG_RELEASE:=37
PKG_SOURCE:=dae-src-2026.08.13-0d20959710a0.tar.gz PKG_SOURCE:=dae-src-2026.08.21-8138f66f2c6d.tar.gz
PKG_SOURCE_URL:=https://github.com/kenzok8/openwrt-daede/releases/download/dae-src PKG_SOURCE_URL:=https://github.com/kenzok8/openwrt-daede/releases/download/dae-src
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_HASH:=skip PKG_HASH:=skip
+3 -3
View File
@@ -5,10 +5,10 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=daed PKG_NAME:=daed
PKG_VERSION:=2026.08.13 PKG_VERSION:=2026.08.21
PKG_RELEASE:=47 PKG_RELEASE:=48
PKG_SOURCE:=daed-src-2026.08.13-4a38e0f66b3d.tar.gz PKG_SOURCE:=daed-src-2026.08.21-aeef51da973f.tar.gz
PKG_SOURCE_URL:=https://github.com/kenzok8/openwrt-daede/releases/download/daed-src PKG_SOURCE_URL:=https://github.com/kenzok8/openwrt-daede/releases/download/daed-src
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_HASH:=skip PKG_HASH:=skip
+2 -2
View File
@@ -5,8 +5,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector-mod-email PKG_NAME:=internet-detector-mod-email
PKG_VERSION:=1.7.3 PKG_VERSION:=1.7.4
PKG_RELEASE:=3 PKG_RELEASE:=4
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
+2 -2
View File
@@ -5,8 +5,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector-mod-modem-restart PKG_NAME:=internet-detector-mod-modem-restart
PKG_VERSION:=1.7.3 PKG_VERSION:=1.7.4
PKG_RELEASE:=3 PKG_RELEASE:=4
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
+2 -2
View File
@@ -5,8 +5,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector-mod-telegram PKG_NAME:=internet-detector-mod-telegram
PKG_VERSION:=1.7.3 PKG_VERSION:=1.7.4
PKG_RELEASE:=3 PKG_RELEASE:=4
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
+2 -2
View File
@@ -5,8 +5,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=internet-detector PKG_NAME:=internet-detector
PKG_VERSION:=1.7.3 PKG_VERSION:=1.7.4
PKG_RELEASE:=5 PKG_RELEASE:=6
PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector> PKG_MAINTAINER:=gSpot <https://github.com/gSpotx2f/luci-app-internet-detector>
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
@@ -27,7 +27,21 @@ local InternetDetector = {
pingCmd = "/bin/ping", pingCmd = "/bin/ping",
pingParams = "-c 1", pingParams = "-c 1",
curlExec = "/usr/bin/curl", curlExec = "/usr/bin/curl",
curlParams = '-s -g --no-keepalive --head --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0"', curlParams = '-s -g --no-keepalive --head --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:153.0) Gecko/20100101 Firefox/153.0"',
curlHttpOkCodes = {
[200] = true,
[202] = true,
[203] = true,
[204] = true,
[206] = true,
[300] = true,
[301] = true,
[302] = true,
[303] = true,
[304] = true,
[307] = true,
[308] = true,
},
mode = 0, -- 0: disabled, 1: Service, 2: UI detector mode = 0, -- 0: disabled, 1: Service, 2: UI detector
loggingLevel = 6, loggingLevel = 6,
hostname = "OpenWrt", hostname = "OpenWrt",
@@ -43,7 +57,7 @@ local InternetDetector = {
urls = { urls = {
[1] = "https://www.google.com", [1] = "https://www.google.com",
}, },
check_type = 0, -- 0: TCP, 1: ICMP check_type = 0, -- 0: TCP, 1: ICMP, 2: URL test
tcp_port = 53, tcp_port = 53,
icmp_packet_size = 56, icmp_packet_size = 56,
interval_up = 30, interval_up = 30,
@@ -280,7 +294,6 @@ function InternetDetector:TCPConnectionToHost(host, port)
if not ok then if not ok then
self:debugOutput(string.format( self:debugOutput(string.format(
"SOCKET ERROR: %s, %s", errMsg, errNum)) "SOCKET ERROR: %s, %s", errMsg, errNum))
unistd.close(sock) unistd.close(sock)
return retCode return retCode
end end
@@ -380,7 +393,7 @@ function InternetDetector:checkURL(url)
if retCode == 0 and data then if retCode == 0 and data then
httpCode = self:getHTTPCode(data) httpCode = self:getHTTPCode(data)
end end
return (httpCode ~= 200) and 1 or 0 return (not self.curlHttpOkCodes[httpCode]) and 1 or 0
end end
function InternetDetector:exit() function InternetDetector:exit()
@@ -27,7 +27,7 @@ local Module = {
requestAttempts = 2, requestAttempts = 2,
timeout = 3, timeout = 3,
curlExec = "/usr/bin/curl", curlExec = "/usr/bin/curl",
curlParams = '-s -g --no-keepalive --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:142.0) Gecko/20100101 Firefox/142.0"', curlParams = '-s -g --no-keepalive --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:153.0) Gecko/20100101 Firefox/153.0"',
providers = { providers = {
opendns1 = { opendns1 = {
name = "opendns1", type = "dns", host = "myip.opendns.com", name = "opendns1", type = "dns", host = "myip.opendns.com",
+2 -2
View File
@@ -5,8 +5,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-internet-detector PKG_NAME:=luci-app-internet-detector
PKG_VERSION:=1.7.3 PKG_VERSION:=1.7.4
PKG_RELEASE:=3 PKG_RELEASE:=4
LUCI_TITLE:=LuCI support for internet-detector LUCI_TITLE:=LuCI support for internet-detector
LUCI_DEPENDS:=+internet-detector LUCI_DEPENDS:=+internet-detector
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
+2 -2
View File
@@ -1,8 +1,8 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-mosdns PKG_NAME:=luci-app-mosdns
PKG_VERSION:=1.7.6 PKG_VERSION:=1.7.7
PKG_RELEASE:=13 PKG_RELEASE:=14
LUCI_TITLE:=LuCI Support for mosdns LUCI_TITLE:=LuCI Support for mosdns
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
@@ -320,6 +320,30 @@ return view.extend({
o.default = 86400; o.default = 86400;
o.depends('cache', '1'); o.depends('cache', '1');
o = s.taboption('advanced', form.Flag, 'prefetch', _('Cache Prefetching'),
_('Proactively refresh hot cache entries in the background before they expire.'));
o.rmempty = false;
o.default = false;
o.depends('cache', '1');
o = s.taboption('advanced', form.Value, 'prefetch_before_expire', _('Prefetch Before Expire'),
_('Prefetch when the remaining TTL is less than this value (in seconds).'));
o.datatype = 'and(uinteger,min(1))';
o.default = 10;
o.depends('prefetch', '1');
o = s.taboption('advanced', form.Value, 'prefetch_min_hits', _('Prefetch Min Hits'),
_('Minimum cache hits required since the last refresh to trigger a prefetch.'));
o.datatype = 'and(uinteger,min(1))';
o.default = 3;
o.depends('prefetch', '1');
o = s.taboption('advanced', form.Value, 'prefetch_scan_interval', _('Prefetch Scan Interval'),
_('Interval for the background thread to scan the cache for prefetching (in seconds).'));
o.datatype = 'and(uinteger,min(1))';
o.default = 5;
o.depends('prefetch', '1');
o = s.taboption('advanced', form.Flag, 'dump_file', _('Cache Dump'), o = s.taboption('advanced', form.Flag, 'dump_file', _('Cache Dump'),
_('Save the cache locally and reload the cache dump on the next startup')); _('Save the cache locally and reload the cache dump on the next startup'));
o.rmempty = false; o.rmempty = false;
+66 -30
View File
@@ -5,11 +5,11 @@ msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "360 Public DNS (DNS over HTTPS)" msgid "360 Public DNS (DNS over HTTPS)"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:356 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:380
msgid "ADblock Source" msgid "ADblock Source"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:395 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:419
msgid "API Listen port" msgid "API Listen port"
msgstr "" msgstr ""
@@ -82,7 +82,7 @@ msgstr ""
msgid "Apple domains optimization" msgid "Apple domains optimization"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:330 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:354
msgid "Auto Save Cache Interval" msgid "Auto Save Cache Interval"
msgstr "" msgstr ""
@@ -105,7 +105,7 @@ msgstr ""
msgid "Basic Setting" msgid "Basic Setting"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:348 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:372
msgid "" msgid ""
"Block DNS RR Type 65 records (HTTPS/SVCB, used for HTTP/3, ECH, etc.), force " "Block DNS RR Type 65 records (HTTPS/SVCB, used for HTTP/3, ECH, etc.), force "
"using only A/AAAA records." "using only A/AAAA records."
@@ -129,10 +129,14 @@ msgid ""
"resolvers you specify as upstreams" "resolvers you specify as upstreams"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:323 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:347
msgid "Cache Dump" msgid "Cache Dump"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:323
msgid "Cache Prefetching"
msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/update.js:150 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/update.js:150
msgid "Check And Update" msgid "Check And Update"
msgstr "" msgstr ""
@@ -178,7 +182,7 @@ msgstr ""
msgid "CloudFlare Public DNS (1.1.1.1)" msgid "CloudFlare Public DNS (1.1.1.1)"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:380 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:404
msgid "Cloudflare IP Ranges" msgid "Cloudflare IP Ranges"
msgstr "" msgstr ""
@@ -198,7 +202,7 @@ msgstr ""
msgid "Config File" msgid "Config File"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:426 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:450
msgid "Configuration Editor" msgid "Configuration Editor"
msgstr "" msgstr ""
@@ -216,7 +220,7 @@ msgid ""
"supports domain matching rules)." "supports domain matching rules)."
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:375 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:399
msgid "Custom IP" msgid "Custom IP"
msgstr "" msgstr ""
@@ -258,7 +262,7 @@ msgstr ""
msgid "Default Config" msgid "Default Config"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:347 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:371
msgid "Disable RR Type 65 (HTTPS/SVCB)" msgid "Disable RR Type 65 (HTTPS/SVCB)"
msgstr "" msgstr ""
@@ -280,7 +284,7 @@ msgstr ""
msgid "Enable Auto Database Update" msgid "Enable Auto Database Update"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:352 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:376
msgid "Enable DNS ADblock" msgid "Enable DNS ADblock"
msgstr "" msgstr ""
@@ -302,15 +306,15 @@ msgid "Enable this option fallback policy forces forwarding to remote DNS"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:142 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:142
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:368 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:392
msgid "Enabled" msgid "Enabled"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:453 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:477
msgid "Enter the GeoIP.dat category to be exported, Allow add multiple tags" msgid "Enter the GeoIP.dat category to be exported, Allow add multiple tags"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:448 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:472
msgid "Enter the GeoSite.dat category to be exported, Allow add multiple tags" msgid "Enter the GeoSite.dat category to be exported, Allow add multiple tags"
msgstr "" msgstr ""
@@ -350,8 +354,8 @@ msgstr ""
msgid "Every Wednesday" msgid "Every Wednesday"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:449 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:473
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:454 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:478
msgid "Export directory: /var/mosdns" msgid "Export directory: /var/mosdns"
msgstr "" msgstr ""
@@ -363,7 +367,7 @@ msgstr ""
msgid "Failed to start update." msgid "Failed to start update."
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:403 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:427
msgid "Flush DNS Cache" msgid "Flush DNS Cache"
msgstr "" msgstr ""
@@ -375,7 +379,7 @@ msgstr ""
msgid "Flushing DNS Cache Success." msgid "Flushing DNS Cache Success."
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:401 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:425
msgid "" msgid ""
"Flushing DNS Cache will clear any IP addresses or DNS records from MosDNS " "Flushing DNS Cache will clear any IP addresses or DNS records from MosDNS "
"cache." "cache."
@@ -411,7 +415,7 @@ msgstr ""
msgid "GeoData Export" msgid "GeoData Export"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:452 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:476
msgid "GeoIP Tags" msgid "GeoIP Tags"
msgstr "" msgstr ""
@@ -419,7 +423,7 @@ msgstr ""
msgid "GeoIP Type" msgid "GeoIP Type"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:447 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:471
msgid "GeoSite Tags" msgid "GeoSite Tags"
msgstr "" msgstr ""
@@ -458,7 +462,7 @@ msgstr ""
msgid "IP Address" msgid "IP Address"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:381 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:405
msgid "" msgid ""
"IPv4 CIDR: <a href=\"https://www.cloudflare.com/ips-v4\" target=\"_blank" "IPv4 CIDR: <a href=\"https://www.cloudflare.com/ips-v4\" target=\"_blank"
"\">https://www.cloudflare.com/ips-v4</a> <br /> IPv6 CIDR: <a href=\"https://" "\">https://www.cloudflare.com/ips-v4</a> <br /> IPv6 CIDR: <a href=\"https://"
@@ -486,6 +490,12 @@ msgstr ""
msgid "Info" msgid "Info"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:342
msgid ""
"Interval for the background thread to scan the cache for prefetching (in "
"seconds)."
msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:317 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:317
msgid "Lazy Cache TTL" msgid "Lazy Cache TTL"
msgstr "" msgstr ""
@@ -527,28 +537,33 @@ msgstr ""
msgid "Logs" msgid "Logs"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:369 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:393
msgid "" msgid ""
"Match the parsing result with the Cloudflare IP ranges, and when there is a " "Match the parsing result with the Cloudflare IP ranges, and when there is a "
"successful match, use the 'Custom IP' as the parsing result (experimental " "successful match, use the 'Custom IP' as the parsing result (experimental "
"feature)" "feature)"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:341 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:365
msgid "Maximum TTL" msgid "Maximum TTL"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:335 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:359
msgid "Minimum TTL" msgid "Minimum TTL"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:342 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:336
msgid ""
"Minimum cache hits required since the last refresh to trigger a prefetch."
msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:366
msgid "" msgid ""
"Modify the Maximum TTL value (seconds) for DNS answer results, 0 indicating " "Modify the Maximum TTL value (seconds) for DNS answer results, 0 indicating "
"no modification" "no modification"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:336 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:360
msgid "" msgid ""
"Modify the Minimum TTL value (seconds) for DNS answer results, 0 indicating " "Modify the Minimum TTL value (seconds) for DNS answer results, 0 indicating "
"no modification" "no modification"
@@ -589,10 +604,31 @@ msgstr ""
msgid "Please wait, this may take a few moments..." msgid "Please wait, this may take a few moments..."
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:329
msgid "Prefetch Before Expire"
msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:335
msgid "Prefetch Min Hits"
msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:341
msgid "Prefetch Scan Interval"
msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:330
msgid "Prefetch when the remaining TTL is less than this value (in seconds)."
msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:301 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:301
msgid "Prevent DNS Leaks" msgid "Prevent DNS Leaks"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:324
msgid ""
"Proactively refresh hot cache entries in the background before they expire."
msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:227 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:227
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:244 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:244
msgid "Quad9 Public DNS (149.112.112.112)" msgid "Quad9 Public DNS (149.112.112.112)"
@@ -637,7 +673,7 @@ msgstr ""
msgid "Rules" msgid "Rules"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:324 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:348
msgid "Save the cache locally and reload the cache dump on the next startup" msgid "Save the cache locally and reload the cache dump on the next startup"
msgstr "" msgstr ""
@@ -653,7 +689,7 @@ msgstr ""
msgid "Streaming Media DNS server" msgid "Streaming Media DNS server"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:359 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:383
msgid "Support for local files, such as: file:///var/mosdns/example.txt" msgid "Support for local files, such as: file:///var/mosdns/example.txt"
msgstr "" msgstr ""
@@ -686,7 +722,7 @@ msgid ""
"server)" "server)"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:427 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:451
msgid "" msgid ""
"This is the content of the file '/etc/mosdns/config_custom.yaml' from which " "This is the content of the file '/etc/mosdns/config_custom.yaml' from which "
"your MosDNS configuration will be generated. Only accepts configuration " "your MosDNS configuration will be generated. Only accepts configuration "
@@ -701,7 +737,7 @@ msgstr ""
msgid "TrafficRoute Public DNS (180.184.2.2)" msgid "TrafficRoute Public DNS (180.184.2.2)"
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:442 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:466
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:43 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:43
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:48 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:48
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:67 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:67
@@ -765,7 +801,7 @@ msgid ""
"domain matching rules)." "domain matching rules)."
msgstr "" msgstr ""
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:357 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:381
msgid "" msgid ""
"When using custom rule sources, please use rule types supported by MosDNS " "When using custom rule sources, please use rule types supported by MosDNS "
"(domain list or AdGuardHome rules)." "(domain list or AdGuardHome rules)."
+66 -30
View File
@@ -15,11 +15,11 @@ msgstr ""
msgid "360 Public DNS (DNS over HTTPS)" msgid "360 Public DNS (DNS over HTTPS)"
msgstr "360 安全 DNSDNS over HTTPS" msgstr "360 安全 DNSDNS over HTTPS"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:356 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:380
msgid "ADblock Source" msgid "ADblock Source"
msgstr "广告过滤规则来源" msgstr "广告过滤规则来源"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:395 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:419
msgid "API Listen port" msgid "API Listen port"
msgstr "API 监听端口" msgstr "API 监听端口"
@@ -97,7 +97,7 @@ msgstr "另一个更新正在进行中。"
msgid "Apple domains optimization" msgid "Apple domains optimization"
msgstr "Apple 域名解析优化" msgstr "Apple 域名解析优化"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:330 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:354
msgid "Auto Save Cache Interval" msgid "Auto Save Cache Interval"
msgstr "自动保存缓存间隔(秒)" msgstr "自动保存缓存间隔(秒)"
@@ -120,7 +120,7 @@ msgstr "基本选项"
msgid "Basic Setting" msgid "Basic Setting"
msgstr "基本设置" msgstr "基本设置"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:348 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:372
msgid "" msgid ""
"Block DNS RR Type 65 records (HTTPS/SVCB, used for HTTP/3, ECH, etc.), force " "Block DNS RR Type 65 records (HTTPS/SVCB, used for HTTP/3, ECH, etc.), force "
"using only A/AAAA records." "using only A/AAAA records."
@@ -146,10 +146,14 @@ msgid ""
"resolvers you specify as upstreams" "resolvers you specify as upstreams"
msgstr "Bootstrap DNS 服务器用于解析您指定为上游的 DoH / DoT 解析器的 IP 地址" msgstr "Bootstrap DNS 服务器用于解析您指定为上游的 DoH / DoT 解析器的 IP 地址"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:323 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:347
msgid "Cache Dump" msgid "Cache Dump"
msgstr "自动保存缓存" msgstr "自动保存缓存"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:323
msgid "Cache Prefetching"
msgstr "缓存预读"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/update.js:150 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/update.js:150
msgid "Check And Update" msgid "Check And Update"
msgstr "检查并更新" msgstr "检查并更新"
@@ -195,7 +199,7 @@ msgstr "CloudFlare 公共 DNS1.0.0.1"
msgid "CloudFlare Public DNS (1.1.1.1)" msgid "CloudFlare Public DNS (1.1.1.1)"
msgstr "CloudFlare 公共 DNS1.1.1.1" msgstr "CloudFlare 公共 DNS1.1.1.1"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:380 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:404
msgid "Cloudflare IP Ranges" msgid "Cloudflare IP Ranges"
msgstr "Cloudflare IP 范围" msgstr "Cloudflare IP 范围"
@@ -215,7 +219,7 @@ msgstr "DNS 服务器并发数(默认 2"
msgid "Config File" msgid "Config File"
msgstr "配置文件" msgstr "配置文件"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:426 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:450
msgid "Configuration Editor" msgid "Configuration Editor"
msgstr "配置编辑器" msgstr "配置编辑器"
@@ -234,7 +238,7 @@ msgid ""
msgstr "" msgstr ""
"自定义 Hosts 重写,如:baidu.com 10.0.0.1(每个规则一行,支持域名匹配规则)" "自定义 Hosts 重写,如:baidu.com 10.0.0.1(每个规则一行,支持域名匹配规则)"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:375 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:399
msgid "Custom IP" msgid "Custom IP"
msgstr "自选 IP" msgstr "自选 IP"
@@ -276,7 +280,7 @@ msgstr "调试"
msgid "Default Config" msgid "Default Config"
msgstr "内置预设" msgstr "内置预设"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:347 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:371
msgid "Disable RR Type 65 (HTTPS/SVCB)" msgid "Disable RR Type 65 (HTTPS/SVCB)"
msgstr "禁用 RR Type 65 (HTTPS/SVCB)" msgstr "禁用 RR Type 65 (HTTPS/SVCB)"
@@ -299,7 +303,7 @@ msgstr "DoH/TCP/DoT 连接复用空闲保持时间(默认 30 秒)"
msgid "Enable Auto Database Update" msgid "Enable Auto Database Update"
msgstr "启用自动更新" msgstr "启用自动更新"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:352 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:376
msgid "Enable DNS ADblock" msgid "Enable DNS ADblock"
msgstr "启用 DNS 广告过滤" msgstr "启用 DNS 广告过滤"
@@ -321,15 +325,15 @@ msgid "Enable this option fallback policy forces forwarding to remote DNS"
msgstr "启用此选项 fallback 策略会强制转发到远程 DNS" msgstr "启用此选项 fallback 策略会强制转发到远程 DNS"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:142 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:142
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:368 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:392
msgid "Enabled" msgid "Enabled"
msgstr "启用" msgstr "启用"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:453 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:477
msgid "Enter the GeoIP.dat category to be exported, Allow add multiple tags" msgid "Enter the GeoIP.dat category to be exported, Allow add multiple tags"
msgstr "输入需要导出的 GeoIP.dat 类别条目,允许添加多个标签" msgstr "输入需要导出的 GeoIP.dat 类别条目,允许添加多个标签"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:448 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:472
msgid "Enter the GeoSite.dat category to be exported, Allow add multiple tags" msgid "Enter the GeoSite.dat category to be exported, Allow add multiple tags"
msgstr "填写需要导出的 GeoSite.dat 类别条目,允许添加多个标签" msgstr "填写需要导出的 GeoSite.dat 类别条目,允许添加多个标签"
@@ -369,8 +373,8 @@ msgstr "每周二"
msgid "Every Wednesday" msgid "Every Wednesday"
msgstr "每周三" msgstr "每周三"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:449 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:473
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:454 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:478
msgid "Export directory: /var/mosdns" msgid "Export directory: /var/mosdns"
msgstr "导出目录:/var/mosdns" msgstr "导出目录:/var/mosdns"
@@ -382,7 +386,7 @@ msgstr "清理日志失败:%s"
msgid "Failed to start update." msgid "Failed to start update."
msgstr "启动更新失败" msgstr "启动更新失败"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:403 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:427
msgid "Flush DNS Cache" msgid "Flush DNS Cache"
msgstr "刷新 DNS 缓存" msgstr "刷新 DNS 缓存"
@@ -394,7 +398,7 @@ msgstr "刷新 DNS 缓存失败,请检查 MosDNS 状态是否在运行中。"
msgid "Flushing DNS Cache Success." msgid "Flushing DNS Cache Success."
msgstr "刷新 DNS 缓存成功" msgstr "刷新 DNS 缓存成功"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:401 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:425
msgid "" msgid ""
"Flushing DNS Cache will clear any IP addresses or DNS records from MosDNS " "Flushing DNS Cache will clear any IP addresses or DNS records from MosDNS "
"cache." "cache."
@@ -430,7 +434,7 @@ msgstr "全量:包含所有国家和私有 IP 地址。"
msgid "GeoData Export" msgid "GeoData Export"
msgstr "GeoData 导出" msgstr "GeoData 导出"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:452 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:476
msgid "GeoIP Tags" msgid "GeoIP Tags"
msgstr "GeoIP 标签" msgstr "GeoIP 标签"
@@ -438,7 +442,7 @@ msgstr "GeoIP 标签"
msgid "GeoIP Type" msgid "GeoIP Type"
msgstr "GeoIP 类型" msgstr "GeoIP 类型"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:447 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:471
msgid "GeoSite Tags" msgid "GeoSite Tags"
msgstr "GeoSite 标签" msgstr "GeoSite 标签"
@@ -477,7 +481,7 @@ msgstr ""
msgid "IP Address" msgid "IP Address"
msgstr "IP 地址" msgstr "IP 地址"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:381 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:405
msgid "" msgid ""
"IPv4 CIDR: <a href=\"https://www.cloudflare.com/ips-v4\" target=\"_blank" "IPv4 CIDR: <a href=\"https://www.cloudflare.com/ips-v4\" target=\"_blank"
"\">https://www.cloudflare.com/ips-v4</a> <br /> IPv6 CIDR: <a href=\"https://" "\">https://www.cloudflare.com/ips-v4</a> <br /> IPv6 CIDR: <a href=\"https://"
@@ -505,6 +509,12 @@ msgstr "空闲超时"
msgid "Info" msgid "Info"
msgstr "信息" msgstr "信息"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:342
msgid ""
"Interval for the background thread to scan the cache for prefetching (in "
"seconds)."
msgstr "后台线程扫描缓存以进行预取的时间间隔(单位:秒)"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:317 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:317
msgid "Lazy Cache TTL" msgid "Lazy Cache TTL"
msgstr "乐观缓存 TTL" msgstr "乐观缓存 TTL"
@@ -546,7 +556,7 @@ msgstr "日志等级"
msgid "Logs" msgid "Logs"
msgstr "日志" msgstr "日志"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:369 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:393
#, fuzzy #, fuzzy
msgid "" msgid ""
"Match the parsing result with the Cloudflare IP ranges, and when there is a " "Match the parsing result with the Cloudflare IP ranges, and when there is a "
@@ -556,21 +566,26 @@ msgstr ""
"将解析结果与 Cloudflare IP 范围进行匹配,当匹配成功时,使用 “自选 IP” 作为解" "将解析结果与 Cloudflare IP 范围进行匹配,当匹配成功时,使用 “自选 IP” 作为解"
"析结果(实验性功能)" "析结果(实验性功能)"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:341 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:365
msgid "Maximum TTL" msgid "Maximum TTL"
msgstr "覆盖最大 TTL 值(默认 0" msgstr "覆盖最大 TTL 值(默认 0"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:335 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:359
msgid "Minimum TTL" msgid "Minimum TTL"
msgstr "覆盖最小 TTL 值(默认 0" msgstr "覆盖最小 TTL 值(默认 0"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:342 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:336
msgid ""
"Minimum cache hits required since the last refresh to trigger a prefetch."
msgstr "触发预读所需的最小缓存命中次数(自上次刷新起)"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:366
msgid "" msgid ""
"Modify the Maximum TTL value (seconds) for DNS answer results, 0 indicating " "Modify the Maximum TTL value (seconds) for DNS answer results, 0 indicating "
"no modification" "no modification"
msgstr "修改 DNS 应答结果的最大 TTL 值(秒),0 表示不修改" msgstr "修改 DNS 应答结果的最大 TTL 值(秒),0 表示不修改"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:336 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:360
msgid "" msgid ""
"Modify the Minimum TTL value (seconds) for DNS answer results, 0 indicating " "Modify the Minimum TTL value (seconds) for DNS answer results, 0 indicating "
"no modification" "no modification"
@@ -613,10 +628,31 @@ msgstr ""
msgid "Please wait, this may take a few moments..." msgid "Please wait, this may take a few moments..."
msgstr "请稍候,这可能需要一点时间..." msgstr "请稍候,这可能需要一点时间..."
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:329
msgid "Prefetch Before Expire"
msgstr "预读触发阈值"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:335
msgid "Prefetch Min Hits"
msgstr "预读最小命中次数"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:341
msgid "Prefetch Scan Interval"
msgstr "预读扫描周期"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:330
msgid "Prefetch when the remaining TTL is less than this value (in seconds)."
msgstr "当剩余 TTL 小于此值(秒)时触发预读"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:301 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:301
msgid "Prevent DNS Leaks" msgid "Prevent DNS Leaks"
msgstr "防止 DNS 泄漏" msgstr "防止 DNS 泄漏"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:324
msgid ""
"Proactively refresh hot cache entries in the background before they expire."
msgstr "在缓存到期前,后台主动预读并刷新高频访问的 DNS 记录"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:227 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:227
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:244 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:244
msgid "Quad9 Public DNS (149.112.112.112)" msgid "Quad9 Public DNS (149.112.112.112)"
@@ -663,7 +699,7 @@ msgstr "自定义规则列表"
msgid "Rules" msgid "Rules"
msgstr "规则列表" msgstr "规则列表"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:324 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:348
msgid "Save the cache locally and reload the cache dump on the next startup" msgid "Save the cache locally and reload the cache dump on the next startup"
msgstr "保存缓存到本地文件,以供下次启动时重新载入使用" msgstr "保存缓存到本地文件,以供下次启动时重新载入使用"
@@ -679,7 +715,7 @@ msgstr "流媒体"
msgid "Streaming Media DNS server" msgid "Streaming Media DNS server"
msgstr "流媒体 DNS 服务器" msgstr "流媒体 DNS 服务器"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:359 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:383
msgid "Support for local files, such as: file:///var/mosdns/example.txt" msgid "Support for local files, such as: file:///var/mosdns/example.txt"
msgstr "支持本地文件,例如:file:///var/mosdns/example.txt" msgstr "支持本地文件,例如:file:///var/mosdns/example.txt"
@@ -714,7 +750,7 @@ msgstr ""
"此功能通常在使用自建 DNS 服务器作为 远程 / 流媒体 DNS 上游时使用(需要上游服" "此功能通常在使用自建 DNS 服务器作为 远程 / 流媒体 DNS 上游时使用(需要上游服"
"务器的支持)" "务器的支持)"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:427 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:451
msgid "" msgid ""
"This is the content of the file '/etc/mosdns/config_custom.yaml' from which " "This is the content of the file '/etc/mosdns/config_custom.yaml' from which "
"your MosDNS configuration will be generated. Only accepts configuration " "your MosDNS configuration will be generated. Only accepts configuration "
@@ -731,7 +767,7 @@ msgstr "火山引擎公共 DNS180.184.1.1"
msgid "TrafficRoute Public DNS (180.184.2.2)" msgid "TrafficRoute Public DNS (180.184.2.2)"
msgstr "火山引擎公共 DNS180.184.2.2" msgstr "火山引擎公共 DNS180.184.2.2"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:442 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:466
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:43 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:43
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:48 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:48
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:67 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/rules.js:67
@@ -797,7 +833,7 @@ msgstr ""
"启用 “自定义流媒体 DNS” 时,加入的域名始终使用 “流媒体 DNS 服务器” 进行解析" "启用 “自定义流媒体 DNS” 时,加入的域名始终使用 “流媒体 DNS 服务器” 进行解析"
"(每个域名一行,支持域名匹配规则)" "(每个域名一行,支持域名匹配规则)"
#: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:357 #: luci-app-mosdns/htdocs/luci-static/resources/view/mosdns/basic.js:381
msgid "" msgid ""
"When using custom rule sources, please use rule types supported by MosDNS " "When using custom rule sources, please use rule types supported by MosDNS "
"(domain list or AdGuardHome rules)." "(domain list or AdGuardHome rules)."
+10
View File
@@ -22,6 +22,10 @@ get_config() {
config_get lazy_cache_ttl $1 lazy_cache_ttl 86400 config_get lazy_cache_ttl $1 lazy_cache_ttl 86400
config_get dump_file $1 dump_file 0 config_get dump_file $1 dump_file 0
config_get dump_interval $1 dump_interval 3600 config_get dump_interval $1 dump_interval 3600
config_get prefetch $1 prefetch 0
config_get prefetch_before_expire $1 prefetch_before_expire 10
config_get prefetch_min_hits $1 prefetch_min_hits 3
config_get prefetch_scan_interval $1 prefetch_scan_interval 5
config_get enable_pipeline $1 enable_pipeline 0 config_get enable_pipeline $1 enable_pipeline 0
config_get geo_auto_update $1 geo_auto_update 0 config_get geo_auto_update $1 geo_auto_update 0
config_get geo_update_day_time $1 geo_update_day_time 2 config_get geo_update_day_time $1 geo_update_day_time 2
@@ -232,6 +236,12 @@ generate_config() {
json_add_string "dump_file" "/etc/mosdns/cache.dump" json_add_string "dump_file" "/etc/mosdns/cache.dump"
json_add_int "dump_interval" "$dump_interval" json_add_int "dump_interval" "$dump_interval"
} }
[ "$prefetch" -eq 1 ] && {
json_add_boolean "prefetch" 1
json_add_int "prefetch_before_expire" "$prefetch_before_expire"
json_add_int "prefetch_min_hits" "$prefetch_min_hits"
json_add_int "prefetch_scan_interval" "$prefetch_scan_interval"
}
json_close_object json_close_object
json_close_object json_close_object
} }
+1 -1
View File
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall PKG_NAME:=luci-app-passwall
PKG_VERSION:=26.8.19 PKG_VERSION:=26.8.19
PKG_RELEASE:=233 PKG_RELEASE:=238
PKG_PO_VERSION:=$(PKG_VERSION) PKG_PO_VERSION:=$(PKG_VERSION)
PKG_CONFIG_DEPENDS:= \ PKG_CONFIG_DEPENDS:= \
@@ -250,57 +250,39 @@ end
function get_now_use_node() function get_now_use_node()
local path = api.TMP_PATH .. "/acl/default" local path = api.TMP_PATH .. "/acl/default"
local e = {} local e = {}
local tcp_node = api.get_cache_var("ACL_GLOBAL_TCP_node") local node = api.get_cache_var("ACL_GLOBAL_node")
if tcp_node then if node then
e["TCP"] = tcp_node e["global"] = node
end
local udp_node = api.get_cache_var("ACL_GLOBAL_UDP_node")
if udp_node then
e["UDP"] = udp_node
end end
http_write_json(e) http_write_json(e)
end end
function get_redir_log() function get_redir_log()
local name = http.formvalue("name") local id = http.formvalue("id")
local proto = http.formvalue("proto"):upper() local path = api.TMP_PATH .. "/acl/" .. id
local path = api.TMP_PATH .. "/acl/" .. name
local function alert(msg) local function alert(msg)
http.write(string.format("<script>alert('%s');window.close();</script>", i18n.translate(msg))) http.write(string.format("<script>alert('%s');window.close();</script>", i18n.translate(msg)))
end end
if name == "default" then local name = "global"
if proto == "UDP" and (uci_get("@global[0]", "udp_node") or "nil") == "tcp" and not fs.access(path .. "/" .. proto .. ".log") then if id and id ~= "default" then
proto = "TCP" local global_node = uci_get("@global[0]", "node") or "nil"
local acl_node = uci_get(id, "node") or "nil"
local global_enabled = uci_get("@global[0]", "enabled") == "1"
if acl_node == global_node and global_enabled then
path = api.TMP_PATH .. "/acl/default"
if uci_get("@global[0]", "log_node") ~= "1" then
alert("The access control node is the same as the global node. Please enable global logging.")
return
end end
else else
local global_tcp = uci_get("@global[0]", "tcp_node") or "nil" name = "node"
local global_udp = uci_get("@global[0]", "udp_node") or "nil"
local acl_tcp = uci_get(name, "tcp_node") or "nil"
local acl_udp = uci_get(name, "udp_node") or "nil"
local global_enabled = uci_get("@global[0]", "enabled") == "1"
if proto == "TCP" and acl_tcp == global_tcp and global_enabled then
path = api.TMP_PATH .. "/acl/default"
if uci_get("@global[0]", "log_tcp") ~= "1" then
alert("The access control node is the same as the global node. Please enable global logging.")
return
end
end
if proto == "UDP" and acl_udp == global_udp and global_enabled then
path = api.TMP_PATH .. "/acl/default"
if uci_get("@global[0]", "log_udp") ~= "1" then
alert("The access control node is the same as the global node. Please enable global logging.")
return
end
end
if proto == "UDP" and acl_udp == "tcp" and not fs.access(path .. "/" .. proto .. ".log") then
proto = "TCP"
end end
end end
if fs.access(path .. "/" .. proto .. ".log") then if fs.access(path .. "/" .. name .. ".log") then
local content = luci.sys.exec("tail -n 19999 ".. path .. "/" .. proto .. ".log") local content = luci.sys.exec("tail -n 5000 ".. path .. "/" .. name .. ".log")
content = content:gsub("\n", "<br />") content = content:gsub("\n", "<br />")
http.write(content) http.write(content)
else else
@@ -312,7 +294,7 @@ function get_socks_log()
local name = http.formvalue("name") local name = http.formvalue("name")
local path = api.TMP_PATH .. "/" .. name .. ".log" local path = api.TMP_PATH .. "/" .. name .. ".log"
if fs.access(path) then if fs.access(path) then
local content = luci.sys.exec("cat ".. path) local content = luci.sys.exec("tail -n 5000 ".. path)
content = content:gsub("\n", "<br />") content = content:gsub("\n", "<br />")
http.write(content) http.write(content)
else else
@@ -324,9 +306,9 @@ function get_chinadns_log()
local flag = http.formvalue("flag") local flag = http.formvalue("flag")
local path = api.TMP_PATH .. "/acl/" .. flag .. "/chinadns_ng.log" local path = api.TMP_PATH .. "/acl/" .. flag .. "/chinadns_ng.log"
if flag ~= "default" then if flag ~= "default" then
local global_tcp = uci_get("@global[0]", "tcp_node") or "nil" local global_node = uci_get("@global[0]", "node") or "nil"
local acl_tcp = uci_get(flag, "tcp_node") or "nil" local acl_node = uci_get(flag, "node") or "nil"
if acl_tcp == global_tcp and uci_get("@global[0]", "enabled") == "1" then if acl_node == global_node and uci_get("@global[0]", "enabled") == "1" then
path = api.TMP_PATH .. "/acl/default/chinadns_ng.log" path = api.TMP_PATH .. "/acl/default/chinadns_ng.log"
if uci_get("@global[0]", "log_chinadns_ng") ~= "1" then if uci_get("@global[0]", "log_chinadns_ng") ~= "1" then
http.write(string.format("<script>alert('%s');window.close();</script>", i18n.translate("The access control node is the same as the global node. Please enable global logging."))) http.write(string.format("<script>alert('%s');window.close();</script>", i18n.translate("The access control node is the same as the global node. Please enable global logging.")))
@@ -334,7 +316,6 @@ function get_chinadns_log()
end end
end end
end end
if fs.access(path) then if fs.access(path) then
local content = luci.sys.exec("tail -n 5000 ".. path) local content = luci.sys.exec("tail -n 5000 ".. path)
content = content:gsub("\n", "<br />") content = content:gsub("\n", "<br />")
@@ -442,22 +423,29 @@ function index_status()
e.haproxy_status = "-1" e.haproxy_status = "-1"
if api.is_finded("haproxy") then if api.is_finded("haproxy") then
e.haproxy_status = (luci.sys.call("/bin/busybox top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null" % appname) == 0) and "0" or "1" e.haproxy_status = (luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep haproxy >/dev/null" % appname) == 0) and "0" or "1"
end end
e["tcp_node_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep 'default' | grep 'TCP' >/dev/null" % api.TMP_PATH) == 0 if api.get_cache_var("ENABLED_DEFAULT_ACL") == "1" then
local has_tproxy = api.get_cache_var("HAS_TPROXY")
if (uci_get("@global[0]", "udp_node") or "nil") == "tcp" then if not has_tproxy then
e["udp_node_status"] = e["tcp_node_status"] local handle = io.popen("lsmod")
else local mods = handle and handle:read("*a") or ""
e["udp_node_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep 'default' | grep 'UDP' >/dev/null" % api.TMP_PATH) == 0 if handle then handle:close() end
has_tproxy = (mods:find("TPROXY") or mods:find("nft_tproxy")) and "1" or "0"
api.set_cache_var("HAS_TPROXY", has_tproxy)
end
e["tcp_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep 'default' | grep 'global' >/dev/null" % api.TMP_PATH) == 0
if has_tproxy == "1" then
e["udp_status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v -E 'grep|naive' | grep '%s/bin/' | grep 'default' | grep 'global' >/dev/null" % api.TMP_PATH) == 0
end
end end
http_write_json(e) http_write_json(e)
end end
function haproxy_status() function haproxy_status()
local e = {} local e = {}
e["status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null" % appname) == 0 e["status"] = luci.sys.call("/bin/busybox top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep haproxy >/dev/null" % appname) == 0
http_write_json(e) http_write_json(e)
end end
@@ -485,7 +473,7 @@ function connect_status()
local gfw_list = uci_get("@global[0]", "use_gfw_list") or "1" local gfw_list = uci_get("@global[0]", "use_gfw_list") or "1"
local proxy_mode = uci_get("@global[0]", "tcp_proxy_mode") or "proxy" local proxy_mode = uci_get("@global[0]", "tcp_proxy_mode") or "proxy"
local localhost_proxy = uci_get("@global[0]", "localhost_proxy") or "1" local localhost_proxy = uci_get("@global[0]", "localhost_proxy") or "1"
local socks_server = (localhost_proxy == "0") and api.get_cache_var("GLOBAL_TCP_SOCKS_server") or "" local socks_server = (localhost_proxy == "0") and api.get_cache_var("GLOBAL_SOCKS_server") or ""
url = "-w %{http_code}:%{time_pretransfer} " .. url url = "-w %{http_code}:%{time_pretransfer} " .. url
if socks_server and socks_server ~= "" then if socks_server and socks_server ~= "" then
if (chn_list == "proxy" and gfw_list == "0" and proxy_mode ~= "proxy" and aliyun ~= nil) or (chn_list == "0" and gfw_list == "0" and proxy_mode == "proxy") then if (chn_list == "proxy" and gfw_list == "0" and proxy_mode ~= "proxy" and aliyun ~= nil) or (chn_list == "0" and gfw_list == "0" and proxy_mode == "proxy") then
@@ -592,23 +580,24 @@ function add_node()
end end
function set_node() function set_node()
local protocol = http.formvalue("protocol") local type = http.formvalue("type")
local config = http.formvalue("config")
local section = http.formvalue("section") local section = http.formvalue("section")
uci_set("@global[0]", protocol .. "_node", section) if type == "@global[0]" then
if protocol == "tcp" then
local node_protocol = uci_get(section, "protocol") local node_protocol = uci_get(section, "protocol")
if node_protocol == "_shunt" then if node_protocol == "_shunt" then
local type = uci_get(section, "type") local node_type = uci_get(section, "type")
local dns_shunt = uci_get("@global[0]", "dns_shunt") local dns_shunt = uci_get(type, "dns_shunt")
local dns_key = (dns_shunt == "smartdns") and "smartdns_dns_mode" or "dns_mode" local dns_key = (dns_shunt == "smartdns") and "smartdns_dns_mode" or "dns_mode"
local dns_mode = uci_get("@global[0]", dns_key) local dns_mode = uci_get(type, dns_key)
local new_dns_mode = (type == "Xray") and "xray" or "sing-box" local new_dns_mode = (node_type == "Xray") and "xray" or "sing-box"
if dns_mode ~= new_dns_mode then if dns_mode ~= new_dns_mode then
uci_set("@global[0]", dns_key, new_dns_mode) uci_set(type, dns_key, new_dns_mode)
uci_set("@global[0]", "v2ray_dns_mode", "tcp") uci_set(type, "v2ray_dns_mode", "tcp")
end end
end end
end end
uci_set(type, config, section)
uci_save(true, true) uci_save(true, true)
http.redirect(api.url("log")) http.redirect(api.url("log"))
end end
@@ -632,8 +621,7 @@ function clear_all_nodes()
uci_set('@global[0]', "enabled", "0") uci_set('@global[0]', "enabled", "0")
uci_set('@global[0]', "socks_enabled", "0") uci_set('@global[0]', "socks_enabled", "0")
uci_set('@global_haproxy[0]', "balancing_enable", "0") uci_set('@global_haproxy[0]', "balancing_enable", "0")
uci_del('@global[0]', "tcp_node") uci_del('@global[0]', "node")
uci_del('@global[0]', "udp_node")
uci_foreach("socks", function(t) uci_foreach("socks", function(t)
uci_del(t[".name"]) uci_del(t[".name"])
uci_set(t[".name"], "autoswitch_backup_node", {}) uci_set(t[".name"], "autoswitch_backup_node", {})
@@ -642,8 +630,7 @@ function clear_all_nodes()
uci_del(t[".name"]) uci_del(t[".name"])
end) end)
uci_foreach("acl_rule", function(t) uci_foreach("acl_rule", function(t)
uci_del(t[".name"], "tcp_node") uci_del(t[".name"], "node")
uci_del(t[".name"], "udp_node")
end) end)
uci_foreach("nodes", function(node) uci_foreach("nodes", function(node)
uci_del(node['.name']) uci_del(node['.name'])
@@ -664,11 +651,8 @@ function delete_select_nodes()
local ids_t = {} local ids_t = {}
string.gsub(ids, '[^' .. "," .. ']+', function(w) string.gsub(ids, '[^' .. "," .. ']+', function(w)
ids_t[#ids_t + 1] = w ids_t[#ids_t + 1] = w
if (uci_get("@global[0]", "tcp_node") or "") == w then if (uci_get("@global[0]", "node") or "") == w then
uci_del('@global[0]', "tcp_node") uci_del('@global[0]', "node")
end
if (uci_get("@global[0]", "udp_node") or "") == w then
uci_del('@global[0]', "udp_node")
end end
uci_foreach("socks", function(t) uci_foreach("socks", function(t)
local changed = false local changed = false
@@ -697,11 +681,8 @@ function delete_select_nodes()
end end
end) end)
uci_foreach("acl_rule", function(t) uci_foreach("acl_rule", function(t)
if t["tcp_node"] == w then if t["node"] == w then
uci_del(t[".name"], "tcp_node") uci_del(t[".name"], "node")
end
if t["udp_node"] == w then
uci_del(t[".name"], "udp_node")
end end
end) end)
uci_foreach("nodes", function(t) uci_foreach("nodes", function(t)
@@ -128,31 +128,25 @@ sources.validate = function(self, value, t)
flag = true flag = true
end end
end end
if flag == false and datatypes.macaddr(v) then if flag == false and datatypes.macaddr(v) then
flag = true flag = true
end end
if flag == false and datatypes.ip4addr(v) then if flag == false and datatypes.ip4addr(v) then
flag = true flag = true
end end
if flag == false and api.iprange(v) then if flag == false and api.iprange(v) then
flag = true flag = true
end end
if flag == false then if flag == false then
err[#err + 1] = v err[#err + 1] = v
end end
end end
if #err > 0 then if #err > 0 then
self:add_error(t, "invalid", translate("Not true format, please re-enter!")) self:add_error(t, "invalid", translate("Not true format, please re-enter!"))
for _, v in ipairs(err) do for _, v in ipairs(err) do
self:add_error(t, "invalid", v) self:add_error(t, "invalid", v)
end end
end end
return value return value
end end
@@ -195,57 +189,16 @@ o.default = "0"
o.rmempty = false o.rmempty = false
o:depends({ _hide_node_option = "1", ['!reverse'] = true }) o:depends({ _hide_node_option = "1", ['!reverse'] = true })
o = s:option(ListValue, "tcp_node", "<a style='color: red'>" .. translate("TCP Node") .. "</a>") o = s:option(ListValue, "node", "<a style='color: red'>" .. translate("Proxy Node") .. "</a>")
o.default = "" o.default = ""
o:depends({ _hide_node_option = false, use_global_config = false }) o:depends({ _hide_node_option = false, use_global_config = false })
o.template = m:template_path("/cbi/nodes_listvalue") o.template = m:template_path("/cbi/nodes_listvalue")
o.group = {} o.group = {}
o.remove = function(self, section)
m:del(section, self.option)
m:del(section, "udp_node")
end
o = s:option(DummyValue, "_tcp_node_bool", "") o = s:option(DummyValue, "_acl_node_bool", "")
o.template = m:template_path("/cbi/hidevalue") o.template = m:template_path("/cbi/hidevalue")
o.value = "1" o.value = "1"
o:depends({ tcp_node = "", ['!reverse'] = true }) o:depends({ node = "", ['!reverse'] = true })
o = s:option(ListValue, "udp_node", "<a style='color: red'>" .. translate("UDP Node") .. "</a>")
o.default = ""
o:value("", translate("Close"))
o:value("tcp", translate("Same as the tcp node"))
o:depends({ _tcp_node_bool = "1", _node_sel_other = "1" })
o.template = m:template_path("/cbi/nodes_listvalue")
o.group = {"",""}
o.remove = function(self, section)
local v = s.fields["shunt_udp_node"]:formvalue(section)
if not v or v == "close" then
return m:del(section, self.option)
else
return m:set(section, self.option, "tcp")
end
end
o = s:option(ListValue, "shunt_udp_node", "<a style='color: red'>" .. translate("UDP Node") .. "</a>")
o:value("close", translate("Close"))
o:value("tcp", translate("Same as the tcp node"))
o:depends({ _tcp_node_bool = "1", _node_sel_shunt = "1" })
o.cfgvalue = function(self, section)
local v = m:get(section, "udp_node") or ""
if v == "" then v = "close" end
if v ~= "close" and v ~= "tcp" then v = "tcp" end
return v
end
o.write = function(self, section, value)
if value == "close" then value = "" end
return m:set(section, "udp_node", value)
end
o = s:option(DummyValue, "_udp_node_bool", "")
o.template = m:template_path("/cbi/hidevalue")
o.value = "1"
o:depends({ udp_node = "", ['!reverse'] = true })
o:depends({ shunt_udp_node = "tcp" })
---- Log ---- Log
o = s:option(Flag, "log", translate("Enable Node Log")) o = s:option(Flag, "log", translate("Enable Node Log"))
@@ -268,7 +221,7 @@ o:value("", translate("Use global config") .. "(" .. TCP_PROXY_DROP_PORTS .. ")"
o:value("disable", translate("No patterns are used")) o:value("disable", translate("No patterns are used"))
o.validate = port_validate o.validate = port_validate
o:depends({ use_global_config = true }) o:depends({ use_global_config = true })
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
---- UDP Proxy Drop Ports ---- UDP Proxy Drop Ports
local UDP_PROXY_DROP_PORTS = m:get("@global_forwarding[0]", "udp_proxy_drop_ports") local UDP_PROXY_DROP_PORTS = m:get("@global_forwarding[0]", "udp_proxy_drop_ports")
@@ -278,7 +231,7 @@ o:value("disable", translate("No patterns are used"))
o:value("443", translate("QUIC")) o:value("443", translate("QUIC"))
o.validate = port_validate o.validate = port_validate
o:depends({ use_global_config = true }) o:depends({ use_global_config = true })
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
---- TCP Redir Ports ---- TCP Redir Ports
local TCP_REDIR_PORTS = m:get("@global_forwarding[0]", "tcp_redir_ports") local TCP_REDIR_PORTS = m:get("@global_forwarding[0]", "tcp_redir_ports")
@@ -290,7 +243,7 @@ o:value("80:65535", "80 " .. translate("or more"))
o:value("1:443", "443 " .. translate("or less")) o:value("1:443", "443 " .. translate("or less"))
o.validate = port_validate o.validate = port_validate
o:depends({ use_global_config = true }) o:depends({ use_global_config = true })
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
---- UDP Redir Ports ---- UDP Redir Ports
local UDP_REDIR_PORTS = m:get("@global_forwarding[0]", "udp_redir_ports") local UDP_REDIR_PORTS = m:get("@global_forwarding[0]", "udp_redir_ports")
@@ -300,7 +253,7 @@ o:value("1:65535", translate("All"))
o:value("53", "53") o:value("53", "53")
o.validate = port_validate o.validate = port_validate
o:depends({ use_global_config = true }) o:depends({ use_global_config = true })
o:depends({ _udp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
o = s:option(DummyValue, "tips", " ") o = s:option(DummyValue, "tips", " ")
o.rawhtml = true o.rawhtml = true
@@ -309,24 +262,24 @@ o.cfgvalue = function(t, n)
translate("The port settings support single ports and ranges.<br>Separate multiple ports with commas (,).<br>Example: 21,80,443,1000:2000.")) translate("The port settings support single ports and ranges.<br>Separate multiple ports with commas (,).<br>Example: 21,80,443,1000:2000."))
end end
o:depends({ use_global_config = true }) o:depends({ use_global_config = true })
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
o = s:option(Flag, "use_direct_list", translatef("Use %s", translate("Direct List"))) o = s:option(Flag, "use_direct_list", translatef("Use %s", translate("Direct List")))
o.default = "1" o.default = "1"
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
o = s:option(Flag, "use_proxy_list", translatef("Use %s", translate("Proxy List"))) o = s:option(Flag, "use_proxy_list", translatef("Use %s", translate("Proxy List")))
o.default = "1" o.default = "1"
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
o = s:option(Flag, "use_block_list", translatef("Use %s", translate("Block List"))) o = s:option(Flag, "use_block_list", translatef("Use %s", translate("Block List")))
o.default = "1" o.default = "1"
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
if has_gfwlist then if has_gfwlist then
o = s:option(Flag, "use_gfw_list", translatef("Use %s", translate("GFW List"))) o = s:option(Flag, "use_gfw_list", translatef("Use %s", translate("GFW List")))
o.default = "1" o.default = "1"
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
end end
if has_chnlist or has_chnroute then if has_chnlist or has_chnroute then
@@ -335,28 +288,28 @@ if has_chnlist or has_chnroute then
o:value("direct", translate("Direct Connection")) o:value("direct", translate("Direct Connection"))
o:value("proxy", translate("Proxy")) o:value("proxy", translate("Proxy"))
o.default = "direct" o.default = "direct"
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
end end
o = s:option(ListValue, "tcp_proxy_mode", "TCP " .. translate("Proxy Mode")) o = s:option(ListValue, "tcp_proxy_mode", "TCP " .. translate("Proxy Mode"))
o:value("disable", translate("No Proxy")) o:value("disable", translate("No Proxy"))
o:value("proxy", translate("Proxy")) o:value("proxy", translate("Proxy"))
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
o = s:option(ListValue, "udp_proxy_mode", "UDP " .. translate("Proxy Mode")) o = s:option(ListValue, "udp_proxy_mode", "UDP " .. translate("Proxy Mode"))
o:value("disable", translate("No Proxy")) o:value("disable", translate("No Proxy"))
o:value("proxy", translate("Proxy")) o:value("proxy", translate("Proxy"))
o:depends({ _udp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
o = s:option(DummyValue, "switch_mode", " ") o = s:option(DummyValue, "switch_mode", " ")
o.template = m:template_path("/global/proxy") o.template = m:template_path("/global/proxy")
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
-- Node → DNS Depends Settings -- Node → DNS Depends Settings
o = s:option(DummyValue, "_node_sel_shunt", "") o = s:option(DummyValue, "_node_sel_shunt", "")
o.template = m:template_path("/cbi/hidevalue") o.template = m:template_path("/cbi/hidevalue")
o.value = "1" o.value = "1"
o:depends({ tcp_node = "__always__" }) o:depends({ node = "__always__" })
o = s:option(DummyValue, "_node_sel_other", "") o = s:option(DummyValue, "_node_sel_other", "")
o.template = m:template_path("/cbi/hidevalue") o.template = m:template_path("/cbi/hidevalue")
@@ -368,11 +321,11 @@ o = s:option(ListValue, "dns_shunt", "DNS " .. translate("Shunt"))
o.default = "chinadns-ng" o.default = "chinadns-ng"
o:value("dnsmasq", "Dnsmasq") o:value("dnsmasq", "Dnsmasq")
o:value("chinadns-ng", translate("ChinaDNS-NG (recommended)")) o:value("chinadns-ng", translate("ChinaDNS-NG (recommended)"))
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
o = s:option(Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6"), translate("Experimental feature.")) o = s:option(Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6"), translate("Experimental feature."))
o.default = "0" o.default = "0"
o:depends({ _tcp_node_bool = "1" }) o:depends({ _acl_node_bool = "1" })
---- DNS Forward Mode ---- DNS Forward Mode
o = s:option(ListValue, "dns_mode", translate("Filter Mode")) o = s:option(ListValue, "dns_mode", translate("Filter Mode"))
@@ -385,7 +338,7 @@ end
if has_xray then if has_xray then
o:value("xray", "Xray") o:value("xray", "Xray")
end end
o:depends({ _tcp_node_bool = "1", _node_sel_other = "1" }) o:depends({ _acl_node_bool = "1", _node_sel_other = "1" })
o.write = function(self, section, value) o.write = function(self, section, value)
if value == "dns2socks" then if value == "dns2socks" then
m:del(section, "v2ray_dns_mode") m:del(section, "v2ray_dns_mode")
@@ -393,7 +346,7 @@ o.write = function(self, section, value)
return ListValue.write(self, section, value) return ListValue.write(self, section, value)
end end
o.remove = function(self, section) o.remove = function(self, section)
local f = s.fields["tcp_node"] local f = s.fields["node"]
local id_val = f and f:formvalue(section) or "" local id_val = f and f:formvalue(section) or ""
if id_val == "" then if id_val == "" then
return m:del(section, self.option) return m:del(section, self.option)
@@ -517,10 +470,10 @@ o:depends({dns_mode = "xray"})
o.validate = function(self, value, t) o.validate = function(self, value, t)
if value and value == "1" then if value and value == "1" then
local _dns_mode = s.fields["dns_mode"]:formvalue(t) local _dns_mode = s.fields["dns_mode"]:formvalue(t)
local _tcp_node = s.fields["tcp_node"]:formvalue(t) local _node = s.fields["node"]:formvalue(t)
if _dns_mode and _tcp_node then if _dns_mode and _node then
if (m:get(_tcp_node, "type") or ""):lower() ~= _dns_mode and not _tcp_node:find("socks_") then if (m:get(_node, "type") or ""):lower() ~= _dns_mode and not _node:find("socks_") then
return nil, translatef("TCP node must be '%s' type to use FakeDNS.", _dns_mode) return nil, translatef("Node must be '%s' type to use FakeDNS.", _dns_mode)
end end
end end
end end
@@ -562,44 +515,35 @@ o:value("direct", translate("Direct DNS"))
o.description = desc .. "</ul>" o.description = desc .. "</ul>"
o:depends({dns_shunt = "dnsmasq", tcp_proxy_mode = "proxy", chn_list = "direct"}) o:depends({dns_shunt = "dnsmasq", tcp_proxy_mode = "proxy", chn_list = "direct"})
local tcp = s.fields["tcp_node"] local o_node = s.fields["node"]
local udp = s.fields["udp_node"]
for k, v in pairs(socks_list) do for k, v in pairs(socks_list) do
tcp:value(v.id, v["remark"]) o_node:value(v.id, v["remark"])
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default") o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
udp:value(v.id, v["remark"])
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
end end
for k, v in pairs(nodes_table) do for k, v in pairs(nodes_table) do
if #normal_list == 0 then if #normal_list == 0 then
s.fields["dns_mode"]:depends({ _tcp_node_bool = "1" }) s.fields["dns_mode"]:depends({ _acl_node_bool = "1" })
break break
end end
if v.protocol == "_shunt" then if v.protocol == "_shunt" then
if v.type == "Xray" and has_xray then if v.type == "Xray" and has_xray then
tcp:value(v.id, v["remark"]) o_node:value(v.id, v["remark"])
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default") o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
udp:value(v.id, v["remark"])
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
s.fields["xray_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id }) s.fields["xray_dns_mode"]:depends({ _acl_node_bool = "1", node = v.id })
s.fields["_node_sel_shunt"]:depends({ tcp_node = v.id }) s.fields["_node_sel_shunt"]:depends({ node = v.id })
end end
if v.type == "sing-box" and has_singbox then if v.type == "sing-box" and has_singbox then
tcp:value(v.id, v["remark"]) o_node:value(v.id, v["remark"])
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default") o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
udp:value(v.id, v["remark"])
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
s.fields["singbox_dns_mode"]:depends({ _tcp_node_bool = "1", tcp_node = v.id }) s.fields["singbox_dns_mode"]:depends({ _acl_node_bool = "1", node = v.id })
s.fields["_node_sel_shunt"]:depends({ tcp_node = v.id }) s.fields["_node_sel_shunt"]:depends({ node = v.id })
s.fields["remote_rewrite_ttl"]:depends({ _tcp_node_bool = "1", tcp_node = v.id }) s.fields["remote_rewrite_ttl"]:depends({ _acl_node_bool = "1", node = v.id })
end end
else else
tcp:value(v.id, v["remark"]) o_node:value(v.id, v["remark"])
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default") o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
udp:value(v.id, v["remark"])
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
end end
end end
@@ -43,11 +43,11 @@ end
local socks_list = {} local socks_list = {}
local tcp_socks_server = "127.0.0.1" .. ":" .. (m:get("@global[0]", "tcp_node_socks_port") or "1070") local socks_server = "127.0.0.1" .. ":" .. (m:get("@global[0]", "node_socks_port") or "1070")
local socks_table = {} local socks_table = {}
socks_table[#socks_table + 1] = { socks_table[#socks_table + 1] = {
id = tcp_socks_server, id = socks_server,
remark = tcp_socks_server .. " - " .. translate("TCP Node") remark = socks_server .. " - " .. translate("Proxy Node")
} }
m:foreach("socks", function(s) m:foreach("socks", function(s)
if s.enabled == "1" and s.node then if s.enabled == "1" and s.node then
@@ -103,44 +103,13 @@ s:tab("Main", translate("Main"))
o = s:taboption("Main", Flag, "enabled", translate("Main switch")) o = s:taboption("Main", Flag, "enabled", translate("Main switch"))
o.rmempty = false o.rmempty = false
---- TCP Node ---- Node
o = s:taboption("Main", ListValue, "tcp_node", "<a style='color: red'>" .. translate("TCP Node") .. "</a>") o = s:taboption("Main", ListValue, "node", "<a style='color: red'>" .. translate("Proxy Node") .. "</a>")
o.template = m:template_path("/cbi/nodes_listvalue") o.template = m:template_path("/cbi/nodes_listvalue")
o:value("", translate("Close")) o:value("", translate("Close"))
o.group = {""} o.group = {""}
---- UDP Node current_node_id = m:get(s.section, "node")
o = s:taboption("Main", ListValue, "udp_node", "<a style='color: red'>" .. translate("UDP Node") .. "</a>")
o.template = m:template_path("/cbi/nodes_listvalue")
o:value("", translate("Close"))
o:value("tcp", translate("Same as the tcp node"))
o.group = {"",""}
o:depends("_node_sel_other", "1")
o.remove = function(self, section)
local v = s.fields["shunt_udp_node"]:formvalue(section)
if not v or v == "close" then
return m:del(section, self.option)
else
return m:set(section, self.option, "tcp")
end
end
o = s:taboption("Main", ListValue, "shunt_udp_node", "<a style='color: red'>" .. translate("UDP Node") .. "</a>")
o:value("close", translate("Close"))
o:value("tcp", translate("Same as the tcp node"))
o:depends("_node_sel_shunt", "1")
o.cfgvalue = function(self, section)
local v = m:get(section, "udp_node") or ""
if v == "" then v = "close" end
if v ~= "close" and v ~= "tcp" then v = "tcp" end
return v
end
o.write = function(self, section, value)
if value == "close" then value = "" end
return m:set(section, "udp_node", value)
end
current_node_id = m:get(s.section, "tcp_node")
current_node = current_node_id and m:get(current_node_id) or {} current_node = current_node_id and m:get(current_node_id) or {}
-- Shunt Start -- Shunt Start
@@ -157,7 +126,7 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
balancing_list = balancing_list, balancing_list = balancing_list,
iface_list = iface_list, iface_list = iface_list,
normal_list = normal_list, normal_list = normal_list,
verify_option = s.fields["tcp_node"], verify_option = s.fields["node"],
tab = "Shunt", tab = "Shunt",
tab_desc = translate("Shunt Rule") tab_desc = translate("Shunt Rule")
}) })
@@ -168,36 +137,36 @@ if (has_singbox or has_xray) and #nodes_table > 0 then
tips.cfgvalue = function(t, n) tips.cfgvalue = function(t, n)
return string.format('<a style="color: red">%s</a>', translate("There are no available nodes, please add or subscribe nodes first.")) return string.format('<a style="color: red">%s</a>', translate("There are no available nodes, please add or subscribe nodes first."))
end end
tips:depends({ tcp_node = "", ["!reverse"] = true }) tips:depends({ node = "", ["!reverse"] = true })
for k, v in pairs(shunt_list) do for k, v in pairs(shunt_list) do
tips:depends("tcp_node", v.id) tips:depends("node", v.id)
end end
for k, v in pairs(balancing_list) do for k, v in pairs(balancing_list) do
tips:depends("tcp_node", v.id) tips:depends("node", v.id)
end end
end end
end end
o = s:taboption("Main", Value, "tcp_node_socks_port", translate("TCP Node") .. " Socks " .. translate("Listen Port")) o = s:taboption("Main", Value, "node_socks_port", translate("Node") .. " Socks " .. translate("Listen Port"))
o.default = 1070 o.default = 1070
o.datatype = "port" o.datatype = "port"
o:depends({ tcp_node = "", ["!reverse"] = true }) o:depends({ node = "", ["!reverse"] = true })
--[[ --[[
if has_singbox or has_xray then if has_singbox or has_xray then
o = s:taboption("Main", Value, "tcp_node_http_port", translate("TCP Node") .. " HTTP " .. translate("Listen Port") .. " " .. translate("0 is not use")) o = s:taboption("Main", Value, "node_http_port", translate("Node") .. " HTTP " .. translate("Listen Port") .. " " .. translate("0 is not use"))
o.default = 0 o.default = 0
o.datatype = "port" o.datatype = "port"
end end
]]-- ]]--
o = s:taboption("Main", Flag, "tcp_node_socks_bind_local", translate("TCP Node") .. " Socks " .. translate("Bind Local"), translate("When selected, it can only be accessed localhost.")) o = s:taboption("Main", Flag, "node_socks_bind_local", translate("Node") .. " Socks " .. translate("Bind Local"), translate("When selected, it can only be accessed localhost."))
o.default = "1" o.default = "1"
o:depends({ tcp_node = "", ["!reverse"] = true }) o:depends({ node = "", ["!reverse"] = true })
-- Node → DNS Depends Settings -- Node → DNS Depends Settings
o = s:taboption("Main", DummyValue, "_node_sel_shunt", "") o = s:taboption("Main", DummyValue, "_node_sel_shunt", "")
o.template = m:template_path("/cbi/hidevalue") o.template = m:template_path("/cbi/hidevalue")
o.value = "1" o.value = "1"
o:depends({ tcp_node = "__always__" }) o:depends({ node = "__always__" })
o = s:taboption("Main", DummyValue, "_node_sel_other", "") o = s:taboption("Main", DummyValue, "_node_sel_other", "")
o.template = m:template_path("/cbi/hidevalue") o.template = m:template_path("/cbi/hidevalue")
@@ -256,9 +225,9 @@ o:depends("direct_dns_mode", "tcp")
o = s:taboption("DNS", Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6")) o = s:taboption("DNS", Flag, "filter_proxy_ipv6", translate("Filter Proxy Host IPv6"))
o.default = "0" o.default = "0"
-- TCP分流时dns过滤模式保存逻辑 -- 分流时dns过滤模式保存逻辑
function dns_mode_save(section) function dns_mode_save(section)
local f = s.fields["tcp_node"] local f = s.fields["node"]
local id_val = f and f:formvalue(section) or "" local id_val = f and f:formvalue(section) or ""
if id_val == "" then if id_val == "" then
return return
@@ -478,10 +447,10 @@ o.validate = function(self, value, t)
if not _dns_mode and s.fields["smartdns_dns_mode"] then if not _dns_mode and s.fields["smartdns_dns_mode"] then
_dns_mode = s.fields["smartdns_dns_mode"]:formvalue(t) _dns_mode = s.fields["smartdns_dns_mode"]:formvalue(t)
end end
local _tcp_node = s.fields["tcp_node"]:formvalue(t) local _node = s.fields["node"]:formvalue(t)
if _dns_mode and _tcp_node then if _dns_mode and _node then
if (m:get(_tcp_node, "type") or ""):lower() ~= _dns_mode and not _tcp_node:find("socks_") then if (m:get(_node, "type") or ""):lower() ~= _dns_mode and not _node:find("socks_") then
return nil, translatef("TCP node must be '%s' type to use FakeDNS.", _dns_mode) return nil, translatef("Node must be '%s' type to use FakeDNS.", _dns_mode)
end end
end end
end end
@@ -665,11 +634,7 @@ o.cfgvalue = function(t, n)
end end
s:tab("log", translate("Log")) s:tab("log", translate("Log"))
o = s:taboption("log", Flag, "log_tcp", translate("Enable") .. " " .. translatef("%s Node Log", "TCP")) o = s:taboption("log", Flag, "log_node", translate("Enable Node Log"))
o.default = "0"
o.rmempty = false
o = s:taboption("log", Flag, "log_udp", translate("Enable") .. " " .. translatef("%s Node Log", "UDP"))
o.default = "0" o.default = "0"
o.rmempty = false o.rmempty = false
@@ -731,18 +696,12 @@ function s2.remove(e, t)
if node0 then if node0 then
new_node = node0[".name"] new_node = node0[".name"]
end end
if (m:get("@global[0]", "tcp_node") or "") == t then if (m:get("@global[0]", "node") or "") == t then
m:set('@global[0]', "tcp_node", new_node) m:set('@global[0]', "node", new_node)
end
if (m:get("@global[0]", "udp_node") or "") == t then
m:set('@global[0]', "udp_node", new_node)
end end
m:foreach("acl_rule", function(s) m:foreach("acl_rule", function(s)
if s["tcp_node"] and s["tcp_node"] == t then if s["node"] and s["node"] == t then
m:set(s[".name"], "tcp_node", "default") m:set(s[".name"], "node", "default")
end
if s["udp_node"] and s["udp_node"] == t then
m:set(s[".name"], "udp_node", "default")
end end
end) end)
m:foreach("nodes", function(s) m:foreach("nodes", function(s)
@@ -819,14 +778,11 @@ if has_singbox or has_xray then
end end
]]-- ]]--
local tcp = s.fields["tcp_node"] local o_node = s.fields["node"]
local udp = s.fields["udp_node"] local o_socks = s2.fields["node"]
local socks = s2.fields["node"]
for k, v in pairs(socks_list) do for k, v in pairs(socks_list) do
tcp:value(v.id, v["remark"]) o_node:value(v.id, v["remark"])
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default") o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
udp:value(v.id, v["remark"])
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
end end
for k, v in pairs(nodes_table) do for k, v in pairs(nodes_table) do
if #normal_list == 0 and #iface_list == 0 then if #normal_list == 0 and #iface_list == 0 then
@@ -834,33 +790,29 @@ for k, v in pairs(nodes_table) do
end end
if v.protocol == "_shunt" then if v.protocol == "_shunt" then
if has_singbox or has_xray then if has_singbox or has_xray then
tcp:value(v.id, v["remark"]) o_node:value(v.id, v["remark"])
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default") o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
udp:value(v.id, v["remark"])
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
s.fields["_node_sel_shunt"]:depends({ tcp_node = v.id }) s.fields["_node_sel_shunt"]:depends({ node = v.id })
if m:get(v.id, "type") == "Xray" then if m:get(v.id, "type") == "Xray" then
s.fields["xray_dns_mode"]:depends({ tcp_node = v.id }) s.fields["xray_dns_mode"]:depends({ node = v.id })
else else
s.fields["singbox_dns_mode"]:depends({ tcp_node = v.id }) s.fields["singbox_dns_mode"]:depends({ node = v.id })
s.fields["remote_rewrite_ttl"]:depends({ tcp_node = v.id }) s.fields["remote_rewrite_ttl"]:depends({ node = v.id })
end end
end end
else else
tcp:value(v.id, v["remark"]) o_node:value(v.id, v["remark"])
tcp.group[#tcp.group+1] = (v.group and v.group ~= "") and v.group or translate("default") o_node.group[#o_node.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
udp:value(v.id, v["remark"])
udp.group[#udp.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
end end
if v.type == "Socks" then if v.type == "Socks" then
if has_singbox or has_xray then if has_singbox or has_xray then
socks:value(v.id, v["remark"]) o_socks:value(v.id, v["remark"])
socks.group[#socks.group+1] = (v.group and v.group ~= "") and v.group or translate("default") o_socks.group[#o_socks.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
end end
else else
socks:value(v.id, v["remark"]) o_socks:value(v.id, v["remark"])
socks.group[#socks.group+1] = (v.group and v.group ~= "") and v.group or translate("default") o_socks.group[#o_socks.group+1] = (v.group and v.group ~= "") and v.group or translate("default")
end end
end end
@@ -119,11 +119,8 @@ o:value("1", "Nftables")
---- Check the transparent proxy component ---- Check the transparent proxy component
local handle = io.popen("lsmod") local handle = io.popen("lsmod")
local mods = "" local mods = handle and handle:read("*a") or ""
if handle then if handle then handle:close() end
mods = handle:read("*a") or ""
handle:close()
end
if (mods:find("REDIRECT") and mods:find("TPROXY")) or (mods:find("nft_redir") and mods:find("nft_tproxy")) then if (mods:find("REDIRECT") and mods:find("TPROXY")) or (mods:find("nft_redir") and mods:find("nft_tproxy")) then
o = s:option(ListValue, "tcp_proxy_way", translate("TCP Proxy Way")) o = s:option(ListValue, "tcp_proxy_way", translate("TCP Proxy Way"))
+1 -1
View File
@@ -258,7 +258,7 @@ end
function curl_proxy(url, file, args) function curl_proxy(url, file, args)
--使用代理 --使用代理
local socks_server = get_cache_var("GLOBAL_TCP_SOCKS_server") local socks_server = get_cache_var("GLOBAL_SOCKS_server")
if socks_server and socks_server ~= "" then if socks_server and socks_server ~= "" then
if not args then args = {} end if not args then args = {} end
local tmp_args = clone(args) local tmp_args = clone(args)
@@ -73,8 +73,7 @@ function gen_config(var)
return return
end end
local node = api.uci_get_c(node_id) local node = api.uci_get_c(node_id)
local local_tcp_redir_port = var["local_tcp_redir_port"] local local_redir_port = var["local_redir_port"]
local local_udp_redir_port = var["local_udp_redir_port"]
local local_socks_address = var["local_socks_address"] or "0.0.0.0" local local_socks_address = var["local_socks_address"] or "0.0.0.0"
local local_socks_port = var["local_socks_port"] local local_socks_port = var["local_socks_port"]
local local_socks_username = var["local_socks_username"] local local_socks_username = var["local_socks_username"]
@@ -170,14 +169,14 @@ function gen_config(var)
username = (local_http_username and local_http_password) and local_http_username or nil, username = (local_http_username and local_http_password) and local_http_username or nil,
password = (local_http_username and local_http_password) and local_http_password or nil, password = (local_http_username and local_http_password) and local_http_password or nil,
} or nil, } or nil,
tcpRedirect = ("redirect" == tcp_proxy_way and local_tcp_redir_port) and { tcpRedirect = ("redirect" == tcp_proxy_way and local_redir_port) and {
listen = "0.0.0.0:" .. local_tcp_redir_port listen = "0.0.0.0:" .. local_redir_port
} or nil, } or nil,
tcpTProxy = ("tproxy" == tcp_proxy_way and local_tcp_redir_port) and { tcpTProxy = ("tproxy" == tcp_proxy_way and local_redir_port) and {
listen = "0.0.0.0:" .. local_tcp_redir_port listen = "0.0.0.0:" .. local_redir_port
} or nil, } or nil,
udpTProxy = (local_udp_redir_port) and { udpTProxy = (local_redir_port) and {
listen = "0.0.0.0:" .. local_udp_redir_port listen = "0.0.0.0:" .. local_redir_port
} or nil } or nil
} }
@@ -53,10 +53,8 @@ function gen_config(var)
local local_http_port = var["local_http_port"] local local_http_port = var["local_http_port"]
local local_http_username = var["local_http_username"] local local_http_username = var["local_http_username"]
local local_http_password = var["local_http_password"] local local_http_password = var["local_http_password"]
local local_tcp_redir_port = var["local_tcp_redir_port"] local local_redir_port = var["local_redir_port"]
local local_tcp_redir_address = var["local_tcp_redir_address"] or "0.0.0.0" local local_redir_address = var["local_redir_address"] or "0.0.0.0"
local local_udp_redir_port = var["local_udp_redir_port"]
local local_udp_redir_address = var["local_udp_redir_address"] or "0.0.0.0"
if api.is_ipv6(server_host) then if api.is_ipv6(server_host) then
server_host = api.get_ipv6_only(server_host) server_host = api.get_ipv6_only(server_host)
@@ -118,21 +116,13 @@ function gen_config(var)
local_port = tonumber(local_http_port) local_port = tonumber(local_http_port)
}) })
end end
if local_tcp_redir_address and local_tcp_redir_port then if local_redir_address and local_redir_port then
table.insert(config.locals, { table.insert(config.locals, {
protocol = "redir", protocol = "redir",
mode = "tcp_only", mode = "tcp_and_udp",
tcp_redir = var["tcp_tproxy"] and "tproxy" or nil, tcp_redir = var["tcp_tproxy"] and "tproxy" or nil,
local_address = local_tcp_redir_address, local_address = local_redir_address,
local_port = tonumber(local_tcp_redir_port) local_port = tonumber(local_redir_port)
})
end
if local_udp_redir_address and local_udp_redir_port then
table.insert(config.locals, {
protocol = "redir",
mode = "udp_only",
local_address = local_udp_redir_address,
local_port = tonumber(local_udp_redir_port)
}) })
end end
end end
@@ -1087,8 +1087,7 @@ function gen_config(var)
local server_host = var["server_host"] local server_host = var["server_host"]
local server_port = var["server_port"] local server_port = var["server_port"]
local tcp_proxy_way = var["tcp_proxy_way"] local tcp_proxy_way = var["tcp_proxy_way"]
local tcp_redir_port = var["tcp_redir_port"] local redir_port = var["redir_port"]
local udp_redir_port = var["udp_redir_port"]
local local_socks_address = var["local_socks_address"] or "0.0.0.0" local local_socks_address = var["local_socks_address"] or "0.0.0.0"
local local_socks_port = var["local_socks_port"] local local_socks_port = var["local_socks_port"]
local local_socks_username = var["local_socks_username"] local local_socks_username = var["local_socks_username"]
@@ -1237,43 +1236,34 @@ function gen_config(var)
table.insert(inbounds, inbound) table.insert(inbounds, inbound)
end end
if tcp_redir_port then if redir_port then
local inbound local inbound_tproxy = {
type = "tproxy",
tag = "tproxy",
listen = "::",
listen_port = tonumber(redir_port),
}
if tcp_proxy_way ~= "tproxy" then if tcp_proxy_way ~= "tproxy" then
inbound = { local inbound = {
type = "redirect", type = "redirect",
tag = "redirect_tcp", tag = "redirect_tcp",
listen = "::", listen = "::",
listen_port = tonumber(tcp_redir_port) listen_port = tonumber(redir_port),
} }
else
inbound = {
type = "tproxy",
tag = "tproxy_tcp",
network = "tcp",
listen = "::",
listen_port = tonumber(tcp_redir_port)
}
end
table.insert(inbounds, inbound) table.insert(inbounds, inbound)
table.insert(route.rules, { table.insert(route.rules, {
action = "sniff", action = "sniff",
inbound = inbound.tag inbound = inbound.tag
}) })
inbound_tproxy.tag = "tproxy_udp"
inbound_tproxy.network = "udp"
end end
if udp_redir_port then table.insert(inbounds, inbound_tproxy)
local inbound = {
type = "tproxy",
tag = "tproxy_udp",
network = "udp",
listen = "::",
listen_port = tonumber(udp_redir_port)
}
table.insert(inbounds, inbound)
table.insert(route.rules, { table.insert(route.rules, {
action = "sniff", action = "sniff",
inbound = inbound.tag inbound = inbound_tproxy.tag
}) })
end end
@@ -1315,7 +1305,7 @@ function gen_config(var)
ut_nodes = _node.urltest_node ut_nodes = _node.urltest_node
end end
api.log(" - 加载 Sing-Box URLTest 节点【" .. (_node.remarks or "") .. "】,子节点数量:" .. #(ut_nodes or {})) -- api.log(" - 加载 Sing-Box URLTest 节点【" .. (_node.remarks or "") .. "】,子节点数量:" .. #(ut_nodes or {}))
local valid_nodes = {} local valid_nodes = {}
for i = 1, #(ut_nodes or {}) do for i = 1, #(ut_nodes or {}) do
@@ -1620,17 +1610,15 @@ function gen_config(var)
if e["inbound"] and e["inbound"] ~= "" then if e["inbound"] and e["inbound"] ~= "" then
inboundTag = {} inboundTag = {}
if e["inbound"]:find("tproxy") then if e["inbound"]:find("tproxy") then
if tcp_redir_port then if redir_port then
if tcp_proxy_way == "tproxy" then if tcp_proxy_way == "tproxy" then
table.insert(inboundTag, "tproxy_tcp") table.insert(inboundTag, "tproxy")
else else
table.insert(inboundTag, "redirect_tcp") table.insert(inboundTag, "redirect_tcp")
end
end
if udp_redir_port then
table.insert(inboundTag, "tproxy_udp") table.insert(inboundTag, "tproxy_udp")
end end
end end
end
if e["inbound"]:find("socks") then if e["inbound"]:find("socks") then
if local_socks_port then if local_socks_port then
table.insert(inboundTag, "socks-in") table.insert(inboundTag, "socks-in")
@@ -1987,7 +1975,7 @@ function gen_config(var)
local default_dns_flag = "remote" local default_dns_flag = "remote"
if dns_socks_address and dns_socks_port then if dns_socks_address and dns_socks_port then
else else
if node_id and (tcp_redir_port or udp_redir_port) then if node_id and redir_port then
local node = get_node_by_id(node_id) local node = get_node_by_id(node_id)
if node.protocol == "_shunt" then if node.protocol == "_shunt" then
if node.default_node == "_direct" then if node.default_node == "_direct" then
@@ -869,8 +869,7 @@ function gen_config(var)
local server_host = var["server_host"] local server_host = var["server_host"]
local server_port = var["server_port"] local server_port = var["server_port"]
local tcp_proxy_way = var["tcp_proxy_way"] or "redirect" local tcp_proxy_way = var["tcp_proxy_way"] or "redirect"
local tcp_redir_port = var["tcp_redir_port"] local redir_port = var["redir_port"]
local udp_redir_port = var["udp_redir_port"]
local local_socks_address = var["local_socks_address"] or "0.0.0.0" local local_socks_address = var["local_socks_address"] or "0.0.0.0"
local local_socks_port = var["local_socks_port"] local local_socks_port = var["local_socks_port"]
local local_socks_username = var["local_socks_username"] local local_socks_username = var["local_socks_username"]
@@ -1068,7 +1067,7 @@ function gen_config(var)
blc_nodes = _node.balancing_node blc_nodes = _node.balancing_node
end end
api.log(" - 加载 Xray 负载均衡 节点【" .. (_node.remarks or "") .. "】,子节点数量:" .. #(blc_nodes or {})) -- api.log(" - 加载 Xray 负载均衡 节点【" .. (_node.remarks or "") .. "】,子节点数量:" .. #(blc_nodes or {}))
local valid_nodes = {} local valid_nodes = {}
for i = 1, #(blc_nodes or {}) do for i = 1, #(blc_nodes or {}) do
@@ -1448,11 +1447,9 @@ function gen_config(var)
if e["inbound"] and e["inbound"] ~= "" then if e["inbound"] and e["inbound"] ~= "" then
inbound_tag = {} inbound_tag = {}
if e["inbound"]:find("tproxy") then if e["inbound"]:find("tproxy") then
if tcp_redir_port then if redir_port then
table.insert(inbound_tag, "tcp_redir") table.insert(inboundTag, "tcp_redir")
end table.insert(inboundTag, "udp_redir")
if udp_redir_port then
table.insert(inbound_tag, "udp_redir")
end end
end end
if e["inbound"]:find("socks") then if e["inbound"]:find("socks") then
@@ -1585,13 +1582,14 @@ function gen_config(var)
end end
end end
if tcp_redir_port or udp_redir_port then if redir_port then
local inbound = { local inbound = {
port = tonumber(redir_port),
protocol = "tunnel", protocol = "tunnel",
settings = {allowedNetwork = "tcp,udp", followRedirect = true}, settings = {allowedNetwork = "tcp,udp", followRedirect = true},
streamSettings = {sockopt = {tproxy = "tproxy"}}, streamSettings = {sockopt = {tproxy = "tproxy"}},
sniffing = { sniffing = {
enabled = (xray_settings.sniffing_override_dest == "1") or (node and node.protocol == "_shunt") or false enabled = xray_settings.sniffing_override_dest == "1" or node.protocol == "_shunt"
} }
} }
if inbound.sniffing.enabled == true then if inbound.sniffing.enabled == true then
@@ -1611,24 +1609,18 @@ function gen_config(var)
end end
end end
if tcp_redir_port then
local tcp_inbound = api.clone(inbound) local tcp_inbound = api.clone(inbound)
tcp_inbound.tag = "tcp_redir" tcp_inbound.tag = "tcp_redir"
tcp_inbound.settings.allowedNetwork = "tcp" tcp_inbound.settings.allowedNetwork = "tcp"
tcp_inbound.port = tonumber(tcp_redir_port)
tcp_inbound.streamSettings.sockopt.tproxy = tcp_proxy_way tcp_inbound.streamSettings.sockopt.tproxy = tcp_proxy_way
table.insert(inbounds, tcp_inbound) table.insert(inbounds, tcp_inbound)
end
if udp_redir_port then
local udp_inbound = api.clone(inbound) local udp_inbound = api.clone(inbound)
udp_inbound.tag = "udp_redir" udp_inbound.tag = "udp_redir"
udp_inbound.settings.allowedNetwork = "udp" udp_inbound.settings.allowedNetwork = "udp"
udp_inbound.port = tonumber(udp_redir_port)
table.insert(inbounds, udp_inbound) table.insert(inbounds, udp_inbound)
end end
end end
end
local node_dns = {} local node_dns = {}
for i, v in pairs(GLOBAL.DNS_SERVER) do for i, v in pairs(GLOBAL.DNS_SERVER) do
@@ -33,7 +33,7 @@ local sid = self.section
if (!node) return false; if (!node) return false;
let changed = false; let changed = false;
const all_node = node.querySelectorAll("[id]"); const all_node = node.querySelectorAll("[id]");
const reg1 = /^cbid\..*\.(tcp_node|udp_node)\.main$/; const reg1 = /^cbid\..*node\.main$/;
for (const el of all_node) { for (const el of all_node) {
if (!reg1.test(el.id)) continue; if (!reg1.test(el.id)) continue;
@@ -43,15 +43,15 @@ local sid = self.section
const cbid = el.id.replace(/\.main$/, ""); const cbid = el.id.replace(/\.main$/, "");
const hidden_select = document.getElementById(cbid); const hidden_select = document.getElementById(cbid);
const node_select_value = hidden_select?.options[0]?.value; const node_select_value = hidden_select?.options[0]?.value;
if (!node_select_value || node_select_value.indexOf("tcp") === 0) { if (!node_select_value) {
continue; continue;
} }
let html = '<a href="#" onclick="return to_edit_node(this);"><%:Edit%></a>'; let html = '<a href="#" onclick="return to_edit_node(this);"><%:Edit%></a>';
const m = cbid.match(/\.(tcp|udp)_node$/); const m = cbid.match(/\.node$/);
if (m && (m[1] === "tcp" || m[1] === "udp")) { if (m) {
html += '<a href="#" onclick="window.open(\'' + '<%=api.url("get_redir_log") .. "?name=" .. sid%>&proto=' + m[1] + '\', \'_blank\')"><%:Log%></a>'; html += '<a href="#" onclick="window.open(\'' + '<%=api.url("get_redir_log") .. "?id=" .. sid%>' + '\', \'_blank\')"><%:Log%></a>';
} }
html = '<div class="node-actions" style="display:inline-flex; align-items:center; gap:4px; flex-wrap:wrap; margin-left:4px;">' + html + '</div>' html = '<div class="node-actions" style="display:inline-flex; align-items:center; gap:4px; flex-wrap:wrap; margin-left:4px;">' + html + '</div>'
@@ -131,9 +131,9 @@ local sid = "@global[0]"
let html = '<a href="#" onclick="return to_edit_node(this, global_id);"><%:Edit%></a>'; let html = '<a href="#" onclick="return to_edit_node(this, global_id);"><%:Edit%></a>';
const m = cbid.match(/\.(tcp|udp)_node$/); const m = cbid.match(/\.node$/);
if (m && (m[1] === "tcp" || m[1] === "udp")) { if (m) {
html += '<a href="#" onclick="window.open(\'' + '<%=api.url("get_redir_log")%>?name=default&proto=' + m[1] + '\', \'_blank\')"><%:Log%></a>'; html += '<a href="#" onclick="window.open(\'' + '<%=api.url("get_redir_log")%>?id=default' + '\', \'_blank\')"><%:Log%></a>';
} }
html = '<div class="node-actions" style="display:inline-flex; align-items:center; gap:4px; flex-wrap:wrap; margin-left:4px;">' + html + '</div>' html = '<div class="node-actions" style="display:inline-flex; align-items:center; gap:4px; flex-wrap:wrap; margin-left:4px;">' + html + '</div>'
@@ -249,7 +249,7 @@ local sid = "@global[0]"
})(); })();
document.addEventListener("DOMContentLoaded", () => setTimeout(() => { document.addEventListener("DOMContentLoaded", () => setTimeout(() => {
const hiddenSelect = document.getElementById("cbid.<%=appname%>.<%=sid%>.tcp_node"); const hiddenSelect = document.getElementById("cbid.<%=appname%>.<%=sid%>.node");
let o_val = hiddenSelect.value let o_val = hiddenSelect.value
const o_hasItem = shunt_list.find(element => element.id == o_val); const o_hasItem = shunt_list.find(element => element.id == o_val);
hiddenSelect.addEventListener("change", function(el){ hiddenSelect.addEventListener("change", function(el){
@@ -259,7 +259,7 @@ local sid = "@global[0]"
XHR.get('<%=api.url("update_config")%>', { XHR.get('<%=api.url("update_config")%>', {
id: "<%=sid%>", id: "<%=sid%>",
data: JSON.stringify({ data: JSON.stringify({
tcp_node: new_val node: new_val
}) })
}, },
function(x, data) { function(x, data) {
@@ -99,7 +99,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
</div> </div>
</div> </div>
<div class="pure-u-2-3"> <div class="pure-u-2-3">
<h4 id="status_tcp_node">TCP<br /><span class="red"><%:NOT RUNNING%></span></h4> <h4 id="status_tcp">TCP<br /><span class="red"><%:NOT RUNNING%></span></h4>
</div> </div>
</div> </div>
</div> </div>
@@ -111,7 +111,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
</div> </div>
</div> </div>
<div class="pure-u-2-3"> <div class="pure-u-2-3">
<h4 id="status_udp_node">UDP<br /><span class="red"><%:NOT RUNNING%></span></h4> <h4 id="status_udp">UDP<br /><span class="red"><%:NOT RUNNING%></span></h4>
</div> </div>
</div> </div>
</div> </div>
@@ -201,26 +201,26 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
var status_haproxy = document.getElementById('status_haproxy'); var status_haproxy = document.getElementById('status_haproxy');
if (data) { if (data) {
if (true) { if (true) {
var status_tcp_node = document.getElementById('status_tcp_node'); var status_tcp = document.getElementById('status_tcp');
if (status_tcp_node) { if (status_tcp) {
var text = 'TCP<br />'; var text = 'TCP<br />';
if (data["tcp_node_status"]) if (data["tcp_status"])
text += '<span class="green"><%:RUNNING%></span>'; text += '<span class="green"><%:RUNNING%></span>';
else else
text += '<span class="red"><%:NOT RUNNING%></span>'; text += '<span class="red"><%:NOT RUNNING%></span>';
status_tcp_node.innerHTML = text; status_tcp.innerHTML = text;
} }
} }
if (true) { if (true) {
var status_udp_node = document.getElementById('status_udp_node'); var status_udp = document.getElementById('status_udp');
if (status_udp_node) { if (status_udp) {
var text = 'UDP<br />'; var text = 'UDP<br />';
if (data["udp_node_status"]) if (data["udp_status"])
text += '<span class="green"><%:RUNNING%></span>'; text += '<span class="green"><%:RUNNING%></span>';
else else
text += '<span class="red"><%:NOT RUNNING%></span>'; text += '<span class="red"><%:NOT RUNNING%></span>';
status_udp_node.innerHTML = text; status_udp.innerHTML = text;
} }
} }
@@ -75,10 +75,13 @@ display:block !important;
const _ASSETS = '/luci-static/passwall/'; const _ASSETS = '/luci-static/passwall/';
const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[passwall]], [[ip]])%>'; const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[passwall]], [[ip]])%>';
let mainContent = document.getElementById("maincontent");
let statusBar = document.querySelector(".status-bar"); let statusBar = document.querySelector(".status-bar");
function resize() { function resize() {
statusBar.style.width = document.getElementById("maincontent").offsetWidth + 'px'; wW = window.innerWidth;
let lw = document.querySelector(".main-left, :root[data-layout='sidebar'] .fs-sidebar")?.offsetWidth ?? 5;
statusBar.style.width = (wW - lw) + 'px';
let flagElement = statusBar.querySelector(".flag"); let flagElement = statusBar.querySelector(".flag");
flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px'; flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px';
@@ -122,5 +125,7 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
window.addEventListener('resize', resize); window.addEventListener('resize', resize);
if (mainContent && window.getComputedStyle(mainContent).getPropertyValue("contain")=== "paint") {
document.body.appendChild(statusBar); document.body.appendChild(statusBar);
}
</script> </script>
@@ -4,6 +4,23 @@ local api = map.api
local appname = map.config local appname = map.config
local is_js_luci = api.is_js_luci() local is_js_luci = api.is_js_luci()
local section_tag = is_js_luci and "div" or "fieldset" local section_tag = is_js_luci and "div" or "fieldset"
local default_node_type = ""
local shunt_rule_list = {}
local node = map:get("@global[0]", "node")
if node then
local node_type = map:get(node, "type")
local node_protocol = map:get(node, "protocol")
if (node_type == "Xray" or node_type == "sing-box") and node_protocol == "_shunt" then
default_node_type = node_protocol
local node_shunt_group = map:get(node, "shunt_group")
map:foreach("shunt_rules", function(e)
if e[".name"] and e.remarks and e.group == node_shunt_group then
shunt_rule_list[#shunt_rule_list + 1] = e
end
end)
end
end
-%> -%>
<script src="<%=resource%>/view/<%=appname%>/Sortable.min.js?v=1.15.7"></script> <script src="<%=resource%>/view/<%=appname%>/Sortable.min.js?v=1.15.7"></script>
@@ -22,12 +39,13 @@ table td, .table .td {
display: none; display: none;
width: 30rem; width: 30rem;
position: fixed; position: fixed;
top:50%; top:45%;
padding-top: 30px;
z-index: 99; z-index: 99;
text-align: center; text-align: center;
background: white; background: white;
box-shadow: darkgrey 10px 10px 30px 5px; box-shadow: darkgrey 10px 10px 30px 5px;
text-align: center;
padding: 0.5em;
} }
._now_use_bg { ._now_use_bg {
@@ -669,13 +687,13 @@ table td, .table .td {
function get_now_use_node() { function get_now_use_node() {
XHR.get('<%=api.url("get_now_use_node")%>', null, XHR.get('<%=api.url("get_now_use_node")%>', null,
function(x, result) { function(x, result) {
var id = result["TCP"]; var id = result["global"];
if (id) { if (id) {
var dom = document.getElementById("cbi-<%=appname%>-" + id); var dom = document.getElementById("cbi-<%=appname%>-" + id);
if (dom) { if (dom) {
dom.title = '<%=api.i18n.translatef("Currently using %s node", "TCP")%>'; dom.title = "<%:Currently using node%>";
dom.classList.add("_now_use_bg"); dom.classList.add("_now_use_bg");
//var v = "<a style='color: red'>当前TCP节点</a>" + document.getElementById("cbid.<%=appname%>." + id + ".remarks").value; //var v = "<a style='color: red'><%:Using...%></a>" + document.getElementById("cbid.<%=appname%>." + id + ".remarks").value;
//document.getElementById("cbi-<%=appname%>-" + id + "-remarks").innerHTML = v; //document.getElementById("cbi-<%=appname%>-" + id + "-remarks").innerHTML = v;
var dom_remarks = dom.querySelector("td.pw-remark"); var dom_remarks = dom.querySelector("td.pw-remark");
if (dom_remarks) { if (dom_remarks) {
@@ -683,22 +701,6 @@ table td, .table .td {
} }
} }
} }
id = result["UDP"];
if (id) {
var dom = document.getElementById("cbi-<%=appname%>-" + id);
if (dom) {
if (result["TCP"] == result["UDP"]) {
dom.title = '<%=api.i18n.translatef("Currently using %s node", "TCP/UDP")%>';
} else {
dom.title = '<%=api.i18n.translatef("Currently using %s node", "UDP")%>';
}
dom.classList.add("_now_use_bg");
var dom_remarks = dom.querySelector("td.pw-remark");
if (dom_remarks) {
dom_remarks.style.color = 'red';
}
}
}
} }
); );
} }
@@ -1223,10 +1225,10 @@ table td, .table .td {
document.getElementById("set_node_div").style.display="none"; document.getElementById("set_node_div").style.display="none";
document.getElementById("set_node_name").textContent = ""; document.getElementById("set_node_name").textContent = "";
}, },
set(protocol) { set(type, config) {
if (confirm('<%:Are you sure set to%> ' + protocol.toUpperCase() + ' <%:the server?%>') == true){ if (confirm('<%:Are you sure set this node?%>') == true){
ajax.abortAll(); ajax.abortAll();
window.location.href = '<%=api.url("set_node")%>?protocol=' + protocol + '&section=' + this.section; window.location.href = '<%=api.url("set_node")%>?type=' + type + '&config=' + config + '&section=' + this.section;
} }
} }
} }
@@ -1617,14 +1619,22 @@ table td, .table .td {
</div> </div>
<div style="display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center;"> <div style="display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center;">
<div id="set_node_div" style="text-align: center;"> <div id="set_node_div">
<div class="cbi-value" style="display: flex; justify-content: center; align-items: center; margin: 8px 0;"> <div class="cbi-value" style="display: flex; justify-content: center; align-items: center; margin: 1em 0; height: 2em;">
<font color=#666><%:You choose node is:%></font><a style="color: red" id="set_node_name"></a> <font color=#666><%:You choose node is:%></font><a style="color: red" id="set_node_name"></a>
<div style="position:absolute; right:0.5em; top: 0.5em;"><input class="btn cbi-button" type="button" onclick="set_node_div.close()" value="X" /></div>
</div> </div>
<div class="cbi-value" style="display: flex; justify-content: center; gap: 8px; margin: 8px 0;"> <div class="cbi-value" style="justify-content: center; gap: 8px; margin: 1em 0;">
<input class="btn cbi-button cbi-button-edit" type="button" onclick="set_node_div.set('tcp')" value="TCP" /> <%- if default_node_type == "_shunt" then
<input class="btn cbi-button cbi-button-edit" type="button" onclick="set_node_div.set('udp')" value="UDP" /> for i, v in ipairs(shunt_rule_list) do
<input class="btn cbi-button cbi-button-remove" type="button" onclick="set_node_div.close()" value="<%:Close%>" /> -%>
<input class="btn cbi-button" type="button" onclick="set_node_div.set('<%=node%>', '<%=v[".name"]%>')" value="<%=v.remarks%>" />
<%-
end
-%>
<% else %>
<input class="btn cbi-button" type="button" onclick="set_node_div.set('@global[0]', 'node')" value="<%:Node%>" />
<% end %>
</div> </div>
</div> </div>
</div> </div>
+8 -14
View File
@@ -136,11 +136,8 @@ msgstr "清除"
msgid "Main switch" msgid "Main switch"
msgstr "主开关" msgstr "主开关"
msgid "TCP Node" msgid "Proxy Node"
msgstr "TCP 节点" msgstr "代理节点"
msgid "UDP Node"
msgstr "UDP 节点"
msgid "Edit Current Node" msgid "Edit Current Node"
msgstr "编辑当前节点" msgstr "编辑当前节点"
@@ -181,8 +178,8 @@ msgstr "%s 不能为空。"
msgid "Filter Mode" msgid "Filter Mode"
msgstr "过滤模式" msgstr "过滤模式"
msgid "TCP node must be '%s' type to use FakeDNS." msgid "Node must be '%s' type to use FakeDNS."
msgstr "TCP 节点必须是 '%s' 类型才能使用 FakeDNS。" msgstr "节点必须是 '%s' 类型才能使用 FakeDNS。"
msgid "Direct DNS" msgid "Direct DNS"
msgstr "直连 DNS" msgstr "直连 DNS"
@@ -472,8 +469,8 @@ msgstr "你确定要删除选择的节点吗?"
msgid "You no select nodes !" msgid "You no select nodes !"
msgstr "你没有选择任何节点!" msgstr "你没有选择任何节点!"
msgid "Are you sure set to" msgid "Are you sure set this node?"
msgstr "你确定要设" msgstr "你确定要设置这个节点吗?"
msgid "the server?" msgid "the server?"
msgstr "服务器吗?" msgstr "服务器吗?"
@@ -1667,9 +1664,6 @@ msgstr "日志"
msgid "Enable Node Log" msgid "Enable Node Log"
msgstr "启用节点日志" msgstr "启用节点日志"
msgid "%s Node Log"
msgstr "%s 节点日志"
msgid "Log Level" msgid "Log Level"
msgstr "日志等级" msgstr "日志等级"
@@ -2175,8 +2169,8 @@ msgstr "调整分组"
msgid "Reassign Node Group" msgid "Reassign Node Group"
msgstr "调整节点分组" msgstr "调整节点分组"
msgid "Currently using %s node" msgid "Currently using node"
msgstr "当前使用的 %s 节点" msgstr "当前使用的节点"
msgid "Search nodes..." msgid "Search nodes..."
msgstr "搜索节点…" msgstr "搜索节点…"
@@ -69,6 +69,31 @@ for sid in $(uci show passwall | grep "@subscribe_list" | cut -d '.' -sf 2 | cut
unset sid new_id unset sid new_id
done done
migrate_option() {
local section="$1"
local old="$2"
local new="$3"
local prefix="passwall.${section}"
if uci -q show "${prefix}.${new}" >/dev/null; then
uci -q delete "${prefix}.${old}"
elif uci -q show "${prefix}.${old}" >/dev/null; then
uci -q set "${prefix}.${new}=$(uci -q get "${prefix}.${old}")"
uci -q delete "${prefix}.${old}"
fi
}
migrate_option "@global[0]" tcp_node node
uci -q delete "passwall.@global[0].udp_node"
migrate_option "@global[0]" tcp_node_socks_port node_socks_port
migrate_option "@global[0]" tcp_node_socks_bind_local node_socks_bind_local
migrate_option "@global[0]" log_tcp log_node
uci -q delete "passwall.@global[0].log_udp"
for sid in $(uci show passwall | grep "=acl_rule" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do
migrate_option "${sid}" tcp_node node
uci -q delete "passwall.${sid}.udp_node"
done
uci -q commit passwall uci -q commit passwall
sed -i "s#add_from#group#g" /etc/config/passwall 2>/dev/null sed -i "s#add_from#group#g" /etc/config/passwall 2>/dev/null
@@ -2,7 +2,7 @@
config global config global
option enabled '0' option enabled '0'
option socks_enabled '0' option socks_enabled '0'
option tcp_node_socks_port '1070' option node_socks_port '1070'
option filter_proxy_ipv6 '1' option filter_proxy_ipv6 '1'
option dns_shunt 'chinadns-ng' option dns_shunt 'chinadns-ng'
option dns_mode 'tcp' option dns_mode 'tcp'
@@ -21,8 +21,7 @@ config global
option localhost_proxy '1' option localhost_proxy '1'
option client_proxy '1' option client_proxy '1'
option acl_enable '0' option acl_enable '0'
option log_tcp '0' option log_node '0'
option log_udp '0'
option loglevel 'error' option loglevel 'error'
option log_chinadns_ng '0' option log_chinadns_ng '0'
+159 -415
View File
@@ -72,32 +72,20 @@ check_run_environment() {
} }
run_ipt2socks() { run_ipt2socks() {
local flag proto tcp_tproxy local_port socks_address socks_port socks_username socks_password log_file local flag tcp_tproxy local_port socks_address socks_port socks_username socks_password log_file
local _extra_param="" local _extra_param=""
eval_set_val "$@" eval_set_val "$@"
[ -n "$log_file" ] || log_file="/dev/null" [ -n "$log_file" ] || log_file="/dev/null"
socks_address=$(get_host_ip "ipv4" ${socks_address}) socks_address=$(get_host_ip "ipv4" ${socks_address})
[ -n "$socks_username" ] && [ -n "$socks_password" ] && _extra_param="${_extra_param} -a $socks_username -k $socks_password" [ -n "$socks_username" ] && [ -n "$socks_password" ] && _extra_param="${_extra_param} -a $socks_username -k $socks_password"
[ -n "$tcp_tproxy" ] || _extra_param="${_extra_param} -R" [ -n "$tcp_tproxy" ] || _extra_param="${_extra_param} -R"
case "$proto" in
UDP)
flag="${flag}_UDP"
_extra_param="${_extra_param} -U"
;;
TCP)
flag="${flag}_TCP"
_extra_param="${_extra_param} -T"
;;
*)
flag="${flag}_TCP_UDP" flag="${flag}_TCP_UDP"
;;
esac
_extra_param="${_extra_param} -o 60 -n 65535 -v" _extra_param="${_extra_param} -o 60 -n 65535 -v"
ln_run "$(first_type ipt2socks)" "ipt2socks_${flag}" $log_file -l $local_port -b 0.0.0.0 -s $socks_address -p $socks_port ${_extra_param} ln_run "$(first_type ipt2socks)" "ipt2socks_${flag}" $log_file -l $local_port -b 0.0.0.0 -s $socks_address -p $socks_port ${_extra_param}
} }
run_singbox() { run_singbox() {
local flag type node tcp_redir_port tcp_proxy_way udp_redir_port socks_address socks_port socks_username socks_password http_address http_port http_username http_password local flag type node redir_port tcp_proxy_way socks_address socks_port socks_username socks_password http_address http_port http_username http_password
local dns_listen_port direct_dns_query_strategy direct_dns_port direct_dns_udp_server direct_dns_tcp_server remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_dns_client_ip remote_fakedns remote_dns_query_strategy remote_rewrite_ttl dns_cache dns_socks_address dns_socks_port local dns_listen_port direct_dns_query_strategy direct_dns_port direct_dns_udp_server direct_dns_tcp_server remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_dns_client_ip remote_fakedns remote_dns_query_strategy remote_rewrite_ttl dns_cache dns_socks_address dns_socks_port
local loglevel log_file config_file server_host server_port no_run use_proxy_list use_gfw_list chn_list local loglevel log_file config_file server_host server_port no_run use_proxy_list use_gfw_list chn_list
eval_set_val "$@" eval_set_val "$@"
@@ -124,9 +112,8 @@ run_singbox() {
[ -n "$chn_list" ] && json_add_string "chn_list" "$chn_list" [ -n "$chn_list" ] && json_add_string "chn_list" "$chn_list"
[ -n "$server_host" ] && json_add_string "server_host" "$server_host" [ -n "$server_host" ] && json_add_string "server_host" "$server_host"
[ -n "$server_port" ] && json_add_string "server_port" "$server_port" [ -n "$server_port" ] && json_add_string "server_port" "$server_port"
[ -n "$tcp_redir_port" ] && json_add_string "tcp_redir_port" "$tcp_redir_port" [ -n "$redir_port" ] && json_add_string "redir_port" "$redir_port"
[ -n "$tcp_proxy_way" ] && json_add_string "tcp_proxy_way" "$tcp_proxy_way" [ -n "$tcp_proxy_way" ] && json_add_string "tcp_proxy_way" "$tcp_proxy_way"
[ -n "$udp_redir_port" ] && json_add_string "udp_redir_port" "$udp_redir_port"
[ -n "$socks_address" ] && json_add_string "local_socks_address" "$socks_address" [ -n "$socks_address" ] && json_add_string "local_socks_address" "$socks_address"
[ -n "$socks_port" ] && json_add_string "local_socks_port" "$socks_port" [ -n "$socks_port" ] && json_add_string "local_socks_port" "$socks_port"
[ -n "$socks_username" ] && [ -n "$socks_password" ] && { [ -n "$socks_username" ] && [ -n "$socks_password" ] && {
@@ -198,7 +185,7 @@ run_singbox() {
} }
run_xray() { run_xray() {
local flag type node tcp_redir_port tcp_proxy_way udp_redir_port socks_address socks_port socks_username socks_password http_address http_port http_username http_password local flag type node redir_port tcp_proxy_way socks_address socks_port socks_username socks_password http_address http_port http_username http_password
local dns_listen_port direct_dns_query_strategy direct_dns_port direct_dns_udp_server direct_dns_tcp_server remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_dns_client_ip remote_fakedns remote_dns_query_strategy dns_cache dns_socks_address dns_socks_port local dns_listen_port direct_dns_query_strategy direct_dns_port direct_dns_udp_server direct_dns_tcp_server remote_dns_protocol remote_dns_udp_server remote_dns_tcp_server remote_dns_doh remote_dns_client_ip remote_fakedns remote_dns_query_strategy dns_cache dns_socks_address dns_socks_port
local loglevel log_file config_file server_host server_port no_run use_proxy_list use_gfw_list chn_list local loglevel log_file config_file server_host server_port no_run use_proxy_list use_gfw_list chn_list
eval_set_val "$@" eval_set_val "$@"
@@ -217,9 +204,8 @@ run_xray() {
[ -n "$chn_list" ] && json_add_string "chn_list" "$chn_list" [ -n "$chn_list" ] && json_add_string "chn_list" "$chn_list"
[ -n "$server_host" ] && json_add_string "server_host" "$server_host" [ -n "$server_host" ] && json_add_string "server_host" "$server_host"
[ -n "$server_port" ] && json_add_string "server_port" "$server_port" [ -n "$server_port" ] && json_add_string "server_port" "$server_port"
[ -n "$tcp_redir_port" ] && json_add_string "tcp_redir_port" "$tcp_redir_port" [ -n "$redir_port" ] && json_add_string "redir_port" "$redir_port"
[ -n "$tcp_proxy_way" ] && json_add_string "tcp_proxy_way" "$tcp_proxy_way" [ -n "$tcp_proxy_way" ] && json_add_string "tcp_proxy_way" "$tcp_proxy_way"
[ -n "$udp_redir_port" ] && json_add_string "udp_redir_port" "$udp_redir_port"
[ -n "$socks_address" ] && json_add_string "local_socks_address" "$socks_address" [ -n "$socks_address" ] && json_add_string "local_socks_address" "$socks_address"
[ -n "$socks_port" ] && json_add_string "local_socks_port" "$socks_port" [ -n "$socks_port" ] && json_add_string "local_socks_port" "$socks_port"
[ -n "$socks_username" ] && [ -n "$socks_password" ] && { [ -n "$socks_username" ] && [ -n "$socks_password" ] && {
@@ -309,7 +295,7 @@ run_dns2socks() {
} }
run_chinadns_ng() { run_chinadns_ng() {
local _flag _listen_port _dns_local _dns_trust _no_ipv6_trust _use_direct_list _use_proxy_list _gfwlist _chnlist _default_mode _default_tag _no_logic_log _tcp_node _filter_https _log local _flag _listen_port _dns_local _dns_trust _no_ipv6_trust _use_direct_list _use_proxy_list _gfwlist _chnlist _default_mode _default_tag _no_logic_log _node _filter_https _log
local _extra_param="" local _extra_param=""
eval_set_val "$@" eval_set_val "$@"
@@ -317,7 +303,7 @@ run_chinadns_ng() {
local _LOG_FILE="/dev/null" local _LOG_FILE="/dev/null"
[ "${_log}" = "1" ] && _LOG_FILE=$TMP_ACL_PATH/$_flag/chinadns_ng.log [ "${_log}" = "1" ] && _LOG_FILE=$TMP_ACL_PATH/$_flag/chinadns_ng.log
_extra_param="-FLAG ${_flag} -TCP_NODE ${_tcp_node} -LISTEN_PORT ${_listen_port} -DNS_LOCAL ${_dns_local} -DNS_TRUST ${_dns_trust}" _extra_param="-FLAG ${_flag} -NODE ${_node} -LISTEN_PORT ${_listen_port} -DNS_LOCAL ${_dns_local} -DNS_TRUST ${_dns_trust}"
_extra_param="${_extra_param} -USE_DIRECT_LIST ${_use_direct_list} -USE_PROXY_LIST ${_use_proxy_list} -USE_BLOCK_LIST ${_use_block_list}" _extra_param="${_extra_param} -USE_DIRECT_LIST ${_use_direct_list} -USE_PROXY_LIST ${_use_proxy_list} -USE_BLOCK_LIST ${_use_block_list}"
_extra_param="${_extra_param} -GFWLIST ${_gfwlist} -CHNLIST ${_chnlist} -NO_IPV6_TRUST ${_no_ipv6_trust} -DEFAULT_MODE ${_default_mode}" _extra_param="${_extra_param} -GFWLIST ${_gfwlist} -CHNLIST ${_chnlist} -NO_IPV6_TRUST ${_no_ipv6_trust} -DEFAULT_MODE ${_default_mode}"
_extra_param="${_extra_param} -DEFAULT_TAG ${_default_tag} -NFTFLAG ${nftflag} -NO_LOGIC_LOG ${_no_logic_log}" _extra_param="${_extra_param} -DEFAULT_TAG ${_default_tag} -NFTFLAG ${nftflag} -NO_LOGIC_LOG ${_no_logic_log}"
@@ -531,29 +517,22 @@ run_socks() {
[ -z "$no_run" ] && [ "${server_host}" != "127.0.0.1" ] && [ "$type" != "sing-box" ] && [ "$type" != "xray" ] && echo "${node}" >> $TMP_PATH/direct_node_list [ -z "$no_run" ] && [ "${server_host}" != "127.0.0.1" ] && [ "$type" != "sing-box" ] && [ "$type" != "xray" ] && echo "${node}" >> $TMP_PATH/direct_node_list
} }
run_redir() { start_global() {
local node proto bind local_port config_file log_file [ -z "$NODE" ] && return 1
eval_set_val "$@" local type=$(echo $(config_n_get $NODE type) | tr 'A-Z' 'a-z')
local tcp_node_socks_flag tcp_node_http_flag [ -z "$type" ] && return 1
[ -n "$config_file" ] && [ -z "$(echo ${config_file} | grep $TMP_PATH)" ] && config_file=${GLOBAL_ACL_PATH}/${config_file}
if [ -n "$log_file" ] && [ "$log_file" != "/dev/null" ] && [ -z "$(echo ${log_file} | grep $TMP_PATH)" ]; then
log_file=${GLOBAL_ACL_PATH}/${log_file}
else
log_file="/dev/null"
fi
local proto=$(echo $proto | tr 'A-Z' 'a-z')
local PROTO=$(echo $proto | tr 'a-z' 'A-Z')
local config_file=${GLOBAL_ACL_PATH}/global.json
local log_file=${GLOBAL_ACL_PATH}/global.log
local node2socks_port=0 local node2socks_port=0
local type remarks server_host port local remarks server_host port
if [ "$(config_get_type $node)" = "socks" ]; then if [ "$(config_get_type $NODE)" = "socks" ]; then
node2socks_port=$(config_n_get $node port 0) node2socks_port=$(config_n_get $NODE port 0)
fi fi
if [ "$node2socks_port" = "0" ]; then if [ "$node2socks_port" = "0" ]; then
type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z') remarks=$(config_n_get $NODE remarks)
remarks=$(config_n_get $node remarks) server_host=$(config_n_get $NODE address)
server_host=$(config_n_get $node address) port=$(config_n_get $NODE port)
port=$(config_n_get $node port)
else else
if [ "${DNS_MODE}" = "xray" ]; then if [ "${DNS_MODE}" = "xray" ]; then
type="xray" type="xray"
@@ -566,94 +545,30 @@ run_redir() {
port=$node2socks_port port=$node2socks_port
remarks="Socks 配置($port 端口)" remarks="Socks 配置($port 端口)"
fi fi
local enable_log=$(config_t_get global log_node 1)
local enable_log=$(config_t_get global log_${proto} 1)
[ "$enable_log" != "1" ] && log_file="/dev/null" [ "$enable_log" != "1" ] && log_file="/dev/null"
[ -n "$server_host" ] && [ -n "$port" ] && { [ -n "$server_host" ] && [ -n "$port" ] && {
check_host $server_host check_host $server_host
[ $? != 0 ] && { [ $? != 0 ] && {
echolog "${PROTO}节点:[$remarks]${server_host} 是非法的服务器地址,无法启动!" echolog "全局节点:[$remarks]${server_host} 是非法的服务器地址,无法启动!"
return 1 return 1
} }
} }
[ "$bind" != "127.0.0.1" ] && echolog "${PROTO}节点:[$remarks],监听端口:$local_port" echolog "全局节点:[$remarks],监听端口:$REDIR_PORT"
local on_node_socks=1
json_init local node_socks_bind_local=$(config_t_get global node_socks_bind_local 1)
json_add_string "node" "${node}" local node_socks_bind="127.0.0.1"
case "$PROTO" in [ "${node_socks_bind_local}" != "1" ] && node_socks_bind="0.0.0.0"
UDP) local global_socks_port=$(config_t_get global node_socks_port 1070)
case "$type" in GLOBAL_SOCKS_port=$(get_new_port $global_socks_port)
socks) if [ "$GLOBAL_SOCKS_port" != "$global_socks_port" ]; then
local _socks_address _socks_port _socks_username _socks_password echolog "注意:全局节点 Socks 端口冲突,原端口 ${global_socks_port} 已自动更改为 ${GLOBAL_SOCKS_port}"
if [ "$node2socks_port" = "0" ]; then
_socks_address=$(config_n_get $node address)
_socks_port=$(config_n_get $node port)
_socks_username=$(config_n_get $node username)
_socks_password=$(config_n_get $node password)
else
_socks_address="127.0.0.1"
_socks_port=$node2socks_port
fi fi
run_ipt2socks flag=default proto=UDP local_port=${local_port} socks_address=${_socks_address} socks_port=${_socks_port} socks_username=${_socks_username} socks_password=${_socks_password} log_file=${log_file} GLOBAL_HTTP_port=$(config_t_get global node_http_port 0)
;; [ "$GLOBAL_HTTP_port" != "0" ] && local on_node_http=1
sing-box)
local protocol=$(config_n_get $node protocol)
[ "$protocol" = "_shunt" ] && {
local geoip_path="${V2RAY_LOCATION_ASSET%*/}/geoip.dat"
local geosite_path="${V2RAY_LOCATION_ASSET%*/}/geosite.dat"
if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then
echolog "* 缺少Geo规则文件,UDP Sing-Box分流节点无法正常使用!"
fi
}
run_singbox flag=UDP node=$node udp_redir_port=$local_port config_file=$config_file log_file=$log_file
;;
xray)
local protocol=$(config_n_get $node protocol)
[ "$protocol" = "_shunt" ] && {
local geoip_path="${V2RAY_LOCATION_ASSET%*/}/geoip.dat"
local geosite_path="${V2RAY_LOCATION_ASSET%*/}/geosite.dat"
if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then
echolog "* 缺少Geo规则文件,UDP Xray分流节点无法正常使用!"
fi
}
run_xray flag=UDP node=$node udp_redir_port=$local_port config_file=$config_file log_file=$log_file
;;
naiveproxy)
echolog "Naiveproxy不支持UDP转发!"
;;
ssr)
json_add_string "local_addr" "0.0.0.0"
json_add_string "local_port" "$local_port"
lua $UTIL_SS gen_config "$(json_dump)" > $config_file
ln_run "$(first_type ssr-redir)" "ssr-redir" $log_file -c "$config_file" -v -U
;;
ss-rust)
local plugin_sh="${config_file%.json}_plugin.sh"
json_add_string "plugin_sh" "$plugin_sh"
json_add_string "local_udp_redir_port" "$local_port"
lua $UTIL_SS gen_config "$(json_dump)" > $config_file
ln_run "$(first_type sslocal)" "sslocal" $log_file -c "$config_file" -v
;;
hysteria2)
json_add_string "local_udp_redir_port" "$local_port"
lua $UTIL_HYSTERIA2 gen_config "$(json_dump)" > $config_file
ln_run "$(first_type $(config_t_get global_app hysteria_file))" "hysteria" $log_file -c "$config_file" client
;;
esac
;;
TCP)
[ "$TCP_UDP" = "1" ] && echolog "UDP节点:与TCP节点相同"
tcp_node_socks=1
tcp_node_socks_bind_local=$(config_t_get global tcp_node_socks_bind_local 1)
tcp_node_socks_bind="127.0.0.1"
[ "${tcp_node_socks_bind_local}" != "1" ] && tcp_node_socks_bind="0.0.0.0"
tcp_node_socks_port=$(get_new_port $(config_t_get global tcp_node_socks_port 1070))
tcp_node_http_port=$(config_t_get global tcp_node_http_port 0)
[ "$tcp_node_http_port" != "0" ] && tcp_node_http=1
if [ $PROXY_IPV6 = "1" ]; then if [ $PROXY_IPV6 = "1" ]; then
echolog "开启实验性IPv6透明代理(TProxy),请确认您的节点及类型支持IPv6!" echolog "开启实验性IPv6透明代理(TProxy),请确认您的节点及类型支持IPv6!"
fi fi
if [ "${TCP_PROXY_WAY}" = "redirect" ]; then if [ "${TCP_PROXY_WAY}" = "redirect" ]; then
can_ipt=$(echo "$REDIRECT_LIST" | grep "$type") can_ipt=$(echo "$REDIRECT_LIST" | grep "$type")
elif [ "${TCP_PROXY_WAY}" = "tproxy" ]; then elif [ "${TCP_PROXY_WAY}" = "tproxy" ]; then
@@ -661,51 +576,46 @@ run_redir() {
fi fi
[ -z "$can_ipt" ] && type="socks" [ -z "$can_ipt" ] && type="socks"
json_init
json_add_string "node" "$NODE"
local _socks_flag node_socks_flag node_http_flag _socks_address _socks_port _socks_username _socks_password
case "$type" in case "$type" in
socks) socks)
_socks_flag=1 _socks_flag=1
if [ "$node2socks_port" = "0" ]; then if [ "$node2socks_port" = "0" ]; then
_socks_address=$(config_n_get $node address) _socks_address=$(config_n_get $NODE address)
_socks_port=$(config_n_get $node port) _socks_port=$(config_n_get $NODE port)
_socks_username=$(config_n_get $node username) _socks_username=$(config_n_get $NODE username)
_socks_password=$(config_n_get $node password) _socks_password=$(config_n_get $NODE password)
else else
_socks_address="127.0.0.1" _socks_address="127.0.0.1"
_socks_port=$node2socks_port _socks_port=$node2socks_port
fi fi
[ -z "$can_ipt" ] && { [ -z "$can_ipt" ] && {
local _config_file=$config_file local _config_file=$config_file
_config_file="TCP_SOCKS_${node}.json" _config_file="Global_SOCKS_${NODE}.json"
local _port=$(get_new_port 3001) local _port=$(get_new_port 3001)
run_socks flag="TCP" node=$node bind=127.0.0.1 socks_port=${_port} config_file=${_config_file} run_socks flag="global" node=$NODE bind=127.0.0.1 socks_port=${_port} config_file=${_config_file}
_socks_address=127.0.0.1 _socks_address="127.0.0.1"
_socks_port=${_port} _socks_port=${_port}
unset _socks_username unset _socks_username
unset _socks_password unset _socks_password
} }
;; ;;
sing-box) sing-box)
local _flag="TCP" local _flag="global"
local _args="" local _args=""
[ "$tcp_node_socks" = "1" ] && { [ "$on_node_socks" = "1" ] && {
tcp_node_socks_flag=1 node_socks_flag=1
_args="${_args} socks_address=${tcp_node_socks_bind} socks_port=${tcp_node_socks_port}" _args="${_args} socks_address=${node_socks_bind} socks_port=${GLOBAL_SOCKS_port}"
config_file="${config_file//TCP/TCP_SOCKS}"
} }
[ "$tcp_node_http" = "1" ] && { [ "$on_node_http" = "1" ] && {
tcp_node_http_flag=1 node_http_flag=1
_args="${_args} http_port=${tcp_node_http_port}" _args="${_args} http_port=${GLOBAL_HTTP_port}"
config_file="${config_file//TCP/TCP_HTTP}"
}
[ "$TCP_UDP" = "1" ] && {
UDP_REDIR_PORT=$local_port
unset UDP_NODE
_flag="TCP_UDP"
_args="${_args} udp_redir_port=${UDP_REDIR_PORT}"
config_file="${config_file//TCP/TCP_UDP}"
} }
local protocol=$(config_n_get $node protocol) local protocol=$(config_n_get $NODE protocol)
local v2ray_dns_mode=$(config_t_get global v2ray_dns_mode tcp) local v2ray_dns_mode=$(config_t_get global v2ray_dns_mode tcp)
[ "${DNS_MODE}" != "sing-box" ] && [ "$protocol" = "_shunt" ] && { [ "${DNS_MODE}" != "sing-box" ] && [ "$protocol" = "_shunt" ] && {
DNS_MODE="sing-box" DNS_MODE="sing-box"
@@ -718,7 +628,7 @@ run_redir() {
if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then
echolog "* 缺少Geo规则文件,TCP Sing-Box分流节点无法正常使用!" echolog "* 缺少Geo规则文件,TCP Sing-Box分流节点无法正常使用!"
fi fi
[ "$(config_n_get $node fakedns)" = "1" ] && { [ "$(config_n_get $NODE fakedns)" = "1" ] && {
USE_FAKEDNS=1 USE_FAKEDNS=1
GLOBAL_SHUNT_NODE_FAKEDNS=1 GLOBAL_SHUNT_NODE_FAKEDNS=1
} }
@@ -726,7 +636,6 @@ run_redir() {
[ "${DNS_MODE}" = "sing-box" ] && { [ "${DNS_MODE}" = "sing-box" ] && {
NO_PLUGIN_DNS=1 NO_PLUGIN_DNS=1
config_file="${config_file//.json/_DNS.json}"
_args="${_args} remote_dns_query_strategy=${REMOTE_DNS_QUERY_STRATEGY}" _args="${_args} remote_dns_query_strategy=${REMOTE_DNS_QUERY_STRATEGY}"
DNSMASQ_FILTER_PROXY_IPV6=0 DNSMASQ_FILTER_PROXY_IPV6=0
local _remote_dns_client_ip=$(config_t_get global remote_dns_client_ip) local _remote_dns_client_ip=$(config_t_get global remote_dns_client_ip)
@@ -768,37 +677,26 @@ run_redir() {
NEXT_DNS_LISTEN_PORT=$(expr $NEXT_DNS_LISTEN_PORT + 1) NEXT_DNS_LISTEN_PORT=$(expr $NEXT_DNS_LISTEN_PORT + 1)
} }
_args="${_args} use_proxy_list=$USE_PROXY_LIST use_gfw_list=$USE_GFW_LIST chn_list=$CHN_LIST" _args="${_args} use_proxy_list=$USE_PROXY_LIST use_gfw_list=$USE_GFW_LIST chn_list=$CHN_LIST"
run_singbox flag=$_flag node=$node tcp_redir_port=$local_port tcp_proxy_way=$TCP_PROXY_WAY config_file=$config_file log_file=$log_file ${_args} run_singbox flag=$_flag node=$NODE redir_port=$REDIR_PORT tcp_proxy_way=$TCP_PROXY_WAY config_file=$config_file log_file=$log_file ${_args}
;; ;;
xray) xray)
local _flag="TCP" local _flag="global"
local _args="" local _args=""
[ "$tcp_node_socks" = "1" ] && { [ "$on_node_socks" = "1" ] && {
tcp_node_socks_flag=1 node_socks_flag=1
_args="${_args} socks_address=${tcp_node_socks_bind} socks_port=${tcp_node_socks_port}" _args="${_args} socks_address=${node_socks_bind} socks_port=${GLOBAL_SOCKS_port}"
config_file="${config_file//TCP/TCP_SOCKS}"
} }
[ "$tcp_node_http" = "1" ] && { [ "$on_node_http" = "1" ] && {
tcp_node_http_flag=1 node_http_flag=1
_args="${_args} http_port=${tcp_node_http_port}" _args="${_args} http_port=${GLOBAL_HTTP_port}"
config_file="${config_file//TCP/TCP_HTTP}"
}
[ "$TCP_UDP" = "1" ] && {
UDP_REDIR_PORT=$local_port
unset UDP_NODE
_flag="TCP_UDP"
_args="${_args} udp_redir_port=${UDP_REDIR_PORT}"
config_file="${config_file//TCP/TCP_UDP}"
} }
local protocol=$(config_n_get $node protocol) local protocol=$(config_n_get $NODE protocol)
local v2ray_dns_mode=$(config_t_get global v2ray_dns_mode tcp) local v2ray_dns_mode=$(config_t_get global v2ray_dns_mode tcp)
[ "${DNS_MODE}" != "xray" ] && [ "$protocol" = "_shunt" ] && { [ "${DNS_MODE}" != "xray" ] && [ "$protocol" = "_shunt" ] && {
DNS_MODE="xray" DNS_MODE="xray"
[ "$v2ray_dns_mode" = "http3" ] && v2ray_dns_mode="tcp" [ "$v2ray_dns_mode" = "http3" ] && v2ray_dns_mode="tcp"
} }
#兼容旧模式,择机移除
[ "$v2ray_dns_mode" = "tcp+doh" ] && v2ray_dns_mode="tcp"
[ "$protocol" = "_shunt" ] && { [ "$protocol" = "_shunt" ] && {
local geoip_path="${V2RAY_LOCATION_ASSET%*/}/geoip.dat" local geoip_path="${V2RAY_LOCATION_ASSET%*/}/geoip.dat"
@@ -806,7 +704,7 @@ run_redir() {
if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then if [ ! -s "$geoip_path" ] || [ ! -s "$geosite_path" ]; then
echolog "* 缺少Geo规则文件,TCP Xray分流节点无法正常使用!" echolog "* 缺少Geo规则文件,TCP Xray分流节点无法正常使用!"
fi fi
[ "$(config_n_get $node fakedns)" = "1" ] && { [ "$(config_n_get $NODE fakedns)" = "1" ] && {
USE_FAKEDNS=1 USE_FAKEDNS=1
GLOBAL_SHUNT_NODE_FAKEDNS=1 GLOBAL_SHUNT_NODE_FAKEDNS=1
} }
@@ -814,7 +712,6 @@ run_redir() {
[ "${DNS_MODE}" = "xray" ] && { [ "${DNS_MODE}" = "xray" ] && {
NO_PLUGIN_DNS=1 NO_PLUGIN_DNS=1
config_file="${config_file//.json/_DNS.json}"
_args="${_args} remote_dns_query_strategy=${REMOTE_DNS_QUERY_STRATEGY}" _args="${_args} remote_dns_query_strategy=${REMOTE_DNS_QUERY_STRATEGY}"
DNSMASQ_FILTER_PROXY_IPV6=0 DNSMASQ_FILTER_PROXY_IPV6=0
local _remote_dns_client_ip=$(config_t_get global remote_dns_client_ip) local _remote_dns_client_ip=$(config_t_get global remote_dns_client_ip)
@@ -855,48 +752,35 @@ run_redir() {
NEXT_DNS_LISTEN_PORT=$(expr $NEXT_DNS_LISTEN_PORT + 1) NEXT_DNS_LISTEN_PORT=$(expr $NEXT_DNS_LISTEN_PORT + 1)
} }
_args="${_args} use_proxy_list=$USE_PROXY_LIST use_gfw_list=$USE_GFW_LIST chn_list=$CHN_LIST" _args="${_args} use_proxy_list=$USE_PROXY_LIST use_gfw_list=$USE_GFW_LIST chn_list=$CHN_LIST"
run_xray flag=$_flag node=$node tcp_redir_port=$local_port tcp_proxy_way=$TCP_PROXY_WAY config_file=$config_file log_file=$log_file ${_args} run_xray flag=$_flag node=$NODE redir_port=$REDIR_PORT tcp_proxy_way=$TCP_PROXY_WAY config_file=$config_file log_file=$log_file ${_args}
;; ;;
naiveproxy) naiveproxy)
json_add_string "run_type" "redir" json_add_string "run_type" "redir"
json_add_string "local_addr" "0.0.0.0" json_add_string "local_addr" "0.0.0.0"
json_add_string "local_port" "$local_port" json_add_string "local_port" "$REDIR_PORT"
lua $UTIL_NAIVE gen_config "$(json_dump)" > $config_file lua $UTIL_NAIVE gen_config "$(json_dump)" > $config_file
ln_run "$(first_type naive)" naive $log_file "$config_file" ln_run "$(first_type naive)" naive $log_file "$config_file"
echolog "注意:Naiveproxy 不支持 UDP 转发!"
;; ;;
ssr) ssr)
[ "${TCP_PROXY_WAY}" = "tproxy" ] && json_add_string "tcp_tproxy" "true" [ "${TCP_PROXY_WAY}" = "tproxy" ] && json_add_string "tcp_tproxy" "true"
local _extra_param local _extra_param="-u"
[ "$TCP_UDP" = "1" ] && {
config_file="${config_file//TCP/TCP_UDP}"
UDP_REDIR_PORT=$TCP_REDIR_PORT
unset UDP_NODE
_extra_param="-u"
}
json_add_string "local_addr" "0.0.0.0" json_add_string "local_addr" "0.0.0.0"
json_add_string "local_port" "$local_port" json_add_string "local_port" "$REDIR_PORT"
lua $UTIL_SS gen_config "$(json_dump)" > $config_file lua $UTIL_SS gen_config "$(json_dump)" > $config_file
ln_run "$(first_type ssr-redir)" "ssr-redir" $log_file -c "$config_file" -v ${_extra_param} ln_run "$(first_type ssr-redir)" "ssr-redir" $log_file -c "$config_file" -v ${_extra_param}
;; ;;
ss-rust) ss-rust)
json_add_string "local_tcp_redir_port" "$local_port" json_add_string "local_redir_port" "$REDIR_PORT"
[ "${TCP_PROXY_WAY}" = "tproxy" ] && json_add_string "tcp_tproxy" "true" [ "${TCP_PROXY_WAY}" = "tproxy" ] && json_add_string "tcp_tproxy" "true"
[ "$tcp_node_socks" = "1" ] && { [ "$on_node_socks" = "1" ] && {
tcp_node_socks_flag=1 node_socks_flag=1
config_file="${config_file//TCP/TCP_SOCKS}" json_add_string "local_socks_address" "${node_socks_bind}"
json_add_string "local_socks_address" "${tcp_node_socks_bind}" json_add_string "local_socks_port" "${GLOBAL_SOCKS_port}"
json_add_string "local_socks_port" "${tcp_node_socks_port}"
} }
[ "$tcp_node_http" = "1" ] && { [ "$on_node_http" = "1" ] && {
tcp_node_http_flag=1 node_http_flag=1
config_file="${config_file//TCP/TCP_HTTP}" json_add_string "local_http_port" "${GLOBAL_HTTP_port}"
json_add_string "local_http_port" "${tcp_node_http_port}"
}
[ "$TCP_UDP" = "1" ] && {
config_file="${config_file//TCP/TCP_UDP}"
UDP_REDIR_PORT=$TCP_REDIR_PORT
unset UDP_NODE
json_add_string "local_udp_redir_port" "$local_port"
} }
local plugin_sh="${config_file%.json}_plugin.sh" local plugin_sh="${config_file%.json}_plugin.sh"
json_add_string "plugin_sh" "$plugin_sh" json_add_string "plugin_sh" "$plugin_sh"
@@ -904,23 +788,15 @@ run_redir() {
ln_run "$(first_type sslocal)" "sslocal" $log_file -c "$config_file" -v ln_run "$(first_type sslocal)" "sslocal" $log_file -c "$config_file" -v
;; ;;
hysteria2) hysteria2)
json_add_string "local_tcp_redir_port" "$local_port" json_add_string "local_redir_port" "$REDIR_PORT"
[ "$tcp_node_socks" = "1" ] && { [ "$on_node_socks" = "1" ] && {
tcp_node_socks_flag=1 node_socks_flag=1
config_file="${config_file//TCP/TCP_SOCKS}" json_add_string "local_socks_address" "${node_socks_bind}"
json_add_string "local_socks_address" "${tcp_node_socks_bind}" json_add_string "local_socks_port" "${GLOBAL_SOCKS_port}"
json_add_string "local_socks_port" "${tcp_node_socks_port}"
} }
[ "$tcp_node_http" = "1" ] && { [ "$on_node_http" = "1" ] && {
tcp_node_http_flag=1 node_http_flag=1
config_file="${config_file//TCP/TCP_HTTP}" json_add_string "local_http_port" "${GLOBAL_HTTP_port}"
json_add_string "local_http_port" "${tcp_node_http_port}"
}
[ "$TCP_UDP" = "1" ] && {
config_file="${config_file//TCP/TCP_UDP}"
UDP_REDIR_PORT=$TCP_REDIR_PORT
unset UDP_NODE
json_add_string "local_udp_redir_port" "$local_port"
} }
json_add_string "tcp_proxy_way" "${TCP_PROXY_WAY}" json_add_string "tcp_proxy_way" "${TCP_PROXY_WAY}"
lua $UTIL_HYSTERIA2 gen_config "$(json_dump)" > $config_file lua $UTIL_HYSTERIA2 gen_config "$(json_dump)" > $config_file
@@ -928,62 +804,32 @@ run_redir() {
;; ;;
esac esac
if [ -n "${_socks_flag}" ]; then if [ -n "${_socks_flag}" ]; then
local _flag="TCP"
[ "$TCP_UDP" = "1" ] && {
_flag="TCP_UDP"
UDP_REDIR_PORT=$TCP_REDIR_PORT
unset UDP_NODE
}
local _socks_tproxy="" local _socks_tproxy=""
[ "${TCP_PROXY_WAY}" = "tproxy" ] && _socks_tproxy="1" [ "${TCP_PROXY_WAY}" = "tproxy" ] && _socks_tproxy="1"
run_ipt2socks flag=default proto=${_flag} tcp_tproxy=${_socks_tproxy} local_port=${local_port} socks_address=${_socks_address} socks_port=${_socks_port} socks_username=${_socks_username} socks_password=${_socks_password} log_file=${log_file} run_ipt2socks flag=default tcp_tproxy=${_socks_tproxy} local_port=${REDIR_PORT} socks_address=${_socks_address} socks_port=${_socks_port} socks_username=${_socks_username} socks_password=${_socks_password} log_file=${log_file}
fi fi
[ -z "$tcp_node_socks_flag" ] && { [ -z "$node_socks_flag" ] && {
[ "$tcp_node_socks" = "1" ] && { [ "$on_node_socks" = "1" ] && {
local config_file="SOCKS_TCP.json" local config_file=${GLOBAL_ACL_PATH}/global_socks.json
local log_file="SOCKS_TCP.log" local log_file=${GLOBAL_ACL_PATH}/global_socks.log
local http_port=0 local http_port=0
local http_config_file="HTTP2SOCKS_TCP.json" local http_config_file=${GLOBAL_ACL_PATH}/global_socks_http.json
[ "$tcp_node_http" = "1" ] && [ -z "$tcp_node_http_flag" ] && { [ "$on_node_http" = "1" ] && [ -z "$node_http_flag" ] && {
http_port=$tcp_node_http_port http_port=$GLOBAL_HTTP_port
} }
run_socks flag=TCP node=$node bind=$tcp_node_socks_bind socks_port=$tcp_node_socks_port config_file=$config_file http_port=$http_port http_config_file=$http_config_file run_socks flag=TCP node=$NODE bind=$node_socks_bind socks_port=$GLOBAL_SOCKS_port config_file=$config_file http_port=$http_port http_config_file=$http_config_file
} }
} }
[ "$tcp_node_socks" = "1" ] && { [ "$on_node_socks" = "1" ] && {
TCP_SOCKS_server="127.0.0.1:$tcp_node_socks_port" GLOBAL_SOCKS_server="127.0.0.1:$GLOBAL_SOCKS_port"
set_cache_var "GLOBAL_TCP_SOCKS_server" "${TCP_SOCKS_server}" set_cache_var "GLOBAL_SOCKS_server" "${GLOBAL_SOCKS_server}"
} }
;; [ "$type" != "sing-box" ] && [ "$type" != "xray" ] && echo "${NODE}" >> $TMP_PATH/direct_node_list
esac set_cache_var "node_${NODE}_redir_port" "$REDIR_PORT"
unset tcp_node_socks_flag tcp_node_http_flag set_cache_var "ACL_GLOBAL_node" "$NODE"
[ "$type" != "sing-box" ] && [ "$type" != "xray" ] && echo "${node}" >> $TMP_PATH/direct_node_list set_cache_var "ACL_GLOBAL_redir_port" "$REDIR_PORT"
[ -n "${redir_port}" ] && set_cache_var "node_${node}_${PROTO}_redir_port" "${local_port}"
}
start_redir() {
local proto=${1}
eval node=\$${proto}_NODE
if [ -n "$node" ]; then
TYPE=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
local config_file="${proto}.json"
local log_file="${proto}.log"
eval current_port=\$${proto}_REDIR_PORT
local port=$(echo $(get_new_port $current_port $proto))
eval ${proto}_REDIR_PORT=$port
run_redir node=$node proto=${proto} bind=0.0.0.0 local_port=$port config_file=$config_file log_file=$log_file
set_cache_var "ACL_GLOBAL_${proto}_node" "${node}"
set_cache_var "ACL_GLOBAL_${proto}_redir_port" "${port}"
[ "$TCP_UDP" = "1" ] && {
set_cache_var "ACL_GLOBAL_UDP_node" "${node}"
set_cache_var "ACL_GLOBAL_UDP_redir_port" "${port}"
}
else
[ "${proto}" = "UDP" ] && [ "$TCP_UDP" = "1" ] && return
echolog "${proto}节点没有选择或为空,不代理${proto}"
fi
} }
start_socks() { start_socks() {
@@ -1262,8 +1108,8 @@ start_dns() {
;; ;;
sing-box) sing-box)
[ -z "${NO_PLUGIN_DNS}" ] && { [ -z "${NO_PLUGIN_DNS}" ] && {
local config_file=$TMP_PATH/DNS.json local config_file=${GLOBAL_ACL_PATH}/DNS.json
local log_file=$TMP_PATH/DNS.log # local log_file=${GLOBAL_ACL_PATH}/DNS.log
local log_file=/dev/null local log_file=/dev/null
local _args="type=$DNS_MODE config_file=$config_file log_file=$log_file" local _args="type=$DNS_MODE config_file=$config_file log_file=$log_file"
[ "${DNS_CACHE}" = "0" ] && _args="${_args} dns_cache=0" [ "${DNS_CACHE}" = "0" ] && _args="${_args} dns_cache=0"
@@ -1295,15 +1141,15 @@ start_dns() {
echolog " - Sing-Box DNS(${TUN_DNS}) -> ${remote_dns_doh}" echolog " - Sing-Box DNS(${TUN_DNS}) -> ${remote_dns_doh}"
;; ;;
esac esac
_args="${_args} dns_socks_address=127.0.0.1 dns_socks_port=${tcp_node_socks_port}" _args="${_args} dns_socks_address=127.0.0.1 dns_socks_port=${GLOBAL_SOCKS_port}"
[ -n "${sing_box_local_dns}" ] && _args="${_args} ${sing_box_local_dns}" [ -n "${sing_box_local_dns}" ] && _args="${_args} ${sing_box_local_dns}"
run_singbox ${_args} run_singbox ${_args}
} }
;; ;;
xray) xray)
[ -z "${NO_PLUGIN_DNS}" ] && { [ -z "${NO_PLUGIN_DNS}" ] && {
local config_file=$TMP_PATH/DNS.json local config_file=${GLOBAL_ACL_PATH}/DNS.json
local log_file=$TMP_PATH/DNS.log # local log_file=${GLOBAL_ACL_PATH}/DNS.log
local log_file=/dev/null local log_file=/dev/null
local _args="type=$DNS_MODE config_file=$config_file log_file=$log_file" local _args="type=$DNS_MODE config_file=$config_file log_file=$log_file"
[ "${DNS_CACHE}" = "0" ] && _args="${_args} dns_cache=0" [ "${DNS_CACHE}" = "0" ] && _args="${_args} dns_cache=0"
@@ -1320,8 +1166,6 @@ start_dns() {
[ -n "${_remote_dns_client_ip}" ] && _args="${_args} remote_dns_client_ip=${_remote_dns_client_ip}" [ -n "${_remote_dns_client_ip}" ] && _args="${_args} remote_dns_client_ip=${_remote_dns_client_ip}"
TCP_PROXY_DNS=1 TCP_PROXY_DNS=1
local v2ray_dns_mode=$(config_t_get global v2ray_dns_mode tcp) local v2ray_dns_mode=$(config_t_get global v2ray_dns_mode tcp)
#兼容旧模式,择机移除
[ "$v2ray_dns_mode" = "tcp+doh" ] && v2ray_dns_mode="tcp"
_args="${_args} dns_listen_port=${NEXT_DNS_LISTEN_PORT}" _args="${_args} dns_listen_port=${NEXT_DNS_LISTEN_PORT}"
_args="${_args} remote_dns_protocol=${v2ray_dns_mode}" _args="${_args} remote_dns_protocol=${v2ray_dns_mode}"
case "$v2ray_dns_mode" in case "$v2ray_dns_mode" in
@@ -1336,7 +1180,7 @@ start_dns() {
echolog " - Xray DNS(${TUN_DNS}) -> ${remote_dns_doh}" echolog " - Xray DNS(${TUN_DNS}) -> ${remote_dns_doh}"
;; ;;
esac esac
_args="${_args} dns_socks_address=127.0.0.1 dns_socks_port=${tcp_node_socks_port}" _args="${_args} dns_socks_address=127.0.0.1 dns_socks_port=${GLOBAL_SOCKS_port}"
run_xray ${_args} run_xray ${_args}
} }
;; ;;
@@ -1391,10 +1235,10 @@ start_dns() {
local subnet_ip=$(config_t_get global remote_dns_client_ip) local subnet_ip=$(config_t_get global remote_dns_client_ip)
lua $APP_PATH/helper_smartdns_add.lua -FLAG "default" -SMARTDNS_CONF "/tmp/etc/smartdns/$CONFIG.conf" \ lua $APP_PATH/helper_smartdns_add.lua -FLAG "default" -SMARTDNS_CONF "/tmp/etc/smartdns/$CONFIG.conf" \
-LISTEN_PORT ${SMARTDNS_LISTEN_PORT} -LOCAL_PORT ${SMARTDNS_LOCAL_PORT} \ -LISTEN_PORT ${SMARTDNS_LISTEN_PORT} -LOCAL_PORT ${SMARTDNS_LOCAL_PORT} \
-LOCAL_GROUP ${group_domestic:-null} -REMOTE_GROUP "passwall_proxy" -REMOTE_PROXY_SERVER ${TCP_SOCKS_server} -USE_DEFAULT_DNS "${USE_DEFAULT_DNS:-direct}" \ -LOCAL_GROUP ${group_domestic:-null} -REMOTE_GROUP "passwall_proxy" -REMOTE_PROXY_SERVER ${GLOBAL_SOCKS_server} -USE_DEFAULT_DNS "${USE_DEFAULT_DNS:-direct}" \
-REMOTE_DNS ${smartdns_remote_dns} -DNS_MODE ${DNS_MODE:-socks} -TUN_DNS ${TUN_DNS} \ -REMOTE_DNS ${smartdns_remote_dns} -DNS_MODE ${DNS_MODE:-socks} -TUN_DNS ${TUN_DNS} \
-USE_DIRECT_LIST "${USE_DIRECT_LIST}" -USE_PROXY_LIST "${USE_PROXY_LIST}" -USE_BLOCK_LIST "${USE_BLOCK_LIST}" -USE_GFW_LIST "${USE_GFW_LIST}" -CHN_LIST "${CHN_LIST}" \ -USE_DIRECT_LIST "${USE_DIRECT_LIST}" -USE_PROXY_LIST "${USE_PROXY_LIST}" -USE_BLOCK_LIST "${USE_BLOCK_LIST}" -USE_GFW_LIST "${USE_GFW_LIST}" -CHN_LIST "${CHN_LIST}" \
-TCP_NODE ${TCP_NODE} -DEFAULT_PROXY_MODE "${TCP_PROXY_MODE}" -NO_PROXY_IPV6 ${FILTER_PROXY_IPV6:-0} -NFTFLAG ${nftflag:-0} \ -NODE ${NODE} -DEFAULT_PROXY_MODE "${TCP_PROXY_MODE}" -NO_PROXY_IPV6 ${FILTER_PROXY_IPV6:-0} -NFTFLAG ${nftflag:-0} \
-SUBNET ${subnet_ip:-0} -NO_LOGIC_LOG ${NO_LOGIC_LOG:-0} -SUBNET ${subnet_ip:-0} -NO_LOGIC_LOG ${NO_LOGIC_LOG:-0}
source $APP_PATH/helper_smartdns.sh restart source $APP_PATH/helper_smartdns.sh restart
@@ -1435,7 +1279,7 @@ start_dns() {
_default_mode=${TCP_PROXY_MODE} \ _default_mode=${TCP_PROXY_MODE} \
_default_tag=$(config_t_get global chinadns_ng_default_tag smart) \ _default_tag=$(config_t_get global chinadns_ng_default_tag smart) \
_no_logic_log=0 \ _no_logic_log=0 \
_tcp_node=${TCP_NODE} \ _node=${NODE} \
_filter_https=$(config_t_get global force_https_soa 0) \ _filter_https=$(config_t_get global force_https_soa 0) \
_log=$(config_t_get global log_chinadns_ng 0) _log=$(config_t_get global log_chinadns_ng 0)
@@ -1470,7 +1314,7 @@ start_dns() {
-DEFAULT_DNS ${DEFAULT_DNS} -LOCAL_DNS ${LOCAL_DNS} -TUN_DNS ${DNSMASQ_TUN_DNS} \ -DEFAULT_DNS ${DEFAULT_DNS} -LOCAL_DNS ${LOCAL_DNS} -TUN_DNS ${DNSMASQ_TUN_DNS} \
-USE_DEFAULT_DNS "${USE_DEFAULT_DNS:-direct}" -CHINADNS_DNS ${china_ng_listen:-0} \ -USE_DEFAULT_DNS "${USE_DEFAULT_DNS:-direct}" -CHINADNS_DNS ${china_ng_listen:-0} \
-USE_DIRECT_LIST "${USE_DIRECT_LIST}" -USE_PROXY_LIST "${USE_PROXY_LIST}" -USE_BLOCK_LIST "${USE_BLOCK_LIST}" -USE_GFW_LIST "${USE_GFW_LIST}" -CHN_LIST "${CHN_LIST}" \ -USE_DIRECT_LIST "${USE_DIRECT_LIST}" -USE_PROXY_LIST "${USE_PROXY_LIST}" -USE_BLOCK_LIST "${USE_BLOCK_LIST}" -USE_GFW_LIST "${USE_GFW_LIST}" -CHN_LIST "${CHN_LIST}" \
-TCP_NODE ${TCP_NODE} -DEFAULT_PROXY_MODE ${TCP_PROXY_MODE} -NO_PROXY_IPV6 ${DNSMASQ_FILTER_PROXY_IPV6:-0} -NFTFLAG ${nftflag:-0} \ -NODE ${NODE} -DEFAULT_PROXY_MODE ${TCP_PROXY_MODE} -NO_PROXY_IPV6 ${DNSMASQ_FILTER_PROXY_IPV6:-0} -NFTFLAG ${nftflag:-0} \
-NO_LOGIC_LOG ${NO_LOGIC_LOG:-0} -NO_LOGIC_LOG ${NO_LOGIC_LOG:-0}
uci -q add_list dhcp.@dnsmasq[0].addnmount=${GLOBAL_DNSMASQ_CONF_PATH} uci -q add_list dhcp.@dnsmasq[0].addnmount=${GLOBAL_DNSMASQ_CONF_PATH}
uci -q commit dhcp uci -q commit dhcp
@@ -1484,7 +1328,7 @@ start_dns() {
-LISTEN_PORT ${GLOBAL_DNSMASQ_PORT} -DEFAULT_DNS ${DEFAULT_DNS} -LOCAL_DNS ${LOCAL_DNS} -TUN_DNS ${DNSMASQ_TUN_DNS} \ -LISTEN_PORT ${GLOBAL_DNSMASQ_PORT} -DEFAULT_DNS ${DEFAULT_DNS} -LOCAL_DNS ${LOCAL_DNS} -TUN_DNS ${DNSMASQ_TUN_DNS} \
-USE_DEFAULT_DNS "${USE_DEFAULT_DNS:-direct}" -CHINADNS_DNS ${china_ng_listen:-0} \ -USE_DEFAULT_DNS "${USE_DEFAULT_DNS:-direct}" -CHINADNS_DNS ${china_ng_listen:-0} \
-USE_DIRECT_LIST "${USE_DIRECT_LIST}" -USE_PROXY_LIST "${USE_PROXY_LIST}" -USE_BLOCK_LIST "${USE_BLOCK_LIST}" -USE_GFW_LIST "${USE_GFW_LIST}" -CHN_LIST "${CHN_LIST}" \ -USE_DIRECT_LIST "${USE_DIRECT_LIST}" -USE_PROXY_LIST "${USE_PROXY_LIST}" -USE_BLOCK_LIST "${USE_BLOCK_LIST}" -USE_GFW_LIST "${USE_GFW_LIST}" -CHN_LIST "${CHN_LIST}" \
-TCP_NODE ${TCP_NODE} -DEFAULT_PROXY_MODE ${TCP_PROXY_MODE} -NO_PROXY_IPV6 ${DNSMASQ_FILTER_PROXY_IPV6:-0} -NFTFLAG ${nftflag:-0} \ -NODE ${NODE} -DEFAULT_PROXY_MODE ${TCP_PROXY_MODE} -NO_PROXY_IPV6 ${DNSMASQ_FILTER_PROXY_IPV6:-0} -NFTFLAG ${nftflag:-0} \
-NO_LOGIC_LOG ${NO_LOGIC_LOG:-0} -NO_LOGIC_LOG ${NO_LOGIC_LOG:-0}
ln_run "$(first_type dnsmasq)" "dnsmasq_default" "/dev/null" -C ${GLOBAL_DNSMASQ_CONF} -x ${GLOBAL_ACL_PATH}/dnsmasq.pid ln_run "$(first_type dnsmasq)" "dnsmasq_default" "/dev/null" -C ${GLOBAL_DNSMASQ_CONF} -x ${GLOBAL_ACL_PATH}/dnsmasq.pid
set_cache_var "ACL_default_dns_port" "${GLOBAL_DNSMASQ_PORT}" set_cache_var "ACL_default_dns_port" "${GLOBAL_DNSMASQ_PORT}"
@@ -1568,15 +1412,13 @@ acl_app() {
use_global_config=${use_global_config:-0} use_global_config=${use_global_config:-0}
[ "${use_global_config}" = "1" ] && { [ "${use_global_config}" = "1" ] && {
tcp_node="default" node="default"
udp_node="default"
} }
tcp_no_redir_ports=${tcp_no_redir_ports:-${TCP_NO_REDIR_PORTS}} tcp_no_redir_ports=${tcp_no_redir_ports:-${TCP_NO_REDIR_PORTS}}
udp_no_redir_ports=${udp_no_redir_ports:-${UDP_NO_REDIR_PORTS}} udp_no_redir_ports=${udp_no_redir_ports:-${UDP_NO_REDIR_PORTS}}
if has_1_65535 "$tcp_no_redir_ports" && has_1_65535 "$udp_no_redir_ports"; then if has_1_65535 "$tcp_no_redir_ports" && has_1_65535 "$udp_no_redir_ports"; then
unset use_global_config unset use_global_config
unset tcp_node unset node
unset udp_node
else else
use_direct_list=${use_direct_list:-1} use_direct_list=${use_direct_list:-1}
use_proxy_list=${use_proxy_list:-1} use_proxy_list=${use_proxy_list:-1}
@@ -1593,41 +1435,39 @@ acl_app() {
use_default_dns=${use_default_dns:-direct} use_default_dns=${use_default_dns:-direct}
fi fi
[ -n "$tcp_node" ] && { [ -n "$node" ] && {
local GLOBAL_TCP_NODE=$(get_cache_var "ACL_GLOBAL_TCP_node") local GLOBAL_NODE=$(get_cache_var "ACL_GLOBAL_node")
[ -n "${GLOBAL_TCP_NODE}" ] && GLOBAL_TCP_redir_port=$(get_cache_var "ACL_GLOBAL_TCP_redir_port") [ -n "${GLOBAL_NODE}" ] && GLOBAL_redir_port=$(get_cache_var "ACL_GLOBAL_redir_port")
if [ "$tcp_node" = "default" ]; then if [ "$node" = "default" ]; then
if [ -n "${GLOBAL_TCP_NODE}" ]; then if [ -n "${GLOBAL_NODE}" ]; then
set_cache_var "ACL_${sid}_tcp_node" "${GLOBAL_TCP_NODE}" set_cache_var "ACL_${sid}_node" "${GLOBAL_NODE}"
set_cache_var "ACL_${sid}_tcp_redir_port" "${GLOBAL_TCP_redir_port}" set_cache_var "ACL_${sid}_redir_port" "${GLOBAL_redir_port}"
set_cache_var "ACL_${sid}_dns_port" "${GLOBAL_DNSMASQ_PORT}" set_cache_var "ACL_${sid}_dns_port" "${GLOBAL_DNSMASQ_PORT}"
set_cache_var "ACL_${sid}_tcp_default" "1" set_cache_var "ACL_${sid}_default" "1"
[ "$GLOBAL_SHUNT_NODE_FAKEDNS" = "1" ] && use_fakedns=1 [ "$GLOBAL_SHUNT_NODE_FAKEDNS" = "1" ] && use_fakedns=1
else else
echolog " - 全局节点未启用,跳过【${remarks}" echolog " - 全局节点未启用,跳过【${remarks}"
fi fi
else else
[ "$(config_get_type $tcp_node)" = "nodes" ] || [ "$(config_get_type $tcp_node)" = "socks" ] && { [ "$(config_get_type $node)" = "nodes" ] || [ "$(config_get_type $node)" = "socks" ] && {
if [ -n "${GLOBAL_TCP_NODE}" ] && [ "$tcp_node" = "${GLOBAL_TCP_NODE}" ]; then if [ -n "${GLOBAL_NODE}" ] && [ "$node" = "${GLOBAL_NODE}" ]; then
set_cache_var "ACL_${sid}_tcp_node" "${GLOBAL_TCP_NODE}" set_cache_var "ACL_${sid}_node" "${GLOBAL_NODE}"
set_cache_var "ACL_${sid}_tcp_redir_port" "${GLOBAL_TCP_redir_port}" set_cache_var "ACL_${sid}_redir_port" "${GLOBAL_redir_port}"
set_cache_var "ACL_${sid}_dns_port" "${GLOBAL_DNSMASQ_PORT}" set_cache_var "ACL_${sid}_dns_port" "${GLOBAL_DNSMASQ_PORT}"
set_cache_var "ACL_${sid}_tcp_default" "1" set_cache_var "ACL_${sid}_default" "1"
[ "$GLOBAL_SHUNT_NODE_FAKEDNS" = "1" ] && use_fakedns=1 [ "$GLOBAL_SHUNT_NODE_FAKEDNS" = "1" ] && use_fakedns=1
else else
local type protocol local type protocol
if [ "$(config_get_type $tcp_node)" = "socks" ]; then if [ "$(config_get_type $node)" = "socks" ]; then
if [ "${dns_mode}" = "xray" ]; then if [ "${dns_mode}" = "xray" ]; then
type="xray" type="xray"
elif [ "${dns_mode}" = "sing-box" ]; then elif [ "${dns_mode}" = "sing-box" ]; then
type="sing-box" type="sing-box"
fi fi
else else
type=$(echo $(config_n_get $tcp_node type) | tr 'A-Z' 'a-z') type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
protocol=$(config_n_get $tcp_node protocol) protocol=$(config_n_get $node protocol)
fi fi
#兼容旧模式,择机移除
[ "$v2ray_dns_mode" = "tcp+doh" ] && v2ray_dns_mode="tcp"
([ "$type" = "sing-box" ] || [ "$type" = "xray" ]) && [ "$protocol" = "_shunt" ] && [ "$type" != "$dns_mode" ] && { ([ "$type" = "sing-box" ] || [ "$type" = "xray" ]) && [ "$protocol" = "_shunt" ] && [ "$type" != "$dns_mode" ] && {
dns_mode=$type dns_mode=$type
[ "$type" = "xray" ] && [ "$v2ray_dns_mode" = "http3" ] && v2ray_dns_mode="tcp" [ "$type" = "xray" ] && [ "$v2ray_dns_mode" = "http3" ] && v2ray_dns_mode="tcp"
@@ -1637,7 +1477,7 @@ acl_app() {
dns_cache_key="${dns_mode}_${remote_dns_doh:-https://1.1.1.1/dns-query}_${v2ray_dns_mode:-doh}_${remote_dns_client_ip:-0}_${remote_fakedns:-0}_${remote_rewrite_ttl:-30}" dns_cache_key="${dns_mode}_${remote_dns_doh:-https://1.1.1.1/dns-query}_${v2ray_dns_mode:-doh}_${remote_dns_client_ip:-0}_${remote_fakedns:-0}_${remote_rewrite_ttl:-30}"
} }
if [ "$remote_fakedns" = "1" ] || ([ "$protocol" = "_shunt" ] && [ "$(config_n_get $tcp_node fakedns)" = "1" ]); then if [ "$remote_fakedns" = "1" ] || ([ "$protocol" = "_shunt" ] && [ "$(config_n_get $node fakedns)" = "1" ]); then
use_fakedns=1 use_fakedns=1
fi fi
@@ -1650,7 +1490,7 @@ acl_app() {
if [ "$dns_mode" = "dns2socks" ]; then if [ "$dns_mode" = "dns2socks" ]; then
run_dns2socks flag=acl_${sid} socks_address=127.0.0.1 socks_port=$socks_port listen_address=0.0.0.0 listen_port=${_dns_port} dns=$remote_dns cache=1 run_dns2socks flag=acl_${sid} socks_address=127.0.0.1 socks_port=$socks_port listen_address=0.0.0.0 listen_port=${_dns_port} dns=$remote_dns cache=1
elif [ "$dns_mode" = "sing-box" ] || [ "$dns_mode" = "xray" ]; then elif [ "$dns_mode" = "sing-box" ] || [ "$dns_mode" = "xray" ]; then
config_file=$TMP_ACL_PATH/${tcp_node}_SOCKS_${socks_port}_DNS.json config_file=$TMP_ACL_PATH/${node}_SOCKS_${socks_port}_DNS.json
remote_dns_doh=${remote_dns_doh:-https://1.1.1.1/dns-query} remote_dns_doh=${remote_dns_doh:-https://1.1.1.1/dns-query}
local type=${dns_mode} local type=${dns_mode}
[ "${dns_mode}" = "sing-box" ] && type="singbox" [ "${dns_mode}" = "sing-box" ] && type="singbox"
@@ -1659,7 +1499,7 @@ acl_app() {
[ "$filter_proxy_ipv6" = "1" ] && remote_dns_query_strategy="UseIPv4" [ "$filter_proxy_ipv6" = "1" ] && remote_dns_query_strategy="UseIPv4"
run_${type} flag=acl_${sid} type=$dns_mode dns_socks_address=127.0.0.1 dns_socks_port=$socks_port dns_listen_port=${_dns_port} remote_dns_protocol=${v2ray_dns_mode} remote_dns_udp_server=${remote_dns} remote_dns_tcp_server=${remote_dns} remote_dns_doh="${remote_dns_doh}" remote_dns_query_strategy=${remote_dns_query_strategy} remote_dns_client_ip=${remote_dns_client_ip} config_file=$config_file run_${type} flag=acl_${sid} type=$dns_mode dns_socks_address=127.0.0.1 dns_socks_port=$socks_port dns_listen_port=${_dns_port} remote_dns_protocol=${v2ray_dns_mode} remote_dns_udp_server=${remote_dns} remote_dns_tcp_server=${remote_dns} remote_dns_doh="${remote_dns_doh}" remote_dns_query_strategy=${remote_dns_query_strategy} remote_dns_client_ip=${remote_dns_client_ip} config_file=$config_file
fi fi
set_cache_var "node_${tcp_node}_$(echo -n "${dns_cache_key}" | md5sum | cut -d " " -f1)" "${_dns_port}" set_cache_var "node_${node}_$(echo -n "${dns_cache_key}" | md5sum | cut -d " " -f1)" "${_dns_port}"
} }
[ "$dns_shunt" = "chinadns-ng" ] && [ -n "$(first_type chinadns-ng)" ] && { [ "$dns_shunt" = "chinadns-ng" ] && [ -n "$(first_type chinadns-ng)" ] && {
@@ -1698,7 +1538,7 @@ acl_app() {
_default_mode=${tcp_proxy_mode} \ _default_mode=${tcp_proxy_mode} \
_default_tag=${chinadns_ng_default_tag:-smart} \ _default_tag=${chinadns_ng_default_tag:-smart} \
_no_logic_log=1 \ _no_logic_log=1 \
_tcp_node=${tcp_node} \ _node=${node} \
_filter_https=${force_https_soa:-0} \ _filter_https=${force_https_soa:-0} \
_log=${log} _log=${log}
@@ -1712,42 +1552,41 @@ acl_app() {
-LISTEN_PORT ${dnsmasq_port} -DEFAULT_DNS ${DEFAULT_DNS} -LOCAL_DNS $LOCAL_DNS \ -LISTEN_PORT ${dnsmasq_port} -DEFAULT_DNS ${DEFAULT_DNS} -LOCAL_DNS $LOCAL_DNS \
-USE_DIRECT_LIST "${use_direct_list}" -USE_PROXY_LIST "${use_proxy_list}" -USE_BLOCK_LIST "${use_block_list}" -USE_GFW_LIST "${use_gfw_list}" -CHN_LIST "${chn_list}" \ -USE_DIRECT_LIST "${use_direct_list}" -USE_PROXY_LIST "${use_proxy_list}" -USE_BLOCK_LIST "${use_block_list}" -USE_GFW_LIST "${use_gfw_list}" -CHN_LIST "${chn_list}" \
-TUN_DNS "127.0.0.1#${_dns_port}" -USE_DEFAULT_DNS "${use_default_dns:-direct}" -CHINADNS_DNS ${_china_ng_listen:-0} \ -TUN_DNS "127.0.0.1#${_dns_port}" -USE_DEFAULT_DNS "${use_default_dns:-direct}" -CHINADNS_DNS ${_china_ng_listen:-0} \
-TCP_NODE $tcp_node -DEFAULT_PROXY_MODE ${tcp_proxy_mode} -NO_PROXY_IPV6 ${dnsmasq_filter_proxy_ipv6:-0} -NFTFLAG ${nftflag:-0} \ -NODE $node -DEFAULT_PROXY_MODE ${tcp_proxy_mode} -NO_PROXY_IPV6 ${dnsmasq_filter_proxy_ipv6:-0} -NFTFLAG ${nftflag:-0} \
-NO_LOGIC_LOG 1 -NO_LOGIC_LOG 1
ln_run "$(first_type dnsmasq)" "dnsmasq_${sid}" "/dev/null" -C ${dnsmasq_conf} -x ${acl_path}/dnsmasq.pid ln_run "$(first_type dnsmasq)" "dnsmasq_${sid}" "/dev/null" -C ${dnsmasq_conf} -x ${acl_path}/dnsmasq.pid
set_cache_var "ACL_${sid}_dns_port" "${dnsmasq_port}" set_cache_var "ACL_${sid}_dns_port" "${dnsmasq_port}"
set_cache_var "node_${tcp_node}_$(echo -n "${tcp_proxy_mode}_${dns_cache_key}" | md5sum | cut -d " " -f1)" "${dnsmasq_port}" set_cache_var "node_${node}_$(echo -n "${tcp_proxy_mode}_${dns_cache_key}" | md5sum | cut -d " " -f1)" "${dnsmasq_port}"
#dhcp.leases to hosts #dhcp.leases to hosts
$APP_PATH/lease2hosts.sh > /dev/null 2>&1 & $APP_PATH/lease2hosts.sh > /dev/null 2>&1 &
} }
_redir_port=$(get_cache_var "node_${tcp_node}_redir_port") _redir_port=$(get_cache_var "node_${node}_redir_port")
_socks_port=$(get_cache_var "node_${tcp_node}_socks_port") _socks_port=$(get_cache_var "node_${node}_socks_port")
if [ -n "${_socks_port}" ] && [ -n "${_redir_port}" ]; then if [ -n "${_socks_port}" ] && [ -n "${_redir_port}" ]; then
socks_port=${_socks_port} socks_port=${_socks_port}
tcp_port=${_redir_port} node_port=${_redir_port}
_dnsmasq_port=$(get_cache_var "node_${tcp_node}_$(echo -n "${tcp_proxy_mode}_${dns_cache_key}" | md5sum | cut -d " " -f1)") _dnsmasq_port=$(get_cache_var "node_${node}_$(echo -n "${tcp_proxy_mode}_${dns_cache_key}" | md5sum | cut -d " " -f1)")
if [ -z "${_dnsmasq_port}" ]; then if [ -z "${_dnsmasq_port}" ]; then
_dns_port=$(get_cache_var "node_${tcp_node}_$(echo -n "${dns_cache_key}" | md5sum | cut -d " " -f1)") _dns_port=$(get_cache_var "node_${node}_$(echo -n "${dns_cache_key}" | md5sum | cut -d " " -f1)")
run_dns ${_dns_port} run_dns ${_dns_port}
else else
[ -n "${_dnsmasq_port}" ] && set_cache_var "ACL_${sid}_dns_port" "${_dnsmasq_port}" [ -n "${_dnsmasq_port}" ] && set_cache_var "ACL_${sid}_dns_port" "${_dnsmasq_port}"
fi fi
else else
socks_port=$(get_new_port $(expr $socks_port + 1)) socks_port=$(get_new_port $(expr $socks_port + 1))
set_cache_var "node_${tcp_node}_socks_port" "${socks_port}" set_cache_var "node_${node}_socks_port" "${socks_port}"
redir_port=$(get_new_port $(expr $redir_port + 1)) redir_port=$(get_new_port $(expr $redir_port + 1))
set_cache_var "node_${tcp_node}_redir_port" "${redir_port}" set_cache_var "node_${node}_redir_port" "${redir_port}"
tcp_port=$redir_port node_port=$redir_port
local log_file="/dev/null" local log_file="/dev/null"
[ "${log}" = "1" ] && log_file="${TMP_ACL_PATH}/${sid}/TCP.log" [ "${log}" = "1" ] && log_file="${TMP_ACL_PATH}/${sid}/node.log"
if [ "${type}" = "sing-box" ] || [ "${type}" = "xray" ]; then if [ "${type}" = "sing-box" ] || [ "${type}" = "xray" ]; then
config_file="acl/${tcp_node}_TCP_${redir_port}.json" config_file="acl/${node}_${redir_port}.json"
_extra_param="socks_address=127.0.0.1 socks_port=$socks_port" _extra_param="socks_address=127.0.0.1 socks_port=$socks_port"
[ "${type}" = "${dns_mode}" ] && { [ "${type}" = "${dns_mode}" ] && {
dns_port=$(get_new_port $(expr $dns_port + 1)) dns_port=$(get_new_port $(expr $dns_port + 1))
_dns_port=$dns_port _dns_port=$dns_port
config_file="${config_file//TCP_/DNS_${_dns_port}_TCP_}"
dnsmasq_filter_proxy_ipv6=0 dnsmasq_filter_proxy_ipv6=0
remote_dns_query_strategy="UseIP" remote_dns_query_strategy="UseIP"
[ "$filter_proxy_ipv6" = "1" ] && remote_dns_query_strategy="UseIPv4" [ "$filter_proxy_ipv6" = "1" ] && remote_dns_query_strategy="UseIPv4"
@@ -1756,107 +1595,31 @@ acl_app() {
_extra_param="${_extra_param} remote_dns_doh=${remote_dns_doh} remote_dns_query_strategy=${remote_dns_query_strategy} remote_fakedns=${remote_fakedns:-0} remote_dns_client_ip=${remote_dns_client_ip}" _extra_param="${_extra_param} remote_dns_doh=${remote_dns_doh} remote_dns_query_strategy=${remote_dns_query_strategy} remote_fakedns=${remote_fakedns:-0} remote_dns_client_ip=${remote_dns_client_ip}"
} }
_extra_param="${_extra_param} tcp_proxy_way=$TCP_PROXY_WAY" _extra_param="${_extra_param} tcp_proxy_way=$TCP_PROXY_WAY"
[ -n "$udp_node" ] && ([ "$udp_node" = "tcp" ] || [ "$udp_node" = "$tcp_node" ]) && {
config_file="${config_file//TCP_/TCP_UDP_}"
_extra_param="${_extra_param} udp_redir_port=$redir_port"
}
config_file="$TMP_PATH/$config_file" config_file="$TMP_PATH/$config_file"
[ "${type}" = "sing-box" ] && { [ "${type}" = "sing-box" ] && {
type="singbox" type="singbox"
_extra_param="${_extra_param} remote_rewrite_ttl=${remote_rewrite_ttl:-30}" _extra_param="${_extra_param} remote_rewrite_ttl=${remote_rewrite_ttl:-30}"
} }
_extra_param="${_extra_param} use_proxy_list=$use_proxy_list use_gfw_list=$use_gfw_list chn_list=$chn_list" _extra_param="${_extra_param} use_proxy_list=$use_proxy_list use_gfw_list=$use_gfw_list chn_list=$chn_list"
run_${type} flag=$tcp_node node=$tcp_node tcp_redir_port=$redir_port ${_extra_param} config_file=$config_file log_file=$log_file loglevel=$loglevel run_${type} flag=$node node=$node redir_port=$redir_port ${_extra_param} config_file=$config_file log_file=$log_file loglevel=$loglevel
else else
config_file="acl/${tcp_node}_SOCKS_${socks_port}.json" config_file="acl/${node}_SOCKS_${socks_port}.json"
run_socks flag=$tcp_node node=$tcp_node bind=127.0.0.1 socks_port=$socks_port config_file=$config_file log_file=$log_file run_socks flag=$node node=$node bind=127.0.0.1 socks_port=$socks_port config_file=$config_file log_file=$log_file
# log_file=$TMP_ACL_PATH/ipt2socks_${tcp_node}_${redir_port}.log # log_file=$TMP_ACL_PATH/ipt2socks_${node}_${redir_port}.log
log_file="/dev/null" log_file="/dev/null"
run_ipt2socks flag=acl_${tcp_node} tcp_tproxy=${is_tproxy} local_port=$redir_port socks_address=127.0.0.1 socks_port=$socks_port log_file=$log_file run_ipt2socks flag=acl_${node} tcp_tproxy=${is_tproxy} local_port=$redir_port socks_address=127.0.0.1 socks_port=$socks_port log_file=$log_file
fi fi
run_dns ${_dns_port} run_dns ${_dns_port}
fi fi
set_cache_var "ACL_${sid}_tcp_node" "${tcp_node}" set_cache_var "ACL_${sid}_node" "${node}"
set_cache_var "ACL_${sid}_tcp_redir_port" "${tcp_port}" set_cache_var "ACL_${sid}_redir_port" "${node_port}"
fi fi
} }
fi fi
[ "${use_fakedns}" = "1" ] && set_cache_var "ACL_${sid}_fakedns" "1" [ "${use_fakedns}" = "1" ] && set_cache_var "ACL_${sid}_fakedns" "1"
} }
[ -n "$udp_node" ] && { unset enabled sid remarks sources interface tcp_no_redir_ports udp_no_redir_ports use_global_config node use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode filter_proxy_ipv6 dns_mode remote_dns v2ray_dns_mode remote_dns_doh remote_dns_client_ip
[ -n "$tcp_node" ] && { unset _ip _mac _iprange _ipset _ip_or_mac source_list node_port config_file _extra_param dns_cache_key log loglevel
local protocol=$(config_n_get $tcp_node protocol)
[ "$protocol" = "_shunt" ] && [ "$udp_node" != "default" ] && {
udp_node="tcp"
}
}
if [ "$udp_node" = "default" ]; then
local GLOBAL_UDP_NODE=$(get_cache_var "ACL_GLOBAL_UDP_node")
[ -n "${GLOBAL_UDP_NODE}" ] && GLOBAL_UDP_redir_port=$(get_cache_var "ACL_GLOBAL_UDP_redir_port")
if [ -n "${GLOBAL_UDP_NODE}" ]; then
set_cache_var "ACL_${sid}_udp_node" "${GLOBAL_UDP_NODE}"
set_cache_var "ACL_${sid}_udp_redir_port" "${GLOBAL_UDP_redir_port}"
set_cache_var "ACL_${sid}_udp_default" "1"
else
echolog " - 全局节点未启用,跳过【${remarks}"
fi
elif [ "$udp_node" = "tcp" ] || [ "$udp_node" = "$tcp_node" ]; then
udp_node=$(get_cache_var "ACL_${sid}_tcp_node")
udp_port=$(get_cache_var "ACL_${sid}_tcp_redir_port")
set_cache_var "ACL_${sid}_udp_node" "${udp_node}"
set_cache_var "ACL_${sid}_udp_redir_port" "${udp_port}"
else
[ "$(config_get_type $udp_node)" = "nodes" ] || [ "$(config_get_type $udp_node)" = "socks" ] && {
if [ -n "${GLOBAL_UDP_NODE}" ] && [ "$udp_node" = "${GLOBAL_UDP_NODE}" ]; then
set_cache_var "ACL_${sid}_udp_node" "${GLOBAL_UDP_NODE}"
set_cache_var "ACL_${sid}_udp_redir_port" "${GLOBAL_UDP_redir_port}"
set_cache_var "ACL_${sid}_udp_default" "1"
else
_redir_port=$(get_cache_var "node_${udp_node}_redir_port")
_socks_port=$(get_cache_var "node_${udp_node}_socks_port")
if [ -n "${_socks_port}" ] && [ -n "${_redir_port}" ]; then
socks_port=${_socks_port}
udp_port=${_redir_port}
else
socks_port=$(get_new_port $(expr $socks_port + 1))
set_cache_var "node_${udp_node}_socks_port" "${socks_port}"
redir_port=$(get_new_port $(expr $redir_port + 1))
set_cache_var "node_${udp_node}_redir_port" "${redir_port}"
udp_port=$redir_port
local log_file="/dev/null"
[ "${log}" = "1" ] && log_file="${TMP_ACL_PATH}/${sid}/UDP.log"
local type
if [ "$(config_get_type $udp_node)" = "socks" ]; then
if [ "${dns_mode}" = "xray" ]; then
type="xray"
elif [ "${dns_mode}" = "sing-box" ]; then
type="sing-box"
fi
else
type=$(echo $(config_n_get $udp_node type) | tr 'A-Z' 'a-z')
fi
if [ -n "${type}" ] && ([ "${type}" = "sing-box" ] || [ "${type}" = "xray" ]); then
config_file="acl/${udp_node}_UDP_${redir_port}.json"
config_file="$TMP_PATH/$config_file"
[ "${type}" = "sing-box" ] && type="singbox"
run_${type} flag=$udp_node node=$udp_node udp_redir_port=$redir_port config_file=$config_file log_file=$log_file loglevel=$loglevel
else
config_file="acl/${udp_node}_SOCKS_${socks_port}.json"
run_socks flag=$udp_node node=$udp_node bind=127.0.0.1 socks_port=$socks_port config_file=$config_file log_file=$log_file
# log_file=$TMP_ACL_PATH/ipt2socks_${udp_node}_${redir_port}.log
log_file="/dev/null"
run_ipt2socks flag=acl_${udp_node} local_port=$redir_port socks_address=127.0.0.1 socks_port=$socks_port log_file=$log_file
fi
fi
set_cache_var "ACL_${sid}_udp_node" "${udp_node}"
set_cache_var "ACL_${sid}_udp_redir_port" "${udp_port}"
fi
}
fi
}
unset enabled sid remarks sources interface tcp_no_redir_ports udp_no_redir_ports use_global_config tcp_node udp_node use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode filter_proxy_ipv6 dns_mode remote_dns v2ray_dns_mode remote_dns_doh remote_dns_client_ip
unset _ip _mac _iprange _ipset _ip_or_mac source_list tcp_port udp_port config_file _extra_param dns_cache_key log loglevel
unset _china_ng_listen _chinadns_local_dns _direct_dns_mode chinadns_ng_default_tag dnsmasq_filter_proxy_ipv6 remote_fakedns force_https_soa use_fakedns remote_rewrite_ttl unset _china_ng_listen _chinadns_local_dns _direct_dns_mode chinadns_ng_default_tag dnsmasq_filter_proxy_ipv6 remote_fakedns force_https_soa use_fakedns remote_rewrite_ttl
done done
unset socks_port redir_port dns_port dnsmasq_port chinadns_port unset socks_port redir_port dns_port dnsmasq_port chinadns_port
@@ -1898,8 +1661,7 @@ start() {
fi fi
[ "$ENABLED_DEFAULT_ACL" = 1 ] && { [ "$ENABLED_DEFAULT_ACL" = 1 ] && {
mkdir -p ${GLOBAL_ACL_PATH} mkdir -p ${GLOBAL_ACL_PATH}
start_redir TCP start_global
start_redir UDP
start_dns start_dns
} }
[ -n "$USE_TABLES" ] && source $APP_PATH/${USE_TABLES}.sh start [ -n "$USE_TABLES" ] && source $APP_PATH/${USE_TABLES}.sh start
@@ -1983,33 +1745,15 @@ stop() {
get_config() { get_config() {
ENABLED_DEFAULT_ACL=0 ENABLED_DEFAULT_ACL=0
TCP_REDIR_PORT=1041 REDIR_PORT=$(echo $(get_new_port 1041 tcp,udp))
UDP_REDIR_PORT=1051
ENABLED=$(config_t_get global enabled 0) ENABLED=$(config_t_get global enabled 0)
SOCKS_ENABLED=$(config_t_get global socks_enabled 0) SOCKS_ENABLED=$(config_t_get global socks_enabled 0)
TCP_NODE=$(config_t_get global tcp_node) NODE=$(config_t_get global node)
UDP_NODE=$(config_t_get global udp_node)
TCP_UDP=0
if [ "$UDP_NODE" = "tcp" ]; then
UDP_NODE=$TCP_NODE
TCP_UDP=1
elif [ "$UDP_NODE" = "$TCP_NODE" ]; then
TCP_UDP=1
fi
[ -n "$TCP_NODE" ] && {
local protocol=$(config_n_get $TCP_NODE protocol)
[ "$protocol" = "_shunt" ] && [ -n "$UDP_NODE" ] && {
UDP_NODE=$TCP_NODE
TCP_UDP=1
}
}
[ "$ENABLED" = 1 ] && { [ "$ENABLED" = 1 ] && {
local _node if [ -n "$NODE" ] && ([ "$(config_get_type $NODE)" = "nodes" ] || [ "$(config_get_type $NODE)" = "socks" ]); then
for _node in "$TCP_NODE" "$UDP_NODE"; do
if [ -n "$_node" ] && ([ "$(config_get_type $_node)" = "nodes" ] || [ "$(config_get_type $_node)" = "socks" ]); then
ENABLED_DEFAULT_ACL=1 ENABLED_DEFAULT_ACL=1
fi fi
done
} }
ENABLED_ACLS=$(config_t_get global acl_enable 0) ENABLED_ACLS=$(config_t_get global acl_enable 0)
set_cache_var ENABLED_DEFAULT_ACL $ENABLED_DEFAULT_ACL set_cache_var ENABLED_DEFAULT_ACL $ENABLED_DEFAULT_ACL
@@ -2076,7 +1820,7 @@ get_config() {
SMARTDNS_LOCAL_PORT=0 SMARTDNS_LOCAL_PORT=0
SMARTDNS_LISTEN_PORT=0 SMARTDNS_LISTEN_PORT=0
[ "${DNS_SHUNT}" = "smartdns" ] && { [ "$ENABLED_DEFAULT_ACL" = 1 ] && [ "$DNS_SHUNT" = "smartdns" ] && {
NEXT_DNS_LISTEN_PORT=$(expr $NEXT_DNS_LISTEN_PORT + 1) NEXT_DNS_LISTEN_PORT=$(expr $NEXT_DNS_LISTEN_PORT + 1)
SMARTDNS_LOCAL_PORT=${NEXT_DNS_LISTEN_PORT} SMARTDNS_LOCAL_PORT=${NEXT_DNS_LISTEN_PORT}
NEXT_DNS_LISTEN_PORT=$(expr $NEXT_DNS_LISTEN_PORT + 1) NEXT_DNS_LISTEN_PORT=$(expr $NEXT_DNS_LISTEN_PORT + 1)
@@ -14,7 +14,7 @@ local NO_IPV6_TRUST = var["-NO_IPV6_TRUST"]
local DEFAULT_MODE = var["-DEFAULT_MODE"] local DEFAULT_MODE = var["-DEFAULT_MODE"]
local DEFAULT_TAG = var["-DEFAULT_TAG"] local DEFAULT_TAG = var["-DEFAULT_TAG"]
local NO_LOGIC_LOG = var["-NO_LOGIC_LOG"] local NO_LOGIC_LOG = var["-NO_LOGIC_LOG"]
local TCP_NODE = var["-TCP_NODE"] local NODE = var["-NODE"]
local NFTFLAG = var["-NFTFLAG"] local NFTFLAG = var["-NFTFLAG"]
local FILTER_HTTPS = var["-FILTER_HTTPS"] local FILTER_HTTPS = var["-FILTER_HTTPS"]
local LOG_FILE = var["-LOG_FILE"] local LOG_FILE = var["-LOG_FILE"]
@@ -30,7 +30,7 @@ local FLAG_PATH = TMP_ACL_PATH .. "/" .. FLAG
local config_lines = {} local config_lines = {}
local tmp_lines = {} local tmp_lines = {}
local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview") local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview")
local IS_SHUNT_NODE = api.uci_get_c(TCP_NODE, "protocol") == "_shunt" local IS_SHUNT_NODE = api.uci_get_c(NODE, "protocol") == "_shunt"
if not api.is_finded("geoview") then if not api.is_finded("geoview") then
USE_GEOVIEW = "0" USE_GEOVIEW = "0"
@@ -385,7 +385,7 @@ if IS_SHUNT_NODE then
local file_shunt_host = FLAG_PATH .. "/shunt_proxy_host" local file_shunt_host = FLAG_PATH .. "/shunt_proxy_host"
local geosite_white_arg, geosite_shunt_arg = "", "" local geosite_white_arg, geosite_shunt_arg = "", ""
local t = api.uci_get_c(TCP_NODE) local t = api.uci_get_c(NODE)
local default_node_id = t["default_node"] or "_direct" local default_node_id = t["default_node"] or "_direct"
api.uci_foreach_c("shunt_rules", function(s) api.uci_foreach_c("shunt_rules", function(s)
local _node_id = t[s[".name"]] local _node_id = t[s[".name"]]
@@ -163,7 +163,7 @@ function add_rule(var)
local TUN_DNS = var["-TUN_DNS"] local TUN_DNS = var["-TUN_DNS"]
local USE_DEFAULT_DNS = var["-USE_DEFAULT_DNS"] local USE_DEFAULT_DNS = var["-USE_DEFAULT_DNS"]
local CHINADNS_DNS = var["-CHINADNS_DNS"] local CHINADNS_DNS = var["-CHINADNS_DNS"]
local TCP_NODE = var["-TCP_NODE"] local NODE = var["-NODE"]
local USE_DIRECT_LIST = var["-USE_DIRECT_LIST"] local USE_DIRECT_LIST = var["-USE_DIRECT_LIST"]
local USE_PROXY_LIST = var["-USE_PROXY_LIST"] local USE_PROXY_LIST = var["-USE_PROXY_LIST"]
local USE_BLOCK_LIST = var["-USE_BLOCK_LIST"] local USE_BLOCK_LIST = var["-USE_BLOCK_LIST"]
@@ -178,7 +178,7 @@ function add_rule(var)
local CACHE_DNS_PATH = CACHE_PATH .. "/" .. CACHE_FLAG local CACHE_DNS_PATH = CACHE_PATH .. "/" .. CACHE_FLAG
local CACHE_TEXT_FILE = CACHE_DNS_PATH .. ".txt" local CACHE_TEXT_FILE = CACHE_DNS_PATH .. ".txt"
local USE_CHINADNS_NG = "0" local USE_CHINADNS_NG = "0"
local IS_SHUNT_NODE = api.uci_get_c(TCP_NODE, "protocol") == "_shunt" local IS_SHUNT_NODE = api.uci_get_c(NODE, "protocol") == "_shunt"
local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview") local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview")
local list1 = {} local list1 = {}
@@ -613,7 +613,7 @@ function add_rule(var)
--分流规则 --分流规则
if IS_SHUNT_NODE and USE_CHINADNS_NG == "0" then if IS_SHUNT_NODE and USE_CHINADNS_NG == "0" then
local t = api.uci_get_c(TCP_NODE) local t = api.uci_get_c(NODE)
local default_node_id = t["default_node"] or "_direct" local default_node_id = t["default_node"] or "_direct"
api.uci_foreach_c("shunt_rules", function(s) api.uci_foreach_c("shunt_rules", function(s)
local _node_id = t[s[".name"]] local _node_id = t[s[".name"]]
@@ -10,7 +10,7 @@ local USE_DEFAULT_DNS = var["-USE_DEFAULT_DNS"]
local REMOTE_DNS = var["-REMOTE_DNS"] local REMOTE_DNS = var["-REMOTE_DNS"]
local TUN_DNS = var["-TUN_DNS"] local TUN_DNS = var["-TUN_DNS"]
local DNS_MODE = var["-DNS_MODE"] local DNS_MODE = var["-DNS_MODE"]
local TCP_NODE = var["-TCP_NODE"] local NODE = var["-NODE"]
local USE_DIRECT_LIST = var["-USE_DIRECT_LIST"] local USE_DIRECT_LIST = var["-USE_DIRECT_LIST"]
local USE_PROXY_LIST = var["-USE_PROXY_LIST"] local USE_PROXY_LIST = var["-USE_PROXY_LIST"]
local USE_BLOCK_LIST = var["-USE_BLOCK_LIST"] local USE_BLOCK_LIST = var["-USE_BLOCK_LIST"]
@@ -36,7 +36,7 @@ local TMP_CONF_FILE = FLAG_PATH .. "/smartdns.conf"
local config_lines = {} local config_lines = {}
local tmp_lines = {} local tmp_lines = {}
local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview") local USE_GEOVIEW = api.uci_get_c("@global_rules[0]", "enable_geoview")
local IS_SHUNT_NODE = api.uci_get_c(TCP_NODE, "protocol") == "_shunt" local IS_SHUNT_NODE = api.uci_get_c(NODE, "protocol") == "_shunt"
if not api.is_finded("geoview") then if not api.is_finded("geoview") then
USE_GEOVIEW = "0" USE_GEOVIEW = "0"
@@ -553,7 +553,7 @@ if IS_SHUNT_NODE then
local file_shunt_host = FLAG_PATH .. "/shunt_proxy_host" local file_shunt_host = FLAG_PATH .. "/shunt_proxy_host"
local geosite_white_arg, geosite_shunt_arg = "", "" local geosite_white_arg, geosite_shunt_arg = "", ""
local t = api.uci_get_c(TCP_NODE) local t = api.uci_get_c(NODE)
local default_node_id = t["default_node"] or "_direct" local default_node_id = t["default_node"] or "_direct"
api.uci_foreach_c("shunt_rules", function(s) api.uci_foreach_c("shunt_rules", function(s)
local _node_id = t[s[".name"]] local _node_id = t[s[".name"]]
@@ -25,9 +25,6 @@ IPSET_BLACK6="psw_black6"
IPSET_WHITE6="psw_white6" IPSET_WHITE6="psw_white6"
IPSET_BLOCK6="psw_block6" IPSET_BLOCK6="psw_block6"
USE_SHUNT_TCP=0
USE_SHUNT_UDP=0
# ASCII code for PSW1.Use whatever,just not the same. # ASCII code for PSW1.Use whatever,just not the same.
FWMARK="0x50535731" FWMARK="0x50535731"
@@ -231,42 +228,29 @@ load_acl() {
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS [ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
[ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS [ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
[ -n "$(get_cache_var "ACL_${sid}_tcp_node")" ] && tcp_node=$(get_cache_var "ACL_${sid}_tcp_node") [ -n "$(get_cache_var "ACL_${sid}_node")" ] && node=$(get_cache_var "ACL_${sid}_node")
[ -n "$(get_cache_var "ACL_${sid}_tcp_redir_port")" ] && tcp_port=$(get_cache_var "ACL_${sid}_tcp_redir_port") [ -n "$(get_cache_var "ACL_${sid}_redir_port")" ] && {
[ -n "$(get_cache_var "ACL_${sid}_udp_node")" ] && udp_node=$(get_cache_var "ACL_${sid}_udp_node") tcp_port=$(get_cache_var "ACL_${sid}_redir_port")
[ -n "$(get_cache_var "ACL_${sid}_udp_redir_port")" ] && udp_port=$(get_cache_var "ACL_${sid}_udp_redir_port") udp_port=$tcp_port
}
[ -n "$(get_cache_var "ACL_${sid}_dns_port")" ] && dns_redirect_port=$(get_cache_var "ACL_${sid}_dns_port") [ -n "$(get_cache_var "ACL_${sid}_dns_port")" ] && dns_redirect_port=$(get_cache_var "ACL_${sid}_dns_port")
[ -n "$(get_cache_var "ACL_${sid}_fakedns")" ] && use_fakedns=$(get_cache_var "ACL_${sid}_fakedns") [ -n "$(get_cache_var "ACL_${sid}_fakedns")" ] && use_fakedns=$(get_cache_var "ACL_${sid}_fakedns")
[ -n "$tcp_node" ] && { [ -n "$node" ] && {
if [ "$(config_get_type $tcp_node)" = "socks" ]; then if [ "$(config_get_type $node)" = "socks" ]; then
tcp_node_remark="Socks 配置($(config_n_get $tcp_node port) 端口)" node_remark="Socks 配置($(config_n_get $node port) 端口)"
else else
tcp_node_remark=$(config_n_get $tcp_node remarks) node_remark=$(config_n_get $node remarks)
fi
}
[ -n "$udp_node" ] && {
if [ "$(config_get_type $udp_node)" = "socks" ]; then
udp_node_remark="Socks 配置($(config_n_get $udp_node port) 端口)"
else
udp_node_remark=$(config_n_get $udp_node remarks)
fi fi
} }
use_shunt_tcp=0 use_shunt_node=0
use_shunt_udp=0 [ -n "$node" ] && [ "$(config_n_get $node protocol)" = "_shunt" ] && use_shunt_node=1
[ -n "$tcp_node" ] && [ "$(config_n_get $tcp_node protocol)" = "_shunt" ] && use_shunt_tcp=1
[ -n "$udp_node" ] && [ "$(config_n_get $udp_node protocol)" = "_shunt" ] && use_shunt_udp=1
[ "${use_global_config}" = "1" ] && { [ "${use_global_config}" = "1" ] && {
if [ "$(config_get_type $TCP_NODE)" = "socks" ]; then if [ "$(config_get_type $NODE)" = "socks" ]; then
tcp_node_remark="Socks 配置($(config_n_get $TCP_NODE} port) 端口)" node_remark="Socks 配置($(config_n_get $NODE} port) 端口)"
else else
tcp_node_remark=$(config_n_get $TCP_NODE remarks) node_remark=$(config_n_get $NODE remarks)
fi
if [ "$(config_get_type $UDP_NODE)" = "socks" ]; then
udp_node_remark="Socks 配置($(config_n_get $UDP_NODE port) 端口)"
else
udp_node_remark=$(config_n_get $UDP_NODE remarks)
fi fi
use_direct_list=${USE_DIRECT_LIST} use_direct_list=${USE_DIRECT_LIST}
use_proxy_list=${USE_PROXY_LIST} use_proxy_list=${USE_PROXY_LIST}
@@ -275,8 +259,7 @@ load_acl() {
chn_list=${CHN_LIST} chn_list=${CHN_LIST}
tcp_proxy_mode=${TCP_PROXY_MODE} tcp_proxy_mode=${TCP_PROXY_MODE}
udp_proxy_mode=${UDP_PROXY_MODE} udp_proxy_mode=${UDP_PROXY_MODE}
use_shunt_tcp=${USE_SHUNT_TCP} use_shunt_node=${USE_SHUNT_NODE}
use_shunt_udp=${USE_SHUNT_UDP}
dns_redirect_port=${DNS_REDIRECT_PORT} dns_redirect_port=${DNS_REDIRECT_PORT}
black_set_name=${IPSET_BLACK} black_set_name=${IPSET_BLACK}
black6_set_name=${IPSET_BLACK6} black6_set_name=${IPSET_BLACK6}
@@ -388,7 +371,7 @@ load_acl() {
ipset -! create $gfw6_set_name nethash family inet6 maxelem 1048576 timeout 172800 ipset -! create $gfw6_set_name nethash family inet6 maxelem 1048576 timeout 172800
} }
} }
[ "${use_shunt_tcp}" = "1" ] || [ "${use_shunt_udp}" = "1" ] && { [ "${use_shunt_node}" = "1" ] && {
[ "${use_global_config}" = "0" ] && { [ "${use_global_config}" = "0" ] && {
shunt_set_name="psw_${sid}_shunt" shunt_set_name="psw_${sid}_shunt"
shunt6_set_name="psw_${sid}_shunt6" shunt6_set_name="psw_${sid}_shunt6"
@@ -397,12 +380,8 @@ load_acl() {
# 预加载分流规则 ip 到 ipset # 预加载分流规则 ip 到 ipset
local GEOIP_CODE="" local GEOIP_CODE=""
local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}') local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
local shunt_group shunt_id local shunt_group=$(config_n_get $node shunt_group)
if [ "${use_shunt_tcp}" = "1" ]; then local shunt_id
shunt_group=$(config_n_get $tcp_node shunt_group)
elif [ "${use_shunt_udp}" = "1" ]; then
shunt_group=$(config_n_get $udp_node shunt_group)
fi
for shunt_id in $shunt_ids; do for shunt_id in $shunt_ids; do
[ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue [ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue
config_n_get $shunt_id ip_list | tr -s "\r\n" "\n" | grep -v "^#" | sed -e "/^$/d" | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | sed -e "s/^/add $shunt_set_name &/g" -e "s/$/ timeout 0/g" | ipset -! -R config_n_get $shunt_id ip_list | tr -s "\r\n" "\n" | grep -v "^#" | sed -e "/^$/d" | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | sed -e "s/^/add $shunt_set_name &/g" -e "s/$/ timeout 0/g" | ipset -! -R
@@ -431,7 +410,7 @@ load_acl() {
[ "$_ipv4" != "1" ] && $ip6t_n -A PSW_DNS $(comment "$remarks") -p udp ${_ipt_source} --dport 53 -j REDIRECT --to-ports ${dns_redirect} 2>/dev/null [ "$_ipv4" != "1" ] && $ip6t_n -A PSW_DNS $(comment "$remarks") -p udp ${_ipt_source} --dport 53 -j REDIRECT --to-ports ${dns_redirect} 2>/dev/null
$ipt_n -A PSW_DNS $(comment "$remarks") -p tcp ${_ipt_source} --dport 53 -j REDIRECT --to-ports ${dns_redirect} $ipt_n -A PSW_DNS $(comment "$remarks") -p tcp ${_ipt_source} --dport 53 -j REDIRECT --to-ports ${dns_redirect}
[ "$_ipv4" != "1" ] && $ip6t_n -A PSW_DNS $(comment "$remarks") -p tcp ${_ipt_source} --dport 53 -j REDIRECT --to-ports ${dns_redirect} 2>/dev/null [ "$_ipv4" != "1" ] && $ip6t_n -A PSW_DNS $(comment "$remarks") -p tcp ${_ipt_source} --dport 53 -j REDIRECT --to-ports ${dns_redirect} 2>/dev/null
[ -z "$(get_cache_var "ACL_${sid}_tcp_default")" ] && echolog " - ${msg}使用与全局配置不相同节点,已将DNS强制重定向到专用 DNS 服务器。" [ -z "$(get_cache_var "ACL_${sid}_default")" ] && echolog " - ${msg}使用与全局配置不相同节点,已将DNS强制重定向到专用 DNS 服务器。"
fi fi
[ -n "$tcp_port" ] || [ -n "$udp_port" ] && { [ -n "$tcp_port" ] || [ -n "$udp_port" ] && {
@@ -448,14 +427,14 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $black6_set_name) -j MARK --set-mark 88" 2>/dev/null [ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $black6_set_name) -j MARK --set-mark 88" 2>/dev/null
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $gfw6_set_name) -j MARK --set-mark 88" 2>/dev/null [ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $gfw6_set_name) -j MARK --set-mark 88" 2>/dev/null
[ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")" 2>/dev/null [ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")" 2>/dev/null
[ "${use_shunt_tcp}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $shunt6_set_name) -j MARK --set-mark 88" 2>/dev/null [ "${use_shunt_node}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $shunt6_set_name) -j MARK --set-mark 88" 2>/dev/null
[ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "-j MARK --set-mark 88" 2>/dev/null [ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "-j MARK --set-mark 88" 2>/dev/null
} }
[ "${use_fakedns}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "-d $FAKE_IP -j MARK --set-mark 88" [ "${use_fakedns}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "-d $FAKE_IP -j MARK --set-mark 88"
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $black_set_name) -j MARK --set-mark 88" [ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $black_set_name) -j MARK --set-mark 88"
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $gfw_set_name) -j MARK --set-mark 88" [ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $gfw_set_name) -j MARK --set-mark 88"
[ "${chn_list}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")" [ "${chn_list}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")"
[ "${use_shunt_tcp}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $shunt_set_name) -j MARK --set-mark 88" [ "${use_shunt_node}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "$(dst $shunt_set_name) -j MARK --set-mark 88"
[ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "-j MARK --set-mark 88" [ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_proxy_drop_ports "-j MARK --set-mark 88"
echolog " - ${msg}屏蔽代理 TCP 端口[${tcp_proxy_drop_ports}]" echolog " - ${msg}屏蔽代理 TCP 端口[${tcp_proxy_drop_ports}]"
} }
@@ -466,14 +445,14 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $black6_set_name) -j MARK --set-mark 88" 2>/dev/null [ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $black6_set_name) -j MARK --set-mark 88" 2>/dev/null
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $gfw6_set_name) -j MARK --set-mark 88" 2>/dev/null [ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $gfw6_set_name) -j MARK --set-mark 88" 2>/dev/null
[ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")" 2>/dev/null [ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")" 2>/dev/null
[ "${use_shunt_udp}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $shunt6_set_name) -j MARK --set-mark 88" 2>/dev/null [ "${use_shunt_node}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $shunt6_set_name) -j MARK --set-mark 88" 2>/dev/null
[ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "-j MARK --set-mark 88" 2>/dev/null [ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "-j MARK --set-mark 88" 2>/dev/null
} }
[ "${use_fakedns}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "-d $FAKE_IP -j MARK --set-mark 88" [ "${use_fakedns}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "-d $FAKE_IP -j MARK --set-mark 88"
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $black_set_name) -j MARK --set-mark 88" [ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $black_set_name) -j MARK --set-mark 88"
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $gfw_set_name) -j MARK --set-mark 88" [ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $gfw_set_name) -j MARK --set-mark 88"
[ "${chn_list}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")" [ "${chn_list}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "-j MARK --set-mark 88")"
[ "${use_shunt_udp}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $shunt_set_name) -j MARK --set-mark 88" [ "${use_shunt_node}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "$(dst $shunt_set_name) -j MARK --set-mark 88"
[ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "-j MARK --set-mark 88" [ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_proxy_drop_ports "-j MARK --set-mark 88"
echolog " - ${msg}屏蔽代理 UDP 端口[${udp_proxy_drop_ports}]" echolog " - ${msg}屏蔽代理 UDP 端口[${udp_proxy_drop_ports}]"
} }
@@ -486,7 +465,7 @@ load_acl() {
[ -n "$tcp_port" ] && { [ -n "$tcp_port" ] && {
if [ -n "${tcp_proxy_mode}" ]; then if [ -n "${tcp_proxy_mode}" ]; then
msg2="${msg}使用 TCP 节点[$tcp_node_remark]" msg2="${msg}代理 TCP 使用节点[$node_remark]"
if [ -n "${is_tproxy}" ]; then if [ -n "${is_tproxy}" ]; then
msg2="${msg2}(TPROXY:${tcp_port})" msg2="${msg2}(TPROXY:${tcp_port})"
ipt_tmp=$ipt_m ipt_tmp=$ipt_m
@@ -501,7 +480,7 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $black_set_name) $(REDIRECT) [ "${use_proxy_list}" = "1" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $black_set_name) $(REDIRECT)
[ "${use_gfw_list}" = "1" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $gfw_set_name) $(REDIRECT) [ "${use_gfw_list}" = "1" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $gfw_set_name) $(REDIRECT)
[ "${chn_list}" != "0" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $IPSET_CHN) $(get_jump_ipt ${chn_list}) [ "${chn_list}" != "0" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $IPSET_CHN) $(get_jump_ipt ${chn_list})
[ "${use_shunt_tcp}" = "1" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $shunt_set_name) $(REDIRECT) [ "${use_shunt_node}" = "1" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(dst $shunt_set_name) $(REDIRECT)
[ "${tcp_proxy_mode}" != "disable" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(REDIRECT) [ "${tcp_proxy_mode}" != "disable" ] && $ipt_n -A PSW $(comment "$remarks") -p icmp ${_ipt_source} $(REDIRECT)
} }
@@ -510,7 +489,7 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $black6_set_name) $(REDIRECT) 2>/dev/null [ "${use_proxy_list}" = "1" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $black6_set_name) $(REDIRECT) 2>/dev/null
[ "${use_gfw_list}" = "1" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $gfw6_set_name) $(REDIRECT) 2>/dev/null [ "${use_gfw_list}" = "1" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $gfw6_set_name) $(REDIRECT) 2>/dev/null
[ "${chn_list}" != "0" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list}) 2>/dev/null [ "${chn_list}" != "0" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list}) 2>/dev/null
[ "${use_shunt_tcp}" = "1" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $shunt6_set_name) $(REDIRECT) 2>/dev/null [ "${use_shunt_node}" = "1" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(dst $shunt6_set_name) $(REDIRECT) 2>/dev/null
[ "${tcp_proxy_mode}" != "disable" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(REDIRECT) 2>/dev/null [ "${tcp_proxy_mode}" != "disable" ] && $ip6t_n -A PSW $(comment "$remarks") -p ipv6-icmp ${_ipt_source} $(REDIRECT) 2>/dev/null
} }
@@ -518,7 +497,7 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $black_set_name) ${ipt_j}" [ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $black_set_name) ${ipt_j}"
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $gfw_set_name) ${ipt_j}" [ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $gfw_set_name) ${ipt_j}"
[ "${chn_list}" != "0" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "${ipt_j}")" [ "${chn_list}" != "0" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "${ipt_j}")"
[ "${use_shunt_tcp}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $shunt_set_name) ${ipt_j}" [ "${use_shunt_node}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $shunt_set_name) ${ipt_j}"
[ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "${ipt_j}" [ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_tmp -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "${ipt_j}"
[ -n "${is_tproxy}" ] && $ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY) [ -n "${is_tproxy}" ] && $ipt_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY)
@@ -527,7 +506,7 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $black6_set_name) -j PSW_RULE" 2>/dev/null [ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $black6_set_name) -j PSW_RULE" 2>/dev/null
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $gfw6_set_name) -j PSW_RULE" 2>/dev/null [ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $gfw6_set_name) -j PSW_RULE" 2>/dev/null
[ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j PSW_RULE")" 2>/dev/null [ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j PSW_RULE")" 2>/dev/null
[ "${use_shunt_tcp}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $shunt6_set_name) -j PSW_RULE" 2>/dev/null [ "${use_shunt_node}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "$(dst $shunt6_set_name) -j PSW_RULE" 2>/dev/null
[ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "-j PSW_RULE" 2>/dev/null [ "${tcp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source}" $tcp_redir_ports "-j PSW_RULE" 2>/dev/null
$ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY) 2>/dev/null $ip6t_m -A PSW $(comment "$remarks") -p tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY) 2>/dev/null
} }
@@ -542,14 +521,14 @@ load_acl() {
[ -n "$udp_port" ] && { [ -n "$udp_port" ] && {
if [ -n "${udp_proxy_mode}" ]; then if [ -n "${udp_proxy_mode}" ]; then
msg2="${msg}使用 UDP 节点[$udp_node_remark]" msg2="${msg}代理 UDP 使用节点[$node_remark]"
msg2="${msg2}(TPROXY:${udp_port})" msg2="${msg2}(TPROXY:${udp_port})"
[ "${use_fakedns}" = "1" ] && $ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source} -d $FAKE_IP -j PSW_RULE [ "${use_fakedns}" = "1" ] && $ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source} -d $FAKE_IP -j PSW_RULE
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $black_set_name) -j PSW_RULE" [ "${use_proxy_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $black_set_name) -j PSW_RULE"
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $gfw_set_name) -j PSW_RULE" [ "${use_gfw_list}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $gfw_set_name) -j PSW_RULE"
[ "${chn_list}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "-j PSW_RULE")" [ "${chn_list}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $IPSET_CHN) $(get_jump_ipt ${chn_list} "-j PSW_RULE")"
[ "${use_shunt_udp}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $shunt_set_name) -j PSW_RULE" [ "${use_shunt_node}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $shunt_set_name) -j PSW_RULE"
[ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "-j PSW_RULE" [ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "-j PSW_RULE"
$ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source} $(REDIRECT $udp_port TPROXY) $ipt_m -A PSW $(comment "$remarks") -p udp ${_ipt_source} $(REDIRECT $udp_port TPROXY)
@@ -558,7 +537,7 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $black6_set_name) -j PSW_RULE" 2>/dev/null [ "${use_proxy_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $black6_set_name) -j PSW_RULE" 2>/dev/null
[ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $gfw6_set_name) -j PSW_RULE" 2>/dev/null [ "${use_gfw_list}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $gfw6_set_name) -j PSW_RULE" 2>/dev/null
[ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j PSW_RULE")" 2>/dev/null [ "${chn_list}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $IPSET_CHN6) $(get_jump_ipt ${chn_list} "-j PSW_RULE")" 2>/dev/null
[ "${use_shunt_udp}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $shunt6_set_name) -j PSW_RULE" 2>/dev/null [ "${use_shunt_node}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "$(dst $shunt6_set_name) -j PSW_RULE" 2>/dev/null
[ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "-j PSW_RULE" 2>/dev/null [ "${udp_proxy_mode}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source}" $udp_redir_ports "-j PSW_RULE" 2>/dev/null
$ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source} $(REDIRECT $udp_port TPROXY) 2>/dev/null $ip6t_m -A PSW $(comment "$remarks") -p udp ${_ipt_source} $(REDIRECT $udp_port TPROXY) 2>/dev/null
} }
@@ -571,8 +550,8 @@ load_acl() {
$ipt_m -A PSW $(comment "$remarks") ${_ipt_source} -p udp -j RETURN $ipt_m -A PSW $(comment "$remarks") ${_ipt_source} -p udp -j RETURN
unset ipt_tmp ipt_j _ipt_source msg msg2 _ipv4 unset ipt_tmp ipt_j _ipt_source msg msg2 _ipv4
done done
unset enabled sid remarks sources use_global_config use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode dns_redirect_port tcp_no_redir_ports udp_no_redir_ports tcp_proxy_drop_ports udp_proxy_drop_ports tcp_redir_ports udp_redir_ports tcp_node udp_node interface unset enabled sid remarks sources use_global_config use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode dns_redirect_port tcp_no_redir_ports udp_no_redir_ports tcp_proxy_drop_ports udp_proxy_drop_ports tcp_redir_ports udp_redir_ports node interface
unset tcp_port udp_port tcp_node_remark udp_node_remark _acl_list use_shunt_tcp use_shunt_udp dns_redirect use_fakedns unset tcp_port udp_port node_remark _acl_list use_shunt_node dns_redirect use_fakedns
done done
} }
@@ -605,7 +584,7 @@ load_acl() {
local DNS_REDIRECT local DNS_REDIRECT
[ $(config_t_get global dns_redirect "1") = "1" ] && DNS_REDIRECT=53 [ $(config_t_get global dns_redirect "1") = "1" ] && DNS_REDIRECT=53
if ([ -n "$TCP_NODE" ] && [ -n "${TCP_PROXY_MODE}" ]) || ([ -n "$UDP_NODE" ] && [ -n "${UDP_PROXY_MODE}" ]); then if [ -n "$NODE" ] && ([ -n "${TCP_PROXY_MODE}" ] || [ -n "${UDP_PROXY_MODE}" ]); then
[ -n "${DNS_REDIRECT_PORT}" ] && DNS_REDIRECT=${DNS_REDIRECT_PORT} [ -n "${DNS_REDIRECT_PORT}" ] && DNS_REDIRECT=${DNS_REDIRECT_PORT}
else else
[ -n "${DIRECT_DNSMASQ_PORT}" ] && DNS_REDIRECT=${DIRECT_DNSMASQ_PORT} [ -n "${DIRECT_DNSMASQ_PORT}" ] && DNS_REDIRECT=${DIRECT_DNSMASQ_PORT}
@@ -636,14 +615,14 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK6) -j MARK --set-mark 88" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK6) -j MARK --set-mark 88"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_GFW6) -j MARK --set-mark 88" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_GFW6) -j MARK --set-mark 88"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT6) -j MARK --set-mark 88" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT6) -j MARK --set-mark 88"
[ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "-j MARK --set-mark 88" [ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
} }
[ "${USE_FAKEDNS}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "-d $FAKE_IP -j MARK --set-mark 88" [ "${USE_FAKEDNS}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "-d $FAKE_IP -j MARK --set-mark 88"
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS $(dst $IPSET_SHUNT) "-j MARK --set-mark 88" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS $(dst $IPSET_SHUNT) "-j MARK --set-mark 88"
[ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "-j MARK --set-mark 88" [ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p tcp" $TCP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]" echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]"
} }
@@ -654,14 +633,14 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK6) -j MARK --set-mark 88" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK6) -j MARK --set-mark 88"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_GFW6) -j MARK --set-mark 88" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_GFW6) -j MARK --set-mark 88"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT6) -j MARK --set-mark 88" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT6) -j MARK --set-mark 88"
[ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "-j MARK --set-mark 88" [ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
} }
[ "${USE_FAKEDNS}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "-d $FAKE_IP -j MARK --set-mark 88" [ "${USE_FAKEDNS}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "-d $FAKE_IP -j MARK --set-mark 88"
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88"
[ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "-j MARK --set-mark 88" [ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]" echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]"
} }
@@ -674,18 +653,18 @@ load_acl() {
# 加载TCP默认代理模式 # 加载TCP默认代理模式
if [ -n "${TCP_PROXY_MODE}" ]; then if [ -n "${TCP_PROXY_MODE}" ]; then
[ -n "$TCP_NODE" ] && { [ -n "$NODE" ] && {
if [ "$(config_get_type $TCP_NODE)" = "socks" ]; then if [ "$(config_get_type $NODE)" = "socks" ]; then
msg2="${msg}使用 TCP 节点[Socks 配置($(config_n_get $TCP_NODE port) 端口)]" msg2="${msg}代理 TCP 使用节点[Socks 配置($(config_n_get $NODE port) 端口)]"
else else
msg2="${msg}使用 TCP 节点[$(config_n_get $TCP_NODE remarks)]" msg2="${msg}代理 TCP 使用节点[$(config_n_get $NODE remarks)]"
fi fi
if [ -n "${is_tproxy}" ]; then if [ -n "${is_tproxy}" ]; then
msg2="${msg2}(TPROXY:${TCP_REDIR_PORT})" msg2="${msg2}(TPROXY:${REDIR_PORT})"
ipt_j="-j PSW_RULE" ipt_j="-j PSW_RULE"
else else
msg2="${msg2}(REDIRECT:${TCP_REDIR_PORT})" msg2="${msg2}(REDIRECT:${REDIR_PORT})"
ipt_j="$(REDIRECT $TCP_REDIR_PORT)" ipt_j="$(REDIRECT $REDIR_PORT)"
fi fi
[ "$accept_icmp" = "1" ] && { [ "$accept_icmp" = "1" ] && {
@@ -693,7 +672,7 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_BLACK) $(REDIRECT) [ "${USE_PROXY_LIST}" = "1" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_BLACK) $(REDIRECT)
[ "${USE_GFW_LIST}" = "1" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_GFW) $(REDIRECT) [ "${USE_GFW_LIST}" = "1" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_GFW) $(REDIRECT)
[ "${CHN_LIST}" != "0" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST}) [ "${CHN_LIST}" != "0" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST})
[ "${USE_SHUNT_TCP}" = "1" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_SHUNT) $(REDIRECT) [ "${USE_SHUNT_NODE}" = "1" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(dst $IPSET_SHUNT) $(REDIRECT)
[ "${TCP_PROXY_MODE}" != "disable" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(REDIRECT) [ "${TCP_PROXY_MODE}" != "disable" ] && $ipt_n -A PSW $(comment "默认") -p icmp $(REDIRECT)
} }
@@ -702,7 +681,7 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_BLACK6) $(REDIRECT) [ "${USE_PROXY_LIST}" = "1" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_BLACK6) $(REDIRECT)
[ "${USE_GFW_LIST}" = "1" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_GFW6) $(REDIRECT) [ "${USE_GFW_LIST}" = "1" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_GFW6) $(REDIRECT)
[ "${CHN_LIST}" != "0" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST}) [ "${CHN_LIST}" != "0" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST})
[ "${USE_SHUNT_TCP}" = "1" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_SHUNT6) $(REDIRECT) [ "${USE_SHUNT_NODE}" = "1" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(dst $IPSET_SHUNT6) $(REDIRECT)
[ "${TCP_PROXY_MODE}" != "disable" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(REDIRECT) [ "${TCP_PROXY_MODE}" != "disable" ] && $ip6t_n -A PSW $(comment "默认") -p ipv6-icmp $(REDIRECT)
} }
@@ -710,18 +689,18 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK) ${ipt_j}" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK) ${ipt_j}"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW) ${ipt_j}" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW) ${ipt_j}"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "${ipt_j}")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "${ipt_j}")"
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT) ${ipt_j}" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT) ${ipt_j}"
[ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "${ipt_j}" [ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_tmp -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "${ipt_j}"
[ -n "${is_tproxy}" ]&& $ipt_tmp -A PSW $(comment "默认") -p tcp $(REDIRECT $TCP_REDIR_PORT TPROXY) [ -n "${is_tproxy}" ]&& $ipt_tmp -A PSW $(comment "默认") -p tcp $(REDIRECT $REDIR_PORT TPROXY)
[ "$PROXY_IPV6" = "1" ] && { [ "$PROXY_IPV6" = "1" ] && {
[ "${USE_FAKEDNS}" = "1" ] && $ip6t_m -A PSW $(comment "默认") -p tcp -d $FAKE_IP_6 -j PSW_RULE [ "${USE_FAKEDNS}" = "1" ] && $ip6t_m -A PSW $(comment "默认") -p tcp -d $FAKE_IP_6 -j PSW_RULE
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
[ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "-j PSW_RULE" [ "${TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p tcp" $TCP_REDIR_PORTS "-j PSW_RULE"
$ip6t_m -A PSW $(comment "默认") -p tcp $(REDIRECT $TCP_REDIR_PORT TPROXY) $ip6t_m -A PSW $(comment "默认") -p tcp $(REDIRECT $REDIR_PORT TPROXY)
} }
echolog " - ${msg2}" echolog " - ${msg2}"
@@ -733,29 +712,29 @@ load_acl() {
# 加载UDP默认代理模式 # 加载UDP默认代理模式
if [ -n "${UDP_PROXY_MODE}" ]; then if [ -n "${UDP_PROXY_MODE}" ]; then
[ -n "$UDP_NODE" ] || [ "$TCP_UDP" = "1" ] && { [ -n "$NODE" ] && {
if [ "$(config_get_type $UDP_NODE)" = "socks" ]; then if [ "$(config_get_type $NODE)" = "socks" ]; then
msg2="${msg}使用 UDP 节点[Socks 配置($(config_n_get $UDP_NODE port) 端口)](TPROXY:${UDP_REDIR_PORT})" msg2="${msg}代理 UDP 使用节点[Socks 配置($(config_n_get $NODE port) 端口)](TPROXY:${REDIR_PORT})"
else else
msg2="${msg}使用 UDP 节点[$(config_n_get $UDP_NODE remarks)](TPROXY:${UDP_REDIR_PORT})" msg2="${msg}代理 UDP 使用节点[$(config_n_get $NODE remarks)](TPROXY:${REDIR_PORT})"
fi fi
[ "${USE_FAKEDNS}" = "1" ] && $ipt_m -A PSW $(comment "默认") -p udp -d $FAKE_IP -j PSW_RULE [ "${USE_FAKEDNS}" = "1" ] && $ipt_m -A PSW $(comment "默认") -p udp -d $FAKE_IP -j PSW_RULE
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK) -j PSW_RULE" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK) -j PSW_RULE"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW) -j PSW_RULE" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW) -j PSW_RULE"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT) -j PSW_RULE" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT) -j PSW_RULE"
[ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "-j PSW_RULE" [ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "-j PSW_RULE"
$ipt_m -A PSW $(comment "默认") -p udp $(REDIRECT $UDP_REDIR_PORT TPROXY) $ipt_m -A PSW $(comment "默认") -p udp $(REDIRECT $REDIR_PORT TPROXY)
[ "$PROXY_IPV6" = "1" ] && { [ "$PROXY_IPV6" = "1" ] && {
[ "${USE_FAKEDNS}" = "1" ] && $ip6t_m -A PSW $(comment "默认") -p udp -d $FAKE_IP_6 -j PSW_RULE [ "${USE_FAKEDNS}" = "1" ] && $ip6t_m -A PSW $(comment "默认") -p udp -d $FAKE_IP_6 -j PSW_RULE
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
[ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "-j PSW_RULE" [ "${UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW $(comment "默认") -p udp" $UDP_REDIR_PORTS "-j PSW_RULE"
$ip6t_m -A PSW $(comment "默认") -p udp $(REDIRECT $UDP_REDIR_PORT TPROXY) $ip6t_m -A PSW $(comment "默认") -p udp $(REDIRECT $REDIR_PORT TPROXY)
} }
echolog " - ${msg2}" echolog " - ${msg2}"
@@ -909,18 +888,14 @@ add_firewall_rule() {
cat $RULES_PATH/chnroute6 | tr -s '\n' | grep -v "^#" | sed -e "/^$/d" | sed -e "s/^/add $IPSET_CHN6 &/g" -e "s/$/ timeout 0/g" | ipset -! -R cat $RULES_PATH/chnroute6 | tr -s '\n' | grep -v "^#" | sed -e "/^$/d" | sed -e "s/^/add $IPSET_CHN6 &/g" -e "s/$/ timeout 0/g" | ipset -! -R
#导入规则列表、分流规则中的IP列表 #导入规则列表、分流规则中的IP列表
local USE_SHUNT_NODE=0
local USE_PROXY_LIST_ALL=${USE_PROXY_LIST} local USE_PROXY_LIST_ALL=${USE_PROXY_LIST}
local USE_DIRECT_LIST_ALL=${USE_DIRECT_LIST} local USE_DIRECT_LIST_ALL=${USE_DIRECT_LIST}
local USE_BLOCK_LIST_ALL=${USE_BLOCK_LIST} local USE_BLOCK_LIST_ALL=${USE_BLOCK_LIST}
local _TCP_NODE=$(config_t_get global tcp_node) USE_SHUNT_NODE=0
local _UDP_NODE=$(config_t_get global udp_node)
USE_GEOVIEW=$(config_t_get global_rules enable_geoview) USE_GEOVIEW=$(config_t_get global_rules enable_geoview)
[ -z "$(first_type $(config_t_get global_app geoview_file) geoview)" ] && USE_GEOVIEW=0 [ -z "$(first_type $(config_t_get global_app geoview_file) geoview)" ] && USE_GEOVIEW=0
[ -n "$_TCP_NODE" ] && [ "$(config_n_get $_TCP_NODE protocol)" = "_shunt" ] && USE_SHUNT_TCP=1 && USE_SHUNT_NODE=1 [ -n "$NODE" ] && [ "$(config_n_get $NODE protocol)" = "_shunt" ] && USE_SHUNT_NODE=1
[ -n "$_UDP_NODE" ] && [ "$(config_n_get $_UDP_NODE protocol)" = "_shunt" ] && USE_SHUNT_UDP=1 && USE_SHUNT_NODE=1
[ "$_UDP_NODE" = "tcp" ] && USE_SHUNT_UDP=$USE_SHUNT_TCP
for acl_section in $(uci show ${CONFIG} | grep "=acl_rule" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do for acl_section in $(uci show ${CONFIG} | grep "=acl_rule" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do
[ "$(config_n_get $acl_section enabled)" != "1" ] && continue [ "$(config_n_get $acl_section enabled)" != "1" ] && continue
@@ -929,10 +904,6 @@ add_firewall_rule() {
[ "$(config_n_get $acl_section use_proxy_list 1)" = "1" ] && USE_DIRECT_LIST_ALL=1 [ "$(config_n_get $acl_section use_proxy_list 1)" = "1" ] && USE_DIRECT_LIST_ALL=1
[ "$(config_n_get $acl_section use_block_list 1)" = "1" ] && USE_BLOCK_LIST_ALL=1 [ "$(config_n_get $acl_section use_block_list 1)" = "1" ] && USE_BLOCK_LIST_ALL=1
} }
for _node in $(config_n_get $acl_section tcp_node) $(config_n_get $acl_section udp_node); do
local node_protocol=$(config_n_get $_node protocol)
[ "$node_protocol" = "_shunt" ] && { USE_SHUNT_NODE=1; break; }
done
done done
#直连列表 #直连列表
@@ -981,12 +952,8 @@ add_firewall_rule() {
[ "$USE_SHUNT_NODE" = "1" ] && { [ "$USE_SHUNT_NODE" = "1" ] && {
local GEOIP_CODE="" local GEOIP_CODE=""
local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}') local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
local shunt_group shunt_id local shunt_group=$(config_n_get $NODE shunt_group)
if [ "${USE_SHUNT_TCP}" = "1" ]; then local shunt_id
shunt_group=$(config_n_get $_TCP_NODE shunt_group)
elif [ "${USE_SHUNT_UDP}" = "1" ]; then
shunt_group=$(config_n_get $_UDP_NODE shunt_group)
fi
for shunt_id in $shunt_ids; do for shunt_id in $shunt_ids; do
[ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue [ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue
config_n_get $shunt_id ip_list | tr -s "\r\n" "\n" | grep -v "^#" | sed -e "/^$/d" | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | sed -e "s/^/add $IPSET_SHUNT &/g" -e "s/$/ timeout 0/g" | ipset -! -R config_n_get $shunt_id ip_list | tr -s "\r\n" "\n" | grep -v "^#" | sed -e "/^$/d" | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | sed -e "s/^/add $IPSET_SHUNT &/g" -e "s/$/ timeout 0/g" | ipset -! -R
@@ -1197,15 +1164,13 @@ add_firewall_rule() {
ip -6 rule add fwmark ${FWMARK} table 999 priority 999 ip -6 rule add fwmark ${FWMARK} table 999 priority 999
ip -6 route add local ::/0 dev lo table 999 ip -6 route add local ::/0 dev lo table 999
[ "$TCP_UDP" = "1" ] && [ -z "$UDP_NODE" ] && UDP_NODE=$TCP_NODE
[ "$ENABLED_DEFAULT_ACL" = 1 ] && { [ "$ENABLED_DEFAULT_ACL" = 1 ] && {
local ipt_tmp=$ipt_n local ipt_tmp=$ipt_n
if [ -n "${is_tproxy}" ]; then if [ -n "${is_tproxy}" ]; then
ipt_tmp=$ipt_m ipt_tmp=$ipt_m
ipt_j="-j PSW_RULE" ipt_j="-j PSW_RULE"
else else
ipt_j="$(REDIRECT $TCP_REDIR_PORT)" ipt_j="$(REDIRECT $REDIR_PORT)"
fi fi
msg="【路由器本机】," msg="【路由器本机】,"
@@ -1231,7 +1196,7 @@ add_firewall_rule() {
fi fi
} }
if ([ -n "$TCP_NODE" ] && [ -n "${LOCALHOST_TCP_PROXY_MODE}" ]) || ([ -n "$UDP_NODE" ] && [ -n "${LOCALHOST_UDP_PROXY_MODE}" ]); then if [ -n "$NODE" ] && ([ -n "${LOCALHOST_TCP_PROXY_MODE}" ] || [ -n "${LOCALHOST_UDP_PROXY_MODE}" ]); then
[ -n "$DNS_REDIRECT_PORT" ] && { [ -n "$DNS_REDIRECT_PORT" ] && {
$ipt_n -A OUTPUT $(comment "PSW_DNS") -p udp -o lo --dport 53 -j REDIRECT --to-ports $DNS_REDIRECT_PORT $ipt_n -A OUTPUT $(comment "PSW_DNS") -p udp -o lo --dport 53 -j REDIRECT --to-ports $DNS_REDIRECT_PORT
$ip6t_n -A OUTPUT $(comment "PSW_DNS") -p udp -o lo --dport 53 -j REDIRECT --to-ports $DNS_REDIRECT_PORT 2>/dev/null $ip6t_n -A OUTPUT $(comment "PSW_DNS") -p udp -o lo --dport 53 -j REDIRECT --to-ports $DNS_REDIRECT_PORT 2>/dev/null
@@ -1246,7 +1211,7 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88"
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "-j MARK --set-mark 88" [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p tcp" $TCP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]" echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]"
} }
@@ -1256,14 +1221,14 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_BLACK) -j MARK --set-mark 88"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_GFW) -j MARK --set-mark 88"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j MARK --set-mark 88")"
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "$(dst $IPSET_SHUNT) -j MARK --set-mark 88"
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "-j MARK --set-mark 88" [ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_PROXY_DROP_PORTS "-j MARK --set-mark 88"
echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]" echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]"
} }
} }
# 加载路由器自身代理 TCP # 加载路由器自身代理 TCP
if [ -n "$TCP_NODE" ]; then if [ -n "$NODE" ]; then
_proxy_tcp_access() { _proxy_tcp_access() {
[ -n "${2}" ] || return 0 [ -n "${2}" ] || return 0
if echo "${2}" | grep -q -v ':'; then if echo "${2}" | grep -q -v ':'; then
@@ -1273,10 +1238,10 @@ add_firewall_rule() {
return 0 return 0
} }
if [ -z "${is_tproxy}" ]; then if [ -z "${is_tproxy}" ]; then
$ipt_n -I PSW_OUTPUT -p tcp -d ${2} --dport ${3} $(REDIRECT $TCP_REDIR_PORT) $ipt_n -I PSW_OUTPUT -p tcp -d ${2} --dport ${3} $(REDIRECT $REDIR_PORT)
else else
$ipt_m -I PSW_OUTPUT -p tcp -d ${2} --dport ${3} -j PSW_RULE $ipt_m -I PSW_OUTPUT -p tcp -d ${2} --dport ${3} -j PSW_RULE
$ipt_m -I PSW $(comment "本机") -p tcp -i lo -d ${2} --dport ${3} $(REDIRECT $TCP_REDIR_PORT TPROXY) $ipt_m -I PSW $(comment "本机") -p tcp -i lo -d ${2} --dport ${3} $(REDIRECT $REDIR_PORT TPROXY)
fi fi
echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 TCP 转发链" echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 TCP 转发链"
else else
@@ -1286,7 +1251,7 @@ add_firewall_rule() {
return 0 return 0
} }
$ip6t_m -I PSW_OUTPUT -p tcp -d ${2} --dport ${3} -j PSW_RULE $ip6t_m -I PSW_OUTPUT -p tcp -d ${2} --dport ${3} -j PSW_RULE
$ip6t_m -I PSW $(comment "本机") -p tcp -i lo -d ${2} --dport ${3} $(REDIRECT $TCP_REDIR_PORT TPROXY) $ip6t_m -I PSW $(comment "本机") -p tcp -i lo -d ${2} --dport ${3} $(REDIRECT $REDIR_PORT TPROXY)
echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 TCP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!" echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 TCP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!"
fi fi
} }
@@ -1298,7 +1263,7 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_BLACK) $(REDIRECT) [ "${USE_PROXY_LIST}" = "1" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_BLACK) $(REDIRECT)
[ "${USE_GFW_LIST}" = "1" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_GFW) $(REDIRECT) [ "${USE_GFW_LIST}" = "1" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_GFW) $(REDIRECT)
[ "${CHN_LIST}" != "0" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST}) [ "${CHN_LIST}" != "0" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST})
[ "${USE_SHUNT_TCP}" = "1" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_SHUNT) $(REDIRECT) [ "${USE_SHUNT_NODE}" = "1" ] && $ipt_n -A PSW_OUTPUT -p icmp $(dst $IPSET_SHUNT) $(REDIRECT)
[ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && $ipt_n -A PSW_OUTPUT -p icmp $(REDIRECT) [ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && $ipt_n -A PSW_OUTPUT -p icmp $(REDIRECT)
} }
@@ -1308,7 +1273,7 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_BLACK6) $(REDIRECT) [ "${USE_PROXY_LIST}" = "1" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_BLACK6) $(REDIRECT)
[ "${USE_GFW_LIST}" = "1" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_GFW6) $(REDIRECT) [ "${USE_GFW_LIST}" = "1" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_GFW6) $(REDIRECT)
[ "${CHN_LIST}" != "0" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST}) [ "${CHN_LIST}" != "0" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST})
[ "${USE_SHUNT_TCP}" = "1" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_SHUNT6) $(REDIRECT) [ "${USE_SHUNT_NODE}" = "1" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(dst $IPSET_SHUNT6) $(REDIRECT)
[ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(REDIRECT) [ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && $ip6t_n -A PSW_OUTPUT -p ipv6-icmp $(REDIRECT)
} }
@@ -1317,9 +1282,9 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK) ${ipt_j}" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK) ${ipt_j}"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW) ${ipt_j}" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW) ${ipt_j}"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "${ipt_j}")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "${ipt_j}")"
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT) ${ipt_j}" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT) ${ipt_j}"
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "${ipt_j}" [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_tmp -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "${ipt_j}"
[ -n "${is_tproxy}" ] && $ipt_m -A PSW $(comment "本机") -p tcp -i lo $(REDIRECT $TCP_REDIR_PORT TPROXY) [ -n "${is_tproxy}" ] && $ipt_m -A PSW $(comment "本机") -p tcp -i lo $(REDIRECT $REDIR_PORT TPROXY)
} }
[ -z "${is_tproxy}" ] && $ipt_n -A OUTPUT -p tcp -j PSW_OUTPUT [ -z "${is_tproxy}" ] && $ipt_n -A OUTPUT -p tcp -j PSW_OUTPUT
[ -n "${is_tproxy}" ] && { [ -n "${is_tproxy}" ] && {
@@ -1333,9 +1298,9 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
[ "${USE_SHUNT_TCP}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "-j PSW_RULE" [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p tcp" $TCP_REDIR_PORTS "-j PSW_RULE"
$ip6t_m -A PSW $(comment "本机") -p tcp -i lo $(REDIRECT $TCP_REDIR_PORT TPROXY) $ip6t_m -A PSW $(comment "本机") -p tcp -i lo $(REDIRECT $REDIR_PORT TPROXY)
} }
$ip6t_m -A PSW $(comment "本机") -p tcp -i lo -j RETURN $ip6t_m -A PSW $(comment "本机") -p tcp -i lo -j RETURN
insert_rule_before "$ip6t_m" "OUTPUT" "mwan3" "$(comment mangle-OUTPUT-PSW) -p tcp -j PSW_OUTPUT" insert_rule_before "$ip6t_m" "OUTPUT" "mwan3" "$(comment mangle-OUTPUT-PSW) -p tcp -j PSW_OUTPUT"
@@ -1343,7 +1308,7 @@ add_firewall_rule() {
fi fi
# 加载路由器自身代理 UDP # 加载路由器自身代理 UDP
if [ -n "$UDP_NODE" ] || [ "$TCP_UDP" = "1" ]; then if [ -n "$NODE" ]; then
_proxy_udp_access() { _proxy_udp_access() {
[ -n "${2}" ] || return 0 [ -n "${2}" ] || return 0
if echo "${2}" | grep -q -v ':'; then if echo "${2}" | grep -q -v ':'; then
@@ -1353,7 +1318,7 @@ add_firewall_rule() {
return 0 return 0
} }
$ipt_m -I PSW_OUTPUT -p udp -d ${2} --dport ${3} -j PSW_RULE $ipt_m -I PSW_OUTPUT -p udp -d ${2} --dport ${3} -j PSW_RULE
$ipt_m -I PSW $(comment "本机") -p udp -i lo -d ${2} --dport ${3} $(REDIRECT $UDP_REDIR_PORT TPROXY) $ipt_m -I PSW $(comment "本机") -p udp -i lo -d ${2} --dport ${3} $(REDIRECT $REDIR_PORT TPROXY)
echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 UDP 转发链" echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 UDP 转发链"
else else
ipset -q test $IPSET_LAN6 ${2} ipset -q test $IPSET_LAN6 ${2}
@@ -1362,7 +1327,7 @@ add_firewall_rule() {
return 0 return 0
} }
$ip6t_m -I PSW_OUTPUT -p udp -d ${2} --dport ${3} -j PSW_RULE $ip6t_m -I PSW_OUTPUT -p udp -d ${2} --dport ${3} -j PSW_RULE
$ip6t_m -I PSW $(comment "本机") -p udp -i lo -d ${2} --dport ${3} $(REDIRECT $UDP_REDIR_PORT TPROXY) $ip6t_m -I PSW $(comment "本机") -p udp -i lo -d ${2} --dport ${3} $(REDIRECT $REDIR_PORT TPROXY)
echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 UDP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!" echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 UDP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!"
fi fi
} }
@@ -1372,9 +1337,9 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK) -j PSW_RULE" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK) -j PSW_RULE"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW) -j PSW_RULE" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW) -j PSW_RULE"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT) -j PSW_RULE" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT) -j PSW_RULE"
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "-j PSW_RULE" [ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ipt_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "-j PSW_RULE"
$ipt_m -A PSW $(comment "本机") -p udp -i lo $(REDIRECT $UDP_REDIR_PORT TPROXY) $ipt_m -A PSW $(comment "本机") -p udp -i lo $(REDIRECT $REDIR_PORT TPROXY)
} }
$ipt_m -A PSW $(comment "本机") -p udp -i lo -j RETURN $ipt_m -A PSW $(comment "本机") -p udp -i lo -j RETURN
insert_rule_before "$ipt_m" "OUTPUT" "mwan3" "$(comment mangle-OUTPUT-PSW) -p udp -j PSW_OUTPUT" insert_rule_before "$ipt_m" "OUTPUT" "mwan3" "$(comment mangle-OUTPUT-PSW) -p udp -j PSW_OUTPUT"
@@ -1385,9 +1350,9 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE" [ "${USE_PROXY_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_BLACK6) -j PSW_RULE"
[ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE" [ "${USE_GFW_LIST}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_GFW6) -j PSW_RULE"
[ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")" [ "${CHN_LIST}" != "0" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_CHN6) $(get_jump_ipt ${CHN_LIST} "-j PSW_RULE")"
[ "${USE_SHUNT_UDP}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE" [ "${USE_SHUNT_NODE}" = "1" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "$(dst $IPSET_SHUNT6) -j PSW_RULE"
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "-j PSW_RULE" [ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && add_port_rules "$ip6t_m -A PSW_OUTPUT -p udp" $UDP_REDIR_PORTS "-j PSW_RULE"
$ip6t_m -A PSW $(comment "本机") -p udp -i lo $(REDIRECT $UDP_REDIR_PORT TPROXY) $ip6t_m -A PSW $(comment "本机") -p udp -i lo $(REDIRECT $REDIR_PORT TPROXY)
} }
$ip6t_m -A PSW $(comment "本机") -p udp -i lo -j RETURN $ip6t_m -A PSW $(comment "本机") -p udp -i lo -j RETURN
insert_rule_before "$ip6t_m" "OUTPUT" "mwan3" "$(comment mangle-OUTPUT-PSW) -p udp -j PSW_OUTPUT" insert_rule_before "$ip6t_m" "OUTPUT" "mwan3" "$(comment mangle-OUTPUT-PSW) -p udp -j PSW_OUTPUT"
@@ -42,9 +42,6 @@ NFTSET_WHITE6_STATIC="${NFTSET_WHITE6}_static"
NFTSET_BLOCK6_STATIC="${NFTSET_BLOCK6}_static" NFTSET_BLOCK6_STATIC="${NFTSET_BLOCK6}_static"
NFTSET_SHUNT6_STATIC="${NFTSET_SHUNT6}_static" NFTSET_SHUNT6_STATIC="${NFTSET_SHUNT6}_static"
USE_SHUNT_TCP=0
USE_SHUNT_UDP=0
# ASCII code for PSW1.Use whatever,just not the same. # ASCII code for PSW1.Use whatever,just not the same.
FWMARK="0x50535731" FWMARK="0x50535731"
@@ -291,41 +288,28 @@ load_acl() {
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS [ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
[ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS [ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
[ -n "$(get_cache_var "ACL_${sid}_tcp_node")" ] && tcp_node=$(get_cache_var "ACL_${sid}_tcp_node") [ -n "$(get_cache_var "ACL_${sid}_node")" ] && node=$(get_cache_var "ACL_${sid}_node")
[ -n "$(get_cache_var "ACL_${sid}_tcp_redir_port")" ] && tcp_port=$(get_cache_var "ACL_${sid}_tcp_redir_port") [ -n "$(get_cache_var "ACL_${sid}_redir_port")" ] && {
[ -n "$(get_cache_var "ACL_${sid}_udp_node")" ] && udp_node=$(get_cache_var "ACL_${sid}_udp_node") tcp_port=$(get_cache_var "ACL_${sid}_redir_port")
[ -n "$(get_cache_var "ACL_${sid}_udp_redir_port")" ] && udp_port=$(get_cache_var "ACL_${sid}_udp_redir_port") udp_port=$tcp_port
}
[ -n "$(get_cache_var "ACL_${sid}_dns_port")" ] && dns_redirect_port=$(get_cache_var "ACL_${sid}_dns_port") [ -n "$(get_cache_var "ACL_${sid}_dns_port")" ] && dns_redirect_port=$(get_cache_var "ACL_${sid}_dns_port")
[ -n "$(get_cache_var "ACL_${sid}_fakedns")" ] && use_fakedns=$(get_cache_var "ACL_${sid}_fakedns") [ -n "$(get_cache_var "ACL_${sid}_fakedns")" ] && use_fakedns=$(get_cache_var "ACL_${sid}_fakedns")
[ -n "$tcp_node" ] && { [ -n "$node" ] && {
if [ "$(config_get_type $tcp_node)" = "socks" ]; then if [ "$(config_get_type $node)" = "socks" ]; then
tcp_node_remark="Socks 配置($(config_n_get $tcp_node port) 端口)" node_remark="Socks 配置($(config_n_get $node port) 端口)"
else else
tcp_node_remark=$(config_n_get $tcp_node remarks) node_remark=$(config_n_get $node remarks)
fi fi
} }
[ -n "$udp_node" ] && { use_shunt_node=0
if [ "$(config_get_type $udp_node)" = "socks" ]; then [ -n "$node" ] && [ "$(config_n_get $node protocol)" = "_shunt" ] && use_shunt_node=1
udp_node_remark="Socks 配置($(config_n_get $udp_node port) 端口)"
else
udp_node_remark=$(config_n_get $udp_node remarks)
fi
}
use_shunt_tcp=0
use_shunt_udp=0
[ -n "$tcp_node" ] && [ "$(config_n_get $tcp_node protocol)" = "_shunt" ] && use_shunt_tcp=1
[ -n "$udp_node" ] && [ "$(config_n_get $udp_node protocol)" = "_shunt" ] && use_shunt_udp=1
[ "${use_global_config}" = "1" ] && { [ "${use_global_config}" = "1" ] && {
if [ "$(config_get_type $TCP_NODE)" = "socks" ]; then if [ "$(config_get_type $NODE)" = "socks" ]; then
tcp_node_remark="Socks 配置($(config_n_get $TCP_NODE port) 端口)" node_remark="Socks 配置($(config_n_get $NODE port) 端口)"
else else
tcp_node_remark=$(config_n_get $TCP_NODE remarks) node_remark=$(config_n_get $NODE remarks)
fi
if [ "$(config_get_type $UDP_NODE)" = "socks" ]; then
udp_node_remark="Socks 配置($(config_n_get $UDP_NODE port) 端口)"
else
udp_node_remark=$(config_n_get $UDP_NODE remarks)
fi fi
use_direct_list=${USE_DIRECT_LIST} use_direct_list=${USE_DIRECT_LIST}
use_proxy_list=${USE_PROXY_LIST} use_proxy_list=${USE_PROXY_LIST}
@@ -334,8 +318,7 @@ load_acl() {
chn_list=${CHN_LIST} chn_list=${CHN_LIST}
tcp_proxy_mode=${TCP_PROXY_MODE} tcp_proxy_mode=${TCP_PROXY_MODE}
udp_proxy_mode=${UDP_PROXY_MODE} udp_proxy_mode=${UDP_PROXY_MODE}
use_shunt_tcp=${USE_SHUNT_TCP} use_shunt_node=${USE_SHUNT_NODE}
use_shunt_udp=${USE_SHUNT_UDP}
dns_redirect_port=${DNS_REDIRECT_PORT} dns_redirect_port=${DNS_REDIRECT_PORT}
black_set_name=${NFTSET_BLACK} black_set_name=${NFTSET_BLACK}
black_set_name_static=${NFTSET_BLACK_STATIC} black_set_name_static=${NFTSET_BLACK_STATIC}
@@ -445,7 +428,7 @@ load_acl() {
gen_nftset $gfw6_set_name ipv6_addr "2d" gen_nftset $gfw6_set_name ipv6_addr "2d"
} }
} }
[ "${use_shunt_tcp}" = "1" ] || [ "${use_shunt_udp}" = "1" ] && { [ "${use_shunt_node}" = "1" ] && {
[ "${use_global_config}" = "0" ] && { [ "${use_global_config}" = "0" ] && {
shunt_set_name="psw_${sid}_shunt" shunt_set_name="psw_${sid}_shunt"
shunt_set_name_static="psw_${sid}_shunt_static" shunt_set_name_static="psw_${sid}_shunt_static"
@@ -458,12 +441,8 @@ load_acl() {
# 预加载分流规则 ip 到 nftset # 预加载分流规则 ip 到 nftset
local GEOIP_CODE="" local GEOIP_CODE=""
local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}') local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
local shunt_group shunt_id local shunt_group=$(config_n_get $node shunt_group)
if [ "${use_shunt_tcp}" = "1" ]; then local shunt_id
shunt_group=$(config_n_get $tcp_node shunt_group)
elif [ "${use_shunt_udp}" = "1" ]; then
shunt_group=$(config_n_get $udp_node shunt_group)
fi
for shunt_id in $shunt_ids; do for shunt_id in $shunt_ids; do
[ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue [ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue
config_n_get $shunt_id ip_list | sed 's/#.*//' | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | insert_nftset $shunt_set_name_static config_n_get $shunt_id ip_list | sed 's/#.*//' | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | insert_nftset $shunt_set_name_static
@@ -492,7 +471,7 @@ load_acl() {
#nft "add rule $NFTABLE_NAME PSW_DNS ip protocol tcp ${_ipt_source} tcp dport 53 counter redirect to :${dns_redirect} comment \"$remarks\"" #nft "add rule $NFTABLE_NAME PSW_DNS ip protocol tcp ${_ipt_source} tcp dport 53 counter redirect to :${dns_redirect} comment \"$remarks\""
nft "add rule $NFTABLE_NAME PSW_DNS meta l4proto udp ${_ipt_source} udp dport 53 counter redirect to :${dns_redirect} comment \"$remarks\"" nft "add rule $NFTABLE_NAME PSW_DNS meta l4proto udp ${_ipt_source} udp dport 53 counter redirect to :${dns_redirect} comment \"$remarks\""
nft "add rule $NFTABLE_NAME PSW_DNS meta l4proto tcp ${_ipt_source} tcp dport 53 counter redirect to :${dns_redirect} comment \"$remarks\"" nft "add rule $NFTABLE_NAME PSW_DNS meta l4proto tcp ${_ipt_source} tcp dport 53 counter redirect to :${dns_redirect} comment \"$remarks\""
[ -z "$(get_cache_var "ACL_${sid}_tcp_default")" ] && echolog " - ${msg}使用与全局配置不相同节点,已将DNS强制重定向到专用 DNS 服务器。" [ -z "$(get_cache_var "ACL_${sid}_default")" ] && echolog " - ${msg}使用与全局配置不相同节点,已将DNS强制重定向到专用 DNS 服务器。"
fi fi
[ -n "$tcp_port" ] || [ -n "$udp_port" ] && { [ -n "$tcp_port" ] || [ -n "$udp_port" ] && {
@@ -511,14 +490,14 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr" "$black6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null [ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr" "$black6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr @$gfw6_set_name counter reject comment \"$remarks\"" 2>/dev/null [ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr @$gfw6_set_name counter reject comment \"$remarks\"" 2>/dev/null
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\"" 2>/dev/null [ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\"" 2>/dev/null
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr" "$shunt6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null [ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip6 daddr" "$shunt6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") counter reject comment \"$remarks\"" 2>/dev/null [ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") counter reject comment \"$remarks\"" 2>/dev/null
} }
[ "${use_fakedns}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr $FAKE_IP counter reject comment \"$remarks\"" [ "${use_fakedns}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr $FAKE_IP counter reject comment \"$remarks\""
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr" "$black_set_name" "counter reject comment \"$remarks\"" [ "${use_proxy_list}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr" "$black_set_name" "counter reject comment \"$remarks\""
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr @$gfw_set_name counter reject comment \"$remarks\"" [ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr @$gfw_set_name counter reject comment \"$remarks\""
[ "${chn_list}" != "0" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\"" [ "${chn_list}" != "0" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\""
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr" "$shunt_set_name" "counter reject comment \"$remarks\"" [ "${use_shunt_node}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") ip daddr" "$shunt_set_name" "counter reject comment \"$remarks\""
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") counter reject comment \"$remarks\"" [ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp ${_ipt_source} $(factor $tcp_proxy_drop_ports "tcp dport") counter reject comment \"$remarks\""
echolog " - ${msg}屏蔽代理 TCP 端口[${tcp_proxy_drop_ports}]" echolog " - ${msg}屏蔽代理 TCP 端口[${tcp_proxy_drop_ports}]"
} }
@@ -529,14 +508,14 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr" "$black6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null [ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr" "$black6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr @$gfw6_set_name counter reject comment \"$remarks\"" 2>/dev/null [ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr @$gfw6_set_name counter reject comment \"$remarks\"" 2>/dev/null
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\"" 2>/dev/null [ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\"" 2>/dev/null
[ "${use_shunt_udp}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr" "$shunt6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null [ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip6 daddr" "$shunt6_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
[ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") counter reject comment \"$remarks\"" 2>/dev/null [ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") counter reject comment \"$remarks\"" 2>/dev/null
} }
[ "${use_fakedns}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr $FAKE_IP counter reject comment \"$remarks\"" 2>/dev/null [ "${use_fakedns}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr $FAKE_IP counter reject comment \"$remarks\"" 2>/dev/null
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr" "$black_set_name" "counter reject comment \"$remarks\"" 2>/dev/null [ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr" "$black_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr @$gfw_set_name counter reject comment \"$remarks\"" 2>/dev/null [ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr @$gfw_set_name counter reject comment \"$remarks\"" 2>/dev/null
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\"" 2>/dev/null [ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "counter reject") comment \"$remarks\"" 2>/dev/null
[ "${use_shunt_udp}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr" "$shunt_set_name" "counter reject comment \"$remarks\"" 2>/dev/null [ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") ip daddr" "$shunt_set_name" "counter reject comment \"$remarks\"" 2>/dev/null
[ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") counter reject comment \"$remarks\"" 2>/dev/null [ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_proxy_drop_ports "udp dport") counter reject comment \"$remarks\"" 2>/dev/null
echolog " - ${msg}屏蔽代理 UDP 端口[${udp_proxy_drop_ports}]" echolog " - ${msg}屏蔽代理 UDP 端口[${udp_proxy_drop_ports}]"
} }
@@ -544,7 +523,7 @@ load_acl() {
[ -n "$tcp_port" ] && { [ -n "$tcp_port" ] && {
if [ -n "${tcp_proxy_mode}" ]; then if [ -n "${tcp_proxy_mode}" ]; then
msg2="${msg}使用 TCP 节点[$tcp_node_remark]" msg2="${msg}代理 TCP 使用节点[$node_remark]"
if [ -n "${is_tproxy}" ]; then if [ -n "${is_tproxy}" ]; then
msg2="${msg2}(TPROXY:${tcp_port})" msg2="${msg2}(TPROXY:${tcp_port})"
nft_chain="PSW_MANGLE" nft_chain="PSW_MANGLE"
@@ -561,7 +540,7 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ${_ipt_source} ip daddr" "$black_set_name" "$(REDIRECT) comment \"$remarks\"" [ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ${_ipt_source} ip daddr" "$black_set_name" "$(REDIRECT) comment \"$remarks\""
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ${_ipt_source} ip daddr @$gfw_set_name $(REDIRECT) comment \"$remarks\"" [ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ${_ipt_source} ip daddr @$gfw_set_name $(REDIRECT) comment \"$remarks\""
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ${_ipt_source} ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list}) comment \"$remarks\"" [ "${chn_list}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ${_ipt_source} ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list}) comment \"$remarks\""
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ${_ipt_source} ip daddr" "$shunt_set_name" "$(REDIRECT) comment \"$remarks\"" [ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ${_ipt_source} ip daddr" "$shunt_set_name" "$(REDIRECT) comment \"$remarks\""
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ${_ipt_source} $(REDIRECT) comment \"$remarks\"" [ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ${_ipt_source} $(REDIRECT) comment \"$remarks\""
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ${_ipt_source} return comment \"$remarks\"" nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ${_ipt_source} return comment \"$remarks\""
} }
@@ -572,7 +551,7 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ${_ipt_source} ip6 daddr" "$black6_set_name" "$(REDIRECT) comment \"$remarks\"" 2>/dev/null [ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ${_ipt_source} ip6 daddr" "$black6_set_name" "$(REDIRECT) comment \"$remarks\"" 2>/dev/null
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ${_ipt_source} ip6 daddr @$gfw6_set_name $(REDIRECT) comment \"$remarks\"" 2>/dev/null [ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ${_ipt_source} ip6 daddr @$gfw6_set_name $(REDIRECT) comment \"$remarks\"" 2>/dev/null
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ${_ipt_source} ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list}) comment \"$remarks\"" 2>/dev/null [ "${chn_list}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ${_ipt_source} ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list}) comment \"$remarks\"" 2>/dev/null
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ${_ipt_source} ip6 daddr" "$shunt6_set_name" "$(REDIRECT) comment \"$remarks\"" 2>/dev/null [ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ${_ipt_source} ip6 daddr" "$shunt6_set_name" "$(REDIRECT) comment \"$remarks\"" 2>/dev/null
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ${_ipt_source} $(REDIRECT) comment \"$remarks\"" 2>/dev/null [ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ${_ipt_source} $(REDIRECT) comment \"$remarks\"" 2>/dev/null
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ${_ipt_source} return comment \"$remarks\"" 2>/dev/null nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ${_ipt_source} return comment \"$remarks\"" 2>/dev/null
} }
@@ -581,7 +560,7 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr" "$black_set_name" "${nft_j} comment \"$remarks\"" [ "${use_proxy_list}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr" "$black_set_name" "${nft_j} comment \"$remarks\""
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr @$gfw_set_name ${nft_j} comment \"$remarks\"" [ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr @$gfw_set_name ${nft_j} comment \"$remarks\""
[ "${chn_list}" != "0" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "${nft_j}") comment \"$remarks\"" [ "${chn_list}" != "0" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "${nft_j}") comment \"$remarks\""
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr" "$shunt_set_name" "${nft_j} comment \"$remarks\"" [ "${use_shunt_node}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip daddr" "$shunt_set_name" "${nft_j} comment \"$remarks\""
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ${nft_j} comment \"$remarks\"" [ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ${nft_j} comment \"$remarks\""
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY4) comment \"$remarks\"" [ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY4) comment \"$remarks\""
@@ -590,7 +569,7 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr" "$black6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null [ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr" "$black6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr @$gfw6_set_name counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null [ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr @$gfw6_set_name counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter jump PSW_RULE") comment \"$remarks\"" 2>/dev/null [ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter jump PSW_RULE") comment \"$remarks\"" 2>/dev/null
[ "${use_shunt_tcp}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr" "$shunt6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null [ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") ip6 daddr" "$shunt6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
[ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null [ "${tcp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(factor $tcp_redir_ports "tcp dport") counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY) comment \"$remarks\"" 2>/dev/null nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp ${_ipt_source} $(REDIRECT $tcp_port TPROXY) comment \"$remarks\"" 2>/dev/null
} }
@@ -605,14 +584,14 @@ load_acl() {
[ -n "$udp_port" ] && { [ -n "$udp_port" ] && {
if [ -n "${udp_proxy_mode}" ]; then if [ -n "${udp_proxy_mode}" ]; then
msg2="${msg}使用 UDP 节点[$udp_node_remark]" msg2="${msg}代理 UDP 使用节点[$node_remark]"
msg2="${msg2}(TPROXY:${udp_port})" msg2="${msg2}(TPROXY:${udp_port})"
[ "${use_fakedns}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} ip daddr $FAKE_IP counter jump PSW_RULE comment \"$remarks\"" [ "${use_fakedns}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} ip daddr $FAKE_IP counter jump PSW_RULE comment \"$remarks\""
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr" "$black_set_name" "counter jump PSW_RULE comment \"$remarks\"" [ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr" "$black_set_name" "counter jump PSW_RULE comment \"$remarks\""
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr @$gfw_set_name counter jump PSW_RULE comment \"$remarks\"" [ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr @$gfw_set_name counter jump PSW_RULE comment \"$remarks\""
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "counter jump PSW_RULE") comment \"$remarks\"" [ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${chn_list} "counter jump PSW_RULE") comment \"$remarks\""
[ "${use_shunt_udp}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr" "$shunt_set_name" "counter jump PSW_RULE comment \"$remarks\"" [ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip daddr" "$shunt_set_name" "counter jump PSW_RULE comment \"$remarks\""
[ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") counter jump PSW_RULE comment \"$remarks\"" [ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") counter jump PSW_RULE comment \"$remarks\""
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(REDIRECT $udp_port TPROXY4) comment \"$remarks\"" nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ${_ipt_source} $(REDIRECT $udp_port TPROXY4) comment \"$remarks\""
@@ -621,7 +600,7 @@ load_acl() {
[ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr" "$black6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null [ "${use_proxy_list}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr" "$black6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
[ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr @$gfw6_set_name counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null [ "${use_gfw_list}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr @$gfw6_set_name counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
[ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter jump PSW_RULE") comment \"$remarks\"" 2>/dev/null [ "${chn_list}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${chn_list} "counter jump PSW_RULE") comment \"$remarks\"" 2>/dev/null
[ "${use_shunt_udp}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr" "$shunt6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null [ "${use_shunt_node}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") ip6 daddr" "$shunt6_set_name" "counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
[ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null [ "${udp_proxy_mode}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(factor $udp_redir_ports "udp dport") counter jump PSW_RULE comment \"$remarks\"" 2>/dev/null
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(REDIRECT $udp_port TPROXY) comment \"$remarks\"" 2>/dev/null nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} $(REDIRECT $udp_port TPROXY) comment \"$remarks\"" 2>/dev/null
} }
@@ -634,8 +613,8 @@ load_acl() {
[ "$_ipv4" != "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} counter return comment \"$remarks\"" 2>/dev/null [ "$_ipv4" != "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp ${_ipt_source} counter return comment \"$remarks\"" 2>/dev/null
unset nft_chain nft_j _ipt_source msg msg2 _ipv4 unset nft_chain nft_j _ipt_source msg msg2 _ipv4
done done
unset enabled sid remarks sources use_global_config use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode dns_redirect_port tcp_no_redir_ports udp_no_redir_ports tcp_proxy_drop_ports udp_proxy_drop_ports tcp_redir_ports udp_redir_ports tcp_node udp_node interface unset enabled sid remarks sources use_global_config use_direct_list use_proxy_list use_block_list use_gfw_list chn_list tcp_proxy_mode udp_proxy_mode dns_redirect_port tcp_no_redir_ports udp_no_redir_ports tcp_proxy_drop_ports udp_proxy_drop_ports tcp_redir_ports udp_redir_ports node interface
unset tcp_port udp_port tcp_node_remark udp_node_remark _acl_list use_shunt_tcp use_shunt_udp dns_redirect use_fakedns unset tcp_port udp_port node_remark _acl_list use_shunt_node dns_redirect use_fakedns
done done
} }
@@ -665,7 +644,7 @@ load_acl() {
local DNS_REDIRECT local DNS_REDIRECT
[ $(config_t_get global dns_redirect "1") = "1" ] && DNS_REDIRECT=53 [ $(config_t_get global dns_redirect "1") = "1" ] && DNS_REDIRECT=53
if ([ -n "$TCP_NODE" ] && [ -n "${TCP_PROXY_MODE}" ]) || ([ -n "$UDP_NODE" ] && [ -n "${UDP_PROXY_MODE}" ]); then if [ -n "$NODE" ] && ([ -n "${TCP_PROXY_MODE}" ] || [ -n "${UDP_PROXY_MODE}" ]); then
[ -n "${DNS_REDIRECT_PORT}" ] && DNS_REDIRECT=${DNS_REDIRECT_PORT} [ -n "${DNS_REDIRECT_PORT}" ] && DNS_REDIRECT=${DNS_REDIRECT_PORT}
else else
[ -n "${DIRECT_DNSMASQ_PORT}" ] && DNS_REDIRECT=${DIRECT_DNSMASQ_PORT} [ -n "${DIRECT_DNSMASQ_PORT}" ] && DNS_REDIRECT=${DIRECT_DNSMASQ_PORT}
@@ -698,7 +677,7 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr" "$NFTSET_BLACK6" "counter reject comment \"默认\"" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr" "$NFTSET_BLACK6" "counter reject comment \"默认\""
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr @$NFTSET_GFW6 counter reject comment \"默认\"" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr @$NFTSET_GFW6 counter reject comment \"默认\""
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\"" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\""
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter reject comment \"默认\"" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter reject comment \"默认\""
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject comment \"默认\"" [ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject comment \"默认\""
} }
@@ -706,7 +685,7 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr" "$NFTSET_BLACK" "counter reject comment \"默认\"" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr" "$NFTSET_BLACK" "counter reject comment \"默认\""
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr @$NFTSET_GFW counter reject comment \"默认\"" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr @$NFTSET_GFW counter reject comment \"默认\""
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\"" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\""
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr" "$NFTSET_SHUNT" "counter reject comment \"默认\"" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "$nft_prerouting_chain" "ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") ip daddr" "$NFTSET_SHUNT" "counter reject comment \"默认\""
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject comment \"默认\"" [ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_prerouting_chain ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject comment \"默认\""
echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]" echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]"
} }
@@ -717,14 +696,14 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr" "$NFTSET_BLACK6" "counter reject comment \"默认\"" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr" "$NFTSET_BLACK6" "counter reject comment \"默认\""
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr @$NFTSET_GFW6 counter reject comment \"默认\"" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr @$NFTSET_GFW6 counter reject comment \"默认\""
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\"" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\""
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter reject comment \"默认\"" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter reject comment \"默认\""
[ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject comment \"默认\"" [ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject comment \"默认\""
} }
[ "${USE_FAKEDNS}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr $FAKE_IP counter reject comment \"默认\"" [ "${USE_FAKEDNS}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr $FAKE_IP counter reject comment \"默认\""
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr" "$NFTSET_BLACK" "counter reject comment \"默认\"" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr" "$NFTSET_BLACK" "counter reject comment \"默认\""
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr @$NFTSET_GFW counter reject comment \"默认\"" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr @$NFTSET_GFW counter reject comment \"默认\""
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\"" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "counter reject") comment \"默认\""
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr" "$NFTSET_SHUNT" "counter reject comment \"默认\"" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") ip daddr" "$NFTSET_SHUNT" "counter reject comment \"默认\""
[ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject comment \"默认\"" [ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject comment \"默认\""
echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]" echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]"
} }
@@ -732,20 +711,20 @@ load_acl() {
# 加载TCP默认代理模式 # 加载TCP默认代理模式
if [ -n "${TCP_PROXY_MODE}" ]; then if [ -n "${TCP_PROXY_MODE}" ]; then
[ -n "$TCP_NODE" ] && { [ -n "$NODE" ] && {
if [ "$(config_get_type $TCP_NODE)" = "socks" ]; then if [ "$(config_get_type $NODE)" = "socks" ]; then
msg2="${msg}使用 TCP 节点[Socks 配置($(config_n_get $TCP_NODE port) 端口)]" msg2="${msg}代理 TCP 使用节点[Socks 配置($(config_n_get $NODE port) 端口)]"
else else
msg2="${msg}使用 TCP 节点[$(config_n_get $TCP_NODE remarks)]" msg2="${msg}代理 TCP 使用节点[$(config_n_get $NODE remarks)]"
fi fi
if [ -n "${is_tproxy}" ]; then if [ -n "${is_tproxy}" ]; then
msg2="${msg2}(TPROXY:${TCP_REDIR_PORT})" msg2="${msg2}(TPROXY:${REDIR_PORT})"
nft_chain="PSW_MANGLE" nft_chain="PSW_MANGLE"
nft_j="counter jump PSW_RULE" nft_j="counter jump PSW_RULE"
else else
msg2="${msg2}(REDIRECT:${TCP_REDIR_PORT})" msg2="${msg2}(REDIRECT:${REDIR_PORT})"
nft_chain="PSW_NAT" nft_chain="PSW_NAT"
nft_j="$(REDIRECT $TCP_REDIR_PORT)" nft_j="$(REDIRECT $REDIR_PORT)"
fi fi
[ "$accept_icmp" = "1" ] && { [ "$accept_icmp" = "1" ] && {
@@ -754,7 +733,7 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ip daddr" "$NFTSET_BLACK" "$(REDIRECT) comment \"默认\"" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ip daddr" "$NFTSET_BLACK" "$(REDIRECT) comment \"默认\""
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ip daddr @$NFTSET_GFW $(REDIRECT) comment \"默认\"" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp ip daddr @$NFTSET_GFW $(REDIRECT) comment \"默认\""
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST}) comment \"默认\"" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST}) comment \"默认\""
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ip daddr" "$NFTSET_SHUNT" "$(REDIRECT) comment \"默认\"" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "ip protocol icmp ip daddr" "$NFTSET_SHUNT" "$(REDIRECT) comment \"默认\""
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp $(REDIRECT) comment \"默认\"" [ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp $(REDIRECT) comment \"默认\""
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp return comment \"默认\"" nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT ip protocol icmp return comment \"默认\""
} }
@@ -765,7 +744,7 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ip6 daddr" "$NFTSET_BLACK6" "$(REDIRECT) comment \"默认\"" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ip6 daddr" "$NFTSET_BLACK6" "$(REDIRECT) comment \"默认\""
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ip6 daddr @$NFTSET_GFW6 $(REDIRECT) comment \"默认\"" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 ip6 daddr @$NFTSET_GFW6 $(REDIRECT) comment \"默认\""
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST}) comment \"默认\"" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST}) comment \"默认\""
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ip6 daddr" "$NFTSET_SHUNT6" "$(REDIRECT) comment \"默认\"" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "meta l4proto icmpv6 ip6 daddr" "$NFTSET_SHUNT6" "$(REDIRECT) comment \"默认\""
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 $(REDIRECT) comment \"默认\"" [ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 $(REDIRECT) comment \"默认\""
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 return comment \"默认\"" nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT meta l4proto icmpv6 return comment \"默认\""
} }
@@ -774,9 +753,9 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr" "$NFTSET_BLACK" "${nft_j} comment \"默认\"" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr" "$NFTSET_BLACK" "${nft_j} comment \"默认\""
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr @$NFTSET_GFW ${nft_j} comment \"默认\"" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr @$NFTSET_GFW ${nft_j} comment \"默认\""
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_chain" "ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "${nft_j}") comment \"默认\"" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_chain" "ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "${nft_j}") comment \"默认\""
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr" "$NFTSET_SHUNT" "${nft_j} comment \"默认\"" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip daddr" "$NFTSET_SHUNT" "${nft_j} comment \"默认\""
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j} comment \"默认\"" [ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j} comment \"默认\""
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(REDIRECT $TCP_REDIR_PORT TPROXY4) comment \"默认\"" [ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(REDIRECT $REDIR_PORT TPROXY4) comment \"默认\""
nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp counter return comment \"默认\"" nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp counter return comment \"默认\""
[ "$PROXY_IPV6" = "1" ] && { [ "$PROXY_IPV6" = "1" ] && {
@@ -784,9 +763,9 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr" "$NFTSET_BLACK6" "counter jump PSW_RULE comment \"默认\"" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr" "$NFTSET_BLACK6" "counter jump PSW_RULE comment \"默认\""
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr @$NFTSET_GFW6 counter jump PSW_RULE comment \"默认\"" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr @$NFTSET_GFW6 counter jump PSW_RULE comment \"默认\""
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE") comment \"默认\"" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE") comment \"默认\""
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter jump PSW_RULE comment \"默认\"" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter jump PSW_RULE comment \"默认\""
[ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE comment \"默认\"" [ "${TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE comment \"默认\""
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(REDIRECT $TCP_REDIR_PORT TPROXY) comment \"默认\"" nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp $(REDIRECT $REDIR_PORT TPROXY) comment \"默认\""
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp counter return comment \"默认\"" nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp counter return comment \"默认\""
} }
@@ -796,20 +775,20 @@ load_acl() {
# 加载UDP默认代理模式 # 加载UDP默认代理模式
if [ -n "${UDP_PROXY_MODE}" ]; then if [ -n "${UDP_PROXY_MODE}" ]; then
[ -n "$UDP_NODE" ] || [ "$TCP_UDP" = "1" ] && { [ -n "$NODE" ] && {
if [ "$(config_get_type $UDP_NODE)" = "socks" ]; then if [ "$(config_get_type $NODE)" = "socks" ]; then
msg2="${msg}使用 UDP 节点[Socks 配置($(config_n_get $UDP_NODE port) 端口)](TPROXY:${UDP_REDIR_PORT})" msg2="${msg}代理 UDP 使用节点[Socks 配置($(config_n_get $NODE port) 端口)](TPROXY:${REDIR_PORT})"
else else
msg2="${msg}使用 UDP 节点[$(config_n_get $UDP_NODE remarks)](TPROXY:${UDP_REDIR_PORT})" msg2="${msg}代理 UDP 使用节点[$(config_n_get $NODE remarks)](TPROXY:${REDIR_PORT})"
fi fi
[ "${USE_FAKEDNS}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ip daddr $FAKE_IP counter jump PSW_RULE comment \"默认\"" [ "${USE_FAKEDNS}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp ip daddr $FAKE_IP counter jump PSW_RULE comment \"默认\""
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr" "$NFTSET_BLACK" "counter jump PSW_RULE comment \"默认\"" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr" "$NFTSET_BLACK" "counter jump PSW_RULE comment \"默认\""
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr @$NFTSET_GFW counter jump PSW_RULE comment \"默认\"" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr @$NFTSET_GFW counter jump PSW_RULE comment \"默认\""
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE") comment \"默认\"" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE") comment \"默认\""
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr" "$NFTSET_SHUNT" "counter jump PSW_RULE comment \"默认\"" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE" "ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") ip daddr" "$NFTSET_SHUNT" "counter jump PSW_RULE comment \"默认\""
[ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE comment \"默认\"" [ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE comment \"默认\""
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(REDIRECT $UDP_REDIR_PORT TPROXY4) comment \"默认\"" nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp $(REDIRECT $REDIR_PORT TPROXY4) comment \"默认\""
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp counter return comment \"默认\"" nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp counter return comment \"默认\""
[ "$PROXY_IPV6" = "1" ] && { [ "$PROXY_IPV6" = "1" ] && {
@@ -817,9 +796,9 @@ load_acl() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr" "$NFTSET_BLACK6" "counter jump PSW_RULE comment \"默认\"" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr" "$NFTSET_BLACK6" "counter jump PSW_RULE comment \"默认\""
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr @$NFTSET_GFW6 counter jump PSW_RULE comment \"默认\"" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr @$NFTSET_GFW6 counter jump PSW_RULE comment \"默认\""
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE") comment \"默认\"" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE") comment \"默认\""
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter jump PSW_RULE comment \"默认\"" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_MANGLE_V6" "meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") ip6 daddr" "$NFTSET_SHUNT6" "counter jump PSW_RULE comment \"默认\""
[ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE comment \"默认\"" [ "${UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE comment \"默认\""
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(REDIRECT $UDP_REDIR_PORT TPROXY) comment \"默认\"" nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp $(REDIRECT $REDIR_PORT TPROXY) comment \"默认\""
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp counter return comment \"默认\"" nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp counter return comment \"默认\""
} }
@@ -1013,18 +992,14 @@ add_firewall_rule() {
gen_nftset $NFTSET_SHUNT6_STATIC ipv6_addr 0 gen_nftset $NFTSET_SHUNT6_STATIC ipv6_addr 0
#导入规则列表、分流规则中的IP列表 #导入规则列表、分流规则中的IP列表
local USE_SHUNT_NODE=0
local USE_PROXY_LIST_ALL=${USE_PROXY_LIST} local USE_PROXY_LIST_ALL=${USE_PROXY_LIST}
local USE_DIRECT_LIST_ALL=${USE_DIRECT_LIST} local USE_DIRECT_LIST_ALL=${USE_DIRECT_LIST}
local USE_BLOCK_LIST_ALL=${USE_BLOCK_LIST} local USE_BLOCK_LIST_ALL=${USE_BLOCK_LIST}
local _TCP_NODE=$(config_t_get global tcp_node) USE_SHUNT_NODE=0
local _UDP_NODE=$(config_t_get global udp_node)
USE_GEOVIEW=$(config_t_get global_rules enable_geoview) USE_GEOVIEW=$(config_t_get global_rules enable_geoview)
[ -z "$(first_type $(config_t_get global_app geoview_file) geoview)" ] && USE_GEOVIEW=0 [ -z "$(first_type $(config_t_get global_app geoview_file) geoview)" ] && USE_GEOVIEW=0
[ -n "$_TCP_NODE" ] && [ "$(config_n_get $_TCP_NODE protocol)" = "_shunt" ] && USE_SHUNT_TCP=1 && USE_SHUNT_NODE=1 [ -n "$NODE" ] && [ "$(config_n_get $NODE protocol)" = "_shunt" ] && USE_SHUNT_NODE=1
[ -n "$_UDP_NODE" ] && [ "$(config_n_get $_UDP_NODE protocol)" = "_shunt" ] && USE_SHUNT_UDP=1 && USE_SHUNT_NODE=1
[ "$_UDP_NODE" = "tcp" ] && USE_SHUNT_UDP=$USE_SHUNT_TCP
for acl_section in $(uci show ${CONFIG} | grep "=acl_rule" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do for acl_section in $(uci show ${CONFIG} | grep "=acl_rule" | cut -d '.' -sf 2 | cut -d '=' -sf 1); do
[ "$(config_n_get $acl_section enabled)" != "1" ] && continue [ "$(config_n_get $acl_section enabled)" != "1" ] && continue
@@ -1033,10 +1008,6 @@ add_firewall_rule() {
[ "$(config_n_get $acl_section use_proxy_list 1)" = "1" ] && USE_DIRECT_LIST_ALL=1 [ "$(config_n_get $acl_section use_proxy_list 1)" = "1" ] && USE_DIRECT_LIST_ALL=1
[ "$(config_n_get $acl_section use_block_list 1)" = "1" ] && USE_BLOCK_LIST_ALL=1 [ "$(config_n_get $acl_section use_block_list 1)" = "1" ] && USE_BLOCK_LIST_ALL=1
} }
for _node in $(config_n_get $acl_section tcp_node) $(config_n_get $acl_section udp_node); do
local node_protocol=$(config_n_get $_node protocol)
[ "$node_protocol" = "_shunt" ] && { USE_SHUNT_NODE=1; break; }
done
done done
#直连列表 #直连列表
@@ -1085,12 +1056,8 @@ add_firewall_rule() {
[ "$USE_SHUNT_NODE" = "1" ] && { [ "$USE_SHUNT_NODE" = "1" ] && {
local GEOIP_CODE="" local GEOIP_CODE=""
local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}') local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
local shunt_group shunt_id local shunt_group=$(config_n_get $NODE shunt_group)
if [ "${USE_SHUNT_TCP}" = "1" ]; then local shunt_id
shunt_group=$(config_n_get $_TCP_NODE shunt_group)
elif [ "${USE_SHUNT_UDP}" = "1" ]; then
shunt_group=$(config_n_get $_UDP_NODE shunt_group)
fi
for shunt_id in $shunt_ids; do for shunt_id in $shunt_ids; do
[ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue [ "${shunt_group}" != "$(config_n_get ${shunt_id} group)" ] && continue
config_n_get $shunt_id ip_list | sed 's/#.*//' | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | insert_nftset $NFTSET_SHUNT_STATIC config_n_get $shunt_id ip_list | sed 's/#.*//' | grep -E "(\.((2(5[0-5]|[0-4][0-9]))|[0-1]?[0-9]{1,2})){3}" | insert_nftset $NFTSET_SHUNT_STATIC
@@ -1145,8 +1112,7 @@ add_firewall_rule() {
filter_vpsip > /dev/null 2>&1 & filter_vpsip > /dev/null 2>&1 &
# filter_haproxy > /dev/null 2>&1 & # filter_haproxy > /dev/null 2>&1 &
# Prevent some conditions # Prevent some conditions
filter_vps_addr $(config_n_get $TCP_NODE address) $(config_n_get $UDP_NODE address) > /dev/null 2>&1 & filter_vps_addr $(config_n_get $NODE address) $(config_n_get $NODE download_address) > /dev/null 2>&1 &
filter_vps_addr $(config_n_get $TCP_NODE download_address) $(config_n_get $UDP_NODE download_address) > /dev/null 2>&1 &
accept_icmp=$(config_t_get global_forwarding accept_icmp 0) accept_icmp=$(config_t_get global_forwarding accept_icmp 0)
accept_icmpv6=$(config_t_get global_forwarding accept_icmpv6 0) accept_icmpv6=$(config_t_get global_forwarding accept_icmpv6 0)
@@ -1291,8 +1257,6 @@ add_firewall_rule() {
ip -6 route add local ::/0 dev lo table 999 ip -6 route add local ::/0 dev lo table 999
} }
[ "$TCP_UDP" = "1" ] && [ -z "$UDP_NODE" ] && UDP_NODE=$TCP_NODE
[ "$ENABLED_DEFAULT_ACL" = 1 ] && { [ "$ENABLED_DEFAULT_ACL" = 1 ] && {
msg="【路由器本机】," msg="【路由器本机】,"
@@ -1318,7 +1282,7 @@ add_firewall_rule() {
fi fi
} }
if ([ -n "$TCP_NODE" ] && [ -n "${LOCALHOST_TCP_PROXY_MODE}" ]) || ([ -n "$UDP_NODE" ] && [ -n "${LOCALHOST_UDP_PROXY_MODE}" ]); then if [ -n "$NODE" ] && ([ -n "${LOCALHOST_TCP_PROXY_MODE}" ] || [ -n "${LOCALHOST_UDP_PROXY_MODE}" ]); then
[ -n "$DNS_REDIRECT_PORT" ] && { [ -n "$DNS_REDIRECT_PORT" ] && {
nft "add rule $NFTABLE_NAME nat_output ip protocol udp oif lo udp dport 53 counter redirect to :$DNS_REDIRECT_PORT comment \"PSW_DNS\"" nft "add rule $NFTABLE_NAME nat_output ip protocol udp oif lo udp dport 53 counter redirect to :$DNS_REDIRECT_PORT comment \"PSW_DNS\""
nft "add rule $NFTABLE_NAME nat_output ip protocol tcp oif lo tcp dport 53 counter redirect to :$DNS_REDIRECT_PORT comment \"PSW_DNS\"" nft "add rule $NFTABLE_NAME nat_output ip protocol tcp oif lo tcp dport 53 counter redirect to :$DNS_REDIRECT_PORT comment \"PSW_DNS\""
@@ -1333,7 +1297,7 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_output_chain" "ip protocol tcp ip daddr" "$NFTSET_BLACK" "$(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_output_chain" "ip protocol tcp ip daddr" "$NFTSET_BLACK" "$(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject"
[ "${USE_GFW_LIST}" = "1" ] && nft add rule $NFTABLE_NAME $nft_output_chain ip protocol tcp ip daddr @$NFTSET_GFW $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject [ "${USE_GFW_LIST}" = "1" ] && nft add rule $NFTABLE_NAME $nft_output_chain ip protocol tcp ip daddr @$NFTSET_GFW $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_output_chain" "ip protocol tcp ip daddr" "$NFTSET_CHN" "$(factor $TCP_PROXY_DROP_PORTS "tcp dport") $(get_jump_nft ${CHN_LIST} "counter reject")" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_output_chain" "ip protocol tcp ip daddr" "$NFTSET_CHN" "$(factor $TCP_PROXY_DROP_PORTS "tcp dport") $(get_jump_nft ${CHN_LIST} "counter reject")"
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "$nft_output_chain" "ip protocol tcp ip daddr" "$NFTSET_SHUNT" "$(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "$nft_output_chain" "ip protocol tcp ip daddr" "$NFTSET_SHUNT" "$(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject"
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft add rule $NFTABLE_NAME $nft_output_chain ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft add rule $NFTABLE_NAME $nft_output_chain ip protocol tcp $(factor $TCP_PROXY_DROP_PORTS "tcp dport") counter reject
echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]" echolog " - ${msg}屏蔽代理 TCP 端口[${TCP_PROXY_DROP_PORTS}]"
} }
@@ -1343,14 +1307,14 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_BLACK" "$(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_BLACK" "$(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject"
[ "${USE_GFW_LIST}" = "1" ] && nft add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp ip daddr @$NFTSET_GFW $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject [ "${USE_GFW_LIST}" = "1" ] && nft add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp ip daddr @$NFTSET_GFW $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_CHN" "$(factor $UDP_PROXY_DROP_PORTS "udp dport") $(get_jump_nft ${CHN_LIST} "counter reject")" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_CHN" "$(factor $UDP_PROXY_DROP_PORTS "udp dport") $(get_jump_nft ${CHN_LIST} "counter reject")"
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_SHUNT" "$(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_SHUNT" "$(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject"
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && nft add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject [ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && nft add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp $(factor $UDP_PROXY_DROP_PORTS "udp dport") counter reject
echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]" echolog " - ${msg}屏蔽代理 UDP 端口[${UDP_PROXY_DROP_PORTS}]"
} }
} }
# 加载路由器自身代理 TCP # 加载路由器自身代理 TCP
if [ -n "$TCP_NODE" ]; then if [ -n "$NODE" ]; then
_proxy_tcp_access() { _proxy_tcp_access() {
[ -n "${2}" ] || return 0 [ -n "${2}" ] || return 0
if echo "${2}" | grep -q -v ':'; then if echo "${2}" | grep -q -v ':'; then
@@ -1360,10 +1324,10 @@ add_firewall_rule() {
return 0 return 0
} }
if [ -z "${is_tproxy}" ]; then if [ -z "${is_tproxy}" ]; then
nft insert rule $NFTABLE_NAME PSW_OUTPUT_NAT ip protocol tcp ip daddr ${2} tcp dport ${3} $(REDIRECT $TCP_REDIR_PORT) nft insert rule $NFTABLE_NAME PSW_OUTPUT_NAT ip protocol tcp ip daddr ${2} tcp dport ${3} $(REDIRECT $REDIR_PORT)
else else
nft insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol tcp ip daddr ${2} tcp dport ${3} counter jump PSW_RULE nft insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol tcp ip daddr ${2} tcp dport ${3} counter jump PSW_RULE
nft insert rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo tcp dport ${3} ip daddr ${2} $(REDIRECT $TCP_REDIR_PORT TPROXY4) comment \"本机\" nft insert rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo tcp dport ${3} ip daddr ${2} $(REDIRECT $REDIR_PORT TPROXY4) comment \"本机\"
fi fi
echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 TCP 转发链" echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 TCP 转发链"
else else
@@ -1373,7 +1337,7 @@ add_firewall_rule() {
return 0 return 0
} }
nft "insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto tcp ip6 daddr ${2} tcp dport ${3} counter jump PSW_RULE" nft "insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto tcp ip6 daddr ${2} tcp dport ${3} counter jump PSW_RULE"
nft "insert rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo tcp dport ${3} ip6 daddr ${2} $(REDIRECT $TCP_REDIR_PORT TPROXY6) comment \"本机\"" nft "insert rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo tcp dport ${3} ip6 daddr ${2} $(REDIRECT $REDIR_PORT TPROXY6) comment \"本机\""
echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 TCP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!" echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 TCP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!"
fi fi
} }
@@ -1384,7 +1348,7 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo ip protocol icmp ip daddr" "$NFTSET_BLACK" "counter redirect" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo ip protocol icmp ip daddr" "$NFTSET_BLACK" "counter redirect"
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo ip protocol icmp ip daddr @$NFTSET_GFW counter redirect" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo ip protocol icmp ip daddr @$NFTSET_GFW counter redirect"
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo ip protocol icmp ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST})" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo ip protocol icmp ip daddr" "$NFTSET_CHN" "$(get_jump_nft ${CHN_LIST})"
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo ip protocol icmp ip daddr" "$NFTSET_SHUNT" "counter redirect" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo ip protocol icmp ip daddr" "$NFTSET_SHUNT" "counter redirect"
[ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo ip protocol icmp counter redirect" [ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo ip protocol icmp counter redirect"
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo ip protocol icmp counter return" nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo ip protocol icmp counter return"
} }
@@ -1394,7 +1358,7 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo meta l4proto icmpv6 ip6 daddr" "$NFTSET_BLACK6" "counter redirect" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo meta l4proto icmpv6 ip6 daddr" "$NFTSET_BLACK6" "counter redirect"
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo meta l4proto icmpv6 ip6 daddr @$NFTSET_GFW6 counter redirect" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo meta l4proto icmpv6 ip6 daddr @$NFTSET_GFW6 counter redirect"
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo meta l4proto icmpv6 ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST})" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo meta l4proto icmpv6 ip6 daddr" "$NFTSET_CHN6" "$(get_jump_nft ${CHN_LIST})"
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo meta l4proto icmpv6 ip6 daddr" "$NFTSET_SHUNT6" "counter redirect" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_ICMP_REDIRECT" "oif lo meta l4proto icmpv6 ip6 daddr" "$NFTSET_SHUNT6" "counter redirect"
[ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo meta l4proto icmpv6 counter redirect" [ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo meta l4proto icmpv6 counter redirect"
nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo meta l4proto icmpv6 counter return" nft "add rule $NFTABLE_NAME PSW_ICMP_REDIRECT oif lo meta l4proto icmpv6 counter return"
} }
@@ -1404,7 +1368,7 @@ add_firewall_rule() {
nft_j="counter jump PSW_RULE" nft_j="counter jump PSW_RULE"
else else
nft_chain="PSW_OUTPUT_NAT" nft_chain="PSW_OUTPUT_NAT"
nft_j="$(REDIRECT $TCP_REDIR_PORT)" nft_j="$(REDIRECT $REDIR_PORT)"
fi fi
[ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && { [ -n "${LOCALHOST_TCP_PROXY_MODE}" ] && {
@@ -1412,9 +1376,9 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ip daddr" "$NFTSET_BLACK" "$(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ip daddr" "$NFTSET_BLACK" "$(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}"
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ip daddr @$NFTSET_GFW $(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp ip daddr @$NFTSET_GFW $(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}"
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ip daddr" "$NFTSET_CHN" "$(factor $TCP_REDIR_PORTS "tcp dport") $(get_jump_nft ${CHN_LIST} "${nft_j}")" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ip daddr" "$NFTSET_CHN" "$(factor $TCP_REDIR_PORTS "tcp dport") $(get_jump_nft ${CHN_LIST} "${nft_j}")"
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ip daddr" "$NFTSET_SHUNT" "$(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "$nft_chain" "ip protocol tcp ip daddr" "$NFTSET_SHUNT" "$(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}"
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}" [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME $nft_chain ip protocol tcp $(factor $TCP_REDIR_PORTS "tcp dport") ${nft_j}"
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo $(REDIRECT $TCP_REDIR_PORT TPROXY4) comment \"本机\"" [ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo $(REDIRECT $REDIR_PORT TPROXY4) comment \"本机\""
} }
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo counter return comment \"本机\"" [ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol tcp iif lo counter return comment \"本机\""
[ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME mangle_output ip protocol tcp counter jump PSW_OUTPUT_MANGLE comment \"PSW_OUTPUT_MANGLE\"" [ -n "${is_tproxy}" ] && nft "add rule $NFTABLE_NAME mangle_output ip protocol tcp counter jump PSW_OUTPUT_MANGLE comment \"PSW_OUTPUT_MANGLE\""
@@ -1426,16 +1390,16 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto tcp ip6 daddr" "$NFTSET_BLACK6" "$(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto tcp ip6 daddr" "$NFTSET_BLACK6" "$(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE"
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto tcp ip6 daddr @$NFTSET_GFW6 $(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto tcp ip6 daddr @$NFTSET_GFW6 $(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE"
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto tcp ip6 daddr" "$NFTSET_CHN6" "$(factor $TCP_REDIR_PORTS "tcp dport") $(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE")" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto tcp ip6 daddr" "$NFTSET_CHN6" "$(factor $TCP_REDIR_PORTS "tcp dport") $(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE")"
[ "${USE_SHUNT_TCP}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto tcp ip6 daddr" "$NFTSET_SHUNT6" "$(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto tcp ip6 daddr" "$NFTSET_SHUNT6" "$(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE"
[ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE" [ "${LOCALHOST_TCP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto tcp $(factor $TCP_REDIR_PORTS "tcp dport") counter jump PSW_RULE"
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo $(REDIRECT $TCP_REDIR_PORT TPROXY) comment \"本机\"" nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo $(REDIRECT $REDIR_PORT TPROXY) comment \"本机\""
} }
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo counter return comment \"本机\"" nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto tcp iif lo counter return comment \"本机\""
} }
fi fi
# 加载路由器自身代理 UDP # 加载路由器自身代理 UDP
if [ -n "$UDP_NODE" ] || [ "$TCP_UDP" = "1" ]; then if [ -n "$NODE" ]; then
_proxy_udp_access() { _proxy_udp_access() {
[ -n "${2}" ] || return 0 [ -n "${2}" ] || return 0
if echo "${2}" | grep -q -v ':'; then if echo "${2}" | grep -q -v ':'; then
@@ -1445,7 +1409,7 @@ add_firewall_rule() {
return 0 return 0
} }
nft "insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp ip daddr ${2} udp dport ${3} counter jump PSW_RULE" nft "insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp ip daddr ${2} udp dport ${3} counter jump PSW_RULE"
nft "insert rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo ip daddr ${2} $(REDIRECT $UDP_REDIR_PORT TPROXY4) comment \"本机\"" nft "insert rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo ip daddr ${2} $(REDIRECT $REDIR_PORT TPROXY4) comment \"本机\""
echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 UDP 转发链" echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 UDP 转发链"
else else
nft "get element $NFTABLE_NAME $NFTSET_LAN6 {${2}}" &>/dev/null nft "get element $NFTABLE_NAME $NFTSET_LAN6 {${2}}" &>/dev/null
@@ -1454,7 +1418,7 @@ add_firewall_rule() {
return 0 return 0
} }
nft "insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto udp ip6 daddr ${2} udp dport ${3} counter jump PSW_RULE" nft "insert rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto udp ip6 daddr ${2} udp dport ${3} counter jump PSW_RULE"
nft "insert rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo ip6 daddr ${2} $(REDIRECT $UDP_REDIR_PORT TPROXY6) comment \"本机\"" nft "insert rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo ip6 daddr ${2} $(REDIRECT $REDIR_PORT TPROXY6) comment \"本机\""
echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 UDP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!" echolog " - [$?]将上游 DNS 服务器 [${2}]:${3} 加入到路由器自身代理的 UDP 转发链,请确保您的节点支持IPv6,并开启IPv6透明代理!"
fi fi
} }
@@ -1464,9 +1428,9 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_BLACK" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_BLACK" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp ip daddr @$NFTSET_GFW $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp ip daddr @$NFTSET_GFW $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_CHN" "$(factor $UDP_REDIR_PORTS "udp dport") $(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE")" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_CHN" "$(factor $UDP_REDIR_PORTS "udp dport") $(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE")"
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_SHUNT" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE" "ip protocol udp ip daddr" "$NFTSET_SHUNT" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE" [ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE ip protocol udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo $(REDIRECT $UDP_REDIR_PORT TPROXY4) comment \"本机\"" nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo $(REDIRECT $REDIR_PORT TPROXY4) comment \"本机\""
} }
nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo counter return comment \"本机\"" nft "add rule $NFTABLE_NAME PSW_MANGLE ip protocol udp iif lo counter return comment \"本机\""
nft "add rule $NFTABLE_NAME mangle_output ip protocol udp counter jump PSW_OUTPUT_MANGLE comment \"PSW_OUTPUT_MANGLE\"" nft "add rule $NFTABLE_NAME mangle_output ip protocol udp counter jump PSW_OUTPUT_MANGLE comment \"PSW_OUTPUT_MANGLE\""
@@ -1477,9 +1441,9 @@ add_firewall_rule() {
[ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto udp ip6 daddr" "$NFTSET_BLACK6" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE" [ "${USE_PROXY_LIST}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto udp ip6 daddr" "$NFTSET_BLACK6" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
[ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto udp ip6 daddr @$NFTSET_GFW6 $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE" [ "${USE_GFW_LIST}" = "1" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto udp ip6 daddr @$NFTSET_GFW6 $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
[ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto udp ip6 daddr" "$NFTSET_CHN6" "$(factor $UDP_REDIR_PORTS "udp dport") $(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE")" [ "${CHN_LIST}" != "0" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto udp ip6 daddr" "$NFTSET_CHN6" "$(factor $UDP_REDIR_PORTS "udp dport") $(get_jump_nft ${CHN_LIST} "counter jump PSW_RULE")"
[ "${USE_SHUNT_UDP}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto udp ip6 daddr" "$NFTSET_SHUNT6" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE" [ "${USE_SHUNT_NODE}" = "1" ] && nft_rule_dual "PSW_OUTPUT_MANGLE_V6" "meta l4proto udp ip6 daddr" "$NFTSET_SHUNT6" "$(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
[ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE" [ "${LOCALHOST_UDP_PROXY_MODE}" != "disable" ] && nft "add rule $NFTABLE_NAME PSW_OUTPUT_MANGLE_V6 meta l4proto udp $(factor $UDP_REDIR_PORTS "udp dport") counter jump PSW_RULE"
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo $(REDIRECT $UDP_REDIR_PORT TPROXY) comment \"本机\"" nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo $(REDIRECT $REDIR_PORT TPROXY) comment \"本机\""
} }
nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo counter return comment \"本机\"" nft "add rule $NFTABLE_NAME PSW_MANGLE_V6 meta l4proto udp iif lo counter return comment \"本机\""
} }
@@ -136,15 +136,13 @@ end
-- 获取各项动态配置的当前服务器,可以用 get 和 set, get必须要获取到节点表 -- 获取各项动态配置的当前服务器,可以用 get 和 set, get必须要获取到节点表
local CONFIG = {} local CONFIG = {}
do do
local function import_config(protocol) if true then
local name = string.upper(protocol)
local szType = "@global[0]" local szType = "@global[0]"
local option = protocol .. "_node" local option = "node"
local node_id = uci_get(szType, option) local node_id = uci_get(szType, option)
CONFIG[#CONFIG + 1] = { CONFIG[#CONFIG + 1] = {
log = true, log = true,
remarks = name .. "节点", remarks = "全局节点",
currentNode = (function(id) currentNode = (function(id)
local section = id and uci_get(id) or nil local section = id and uci_get(id) or nil
if not section then return nil end if not section then return nil end
@@ -159,8 +157,6 @@ do
end end
} }
end end
import_config("tcp")
import_config("udp")
if true then if true then
local i = 0 local i = 0
@@ -255,11 +251,9 @@ do
if true then if true then
local i = 0 local i = 0
local options = {"tcp", "udp"}
uci_foreach("acl_rule", function(t) uci_foreach("acl_rule", function(t)
i = i + 1 i = i + 1
for index, value in ipairs(options) do local option = "node"
local option = value .. "_node"
local node_id = t[option] local node_id = t[option]
CONFIG[#CONFIG + 1] = { CONFIG[#CONFIG + 1] = {
log = true, log = true,
@@ -278,7 +272,6 @@ do
o.newNodeId = server o.newNodeId = server
end end
} }
end
end) end)
end end
@@ -486,20 +486,16 @@ ln_run() {
if [ -z "$persist_log_path" ] && [ "$sys_log" != "1" ]; then if [ -z "$persist_log_path" ] && [ "$sys_log" != "1" ]; then
${file_func:-echolog " - ${ln_name}"} "$@" >${output} 2>&1 & ${file_func:-echolog " - ${ln_name}"} "$@" >${output} 2>&1 &
else else
case "$output" in
*TCP.log) local protocol="TCP" ;;
*UDP.log) local protocol="UDP" ;;
esac
if [ -n "${persist_log_path}" ]; then if [ -n "${persist_log_path}" ]; then
mkdir -p ${persist_log_path} mkdir -p ${persist_log_path}
local log_file=${persist_log_path}/passwall_${protocol}_${ln_name}_$(date '+%F').log local log_file=${persist_log_path}/passwall_global_${ln_name}_$(date '+%F').log
echolog "记录到持久性日志文件:${log_file}" echolog "记录到持久性日志文件:${log_file}"
${file_func:-echolog " - ${ln_name}"} "$@" >> ${log_file} 2>&1 & ${file_func:-echolog " - ${ln_name}"} "$@" >> ${log_file} 2>&1 &
sys_log=0 sys_log=0
fi fi
if [ "${sys_log}" = "1" ]; then if [ "${sys_log}" = "1" ]; then
echolog "记录 ${ln_name}_${protocol} 到系统日志" echolog "记录 ${ln_name}_global 到系统日志"
${file_func:-echolog " - ${ln_name}"} "$@" 2>&1 | logger -t PASSWALL_${protocol}_${ln_name} & ${file_func:-echolog " - ${ln_name}"} "$@" 2>&1 | logger -t PASSWALL_global_${ln_name} &
fi fi
fi fi
[ "$NO_REC_PROCESS" = "1" ] && return [ "$NO_REC_PROCESS" = "1" ] && return
+1 -1
View File
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall2 PKG_NAME:=luci-app-passwall2
PKG_VERSION:=26.8.20 PKG_VERSION:=26.8.20
PKG_RELEASE:=94 PKG_RELEASE:=98
PKG_PO_VERSION:=$(PKG_VERSION) PKG_PO_VERSION:=$(PKG_VERSION)
PKG_CONFIG_DEPENDS:= \ PKG_CONFIG_DEPENDS:= \
@@ -78,10 +78,13 @@
const _ASSETS = '/luci-static/passwall2/'; const _ASSETS = '/luci-static/passwall2/';
const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[passwall2]], [[ip]])%>'; const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[passwall2]], [[ip]])%>';
let mainContent = document.getElementById("maincontent");
let statusBar = document.querySelector(".status-bar"); let statusBar = document.querySelector(".status-bar");
function resize() { function resize() {
statusBar.style.width = document.getElementById("maincontent").offsetWidth + 'px'; wW = window.innerWidth;
let lw = document.querySelector(".main-left, :root[data-layout='sidebar'] .fs-sidebar")?.offsetWidth ?? 5;
statusBar.style.width = (wW - lw) + 'px';
let flagElement = statusBar.querySelector(".flag"); let flagElement = statusBar.querySelector(".flag");
flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px'; flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px';
@@ -125,5 +128,7 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
window.addEventListener('resize', resize); window.addEventListener('resize', resize);
if (mainContent && window.getComputedStyle(mainContent).getPropertyValue("contain")=== "paint") {
document.body.appendChild(statusBar); document.body.appendChild(statusBar);
}
</script> </script>
+1 -1
View File
@@ -4,7 +4,7 @@ LUCI_TITLE:=luci-app-ssr-plus
LUCI_PKGARCH:=all LUCI_PKGARCH:=all
PKG_NAME:=luci-app-ssr-plus PKG_NAME:=luci-app-ssr-plus
PKG_VERSION:=196 PKG_VERSION:=196
PKG_RELEASE:=61 PKG_RELEASE:=65
PKG_CONFIG_DEPENDS:= \ PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \ CONFIG_PACKAGE_$(PKG_NAME)_Iptables_Transparent_Proxy \
@@ -78,10 +78,13 @@
const _ASSETS = '/luci-static/shadowsocksr/'; const _ASSETS = '/luci-static/shadowsocksr/';
const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[shadowsocksr]], [[ip]])%>'; const CHECK_IP_URL = '<%=url([[admin]], [[services]], [[shadowsocksr]], [[ip]])%>';
let mainContent = document.getElementById("maincontent");
let statusBar = document.querySelector(".status-bar"); let statusBar = document.querySelector(".status-bar");
function resize() { function resize() {
statusBar.style.width = document.getElementById("maincontent").offsetWidth + 'px'; wW = window.innerWidth;
let lw = document.querySelector(".main-left, :root[data-layout='sidebar'] .fs-sidebar")?.offsetWidth ?? 5;
statusBar.style.width = (wW - lw) + 'px';
let flagElement = statusBar.querySelector(".flag"); let flagElement = statusBar.querySelector(".flag");
flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px'; flagElement.style.width = (flagElement.offsetHeight / 3 * 4) + 'px';
@@ -125,5 +128,7 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
window.addEventListener('resize', resize); window.addEventListener('resize', resize);
if (mainContent && window.getComputedStyle(mainContent).getPropertyValue("contain")=== "paint") {
document.body.appendChild(statusBar); document.body.appendChild(statusBar);
}
</script> </script>
+1 -1
View File
@@ -17,7 +17,7 @@ LUCI_NAME:=luci-theme-footstrap
FOOTSTRAP_VERSION?= FOOTSTRAP_VERSION?=
ifneq ($(FOOTSTRAP_VERSION),) ifneq ($(FOOTSTRAP_VERSION),)
PKG_VERSION:=$(FOOTSTRAP_VERSION) PKG_VERSION:=$(FOOTSTRAP_VERSION)
PKG_RELEASE:=32 PKG_RELEASE:=33
endif endif
LUCI_TITLE:=Footstrap Theme LUCI_TITLE:=Footstrap Theme
@@ -4,3 +4,4 @@ config footstrap 'settings'
option darkmode 'dark' option darkmode 'dark'
option wallpaper 'pattern' option wallpaper 'pattern'
option layout 'sidebar' option layout 'sidebar'
option palette 'bootstrap'
+1 -1
View File
@@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=mosdns PKG_NAME:=mosdns
PKG_VERSION:=5.3.4 PKG_VERSION:=5.3.4
PKG_RELEASE:=15 PKG_RELEASE:=16
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/IrineSistiana/mosdns/tar.gz/v$(PKG_VERSION)? PKG_SOURCE_URL:=https://codeload.github.com/IrineSistiana/mosdns/tar.gz/v$(PKG_VERSION)?
@@ -0,0 +1,227 @@
From 819415303eb05bdf5b6dadf119f947645c9062cc Mon Sep 17 00:00:00 2001
From: sbwml <admin@cooluc.com>
Date: Sat, 22 Aug 2026 22:56:30 +0800
Subject: [PATCH] feat(cache): add proactive prefetch support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
plugins:
- tag: lazy_cache
type: cache
args:
size: 1024
# 开启预读功能 (默认为 false)
prefetch: true
# 在 TTL 还剩 10 秒时尝试预读 (默认为 10)
prefetch_before_expire: 10
# 至少被命中 2 次才触发预读 (默认为 3)
prefetch_min_hits: 2
# 后台扫描周期,每 3 秒扫描一次 (默认为 5)
prefetch_scan_interval: 3
Signed-off-by: sbwml <admin@cooluc.com>
---
plugin/executable/cache/cache.go | 113 +++++++++++++++++++++++++++++--
plugin/executable/cache/utils.go | 2 +
2 files changed, 110 insertions(+), 5 deletions(-)
--- a/plugin/executable/cache/cache.go
+++ b/plugin/executable/cache/cache.go
@@ -27,6 +27,7 @@ import (
"io"
"net/http"
"os"
+ "reflect"
"strconv"
"sync"
"sync/atomic"
@@ -69,15 +70,22 @@ const (
var _ sequence.RecursiveExecutable = (*Cache)(nil)
type Args struct {
- Size int `yaml:"size"`
- LazyCacheTTL int `yaml:"lazy_cache_ttl"`
- DumpFile string `yaml:"dump_file"`
- DumpInterval int `yaml:"dump_interval"`
+ Size int `yaml:"size"`
+ LazyCacheTTL int `yaml:"lazy_cache_ttl"`
+ DumpFile string `yaml:"dump_file"`
+ DumpInterval int `yaml:"dump_interval"`
+ Prefetch bool `yaml:"prefetch"`
+ PrefetchBeforeExpire int `yaml:"prefetch_before_expire"`
+ PrefetchMinHits int `yaml:"prefetch_min_hits"`
+ PrefetchScanInterval int `yaml:"prefetch_scan_interval"`
}
func (a *Args) init() {
utils.SetDefaultUnsignNum(&a.Size, 1024)
utils.SetDefaultUnsignNum(&a.DumpInterval, 600)
+ utils.SetDefaultUnsignNum(&a.PrefetchBeforeExpire, 10)
+ utils.SetDefaultUnsignNum(&a.PrefetchMinHits, 3)
+ utils.SetDefaultUnsignNum(&a.PrefetchScanInterval, 5)
}
type Cache struct {
@@ -94,6 +102,11 @@ type Cache struct {
hitTotal prometheus.Counter
lazyHitTotal prometheus.Counter
size prometheus.GaugeFunc
+
+ prefetchTotal prometheus.Counter
+ prefetchFailTotal prometheus.Counter
+ capturedNext *sequence.ChainWalker
+ captureOnce sync.Once
}
func Init(bp *coremain.BP, args any) (any, error) {
@@ -160,6 +173,16 @@ func NewCache(args *Args, opts Opts) *Ca
Help: "The total number of queries that hit the expired cache",
ConstLabels: lb,
}),
+ prefetchTotal: prometheus.NewCounter(prometheus.CounterOpts{
+ Name: "prefetch_total",
+ Help: "The total number of successful proactive prefetch operations",
+ ConstLabels: lb,
+ }),
+ prefetchFailTotal: prometheus.NewCounter(prometheus.CounterOpts{
+ Name: "prefetch_fail_total",
+ Help: "The total number of failed proactive prefetch operations",
+ ConstLabels: lb,
+ }),
size: prometheus.NewGaugeFunc(prometheus.GaugeOpts{
Name: "size_current",
Help: "Current cache size in records",
@@ -173,12 +196,15 @@ func NewCache(args *Args, opts Opts) *Ca
p.logger.Error("failed to load cache dump", zap.Error(err))
}
p.startDumpLoop()
+ if p.args.Prefetch {
+ p.startPrefetchLoop()
+ }
return p
}
func (c *Cache) RegMetricsTo(r prometheus.Registerer) error {
- for _, collector := range [...]prometheus.Collector{c.queryTotal, c.hitTotal, c.lazyHitTotal, c.size} {
+ for _, collector := range [...]prometheus.Collector{c.queryTotal, c.hitTotal, c.lazyHitTotal, c.prefetchTotal, c.prefetchFailTotal, c.size} {
if err := r.Register(collector); err != nil {
return err
}
@@ -187,6 +213,15 @@ func (c *Cache) RegMetricsTo(r prometheu
}
func (c *Cache) Exec(ctx context.Context, qCtx *query_context.Context, next sequence.ChainWalker) error {
+ c.captureOnce.Do(func() {
+ // This implementation assumes the cache plugin is invoked from a single fixed position in the sequence.
+ nextCopy := next
+ c.capturedNext = &nextCopy
+ })
+ if c.capturedNext != nil && !reflect.DeepEqual(next, *c.capturedNext) {
+ c.logger.Warn("cache plugin Exec called with a different next chain than first time")
+ }
+
c.queryTotal.Inc()
q := qCtx.Q()
@@ -205,6 +240,7 @@ func (c *Cache) Exec(ctx context.Context
cachedResp.Id = q.Id // change msg id
qCtx.SetResponse(cachedResp)
if v, _, ok := c.backend.Get(key(msgKey)); ok && v != nil {
+ v.hitCount.Add(1)
ttl := int(v.expirationTime.Sub(v.storedTime).Seconds())
remainingTtl := int(v.expirationTime.Sub(time.Now()).Seconds())
if remainingTtl < 0 {
@@ -255,6 +291,73 @@ func (c *Cache) doLazyUpdate(msgKey stri
c.lazyUpdateSF.DoChan(msgKey, lazyUpdateFunc) // DoChan won't block this goroutine
}
+func (c *Cache) startPrefetchLoop() {
+ go func() {
+ ticker := time.NewTicker(time.Duration(c.args.PrefetchScanInterval) * time.Second)
+ defer ticker.Stop()
+ for {
+ select {
+ case <-ticker.C:
+ if c.capturedNext == nil {
+ continue
+ }
+ now := time.Now()
+ _ = c.backend.Range(func(k key, v *item, cacheExpirationTime time.Time) error {
+ remainingTTL := int(v.expirationTime.Sub(now).Seconds())
+ if remainingTTL >= 0 && remainingTTL < c.args.PrefetchBeforeExpire && v.hitCount.Load() >= uint32(c.args.PrefetchMinHits) {
+ c.doPrefetch(string(k), v, remainingTTL)
+ }
+ return nil
+ })
+ case <-c.closeNotify:
+ return
+ }
+ }
+ }()
+}
+
+func (c *Cache) doPrefetch(msgKey string, v *item, remainingTTL int) {
+ prefetchFunc := func() (any, error) {
+ defer c.lazyUpdateSF.Forget(msgKey)
+
+ req := new(dns.Msg)
+ req.SetQuestion(v.resp.Question[0].Name, v.resp.Question[0].Qtype)
+ req.Id = dns.Id()
+ req.RecursionDesired = true
+ newQCtx := query_context.NewContext(req)
+
+ qname := v.resp.Question[0].Name
+ hitCount := v.hitCount.Load()
+
+ c.logger.Debug("start proactive prefetch",
+ zap.String("qname", qname),
+ zap.Uint32("hit_count", hitCount),
+ zap.Int("remaining_ttl", remainingTTL),
+ )
+ ctx, cancel := context.WithTimeout(context.Background(), defaultLazyUpdateTimeout)
+ defer cancel()
+
+ err := c.capturedNext.ExecNext(ctx, newQCtx)
+ if err != nil {
+ c.logger.Warn("failed to proactive prefetch", zap.String("qname", qname), zap.Error(err))
+ c.prefetchFailTotal.Inc()
+ return nil, err
+ }
+
+ r := newQCtx.R()
+ if r != nil {
+ if saveRespToCache(msgKey, r, c.backend, c.args.LazyCacheTTL) {
+ v.hitCount.Store(0)
+ c.prefetchTotal.Inc()
+ c.updatedKey.Add(1)
+ }
+ }
+ c.logger.Debug("proactive prefetch updated", zap.String("qname", qname), newQCtx.InfoField())
+ return nil, nil
+ }
+ c.lazyUpdateSF.DoChan(msgKey, prefetchFunc)
+}
+
func (c *Cache) Close() error {
if err := c.dumpCache(); err != nil {
c.logger.Error("failed to dump cache", zap.Error(err))
--- a/plugin/executable/cache/utils.go
+++ b/plugin/executable/cache/utils.go
@@ -21,6 +21,7 @@ package cache
import (
"hash/maphash"
+ "sync/atomic"
"time"
"github.com/IrineSistiana/mosdns/v5/pkg/cache"
@@ -78,6 +79,7 @@ type item struct {
resp *dns.Msg
storedTime time.Time
expirationTime time.Time
+ hitCount atomic.Uint32
}
func copyNoOpt(m *dns.Msg) *dns.Msg {
+1 -1
View File
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=my-default-settings PKG_NAME:=my-default-settings
PKG_VERSION:=2 PKG_VERSION:=2
PKG_RELEASE:=7 PKG_RELEASE:=8
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
@@ -49,7 +49,7 @@ fi
if [ -z "$version" ] || [ "$version" -lt 1 ]; then if [ -z "$version" ] || [ "$version" -lt 1 ]; then
uci -q set luci.main.lang='auto' uci -q set luci.main.lang='auto'
uci -q set luci.main.mediaurlbase=/luci-static/argon uci -q set luci.main.mediaurlbase=/luci-static/footstrap
uci commit luci uci commit luci
if uci -q get system.@system[0] >/dev/null; then if uci -q get system.@system[0] >/dev/null; then
+2 -2
View File
@@ -30,11 +30,11 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=wwand PKG_NAME:=wwand
PKG_RELEASE:=6 PKG_RELEASE:=7
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/ddimension/wwand.git PKG_SOURCE_URL:=https://github.com/ddimension/wwand.git
PKG_SOURCE_VERSION:=57196fbe92f8d6fa18a3c3e4e8269c54328f2ffe PKG_SOURCE_VERSION:=4035709733ab3d10db5b205aa18d9263216db15e
PKG_SOURCE_DATE:=2026-08-21 PKG_SOURCE_DATE:=2026-08-21
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip