luci-app-passwall: sync with upstream source

This commit is contained in:
CN_SZTL 2020-04-10 01:07:41 +08:00
parent 541e0f4ed4
commit abdeca1ff8
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
20 changed files with 205 additions and 212 deletions

View File

@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=3.6
PKG_RELEASE:=38
PKG_DATE:=20200406
PKG_RELEASE:=39
PKG_DATE:=20200408
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

View File

@ -149,17 +149,17 @@ function status()
appname, i)) == 0
end
local socks5_node_num = luci.sys.exec(
"echo -n $(uci -q get %s.@global_other[0].socks5_node_num)" %
local socks_node_num = luci.sys.exec(
"echo -n $(uci -q get %s.@global_other[0].socks_node_num)" %
appname)
for i = 1, socks5_node_num, 1 do
for i = 1, socks_node_num, 1 do
e["kcptun_socks_node%s_status" % i] =
luci.sys.call(string.format(
"ps -w | grep -v grep | grep '%s/bin/' | grep 'kcptun_socks_%s' >/dev/null",
appname, i)) == 0
e["socks5_node%s_status" % i] = luci.sys.call(
e["socks_node%s_status" % i] = luci.sys.call(
string.format(
"ps -w | grep -v grep | grep -v kcptun | grep '%s/bin/' | grep -i -E 'SOCKS_%s|SOCKS5_%s' >/dev/null",
"ps -w | grep -v grep | grep -v kcptun | grep '%s/bin/' | grep -i 'SOCKS_%s' >/dev/null",
appname, i, i)) == 0
end
luci.http.prepare_content("application/json")

View File

@ -3,7 +3,7 @@ local json = require "luci.jsonc"
local node_section = arg[1]
local proto = arg[2]
local redir_port = arg[3]
local socks5_proxy_port = arg[4]
local socks_proxy_port = arg[4]
local node = ucursor:get_all("passwall", node_section)
local inbounds = {}
local outbounds = {}
@ -103,10 +103,10 @@ local function gen_outbound(node)
return result
end
if socks5_proxy_port ~= "nil" then
if socks_proxy_port ~= "nil" then
table.insert(inbounds, {
listen = "0.0.0.0",
port = socks5_proxy_port,
port = socks_proxy_port,
protocol = "socks",
settings = {auth = "noauth", udp = true, ip = "127.0.0.1"}
})

View File

@ -4,7 +4,7 @@ local json = require "luci.jsonc"
local node_section = arg[1]
local proto = arg[2]
local redir_port = arg[3]
local socks5_proxy_port = arg[4]
local socks_proxy_port = arg[4]
local node = ucursor:get_all("passwall", node_section)
local inbounds = {}
local outbounds = {}
@ -27,7 +27,7 @@ local function gen_outbound(node)
node.port = new_port
sys.call(string.format(
"/usr/share/passwall/app.sh gen_start_config %s %s %s %s %s %s",
node_id, new_port, "SOCKS5",
node_id, new_port, "SOCKS",
"/var/etc/passwall/v2_balancing_" .. node_type .. "_" ..
node_id .. ".json", "4", "127.0.0.1"))
node.v2ray_protocol = "socks"
@ -121,10 +121,10 @@ local function gen_outbound(node)
return result
end
if socks5_proxy_port ~= "nil" then
if socks_proxy_port ~= "nil" then
table.insert(inbounds, {
listen = "0.0.0.0",
port = socks5_proxy_port,
port = socks_proxy_port,
protocol = "socks",
settings = {auth = "noauth", udp = true, ip = "127.0.0.1"}
})

View File

@ -4,7 +4,7 @@ local json = require "luci.jsonc"
local node_section = arg[1]
local proto = arg[2]
local redir_port = arg[3]
local socks5_proxy_port = arg[4]
local socks_proxy_port = arg[4]
local node = ucursor:get_all("passwall", node_section)
local inbounds = {}
local outbounds = {}
@ -27,7 +27,7 @@ local function gen_outbound(node, tag)
node.port = new_port
sys.call(string.format(
"/usr/share/passwall/app.sh gen_start_config %s %s %s %s %s %s",
node_id, new_port, "SOCKS5",
node_id, new_port, "SOCKS",
"/var/etc/passwall/v2_shunt_" .. node_type .. "_" ..
node_id .. ".json", "4", "127.0.0.1"))
node.v2ray_protocol = "socks"
@ -121,10 +121,10 @@ local function gen_outbound(node, tag)
return result
end
if socks5_proxy_port ~= "nil" then
if socks_proxy_port ~= "nil" then
table.insert(inbounds, {
listen = "0.0.0.0",
port = socks5_proxy_port,
port = socks_proxy_port,
protocol = "socks",
settings = {auth = "noauth", udp = true, ip = "127.0.0.1"}
})

View File

@ -88,18 +88,18 @@ for i = 1, udp_node_num, 1 do
for _, key in pairs(key_table) do o:value(key, n[key]) end
end
---- Socks5 Node
local socks5_node_num = tonumber(api.uci_get_type("global_other",
"socks5_node_num", 1))
for i = 1, socks5_node_num, 1 do
---- Socks Node
local socks_node_num = tonumber(api.uci_get_type("global_other",
"socks_node_num", 1))
for i = 1, socks_node_num, 1 do
if i == 1 then
o = s:option(ListValue, "socks5_node" .. i, translate("Socks5 Node"))
-- o.description = translate("The client can use the router's Socks5 proxy.")
o = s:option(ListValue, "socks_node" .. i, translate("Socks Node"))
-- o.description = translate("The client can use the router's Socks proxy.")
o:value("nil", translate("Close"))
o:value("tcp", translate("Same as the tcp node"))
else
o = s:option(ListValue, "socks5_node" .. i,
translate("Socks5 Node") .. " " .. i)
o = s:option(ListValue, "socks_node" .. i,
translate("Socks Node") .. " " .. i)
o:value("nil", translate("Close"))
end
for _, key in pairs(key_table) do o:value(key, n[key]) end
@ -131,7 +131,7 @@ if is_installed("pdnsd") or is_installed("pdnsd-alt") or is_finded("pdnsd") then
end
if is_finded("dns2socks") then
o:value("dns2socks",
"dns2socks + " .. translate("Use Socks5 Node Resolve DNS"))
"dns2socks + " .. translate("Use Socks Node Resolve DNS"))
end
o:value("local_7913", translate("Use local port 7913 as DNS"))
o:value("nonuse", translate("No patterns are used"))
@ -146,7 +146,7 @@ if is_installed("pdnsd") or is_installed("pdnsd-alt") or is_finded("pdnsd") then
end
if is_finded("dns2socks") then
o:value("dns2socks",
"dns2socks + " .. translate("Use Socks5 Node Resolve DNS"))
"dns2socks + " .. translate("Use Socks Node Resolve DNS"))
end
o:value("8.8.4.4,8.8.8.8", "8.8.4.4, 8.8.8.8 (Google DNS)")
o:value("208.67.222.222,208.67.220.220",

View File

@ -52,6 +52,10 @@ function o.write(e, e)
"log"))
end
filter_enabled = s:option(Flag, "filter_enabled", translate("Filter keyword switch"), translate("When checked, below options can only be take effect."))
o.default = 1
o.rmempty = false
filter_keyword = s:option(DynamicList, "filter_keyword", translate("Filter keyword"))
o = s:option(Flag, "filter_keyword_discarded", translate("Filter keyword discarded"), translate("When checked, the keywords in the list are discarded. Otherwise, it is not discarded."))

