Merge Mainline

This commit is contained in:
CN_SZTL 2020-09-06 12:49:42 +08:00
commit 2864a42d2d
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
37 changed files with 3442 additions and 3329 deletions

View File

@ -181,7 +181,7 @@ $$(call addfield,Depends,$$(Package/$(1)/DEPENDS)
)$$(call addfield,LicenseFiles,$(LICENSE_FILES)
)$$(call addfield,Section,$(SECTION)
)$$(call addfield,Require-User,$(USERID)
)$$(call addfield,SourceDateEpoch,$(shell $(TOPDIR)/scripts/get_source_date_epoch.sh $(SOURCE))
)$$(call addfield,SourceDateEpoch,$(PKG_SOURCE_DATE_EPOCH)
)$(if $(PKG_CPE_ID),CPE-ID: $(PKG_CPE_ID)
)$(if $(filter hold,$(PKG_FLAGS)),Status: unknown hold not-installed
)$(if $(filter essential,$(PKG_FLAGS)),Essential: yes
@ -193,7 +193,7 @@ $(_endef)
$$(IPKG_$(1)) : export CONTROL=$$(Package/$(1)/CONTROL)
$$(IPKG_$(1)) : export DESCRIPTION=$$(Package/$(1)/description)
$$(IPKG_$(1)) : export PATH=$$(TARGET_PATH_PKG)
$$(IPKG_$(1)) : export PKG_SOURCE_DATE_EPOCH=$(shell $(TOPDIR)/scripts/get_source_date_epoch.sh $(SOURCE))
$$(IPKG_$(1)) : export PKG_SOURCE_DATE_EPOCH:=$(PKG_SOURCE_DATE_EPOCH)
$(PKG_INFO_DIR)/$(1).provides $$(IPKG_$(1)): $(STAMP_BUILT) $(INCLUDE_DIR)/package-ipkg.mk
@rm -rf $$(IDIR_$(1)); \
$$(call remove_ipkg_files,$(1),$$(call opkg_package_files,$(call gen_ipkg_wildcard,$(1))))

View File

@ -19,6 +19,8 @@ PKG_IREMAP ?= 1
MAKE_J:=$(if $(MAKE_JOBSERVER),$(MAKE_JOBSERVER) $(if $(filter 3.% 4.0 4.1,$(MAKE_VERSION)),-j))
PKG_SOURCE_DATE_EPOCH:=$(if $(DUMP),,$(shell $(TOPDIR)/scripts/get_source_date_epoch.sh $(CURDIR)))
ifeq ($(strip $(PKG_BUILD_PARALLEL)),0)
PKG_JOBS?=-j1
else

View File

@ -2,20 +2,26 @@
<label class="cbi-value-title"><%= translate("Cookie Tools") %></label>
<div class="cbi-value-field">
<a class="cbi-button cbi-button-reload" href='/jd-dailybonus/JDCookie.crx'><%= translate("JDCookie.crx") %></a> <a class="cbi-button cbi-button-reload" href='/jd-dailybonus/JDCookie.zip'><%= translate("JDCookie.zip") %></a>
<input type="button" class="cbi-button cbi-input-reload" value="<%= translate('JDCookie.crx') %>" onclick="javascript:window.open('/jd-dailybonus/JDCookie.crx','target');" />
<input type="button" class="cbi-button cbi-input-reload" value="<%= translate('JDCookie.zip') %>" onclick="javascript:window.open('/jd-dailybonus/JDCookie.zip','target');" />
<br>
<div class="cbi-value-description">
<span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" alt="帮助"></span>
<%= translate("Click to Install copy cookie tools,And click the jd link below. if you can't install the crx extensions,please download the JDCookie.zip,unzip it,and use load Unpacked extensions to install.link:[chrome://extensions/]")%>
</div>
</div>
<%+cbi/valuefooter%>
<%+cbi/valueheader%>
<label class="cbi-value-title"><%= translate("JD Url") %></label>
<div class="cbi-value-field">
<a class="cbi-button cbi-button-reload" href='https://bean.m.jd.com' target="_blank">bean.m.jd.com</a>
<input type="button" class="cbi-button cbi-input-reload" value="bean.m.jd.com" onclick="javascript:window.open('https://bean.m.jd.com','target');" />
<br>
<div class="cbi-value-description">
<span class="cbi-value-helpicon"><img src="/luci-static/resources/cbi/help.gif" alt="帮助"></span>
<%= translate("Sign in ,then click JDCookie button.you will copy JD cookies, paste the cookie below.")%>
</div>
</div>
<%+cbi/valuefooter%>
<%+cbi/valuefooter%>

View File

@ -22,7 +22,7 @@ server_addr = s:option(Value, "server_addr", translate("Server Address"))
server_addr.description = translate("proto://user:pass@hostname[:port]")
server_addr.rmempty = false
extra_argument= s:option(Value, "extra_argument", translate("Extra Argument"))
extra_argument = s:option(Value, "extra_argument", translate("Extra Argument"))
extra_argument.description = translate("Appends extra argument to NaiveProxy")
return mp

View File

@ -25,37 +25,37 @@ uci_get_by_name() {
lan_addr="$(uci get network.lan.ipaddr)"
enable="$(uci_get_by_type "unblockneteasemusic" "enable" "0")"
enable="$(uci_get_by_type "$NAME" "enable" "0")"
music_source="$(uci_get_by_type "unblockneteasemusic" "music_source" "default")"
neteasemusic_cookie="$(uci_get_by_type "unblockneteasemusic" "neteasemusic_cookie")"
qq_cookie="$(uci_get_by_type "unblockneteasemusic" "qq_cookie")"
youtube_key="$(uci_get_by_type "unblockneteasemusic" "youtube_key")"
music_source="$(uci_get_by_type "$NAME" "music_source" "default")"
neteasemusic_cookie="$(uci_get_by_type "$NAME" "neteasemusic_cookie")"
qq_cookie="$(uci_get_by_type "$NAME" "qq_cookie")"
youtube_key="$(uci_get_by_type "$NAME" "youtube_key")"
replace_music_source="$(uci_get_by_type "unblockneteasemusic" "replace_music_source" "dont_replace")"
enable_flac="$(uci_get_by_type "unblockneteasemusic" "enable_flac" "0")"
replace_music_source="$(uci_get_by_type "$NAME" "replace_music_source" "dont_replace")"
enable_flac="$(uci_get_by_type "$NAME" "enable_flac" "0")"
[ "${enable_flac}" -eq "1" ] && un_env="ENABLE_FLAC=true"
endpoint_url="$(uci_get_by_type "unblockneteasemusic" "endpoint_url" "http://music.163.com")"
hijack_ways="$(uci_get_by_type "unblockneteasemusic" "hijack_ways" "use_ipset")"
endpoint_url="$(uci_get_by_type "$NAME" "endpoint_url" "http://music.163.com")"
hijack_ways="$(uci_get_by_type "$NAME" "hijack_ways" "use_ipset")"
auto_update="$(uci_get_by_type "unblockneteasemusic" "auto_update" "1")"
update_time="$(uci_get_by_type "unblockneteasemusic" "update_time" "3")"
auto_update="$(uci_get_by_type "$NAME" "auto_update" "1")"
update_time="$(uci_get_by_type "$NAME" "update_time" "3")"
http_port="$(uci_get_by_type "unblockneteasemusic" "http_port" "5200")"
https_port="$(uci_get_by_type "unblockneteasemusic" "https_port" "5201")"
http_port="$(uci_get_by_type "$NAME" "http_port" "5200")"
https_port="$(uci_get_by_type "$NAME" "https_port" "5201")"
keep_core_when_upgrade="$(uci_get_by_type "unblockneteasemusic" "keep_core_when_upgrade")"
[ "$(uci_get_by_type "unblockneteasemusic" "pub_access")" = "1" ] && addr="0.0.0.0" || addr="${lan_addr}"
[ "$(uci_get_by_type "unblockneteasemusic" "strict_mode")" = "1" ] && strict_mode="-s"
keep_core_when_upgrade="$(uci_get_by_type "$NAME" "keep_core_when_upgrade")"
[ "$(uci_get_by_type "$NAME" "pub_access")" = "1" ] && addr="0.0.0.0" || addr="${lan_addr}"
[ "$(uci_get_by_type "$NAME" "strict_mode")" = "1" ] && strict_mode="-s"
netease_server_ip="$(uci_get_by_type "unblockneteasemusic" "netease_server_ip")"
netease_server_ip="$(uci_get_by_type "$NAME" "netease_server_ip")"
[ -n "${netease_server_ip}" ] && netease_server_ip="-f ${netease_server_ip}"
proxy_server_ip="$(uci_get_by_type "unblockneteasemusic" "proxy_server_ip")"
proxy_server_ip="$(uci_get_by_type "$NAME" "proxy_server_ip")"
[ -n "${proxy_server_ip}" ] && proxy_server_ip="-u ${proxy_server_ip}"
self_issue_cert_crt="$(uci_get_by_type "unblockneteasemusic" "self_issue_cert_crt")"
self_issue_cert_key="$(uci_get_by_type "unblockneteasemusic" "self_issue_cert_key")"
self_issue_cert_crt="$(uci_get_by_type "$NAME" "self_issue_cert_crt")"
self_issue_cert_key="$(uci_get_by_type "$NAME" "self_issue_cert_key")"
set_ipset()
{
@ -76,7 +76,7 @@ ipset=/clientlog3.music.163.com/neteasemusic
if ! ipset list "acl_neteasemusic_http" > "/dev/null"; then ipset create "acl_neteasemusic_http" hash:ip; fi
if ! ipset list "acl_neteasemusic_https" > "/dev/null"; then ipset create "acl_neteasemusic_https" hash:ip; fi
ip_addr_num="$(uci show "unblockneteasemusic" | grep -c "filter_mode")"
ip_addr_num="$(uci show "$NAME" | grep -c "filter_mode")"
let ip_addr_num="ip_addr_num-1"
[ "${ip_addr_num}" -ge "0" ] && for i in $(seq 0 "${ip_addr_num}")
do
@ -178,6 +178,11 @@ start()
[ "${enable}" -ne "1" ] && exit 0
sed -i '/unblockneteasemusic/d' /etc/crontabs/root
[ "${auto_update}" -eq "1" ] && echo "0 ${update_time} * * * /usr/share/unblockneteasemusic/update.sh update_core" >> "/etc/crontabs/root"
echo "*/5 * * * * /usr/share/unblockneteasemusic/log_check.sh" >> "/etc/crontabs/root"
/etc/init.d/cron restart > "/dev/null" 2>&1
[ ! -e "/usr/share/unblockneteasemusic/core/app.js" ] && { rm -f "/usr/share/unblockneteasemusic/local_ver"; bash "/usr/share/unblockneteasemusic/update.sh" "update_core_non_restart"; }
[ ! -e "/usr/share/unblockneteasemusic/core/app.js" ] && { echo "Core Not Found, please download it before starting." >> "/tmp/unblockneteasemusic.log"; exit 1; }
@ -225,12 +230,7 @@ start()
set_hosts > "/dev/null" 2>&1
fi
[ "$(uci_get_by_type "unblockneteasemusic" pub_access)" = "1" ] && set_ports > "/dev/null" 2>&1
sed -i '/unblockneteasemusic/d' /etc/crontabs/root
[ "${auto_update}" -eq "1" ] && echo "0 ${update_time} * * * /usr/share/unblockneteasemusic/update.sh update_core" >> "/etc/crontabs/root"
echo "*/5 * * * * /usr/share/unblockneteasemusic/log_check.sh" >> "/etc/crontabs/root"
/etc/init.d/cron restart > "/dev/null" 2>&1
[ "$(uci_get_by_type "$NAME" pub_access)" = "1" ] && set_ports > "/dev/null" 2>&1
}
stop()

View File

@ -7,12 +7,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=naiveproxy
PKG_VERSION:=85.0.4183.83-1
PKG_VERSION:=85.0.4183.83-2
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/klzgrad/naiveproxy/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=5fa9b2f26212f2414dc0ebc021f64c566585e26c20ec17955cef53ce3bc314da
PKG_HASH:=620ca571615ee15d5de4c7723beb1fd3eb806413bbb992c3abcb3972d1a68cae
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_LICENSE:=BSD 3-Clause

View File

@ -16,14 +16,12 @@ USE_SRC=$(shell ls ./src/ 2>/dev/null >/dev/null && echo 1)
include $(INCLUDE_DIR)/package.mk
FS_QNTFS_TARGET_DEPENDS=@(TARGET_ar71xx_generic||TARGET_ar71xx_nand||TARGET_ath79_generic||TARGET_ath79_nand||TARGET_ipq40xx_generic||TARGET_ipq806x_generic||TARGET_ramips_mt76x8||TARGET_ramips_mt7620||TARGET_ramips_mt7621)
# TODO: target qualcomm-ipq40xx not found
define KernelPackage/fs-qntfs
SUBMENU:=Filesystems
TITLE:=PandoraBox Quick-NTFS filesystem
FILES:=$(PKG_BUILD_DIR)/qntfs.ko
DEPENDS:=$(FS_QNTFS_TARGET_DEPENDS) +kmod-nls-cp936 +kmod-nls-utf8 +kmod-nls-cp437 +kmod-nls-iso8859-1
DEPENDS:=@(TARGET_ar71xx||TARGET_ath79||TARGET_ipq40xx||TARGET_ipq806x||TARGET_ramips) \
+kmod-nls-cp936 +kmod-nls-utf8 +kmod-nls-cp437 +kmod-nls-iso8859-1 +@LINUX_4_14
AUTOLOAD:=$(call AutoLoad,30,qntfs,1)
endef
@ -34,14 +32,15 @@ endef
EXTRA_KCONFIG:= \
CONFIG_QNTFS_FS=m \
CONFIG_QNTFS_SYMLINKS=y
MAKE_OPTS:= \
ARCH="$(LINUX_KARCH)" \
CROSS_COMPILE="$(TARGET_CROSS)" \
M="$(PKG_BUILD_DIR)" \
$(EXTRA_KCONFIG)
ifneq ($(USE_SRC),)
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
@ -51,7 +50,7 @@ define Build/Compile
$(MAKE) -C "$(LINUX_DIR)" \
$(MAKE_OPTS) \
modules
@echo ----------Build:$(CONFIG_TARGET_BOARD)-$(CONFIG_TARGET_SUBTARGET)----------
mkdir -p ./files/$(CONFIG_TARGET_BOARD)-$(CONFIG_TARGET_SUBTARGET)
$(CP) $(PKG_BUILD_DIR)/qntfs.ko ./files/$(CONFIG_TARGET_BOARD)-$(CONFIG_TARGET_SUBTARGET)/
@ -61,12 +60,12 @@ else
define Build/Prepare
@echo ----------Build:$(CONFIG_TARGET_BOARD)-$(CONFIG_TARGET_SUBTARGET)----------
mkdir -p $(PKG_BUILD_DIR)/
$(CP) ./files/$(CONFIG_TARGET_BOARD)-$(CONFIG_TARGET_SUBTARGET)/qntfs.ko $(PKG_BUILD_DIR)/
mkdir -p $(PKG_BUILD_DIR)/
$(CP) ./files/$(CONFIG_TARGET_BOARD)-$(CONFIG_TARGET_SUBTARGET)/qntfs.ko $(PKG_BUILD_DIR)/
endef
define Build/Compile
echo
true
endef
endif

View File

@ -70,7 +70,7 @@ o.write = function()
end)
uci:save("shadowsocksr")
uci:commit("shadowsocksr")
luci.sys.exec("/etc/init.d/shadowsocksr restart")
luci.sys.exec("/etc/init.d/shadowsocksr restart &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "servers"))
return
end
@ -119,7 +119,7 @@ node.write = function(self, section)
uci:set("shadowsocksr", '@global[0]', 'global_server', section)
uci:save("shadowsocksr")
uci:commit("shadowsocksr")
luci.sys.exec("/etc/init.d/shadowsocksr restart")
luci.sys.exec("/etc/init.d/shadowsocksr restart &")
luci.http.redirect(luci.dispatcher.build_url("admin", "services", "shadowsocksr", "client"))
end

View File

@ -41,7 +41,7 @@ endif
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-linux-$(PKG_ARCH_VERYSYNC)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://releases-cdn.verysync.com/releases/$(PKG_VERSION)/
PKG_SOURCE_URL:=http://dl.verysync.net/$(PKG_VERSION)/
PKG_HASH:=skip
include $(INCLUDE_DIR)/package.mk

View File

@ -40,7 +40,7 @@ ifeq ($(ARCH),mips64el)
endif
PKG_NAME:=brook
PKG_VERSION:=20200901
PKG_VERSION:=20200909
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=brook_linux_$(PKG_ARCH_BROOK)
@ -76,4 +76,4 @@ define Package/$(PKG_NAME)/install
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_SOURCE) $(1)/usr/bin/brook
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
$(eval $(call BuildPackage,$(PKG_NAME)))

View File

@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=3.9
PKG_RELEASE:=52
PKG_RELEASE:=54
PKG_DATE:=20200905
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

View File

@ -29,8 +29,7 @@ o.default = 0
o.rmempty = false
---- Testing Time
o = s:option(Value, "testing_time", translate("How often is a diagnosis made"),
translate("Units:minutes"))
o = s:option(Value, "testing_time", translate("How often is a diagnosis made"), translate("Units:minutes"))
o.default = "3"
---- TCP Node
@ -38,7 +37,12 @@ o.default = "3"
-- 暂时只支持TCP1
local tcp_node_num = 1
for i = 1, tcp_node_num, 1 do
o = s:option(DynamicList, "tcp_node" .. i, "TCP " .. i .. " " .. translate("List of backup nodes"), translate("List of backup nodes, the first of which must be the primary node and the others the standby node."))
o = s:option(ListValue, "tcp_main" .. i, "TCP " .. i .. " " .. translate("Main node"))
for k, v in pairs(nodes_table) do
o:value(v.id, v.remarks)
end
o = s:option(DynamicList, "tcp_node" .. i, "TCP " .. i .. " " .. translate("List of backup nodes"))
for k, v in pairs(nodes_table) do
o:value(v.id, v.remarks)
end

View File

@ -69,9 +69,28 @@ for i = 1, tcp_node_num, 1 do
if i == 1 then
o = s:taboption("Main", ListValue, "tcp_node" .. i, translate("TCP Node"))
o.description = translate("For proxy specific list.")
if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then
local now_node = luci.sys.exec(string.format("[ -f '/var/etc/%s/id/TCP_%s' ] && echo -n $(cat /var/etc/%s/id/TCP_%s)", appname, i, appname, i))
if now_node and now_node ~= "" then
local e = uci:get_all(appname, now_node)
if e then
local remarks = ""
if e.type == "V2ray" and (e.protocol == "_balancing" or e.protocol == "_shunt") then
remarks = "%s[%s] " % {translatef(e.type .. e.protocol), e.remarks}
else
if e.use_kcp and e.use_kcp == "1" then
remarks = "%s+%s[%s] %s" % {e.type, "Kcptun", e.remarks, e.address}
else
remarks = "%s[%s] %s:%s" % {e.type, e.remarks, e.address, e.port}
end
end
o.description = o.description .. "<br />" ..translatef("Current node: %s", remarks)
end
end
end
else
o = s:taboption("Main", ListValue, "tcp_node" .. i,
translate("TCP Node") .. " " .. i)
o = s:taboption("Main", ListValue, "tcp_node" .. i, translate("TCP Node") .. " " .. i)
end
o:value("nil", translate("Close"))
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end
@ -88,8 +107,7 @@ for i = 1, udp_node_num, 1 do
--o:value("tcp", translate("Same as the tcp node"))
--o:value("tcp_", translate("Same as the tcp node") .. "" .. translate("New process") .. "")
else
o = s:taboption("Main", ListValue, "udp_node" .. i,
translate("UDP Node") .. " " .. i)
o = s:taboption("Main", ListValue, "udp_node" .. i, translate("UDP Node") .. " " .. i)
o:value("nil", translate("Close"))
end
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end

View File

@ -5,39 +5,30 @@ m = Map(appname)
-- [[ Rule Settings ]]--
s = m:section(TypedSection, "global_rules", translate("Rule status"))
s.anonymous = true
s:append(Template(appname .. "/rule/rule_version"))
--[[
o = s:option(Flag, "adblock", translate("Enable adblock"))
o.rmempty = false
]]--
---- Enable custom url
--[[
o = s:option(Flag, "enable_custom_url", translate("Enable custom URL"))
o.default = 0
o.rmempty = false
]]--
---- gfwlist URL
o = s:option(Value, "gfwlist_url", translate("GFW domains(gfwlist) Update URL"))
o:value("https://cdn.jsdelivr.net/gh/Loukky/gfwlist-by-loukky/gfwlist.txt", translate("Loukky/gfwlist-by-loukky"))
o:value("https://cdn.jsdelivr.net/gh/gfwlist/gfwlist/gfwlist.txt", translate("gfwlist/gfwlist"))
o.default = "https://cdn.jsdelivr.net/gh/Loukky/gfwlist-by-loukky/gfwlist.txt"
--o:depends("enable_custom_url", 1)
----chnroute URL
o = s:option(Value, "chnroute_url", translate("China IPs(chnroute) Update URL"))
o:value("https://ispip.clang.cn/all_cn.txt", translate("Clang.CN"))
o:value("https://ispip.clang.cn/all_cn_cidr.txt", translate("Clang.CN.CIDR"))
o.default = "https://ispip.clang.cn/all_cn.txt"
--o:depends("enable_custom_url", 1)
----chnroute6 URL
o = s:option(Value, "chnroute6_url", translate("China IPv6s(chnroute6) Update URL"))
o:value("https://ispip.clang.cn/all_cn_ipv6.txt", translate("Clang.CN.IPv6"))
o.default = "https://ispip.clang.cn/all_cn_ipv6.txt"
--o:depends("enable_custom_url", 1)
s:append(Template(appname .. "/rule/rule_version"))
---- Auto Update
o = s:option(Flag, "auto_update", translate("Enable auto update rules"))

View File

@ -1,11 +1,6 @@
<%
local api = require "luci.model.cbi.passwall.api.api"
local gfwlist_version = api.uci_get_type("global_rules", "gfwlist_version")
local chnroute_version = api.uci_get_type("global_rules", "chnroute_version")
local chnroute6_version = api.uci_get_type("global_rules", "chnroute6_version")
local chnlist_version = api.uci_get_type("global_rules", "chnlist_version")
local gfwlist_update = api.uci_get_type("global_rules", "gfwlist_update", "1") == "1" and "checked='checked'" or ""
local chnroute_update = api.uci_get_type("global_rules", "chnroute_update", "1") == "1" and "checked='checked'" or ""
local chnroute6_update = api.uci_get_type("global_rules", "chnroute6_update", "1") == "1" and "checked='checked'" or ""
@ -45,62 +40,31 @@ local chnlist_update = api.uci_get_type("global_rules", "chnlist_update", "1") =
</script>
<fieldset class="cbi-section">
<fieldset class="cbi-section" id="_rule_fieldset">
<div class="cbi-value">
<label class="cbi-value-title">gfwlist
<%:Version%>
</label>
<div class="cbi-value-field">
<div class="cbi-value-description">
<span><%=gfwlist_version%> 】</span>
<input type="checkbox" name="gfwlist_update" value="1" <%=gfwlist_update%> />
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title">chnroute
<%:Version%>
</label>
<div class="cbi-value-field">
<div class="cbi-value-description">
<span><%=chnroute_version%> 】</span>
<input type="checkbox" name="chnroute_update" value="1" <%=chnroute_update%> />
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title">chnroute6
<%:Version%>
</label>
<div class="cbi-value-field">
<div class="cbi-value-description">
<span><%=chnroute6_version%> 】</span>
<input type="checkbox" name="chnroute6_update" value="1" <%=chnroute6_update%> />
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title">chnlist
<%:Version%>
</label>
<div class="cbi-value-field">
<div class="cbi-value-description">
<span><%=chnlist_version%> 】</span>
<input type="checkbox" name="chnlist_update" value="1" <%=chnlist_update%> />
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title">
<%:Manually update%>
</label>
<div class="cbi-value-field">
<input class="cbi-button cbi-input-apply" type="button" id="update_rules_btn" onclick="update_rules(this)" value="<%:Manually update%>" />
<div>
<label>
<input class="cbi-input-checkbox" type="checkbox" name="gfwlist" value="1" <%=gfwlist_update%>>
gfwlist
</label>
<label>
<input class="cbi-input-checkbox" type="checkbox" name="chnroute" value="1" <%=chnroute_update%>>
chnroute
</label>
<label>
<input class="cbi-input-checkbox" type="checkbox" name="chnroute6" value="1" <%=chnroute6_update%>>
chnroute6
</label>
<label>
<input class="cbi-input-checkbox" type="checkbox" name="chnlist" value="1" <%=chnlist_update%>>
chnlist
</label>
<input class="cbi-button cbi-input-apply" type="button" id="update_rules_btn" onclick="update_rules(this)" value="<%:Manually update%>" />
</div>
</div>
</div>
</fieldset>
</fieldset>

View File

@ -127,6 +127,9 @@ msgstr "与TCP%s节点相同"
msgid "New process"
msgstr "另开进程"
msgid "Current node: %s"
msgstr "当前节点:%s"
msgid "For proxy specific list."
msgstr "用于代理特定的列表。"
@ -595,12 +598,12 @@ msgstr "检测时间"
msgid "Automatic switching cannot be used when this option is checked"
msgstr "当勾选此选项时,不能使用自动切换"
msgid "Main node"
msgstr "主节点"
msgid "List of backup nodes"
msgstr "备用节点的列表"
msgid "List of backup nodes, the first of which must be the primary node and the others the standby node."
msgstr "备用节点的列表,第一个必须是主节点,其他是备用节点。"
msgid "Configure this node with 127.0.0.1: this port"
msgstr "使用127.0.0.1和此端口配置节点"

View File

@ -43,11 +43,6 @@ config global_rules
option chnroute_update '1'
option chnroute6_update '1'
option gfwlist_update '1'
option chnroute6_version '2020-08-22'
option gfwlist_version '2020-08-24'
option chnroute_version '2020-08-24'
option chnlist_version '2020-08-24'
option enable_custom_url '0'
option gfwlist_url 'https://cdn.jsdelivr.net/gh/Loukky/gfwlist-by-loukky/gfwlist.txt'
option chnroute_url 'https://ispip.clang.cn/all_cn.txt'
option chnroute6_url 'https://ispip.clang.cn/all_cn_ipv6.txt'

View File

@ -514,9 +514,9 @@ node_switch() {
local port=$(cat $TMP_PORT_PATH/${1}_${i})
run_redir $node "0.0.0.0" $port $config_file $1 $i
echo $node > $TMP_ID_PATH/${1}_${i}
local node_net=$(echo $1 | tr 'A-Z' 'a-z')
uci set $CONFIG.@global[0].${node_net}_node${i}=$node
uci commit $CONFIG
#local node_net=$(echo $1 | tr 'A-Z' 'a-z')
#uci set $CONFIG.@global[0].${node_net}_node${i}=$node
#uci commit $CONFIG
/etc/init.d/dnsmasq restart >/dev/null 2>&1
}
}

