Merge Mainline
This commit is contained in:
commit
8dbe7b1459
4
Makefile
4
Makefile
@ -18,7 +18,7 @@ $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt dir
|
||||
|
||||
world:
|
||||
|
||||
DISTRO_PKG_CONFIG:=$(shell which -a pkg-config | grep -E '\/usr' | head -n 1)
|
||||
DISTRO_PKG_CONFIG:=$(shell command -pv pkg-config | grep -E '\/usr' | head -n 1)
|
||||
export PATH:=$(TOPDIR)/staging_dir/host/bin:$(PATH)
|
||||
|
||||
ifneq ($(OPENWRT_BUILD),1)
|
||||
@ -64,7 +64,7 @@ dirclean: clean
|
||||
|
||||
cacheclean:
|
||||
ifneq ($(CONFIG_CCACHE),)
|
||||
rm -rf $(CCACHE_DIR)
|
||||
$(STAGING_DIR_HOST)/bin/ccache -C
|
||||
endif
|
||||
|
||||
ifndef DUMP_TARGET_DB
|
||||
|
||||
@ -15,7 +15,7 @@ MAKE_PATH = $(firstword $(CMAKE_BINARY_SUBDIR) .)
|
||||
ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
|
||||
cmake_tool=$(TOOLCHAIN_DIR)/bin/$(1)
|
||||
else
|
||||
cmake_tool=$(shell which $(1))
|
||||
cmake_tool=$(shell command -v $(1))
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CCACHE),)
|
||||
|
||||
@ -52,7 +52,7 @@ endef
|
||||
|
||||
define RequireCommand
|
||||
define Require/$(1)
|
||||
which $(1)
|
||||
command -pv $(1)
|
||||
endef
|
||||
|
||||
$$(eval $$(call Require,$(1),$(2)))
|
||||
@ -106,7 +106,7 @@ define SetupHostCommand
|
||||
$(call QuoteHostCommand,$(11)) $(call QuoteHostCommand,$(12)); do \
|
||||
if [ -n "$$$$$$$$cmd" ]; then \
|
||||
bin="$$$$$$$$(PATH="$(subst $(space),:,$(filter-out $(STAGING_DIR_HOST)/%,$(subst :,$(space),$(PATH))))" \
|
||||
which "$$$$$$$${cmd%% *}")"; \
|
||||
command -pv "$$$$$$$${cmd%% *}")"; \
|
||||
if [ -x "$$$$$$$$bin" ] && eval "$$$$$$$$cmd" >/dev/null 2>/dev/null; then \
|
||||
mkdir -p "$(STAGING_DIR_HOST)/bin"; \
|
||||
ln -sf "$$$$$$$$bin" "$(STAGING_DIR_HOST)/bin/$(strip $(1))"; \
|
||||
|
||||
@ -19,7 +19,6 @@ else
|
||||
SOURCE_DATE_EPOCH:=$(shell $(TOPDIR)/scripts/get_source_date_epoch.sh)
|
||||
endif
|
||||
|
||||
HOSTCC ?= $(CC)
|
||||
export REVISION
|
||||
export SOURCE_DATE_EPOCH
|
||||
export GIT_CONFIG_PARAMETERS='core.autocrlf=false'
|
||||
@ -59,13 +58,6 @@ export PATH:=$(path)
|
||||
|
||||
unexport TAR_OPTIONS
|
||||
|
||||
ifneq ($(shell $(HOSTCC) 2>&1 | grep clang),)
|
||||
export HOSTCC_REAL?=$(HOSTCC)
|
||||
export HOSTCC_WRAPPER:=$(TOPDIR)/scripts/clang-gcc-wrapper
|
||||
else
|
||||
export HOSTCC_WRAPPER:=$(HOSTCC)
|
||||
endif
|
||||
|
||||
ifeq ($(FORCE),)
|
||||
.config scripts/config/conf scripts/config/mconf: staging_dir/host/.prereq-build
|
||||
endif
|
||||
@ -115,7 +107,7 @@ endif
|
||||
scripts/config/%onf: CFLAGS+= -O2
|
||||
scripts/config/%onf:
|
||||
@$(_SINGLE)$(SUBMAKE) $(if $(findstring s,$(OPENWRT_VERBOSE)),,-s) \
|
||||
-C scripts/config $(notdir $@) CC="$(HOSTCC_WRAPPER)"
|
||||
-C scripts/config $(notdir $@)
|
||||
|
||||
$(eval $(call rdep,scripts/config,scripts/config/mconf))
|
||||
|
||||
@ -269,8 +261,8 @@ package/symlinks-clean:
|
||||
help:
|
||||
cat README.md
|
||||
|
||||
distclean: cacheclean
|
||||
rm -rf bin build_dir .config* dl feeds key-build* logs package/feeds package/openwrt-packages staging_dir tmp
|
||||
distclean:
|
||||
rm -rf bin build_dir .ccache .config* dl feeds key-build* logs package/feeds package/openwrt-packages staging_dir tmp
|
||||
@$(_SINGLE)$(SUBMAKE) -C scripts/config clean
|
||||
|
||||
ifeq ($(findstring v,$(DEBUG)),)
|
||||
|
||||
@ -8,11 +8,11 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=bpytop
|
||||
PKG_VERSION:=1.0.53
|
||||
PKG_VERSION:=1.0.54
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PYPI_NAME:=bpytop
|
||||
PKG_HASH:=d08b8120444e7f35fe032b33495ca551b5890702130c45ad8a56c1fa978fc358
|
||||
PKG_HASH:=a25665e71627a5ec918e6ecf4422bea1ba449069958f64c3879029cfb58a0ac1
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
@ -35,17 +35,11 @@ define Package/bpytop/description
|
||||
endef
|
||||
|
||||
define Package/bpytop/install
|
||||
$(call Py3Package/$(1)/install,$(1))
|
||||
$(call Py3Package/ProcessFilespec,$(1),$(PKG_INSTALL_DIR),$(1))
|
||||
$(FIND) $(1) -name '*.exe' -delete
|
||||
$(call Python3/CompileAll,$(1))
|
||||
$(call Python3/DeleteSourceFiles,$(1))
|
||||
$(call Python3/DeleteEmptyDirs,$(1))
|
||||
if [ -d "$(1)/usr/bin" ]; then \
|
||||
$(call Python3/FixShebang,$(1)/usr/bin/*) ; \
|
||||
fi
|
||||
$(INSTALL_DIR) $(PKG_INSTALL_DIR)/usr/share/bpytop
|
||||
$(CP) $(PKG_BUILD_DIR)/bpytop-themes/* $(PKG_INSTALL_DIR)/usr/share/bpytop/
|
||||
$(call Py3Package/$(1)/install,$(PKG_BUILD_DIR))
|
||||
$(INSTALL_DIR) $(1)/usr
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/* $(1)/usr/
|
||||
$(INSTALL_DIR) $(1)/usr/share/bpytop
|
||||
$(CP) $(PKG_BUILD_DIR)/bpytop-themes/* $(1)/usr/share/bpytop/
|
||||
endef
|
||||
|
||||
$(eval $(call Py3Package,bpytop))
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-openclash
|
||||
PKG_VERSION:=0.41.13
|
||||
PKG_VERSION:=0.41.14
|
||||
PKG_RELEASE:=beta
|
||||
PKG_MAINTAINER:=vernesong <https://github.com/vernesong/OpenClash>
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ end
|
||||
o = s:option(ListValue, "type", translate("Group Type"))
|
||||
o.rmempty = true
|
||||
o.description = translate("Choose The Operation Mode")
|
||||
o:value("select", translate("Select"))
|
||||
o:value("select", translate("Select "))
|
||||
o:value("url-test", translate("URL-Test"))
|
||||
o:value("fallback", translate("Fallback"))
|
||||
o:value("load-balance", translate("Load-Balance"))
|
||||
|
||||
@ -152,6 +152,17 @@ end
|
||||
o:value("DIRECT")
|
||||
o:value("REJECT")
|
||||
|
||||
o = s:option(ListValue, "Disney", translate("Disney"))
|
||||
o:depends("rule_name", "lhie1")
|
||||
o.rmempty = true
|
||||
for groupname in string.gmatch(groupnames, "([^'##\n']+)##") do
|
||||
if groupname ~= nil and groupname ~= "" then
|
||||
o:value(groupname)
|
||||
end
|
||||
end
|
||||
o:value("DIRECT")
|
||||
o:value("REJECT")
|
||||
|
||||
o = s:option(ListValue, "Spotify", translate("Spotify"))
|
||||
o:depends("rule_name", "lhie1")
|
||||
o.rmempty = true
|
||||
|
||||
@ -490,6 +490,9 @@ msgstr "微软服务流量"
|
||||
msgid "Netflix"
|
||||
msgstr "Netflix流量"
|
||||
|
||||
msgid "Disney"
|
||||
msgstr "Disney流量"
|
||||
|
||||
msgid "Spotify"
|
||||
msgstr "Spotify流量"
|
||||
|
||||
@ -783,7 +786,7 @@ msgstr "检测频率(秒)"
|
||||
msgid "Tolerance(ms)"
|
||||
msgstr "节点切换容忍值(毫秒)"
|
||||
|
||||
msgid "Select"
|
||||
msgid "Select "
|
||||
msgstr "Select【手动选择】"
|
||||
|
||||
msgid "URL-Test"
|
||||
|
||||
24
package/ctcgfw/luci-app-openclash/root/etc/init.d/openclash
Normal file → Executable file
24
package/ctcgfw/luci-app-openclash/root/etc/init.d/openclash
Normal file → Executable file
@ -1197,17 +1197,18 @@ firewall_redirect_exclude()
|
||||
|
||||
set_firewall()
|
||||
{
|
||||
if [ "$(iptables -t nat -nL PREROUTING --line-number |grep "udp dpt:53" |grep "0.0.0.0/0 \{0,\}0.0.0.0/0" |wc -l)" -gt 1 ] && [ "$enable_redirect_dns" -eq 1 ]; then
|
||||
|
||||
if [ "$enable_redirect_dns" -eq 1 ] && [ -z "$(iptables -t nat -nL PREROUTING --line-number |grep "redir ports 53$")"]; then
|
||||
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53
|
||||
iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53
|
||||
fi
|
||||
|
||||
if [ "$(iptables -t nat -nL PREROUTING --line-number |grep "redir ports 53" |wc -l)" -gt 2 ] && [ "$enable_redirect_dns" -eq 1 ]; then
|
||||
echo "发现53端口被劫持,清理防火墙规则..." >$START_LOG
|
||||
pre_lines=$(iptables -nvL PREROUTING -t nat |sed 1,2d |sed -n '/0.0.0.0\/0 \{0,\}0.0.0.0\/0 \{0,\}udp dpt:53/=' 2>/dev/null |sort -rn)
|
||||
pre_lines=$(iptables -nvL PREROUTING -t nat |sed 1,2d |sed -n '/redir ports 53/=' 2>/dev/null |sort -rn)
|
||||
for pre_line in $pre_lines; do
|
||||
iptables -t nat -D PREROUTING "$pre_line" >/dev/null 2>&1
|
||||
done
|
||||
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53 >/dev/null 2>&1
|
||||
sleep 2
|
||||
elif [ "$enable_redirect_dns" -eq 1 ] && [ -z "$(iptables -t nat -nL PREROUTING --line-number |grep "redir ports 53$")"]; then
|
||||
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53
|
||||
iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53
|
||||
fi
|
||||
|
||||
if [ -z "$(uci get firewall.openclash 2>/dev/null)" ] || [ -z "$(uci get ucitrack.@openclash[-1].init 2>/dev/null)" ]; then
|
||||
@ -1313,12 +1314,11 @@ if [ -z "$en_mode_tun" ] || [ "$en_mode_tun" -eq 3 ]; then
|
||||
iptables -t nat -A openclash -m set --match-set china_ip_route dst -j RETURN >/dev/null 2>&1
|
||||
fi
|
||||
iptables -t nat -A openclash -p tcp -j REDIRECT --to-ports "$proxy_port"
|
||||
if [ -z "$en_mode_tun" ]; then
|
||||
iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 --dport 53 -j REDIRECT --to-ports "$proxy_port"
|
||||
iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 --dport 53 -j REDIRECT --to-ports "$proxy_port"
|
||||
fi
|
||||
iptables -t nat -A PREROUTING -p tcp -j openclash
|
||||
if [ -z "$en_mode_tun" ]; then
|
||||
#Google dns
|
||||
iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 --dport 53 -j REDIRECT --to-ports "$proxy_port"
|
||||
iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 --dport 53 -j REDIRECT --to-ports "$proxy_port"
|
||||
#udp
|
||||
if [ "$enable_udp_proxy" -eq 1 ]; then
|
||||
modprobe xt_TPROXY >/dev/null 2>&1
|
||||
@ -1754,6 +1754,8 @@ reload()
|
||||
do_run_mode 2>/dev/null
|
||||
get_config 2>/dev/null
|
||||
set_firewall 2>/dev/null
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
echo "${LOGTIME} Reload OpenClash Firewall Rules" >> $LOG_FILE
|
||||
echo "" >$START_LOG
|
||||
fi
|
||||
}
|
||||
|
||||
@ -14,6 +14,12 @@ PORT=$(uci get openclash.config.cn_port 2>/dev/null)
|
||||
LOG_FILE="/tmp/openclash.log"
|
||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||
|
||||
if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then
|
||||
CONFIG_FILE=$(uci get openclash.config.config_path 2>/dev/null)
|
||||
CONFIG_NAME=$(echo "$CONFIG_FILE" |awk -F '/' '{print $5}' 2>/dev/null)
|
||||
HISTORY_PATH="/etc/openclash/history/$CONFIG_NAME"
|
||||
fi
|
||||
|
||||
if [ -n "$(pidof clash)" ] && [ -f "$CONFIG_FILE" ]; then
|
||||
curl -m 5 --retry 2 -w %{http_code}"\n" -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X GET http://"$LAN_IP":"$PORT"/proxies > "$CURL_CACHE" 2>/dev/null
|
||||
if [ "$(sed -n '$p' "$CURL_CACHE" 2>/dev/null)" = "200" ]; then
|
||||
|
||||
@ -43,6 +43,12 @@ close_all_conection() {
|
||||
curl -m 5 --retry 2 -H "Authorization: Bearer ${SECRET}" -H "Content-Type:application/json" -X DELETE http://"$LAN_IP":"$PORT"/connections >/dev/null 2>&1
|
||||
}
|
||||
|
||||
if [ -z "$CONFIG_FILE" ] || [ ! -f "$CONFIG_FILE" ]; then
|
||||
CONFIG_FILE=$(uci get openclash.config.config_path 2>/dev/null)
|
||||
CONFIG_NAME=$(echo "$CONFIG_FILE" |awk -F '/' '{print $5}' 2>/dev/null)
|
||||
HISTORY_PATH="/etc/openclash/history/$CONFIG_NAME"
|
||||
fi
|
||||
|
||||
if [ -s "$HISTORY_PATH" ] && [ ! -z "$(pidof clash)" ]; then
|
||||
cat "$HISTORY_PATH" |while read -r line
|
||||
do
|
||||
|
||||
@ -85,7 +85,10 @@ fi
|
||||
last_line=$(iptables -t nat -nL PREROUTING --line-number |awk '{print $1}' 2>/dev/null |awk 'END {print}' |sed -n '$p')
|
||||
op_line=$(iptables -t nat -nL PREROUTING --line-number |grep "openclash" 2>/dev/null |awk '{print $1}' 2>/dev/null |head -1)
|
||||
if [ "$last_line" != "$op_line" ] && [ -z "$core_type" ]; then
|
||||
iptables -t nat -D PREROUTING -p tcp -j openclash
|
||||
pre_lines=$(iptables -nvL PREROUTING -t nat |sed 1,2d |sed -n '/openclash/=' 2>/dev/null |sort -rn)
|
||||
for pre_line in $pre_lines; do
|
||||
iptables -t nat -D PREROUTING "$pre_line" >/dev/null 2>&1
|
||||
done >/dev/null 2>&1
|
||||
iptables -t nat -A PREROUTING -p tcp -j openclash
|
||||
echo "$LOGTIME Watchdog: Reset Firewall For Enabling Redirect." >>$LOG_FILE
|
||||
fi
|
||||
|
||||
@ -4,12 +4,14 @@ rules:
|
||||
- RULE-SET,Netflix,Netflix
|
||||
- RULE-SET,Spotify,Spotify
|
||||
- RULE-SET,YouTube,YouTube
|
||||
- RULE-SET,Disney Plus,Disney
|
||||
- RULE-SET,Bilibili,AsianTV
|
||||
- RULE-SET,iQiyi,AsianTV
|
||||
- RULE-SET,Letv,AsianTV
|
||||
- RULE-SET,Netease Music,AsianTV
|
||||
- RULE-SET,Tencent Video,AsianTV
|
||||
- RULE-SET,Youku,AsianTV
|
||||
- RULE-SET,WeTV,AsianTV
|
||||
- RULE-SET,ABC,GlobalTV
|
||||
- RULE-SET,Abema TV,GlobalTV
|
||||
- RULE-SET,Amazon,GlobalTV
|
||||
@ -18,7 +20,7 @@ rules:
|
||||
- RULE-SET,Bahamut,GlobalTV
|
||||
- RULE-SET,BBC iPlayer,GlobalTV
|
||||
- RULE-SET,DAZN,GlobalTV
|
||||
- RULE-SET,Disney Plus,GlobalTV
|
||||
- RULE-SET,Discovery Plus,GlobalTV
|
||||
- RULE-SET,encoreTVB,GlobalTV
|
||||
- RULE-SET,Fox Now,GlobalTV
|
||||
- RULE-SET,Fox+,GlobalTV
|
||||
@ -57,12 +59,14 @@ script:
|
||||
"Netflix": "Netflix",
|
||||
"Spotify": "Spotify",
|
||||
"YouTube": "YouTube",
|
||||
"Disney Plus": "Disney",
|
||||
"Bilibili": "AsianTV",
|
||||
"iQiyi": "AsianTV",
|
||||
"Letv": "AsianTV",
|
||||
"Netease Music": "AsianTV",
|
||||
"Tencent Video": "AsianTV",
|
||||
"Youku": "AsianTV",
|
||||
"WeTV": "AsianTV",
|
||||
"ABC": "GlobalTV",
|
||||
"Abema TV": "GlobalTV",
|
||||
"Amazon": "GlobalTV",
|
||||
@ -71,7 +75,7 @@ script:
|
||||
"Bahamut": "GlobalTV",
|
||||
"BBC iPlayer": "GlobalTV",
|
||||
"DAZN": "GlobalTV",
|
||||
"Disney Plus": "GlobalTV",
|
||||
"Discovery Plus": "GlobalTV",
|
||||
"encoreTVB": "GlobalTV",
|
||||
"Fox Now": "GlobalTV",
|
||||
"Fox+": "GlobalTV",
|
||||
@ -187,6 +191,12 @@ rule-providers:
|
||||
url: https://cdn.jsdelivr.net/gh/lhie1/Rules@master/Clash/Provider/Media/Youku.yaml
|
||||
path: "./Rules/Media/Youku"
|
||||
interval: 86400
|
||||
WeTV:
|
||||
type: http
|
||||
behavior: classical
|
||||
url: https://cdn.jsdelivr.net/gh/lhie1/Rules@master/Clash/Provider/Media/WeTV.yaml
|
||||
path: "./Rules/Media/WeTV"
|
||||
interval: 86400
|
||||
ABC:
|
||||
type: http
|
||||
behavior: classical
|
||||
@ -235,6 +245,12 @@ rule-providers:
|
||||
url: https://cdn.jsdelivr.net/gh/lhie1/Rules@master/Clash/Provider/Media/DAZN.yaml
|
||||
path: "./Rules/Media/DAZN"
|
||||
interval: 86400
|
||||
Discovery Plus:
|
||||
type: http
|
||||
behavior: classical
|
||||
url: https://cdn.jsdelivr.net/gh/lhie1/Rules@master/Clash/Provider/Media/Discovery%20Plus.yaml
|
||||
path: "./Rules/Media/Discovery_Plus"
|
||||
interval: 86400
|
||||
Disney Plus:
|
||||
type: http
|
||||
behavior: classical
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -813,6 +813,20 @@ cat >> "$SERVER_FILE" <<-EOF
|
||||
EOF
|
||||
fi
|
||||
cat /tmp/Proxy_Provider >> $SERVER_FILE 2>/dev/null
|
||||
cat >> "$SERVER_FILE" <<-EOF
|
||||
- name: Disney
|
||||
type: select
|
||||
proxies:
|
||||
- GlobalTV
|
||||
- DIRECT
|
||||
EOF
|
||||
cat /tmp/Proxy_Server >> $SERVER_FILE 2>/dev/null
|
||||
if [ -f "/tmp/Proxy_Provider" ]; then
|
||||
cat >> "$SERVER_FILE" <<-EOF
|
||||
use:
|
||||
EOF
|
||||
fi
|
||||
cat /tmp/Proxy_Provider >> $SERVER_FILE 2>/dev/null
|
||||
cat >> "$SERVER_FILE" <<-EOF
|
||||
- name: Youtube
|
||||
type: select
|
||||
@ -947,6 +961,7 @@ ${uci_set}Youtube="Youtube"
|
||||
${uci_set}Apple="Apple"
|
||||
${uci_set}Microsoft="Microsoft"
|
||||
${uci_set}Netflix="Netflix"
|
||||
${uci_set}Disney="Disney"
|
||||
${uci_set}Spotify="Spotify"
|
||||
${uci_set}Steam="Steam"
|
||||
${uci_set}AdBlock="AdBlock"
|
||||
@ -964,6 +979,7 @@ ${uci_set}Others="Others"
|
||||
${UCI_DEL_LIST}="AsianTV" >/dev/null 2>&1 && ${UCI_ADD_LIST}="AsianTV" >/dev/null 2>&1
|
||||
${UCI_DEL_LIST}="GlobalTV" >/dev/null 2>&1 && ${UCI_ADD_LIST}="GlobalTV" >/dev/null 2>&1
|
||||
${UCI_DEL_LIST}="Netflix" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Netflix" >/dev/null 2>&1
|
||||
${UCI_DEL_LIST}="Disney" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Disney" >/dev/null 2>&1
|
||||
${UCI_DEL_LIST}="Spotify" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Spotify" >/dev/null 2>&1
|
||||
${UCI_DEL_LIST}="Steam" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Steam" >/dev/null 2>&1
|
||||
${UCI_DEL_LIST}="Telegram" >/dev/null 2>&1 && ${UCI_ADD_LIST}="Telegram" >/dev/null 2>&1
|
||||
|
||||
@ -137,6 +137,7 @@ yml_other_rules_get()
|
||||
config_get "Youtube" "$section" "Youtube" ""
|
||||
config_get "Apple" "$section" "Apple" ""
|
||||
config_get "Netflix" "$section" "Netflix" ""
|
||||
config_get "Disney" "$section" "Disney" ""
|
||||
config_get "Spotify" "$section" "Spotify" ""
|
||||
config_get "Steam" "$section" "Steam" ""
|
||||
config_get "AdBlock" "$section" "AdBlock" ""
|
||||
@ -180,6 +181,7 @@ if [ "$2" != "0" ]; then
|
||||
|| [ -z "$(grep -F "$Youtube" /tmp/Proxy_Group)" ]\
|
||||
|| [ -z "$(grep -F "$Apple" /tmp/Proxy_Group)" ]\
|
||||
|| [ -z "$(grep -F "$Netflix" /tmp/Proxy_Group)" ]\
|
||||
|| [ -z "$(grep -F "$Disney" /tmp/Proxy_Group)" ]\
|
||||
|| [ -z "$(grep -F "$Spotify" /tmp/Proxy_Group)" ]\
|
||||
|| [ -z "$(grep -F "$Steam" /tmp/Proxy_Group)" ]\
|
||||
|| [ -z "$(grep -F "$AdBlock" /tmp/Proxy_Group)" ]\
|
||||
@ -227,6 +229,7 @@ if [ "$2" != "0" ]; then
|
||||
.gsub(/,YouTube$/, ',$Youtube#d')
|
||||
.gsub(/,Apple$/, ',$Apple#d')
|
||||
.gsub(/,Netflix$/, ',$Netflix#d')
|
||||
.gsub(/,Disney$/, ',$Disney#d')
|
||||
.gsub(/,Spotify$/, ',$Spotify#d')
|
||||
.gsub(/,Steam$/, ',$Steam#d')
|
||||
.gsub(/,AdBlock$/, ',$AdBlock#d')
|
||||
@ -244,6 +247,7 @@ if [ "$2" != "0" ]; then
|
||||
.gsub!(/: \"YouTube\"/,': \"$Youtube#d\"')
|
||||
.gsub!(/: \"Apple\"/,': \"$Apple#d\"')
|
||||
.gsub!(/: \"Netflix\"/,': \"$Netflix#d\"')
|
||||
.gsub!(/: \"Disney\"/,': \"$Disney#d\"')
|
||||
.gsub!(/: \"Spotify\"/,': \"$Spotify#d\"')
|
||||
.gsub!(/: \"Steam\"/,': \"$Steam#d\"')
|
||||
.gsub!(/: \"AdBlock\"/,': \"$AdBlock#d\"')
|
||||
|
||||
68
package/ctcgfw/mt7601u-ap/Makefile
Normal file
68
package/ctcgfw/mt7601u-ap/Makefile
Normal file
@ -0,0 +1,68 @@
|
||||
#
|
||||
# Copyright (C) 2020 CTCGFW Project-OpenWrt
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mt7601u-ap
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2020-05-01
|
||||
PKG_SOURCE_URL:=https://github.com/Anthony96922/mt7601u-ap.git
|
||||
PKG_SOURCE_VERSION:=624307427149e53b75937ccbe7cb235ec3ef2f58
|
||||
PKG_MIRROR_HASH:=70e8f7e94ddca09e1f55ef1b30a47fa7c504750ec654bc0c500f1a3d491eca97
|
||||
|
||||
PKG_MAINTAINER:=[CTCGFW] Project OpenWrt
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
PKG_LICENSE:=GPLv2
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/mt7601u-ap
|
||||
SUBMENU:=Wireless Drivers
|
||||
TITLE:=AP driver for MT7601U dongles
|
||||
DEPENDS:=+kmod-usb-core +wireless-tools @USB_SUPPORT
|
||||
FILES:=$(PKG_BUILD_DIR)/os/linux/mt7601Uap.ko
|
||||
AUTOLOAD:=$(call AutoProbe,mt7601Uap)
|
||||
CONFLICTS:=kmod-mt7601u
|
||||
endef
|
||||
|
||||
define KernelPackage/mt7601u-ap/description
|
||||
AP driver for MT7601U chipset based adapters
|
||||
endef
|
||||
|
||||
MAKE_OPTS:= \
|
||||
ARCH="$(LINUX_KARCH)" \
|
||||
CROSS_COMPILE="$(KERNEL_CROSS)" \
|
||||
LINUX_SRC="$(LINUX_DIR)" \
|
||||
RT28xx_DIR="$(PKG_BUILD_DIR)" \
|
||||
RT28xx_MODE=AP \
|
||||
CHIPSET=7601U \
|
||||
MODULE=7601U \
|
||||
OSABL=NO \
|
||||
|
||||
define Build/Prepare
|
||||
$(Build/Prepare/Default)
|
||||
$(CP) $(PKG_BUILD_DIR)/os/linux/Makefile.6 $(PKG_BUILD_DIR)/os/linux/Makefile
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C "$(LINUX_DIR)" \
|
||||
$(MAKE_OPTS) \
|
||||
M="$(PKG_BUILD_DIR)/os/linux" \
|
||||
modules
|
||||
endef
|
||||
|
||||
define KernelPackage/mt7601u-ap/install
|
||||
$(INSTALL_DIR) $(1)/etc/wifi/RT2870AP
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/RT2870AP.txt $(1)/etc/wifi/RT2870AP/
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,mt7601u-ap))
|
||||
@ -0,0 +1,10 @@
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -943,6 +943,7 @@ then
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ALWAYS_KEEP_SNI"
|
||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_EX_DATA"
|
||||
AM_CFLAGS="$AM_CFLAGS -DHAVE_EXT_CACHE"
|
||||
+ AM_CFLAGS="$AM_CFLAGS -DHAVE_SECRET_CALLBACK"
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_EITHER_SIDE"
|
||||
AM_CFLAGS="$AM_CFLAGS -DOPENSSL_EXTRA_X509_SMALL"
|
||||
|
||||
@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=4
|
||||
PKG_RELEASE:=4
|
||||
PKG_DATE:=20201221
|
||||
PKG_RELEASE:=6
|
||||
PKG_DATE:=20210104
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
@ -136,10 +136,6 @@ define Package/$(PKG_NAME)/conffiles
|
||||
/usr/share/passwall/rules/direct_ip
|
||||
/usr/share/passwall/rules/proxy_host
|
||||
/usr/share/passwall/rules/proxy_ip
|
||||
/usr/share/passwall/rules/proxy_host2
|
||||
/usr/share/passwall/rules/proxy_ip2
|
||||
/usr/share/passwall/rules/proxy_host3
|
||||
/usr/share/passwall/rules/proxy_ip3
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
|
||||
@ -135,21 +135,13 @@ end
|
||||
|
||||
function get_now_use_node()
|
||||
local e = {}
|
||||
local tcp_node_num = ucic:get(appname, "@global_other[0]", "tcp_node_num") or 1
|
||||
e.tcp = tonumber(tcp_node_num)
|
||||
for i = 1, tcp_node_num, 1 do
|
||||
local data, code, msg = nixio.fs.readfile("/var/etc/passwall/id/TCP_" .. i)
|
||||
if data then
|
||||
e["TCP" .. i] = util.trim(data)
|
||||
end
|
||||
local data, code, msg = nixio.fs.readfile("/var/etc/passwall/id/TCP")
|
||||
if data then
|
||||
e["TCP"] = util.trim(data)
|
||||
end
|
||||
local udp_node_num = ucic:get(appname, "@global_other[0]", "udp_node_num") or 1
|
||||
e.udp = tonumber(udp_node_num)
|
||||
for i = 1, udp_node_num, 1 do
|
||||
local data, code, msg = nixio.fs.readfile("/var/etc/passwall/id/UDP_" .. i)
|
||||
if data then
|
||||
e["UDP" .. i] = util.trim(data)
|
||||
end
|
||||
local data, code, msg = nixio.fs.readfile("/var/etc/passwall/id/UDP")
|
||||
if data then
|
||||
e["UDP"] = util.trim(data)
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
@ -158,8 +150,7 @@ end
|
||||
function get_redir_log()
|
||||
local proto = luci.http.formvalue("proto")
|
||||
proto = proto:upper()
|
||||
local index = luci.http.formvalue("index")
|
||||
local filename = proto .. "_" .. index
|
||||
local filename = proto
|
||||
if nixio.fs.access("/var/etc/passwall/" .. filename .. ".log") then
|
||||
local content = luci.sys.exec("cat /var/etc/passwall/" .. filename .. ".log")
|
||||
content = content:gsub("\n", "<br />")
|
||||
@ -183,19 +174,13 @@ function status()
|
||||
local e = {}
|
||||
e.dns_mode_status = luci.sys.call("netstat -apn | grep ':7913 ' >/dev/null") == 0
|
||||
e.haproxy_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
|
||||
local tcp_node_num = ucic:get(appname, "@global_other[0]", "tcp_node_num") or 1
|
||||
for i = 1, tcp_node_num, 1 do
|
||||
e["kcptun_tcp_node%s_status" % i] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/kcptun' | grep -i 'tcp_%s' >/dev/null", appname, i)) == 0
|
||||
e["tcp_node%s_status" % i] = luci.sys.call(string.format("ps -w | grep -v -E 'grep|kcptun' | grep '%s/bin/' | grep -i 'TCP_%s' >/dev/null", appname, i)) == 0
|
||||
end
|
||||
e["kcptun_tcp_node_status"] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/kcptun' | grep -i 'tcp' >/dev/null", appname)) == 0
|
||||
e["tcp_node_status"] = luci.sys.call(string.format("ps -w | grep -v -E 'grep|kcptun' | grep '%s/bin/' | grep -i 'TCP' >/dev/null", appname)) == 0
|
||||
|
||||
local udp_node_num = ucic:get(appname, "@global_other[0]", "udp_node_num") or 1
|
||||
for i = 1, udp_node_num, 1 do
|
||||
if (ucic:get(appname, "@global[0]", "udp_node" .. i) or "nil") == "tcp" then
|
||||
e["udp_node%s_status" % i] = e["tcp_node%s_status" % i]
|
||||
else
|
||||
e["udp_node%s_status" % i] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep -i 'UDP_%s' >/dev/null", appname, i)) == 0
|
||||
end
|
||||
if (ucic:get(appname, "@global[0]", "udp_node") or "nil") == "tcp" then
|
||||
e["udp_node_status"] = e["tcp_node_status"]
|
||||
else
|
||||
e["udp_node_status"] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep -i 'UDP' >/dev/null", appname)) == 0
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
@ -255,9 +240,8 @@ end
|
||||
|
||||
function set_node()
|
||||
local protocol = luci.http.formvalue("protocol")
|
||||
local number = luci.http.formvalue("number")
|
||||
local section = luci.http.formvalue("section")
|
||||
ucic:set(appname, "@global[0]", protocol .. "_node" .. number, section)
|
||||
ucic:set(appname, "@global[0]", protocol .. "_node", section)
|
||||
ucic:commit(appname)
|
||||
luci.sys.call("/etc/init.d/passwall restart > /dev/null 2>&1 &")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname, "log"))
|
||||
|
||||
@ -155,6 +155,7 @@ function gen_outbound(node, tag, relay_port)
|
||||
address = node.address,
|
||||
port = tonumber(node.port),
|
||||
method = node.method or nil,
|
||||
flow = node.flow or nil,
|
||||
password = node.password or "",
|
||||
users = (node.username and node.password) and
|
||||
{{user = node.username, pass = node.password}} or nil
|
||||
|
||||
@ -40,20 +40,6 @@ o = s:option(Value, "mac", translate("MAC"))
|
||||
o.rmempty = true
|
||||
sys.net.mac_hints(function(e, t) o:value(e, "%s (%s)" % {e, t}) end)
|
||||
|
||||
---- TCP Node
|
||||
local tcp_node_num = m:get("@global_other[0]", "tcp_node_num") or 1
|
||||
if tonumber(tcp_node_num) > 1 then
|
||||
o = s:option(ListValue, "tcp_node", translate("TCP Node"))
|
||||
for i = 1, tcp_node_num, 1 do o:value(i, "TCP_" .. i) end
|
||||
end
|
||||
|
||||
---- UDP Node
|
||||
local udp_node_num = m:get("@global_other[0]", "udp_node_num") or 1
|
||||
if tonumber(udp_node_num) > 1 then
|
||||
o = s:option(ListValue, "udp_node", translate("UDP Node"))
|
||||
for i = 1, udp_node_num, 1 do o:value(i, "UDP_" .. i) end
|
||||
end
|
||||
|
||||
---- TCP Proxy Mode
|
||||
o = s:option(ListValue, "tcp_proxy_mode", "TCP" .. translate("Proxy Mode"))
|
||||
o.default = "default"
|
||||
|
||||
@ -25,22 +25,16 @@ o.rmempty = false
|
||||
o = s:option(Value, "testing_time", translate("How often is a diagnosis made"), translate("Units:minutes"))
|
||||
o.default = "3"
|
||||
|
||||
---- TCP Node
|
||||
-- local tcp_node_num = tonumber(m:get("@global_other[0]", "tcp_node_num") or 1)
|
||||
-- 暂时只支持TCP1
|
||||
local tcp_node_num = 1
|
||||
for i = 1, tcp_node_num, 1 do
|
||||
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(ListValue, "tcp_main", "TCP " .. 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
|
||||
|
||||
o = s:option(Flag, "restore_switch" .. i, "TCP " .. i .. " " .. translate("Restore Switch"), translate("When detects main node is available, switch back to the main node."))
|
||||
o = s:option(DynamicList, "tcp_node", "TCP " .. translate("List of backup nodes"))
|
||||
for k, v in pairs(nodes_table) do
|
||||
o:value(v.id, v.remarks)
|
||||
end
|
||||
|
||||
o = s:option(Flag, "restore_switch", "TCP " .. translate("Restore Switch"), translate("When detects main node is available, switch back to the main node."))
|
||||
|
||||
return m
|
||||
|
||||
@ -74,62 +74,51 @@ o = s:taboption("Main", Flag, "enabled", translate("Main switch"))
|
||||
o.rmempty = false
|
||||
|
||||
---- TCP Node
|
||||
local tcp_node_num = tonumber(m:get("@global_other[0]", "tcp_node_num") or 1)
|
||||
for i = 1, tcp_node_num, 1 do
|
||||
o = s:taboption("Main", ListValue, "tcp_node" .. i, translate("TCP Node") .. " " .. i)
|
||||
if i == 1 then
|
||||
o.title = translate("TCP Node")
|
||||
o.description = ""
|
||||
--o.description = translate("For proxy specific list.")
|
||||
--o.description = o.description .. "<br />"
|
||||
local current_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 current_node and current_node ~= "" and current_node ~= "nil" then
|
||||
local n = uci:get_all(appname, current_node)
|
||||
if n then
|
||||
if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then
|
||||
local remarks = api.get_full_node_remarks(n)
|
||||
local url = d.build_url("admin", "services", appname, "node_config", current_node)
|
||||
o.description = o.description .. translatef("Current node: %s", string.format('<a href="%s">%s</a>', url, remarks)) .. "<br />"
|
||||
end
|
||||
if n.protocol and n.protocol == "_shunt" then
|
||||
uci:foreach(appname, "shunt_rules", function(e)
|
||||
local id = e[".name"]
|
||||
local remarks = translate(e.remarks)
|
||||
if n[id] and n[id] ~= "nil" then
|
||||
local url = d.build_url("admin", "services", appname, "node_config", n[id])
|
||||
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
|
||||
o.description = o.description .. remarks .. ":" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
|
||||
end
|
||||
end)
|
||||
local id = "default_node"
|
||||
local remarks = translate("Default")
|
||||
if n[id] and n[id] ~= "nil" then
|
||||
local url = d.build_url("admin", "services", appname, "node_config", n[id])
|
||||
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
|
||||
o.description = o.description .. remarks .. ":" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
|
||||
end
|
||||
o = s:taboption("Main", ListValue, "tcp_node", translate("TCP Node"))
|
||||
o.title = translate("TCP Node")
|
||||
o.description = ""
|
||||
--o.description = translate("For proxy specific list.")
|
||||
--o.description = o.description .. "<br />"
|
||||
local current_node = luci.sys.exec(string.format("[ -f '/var/etc/%s/id/TCP' ] && echo -n $(cat /var/etc/%s/id/TCP)", appname, appname))
|
||||
if current_node and current_node ~= "" and current_node ~= "nil" then
|
||||
local n = uci:get_all(appname, current_node)
|
||||
if n then
|
||||
if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then
|
||||
local remarks = api.get_full_node_remarks(n)
|
||||
local url = d.build_url("admin", "services", appname, "node_config", current_node)
|
||||
o.description = o.description .. translatef("Current node: %s", string.format('<a href="%s">%s</a>', url, remarks)) .. "<br />"
|
||||
end
|
||||
if n.protocol and n.protocol == "_shunt" then
|
||||
uci:foreach(appname, "shunt_rules", function(e)
|
||||
local id = e[".name"]
|
||||
local remarks = translate(e.remarks)
|
||||
if n[id] and n[id] ~= "nil" then
|
||||
local url = d.build_url("admin", "services", appname, "node_config", n[id])
|
||||
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
|
||||
o.description = o.description .. remarks .. ":" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
|
||||
end
|
||||
end)
|
||||
local id = "default_node"
|
||||
local remarks = translate("Default")
|
||||
if n[id] and n[id] ~= "nil" then
|
||||
local url = d.build_url("admin", "services", appname, "node_config", n[id])
|
||||
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
|
||||
o.description = o.description .. remarks .. ":" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
|
||||
end
|
||||
end
|
||||
end
|
||||
o:value("nil", translate("Close"))
|
||||
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end
|
||||
end
|
||||
o:value("nil", translate("Close"))
|
||||
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end
|
||||
|
||||
---- UDP Node
|
||||
local udp_node_num = tonumber(m:get("@global_other[0]", "udp_node_num") or 1)
|
||||
for i = 1, udp_node_num, 1 do
|
||||
o = s:taboption("Main", ListValue, "udp_node" .. i, translate("UDP Node") .. " " .. i)
|
||||
o:value("nil", translate("Close"))
|
||||
if i == 1 then
|
||||
o.title = translate("UDP Node")
|
||||
--o.description = translate("For proxy game network, DNS hijack etc.") .. "<br />" .. translate("The selected server will not use Kcptun.")
|
||||
o:value("tcp_", translate("Same as the tcp node"))
|
||||
--o:value("tcp", translate("Same as the tcp node"))
|
||||
--o:value("tcp_", translate("Same as the tcp node") .. "(" .. translate("New process") .. ")")
|
||||
end
|
||||
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end
|
||||
end
|
||||
o = s:taboption("Main", ListValue, "udp_node", translate("UDP Node"))
|
||||
o:value("nil", translate("Close"))
|
||||
o.title = translate("UDP Node")
|
||||
--o.description = translate("For proxy game network, DNS hijack etc.") .. "<br />" .. translate("The selected server will not use Kcptun.")
|
||||
o:value("tcp_", translate("Same as the tcp node"))
|
||||
--o:value("tcp", translate("Same as the tcp node"))
|
||||
--o:value("tcp_", translate("Same as the tcp node") .. "(" .. translate("New process") .. ")")
|
||||
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end
|
||||
|
||||
s:tab("DNS", translate("DNS"))
|
||||
|
||||
@ -306,14 +295,12 @@ o.default = "default"
|
||||
o.rmempty = false
|
||||
|
||||
s:tab("log", translate("Log"))
|
||||
for i = 1, tcp_node_num, 1 do
|
||||
o = s:taboption("log", Flag, "close_log_tcp_" .. i , translate("Close") .. translate("Log") .. " " .. translate("TCP Node") .. " " .. i)
|
||||
o.rmempty = false
|
||||
end
|
||||
for i = 1, udp_node_num, 1 do
|
||||
o = s:taboption("log", Flag, "close_log_udp_" .. i, translate("Close") .. translate("Log") .. " " .. translate("UDP Node") .. " " .. i)
|
||||
o.rmempty = false
|
||||
end
|
||||
o = s:taboption("log", Flag, "close_log_tcp", translate("Close") .. translate("Log") .. " " .. translate("TCP Node"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:taboption("log", Flag, "close_log_udp", translate("Close") .. translate("Log") .. " " .. translate("UDP Node"))
|
||||
o.rmempty = false
|
||||
|
||||
loglevel = s:taboption("log", ListValue, "loglevel", "X/V2ray" .. translate("Log Level"))
|
||||
loglevel.default = "warning"
|
||||
loglevel:value("debug")
|
||||
@ -355,10 +342,7 @@ o.default = 1
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "node", translate("Socks Node"))
|
||||
local tcp_node_num = tonumber(m:get("@global_other[0]", "tcp_node_num") or 1)
|
||||
for i = 1, tcp_node_num, 1 do
|
||||
o:value("tcp" .. i, translatef("Same as the tcp %s node", i))
|
||||
end
|
||||
o:value("tcp", translate("Same as the tcp node"))
|
||||
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end
|
||||
|
||||
o = s:option(Value, "port", "Socks" .. translate("Listen Port"))
|
||||
|
||||
@ -454,8 +454,10 @@ tls:depends("type", "Trojan-Go")
|
||||
xtls = s:option(Flag, "xtls", translate("XTLS"))
|
||||
xtls.default = 0
|
||||
xtls:depends({ type = "Xray", protocol = "vless", tls = "1" })
|
||||
xtls:depends({ type = "Xray", protocol = "trojan", tls = "1" })
|
||||
|
||||
flow = s:option(Value, "flow", translate("flow"))
|
||||
flow.default = "xtls-rprx-direct"
|
||||
flow:value("xtls-rprx-origin")
|
||||
flow:value("xtls-rprx-origin-udp443")
|
||||
flow:value("xtls-rprx-direct")
|
||||
|
||||
@ -121,29 +121,10 @@ o.rmempty = true
|
||||
--]]
|
||||
|
||||
-- [[ Other Settings ]]--
|
||||
s = m:section(TypedSection, "global_other", translate("Other Settings"),
|
||||
"<font color='red'>" .. translatef(
|
||||
"You can only set up a maximum of %s nodes for the time being, Used for access control.",
|
||||
"3") .. "</font>")
|
||||
s = m:section(TypedSection, "global_other", translate("Other Settings"))
|
||||
s.anonymous = true
|
||||
s.addremove = false
|
||||
|
||||
---- TCP Node Number Option
|
||||
o = s:option(ListValue, "tcp_node_num", "TCP" .. translate("Node Number"))
|
||||
o.default = "1"
|
||||
o.rmempty = false
|
||||
o:value("1")
|
||||
o:value("2")
|
||||
o:value("3")
|
||||
|
||||
---- UDP Node Number Option
|
||||
o = s:option(ListValue, "udp_node_num", "UDP" .. translate("Node Number"))
|
||||
o.default = "1"
|
||||
o.rmempty = false
|
||||
o:value("1")
|
||||
o:value("2")
|
||||
o:value("3")
|
||||
|
||||
o = s:option(MultiValue, "status", translate("Status info"))
|
||||
o:value("big_icon", translate("Big icon")) -- 大图标
|
||||
o:value("show_check_port", translate("Show node check")) -- 显示节点检测
|
||||
|
||||
@ -17,7 +17,7 @@ s:tab("proxy_list3", translate("Proxy List") .. " 3")
|
||||
|
||||
---- Direct Hosts
|
||||
local direct_host = string.format("/usr/share/%s/rules/direct_host", appname)
|
||||
o = s:taboption("direct_list", TextValue, "direct_hosts", "", "<font color='red'>" .. translate("Join the direct hosts list of domain names will not proxy.") .. "</font>")
|
||||
o = s:taboption("direct_list", TextValue, "direct_host", "", "<font color='red'>" .. translate("Join the direct hosts list of domain names will not proxy.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return fs.readfile(direct_host) or "" end
|
||||
@ -91,80 +91,4 @@ o.validate = function(self, value)
|
||||
return value
|
||||
end
|
||||
|
||||
---- Proxy Hosts 2
|
||||
local proxy_host2 = string.format("/usr/share/%s/rules/proxy_host2", appname)
|
||||
o = s:taboption("proxy_list2", TextValue, "proxy_host2", "", "<font color='red'>" .. translate("These had been joined websites will use proxy. Please input the domain names of websites,every line can input only one website domain. For example: google.com.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return fs.readfile(proxy_host2) or "" end
|
||||
o.write = function(self, section, value) fs.writefile(proxy_host2, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) fs.writefile(proxy_host2, "") end
|
||||
o.validate = function(self, value)
|
||||
local hosts= {}
|
||||
string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(hosts, w) end)
|
||||
for index, host in ipairs(hosts) do
|
||||
if not datatypes.hostname(host) then
|
||||
return nil, host .. " " .. translate("Not valid domain name, please re-enter!")
|
||||
end
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
---- Proxy IP 2
|
||||
local proxy_ip2 = string.format("/usr/share/%s/rules/proxy_ip2", appname)
|
||||
o = s:taboption("proxy_list2", TextValue, "blacklist_ip2", "", "<font color='red'>" .. translate("These had been joined ip addresses will use proxy.Please input the ip address or ip address segment,every line can input only one ip address.For example: 35.24.0.0/24 or 8.8.4.4.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return fs.readfile(proxy_ip2) or "" end
|
||||
o.write = function(self, section, value) fs.writefile(proxy_ip2, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) fs.writefile(proxy_ip2, "") end
|
||||
o.validate = function(self, value)
|
||||
local ipmasks= {}
|
||||
string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(ipmasks, w) end)
|
||||
for index, ipmask in ipairs(ipmasks) do
|
||||
if not datatypes.ipmask4(ipmask) then
|
||||
return nil, ipmask .. " " .. translate("Not valid IP format, please re-enter!")
|
||||
end
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
---- Proxy Hosts 3
|
||||
local proxy_host3 = string.format("/usr/share/%s/rules/proxy_host3", appname)
|
||||
o = s:taboption("proxy_list3", TextValue, "proxy_host3", "", "<font color='red'>" .. translate("These had been joined websites will use proxy. Please input the domain names of websites,every line can input only one website domain. For example: google.com.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return fs.readfile(proxy_host3) or "" end
|
||||
o.write = function(self, section, value) fs.writefile(proxy_host3, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) fs.writefile(proxy_host3, "") end
|
||||
o.validate = function(self, value)
|
||||
local hosts= {}
|
||||
string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(hosts, w) end)
|
||||
for index, host in ipairs(hosts) do
|
||||
if not datatypes.hostname(host) then
|
||||
return nil, host .. " " .. translate("Not valid domain name, please re-enter!")
|
||||
end
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
---- Proxy IP 3
|
||||
local proxy_ip3 = string.format("/usr/share/%s/rules/proxy_ip3", appname)
|
||||
o = s:taboption("proxy_list3", TextValue, "blacklist_ip3", "", "<font color='red'>" .. translate("These had been joined ip addresses will use proxy.Please input the ip address or ip address segment,every line can input only one ip address.For example: 35.24.0.0/24 or 8.8.4.4.") .. "</font>")
|
||||
o.rows = 15
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section) return fs.readfile(proxy_ip3) or "" end
|
||||
o.write = function(self, section, value) fs.writefile(proxy_ip3, value:gsub("\r\n", "\n")) end
|
||||
o.remove = function(self, section, value) fs.writefile(proxy_ip3, "") end
|
||||
o.validate = function(self, value)
|
||||
local ipmasks= {}
|
||||
string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(ipmasks, w) end)
|
||||
for index, ipmask in ipairs(ipmasks) do
|
||||
if not datatypes.ipmask4(ipmask) then
|
||||
return nil, ipmask .. " " .. translate("Not valid IP format, please re-enter!")
|
||||
end
|
||||
end
|
||||
return value
|
||||
end
|
||||
|
||||
return m
|
||||
|
||||
@ -58,6 +58,7 @@ function gen_config(user)
|
||||
local clients = {}
|
||||
for i = 1, #user.uuid do
|
||||
clients[i] = {
|
||||
flow = (user.xtls and user.xtls == "1") and user.flow or nil,
|
||||
password = user.uuid[i],
|
||||
level = tonumber(user.level)
|
||||
}
|
||||
@ -77,6 +78,31 @@ function gen_config(user)
|
||||
}
|
||||
end
|
||||
|
||||
if user.fallback and user.fallback == "1" then
|
||||
local fallbacks = {}
|
||||
for i = 1, #user.fallback_list do
|
||||
local fallbackStr = user.fallback_list[i]
|
||||
if fallbackStr then
|
||||
local tmp = {}
|
||||
string.gsub(fallbackStr, '[^' .. "," .. ']+', function(w)
|
||||
table.insert(tmp, w)
|
||||
end)
|
||||
local dest = tmp[1] or ""
|
||||
local path = tmp[2]
|
||||
if dest:find("%.") then
|
||||
else
|
||||
dest = tonumber(dest)
|
||||
end
|
||||
fallbacks[i] = {
|
||||
path = path,
|
||||
dest = dest,
|
||||
xver = 1
|
||||
}
|
||||
end
|
||||
end
|
||||
settings.fallbacks = fallbacks
|
||||
end
|
||||
|
||||
routing = {
|
||||
domainStrategy = "IPOnDemand",
|
||||
rules = {
|
||||
@ -110,7 +136,7 @@ function gen_config(user)
|
||||
network = user.transport,
|
||||
security = "none",
|
||||
xtlsSettings = (user.tls and user.tls == "1" and user.xtls and user.xtls == "1") and {
|
||||
--alpn = {"http/1.1"},
|
||||
alpn = {"http/1.1"},
|
||||
disableSystemRoot = false,
|
||||
certificates = {
|
||||
{
|
||||
@ -120,6 +146,7 @@ function gen_config(user)
|
||||
}
|
||||
} or nil,
|
||||
tlsSettings = (user.tls and user.tls == "1") and {
|
||||
alpn = {"http/1.1"},
|
||||
disableSystemRoot = false,
|
||||
certificates = {
|
||||
{
|
||||
@ -151,7 +178,7 @@ function gen_config(user)
|
||||
header = {type = user.mkcp_guise}
|
||||
} or nil,
|
||||
wsSettings = (user.transport == "ws") and {
|
||||
acceptProxyProtocol = false,
|
||||
acceptProxyProtocol = true,
|
||||
headers = (user.ws_host) and {Host = user.ws_host} or nil,
|
||||
path = user.ws_path
|
||||
} or nil,
|
||||
|
||||
@ -297,6 +297,7 @@ tls:depends({ type = "Xray", protocol = "vmess" })
|
||||
tls:depends({ type = "Xray", protocol = "vless" })
|
||||
tls:depends({ type = "Xray", protocol = "socks" })
|
||||
tls:depends({ type = "Xray", protocol = "shadowsocks" })
|
||||
tls:depends({ type = "Xray", protocol = "trojan" })
|
||||
tls:depends({ type = "V2ray", protocol = "vmess" })
|
||||
tls:depends({ type = "V2ray", protocol = "vless" })
|
||||
tls:depends({ type = "V2ray", protocol = "socks" })
|
||||
@ -308,15 +309,14 @@ tls:depends("type", "Trojan-Go")
|
||||
xtls = s:option(Flag, "xtls", translate("XTLS"))
|
||||
xtls.default = 0
|
||||
xtls:depends({ type = "Xray", protocol = "vless", tls = "1" })
|
||||
xtls:depends({ type = "Xray", protocol = "trojan", tls = "1" })
|
||||
|
||||
flow = s:option(Value, "flow", translate("flow"))
|
||||
flow.default = "xtls-rprx-origin"
|
||||
flow.default = "xtls-rprx-direct"
|
||||
flow:value("xtls-rprx-origin")
|
||||
flow:value("xtls-rprx-origin-udp443")
|
||||
flow:value("xtls-rprx-direct")
|
||||
flow:value("xtls-rprx-direct-udp443")
|
||||
flow:value("xtls-rprx-splice")
|
||||
flow:value("xtls-rprx-splice-udp443")
|
||||
flow:depends("xtls", "1")
|
||||
|
||||
-- [[ TLS部分 ]] --
|
||||
@ -330,7 +330,7 @@ tls_allowInsecure:depends({ type = "Trojan-Go", tls = "1" })
|
||||
tls_serverName = s:option(Value, "tls_serverName", translate("Domain"))
|
||||
tls_serverName:depends("tls", "1")
|
||||
|
||||
tls_certificateFile = s:option(Value, "tls_certificateFile", translate("Public key absolute path"), translate("as:") .. "/etc/ssl/fullchain.pem")
|
||||
tls_certificateFile = s:option(FileUpload, "tls_certificateFile", translate("Public key absolute path"), translate("as:") .. "/etc/ssl/fullchain.pem")
|
||||
tls_certificateFile.validate = function(self, value, t)
|
||||
if value and value ~= "" then
|
||||
if not nixio.fs.access(value) then
|
||||
@ -341,9 +341,10 @@ tls_certificateFile.validate = function(self, value, t)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
tls_certificateFile.default = "/etc/config/ssl/" .. arg[1] .. ".pem"
|
||||
tls_certificateFile:depends("tls", "1")
|
||||
|
||||
tls_keyFile = s:option(Value, "tls_keyFile", translate("Private key absolute path"), translate("as:") .. "/etc/ssl/private.key")
|
||||
tls_keyFile = s:option(FileUpload, "tls_keyFile", translate("Private key absolute path"), translate("as:") .. "/etc/ssl/private.key")
|
||||
tls_keyFile.validate = function(self, value, t)
|
||||
if value and value ~= "" then
|
||||
if not nixio.fs.access(value) then
|
||||
@ -354,6 +355,7 @@ tls_keyFile.validate = function(self, value, t)
|
||||
end
|
||||
return nil
|
||||
end
|
||||
tls_keyFile.default = "/etc/config/ssl/" .. arg[1] .. ".key"
|
||||
tls_keyFile:depends("tls", "1")
|
||||
|
||||
tls_sessionTicket = s:option(Flag, "tls_sessionTicket", translate("Session Ticket"))
|
||||
@ -509,12 +511,14 @@ quic_guise = s:option(ListValue, "quic_guise", translate("Camouflage Type"))
|
||||
for a, t in ipairs(header_type_list) do quic_guise:value(t) end
|
||||
quic_guise:depends("transport", "quic")
|
||||
|
||||
-- [[ VLESS Fallback部分 ]]--
|
||||
--[[
|
||||
-- [[ Fallback部分 ]]--
|
||||
fallback = s:option(Flag, "fallback", translate("Fallback"))
|
||||
fallback:depends({ type = "Xray", protocol = "vless", transport = "tcp", tls = "1" })
|
||||
fallback:depends({ type = "V2ray", protocol = "vless", transport = "tcp", tls = "1" })
|
||||
fallback:depends({ type = "Xray", protocol = "vless", transport = "tcp" })
|
||||
fallback:depends({ type = "Xray", protocol = "trojan", transport = "tcp" })
|
||||
fallback:depends({ type = "V2ray", protocol = "vless", transport = "tcp" })
|
||||
fallback:depends({ type = "V2ray", protocol = "trojan", transport = "tcp" })
|
||||
|
||||
--[[
|
||||
fallback_alpn = s:option(Value, "fallback_alpn", "Fallback alpn")
|
||||
fallback_alpn:depends("fallback", "1")
|
||||
|
||||
@ -529,6 +533,9 @@ fallback_xver.default = 0
|
||||
fallback_xver:depends("fallback", "1")
|
||||
]]--
|
||||
|
||||
fallback_list = s:option(DynamicList, "fallback_list", "Fallback", translate("dest,path"))
|
||||
fallback_list:depends("fallback", "1")
|
||||
|
||||
ss_aead = s:option(Flag, "ss_aead", translate("Shadowsocks2"))
|
||||
ss_aead:depends("type", "Trojan-Go")
|
||||
ss_aead.default = "0"
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
<%
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
|
||||
local auto_switch = api.uci_get_type("auto_switch", "enable", 0)
|
||||
-%>
|
||||
<script type="text/javascript">
|
||||
@ -45,36 +43,29 @@ local auto_switch = api.uci_get_type("auto_switch", "enable", 0)
|
||||
|
||||
for (var i = 0; i <= 1; i++) {
|
||||
var proto = "udp";
|
||||
var num = <%=udp_node_num%>;
|
||||
if (i == 0) {
|
||||
proto = "tcp";
|
||||
num = <%=tcp_node_num%>;
|
||||
}
|
||||
if (num >= 1) {
|
||||
for (var j = 0; j < num; j++) {
|
||||
var index = j + 1;
|
||||
var dom_id = node_id + "-" + proto + "_node" + index;
|
||||
dom_id = dom_id.replace("cbi-", "cbid-").replace(new RegExp("-", 'g'), ".");
|
||||
var node_select = document.getElementById(dom_id);
|
||||
var node_select_value = node_select.value;
|
||||
if (node_select_value && node_select_value != "nil") {
|
||||
var v = document.getElementById(dom_id + "-" + node_select_value);
|
||||
node_select.title = v.text;
|
||||
|
||||
var new_a = document.createElement("a");
|
||||
new_a.innerHTML = "<%:Edit%>";
|
||||
new_a.href = "#";
|
||||
new_a.setAttribute("onclick", "location.href='" + '<%=url([[admin]], [[services]], [[passwall]], [[node_config]])%>' + "/" + node_select_value + "'");
|
||||
|
||||
var log_a = document.createElement("a");
|
||||
log_a.innerHTML = "<%:Log%>";
|
||||
log_a.href = "#";
|
||||
log_a.setAttribute("onclick", "window.open('" + '<%=url([[admin]], [[services]], [[passwall]], [[get_redir_log]])%>' + "?proto=" + proto + "&index=" + index + "', '_blank')");
|
||||
|
||||
node_select.outerHTML = node_select.outerHTML + "  " + new_a.outerHTML + "  " + log_a.outerHTML;
|
||||
//node_select.parentNode.insertBefore(new_a, node_select.nextSibling);
|
||||
}
|
||||
}
|
||||
var dom_id = node_id + "-" + proto + "_node";
|
||||
dom_id = dom_id.replace("cbi-", "cbid-").replace(new RegExp("-", 'g'), ".");
|
||||
var node_select = document.getElementById(dom_id);
|
||||
var node_select_value = node_select.value;
|
||||
if (node_select_value && node_select_value != "nil") {
|
||||
var v = document.getElementById(dom_id + "-" + node_select_value);
|
||||
node_select.title = v.text;
|
||||
|
||||
var new_a = document.createElement("a");
|
||||
new_a.innerHTML = "<%:Edit%>";
|
||||
new_a.href = "#";
|
||||
new_a.setAttribute("onclick", "location.href='" + '<%=url([[admin]], [[services]], [[passwall]], [[node_config]])%>' + "/" + node_select_value + "'");
|
||||
|
||||
var log_a = document.createElement("a");
|
||||
log_a.innerHTML = "<%:Log%>";
|
||||
log_a.href = "#";
|
||||
log_a.setAttribute("onclick", "window.open('" + '<%=url([[admin]], [[services]], [[passwall]], [[get_redir_log]])%>' + "?proto=" + proto + "', '_blank')");
|
||||
|
||||
node_select.outerHTML = node_select.outerHTML + "  " + new_a.outerHTML + "  " + log_a.outerHTML;
|
||||
//node_select.parentNode.insertBefore(new_a, node_select.nextSibling);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,7 +84,7 @@ local auto_switch = api.uci_get_type("auto_switch", "enable", 0)
|
||||
if (node_select_value && node_select_value != "nil") {
|
||||
if (global_id != null && node_select_value.indexOf("tcp") == 0) {
|
||||
var num = node_select_value.replace("tcp", "");
|
||||
var d = global_id + "-tcp_node" + index;
|
||||
var d = global_id + "-tcp_node";
|
||||
d = d.replace("cbi-", "cbid-").replace(new RegExp("-", 'g'), ".");
|
||||
var dom = document.getElementById(d);
|
||||
var _node_select_value = dom.value;
|
||||
|
||||
@ -2,9 +2,6 @@
|
||||
local dsp = require "luci.dispatcher"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
|
||||
|
||||
local status = api.uci_get_type("global_other", "status", "")
|
||||
-%>
|
||||
|
||||
@ -240,13 +237,13 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
var status_haproxy = document.getElementById('status_haproxy');
|
||||
var status_kcptun = document.getElementById('status_kcptun');
|
||||
if (data) {
|
||||
var tcp_node_num = <%=tcp_node_num%>;
|
||||
var tcp_node_num = 1;
|
||||
if (tcp_node_num >= 1) {
|
||||
var status_tcp_node = document.getElementById('status_tcp_node');
|
||||
if (status_tcp_node) {
|
||||
var text = 'TCP<br />';
|
||||
if (tcp_node_num == 1) {
|
||||
if (data["tcp_node1_status"])
|
||||
if (data["tcp_node_status"])
|
||||
text += '<span class="green"><%:RUNNING%></span>';
|
||||
else
|
||||
text += '<span class="red"><%:NOT RUNNING%></span>';
|
||||
@ -265,7 +262,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
if (status_kcptun) {
|
||||
var text = 'Kcptun<br />';
|
||||
if (tcp_node_num == 1) {
|
||||
if (data["kcptun_tcp_node1_status"])
|
||||
if (data["kcptun_tcp_node_status"])
|
||||
text += '<span class="green"><%:RUNNING%></span>';
|
||||
else
|
||||
text += '<span class="red"><%:NOT RUNNING%></span>';
|
||||
@ -282,13 +279,13 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
}
|
||||
}
|
||||
|
||||
var udp_node_num = <%=udp_node_num%>;
|
||||
var udp_node_num = 1;
|
||||
if (udp_node_num >= 1) {
|
||||
var status_udp_node = document.getElementById('status_udp_node');
|
||||
if (status_udp_node) {
|
||||
var text = 'UDP<br />';
|
||||
if (udp_node_num == 1) {
|
||||
if (data["udp_node1_status"])
|
||||
if (data["udp_node_status"])
|
||||
text += '<span class="green"><%:RUNNING%></span>';
|
||||
else
|
||||
text += '<span class="red"><%:NOT RUNNING%></span>';
|
||||
|
||||
@ -2,9 +2,6 @@
|
||||
local dsp = require "luci.dispatcher"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
|
||||
|
||||
local status = api.uci_get_type("global_other", "status", "")
|
||||
-%>
|
||||
|
||||
@ -164,11 +161,11 @@ local status = api.uci_get_type("global_other", "status", "")
|
||||
if (x && x.status == 200) {
|
||||
var tcp_node_status = document.getElementById('_tcp_node_status');
|
||||
if (tcp_node_status) {
|
||||
var tcp_node_num = <%=tcp_node_num%>;
|
||||
var tcp_node_num = 1;
|
||||
if (tcp_node_num >= 1) {
|
||||
var text = '';
|
||||
if (tcp_node_num == 1) {
|
||||
if (json["tcp_node1_status"])
|
||||
if (json["tcp_node_status"])
|
||||
text += '<font color="green"><%:RUNNING%> ✓</font>';
|
||||
else
|
||||
text += '<font color="red"><%:NOT RUNNING%> X</font>';
|
||||
@ -186,7 +183,7 @@ local status = api.uci_get_type("global_other", "status", "")
|
||||
var kcptun_tcp_node_status = document.getElementById('_kcptun_tcp_node_status');
|
||||
text = "";
|
||||
if (tcp_node_num == 1) {
|
||||
if (json["kcptun_tcp_node1_status"])
|
||||
if (json["kcptun_tcp_node_status"])
|
||||
text += '<font color="green"><%:RUNNING%> ✓</font>';
|
||||
else
|
||||
text += '<font color="red"><%:NOT RUNNING%> X</font>';
|
||||
@ -206,11 +203,11 @@ local status = api.uci_get_type("global_other", "status", "")
|
||||
|
||||
var udp_node_status = document.getElementById('_udp_node_status');
|
||||
if (udp_node_status) {
|
||||
var udp_node_num = <%=udp_node_num%>;
|
||||
var udp_node_num = 1;
|
||||
if (udp_node_num >= 1) {
|
||||
var text = '';
|
||||
if (udp_node_num == 1) {
|
||||
if (json["udp_node1_status"])
|
||||
if (json["udp_node_status"])
|
||||
text += '<font color="green"><%:RUNNING%> ✓</font>';
|
||||
else
|
||||
text += '<font color="red"><%:NOT RUNNING%> X</font>';
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
<%+cbi/valueheader%>
|
||||
<%
|
||||
local dsp = require "luci.dispatcher"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
|
||||
-%>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function padright(str, cnt, pad) {
|
||||
@ -555,6 +557,9 @@ local dsp = require "luci.dispatcher"
|
||||
var sstr = b64DecodeUnicode(ssu[1]);
|
||||
var ploc = sstr.indexOf("/?");
|
||||
opt.set('type', "V2ray");
|
||||
<% if api.is_finded("xray") then -%>
|
||||
opt.set('type', "Xray");
|
||||
<% end -%>
|
||||
opt.get('type').dispatchEvent(event);
|
||||
var url0, param = "";
|
||||
if (ploc > 0) {
|
||||
|
||||
@ -3,8 +3,6 @@
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local dsp = require "luci.dispatcher"
|
||||
|
||||
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1)
|
||||
local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1)
|
||||
local nodes_display = api.uci_get_type("global_other", "nodes_display", "")
|
||||
-%>
|
||||
|
||||
@ -202,9 +200,9 @@ table td, .table .td {
|
||||
}
|
||||
}
|
||||
|
||||
function set_node(protocol,number) {
|
||||
if (confirm('<%:Are you sure set to%> ' + protocol.toUpperCase() + "_" + number + '<%:the server?%>')==true){
|
||||
window.location.href = '<%=dsp.build_url("admin/services/passwall/set_node")%>?protocol=' + protocol + '&number=' + number + '§ion=' + section;
|
||||
function set_node(protocol) {
|
||||
if (confirm('<%:Are you sure set to%> ' + protocol.toUpperCase() + '<%:the server?%>')==true){
|
||||
window.location.href = '<%=dsp.build_url("admin/services/passwall/set_node")%>?protocol=' + protocol + '§ion=' + section;
|
||||
}
|
||||
}
|
||||
|
||||
@ -434,17 +432,8 @@ table td, .table .td {
|
||||
<div id="set_node_div">
|
||||
<div class="cbi-value"><%:You choose node is:%><span id="set_node_name"></span></div>
|
||||
<div class="cbi-value">
|
||||
<% if tcp_node_num and tonumber(tcp_node_num) >= 1 then %>
|
||||
<% for i = 1, tcp_node_num, 1 do %>
|
||||
<input class="cbi-button cbi-button-edit" type="button" onclick="set_node('tcp',<%=i%>)" value="TCP_<%=i%>" />
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if udp_node_num and tonumber(udp_node_num) >= 1 then %>
|
||||
<% for i = 1, udp_node_num, 1 do %>
|
||||
<input class="cbi-button cbi-button-edit" type="button" onclick="set_node('udp',<%=i%>)" value="UDP_<%=i%>" />
|
||||
<% end %>
|
||||
<% end %>
|
||||
<input class="cbi-button cbi-button-edit" type="button" onclick="set_node('tcp')" value="TCP" />
|
||||
<input class="cbi-button cbi-button-edit" type="button" onclick="set_node('udp')" value="UDP" />
|
||||
<input class="cbi-button cbi-button-remove" type="button" onclick="close_set_node_div()" value="<%:Close%>" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -130,9 +130,6 @@ msgstr "0为不使用"
|
||||
msgid "Same as the tcp node"
|
||||
msgstr "与TCP节点相同"
|
||||
|
||||
msgid "Same as the tcp %s node"
|
||||
msgstr "与TCP%s节点相同"
|
||||
|
||||
msgid "New process"
|
||||
msgstr "另开进程"
|
||||
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
|
||||
config global
|
||||
option enabled '0'
|
||||
option tcp_node1 'nil'
|
||||
option udp_node1 'nil'
|
||||
option tcp_node 'nil'
|
||||
option udp_node 'nil'
|
||||
option dns_mode 'pdnsd'
|
||||
option up_china_dns 'default'
|
||||
option dns_forward '8.8.4.4'
|
||||
@ -13,8 +13,8 @@ config global
|
||||
option localhost_tcp_proxy_mode 'gfwlist'
|
||||
option localhost_udp_proxy_mode 'gfwlist'
|
||||
option socks_server '0.0.0.0:1080'
|
||||
option close_log_tcp_1 '1'
|
||||
option close_log_udp_1 '1'
|
||||
option close_log_tcp '1'
|
||||
option close_log_udp '1'
|
||||
option loglevel 'warning'
|
||||
option trojan_loglevel '2'
|
||||
|
||||
@ -35,8 +35,6 @@ config global_forwarding
|
||||
option proxy_ipv6 '0'
|
||||
|
||||
config global_other
|
||||
option tcp_node_num '1'
|
||||
option udp_node_num '1'
|
||||
option status 'big_icon show_check_port show_ip111'
|
||||
option nodes_ping 'auto_ping tcping'
|
||||
option nodes_display 'compact_display_nodes show_add_mode'
|
||||
|
||||
@ -265,33 +265,14 @@ ln_start_bin() {
|
||||
|
||||
ENABLED=$(config_t_get global enabled 0)
|
||||
|
||||
TCP_REDIR_PORT1=$(config_t_get global_forwarding tcp_redir_port 1041)
|
||||
TCP_NODE_NUM=$(config_t_get global_other tcp_node_num 1)
|
||||
for i in $(seq 1 $TCP_NODE_NUM); do
|
||||
eval TCP_NODE$i=$(config_t_get global tcp_node$i nil)
|
||||
[ $i -gt 1 ] && {
|
||||
_k=$(expr $i - 1)
|
||||
eval p=\$TCP_REDIR_PORT${_k}
|
||||
eval TCP_REDIR_PORT$i=$(expr $p + 1)
|
||||
}
|
||||
done
|
||||
TCP_REDIR_PORT=1041
|
||||
TCP_NODE=$(config_t_get global tcp_node nil)
|
||||
|
||||
UDP_REDIR_PORT1=$(config_t_get global_forwarding udp_redir_port 1051)
|
||||
UDP_NODE_NUM=$(config_t_get global_other udp_node_num 1)
|
||||
for i in $(seq 1 $UDP_NODE_NUM); do
|
||||
eval UDP_NODE$i=$(config_t_get global udp_node$i nil)
|
||||
[ $i -gt 1 ] && {
|
||||
_k=$(expr $i - 1)
|
||||
eval p=\$UDP_REDIR_PORT${_k}
|
||||
eval UDP_REDIR_PORT$i=$(expr $p + 1)
|
||||
}
|
||||
done
|
||||
UDP_REDIR_PORT=1051
|
||||
UDP_NODE=$(config_t_get global udp_node nil)
|
||||
|
||||
[ "$UDP_NODE1" == "tcp_" ] && UDP_NODE1=$TCP_NODE1
|
||||
[ "$UDP_NODE1" == "tcp" ] && UDP_REDIR_PORT1=$TCP_REDIR_PORT1
|
||||
|
||||
# Dynamic variables (Used to record)
|
||||
# TCP_NODE1_IP="" UDP_NODE1_IP="" TCP_NODE1_PORT="" UDP_NODE1_PORT="" TCP_NODE1_TYPE="" UDP_NODE1_TYPE=""
|
||||
[ "$UDP_NODE" == "tcp_" ] && UDP_NODE=$TCP_NODE
|
||||
[ "$UDP_NODE" == "tcp" ] && UDP_REDIR_PORT=$TCP_REDIR_PORT
|
||||
|
||||
TCP_REDIR_PORTS=$(config_t_get global_forwarding tcp_redir_ports '80,443')
|
||||
UDP_REDIR_PORTS=$(config_t_get global_forwarding udp_redir_ports '1:65535')
|
||||
@ -307,7 +288,7 @@ LOCALHOST_UDP_PROXY_MODE=$(config_t_get global localhost_udp_proxy_mode default)
|
||||
|
||||
load_config() {
|
||||
[ "$ENABLED" != 1 ] && NO_PROXY=1
|
||||
[ "$TCP_NODE1" == "nil" -a "$UDP_NODE1" == "nil" ] && {
|
||||
[ "$TCP_NODE" == "nil" -a "$UDP_NODE" == "nil" ] && {
|
||||
echolog "没有选择节点!"
|
||||
NO_PROXY=1
|
||||
}
|
||||
@ -429,12 +410,11 @@ run_redir() {
|
||||
local local_port=$3
|
||||
local config_file=$4
|
||||
local REDIR_TYPE=$5
|
||||
local index=$6
|
||||
local log_file=$7
|
||||
local log_file=$6
|
||||
[ -z "$log_file" ] && log_file="/dev/null"
|
||||
local redir_type=$(echo $REDIR_TYPE | tr 'A-Z' 'a-z')
|
||||
local type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
|
||||
local close_log=$(config_t_get global close_log_${redir_type}_${index} 1)
|
||||
local close_log=$(config_t_get global close_log_${redir_type} 1)
|
||||
[ "$close_log" = "1" ] && log_file="/dev/null"
|
||||
local remarks=$(config_n_get $node remarks)
|
||||
local server_host=$(config_n_get $node address)
|
||||
@ -449,9 +429,9 @@ run_redir() {
|
||||
return 1
|
||||
}
|
||||
[ "$server_host" == "127.0.0.1" ] && process=1
|
||||
[ "$bind" != "127.0.0.1" ] && echolog "${REDIR_TYPE}_${index}节点:$remarks,节点:${server_host}:${port},监听端口:$local_port"
|
||||
[ "$bind" != "127.0.0.1" ] && echolog "${REDIR_TYPE}节点:$remarks,节点:${server_host}:${port},监听端口:$local_port"
|
||||
}
|
||||
eval ${REDIR_TYPE}_NODE${index}_PORT=$port
|
||||
eval ${REDIR_TYPE}_NODE_PORT=$port
|
||||
|
||||
case "$REDIR_TYPE" in
|
||||
UDP)
|
||||
@ -461,8 +441,8 @@ run_redir() {
|
||||
local node_port=$(config_n_get $node port)
|
||||
local server_username=$(config_n_get $node username)
|
||||
local server_password=$(config_n_get $node password)
|
||||
eval port=\$UDP_REDIR_PORT${index}
|
||||
ln_start_bin "$(first_type ipt2socks)" "ipt2socks_udp_${index}" $log_file -U -l "$port" -b 0.0.0.0 -s "$node_address" -p "$node_port" -R
|
||||
eval port=\$UDP_REDIR_PORT
|
||||
ln_start_bin "$(first_type ipt2socks)" "ipt2socks_udp" $log_file -U -l "$port" -b 0.0.0.0 -s "$node_address" -p "$node_port" -R
|
||||
;;
|
||||
xray)
|
||||
local loglevel=$(config_t_get global loglevel "warning")
|
||||
@ -492,7 +472,7 @@ run_redir() {
|
||||
if [ "$protocol" == "wsclient" ]; then
|
||||
echolog "Brook的WebSocket不支持UDP转发!"
|
||||
else
|
||||
ln_start_bin "$(first_type $(config_t_get global_app brook_file) brook)" "brook_udp_${index}" $log_file tproxy -l ":$local_port" -s "$server_host:$port" -p "$(config_n_get $node password)"
|
||||
ln_start_bin "$(first_type $(config_t_get global_app brook_file) brook)" "brook_udp" $log_file tproxy -l ":$local_port" -s "$server_host:$port" -p "$(config_n_get $node password)"
|
||||
fi
|
||||
;;
|
||||
ss|ssr)
|
||||
@ -517,7 +497,7 @@ run_redir() {
|
||||
[ -n "$kcptun_server_host" ] && run_kcptun_ip=$(get_host_ip $network_type $kcptun_server_host)
|
||||
KCPTUN_REDIR_PORT=$(get_new_port $KCPTUN_REDIR_PORT tcp)
|
||||
kcptun_params="-l 0.0.0.0:$KCPTUN_REDIR_PORT -r $run_kcptun_ip:$kcptun_port $kcptun_config"
|
||||
ln_start_bin "$(first_type $(config_t_get global_app kcptun_client_file) kcptun-client)" "kcptun_tcp_${index}" $log_file $kcptun_params
|
||||
ln_start_bin "$(first_type $(config_t_get global_app kcptun_client_file) kcptun-client)" "kcptun_tcp" $log_file $kcptun_params
|
||||
fi
|
||||
fi
|
||||
local _socks_flag _socks_address _socks_port _socks_username _socks_password
|
||||
@ -532,14 +512,14 @@ run_redir() {
|
||||
xray)
|
||||
local loglevel=$(config_t_get global loglevel "warning")
|
||||
local extra_param="tcp"
|
||||
[ "${index}" == 1 ] && [ "$UDP_NODE1" == "tcp" ] && extra_param="tcp,udp"
|
||||
[ "$UDP_NODE" == "tcp" ] && extra_param="tcp,udp"
|
||||
lua $API_GEN_XRAY -node $node -proto $extra_param -redir_port $local_port -loglevel $loglevel > $config_file
|
||||
ln_start_bin "$(first_type $(config_t_get global_app xray_file) xray)" xray $log_file -config="$config_file"
|
||||
;;
|
||||
v2ray)
|
||||
local loglevel=$(config_t_get global loglevel "warning")
|
||||
local extra_param="tcp"
|
||||
[ "${index}" == 1 ] && [ "$UDP_NODE1" == "tcp" ] && extra_param="tcp,udp"
|
||||
[ "$UDP_NODE" == "tcp" ] && extra_param="tcp,udp"
|
||||
lua $API_GEN_XRAY -node $node -proto $extra_param -redir_port $local_port -loglevel $loglevel > $config_file
|
||||
ln_start_bin "$(first_type $(config_t_get global_app v2ray_file) v2ray)" v2ray $log_file -config="$config_file"
|
||||
;;
|
||||
@ -566,28 +546,28 @@ run_redir() {
|
||||
if [ "$protocol" == "wsclient" ]; then
|
||||
[ "$brook_tls" == "1" ] && server_ip="wss://${server_ip}" || server_ip="ws://${server_ip}"
|
||||
socks_port=$(get_new_port 2081 tcp)
|
||||
ln_start_bin "$(first_type $(config_t_get global_app brook_file) brook)" "brook_tcp_${index}" $log_file wsclient --socks5 "127.0.0.1:$socks_port" -s "$server_ip:$port" -p "$(config_n_get $node password)"
|
||||
ln_start_bin "$(first_type $(config_t_get global_app brook_file) brook)" "brook_tcp" $log_file wsclient --socks5 "127.0.0.1:$socks_port" -s "$server_ip:$port" -p "$(config_n_get $node password)"
|
||||
_socks_flag=1
|
||||
_socks_address="127.0.0.1"
|
||||
_socks_port=$socks_port
|
||||
echolog "Brook的WebSocket不支持透明代理,将使用ipt2socks转换透明代理!"
|
||||
[ "${index}" == 1 ] && [ "$UDP_NODE1" == "tcp" ] && echolog "Brook的WebSocket不支持UDP转发!"
|
||||
[ "$UDP_NODE" == "tcp" ] && echolog "Brook的WebSocket不支持UDP转发!"
|
||||
else
|
||||
[ "$kcptun_use" == "1" ] && {
|
||||
server_ip=127.0.0.1
|
||||
port=$KCPTUN_REDIR_PORT
|
||||
}
|
||||
ln_start_bin "$(first_type $(config_t_get global_app brook_file) brook)" "brook_tcp_${index}" $log_file tproxy -l ":$local_port" -s "$server_ip:$port" -p "$(config_n_get $node password)"
|
||||
ln_start_bin "$(first_type $(config_t_get global_app brook_file) brook)" "brook_tcp" $log_file tproxy -l ":$local_port" -s "$server_ip:$port" -p "$(config_n_get $node password)"
|
||||
fi
|
||||
;;
|
||||
ss|ssr)
|
||||
if [ "$kcptun_use" == "1" ]; then
|
||||
lua $API_GEN_SS -node $node -local_addr "0.0.0.0" -local_port $local_port -server_host "127.0.0.1" -server_port $KCPTUN_REDIR_PORT > $config_file
|
||||
process=1
|
||||
[ "${index}" == 1 ] && [ "$UDP_NODE1" == "tcp" ] && echolog "Kcptun不支持UDP转发!"
|
||||
[ "$UDP_NODE" == "tcp" ] && echolog "Kcptun不支持UDP转发!"
|
||||
else
|
||||
lua $API_GEN_SS -node $node -local_addr "0.0.0.0" -local_port $local_port > $config_file
|
||||
[ "${index}" == 1 ] && [ "$UDP_NODE1" == "tcp" ] && extra_param="-u"
|
||||
[ "$UDP_NODE" == "tcp" ] && extra_param="-u"
|
||||
fi
|
||||
for k in $(seq 1 $process); do
|
||||
ln_start_bin "$(first_type ${type}-redir)" "${type}-redir" $log_file -c "$config_file" $extra_param
|
||||
@ -596,8 +576,8 @@ run_redir() {
|
||||
esac
|
||||
if [ -n "$_socks_flag" ]; then
|
||||
local extra_param="-T"
|
||||
[ "${index}" == 1 ] && [ "$UDP_NODE1" == "tcp" ] && extra_param=""
|
||||
ln_start_bin "$(first_type ipt2socks)" "ipt2socks_tcp_${index}" $log_file -l "$local_port" -b 0.0.0.0 -s "$_socks_address" -p "$_socks_port" -R $extra_param
|
||||
[ "$UDP_NODE" == "tcp" ] && extra_param=""
|
||||
ln_start_bin "$(first_type ipt2socks)" "ipt2socks_tcp" $log_file -l "$local_port" -b 0.0.0.0 -s "$_socks_address" -p "$_socks_port" -R $extra_param
|
||||
fi
|
||||
unset _socks_flag _socks_address _socks_port _socks_username _socks_password
|
||||
;;
|
||||
@ -606,18 +586,17 @@ run_redir() {
|
||||
}
|
||||
|
||||
node_switch() {
|
||||
local i=$3
|
||||
local node=$4
|
||||
[ -n "$1" -a -n "$2" -a -n "$3" -a -n "$4" ] && {
|
||||
ps -w | grep -E "$TMP_PATH" | grep -i "${1}_${i}" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
local config_file=$TMP_PATH/${1}_${i}.json
|
||||
local log_file=$TMP_PATH/${1}_${i}.log
|
||||
eval current_port=\$${1}_REDIR_PORT${i}
|
||||
local port=$(cat $TMP_PORT_PATH/${1}_${i})
|
||||
run_redir $node "0.0.0.0" $port $config_file $1 $i $log_file
|
||||
echo $node > $TMP_ID_PATH/${1}_${i}
|
||||
local node=$3
|
||||
[ -n "$1" -a -n "$2" -a -n "$3" ] && {
|
||||
ps -w | grep -E "$TMP_PATH" | grep -i "${1}" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
local config_file=$TMP_PATH/${1}.json
|
||||
local log_file=$TMP_PATH/${1}.log
|
||||
eval current_port=\$${1}_REDIR_PORT
|
||||
local port=$(cat $TMP_PORT_PATH/${1})
|
||||
run_redir $node "0.0.0.0" $port $config_file $1 $log_file
|
||||
echo $node > $TMP_ID_PATH/${1}
|
||||
#local node_net=$(echo $1 | tr 'A-Z' 'a-z')
|
||||
#uci set $CONFIG.@global[0].${node_net}_node${i}=$node
|
||||
#uci set $CONFIG.@global[0].${node_net}_node=$node
|
||||
#uci commit $CONFIG
|
||||
/etc/init.d/dnsmasq restart >/dev/null 2>&1
|
||||
}
|
||||
@ -625,21 +604,19 @@ node_switch() {
|
||||
|
||||
start_redir() {
|
||||
eval num=\$${1}_NODE_NUM
|
||||
for i in $(seq 1 $num); do
|
||||
eval node=\$${1}_NODE$i
|
||||
[ "$node" != "nil" ] && {
|
||||
TYPE=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
|
||||
local config_file=$TMP_PATH/${1}_${i}.json
|
||||
local log_file=$TMP_PATH/${1}_${i}.log
|
||||
eval current_port=\$${1}_REDIR_PORT$i
|
||||
local port=$(echo $(get_new_port $current_port $2))
|
||||
eval ${1}_REDIR${i}=$port
|
||||
run_redir $node "0.0.0.0" $port $config_file $1 $i $log_file
|
||||
#eval ip=\$${1}_NODE${i}_IP
|
||||
echo $node > $TMP_ID_PATH/${1}_${i}
|
||||
echo $port > $TMP_PORT_PATH/${1}_${i}
|
||||
}
|
||||
done
|
||||
eval node=\$${1}_NODE
|
||||
[ "$node" != "nil" ] && {
|
||||
TYPE=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
|
||||
local config_file=$TMP_PATH/${1}.json
|
||||
local log_file=$TMP_PATH/${1}.log
|
||||
eval current_port=\$${1}_REDIR_PORT
|
||||
local port=$(echo $(get_new_port $current_port $2))
|
||||
eval ${1}_REDIR=$port
|
||||
run_redir $node "0.0.0.0" $port $config_file $1 $log_file
|
||||
#eval ip=\$${1}_NODE_IP
|
||||
echo $node > $TMP_ID_PATH/${1}
|
||||
echo $port > $TMP_PORT_PATH/${1}
|
||||
}
|
||||
}
|
||||
|
||||
start_socks() {
|
||||
@ -650,8 +627,7 @@ start_socks() {
|
||||
[ "$enabled" == "0" ] && continue
|
||||
local node=$(config_n_get $id node nil)
|
||||
if [ "$(echo $node | grep ^tcp)" ]; then
|
||||
local num=$(echo $node | sed "s/tcp//g")
|
||||
eval node=\$TCP_NODE$num
|
||||
eval node=\$TCP_NODE
|
||||
fi
|
||||
[ "$node" == "nil" ] && continue
|
||||
local port=$(config_n_get $id port)
|
||||
@ -966,8 +942,6 @@ add_dnsmasq() {
|
||||
#如果使用chnlist直接使用默认DNS
|
||||
[ "${USE_CHNLIST}" = "1" ] && unset fwd_dns
|
||||
sort -u "${RULES_PATH}/proxy_host" | gen_dnsmasq_items "blacklist" "${fwd_dns}" "${TMP_DNSMASQ_PATH}/12-proxy_host.conf"
|
||||
[ "2" -le "$TCP_NODE_NUM" ] && sort -u "${RULES_PATH}/proxy_host2" | gen_dnsmasq_items "blacklist2" "${fwd_dns}" "${TMP_DNSMASQ_PATH}/11-proxy_host2.conf"
|
||||
[ "3" -le "$TCP_NODE_NUM" ] && sort -u "${RULES_PATH}/proxy_host3" | gen_dnsmasq_items "blacklist3" "${fwd_dns}" "${TMP_DNSMASQ_PATH}/10-proxy_host3.conf"
|
||||
echolog " - [$?]代理域名表(blacklist):${fwd_dns:-默认}"
|
||||
|
||||
#如果没有使用回国模式
|
||||
|
||||
@ -125,34 +125,28 @@ load_acl() {
|
||||
[ -z "${ip}${mac}" ] && continue
|
||||
tcp_proxy_mode=${tcp_proxy_mode:-default}
|
||||
udp_proxy_mode=${udp_proxy_mode:-default}
|
||||
tcp_node=${tcp_node:-1}
|
||||
udp_node=${udp_node:-1}
|
||||
tcp_no_redir_ports=${tcp_no_redir_ports:-default}
|
||||
udp_no_redir_ports=${udp_no_redir_ports:-default}
|
||||
tcp_redir_ports=${tcp_redir_ports:-default}
|
||||
udp_redir_ports=${udp_redir_ports:-default}
|
||||
[ "$tcp_proxy_mode" = "default" ] && tcp_proxy_mode=$TCP_PROXY_MODE
|
||||
[ "$udp_proxy_mode" = "default" ] && udp_proxy_mode=$UDP_PROXY_MODE
|
||||
[ "$tcp_node" -gt "$TCP_NODE_NUM" ] && tcp_node=1
|
||||
[ "$udp_node" -gt "$UDP_NODE_NUM" ] && udp_node=1
|
||||
[ "$tcp_no_redir_ports" = "default" ] && tcp_no_redir_ports=$TCP_NO_REDIR_PORTS
|
||||
[ "$udp_no_redir_ports" = "default" ] && udp_no_redir_ports=$UDP_NO_REDIR_PORTS
|
||||
[ "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
|
||||
[ "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
|
||||
eval TCP_NODE=\$TCP_NODE$tcp_node
|
||||
eval UDP_NODE=\$UDP_NODE$udp_node
|
||||
|
||||
|
||||
#echolog "访问控制:${item}..."
|
||||
[ -n "$ip" ] && msg="IP:$ip,"
|
||||
[ -n "$mac" ] && msg="${msg:+${msg}和}MAC:$mac,"
|
||||
ipt_tmp=$ipt_n
|
||||
[ "$tcp_proxy_mode" != "disable" ] && {
|
||||
[ "$TCP_NODE" != "nil" ] && {
|
||||
eval tcp_port=\$TCP_REDIR_PORT$tcp_node
|
||||
tcp_port=$TCP_REDIR_PORT
|
||||
eval TCP_NODE_TYPE=$(echo $(config_n_get $TCP_NODE type) | tr 'A-Z' 'a-z')
|
||||
[ "$TCP_NODE_TYPE" == "brook" ] && [ "$(config_n_get $TCP_NODE protocol client)" == "client" ] && is_tproxy=1
|
||||
#[ "$TCP_NODE_TYPE" == "trojan-go" ] && is_tproxy=1
|
||||
msg2="${msg}使用TCP节点${tcp_node} [$(get_action_chain_name $tcp_proxy_mode)]"
|
||||
msg2="${msg}使用TCP节点 [$(get_action_chain_name $tcp_proxy_mode)]"
|
||||
if [ -n "${is_tproxy}" ]; then
|
||||
msg2="${msg2}(TPROXY:${tcp_port})代理"
|
||||
ipt_tmp=$ipt_m && is_tproxy="TPROXY"
|
||||
@ -173,9 +167,9 @@ load_acl() {
|
||||
$ipt_tmp -A PSW $(comment "$remarks") $(factor $ip "-s") $(factor $mac "-m mac --mac-source") -p tcp -j RETURN
|
||||
|
||||
[ "$udp_proxy_mode" != "disable" ] && {
|
||||
msg2="${msg}使用UDP节点${udp_node} [$(get_action_chain_name $udp_proxy_mode)]"
|
||||
msg2="${msg}使用UDP节点 [$(get_action_chain_name $udp_proxy_mode)]"
|
||||
[ "$UDP_NODE" != "nil" ] && {
|
||||
eval udp_port=\$UDP_REDIR_PORT$udp_node
|
||||
udp_port=$UDP_REDIR_PORT
|
||||
msg2="${msg2}(TPROXY:${udp_port})代理"
|
||||
[ "$udp_no_redir_ports" != "disable" ] && {
|
||||
$ipt_m -A PSW $(comment "$remarks") $(factor $ip "-s") $(factor $mac "-m mac --mac-source") -p udp -m multiport --dport $udp_no_redir_ports -j RETURN
|
||||
@ -201,58 +195,22 @@ load_acl() {
|
||||
[ "$TCP_NO_REDIR_PORTS" != "disable" ] && $ipt_tmp -A PSW $(comment "默认") -p tcp -m multiport --dport $TCP_NO_REDIR_PORTS -j RETURN
|
||||
ipt_tmp=$ipt_n
|
||||
unset is_tproxy msg
|
||||
[ "3" -le "$TCP_NODE_NUM" ] && [ "$TCP_NODE3" != "nil" ] && {
|
||||
local TCP_NODE3_TYPE=$(echo $(config_n_get $TCP_NODE3 type) | tr 'A-Z' 'a-z')
|
||||
[ "$TCP_NODE3_TYPE" == "brook" ] && [ "$(config_n_get $TCP_NODE3 protocol client)" == "client" ] && is_tproxy=1
|
||||
#[ "$TCP_NODE3_TYPE" == "trojan-go" ] && is_tproxy=1
|
||||
msg="TCP代理列表3:使用TCP节点3"
|
||||
[ "$TCP_NODE" != "nil" ] && {
|
||||
local TCP_NODE_TYPE=$(echo $(config_n_get $TCP_NODE type) | tr 'A-Z' 'a-z')
|
||||
[ "$TCP_NODE_TYPE" == "brook" ] && [ "$(config_n_get $TCP_NODE protocol client)" == "client" ] && is_tproxy=1
|
||||
#[ "$TCP_NODE_TYPE" == "trojan-go" ] && is_tproxy=1
|
||||
msg="TCP默认代理:使用TCP节点 [$(get_action_chain_name $TCP_PROXY_MODE)]"
|
||||
if [ -n "$is_tproxy" ]; then
|
||||
ipt_tmp=$ipt_m && is_tproxy="TPROXY"
|
||||
msg="${msg}(TPROXY:${TCP_REDIR_PORT3})代理"
|
||||
msg="${msg}(TPROXY:${TCP_REDIR_PORT})代理"
|
||||
else
|
||||
msg="${msg}(REDIRECT:${TCP_REDIR_PORT3})代理"
|
||||
msg="${msg}(REDIRECT:${TCP_REDIR_PORT})代理"
|
||||
fi
|
||||
[ "$TCP_NO_REDIR_PORTS" != "disable" ] && msg="${msg}除${TCP_NO_REDIR_PORTS}外的"
|
||||
msg="${msg}所有端口"
|
||||
$ipt_tmp -A PSW $(comment "列表3") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST3) $(REDIRECT $TCP_REDIR_PORT3 $is_tproxy)
|
||||
echolog "${msg}"
|
||||
}
|
||||
ipt_tmp=$ipt_n
|
||||
unset is_tproxy msg
|
||||
[ "2" -le "$TCP_NODE_NUM" ] && [ "$TCP_NODE2" != "nil" ] && {
|
||||
local TCP_NODE2_TYPE=$(echo $(config_n_get $TCP_NODE2 type) | tr 'A-Z' 'a-z')
|
||||
[ "$TCP_NODE2_TYPE" == "brook" ] && [ "$(config_n_get $TCP_NODE2 protocol client)" == "client" ] && is_tproxy=1
|
||||
#[ "$TCP_NODE2_TYPE" == "trojan-go" ] && is_tproxy=1
|
||||
msg="TCP代理列表2:使用TCP节点2"
|
||||
if [ -n "$is_tproxy" ]; then
|
||||
ipt_tmp=$ipt_m && is_tproxy="TPROXY"
|
||||
msg="${msg}(TPROXY:${TCP_REDIR_PORT2})代理"
|
||||
else
|
||||
msg="${msg}(REDIRECT:${TCP_REDIR_PORT2})代理"
|
||||
fi
|
||||
[ "$TCP_NO_REDIR_PORTS" != "disable" ] && msg="${msg}除${TCP_NO_REDIR_PORTS}外的"
|
||||
msg="${msg}所有端口"
|
||||
$ipt_tmp -A PSW $(comment "列表2") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST2) $(REDIRECT $TCP_REDIR_PORT2 $is_tproxy)
|
||||
echolog "${msg}"
|
||||
}
|
||||
ipt_tmp=$ipt_n
|
||||
unset is_tproxy msg
|
||||
[ "$TCP_NODE1" != "nil" ] && {
|
||||
local TCP_NODE1_TYPE=$(echo $(config_n_get $TCP_NODE1 type) | tr 'A-Z' 'a-z')
|
||||
[ "$TCP_NODE1_TYPE" == "brook" ] && [ "$(config_n_get $TCP_NODE1 protocol client)" == "client" ] && is_tproxy=1
|
||||
#[ "$TCP_NODE1_TYPE" == "trojan-go" ] && is_tproxy=1
|
||||
msg="TCP默认代理:使用TCP节点1 [$(get_action_chain_name $TCP_PROXY_MODE)]"
|
||||
if [ -n "$is_tproxy" ]; then
|
||||
ipt_tmp=$ipt_m && is_tproxy="TPROXY"
|
||||
msg="${msg}(TPROXY:${TCP_REDIR_PORT1})代理"
|
||||
else
|
||||
msg="${msg}(REDIRECT:${TCP_REDIR_PORT1})代理"
|
||||
fi
|
||||
[ "$TCP_NO_REDIR_PORTS" != "disable" ] && msg="${msg}除${TCP_NO_REDIR_PORTS}外的"
|
||||
msg="${msg}所有端口"
|
||||
$ipt_tmp -A PSW $(comment "默认") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_SHUNTLIST) $(REDIRECT $TCP_REDIR_PORT1 $is_tproxy)
|
||||
$ipt_tmp -A PSW $(comment "默认") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $TCP_REDIR_PORT1 $is_tproxy)
|
||||
$ipt_tmp -A PSW $(comment "默认") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(get_redirect_ipt $TCP_PROXY_MODE $TCP_REDIR_PORT1 $is_tproxy)
|
||||
$ipt_tmp -A PSW $(comment "默认") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_SHUNTLIST) $(REDIRECT $TCP_REDIR_PORT $is_tproxy)
|
||||
$ipt_tmp -A PSW $(comment "默认") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $TCP_REDIR_PORT $is_tproxy)
|
||||
$ipt_tmp -A PSW $(comment "默认") -p tcp $(factor $TCP_REDIR_PORTS "-m multiport --dport") $(get_redirect_ipt $TCP_PROXY_MODE $TCP_REDIR_PORT $is_tproxy)
|
||||
echolog "${msg}"
|
||||
}
|
||||
fi
|
||||
@ -262,27 +220,13 @@ load_acl() {
|
||||
# 加载UDP默认代理模式
|
||||
if [ "$UDP_PROXY_MODE" != "disable" ]; then
|
||||
[ "$UDP_NO_REDIR_PORTS" != "disable" ] && $ipt_m -A PSW $(comment "默认") -p udp -m multiport --dport $UDP_NO_REDIR_PORTS -j RETURN
|
||||
[ "3" -le "$UDP_NODE_NUM" ] && [ "$UDP_NODE3" != "nil" ] && {
|
||||
msg="UDP代理列表3:使用UDP节点3 (TPROXY:${UDP_REDIR_PORT3})代理"
|
||||
[ "$UDP_NODE" != "nil" ] && {
|
||||
msg="UDP默认代理:使用UDP节点 [$(get_action_chain_name $UDP_PROXY_MODE)](TPROXY:${UDP_REDIR_PORT})代理"
|
||||
[ "$UDP_NO_REDIR_PORTS" != "disable" ] && msg="${msg}除${TCP_NO_REDIR_PORTS}外的"
|
||||
msg="${msg}所有端口"
|
||||
$ipt_m -A PSW $(comment "列表3") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST3) $(REDIRECT $UDP_REDIR_PORT3 TPROXY)
|
||||
echolog "${msg}"
|
||||
}
|
||||
[ "2" -le "$UDP_NODE_NUM" ] && [ "$UDP_NODE2" != "nil" ] && {
|
||||
msg="UDP代理列表2:使用UDP节点2 (TPROXY:${UDP_REDIR_PORT2})代理"
|
||||
[ "$UDP_NO_REDIR_PORTS" != "disable" ] && msg="${msg}除${TCP_NO_REDIR_PORTS}外的"
|
||||
msg="${msg}所有端口"
|
||||
$ipt_m -A PSW $(comment "列表2") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST2) $(REDIRECT $UDP_REDIR_PORT2 TPROXY)
|
||||
echolog "${msg}"
|
||||
}
|
||||
[ "$UDP_NODE1" != "nil" ] && {
|
||||
msg="UDP默认代理:使用UDP节点1 [$(get_action_chain_name $UDP_PROXY_MODE)](TPROXY:${UDP_REDIR_PORT1})代理"
|
||||
[ "$UDP_NO_REDIR_PORTS" != "disable" ] && msg="${msg}除${TCP_NO_REDIR_PORTS}外的"
|
||||
msg="${msg}所有端口"
|
||||
$ipt_m -A PSW $(comment "默认") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_SHUNTLIST) $(REDIRECT $UDP_REDIR_PORT1 TPROXY)
|
||||
$ipt_m -A PSW $(comment "默认") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $UDP_REDIR_PORT1 TPROXY)
|
||||
$ipt_m -A PSW $(comment "默认") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(get_redirect_ipt $UDP_PROXY_MODE $UDP_REDIR_PORT1 TPROXY)
|
||||
$ipt_m -A PSW $(comment "默认") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_SHUNTLIST) $(REDIRECT $UDP_REDIR_PORT TPROXY)
|
||||
$ipt_m -A PSW $(comment "默认") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $UDP_REDIR_PORT TPROXY)
|
||||
$ipt_m -A PSW $(comment "默认") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(get_redirect_ipt $UDP_PROXY_MODE $UDP_REDIR_PORT TPROXY)
|
||||
echolog "${msg}"
|
||||
}
|
||||
fi
|
||||
@ -477,19 +421,19 @@ add_firewall_rule() {
|
||||
ip route add local 0.0.0.0/0 dev lo table 100
|
||||
|
||||
# 加载路由器自身代理 TCP
|
||||
if [ "$TCP_NODE1" != "nil" ]; then
|
||||
if [ "$TCP_NODE" != "nil" ]; then
|
||||
local ipt_tmp=$ipt_n
|
||||
local dns_l="PSW_OUTPUT"
|
||||
local dns_r=$(REDIRECT $TCP_REDIR_PORT1)
|
||||
local blist_r=$(REDIRECT $TCP_REDIR_PORT1)
|
||||
local p_r=$(get_redirect_ipt $LOCALHOST_TCP_PROXY_MODE $TCP_REDIR_PORT1)
|
||||
TCP_NODE1_TYPE=$(echo $(config_n_get $TCP_NODE1 type) | tr 'A-Z' 'a-z')
|
||||
local dns_r=$(REDIRECT $TCP_REDIR_PORT)
|
||||
local blist_r=$(REDIRECT $TCP_REDIR_PORT)
|
||||
local p_r=$(get_redirect_ipt $LOCALHOST_TCP_PROXY_MODE $TCP_REDIR_PORT)
|
||||
TCP_NODE_TYPE=$(echo $(config_n_get $TCP_NODE type) | tr 'A-Z' 'a-z')
|
||||
echolog "加载路由器自身 TCP 代理..."
|
||||
if [ "$TCP_NODE1_TYPE" == "brook" ] && [ "$(config_n_get $TCP_NODE1 protocol client)" == "client" ]; then
|
||||
if [ "$TCP_NODE_TYPE" == "brook" ] && [ "$(config_n_get $TCP_NODE protocol client)" == "client" ]; then
|
||||
echolog " - 启用 TPROXY 模式"
|
||||
ipt_tmp=$ipt_m
|
||||
dns_l="PSW"
|
||||
dns_r="$(REDIRECT $TCP_REDIR_PORT1 TPROXY)"
|
||||
dns_r="$(REDIRECT $TCP_REDIR_PORT TPROXY)"
|
||||
blist_r=$(REDIRECT 1 MARK)
|
||||
p_r=$(get_redirect_ipt $LOCALHOST_TCP_PROXY_MODE 1 MARK)
|
||||
fi
|
||||
@ -547,9 +491,9 @@ add_firewall_rule() {
|
||||
|
||||
if [ "$PROXY_IPV6" == "1" ]; then
|
||||
local msg="IPv6 配置不当,无法代理"
|
||||
$ip6t_n -A PSW -p tcp $(REDIRECT $TCP_REDIR_PORT1)
|
||||
$ip6t_n -A PSW_OUTPUT -p tcp $(REDIRECT $TCP_REDIR_PORT1)
|
||||
msg="${msg},转发 IPv6 TCP 流量到节点1[$?]"
|
||||
$ip6t_n -A PSW -p tcp $(REDIRECT $TCP_REDIR_PORT)
|
||||
$ip6t_n -A PSW_OUTPUT -p tcp $(REDIRECT $TCP_REDIR_PORT)
|
||||
msg="${msg},转发 IPv6 TCP 流量到节点[$?]"
|
||||
echolog "$msg"
|
||||
fi
|
||||
|
||||
@ -566,8 +510,7 @@ add_firewall_rule() {
|
||||
if [ "$node" == "nil" ] || [ "$port" == "0" ]; then
|
||||
msg="${msg} 未配置完全,略过"
|
||||
elif [ "$(echo $node | grep ^tcp)" ]; then
|
||||
num=$(echo $node | sed "s/tcp//g")
|
||||
eval "node=\${TCP_NODE$num}"
|
||||
eval "node=\${TCP_NODE}"
|
||||
msg="${msg} 使用与 TCP 代理自动切换${num} 相同的节点,延后处理"
|
||||
else
|
||||
filter_node $node TCP
|
||||
@ -579,28 +522,25 @@ add_firewall_rule() {
|
||||
# 处理轮换节点的分流或套娃
|
||||
local node port stream switch
|
||||
for stream in TCP UDP; do
|
||||
for switch in $(eval "seq 1 \${${stream}_NODE_NUM}"); do
|
||||
eval "node=\${${stream}_NODE$switch}"
|
||||
eval "port=\${${stream}_REDIR_PORT$switch}"
|
||||
echolog "分析 $stream 代理自动切换$switch..."
|
||||
[ "$node" == "tcp" ] && [ "$stream" == "UDP" ] && {
|
||||
eval "node=\${TCP_NODE$switch}"
|
||||
eval "port=\${TCP_REDIR_PORT$switch}"
|
||||
echolog " - 采用 TCP 代理的配置"
|
||||
}
|
||||
|
||||
if [ "$node" != "nil" ]; then
|
||||
filter_node $node $stream $port
|
||||
else
|
||||
echolog " - 忽略无效的 $stream 代理自动切换$switch"
|
||||
fi
|
||||
done
|
||||
eval "node=\${${stream}_NODE}"
|
||||
eval "port=\${${stream}_REDIR_PORT}"
|
||||
echolog "分析 $stream 代理自动切换..."
|
||||
[ "$node" == "tcp" ] && [ "$stream" == "UDP" ] && {
|
||||
eval "node=\${TCP_NODE}"
|
||||
eval "port=\${TCP_REDIR_PORT}"
|
||||
echolog " - 采用 TCP 代理的配置"
|
||||
}
|
||||
if [ "$node" != "nil" ]; then
|
||||
filter_node $node $stream $port
|
||||
else
|
||||
echolog " - 忽略无效的 $stream 代理自动切换"
|
||||
fi
|
||||
done
|
||||
|
||||
# 加载路由器自身代理 UDP
|
||||
if [ "$UDP_NODE1" != "nil" ]; then
|
||||
if [ "$UDP_NODE" != "nil" ]; then
|
||||
echolog "加载路由器自身 UDP 代理..."
|
||||
local UDP_NODE1_TYPE=$(echo $(config_n_get $UDP_NODE1 type) | tr 'A-Z' 'a-z')
|
||||
local UDP_NODE_TYPE=$(echo $(config_n_get $UDP_NODE type) | tr 'A-Z' 'a-z')
|
||||
local ADD_INDEX=$FORCE_INDEX
|
||||
_proxy_udp_access() {
|
||||
[ -n "${2}" ] || return 0
|
||||
@ -609,7 +549,7 @@ add_firewall_rule() {
|
||||
echolog " - 上游 DNS 服务器 ${2} 已在直接访问的列表中,不强制向 UDP 代理转发对该服务器 UDP/${3} 端口的访问"
|
||||
return 0
|
||||
}
|
||||
$ipt_m -I PSW $ADD_INDEX -p udp -d ${2} --dport ${3} $(REDIRECT $UDP_REDIR_PORT1 TPROXY)
|
||||
$ipt_m -I PSW $ADD_INDEX -p udp -d ${2} --dport ${3} $(REDIRECT $UDP_REDIR_PORT TPROXY)
|
||||
$ipt_m -I PSW_OUTPUT $ADD_INDEX -p udp -d ${2} --dport ${3} $(REDIRECT 1 MARK)
|
||||
echolog " - [$?]将上游 DNS 服务器 ${2}:${3} 加入到路由器自身代理的 UDP 转发链${ADD_INDEX}"
|
||||
}
|
||||
|
||||
@ -26,55 +26,39 @@ ENABLED=$(config_t_get global_delay start_daemon 0)
|
||||
sleep 1m
|
||||
while [ "$ENABLED" -eq 1 ]
|
||||
do
|
||||
TCP_NODE_NUM=$(config_t_get global_other tcp_node_num 1)
|
||||
for i in $(seq 1 $TCP_NODE_NUM); do
|
||||
eval TCP_NODE$i=$(config_t_get global tcp_node$i nil)
|
||||
done
|
||||
|
||||
UDP_NODE_NUM=$(config_t_get global_other udp_node_num 1)
|
||||
for i in $(seq 1 $UDP_NODE_NUM); do
|
||||
eval UDP_NODE$i=$(config_t_get global udp_node$i nil)
|
||||
done
|
||||
|
||||
dns_mode=$(config_t_get global dns_mode)
|
||||
use_haproxy=$(config_t_get global_haproxy balancing_enable 0)
|
||||
|
||||
#tcp
|
||||
for i in $(seq 1 $TCP_NODE_NUM); do
|
||||
eval tmp_node=\$TCP_NODE$i
|
||||
if [ "$tmp_node" != "nil" ]; then
|
||||
#kcptun
|
||||
use_kcp=$(config_n_get $tmp_node use_kcp 0)
|
||||
if [ $use_kcp -gt 0 ]; then
|
||||
icount=$(ps -w | grep -v grep | grep "$RUN_BIN_PATH/kcptun" | grep -i "tcp_${i}" | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
icount=$(ps -w | grep -v -E 'grep|kcptun' | grep "$RUN_BIN_PATH" | grep -i "TCP_${i}" | wc -l)
|
||||
TCP_NODE=$(config_t_get global tcp_node nil)
|
||||
if [ "$TCP_NODE" != "nil" ]; then
|
||||
#kcptun
|
||||
use_kcp=$(config_n_get $TCP_NODE use_kcp 0)
|
||||
if [ $use_kcp -gt 0 ]; then
|
||||
icount=$(ps -w | grep -v grep | grep "$RUN_BIN_PATH/kcptun" | grep -i "tcp" | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
icount=$(ps -w | grep -v -E 'grep|kcptun' | grep "$RUN_BIN_PATH" | grep -i "TCP" | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
#udp
|
||||
for i in $(seq 1 $UDP_NODE_NUM); do
|
||||
eval tmp_node=\$UDP_NODE$i
|
||||
if [ "$tmp_node" != "nil" ]; then
|
||||
[ "$tmp_node" == "tcp" ] && continue
|
||||
[ "$tmp_node" == "tcp_" ] && tmp_node=$TCP_NODE1
|
||||
icount=$(ps -w | grep -v grep | grep "$RUN_BIN_PATH" | grep -i "UDP_${i}" | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
UDP_NODE=$(config_t_get global udp_node nil)
|
||||
if [ "$UDP_NODE" != "nil" ]; then
|
||||
[ "$UDP_NODE" == "tcp" ] && continue
|
||||
[ "$UDP_NODE" == "tcp_" ] && UDP_NODE=$TCP_NODE1
|
||||
icount=$(ps -w | grep -v grep | grep "$RUN_BIN_PATH" | grep -i "UDP" | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
#dns
|
||||
dns_mode=$(config_t_get global dns_mode)
|
||||
if [ "$dns_mode" != "nonuse" ] && [ "$dns_mode" != "custom" ]; then
|
||||
icount=$(netstat -apn | grep 7913 | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
@ -84,6 +68,7 @@ do
|
||||
fi
|
||||
|
||||
#haproxy
|
||||
use_haproxy=$(config_t_get global_haproxy balancing_enable 0)
|
||||
if [ $use_haproxy -gt 0 ]; then
|
||||
icount=$(ps -w | grep -v grep | grep "$RUN_BIN_PATH/haproxy" | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
|
||||
@ -44,27 +44,24 @@ end
|
||||
local CONFIG = {}
|
||||
do
|
||||
local function import_config(protocol)
|
||||
local node_num = ucic2:get(application, "@global_other[0]", protocol .. "_node_num") or 1
|
||||
for i = 1, node_num, 1 do
|
||||
local name = string.upper(protocol)
|
||||
local szType = "@global[0]"
|
||||
local option = protocol .. "_node" .. i
|
||||
|
||||
local node = ucic2:get(application, szType, option)
|
||||
local currentNode
|
||||
if node then
|
||||
currentNode = ucic2:get_all(application, node)
|
||||
end
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
log = true,
|
||||
remarks = name .. "节点" .. i,
|
||||
node = node,
|
||||
currentNode = currentNode,
|
||||
set = function(server)
|
||||
ucic2:set(application, szType, option, server)
|
||||
end
|
||||
}
|
||||
local name = string.upper(protocol)
|
||||
local szType = "@global[0]"
|
||||
local option = protocol .. "_node"
|
||||
|
||||
local node = ucic2:get(application, szType, option)
|
||||
local currentNode
|
||||
if node then
|
||||
currentNode = ucic2:get_all(application, node)
|
||||
end
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
log = true,
|
||||
remarks = name .. "节点",
|
||||
node = node,
|
||||
currentNode = currentNode,
|
||||
set = function(server)
|
||||
ucic2:set(application, szType, option, server)
|
||||
end
|
||||
}
|
||||
end
|
||||
import_config("tcp")
|
||||
import_config("udp")
|
||||
@ -85,21 +82,21 @@ do
|
||||
}
|
||||
end)
|
||||
|
||||
local tcp_main1 = ucic2:get(application, "@auto_switch[0]", "tcp_main1") or "nil"
|
||||
local tcp_main = ucic2:get(application, "@auto_switch[0]", "tcp_main") or "nil"
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
log = false,
|
||||
remarks = "自动切换TCP_1主节点",
|
||||
currentNode = ucic2:get_all(application, tcp_main1),
|
||||
remarks = "自动切换TCP主节点",
|
||||
currentNode = ucic2:get_all(application, tcp_main),
|
||||
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 tcp_node_table = ucic2:get(application, "@auto_switch[0]", "tcp_node")
|
||||
if tcp_node_table then
|
||||
local nodes = {}
|
||||
local new_nodes = {}
|
||||
for k,v in ipairs(tcp_node1_table) do
|
||||
for k,v in ipairs(tcp_node_table) do
|
||||
local node = v
|
||||
local currentNode
|
||||
if node then
|
||||
@ -120,14 +117,14 @@ do
|
||||
}
|
||||
end
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
remarks = "自动切换TCP_1节点列表",
|
||||
remarks = "自动切换TCP节点列表",
|
||||
nodes = nodes,
|
||||
new_nodes = new_nodes,
|
||||
set = function()
|
||||
for kk, vv in pairs(CONFIG) do
|
||||
if (vv.remarks == "自动切换TCP_1节点列表") then
|
||||
log("刷新自动切换列表")
|
||||
ucic2:set_list(application, "@auto_switch[0]", "tcp_node1", vv.new_nodes)
|
||||
ucic2:set_list(application, "@auto_switch[0]", "tcp_node", vv.new_nodes)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -57,11 +57,10 @@ test_proxy() {
|
||||
|
||||
test_auto_switch() {
|
||||
local type=$1
|
||||
local index=$3
|
||||
local b_tcp_nodes=$4
|
||||
local b_tcp_nodes=$3
|
||||
local now_node
|
||||
if [ -f "/var/etc/$CONFIG/id/${type}_${index}" ]; then
|
||||
now_node=$(cat /var/etc/$CONFIG/id/${type}_${index})
|
||||
if [ -f "/var/etc/$CONFIG/id/${type}" ]; then
|
||||
now_node=$(cat /var/etc/$CONFIG/id/${type})
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
@ -72,10 +71,10 @@ test_auto_switch() {
|
||||
return 2
|
||||
fi
|
||||
|
||||
local restore_switch=$(config_t_get auto_switch restore_switch${index} 0)
|
||||
local restore_switch=$(config_t_get auto_switch restore_switch 0)
|
||||
if [ "$restore_switch" == "1" ]; then
|
||||
#检测主节点是否能使用
|
||||
local main_node=$(config_t_get auto_switch tcp_main${index})
|
||||
local main_node=$(config_t_get auto_switch tcp_main)
|
||||
if [ "$now_node" != "$main_node" ]; then
|
||||
local node_type=$(echo $(config_n_get $main_node type) | tr 'A-Z' 'a-z')
|
||||
if [ "$node_type" == "socks" ]; then
|
||||
@ -84,26 +83,26 @@ test_auto_switch() {
|
||||
[ -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"
|
||||
/usr/share/passwall/app.sh run_socks "$main_node" "127.0.0.1" "$tmp_port" "/var/etc/passwall/auto_switch.json" "10"
|
||||
local curlx="socks5h://127.0.0.1:$tmp_port"
|
||||
fi
|
||||
sleep 10s
|
||||
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
|
||||
ps -w | grep -v "grep" | grep "/var/etc/passwall/auto_switch.json" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1
|
||||
if [ "$proxy_status" -eq 200 ]; then
|
||||
#主节点正常,切换到主节点
|
||||
echolog "自动切换检测:${type}_${index}主节点正常,切换到主节点!"
|
||||
/usr/share/passwall/app.sh node_switch $type $2 $index $main_node
|
||||
echolog "自动切换检测:${type}主节点正常,切换到主节点!"
|
||||
/usr/share/passwall/app.sh node_switch $type $2 $main_node
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$status" == 0 ]; then
|
||||
echolog "自动切换检测:${type}_${index}节点$(config_n_get $now_node type) $(config_n_get $now_node address) $(config_n_get $now_node port)正常。"
|
||||
echolog "自动切换检测:${type}节点$(config_n_get $now_node type) $(config_n_get $now_node address) $(config_n_get $now_node port)正常。"
|
||||
return 0
|
||||
elif [ "$status" == 1 ]; then
|
||||
echolog "自动切换检测:${type}_${index}节点异常,开始切换节点!"
|
||||
echolog "自动切换检测:${type}节点异常,开始切换节点!"
|
||||
local new_node
|
||||
in_backup_nodes=$(echo $b_tcp_nodes | grep $now_node)
|
||||
# 判断当前节点是否存在于备用节点列表里
|
||||
@ -120,15 +119,15 @@ test_auto_switch() {
|
||||
new_node=$next_node
|
||||
fi
|
||||
fi
|
||||
/usr/share/passwall/app.sh node_switch $type $2 $index $new_node
|
||||
/usr/share/passwall/app.sh node_switch $type $2 $new_node
|
||||
sleep 10s
|
||||
# 切换节点后等待10秒后再检测一次,如果还是不通继续切,直到可用为止
|
||||
status2=$(test_proxy)
|
||||
if [ "$status2" -eq 0 ]; then
|
||||
echolog "自动切换检测:${type}_${index}节点切换完毕!"
|
||||
echolog "自动切换检测:${type}节点切换完毕!"
|
||||
return 0
|
||||
elif [ "$status2" -eq 1 ]; then
|
||||
test_auto_switch $1 $2 $3 "$4"
|
||||
test_auto_switch $1 $2 "$3"
|
||||
elif [ "$status2" -eq 2 ]; then
|
||||
return 2
|
||||
fi
|
||||
@ -144,16 +143,10 @@ start() {
|
||||
sleep ${delay}m
|
||||
while [ "$ENABLED" -eq 1 ]
|
||||
do
|
||||
# TCP_NODE_NUM=$(config_t_get global_other tcp_node_num 1)
|
||||
# 暂时只能检测TCP1
|
||||
TCP_NODE_NUM=1
|
||||
for i in $(seq 1 $TCP_NODE_NUM); do
|
||||
eval TCP_NODE$i=\"$(config_t_get auto_switch tcp_node$i nil)\"
|
||||
eval tmp=\$TCP_NODE$i
|
||||
[ -n "$tmp" -a "$tmp" != "nil" ] && {
|
||||
test_auto_switch TCP tcp $i "$tmp"
|
||||
}
|
||||
done
|
||||
TCP_NODE=$(config_t_get auto_switch tcp_node nil)
|
||||
[ -n "$TCP_NODE" -a "$TCP_NODE" != "nil" ] && {
|
||||
test_auto_switch TCP tcp "$TCP_NODE"
|
||||
}
|
||||
delay=$(config_t_get auto_switch testing_time 1)
|
||||
sleep ${delay}m
|
||||
done
|
||||
|
||||
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=lua
|
||||
PKG_VERSION:=5.1.5
|
||||
PKG_RELEASE:=7
|
||||
PKG_RELEASE:=8
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.lua.org/ftp/ \
|
||||
@ -99,7 +99,7 @@ define Build/Compile
|
||||
RANLIB="$(TARGET_CROSS)ranlib" \
|
||||
INSTALL_ROOT=/usr \
|
||||
CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
|
||||
MYLDFLAGS="$(TARGET_LDFLAGS) $(if $(CONFIG_USE_GLIBC),-lm)" \
|
||||
MYLDFLAGS="$(TARGET_LDFLAGS) $(if $(CONFIG_USE_GLIBC),-lm -ldl)" \
|
||||
PKG_VERSION=$(PKG_VERSION) \
|
||||
linux
|
||||
rm -rf $(PKG_INSTALL_DIR)
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2011-2014 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=usbreset
|
||||
PKG_RELEASE:=5
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/usbreset
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Utility to send a USB port reset to a USB device
|
||||
MAINTAINER:=Jo-Philipp Wich <xm@subsignal.org>
|
||||
endef
|
||||
|
||||
define Package/usbreset/description
|
||||
This package contains the small usbreset utility which
|
||||
can be used to send a USB port reset to a USB device -
|
||||
useful for debugging or to force re-detection of particular
|
||||
devices.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(TARGET_CC) $(TARGET_CFLAGS) -Wall \
|
||||
-o $(PKG_BUILD_DIR)/usbreset $(PKG_BUILD_DIR)/usbreset.c
|
||||
endef
|
||||
|
||||
define Package/usbreset/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/usbreset $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,usbreset))
|
||||
@ -1,236 +0,0 @@
|
||||
/* usbreset -- send a USB port reset to a USB device */
|
||||
|
||||
/*
|
||||
|
||||
http://marc.info/?l=linux-usb-users&m=116827193506484&w=2
|
||||
|
||||
and needs mounted usbfs filesystem
|
||||
|
||||
sudo mount -t usbfs none /proc/bus/usb
|
||||
|
||||
There is a way to suspend a USB device. In order to use it,
|
||||
you must have a kernel with CONFIG_PM_SYSFS_DEPRECATED turned on. To
|
||||
suspend a device, do (as root):
|
||||
|
||||
echo -n 2 >/sys/bus/usb/devices/.../power/state
|
||||
|
||||
where the "..." is the ID for your device. To unsuspend, do the same
|
||||
thing but with a "0" instead of the "2" above.
|
||||
|
||||
Note that this mechanism is slated to be removed from the kernel within
|
||||
the next year. Hopefully some other mechanism will take its place.
|
||||
|
||||
> To reset a
|
||||
> device?
|
||||
|
||||
Here's a program to do it. You invoke it as either
|
||||
|
||||
usbreset /proc/bus/usb/BBB/DDD
|
||||
or
|
||||
usbreset /dev/usbB.D
|
||||
|
||||
depending on how your system is set up, where BBB and DDD are the bus and
|
||||
device address numbers.
|
||||
|
||||
Alan Stern
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <linux/usbdevice_fs.h>
|
||||
|
||||
|
||||
static char *usbfs = NULL;
|
||||
|
||||
struct usbentry {
|
||||
int bus_num;
|
||||
int dev_num;
|
||||
int vendor_id;
|
||||
int product_id;
|
||||
char vendor_name[128];
|
||||
char product_name[128];
|
||||
};
|
||||
|
||||
|
||||
static char *sysfs_attr(const char *dev, const char *attr)
|
||||
{
|
||||
int fd, len = 0;
|
||||
char path[PATH_MAX];
|
||||
static char buf[129];
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
snprintf(path, sizeof(path) - 1, "/sys/bus/usb/devices/%s/%s", dev, attr);
|
||||
|
||||
if ((fd = open(path, O_RDONLY)) >= 0)
|
||||
{
|
||||
len = read(fd, buf, sizeof(buf) - 1);
|
||||
close(fd);
|
||||
}
|
||||
|
||||
while (--len > 0 && isspace(buf[len]))
|
||||
buf[len] = 0;
|
||||
|
||||
return (len >= 0) ? buf : NULL;
|
||||
}
|
||||
|
||||
static struct usbentry * parse_devlist(DIR *d)
|
||||
{
|
||||
char *attr;
|
||||
struct dirent *e;
|
||||
static struct usbentry dev;
|
||||
|
||||
do {
|
||||
e = readdir(d);
|
||||
|
||||
if (!e)
|
||||
return NULL;
|
||||
}
|
||||
while(!isdigit(e->d_name[0]) || strchr(e->d_name, ':'));
|
||||
|
||||
memset(&dev, 0, sizeof(dev));
|
||||
|
||||
if ((attr = sysfs_attr(e->d_name, "busnum")) != NULL)
|
||||
dev.bus_num = strtoul(attr, NULL, 10);
|
||||
|
||||
if ((attr = sysfs_attr(e->d_name, "devnum")) != NULL)
|
||||
dev.dev_num = strtoul(attr, NULL, 10);
|
||||
|
||||
if ((attr = sysfs_attr(e->d_name, "idVendor")) != NULL)
|
||||
dev.vendor_id = strtoul(attr, NULL, 16);
|
||||
|
||||
if ((attr = sysfs_attr(e->d_name, "idProduct")) != NULL)
|
||||
dev.product_id = strtoul(attr, NULL, 16);
|
||||
|
||||
if ((attr = sysfs_attr(e->d_name, "manufacturer")) != NULL)
|
||||
strcpy(dev.vendor_name, attr);
|
||||
|
||||
if ((attr = sysfs_attr(e->d_name, "product")) != NULL)
|
||||
strcpy(dev.product_name, attr);
|
||||
|
||||
if (dev.bus_num && dev.dev_num && dev.vendor_id && dev.product_id)
|
||||
return &dev;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void list_devices(void)
|
||||
{
|
||||
DIR *devs = opendir("/sys/bus/usb/devices");
|
||||
struct usbentry *dev;
|
||||
|
||||
if (!devs)
|
||||
return;
|
||||
|
||||
while ((dev = parse_devlist(devs)) != NULL)
|
||||
{
|
||||
printf(" Number %03d/%03d ID %04x:%04x %s\n",
|
||||
dev->bus_num, dev->dev_num,
|
||||
dev->vendor_id, dev->product_id,
|
||||
dev->product_name);
|
||||
}
|
||||
|
||||
closedir(devs);
|
||||
}
|
||||
|
||||
struct usbentry * find_device(int *bus, int *dev,
|
||||
int *vid, int *pid,
|
||||
const char *product)
|
||||
{
|
||||
DIR *devs = opendir("/sys/bus/usb/devices");
|
||||
|
||||
struct usbentry *e, *match = NULL;
|
||||
|
||||
if (!devs)
|
||||
return NULL;
|
||||
|
||||
while ((e = parse_devlist(devs)) != NULL)
|
||||
{
|
||||
if ((bus && (e->bus_num == *bus) && (e->dev_num == *dev)) ||
|
||||
(vid && (e->vendor_id == *vid) && (e->product_id == *pid)) ||
|
||||
(product && !strcasecmp(e->product_name, product)))
|
||||
{
|
||||
match = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(devs);
|
||||
|
||||
return match;
|
||||
}
|
||||
|
||||
static void reset_device(struct usbentry *dev)
|
||||
{
|
||||
int fd;
|
||||
char path[PATH_MAX];
|
||||
|
||||
snprintf(path, sizeof(path) - 1, "/dev/bus/usb/%03d/%03d",
|
||||
dev->bus_num, dev->dev_num);
|
||||
|
||||
printf("Resetting %s ... ", dev->product_name);
|
||||
|
||||
if ((fd = open(path, O_WRONLY)) > -1)
|
||||
{
|
||||
if (ioctl(fd, USBDEVFS_RESET, 0) < 0)
|
||||
printf("failed [%s]\n", strerror(errno));
|
||||
else
|
||||
printf("ok\n");
|
||||
|
||||
close(fd);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("can't open [%s]\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int id1, id2;
|
||||
struct usbentry *dev;
|
||||
|
||||
if ((argc == 2) && (sscanf(argv[1], "%3d/%3d", &id1, &id2) == 2))
|
||||
{
|
||||
dev = find_device(&id1, &id2, NULL, NULL, NULL);
|
||||
}
|
||||
else if ((argc == 2) && (sscanf(argv[1], "%4x:%4x", &id1, &id2) == 2))
|
||||
{
|
||||
dev = find_device(NULL, NULL, &id1, &id2, NULL);
|
||||
}
|
||||
else if ((argc == 2) && strlen(argv[1]) < 128)
|
||||
{
|
||||
dev = find_device(NULL, NULL, NULL, NULL, argv[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Usage:\n"
|
||||
" usbreset PPPP:VVVV - reset by product and vendor id\n"
|
||||
" usbreset BBB/DDD - reset by bus and device number\n"
|
||||
" usbreset \"Product\" - reset by product name\n\n"
|
||||
"Devices:\n");
|
||||
list_devices();
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!dev)
|
||||
{
|
||||
fprintf(stderr, "No such device found\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
reset_device(dev);
|
||||
return 0;
|
||||
}
|
||||
@ -1,60 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2007-2016 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=usbutils
|
||||
PKG_VERSION:=007
|
||||
PKG_RELEASE:=11
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||
PKG_SOURCE_URL:=@KERNEL/linux/utils/usb/usbutils
|
||||
PKG_HASH:=7593a01724bbc0fd9fe48e62bc721ceb61c76654f1d7b231b3c65f6dfbbaefa4
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_INSTALL:=1
|
||||
|
||||
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/usbutils
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
DEPENDS:=+libusb-1.0 +librt +libpthread
|
||||
TITLE:=USB devices listing utilities
|
||||
URL:=http://www.linux-usb.org/
|
||||
endef
|
||||
|
||||
USB_IDS_VER:=0.339
|
||||
USB_IDS_FILE:=usb.ids.$(USB_IDS_VER)
|
||||
define Download/usb_ids
|
||||
FILE:=$(USB_IDS_FILE)
|
||||
URL_FILE:=usb.ids
|
||||
URL:=@GITHUB/vcrhonek/hwdata/v$(USB_IDS_VER)
|
||||
HASH:=5ab6b663d3119217aa4117e95063c9b82646107344f2ae1d22248c6c29389fd7
|
||||
endef
|
||||
$(eval $(call Download,usb_ids))
|
||||
|
||||
define Build/Prepare
|
||||
$(Build/Prepare/Default)
|
||||
$(CP) $(DL_DIR)/$(USB_IDS_FILE) $(PKG_BUILD_DIR)/usb.ids
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--disable-zlib
|
||||
|
||||
define Package/usbutils/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lsusb $(1)/usr/bin/
|
||||
$(INSTALL_DIR) $(1)/usr/share
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/usb.ids $(1)/usr/share/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,usbutils))
|
||||
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
_cc="${HOSTCC_REAL:-gcc}"
|
||||
case "$1" in
|
||||
-print-file-name=*)
|
||||
dirs="$($_cc -print-search-dirs | grep -m1 libraries | sed -e 's,:, ,' -e 's,.* =,,')"
|
||||
dirs="$dirs /usr/lib /usr/local/lib"
|
||||
find $dirs -name "${1#*=}" | head -n1
|
||||
;;
|
||||
*)
|
||||
exec $_cc "$@"
|
||||
;;
|
||||
esac
|
||||
@ -537,7 +537,9 @@ sub install_src {
|
||||
my $override = 0;
|
||||
if (is_core_src($name)) {
|
||||
if (!$force) {
|
||||
warn "Not overriding core package $name; use -f to force\n";
|
||||
if ($name ne "toolchain" && $name ne "linux") {
|
||||
warn "WARNING: Not overriding core package '$name'; use -f to force\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
$override = 1;
|
||||
|
||||
@ -48,6 +48,7 @@ $(curdir)/cbootimage/compile += $(curdir)/automake/compile
|
||||
$(curdir)/cmake/compile += $(curdir)/libressl/compile
|
||||
$(curdir)/dosfstools/compile := $(curdir)/autoconf/compile $(curdir)/automake/compile
|
||||
$(curdir)/e2fsprogs/compile := $(curdir)/libtool/compile
|
||||
$(curdir)/fakeroot/compile := $(curdir)/libtool/compile
|
||||
$(curdir)/findutils/compile := $(curdir)/bison/compile
|
||||
$(curdir)/firmware-utils/compile += $(curdir)/libressl/compile $(curdir)/zlib/compile
|
||||
$(curdir)/flex/compile := $(curdir)/libtool/compile
|
||||
|
||||
@ -5,14 +5,15 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fakeroot
|
||||
PKG_VERSION:=1.24
|
||||
PKG_RELEASE:=2
|
||||
PKG_VERSION:=1.25.3
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
|
||||
PKG_SOURCE_URL:=http://deb.debian.org/debian/pool/main/f/fakeroot
|
||||
PKG_HASH:=2e045b3160370b8ab4d44d1f8d267e5d1d555f1bb522d650e7167b09477266ed
|
||||
PKG_HASH:=8e903683357f7f5bcc31b879fd743391ad47691d4be33d24a76be3b6c21e956c
|
||||
PKG_LICENSE:=GPL-3.0-or-later
|
||||
PKG_LICENSE_FILES:=COPYING
|
||||
PKG_FIXUP:=autoreconf
|
||||
|
||||
include $(INCLUDE_DIR)/host-build.mk
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
-FAKEROOT_BINDIR=@bindir@
|
||||
+if [ -n "$STAGING_DIR_HOST" ]; then
|
||||
+ USEABSLIBPATH=1
|
||||
+ LIB=${STAGING_DIR_HOST}/lib/lib@fakeroot_transformed@@DLSUFFIX@
|
||||
+ FAKEROOT_LIB=${STAGING_DIR_HOST}/lib/lib@fakeroot_transformed@@DLSUFFIX@
|
||||
+ FAKED=${STAGING_DIR_HOST}/bin/faked
|
||||
+ PATHS=
|
||||
+else
|
||||
@ -16,11 +16,11 @@
|
||||
+ FAKEROOT_BINDIR=@bindir@
|
||||
|
||||
-USEABSLIBPATH=@LDPRELOADABS@
|
||||
-LIB=lib@fakeroot_transformed@@DLSUFFIX@
|
||||
-FAKEROOT_LIB=lib@fakeroot_transformed@@DLSUFFIX@
|
||||
-PATHS=@libdir@:${FAKEROOT_PREFIX}/lib64/libfakeroot:${FAKEROOT_PREFIX}/lib32/libfakeroot
|
||||
-FAKED=${FAKEROOT_BINDIR}/@faked_transformed@
|
||||
+ USEABSLIBPATH=@LDPRELOADABS@
|
||||
+ LIB=lib@fakeroot_transformed@@DLSUFFIX@
|
||||
+ FAKEROOT_LIB=lib@fakeroot_transformed@@DLSUFFIX@
|
||||
+ PATHS=@libdir@:${FAKEROOT_PREFIX}/lib64/libfakeroot:${FAKEROOT_PREFIX}/lib32/libfakeroot
|
||||
+ FAKED=${FAKEROOT_BINDIR}/@faked_transformed@
|
||||
+fi
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
--- a/libfakeroot.c
|
||||
+++ b/libfakeroot.c
|
||||
@@ -110,8 +110,16 @@
|
||||
#define INT_NEXT_FSTATAT(a,b,c,d) NEXT_FSTATAT(_STAT_VER,a,b,c,d)
|
||||
@@ -112,8 +112,16 @@
|
||||
#define INT_SEND_STAT(a,b) SEND_STAT(a,b,_STAT_VER)
|
||||
#define INT_SEND_GET_XATTR(a,b) SEND_GET_XATTR(a,b,_STAT_VER)
|
||||
#define INT_SEND_GET_STAT(a,b) SEND_GET_STAT(a,b)
|
||||
+
|
||||
+/* 10.10 uses id_t in getpriority/setpriority calls, so pretend
|
||||
+ id_t is used everywhere, just happens to be int on some OSes */
|
||||
@ -17,7 +17,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/msg.h>
|
||||
@@ -123,7 +131,6 @@
|
||||
@@ -125,7 +133,6 @@
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
@ -25,7 +25,7 @@
|
||||
#ifdef HAVE_SYS_ACL_H
|
||||
#include <sys/acl.h>
|
||||
#endif /* HAVE_SYS_ACL_H */
|
||||
@@ -1894,7 +1901,7 @@ ssize_t fremovexattr(int fd, const char
|
||||
@@ -1911,7 +1918,7 @@ ssize_t fremovexattr(int fd, const char
|
||||
}
|
||||
#endif /* HAVE_FREMOVEXATTR */
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
if (fakeroot_disabled)
|
||||
return next_setpriority(which, who, prio);
|
||||
next_setpriority(which, who, prio);
|
||||
@@ -2426,3 +2433,19 @@ int sysinfo(int command, char *buf, long
|
||||
@@ -2520,3 +2527,19 @@ int sysinfo(int command, char *buf, long
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -56,16 +56,16 @@
|
||||
+#endif
|
||||
--- a/wrapfunc.inp
|
||||
+++ b/wrapfunc.inp
|
||||
@@ -145,7 +145,7 @@ setfsgid;gid_t;(gid_t fsgid);(fsgid)
|
||||
#endif /* HAVE_SETFSGID */
|
||||
@@ -146,7 +146,7 @@ setfsgid;gid_t;(gid_t fsgid);(fsgid)
|
||||
initgroups;int;(const char *user, INITGROUPS_SECOND_ARG group);(user, group)
|
||||
getgroups;int;(int size, gid_t list[]);(size, list)
|
||||
setgroups;int;(SETGROUPS_SIZE_TYPE size, const gid_t *list);(size, list)
|
||||
-setpriority;int;(int which, int who, int prio);(which, who, prio)
|
||||
+setpriority;int;(int which, id_t who, int prio);(which, who, prio)
|
||||
#ifdef HAVE_CAPSET
|
||||
capset;int;(cap_user_header_t hdrp, const cap_user_data_t datap);(hdrp, datap)
|
||||
#endif /* HAVE_CAPSET */
|
||||
@@ -197,7 +197,7 @@ fchownat;int;(int dir_fd, const char *pa
|
||||
@@ -198,7 +198,7 @@ fchownat;int;(int dir_fd, const char *pa
|
||||
mkdirat;int;(int dir_fd, const char *pathname, mode_t mode);(dir_fd, pathname, mode)
|
||||
#endif /* HAVE_MKDIRAT */
|
||||
#ifdef HAVE_OPENAT
|
||||
@ -112,17 +112,7 @@
|
||||
print "static __inline__ " ret " next_" name, argtype " {" > tmpffile;
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -110,6 +110,7 @@ for first in size_t int; do
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
+#include <stdio.h>
|
||||
#ifdef HAVE_GRP_H
|
||||
#include <grp.h>
|
||||
#endif
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -12847,6 +12847,7 @@ for first in size_t int; do
|
||||
@@ -146,6 +146,7 @@ for first in size_t int; do
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
10
tools/fakeroot/patches/200-disable-doc.patch
Normal file
10
tools/fakeroot/patches/200-disable-doc.patch
Normal file
@ -0,0 +1,10 @@
|
||||
--- a/Makefile.am
|
||||
+++ b/Makefile.am
|
||||
@@ -1,6 +1,6 @@
|
||||
AUTOMAKE_OPTIONS=foreign
|
||||
ACLOCAL_AMFLAGS = -I build-aux
|
||||
-SUBDIRS=doc scripts test
|
||||
+SUBDIRS=scripts test
|
||||
|
||||
noinst_LTLIBRARIES = libcommunicate.la libmacosx.la
|
||||
libcommunicate_la_SOURCES = communicate.c
|
||||
@ -1,32 +0,0 @@
|
||||
Description: Hide error from dlsym()
|
||||
dlsym(), starting in glibc 2.24 actually reports errors. In our case,
|
||||
we try to get ACL functions which are not in the glibc. This causes
|
||||
failures in test suites, so hide those messages for non-debugging
|
||||
purposes for now. It also makes the build logs annoying to read.
|
||||
Author: Julian Andres Klode <juliank@ubuntu.com>
|
||||
Origin: vendor
|
||||
Bug-Debian: https://bugs.debian.org/830912
|
||||
Forwarded: no
|
||||
Last-Update: 2016-08-12
|
||||
|
||||
--- a/libfakeroot.c
|
||||
+++ b/libfakeroot.c
|
||||
@@ -256,10 +256,16 @@ void load_library_symbols(void){
|
||||
/* clear dlerror() just in case dlsym() legitimately returns NULL */
|
||||
msg = dlerror();
|
||||
*(next_wrap[i].doit)=dlsym(get_libc(), next_wrap[i].name);
|
||||
+
|
||||
if ( (msg = dlerror()) != NULL){
|
||||
- fprintf (stderr, "dlsym(%s): %s\n", next_wrap[i].name, msg);
|
||||
-/* abort ();*/
|
||||
+#ifdef LIBFAKEROOT_DEBUGGING
|
||||
+ if (fakeroot_debug) {
|
||||
+ fprintf (stderr, "dlsym(%s): %s\n", next_wrap[i].name, msg);
|
||||
+/* abort ();*/
|
||||
+ }
|
||||
+#endif
|
||||
}
|
||||
+
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user