View File

@ -1,6 +1,4 @@
local fs = require "nixio.fs"
local net = require"luci.model.network".init()
local ifaces = require"luci.sys".net:devices()
local api = require "luci.model.cbi.passwall.api.api"
m = Map("passwall")
@ -94,11 +92,14 @@ o:value("2", "2 " .. translate("Process"))
o:value("3", "3 " .. translate("Process"))
o:value("4", "4 " .. translate("Process"))
---- Socks5 Proxy Port
o = s:option(Value, "socks5_proxy_port", translate("Socks5 Proxy Port"))
o.datatype = "port"
o.default = 1081
o.rmempty = true
---- Socks Proxy Port
local socks_node_num = tonumber(api.uci_get_type("global_other",
"socks_node_num", 1))
for i = 1, socks_node_num, 1 do
o = s:option(Value, "socks_proxy_port" .. i, translate("Socks Proxy Port"))
o.datatype = "port"
o.default = "108" .. i
end
---- Proxy IPv6
o = s:option(Flag, "proxy_ipv6", translate("Proxy IPv6"),
@ -149,8 +150,8 @@ o:value("1")
o:value("2")
o:value("3")
---- Socks5 Node Number Option
o = s:option(ListValue, "socks5_node_num", "Socks5" .. translate("Node Number"))
---- Socks Node Number Option
o = s:option(ListValue, "socks_node_num", "Socks" .. translate("Node Number"))
o.default = "1"
o.rmempty = false
o:value("1")

View File

@ -13,7 +13,7 @@ end
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 socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
local socks_node_num = api.uci_get_type("global_other", "socks_node_num", 1)
local status_show_check_port = api.uci_get_type("global_other", "status_show_check_port", 0)
local status_show_ip111 = api.uci_get_type("global_other", "status_show_ip111", 0)
@ -142,7 +142,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
<div class="pure-u-1-4">
<div class="block pure-g">
<div class="pure-u-16-24">
<h4 id="status_socks5_node">Socks5<br /><span class="red"><%:NOT RUNNING%></span></h4>
<h4 id="status_socks_node">Socks<br /><span class="red"><%:NOT RUNNING%></span></h4>
</div>
<div class="pure-u-8-24">
<div class="img-con">
@ -327,26 +327,26 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
}
}
var socks5_node_num = <%=socks5_node_num%>;
if (socks5_node_num >= 1) {
var status_socks5_node = document.getElementById('status_socks5_node');
if (status_socks5_node) {
var text = 'Socks5<br />';
if (socks5_node_num == 1) {
if (data["socks5_node1_status"])
var socks_node_num = <%=socks_node_num%>;
if (socks_node_num >= 1) {
var status_socks_node = document.getElementById('status_socks_node');
if (status_socks_node) {
var text = 'Socks<br />';
if (socks_node_num == 1) {
if (data["socks_node1_status"])
text += '<span class="green"><%:RUNNING%></span>';
else
text += '<span class="red"><%:NOT RUNNING%></span>';
} else {
for(var i = 0; i < socks5_node_num; i++) {
for(var i = 0; i < socks_node_num; i++) {
var k = i + 1;
if (data["socks5_node" + k + "_status"])
if (data["socks_node" + k + "_status"])
text += '<span class="green"></span>';
else
text += '<span class="red"> X</span>';
}
}
status_socks5_node.innerHTML = text;
status_socks_node.innerHTML = text;
}
}

View File

@ -13,7 +13,7 @@ end
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 socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
local socks_node_num = api.uci_get_type("global_other", "socks_node_num", 1)
local status_show_check_port = api.uci_get_type("global_other", "status_show_check_port", 0)
local status_show_ip111 = api.uci_get_type("global_other", "status_show_ip111", 0)
@ -83,10 +83,10 @@ local status_show_ip111 = api.uci_get_type("global_other", "status_show_ip111",
</div>
<div class="cbi-value">
<label class="cbi-value-title">Socks5
<label class="cbi-value-title">Socks
<%:Status%>
</label>
<div class="cbi-value-field" id="_socks5_node_status">
<div class="cbi-value-field" id="_socks_node_status">
<%:Collecting data...%>
</div>
</div>
@ -237,26 +237,26 @@ local status_show_ip111 = api.uci_get_type("global_other", "status_show_ip111",
}
}
var socks5_node_status = document.getElementById('_socks5_node_status');
if (socks5_node_status) {
var socks5_node_num = <%=socks5_node_num%>;
if (socks5_node_num >= 1) {
var socks_node_status = document.getElementById('_socks_node_status');
if (socks_node_status) {
var socks_node_num = <%=socks_node_num%>;
if (socks_node_num >= 1) {
var text = '';
if (socks5_node_num == 1) {
if (json["socks5_node1_status"])
if (socks_node_num == 1) {
if (json["socks_node1_status"])
text += '<font color="green"><%:RUNNING%> ✓</font>';
else
text += '<font color="red"><%:NOT RUNNING%> X</font>';
} else {
for(var i = 0; i < socks5_node_num; i++) {
for(var i = 0; i < socks_node_num; i++) {
var k = i + 1;
if (json["socks5_node" + k + "_status"])
if (json["socks_node" + k + "_status"])
text += '<font color="green" size="3"></font>';
else
text += '<font color="red" size="3"> X</font>';
}
}
socks5_node_status.innerHTML = text;
socks_node_status.innerHTML = text;
}
}
if(haproxy_status)

View File

@ -5,7 +5,7 @@
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 socks5_node_num = api.uci_get_type("global_other", "socks5_node_num", 1)
local socks_node_num = api.uci_get_type("global_other", "socks_node_num", 1)
local compact_display_nodes = api.uci_get_type("global_other", "compact_display_nodes", 1)
-%>
@ -261,9 +261,9 @@ table td, .table .td {
<% end %>
<% end %>
<% if socks5_node_num and tonumber(socks5_node_num) >= 1 then %>
<% for i = 1, socks5_node_num, 1 do %>
<input class="cbi-button cbi-button-edit" type="button" onclick="set_node('socks5',<%=i%>)" value="Socks5_<%=i%>" />
<% if socks_node_num and tonumber(socks_node_num) >= 1 then %>
<% for i = 1, socks_node_num, 1 do %>
<input class="cbi-button cbi-button-edit" type="button" onclick="set_node('socks',<%=i%>)" value="Socks_<%=i%>" />
<% end %>
<% end %>
<input class="cbi-button cbi-button-remove" type="button" onclick="close_set_node_div()" value="<%:Close%>" />

View File

@ -115,8 +115,8 @@ msgstr "TCP节点"
msgid "UDP Node"
msgstr "UDP节点"
msgid "Socks5 Node"
msgstr "Socks5节点"
msgid "Socks Node"
msgstr "Socks节点"
msgid "Same as the tcp node"
msgstr "与TCP节点相同"
@ -130,8 +130,8 @@ msgstr "用于游戏模式或DNS解析等。"
msgid "The selected server will not use Kcptun."
msgstr "选中的服务器不会使用Kcptun。"
msgid "The client can use the router's Socks5 proxy."
msgstr "客户端可以使用路由器的Socks5代理。"
msgid "The client can use the router's Socks proxy."
msgstr "客户端可以使用路由器的Socks代理。"
msgid "DNS Mode"
msgstr "DNS模式"
@ -208,8 +208,8 @@ msgstr "自定义"
msgid "DNS Server"
msgstr "DNS服务器"
msgid "Use Socks5 Node Resolve DNS"
msgstr "使用Socks5节点解析DNS"
msgid "Use Socks Node Resolve DNS"
msgstr "使用Socks节点解析DNS"
msgid "Multi Process Option"
msgstr "多进程并发"
@ -436,8 +436,8 @@ msgstr "TCP透明代理端口"
msgid "UDP Redir Port"
msgstr "UDP透明代理端口"
msgid "Socks5 Proxy Port"
msgstr "Socks5代理端口"
msgid "Socks Proxy Port"
msgstr "Socks代理端口"
msgid "Kcptun Port"
msgstr "Kcptun端口"
@ -625,6 +625,12 @@ msgstr "手动订阅"
msgid "Delete All Subscribe Node"
msgstr "删除所有订阅节点"
msgid "Filter keyword switch"
msgstr "过滤关键字开关"
msgid "When checked, below options can only be take effect."
msgstr "当勾选时,下面的选项才生效。"
msgid "Filter keyword"
msgstr "过滤关键字"

View File

@ -3,7 +3,7 @@ config global
option enabled '0'
option tcp_node1 'nil'
option udp_node1 'nil'
option socks5_node1 'nil'
option socks_node1 'nil'
option dns_mode 'pdnsd'
option up_china_dns 'default'
option dns_forward '8.8.4.4'
@ -18,7 +18,7 @@ config global_haproxy
config global_delay
option auto_on '0'
option start_daemon '1'
option start_daemon '0'
option start_delay '1'
config global_forwarding
@ -27,7 +27,9 @@ config global_forwarding
option udp_no_redir_ports '80,443'
option tcp_redir_ports '22,25,53,143,465,587,993,995,80,443'
option udp_redir_ports '1:65535'
option socks5_proxy_port '1081'
option socks_proxy_port1 '1081'
option socks_proxy_port2 '1082'
option socks_proxy_port3 '1083'
option proxy_ipv6 '0'
config global_other
@ -35,7 +37,7 @@ config global_other
option auto_ping '1'
option tcp_node_num '1'
option udp_node_num '1'
option socks5_node_num '1'
option socks_node_num '1'
option status_use_big_icon '1'
option status_show_check_port '0'
option status_show_ip111 '0'
@ -60,6 +62,7 @@ config global_app
config global_subscribe
option subscribe_proxy '0'
option auto_update_subscribe '0'
option filter_enabled '1'
option filter_keyword_discarded '1'
list filter_keyword '过期时间'
list filter_keyword '剩余流量'

View File

@ -13,8 +13,7 @@ uci -q batch <<-EOF >/dev/null
commit firewall
EOF
echo "" > /etc/dnsmasq.conf
killall -q -9 kcptun haproxy shadowsocks-libev shadowsocksr-libev
/etc/init.d/haproxy disable && /etc/init.d/haproxy stop
rm -f /tmp/luci-indexcache
rm -rf /tmp/luci-*cache
exit 0

View File

@ -9,7 +9,6 @@ TMP_PATH=/var/etc/$CONFIG
TMP_BIN_PATH=$TMP_PATH/bin
TMP_ID_PATH=$TMP_PATH/id
TMP_PORT_PATH=$TMP_PATH/port
LOCK_FILE=/var/lock/$CONFIG.lock
LOG_FILE=/var/log/$CONFIG.log
APP_PATH=/usr/share/$CONFIG
RULES_PATH=/usr/share/${CONFIG}/rules
@ -105,7 +104,7 @@ check_port_exists() {
get_new_port() {
port=$1
[ "$port" == "auto" ] && port=$SOCKS5_PROXY_PORT3
[ "$port" == "auto" ] && port=$SOCKS_REDIR_PORT3
protocol=$2
result=$(check_port_exists $port $protocol)
if [ "$result" = 1 ]; then
@ -157,19 +156,19 @@ UDP_REDIR_PORT1=$(config_t_get global_forwarding udp_redir_port 1051)
UDP_REDIR_PORT2=$(expr $UDP_REDIR_PORT1 + 1)
UDP_REDIR_PORT3=$(expr $UDP_REDIR_PORT2 + 1)
SOCKS5_NODE_NUM=$(config_t_get global_other socks5_node_num 1)
for i in $(seq 1 $SOCKS5_NODE_NUM); do
eval SOCKS5_NODE$i=$(config_t_get global socks5_node$i nil)
SOCKS_NODE_NUM=$(config_t_get global_other socks_node_num 1)
for i in $(seq 1 $SOCKS_NODE_NUM); do
eval SOCKS_NODE$i=$(config_t_get global socks_node$i nil)
done
SOCKS5_PROXY_PORT1=$(config_t_get global_forwarding socks5_proxy_port 1081)
SOCKS5_PROXY_PORT2=$(expr $SOCKS5_PROXY_PORT1 + 1)
SOCKS5_PROXY_PORT3=$(expr $SOCKS5_PROXY_PORT2 + 1)
SOCKS_REDIR_PORT1=$(config_t_get global_forwarding socks_proxy_port1 1081)
SOCKS_REDIR_PORT2=$(config_t_get global_forwarding socks_proxy_port2 1082)
SOCKS_REDIR_PORT3=$(config_t_get global_forwarding socks_proxy_port3 1083)
[ "$UDP_NODE1" == "tcp" ] && UDP_NODE1=$TCP_NODE1
[ "$SOCKS5_NODE1" == "tcp" ] && SOCKS5_NODE1=$TCP_NODE1
[ "$SOCKS_NODE1" == "tcp" ] && SOCKS_NODE1=$TCP_NODE1
# Dynamic variables (Used to record)
# TCP_NODE1_IP="" UDP_NODE1_IP="" SOCKS5_NODE1_IP="" TCP_NODE1_PORT="" UDP_NODE1_PORT="" SOCKS5_NODE1_PORT="" TCP_NODE1_TYPE="" UDP_NODE1_TYPE="" SOCKS5_NODE1_TYPE=""
# TCP_NODE1_IP="" UDP_NODE1_IP="" SOCKS_NODE1_IP="" TCP_NODE1_PORT="" UDP_NODE1_PORT="" SOCKS_NODE1_PORT="" TCP_NODE1_TYPE="" UDP_NODE1_TYPE="" SOCKS_NODE1_TYPE=""
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')
@ -185,14 +184,14 @@ LOCALHOST_UDP_PROXY_MODE=$(config_t_get global localhost_udp_proxy_mode default)
load_config() {
[ "$ENABLED" != 1 ] && return 1
[ "$TCP_NODE1" == "nil" -a "$UDP_NODE1" == "nil" -a "$SOCKS5_NODE1" == "nil" ] && {
[ "$TCP_NODE1" == "nil" -a "$UDP_NODE1" == "nil" -a "$SOCKS_NODE1" == "nil" ] && {
echolog "没有选择节点!"
return 1
}
DNS_MODE=$(config_t_get global dns_mode pdnsd)
DNS_FORWARD=$(config_t_get global dns_forward 8.8.4.4)
use_tcp_node_resolve_dns=$(config_t_get global use_tcp_node_resolve_dns 0)
use_tcp_node_resolve_dns=0
use_udp_node_resolve_dns=0
process=1
if [ "$(config_t_get global_forwarding process 0)" = "0" ]; then
@ -287,10 +286,10 @@ gen_start_config() {
[ "$bind" == "0.0.0.0" ] && echolog "${redir_type}_${5}节点:$remarks,节点:${server_host}:${port},监听端口:$local_port"
}
if [ "$redir_type" == "SOCKS5" ]; then
eval SOCKS5_NODE${5}_PORT=$port
if [ "$redir_type" == "SOCKS" ]; then
eval SOCKS_NODE${5}_PORT=$port
if [ "$type" == "socks5" ]; then
echolog "Socks5节点不能使用Socks5代理节点!"
echolog "Socks节点不能使用Socks代理节点"
elif [ "$type" == "v2ray" ]; then
lua $API_GEN_V2RAY $node nil nil $local_port >$config_file
ln_start_bin $(config_t_get global_app v2ray_file $(find_bin v2ray))/v2ray v2ray_socks_$5 "-config=$config_file"
@ -349,10 +348,10 @@ gen_start_config() {
lua $API_GEN_V2RAY_SHUNT $node udp $local_port nil >$config_file
ln_start_bin $(config_t_get global_app v2ray_file $(find_bin v2ray))/v2ray v2ray_udp_$5 "-config=$config_file"
elif [ "$type" == "trojan" ]; then
SOCKS5_PROXY_PORT4=$(expr $SOCKS5_PROXY_PORT3 + 1)
local_port=$(get_new_port $SOCKS5_PROXY_PORT4 tcp)
socks5_port=$local_port
lua $API_GEN_TROJAN $node client "127.0.0.1" $socks5_port >$config_file
SOCKS_REDIR_PORT4=$(expr $SOCKS_REDIR_PORT3 + 1)
local_port=$(get_new_port $SOCKS_REDIR_PORT4 tcp)
socks_port=$local_port
lua $API_GEN_TROJAN $node client "127.0.0.1" $socks_port >$config_file
ln_start_bin $(find_bin trojan) trojan_udp_$5 "-c $config_file"
local node_address=$(config_n_get $node address)
@ -360,7 +359,7 @@ gen_start_config() {
local server_username=$(config_n_get $node username)
local server_password=$(config_n_get $node password)
eval port=\$UDP_REDIR_PORT$5
ln_start_bin $(find_bin ipt2socks) ipt2socks_udp_$5 "-4 -U -l $port -b 0.0.0.0 -s 127.0.0.1 -p $socks5_port -R"
ln_start_bin $(find_bin ipt2socks) ipt2socks_udp_$5 "-4 -U -l $port -b 0.0.0.0 -s 127.0.0.1 -p $socks_port -R"
elif [ "$type" == "brook" ]; then
local protocol=$(config_n_get $node brook_protocol client)
if [ "$protocol" == "wsclient" ]; then
@ -454,8 +453,8 @@ gen_start_config() {
local brook_tls=$(config_n_get $node brook_tls 0)
if [ "$protocol" == "wsclient" ]; then
[ "$brook_tls" == "1" ] && server_ip="wss://${server_ip}" || server_ip="ws://${server_ip}"
socks5_port=$(get_new_port $(expr $SOCKS5_PROXY_PORT3 + 3) tcp)
ln_start_bin $(config_t_get global_app brook_file $(find_bin brook)) brook_tcp_$5 "wsclient -l 127.0.0.1:$socks5_port -i 127.0.0.1 -s $server_ip:$port -p $(config_n_get $node password)"
socks_port=$(get_new_port $(expr $SOCKS_REDIR_PORT3 + 3) tcp)
ln_start_bin $(config_t_get global_app brook_file $(find_bin brook)) brook_tcp_$5 "wsclient -l 127.0.0.1:$socks_port -i 127.0.0.1 -s $server_ip:$port -p $(config_n_get $node password)"
eval port=\$TCP_REDIR_PORT$5
ln_start_bin $(find_bin ipt2socks) ipt2socks_tcp_$5 "-4 -T -l $port -b 0.0.0.0 -s 127.0.0.1 -p $socks5_port -R"
echolog "Brook的WebSocket不支持透明代理将使用ipt2socks转换透明代理"
@ -473,12 +472,12 @@ gen_start_config() {
}
node_switch() {
local i=$4
local node=$5
[ -n "$1" -a -n "$2" -a "$2" != "nil" -a -n "$3" -a -n "$4" -a -n "$5" ] && {
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
eval current_port=\$${1}_${2}_PORT$i
eval current_port=\$${1}_REDIR_PORT${i}
local port=$(cat $TMP_PORT_PATH/${1}_${i})
gen_start_config $node $port $1 $config_file $i
echo $node > $TMP_ID_PATH/${1}_${i}
@ -496,9 +495,9 @@ start_redir() {
[ "$node" != "nil" ] && {
TYPE=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
local config_file=$TMP_PATH/${1}_${i}.json
eval current_port=\$${1}_${2}_PORT$i
local port=$(echo $(get_new_port $current_port $3))
eval ${1}_${2}$i=$port
eval current_port=\$${1}_REDIR_PORT$i
local port=$(echo $(get_new_port $current_port $2))
eval ${1}_REDIR${i}=$port
gen_start_config $node $port $1 $config_file $i
#eval ip=\$${1}_NODE${i}_IP
echo $node > $TMP_ID_PATH/${1}_${i}
@ -581,21 +580,25 @@ start_dns() {
echolog "DNS使用本机7913端口DNS服务器解析域名..."
;;
dns2socks)
if [ -n "$SOCKS5_NODE1" -a "$SOCKS5_NODE1" != "nil" ]; then
if [ -n "$SOCKS_NODE1" -a "$SOCKS_NODE1" != "nil" ]; then
DNS2SOCKS_FORWARD=$(config_t_get global dns2socks_forward 8.8.4.4)
ln_start_bin $(find_bin dns2socks) dns2socks "127.0.0.1:$SOCKS5_PROXY_PORT1 $DNS2SOCKS_FORWARD 127.0.0.1:$DNS_PORT"
ln_start_bin $(find_bin dns2socks) dns2socks "127.0.0.1:$SOCKS_REDIR_PORT1 $DNS2SOCKS_FORWARD 127.0.0.1:$DNS_PORT"
echolog "DNSdns2socks..."
else
echolog "DNSdns2socks模式需要使用Socks5代理节点,请开启!"
echolog "DNSdns2socks模式需要使用Socks代理节点,请开启!"
force_stop
fi
;;
pdnsd)
use_tcp_node_resolve_dns=1
gen_pdnsd_config $DNS_PORT 4096
DNS_FORWARD=$(echo $DNS_FORWARD | sed 's/,/ /g')
ln_start_bin $(find_bin pdnsd) pdnsd "--daemon -c $pdnsd_dir/pdnsd.conf -d"
echolog "DNSpdnsd..."
if [ -z "$TCP_NODE1" -o "$TCP_NODE1" == "nil" ]; then
echolog "DNSpdnsd 模式需要启用TCP节点"
force_stop
else
gen_pdnsd_config $DNS_PORT 2048
DNS_FORWARD=$(echo $DNS_FORWARD | sed 's/,/ /g')
ln_start_bin $(find_bin pdnsd) pdnsd "--daemon -c $pdnsd_dir/pdnsd.conf -d"
echolog "DNSpdnsd + 使用TCP节点解析DNS$DNS_FORWARD..."
fi
;;
chinadns-ng)
other_port=$(expr $DNS_PORT + 1)
@ -616,7 +619,6 @@ start_dns() {
echolog "DNSChinaDNS-NG + pdnsd 模式需要启用TCP节点"
force_stop
else
use_tcp_node_resolve_dns=1
gen_pdnsd_config $other_port 0
DNS_FORWARD=$(echo $DNS_FORWARD | sed 's/,/ /g')
ln_start_bin $(find_bin pdnsd) pdnsd "--daemon -c $pdnsd_dir/pdnsd.conf -d"
@ -624,13 +626,13 @@ start_dns() {
echolog "DNSChinaDNS-NG + pdnsd($DNS_FORWARD)国内DNS$UP_CHINA_DNS"
fi
elif [ "$up_trust_chinadns_ng_dns" == "dns2socks" ]; then
if [ -n "$SOCKS5_NODE1" -a "$SOCKS5_NODE1" != "nil" ]; then
if [ -n "$SOCKS_NODE1" -a "$SOCKS_NODE1" != "nil" ]; then
DNS2SOCKS_FORWARD=$(config_t_get global dns2socks_forward 8.8.4.4)
ln_start_bin $(find_bin dns2socks) dns2socks "127.0.0.1:$SOCKS5_PROXY_PORT1 $DNS2SOCKS_FORWARD 127.0.0.1:$other_port"
ln_start_bin $(find_bin dns2socks) dns2socks "127.0.0.1:$SOCKS_REDIR_PORT1 $DNS2SOCKS_FORWARD 127.0.0.1:$other_port"
ln_start_bin $(find_bin chinadns-ng) chinadns-ng "-l $DNS_PORT -c $UP_CHINA_DNS -t 127.0.0.1#$other_port $gfwlist_param $chnlist_param"
echolog "DNSChinaDNS-NG + dns2socks($DNS2SOCKS_FORWARD)国内DNS$UP_CHINA_DNS"
else
echolog "DNSdns2socks模式需要使用Socks5代理节点,请开启!"
echolog "DNSdns2socks模式需要使用Socks代理节点,请开启!"
force_stop
fi
else
@ -747,51 +749,27 @@ gen_pdnsd_config() {
EOF
[ "$use_tcp_node_resolve_dns" == 1 ] && {
cat >> $pdnsd_dir/pdnsd.conf <<-EOF
server {
label = "node";
ip = $DNS_FORWARD;
edns_query = on;
port = 53;
timeout = 4;
interval = 10m;
uptest = none;
purge_cache = off;
}
EOF
}
cat >> $pdnsd_dir/pdnsd.conf <<-EOF
server {
label = "opendns";
ip = 208.67.222.222, 208.67.220.220;
label = "node";
ip = $DNS_FORWARD;
edns_query = on;
port = 443;
timeout = 3;
interval = 10m;
uptest = none;
purge_cache = off;
}
server {
label = "opendns";
ip = 208.67.222.222, 208.67.220.220;
edns_query = on;
port = 5353;
timeout = 3;
port = 53;
timeout = 4;
interval = 10m;
uptest = none;
purge_cache = off;
}
EOF
use_tcp_node_resolve_dns=1
}
stop_dnsmasq() {
del_dnsmasq() {
rm -rf /var/dnsmasq.d/dnsmasq-$CONFIG.conf
rm -rf $DNSMASQ_PATH/dnsmasq-$CONFIG.conf
rm -rf $TMP_DNSMASQ_PATH
/etc/init.d/dnsmasq restart >/dev/null 2>&1
}
start_haproxy() {
@ -920,7 +898,7 @@ kill_all() {
}
force_stop() {
rm -f "$LOCK_FILE"
stop
exit 0
}
@ -939,33 +917,19 @@ boot() {
start() {
! load_config && return 1
[ -f "$LOCK_FILE" ] && return 3
touch "$LOCK_FILE"
start_haproxy
start_redir SOCKS5 PROXY tcp
start_redir TCP REDIR tcp
start_redir UDP REDIR udp
start_redir SOCKS tcp
start_redir TCP tcp
start_redir UDP udp
start_dns
add_dnsmasq
source $APP_PATH/iptables.sh start
/etc/init.d/dnsmasq restart >/dev/null 2>&1
start_crontab
echolog "运行完成!\n"
rm -f "$LOCK_FILE"
return 0
}
stop() {
failcount=1
while [ "$failcount" -le 10 ]; do
if [ -f "$LOCK_FILE" ]; then
let "failcount++"
sleep 1s
[ "$failcount" -ge 10 ] && rm -f "$LOCK_FILE"
else
break
fi
done
clean_log
source $APP_PATH/iptables.sh stop
kill_all v2ray-plugin obfs-local
@ -974,8 +938,9 @@ stop() {
ps -w | grep -v "grep" | grep -E "$TMP_PATH" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
ps -w | grep -v "grep" | grep "sleep 1m" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
rm -rf $TMP_DNSMASQ_PATH $TMP_PATH
stop_dnsmasq
stop_crontab
del_dnsmasq
/etc/init.d/dnsmasq restart >/dev/null 2>&1
echolog "清空并关闭相关程序和缓存完成。"
}
@ -987,7 +952,7 @@ gen_start_config)
gen_start_config $2 $3 $4 $5 $6 $7
;;
node_switch)
node_switch $2 $3 $4 $5 $6
node_switch $2 $3 $4 $5
;;
stop)
[ -n "$2" -a "$2" == "force" ] && force_stop
@ -999,4 +964,4 @@ start)
boot)
boot
;;
esac
esac

View File

@ -3,7 +3,7 @@ config global
option enabled '0'
option tcp_node1 'nil'
option udp_node1 'nil'
option socks5_node1 'nil'
option socks_node1 'nil'
option dns_mode 'pdnsd'
option up_china_dns 'default'
option dns_forward '8.8.4.4'
@ -27,7 +27,9 @@ config global_forwarding
option udp_no_redir_ports '80,443'
option tcp_redir_ports '22,25,53,143,465,587,993,995,80,443'
option udp_redir_ports '1:65535'
option socks5_proxy_port '1081'
option socks_proxy_port1 '1081'
option socks_proxy_port2 '1082'
option socks_proxy_port3 '1083'
option proxy_ipv6 '0'
config global_other
@ -35,7 +37,7 @@ config global_other
option auto_ping '1'
option tcp_node_num '1'
option udp_node_num '1'
option socks5_node_num '1'
option socks_node_num '1'
option status_use_big_icon '1'
option status_show_check_port '0'
option status_show_ip111 '0'
@ -60,6 +62,7 @@ config global_app
config global_subscribe
option subscribe_proxy '0'
option auto_update_subscribe '0'
option filter_enabled '1'
option filter_keyword_discarded '1'
list filter_keyword '过期时间'
list filter_keyword '剩余流量'

View File

@ -267,8 +267,8 @@ add_firewall_rule() {
ip rule add fwmark 1 lookup 100
ip route add local 0.0.0.0/0 dev lo table 100
for k in $(seq 1 $SOCKS5_NODE_NUM); do
eval node=\$SOCKS5_NODE$k
for k in $(seq 1 $SOCKS_NODE_NUM); do
eval node=\$SOCKS_NODE$k
[ "$node" != "nil" ] && filter_node $node
done

View File

@ -36,9 +36,9 @@ do
eval UDP_NODE$i=$(config_t_get global udp_node$i nil)
done
SOCKS5_NODE_NUM=$(config_t_get global_other socks5_node_num 1)
for i in $(seq 1 $SOCKS5_NODE_NUM); do
eval SOCKS5_NODE$i=$(config_t_get global socks5_node$i nil)
SOCKS_NODE_NUM=$(config_t_get global_other socks_node_num 1)
for i in $(seq 1 $SOCKS_NODE_NUM); do
eval SOCKS_NODE$i=$(config_t_get global socks_node$i nil)
done
dns_mode=$(config_t_get global dns_mode)
@ -78,11 +78,11 @@ do
fi
done
#socks5
for i in $(seq 1 $SOCKS5_NODE_NUM); do
eval tmp_node=\$SOCKS5_NODE$i
#socks
for i in $(seq 1 $SOCKS_NODE_NUM); do
eval tmp_node=\$SOCKS_NODE$i
if [ "$tmp_node" != "nil" ]; then
icount=$(ps -w | grep -v grep | grep -v kcptun | grep $RUN_BIN_PATH | grep -i -E "SOCKS_${i}|SOCKS5_${i}" | wc -l)
icount=$(ps -w | grep -v grep | grep -v kcptun | grep $RUN_BIN_PATH | grep -i "SOCKS_${i}" | wc -l)
if [ $icount = 0 ]; then
/etc/init.d/passwall restart
exit 0

View File

@ -68,7 +68,7 @@ do
end
import_config("tcp")
import_config("udp")
import_config("socks5")
import_config("socks")
local tcp_node1_table = ucic2:get(application, "@auto_switch[0]", "tcp_node1")
if tcp_node1_table then
@ -213,24 +213,27 @@ do
end
-- 判断是否过滤节点关键字
local filter_keyword_enabled = ucic2:get(application, "@global_subscribe[0]", "filter_enabled")
local filter_keyword_table = ucic2:get(application, "@global_subscribe[0]", "filter_keyword")
local filter_keyword_discarded = ucic2:get(application, "@global_subscribe[0]", "filter_keyword_discarded")
local function is_filter_keyword(value)
if filter_keyword_table then
if filter_keyword_discarded and filter_keyword_discarded == "1" then
for k,v in ipairs(filter_keyword_table) do
if value:find(v) then
return true
if filter_keyword_enabled and filter_keyword_enabled == "1" then
if filter_keyword_table then
if filter_keyword_discarded and filter_keyword_discarded == "1" then
for k,v in ipairs(filter_keyword_table) do
if value:find(v) then
return true
end
end
end
else
local result = true
for k,v in ipairs(filter_keyword_table) do
if value:find(v) then
result = false
else
local result = true
for k,v in ipairs(filter_keyword_table) do
if value:find(v) then
result = false
end
end
return result
end
return result
end
end
return false
@ -494,7 +497,7 @@ local function truncate_nodes()
end
clear("tcp")
clear("udp")
clear("socks5")
clear("socks")
ucic2:foreach(application, uciType, function(node)
if (node.is_sub or node.hashkey) and node.add_mode ~= '导入' then

View File

@ -45,8 +45,8 @@ test_proxy() {
test_auto_switch() {
local type=$1
local index=$4
local b_tcp_nodes=$5
local index=$3
local b_tcp_nodes=$4
local now_node
if [ -f "/var/etc/$CONFIG/id/${type}_${index}" ]; then
now_node=$(cat /var/etc/$CONFIG/id/${type}_${index})
@ -55,9 +55,12 @@ test_auto_switch() {
fi
status=$(test_proxy)
if [ "$status" == 2 ]; then
if [ "$status" == 0 ]; then
#echolog "自动切换检测:${type}_${index}节点正常。"
return 0
elif [ "$status" == 2 ]; then
echolog "自动切换检测:无法连接到网络,请检查网络是否正常!"
return 1
return 2
elif [ "$status" == 1 ]; then
echolog "自动切换检测:${type}_${index}节点异常,开始切换节点!"
local new_node
@ -68,7 +71,7 @@ test_auto_switch() {
new_node=$(echo $b_tcp_nodes | awk -F ' ' '{print $1}')
else
# 如果存在,设置下一个备用节点为新的节点
local count=$(expr $(echo $b_tcp_nodes | grep -o ' ' | wc -l) + 1)
#local count=$(expr $(echo $b_tcp_nodes | grep -o ' ' | wc -l) + 1)
local next_node=$(echo $b_tcp_nodes | awk -F "$now_node" '{print $2}' | awk -F " " '{print $1}')
if [ -z "$next_node" ]; then
new_node=$(echo $b_tcp_nodes | awk -F ' ' '{print $1}')
@ -76,12 +79,18 @@ test_auto_switch() {
new_node=$next_node
fi
fi
/usr/share/passwall/app.sh node_switch $type $2 $3 $index $new_node
echolog "自动切换检测:${type}_${index}节点切换完毕!"
return 0
elif [ "$status" == 0 ]; then
#echolog "自动切换检测:${type}_${index}节点正常。"
return 0
/usr/share/passwall/app.sh node_switch $type $2 $index $new_node
sleep 10s
# 切换节点后等待10秒后再检测一次如果还是不通继续切直到可用为止
status2=$(test_proxy)
if [ "$status2" -eq 0 ]; then
echolog "自动切换检测:${type}_${index}节点切换完毕!"
return 0
elif [ "$status2" -eq 1 ]; then
test_auto_switch $1 $2 $3 "$4"
elif [ "$status2" -eq 2 ]; then
return 2
fi
fi
}
@ -105,7 +114,7 @@ start() {
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 REDIR tcp $i "$tmp"
test_auto_switch TCP tcp $i "$tmp"
}
done
delay=$(config_t_get auto_switch testing_time 1)