View File

@ -7,7 +7,6 @@ local name = 'passwall'
local arg1 = arg[1]
local rule_path = "/usr/share/" .. name .. "/rules"
local url_main = 'https://cdn.jsdelivr.net/gh/hq450/fancyss/rules'
local reboot = 0
local gfwlist_update = 0
local chnroute_update = 0
@ -26,8 +25,7 @@ local mydnsport = '7913'
local ipsetname = 'gfwlist'
-- custom url
local enable_custom_url = ucic:get_first(name, 'global_rules', "enable_custom_url", 0)
enable_custom_url = 1
local enable_custom_url = 1
local gfwlist_url = ucic:get_first(name, 'global_rules', "gfwlist_url", "https://cdn.jsdelivr.net/gh/Loukky/gfwlist-by-loukky/gfwlist.txt")
local chnroute_url = ucic:get_first(name, 'global_rules', "chnroute_url", "https://ispip.clang.cn/all_cn.txt")
local chnroute6_url = ucic:get_first(name, 'global_rules', "chnroute6_url", "https://ispip.clang.cn/all_cn_ipv6.txt")
@ -330,88 +328,6 @@ if tonumber(enable_custom_url) == 1 then
end
end
if (enable_custom_url) == 0 then
local version = curl(url_main .. "/version1")
if version and tonumber(version) ~= 0 then
if tonumber(gfwlist_update) == 1 then
log("开始更新gfwlist...")
local gfwlist = luci.sys.exec("echo -n $(echo '" .. version .. "' | sed -n 1p)")
local new_version = luci.sys.exec("echo -n $(echo '" .. gfwlist .. "' | awk '{print $1}')")
local new_md5 = luci.sys.exec("echo -n $(echo '" .. gfwlist .. "' | awk '{print $3}')")
if new_version ~= "" and new_md5 ~= "" then
local old_version = ucic:get_first(name, 'global_rules', "gfwlist_version", "nil")
local old_md5 = luci.sys.exec("echo -n $(md5sum " .. rule_path .. "/gfwlist.conf | awk '{print $1}')")
if old_md5 ~= new_md5 or old_version ~= new_version then
curl(url_main .. "/gfwlist.conf", "/tmp/gfwlist_tmp")
local download_md5 = luci.sys.exec("echo -n $([ -f '/tmp/gfwlist_tmp' ] && md5sum /tmp/gfwlist_tmp | awk '{print $1}')")
if download_md5 == new_md5 then
luci.sys.exec("mv -f /tmp/gfwlist_tmp " .. rule_path .. "/gfwlist.conf")
ucic:set(name, ucic:get_first(name, 'global_rules'), "gfwlist_version", new_version)
reboot = 1
log("更新gfwlist成功...")
end
else
log("gfwlist版本一致不用更新。")
end
else
log("gfwlist文件下载失败")
end
end
if tonumber(chnroute_update) == 1 and tonumber(enable_custom_url) == 0 then
log("开始更新chnroute...")
local chnroute = luci.sys.exec("echo -n $(echo '" .. version .. "' | sed -n 2p)")
local new_version = luci.sys.exec("echo -n $(echo '" .. chnroute .. "' | awk '{print $1}')")
local new_md5 = luci.sys.exec("echo -n $(echo '" .. chnroute .. "' | awk '{print $3}')")
if new_version ~= "" and new_md5 ~= "" then
local old_version = ucic:get_first(name, 'global_rules', "chnroute_version", "nil")
local old_md5 = luci.sys.exec("echo -n $(md5sum " .. rule_path .. "/chnroute | awk '{print $1}')")
if old_md5 ~= new_md5 or old_version ~= new_version then
curl(url_main .. "/chnroute.txt", "/tmp/chnroute_tmp")
local download_md5 = luci.sys.exec("echo -n $([ -f '/tmp/chnroute_tmp' ] && md5sum /tmp/chnroute_tmp | awk '{print $1}')")
if download_md5 == new_md5 then
luci.sys.exec("mv -f /tmp/chnroute_tmp " .. rule_path .. "/chnroute")
ucic:set(name, ucic:get_first(name, 'global_rules'), "chnroute_version", new_version)
reboot = 1
log("更新chnroute成功...")
end
else
log("chnroute版本一致不用更新。")
end
else
log("chnroute文件下载失败")
end
end
if tonumber(chnlist_update) == 1 then
log("开始更新chnlist...")
local chnlist = luci.sys.exec("echo -n $(echo '" .. version .. "' | sed -n 4p)")
local new_version = luci.sys.exec("echo -n $(echo '" .. chnlist .. "' | awk '{print $1}')")
local new_md5 = luci.sys.exec("echo -n $(echo '" .. chnlist .. "' | awk '{print $3}')")
if new_version ~= "" and new_md5 ~= "" then
local old_version = ucic:get_first(name, 'global_rules', "chnlist_version", "nil")
local old_md5 = luci.sys.exec("echo -n $(md5sum " .. rule_path .. "/chnlist | awk '{print $1}')")
if old_md5 ~= new_md5 or old_version ~= new_version then
curl(url_main .. "/cdn.txt", "/tmp/chnlist_tmp")
local download_md5 = luci.sys.exec("echo -n $([ -f '/tmp/chnlist_tmp' ] && md5sum /tmp/chnlist_tmp | awk '{print $1}')")
if download_md5 == new_md5 then
luci.sys.exec("mv -f /tmp/chnlist_tmp " .. rule_path .. "/chnlist")
ucic:set(name, ucic:get_first(name, 'global_rules'), "chnlist_version", new_version)
reboot = 1
log("更新chnlist成功...")
end
else
log("chnlist版本一致不用更新。")
end
else
log("chnlist文件下载失败")
end
end
else
log("版本信息下载失败!")
end
end
ucic:set(name, ucic:get_first(name, 'global_rules'), "gfwlist_update", gfwlist_update)
ucic:set(name, ucic:get_first(name, 'global_rules'), "chnroute_update", chnroute_update)
ucic:set(name, ucic:get_first(name, 'global_rules'), "chnroute6_update", chnroute6_update)

View File

@ -4077,6 +4077,12 @@
103.154.164.0/23
103.154.168.0/23
103.154.242.0/23
103.155.14.0/23
103.155.16.0/23
103.155.34.0/23
103.155.48.0/23
103.155.76.0/23
103.155.100.0/23
103.192.0.0/22
103.192.4.0/22
103.192.8.0/22

View File

@ -88,6 +88,8 @@
2001:df4:4d80::/48
2001:df4:5900::/48
2001:df4:a680::/48
2001:df4:a980::/48
2001:df4:c180::/48
2001:df4:cf00::/48
2001:df5:7800::/48
2001:df6:100::/48
@ -1603,18 +1605,23 @@
2406:6080::/32
2406:6100::/32
2406:6180::/32
2406:61c0::/30
2406:6280::/32
2406:6300::/32
2406:6340::/32
2406:6380::/32
2406:6480::/32
2406:6500::/32
2406:6580::/32
2406:65c0::/32
2406:6640::/32
2406:6680::/32
2406:6780::/32
2406:6880::/32
2406:6980::/32
2406:6a80::/32
2406:6b80::/32
2406:6bc0::/32
2406:6c80::/32
2406:6d80::/32
2406:6e80::/32

View File

@ -85,6 +85,16 @@ do
}
end)
local tcp_main1 = ucic2:get(application, "@auto_switch[0]", "tcp_main1") or "nil"
CONFIG[#CONFIG + 1] = {
log = false,
remarks = "自动切换TCP_1主节点",
currentNode = ucic2:get_all(application, tcp_main1),
set = function(server)
ucic2:set(application, "@auto_switch[0]", "tcp_main1", server)
end
}
local tcp_node1_table = ucic2:get(application, "@auto_switch[0]", "tcp_node1")
if tcp_node1_table then
local nodes = {}

View File

@ -9,6 +9,11 @@ echolog() {
echo -e "$d: $1" >> $LOG_FILE
}
config_n_get() {
local ret=$(uci -q get "${CONFIG}.${1}.${2}" 2>/dev/null)
echo "${ret:=$3}"
}
config_t_get() {
local index=0
[ -n "$4" ] && index=$4
@ -63,7 +68,7 @@ test_auto_switch() {
status=$(test_proxy)
if [ "$status" == 0 ]; then
#echolog "自动切换检测:${type}_${index}节点正常。"
echolog "自动切换检测:${type}_${index}节点正常。"
return 0
elif [ "$status" == 2 ]; then
echolog "自动切换检测:无法连接到网络,请检查网络是否正常!"
@ -71,13 +76,21 @@ test_auto_switch() {
elif [ "$status" == 1 ]; then
echolog "自动切换检测:${type}_${index}节点异常,开始切换节点!"
#检测自动切换列表主节点是否能使用
local main_node=$(echo $b_tcp_nodes | awk -F ' ' '{print $1}')
#检测主节点是否能使用
local main_node=$(config_t_get auto_switch tcp_main1)
if [ "$now_node" != "$main_node" ]; then
local tmp_port=$(/usr/share/passwall/app.sh get_new_port 61080 tcp)
/usr/share/passwall/app.sh run_socks "$main_node" "127.0.0.1" "$tmp_port" "/var/etc/passwall/auto_switch_main.json" "10"
proxy_status=$(test_url "https://www.google.com/generate_204" 3 3 "-x socks5h://127.0.0.1:$tmp_port")
ps -w | grep -v "grep" | grep "/var/etc/passwall/auto_switch_main.json" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1
local node_type=$(echo $(config_n_get $main_node type) | tr 'A-Z' 'a-z')
if [ "$node_type" == "socks" ]; then
local node_address=$(config_n_get $main_node address)
local node_port=$(config_n_get $main_node port)
[ -n "$node_address" ] && [ -n "$node_port" ] && local curlx="socks5h://$node_address:$node_port"
else
local tmp_port=$(/usr/share/passwall/app.sh get_new_port 61080 tcp)
/usr/share/passwall/app.sh run_socks "$main_node" "127.0.0.1" "$tmp_port" "/var/etc/passwall/auto_switch_$index.json" "10"
local curlx="socks5h://127.0.0.1:$tmp_port"
fi
proxy_status=$(test_url "https://www.google.com/generate_204" 3 3 "-x $curlx")
ps -w | grep -v "grep" | grep "/var/etc/passwall/auto_switch_$index.json" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1
if [ "$proxy_status" -eq 200 ]; then
#主节点正常,切换到主节点
echolog "自动切换检测:${type}_${index}主节点正常,切换到主节点!"
@ -90,7 +103,7 @@ test_auto_switch() {
in_backup_nodes=$(echo $b_tcp_nodes | grep $now_node)
# 判断当前节点是否存在于备用节点列表里
if [ -z "$in_backup_nodes" ]; then
# 如果不存在,设置第一节点为新的节点
# 如果不存在,设置第一节点为新的节点
new_node=$(echo $b_tcp_nodes | awk -F ' ' '{print $1}')
else
# 如果存在,设置下一个备用节点为新的节点

View File

@ -0,0 +1,16 @@
# Copyright (C) 2020 Lienol <lawlienol@gmail.com>
#
# This is free software, licensed under the GNU General Public License v3.
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for Socat
LUCI_DEPENDS:=+socat
LUCI_PKGARCH:=all
PKG_RELEASE:=3
PKG_DATE:=20200824
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,19 @@
-- Copyright 2020 Lienol <lawlienol@gmail.com>
module("luci.controller.socat", package.seeall)
local http = require "luci.http"
function index()
if not nixio.fs.access("/etc/config/socat") then return end
entry({"admin", "network", "socat"}, cbi("socat/index"), _("Socat"), 100)
entry({"admin", "network", "socat", "config"}, cbi("socat/config")).leaf = true
entry({"admin", "network", "socat", "status"}, call("status")).leaf = true
end
function status()
local e = {}
e.index = luci.http.formvalue("index")
e.status = luci.sys.call(string.format("ps -w | grep -v 'grep' | grep '/var/etc/socat/%s' >/dev/null", luci.http.formvalue("id"))) == 0
http.prepare_content("application/json")
http.write_json(e)
end

View File

@ -0,0 +1,82 @@
local d = require "luci.dispatcher"
m = Map("socat", translate("Socat Config"))
m.redirect = d.build_url("admin", "network", "socat")
s = m:section(NamedSection, arg[1], "config", "")
s.addremove = false
s.dynamic = false
o = s:option(Flag, "enable", translate("Enable"))
o.default = "1"
o.rmempty = false
o = s:option(Value, "remarks", translate("Remarks"))
o.default = translate("Remarks")
o.rmempty = false
o = s:option(ListValue, "protocol", translate("Protocol"))
o:value("port_forwards", translate("Port Forwards"))
o = s:option(ListValue, "family", translate("Restrict to address family"))
o:value("", translate("IPv4 and IPv6"))
o:value("4", translate("IPv4 only"))
o:value("6", translate("IPv6 only"))
o:depends("protocol", "port_forwards")
o = s:option(ListValue, "proto", translate("Protocol"))
o:value("tcp", "TCP")
o:value("udp", "UDP")
o:depends("protocol", "port_forwards")
o = s:option(Value, "listen_port", translate("Listen port"))
o.datatype = "portrange"
o.rmempty = false
o:depends("protocol", "port_forwards")
o = s:option(Flag, "reuseaddr", "reuseaddr", translate("Bind to a port local"))
o.default = "1"
o.rmempty = false
o = s:option(ListValue, "dest_proto", translate("Destination Protocol"))
o:value("tcp4", "IPv4-TCP")
o:value("udp4", "IPv4-UDP")
o:value("tcp6", "IPv6-TCP")
o:value("udp6", "IPv6-UDP")
o:depends("protocol", "port_forwards")
dest_ipv4 = s:option(Value, "dest_ipv4", translate("Destination address"))
luci.sys.net.ipv4_hints(function(ip, name)
dest_ipv4:value(ip, "%s (%s)" %{ ip, name })
end)
function dest_ipv4.cfgvalue(self, section)
return m:get(section, "dest_ip")
end
function dest_ipv4.write(self, section, value)
m:set(section, "dest_ip", value)
end
dest_ipv4:depends("dest_proto", "tcp4")
dest_ipv4:depends("dest_proto", "udp4")
dest_ipv6 = s:option(Value, "dest_ipv6", translate("Destination address"))
luci.sys.net.ipv6_hints(function(ip, name)
dest_ipv6:value(ip, "%s (%s)" %{ ip, name })
end)
function dest_ipv6.cfgvalue(self, section)
return m:get(section, "dest_ip")
end
function dest_ipv6.write(self, section, value)
m:set(section, "dest_ip", value)
end
dest_ipv6:depends("dest_proto", "tcp6")
dest_ipv6:depends("dest_proto", "udp6")
o = s:option(Value, "dest_port", translate("Destination port"))
o.datatype = "portrange"
o.rmempty = false
o = s:option(Flag, "firewall_accept", translate("Open firewall port"))
o.default = "1"
o.rmempty = false
return m

View File

@ -0,0 +1,76 @@
local d = require "luci.dispatcher"
local e = luci.model.uci.cursor()
m = Map("socat", translate("Socat"), translate("Socat is a versatile networking tool named after 'Socket CAT', which can be regarded as an N-fold enhanced version of NetCat"))
s = m:section(NamedSection, "global", "global")
s.anonymous = true
s.addremove = false
o = s:option(Flag, "enable", translate("Enable"))
o.rmempty = false
s = m:section(TypedSection, "config", translate("Port Forwards"))
s.anonymous = true
s.addremove = true
s.template = "cbi/tblsection"
s.extedit = d.build_url("admin", "network", "socat", "config", "%s")
function s.filter(e, t)
if m:get(t, "protocol") == "port_forwards" then
return true
end
end
function s.create(e, t)
local uuid = string.gsub(luci.sys.exec("echo -n $(cat /proc/sys/kernel/random/uuid)"), "-", "")
t = uuid
TypedSection.create(e, t)
luci.http.redirect(e.extedit:format(t))
end
function s.remove(e, t)
e.map.proceed = true
e.map:del(t)
luci.http.redirect(d.build_url("admin", "network", "socat"))
end
o = s:option(Flag, "enable", translate("Enable"))
o.width = "5%"
o.rmempty = false
o = s:option(DummyValue, "status", translate("Status"))
o.template = "socat/status"
o.value = translate("Collecting data...")
o = s:option(DummyValue, "remarks", translate("Remarks"))
o = s:option(DummyValue, "family", translate("Listen Protocol"))
o.cfgvalue = function(t, n)
local listen = Value.cfgvalue(t, n) or ""
local protocol = (m:get(n, "proto") or ""):upper()
if listen == "" then
return protocol
else
return "IPv" .. listen .. "-" .. protocol
end
end
o = s:option(DummyValue, "listen_port", translate("Listen port"))
o = s:option(DummyValue, "dest_proto", translate("Destination Protocol"))
o.cfgvalue = function(t, n)
local listen = Value.cfgvalue(t, n)
local protocol = listen:sub(0, #listen - 1):upper()
local ip_type = "IPv" .. listen:sub(#listen)
return ip_type .. "-" .. protocol
end
o = s:option(DummyValue, "dest_ip", translate("Destination address"))
o = s:option(DummyValue, "dest_port", translate("Destination port"))
o = s:option(Flag, "firewall_accept", translate("Open firewall port"))
o.default = "1"
o.rmempty = false
m:append(Template("socat/list_status"))
return m

View File

@ -0,0 +1,19 @@
<script type="text/javascript">
//<![CDATA[
var _status = document.getElementsByClassName('_status');
for(var i = 0; i < _status.length; i++) {
var id = _status[i].parentElement.parentElement.parentElement.id;
id = id.substr(id.lastIndexOf("-") + 1);
XHR.poll(1,'<%=url([[admin]], [[network]], [[socat]], [[status]])%>', {
index: i,
id: id
},
function(x, result) {
_status[result.index].setAttribute("style","font-weight:bold;");
_status[result.index].setAttribute("color",result.status ? "green":"red");
_status[result.index].innerHTML = (result.status ? '✓' : 'X');
}
);
}
//]]>
</script>

View File

@ -0,0 +1,3 @@
<%+cbi/valueheader%>
<font class="_status" hint="<%=self:cfgvalue(section)%>">--</font>
<%+cbi/valuefooter%>

View File

@ -0,0 +1,50 @@
msgid "Socat"
msgstr "Socat"
msgid "Socat is a versatile networking tool named after 'Socket CAT', which can be regarded as an N-fold enhanced version of NetCat"
msgstr "Socat 是 Linux 下的一个多功能的网络工具名字来由是「Socket CAT」。其功能与有瑞士军刀之称的 Netcat 类似,可以看做是 Netcat 的加强版。"
msgid "Socat Config"
msgstr "Socat 配置"
msgid "Status"
msgstr "状态"
msgid "Enabled"
msgstr "启用"
msgid "Remarks"
msgstr "备注"
msgid "Protocol"
msgstr "协议"
msgid "IPv6 Only"
msgstr "仅IPv6"
msgid "When checked, only IPv6 ports are listen for, otherwise IPv4 will also be listened for."
msgstr "当勾选时仅监听IPv6否则将会同时监听IPv4。"
msgid "Port Forwards"
msgstr "端口转发"
msgid "Listen Protocol"
msgstr "监听协议"
msgid "Listen port"
msgstr "监听端口"
msgid "Bind to a port local"
msgstr "绑定到本地端口"
msgid "Destination Protocol"
msgstr "目标协议"
msgid "Destination address"
msgstr "目标地址"
msgid "Destination port"
msgstr "目标端口"
msgid "Open firewall port"
msgstr "打开防火墙端口"

View File

@ -0,0 +1,3 @@
config global 'global'
option enable '0'

View File

@ -0,0 +1,119 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2020 Lienol <lawlienol@gmail.com>
START=99
CONFIG=socat
CONFIG_PATH=/var/etc/$CONFIG
add_rule() {
iptables -N SOCAT
iptables -I INPUT -j SOCAT
ip6tables -N SOCAT
ip6tables -I INPUT -j SOCAT
}
del_rule() {
iptables -D INPUT -j SOCAT 2>/dev/null
iptables -F SOCAT 2>/dev/null
iptables -X SOCAT 2>/dev/null
ip6tables -D INPUT -j SOCAT 2>/dev/null
ip6tables -F SOCAT 2>/dev/null
ip6tables -X SOCAT 2>/dev/null
}
gen_include() {
echo '#!/bin/sh' > /var/etc/$CONFIG.include
extract_rules() {
local _ipt="iptables"
[ "$1" == "6" ] && _ipt="ip6tables"
echo "*$2"
${_ipt}-save -t $2 | grep "SOCAT" | \
sed -e "s/^-A \(INPUT\)/-I \1 1/"
echo 'COMMIT'
}
cat <<-EOF >> /var/etc/$CONFIG.include
iptables-save -c | grep -v "SOCAT" | iptables-restore -c
iptables-restore -n <<-EOT
$(extract_rules 4 filter)
EOT
ip6tables-save -c | grep -v "SOCAT" | ip6tables-restore -c
ip6tables-restore -n <<-EOT
$(extract_rules 6 filter)
EOT
EOF
return 0
}
run_service() {
config_get enable $1 enable
[ "$enable" = "0" ] && return 0
config_get remarks $1 remarks
config_get protocol $1 protocol
config_get family $1 family
config_get proto $1 proto
config_get listen_port $1 listen_port
config_get reuseaddr $1 reuseaddr
config_get dest_proto $1 dest_proto
config_get dest_ip $1 dest_ip
config_get dest_port $1 dest_port
config_get firewall_accept $1 firewall_accept
ln -s /usr/bin/socat ${CONFIG_PATH}/$1
if [ "$reuseaddr" == "1" ]; then
reuseaddr=",reuseaddr"
else
reuseaddr=""
fi
if [ "$family" == "6" ]; then
ipv6only_params=",ipv6-v6only"
else
ipv6only_params=""
fi
# 端口转发
if [ "$protocol" == "port_forwards" ]; then
listen=${proto}${family}
[ "$family" == "" ] && listen=${proto}6
${CONFIG_PATH}/$1 ${listen}-listen:${listen_port}${ipv6only_params}${reuseaddr},fork ${dest_proto}:${dest_ip}:${dest_port} >/dev/null 2>&1 &
fi
[ "$firewall_accept" == "1" ] && {
if [ -z "$family" ] || [ "$family" == "6" ]; then
ip6tables -A SOCAT -p $proto --dport $listen_port -m comment --comment "$remarks" -j ACCEPT
fi
if [ -z "$family" ] || [ "$family" == "4" ]; then
iptables -A SOCAT -p $proto --dport $listen_port -m comment --comment "$remarks" -j ACCEPT
fi
}
}
stop_service() {
ps -w | grep "$CONFIG_PATH/" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
del_rule
rm -rf $CONFIG_PATH /var/etc/$CONFIG.include
}
start() {
enable=$(uci -q get $CONFIG.@global[0].enable)
if [ "$enable" = "0" ];then
stop_service
else
mkdir -p $CONFIG_PATH
add_rule
config_load $CONFIG
config_foreach run_service "config"
gen_include
fi
}
stop() {
stop_service
}
restart() {
stop
start
}

View File

@ -0,0 +1,19 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete firewall.socat
set firewall.socat=include
set firewall.socat.type=script
set firewall.socat.path=/var/etc/socat.include
set firewall.socat.reload=1
EOF
uci -q batch <<-EOF >/dev/null
delete ucitrack.@socat[-1]
add ucitrack socat
set ucitrack.@socat[-1].init=socat
commit ucitrack
EOF
rm -rf /tmp/luci-*cache
exit 0

View File

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=fstools
PKG_RELEASE:=4
PKG_RELEASE:=5
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/fstools.git

View File

@ -16,6 +16,10 @@ restart() {
/sbin/block mount
}
restart() {
start
}
stop() {
/sbin/block umount
}