luci-app-passwall: sync with upstream source

This commit is contained in:
CN_SZTL 2020-03-25 19:16:51 +08:00
parent fe56f7cdb3
commit a213808335
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
12 changed files with 116 additions and 69 deletions

View File

@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=3.6
PKG_RELEASE:=29
PKG_DATE:=20200323
PKG_RELEASE:=31
PKG_DATE:=20200325
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

View File

@ -7,7 +7,6 @@ local socks5_proxy_port = arg[4]
local node = ucursor:get_all("passwall", node_section)
local inbounds = {}
local outbounds = {}
local network = proto
local routing = nil
local function gen_outbound(node)
@ -22,7 +21,7 @@ local function gen_outbound(node)
tonumber(node.v2ray_mux_concurrency) or 8
},
-- 底层传输配置
streamSettings = {
streamSettings = (node.v2ray_protocol == "vmess") and {
network = node.v2ray_transport,
security = node.v2ray_stream_security,
tlsSettings = (node.v2ray_stream_security == "tls") and {
@ -67,9 +66,9 @@ local function gen_outbound(node)
key = node.v2ray_quic_key,
header = {type = node.v2ray_quic_guise}
} or nil
},
} or nil,
settings = {
vnext = {
vnext = (node.v2ray_protocol == "vmess") and {
{
address = node.address,
port = tonumber(node.port),
@ -82,7 +81,22 @@ local function gen_outbound(node)
}
}
}
}
} or nil,
servers = (node.v2ray_protocol == "http" or node.v2ray_protocol == "socks" or node.v2ray_protocol == "shadowsocks") and {
{
address = node.address,
port = tonumber(node.port),
method = node.v2ray_ss_encrypt_method,
password = node.password or "",
ota = (node.v2ray_ss_ota == '1') and true or false,
users = (node.username and node.password) and {
{
user = node.username or "",
pass = node.password or ""
}
} or nil
}
} or nil
}
}
end
@ -125,25 +139,9 @@ if redir_port ~= "nil" then
end
end
if node.type == "V2ray_balancing" and node.v2ray_balancing_node then
local nodes = node.v2ray_balancing_node
local length = #nodes
for i = 1, length do
local node = ucursor:get_all("passwall", nodes[i])
local outbound = gen_outbound(node)
if outbound then table.insert(outbounds, outbound) end
end
routing = {
domainStrategy = "IPOnDemand",
balancers = {{tag = "balancer", selector = nodes}},
rules = {
{type = "field", network = "tcp,udp", balancerTag = "balancer"}
}
}
else
local outbound = gen_outbound(node)
if outbound then table.insert(outbounds, outbound) end
end
local outbound = gen_outbound(node)
if outbound then table.insert(outbounds, outbound) end
-- 额外传出连接
table.insert(outbounds,
{protocol = "freedom", tag = "direct", settings = {keep = ""}})

View File

@ -44,7 +44,7 @@ local function gen_outbound(node)
tonumber(node.v2ray_mux_concurrency) or 8
},
-- 底层传输配置
streamSettings = {
streamSettings = (node.v2ray_protocol == "vmess") and {
network = node.v2ray_transport,
security = node.v2ray_stream_security,
tlsSettings = (node.v2ray_stream_security == "tls") and {
@ -90,7 +90,7 @@ local function gen_outbound(node)
key = node.v2ray_quic_key,
header = {type = node.v2ray_quic_guise}
} or nil
},
} or nil,
settings = {
vnext = (node.v2ray_protocol == "vmess") and {
{
@ -114,16 +114,6 @@ local function gen_outbound(node)
{{user = node.username, pass = node.password}} or
nil
}
} or (node.v2ray_protocol == "ss") and {
{
email = nil,
address = node.address,
method = nil,
ota = nil,
password = node.password or nil,
port = tonumber(node.port),
level = 1
}
} or nil
}
}

View File

@ -44,7 +44,7 @@ local function gen_outbound(node, tag)
tonumber(node.v2ray_mux_concurrency) or 8
},
-- 底层传输配置
streamSettings = {
streamSettings = (node.v2ray_protocol == "vmess") and {
network = node.v2ray_transport,
security = node.v2ray_stream_security,
tlsSettings = (node.v2ray_stream_security == "tls") and {
@ -90,7 +90,7 @@ local function gen_outbound(node, tag)
key = node.v2ray_quic_key,
header = {type = node.v2ray_quic_guise}
} or nil
},
} or nil,
settings = {
vnext = (node.v2ray_protocol == "vmess") and {
{
@ -114,16 +114,6 @@ local function gen_outbound(node, tag)
{{user = node.username, pass = node.password}} or
nil
}
} or (node.v2ray_protocol == "ss") and {
{
email = nil,
address = node.address,
method = nil,
ota = nil,
password = node.password or nil,
port = tonumber(node.port),
level = 1
}
} or nil
}
}

View File

@ -76,6 +76,7 @@ o.rmempty = false
---- Haproxy Port
o = s:option(Value, "haproxy_port", translate("Haproxy Port"))
o.default = "1181"
o.rmempty = false
---- Node Weight

View File

@ -44,6 +44,10 @@ local ssr_obfs_list = {
"tls1.0_session_auth", "tls1.2_ticket_auth"
}
local v2ray_ss_encrypt_method_list = {
"aes-128-cfb", "aes-256-cfb", "aes-128-gcm", "aes-256-gcm", "chacha20", "chacha20-ietf", "chacha20-poly1305", "chacha20-ietf-poly1305"
}
local v2ray_security_list = {"none", "auto", "aes-128-gcm", "chacha20-poly1305"}
local v2ray_header_type_list = {
@ -83,6 +87,9 @@ end
v2ray_protocol = s:option(ListValue, "v2ray_protocol",
translate("V2ray Protocol"))
v2ray_protocol:value("vmess", translate("Vmess"))
v2ray_protocol:value("http", translate("HTTP"))
v2ray_protocol:value("socks", translate("Socks"))
v2ray_protocol:value("shadowsocks", translate("Shadowsocks"))
v2ray_protocol:depends("type", "V2ray")
brook_protocol = s:option(ListValue, "brook_protocol",
@ -162,6 +169,8 @@ port:depends("type", "Trojan")
username = s:option(Value, "username", translate("Username"))
username:depends("type", "Socks5")
username:depends("v2ray_protocol", "http")
username:depends("v2ray_protocol", "socks")
password = s:option(Value, "password", translate("Password"))
password.password = true
@ -170,6 +179,9 @@ password:depends("type", "SS")
password:depends("type", "SSR")
password:depends("type", "Brook")
password:depends("type", "Trojan")
password:depends("v2ray_protocol", "http")
password:depends("v2ray_protocol", "socks")
password:depends("v2ray_protocol", "shadowsocks")
ss_encrypt_method = s:option(ListValue, "ss_encrypt_method",
translate("Encrypt Method"))
@ -184,7 +196,17 @@ ssr_encrypt_method:depends("type", "SSR")
v2ray_security = s:option(ListValue, "v2ray_security",
translate("Encrypt Method"))
for a, t in ipairs(v2ray_security_list) do v2ray_security:value(t) end
v2ray_security:depends("type", "V2ray")
v2ray_security:depends("v2ray_protocol", "vmess")
v2ray_ss_encrypt_method = s:option(ListValue, "v2ray_ss_encrypt_method",
translate("Encrypt Method"))
for a, t in ipairs(v2ray_ss_encrypt_method_list) do v2ray_ss_encrypt_method:value(t) end
v2ray_ss_encrypt_method:depends("v2ray_protocol", "shadowsocks")
v2ray_ss_ota = s:option(Flag, "v2ray_ss_ota", translate("OTA"), translate(
"When OTA is enabled, V2Ray will reject connections that are not OTA enabled. This option is invalid when using AEAD encryption."))
v2ray_ss_ota.default = "0"
v2ray_ss_ota:depends("v2ray_protocol", "shadowsocks")
protocol = s:option(ListValue, "protocol", translate("Protocol"))
for a, t in ipairs(ssr_protocol_list) do protocol:value(t) end
@ -250,16 +272,16 @@ kcp_opts:depends("use_kcp", "1")
v2ray_VMess_id = s:option(Value, "v2ray_VMess_id", translate("ID"))
v2ray_VMess_id.password = true
v2ray_VMess_id:depends("type", "V2ray")
v2ray_VMess_id:depends("v2ray_protocol", "vmess")
v2ray_VMess_alterId = s:option(Value, "v2ray_VMess_alterId",
translate("Alter ID"))
v2ray_VMess_alterId:depends("type", "V2ray")
v2ray_VMess_alterId:depends("v2ray_protocol", "vmess")
v2ray_VMess_level =
s:option(Value, "v2ray_VMess_level", translate("User Level"))
v2ray_VMess_level.default = 1
v2ray_VMess_level:depends("type", "V2ray")
v2ray_VMess_level:depends("v2ray_protocol", "vmess")
v2ray_stream_security = s:option(ListValue, "v2ray_stream_security",
translate("Transport Layer Encryption"),
@ -267,7 +289,9 @@ v2ray_stream_security = s:option(ListValue, "v2ray_stream_security",
'Whether or not transport layer encryption is enabled, the supported options are "none" for unencrypted (default) and "TLS" for using TLS.'))
v2ray_stream_security:value("none", "none")
v2ray_stream_security:value("tls", "tls")
v2ray_stream_security:depends("type", "V2ray")
v2ray_stream_security:depends("v2ray_protocol", "vmess")
v2ray_stream_security:depends("v2ray_protocol", "http")
v2ray_stream_security:depends("v2ray_protocol", "shadowsocks")
-- [[ TLS部分 ]] --
tls_serverName = s:option(Value, "tls_serverName", translate("Domain"))
@ -288,7 +312,14 @@ v2ray_transport:value("ws", "WebSocket")
v2ray_transport:value("h2", "HTTP/2")
v2ray_transport:value("ds", "DomainSocket")
v2ray_transport:value("quic", "QUIC")
v2ray_transport:depends("type", "V2ray")
v2ray_transport:depends("v2ray_protocol", "vmess")
--[[
v2ray_ss_transport = s:option(ListValue, "v2ray_ss_transport", translate("Transport"))
v2ray_ss_transport:value("ws", "WebSocket")
v2ray_ss_transport:value("h2", "HTTP/2")
v2ray_ss_transport:depends("v2ray_protocol", "shadowsocks")
]]--
-- [[ TCP部分 ]]--
@ -347,17 +378,21 @@ v2ray_mkcp_writeBufferSize:depends("v2ray_transport", "mkcp")
v2ray_ws_host = s:option(Value, "v2ray_ws_host", translate("WebSocket Host"))
v2ray_ws_host:depends("v2ray_transport", "ws")
v2ray_ws_host:depends("v2ray_ss_transport", "ws")
v2ray_ws_path = s:option(Value, "v2ray_ws_path", translate("WebSocket Path"))
v2ray_ws_path:depends("v2ray_transport", "ws")
v2ray_ws_path:depends("v2ray_ss_transport", "ws")
-- [[ HTTP/2部分 ]]--
v2ray_h2_host = s:option(DynamicList, "v2ray_h2_host", translate("HTTP/2 Host"))
v2ray_h2_host:depends("v2ray_transport", "h2")
v2ray_h2_host:depends("v2ray_ss_transport", "h2")
v2ray_h2_path = s:option(Value, "v2ray_h2_path", translate("HTTP/2 Path"))
v2ray_h2_path:depends("v2ray_transport", "h2")
v2ray_h2_path:depends("v2ray_ss_transport", "h2")
-- [[ DomainSocket部分 ]]--
@ -392,7 +427,8 @@ v2ray_mux_concurrency = s:option(Value, "v2ray_mux_concurrency",
v2ray_mux_concurrency.default = 8
v2ray_mux_concurrency:depends("v2ray_mux", "1")
-- [[ 当作为TCP节点时是否同时开启socks代理 ]]
-- [[ 当作为TCP节点时是否同时开启socks代理 ]]--
--[[
v2ray_tcp_socks = s:option(Flag, "v2ray_tcp_socks", translate("TCP Open Socks"),
translate(
"When using this TCP node, whether to open the socks proxy at the same time"))
@ -421,6 +457,7 @@ v2ray_tcp_socks_auth_username:depends("v2ray_tcp_socks_auth", "password")
v2ray_tcp_socks_auth_password = s:option(Value, "v2ray_tcp_socks_auth_password",
"Socks5 " .. translate("Password"))
v2ray_tcp_socks_auth_password:depends("v2ray_tcp_socks_auth", "password")
--]]
-- [[ Trojan Cert ]]--
trojan_verify_cert = s:option(Flag, "trojan_verify_cert",
@ -464,8 +501,8 @@ type.validate = function(self, value)
address.rmempty = false
port.rmempty = false
-- v2ray_protocol.rmempty = false
v2ray_VMess_id.rmempty = false
v2ray_VMess_alterId.rmempty = false
-- v2ray_VMess_id.rmempty = false
-- v2ray_VMess_alterId.rmempty = false
elseif value == "V2ray_balancing" then
elseif value == "Brook" then
address.rmempty = false

View File

@ -52,6 +52,9 @@ function o.write(e, e)
"log"))
end
filter_keyword = s:option(DynamicList, "filter_keyword", translate("Filter keyword"),
translate("When subscribing, the keywords in the list are discarded."))
s = m:section(TypedSection, "subscribe_list", "",
"<font color='red'>" .. translate(
"Please input the subscription url first, save and submit before updating. If you subscribe to update, it is recommended to delete all subscriptions and then re-subscribe.") ..

View File

@ -625,6 +625,12 @@ msgstr "手动订阅"
msgid "Delete All Subscribe Node"
msgstr "删除所有订阅节点"
msgid "Filter keyword"
msgstr "过滤关键字"
msgid "When subscribing, the keywords in the list are discarded."
msgstr "订阅时,将丢弃包含列表里的关键字的节点。"
msgid "Add"
msgstr "添加"

View File

@ -60,6 +60,10 @@ config global_app
config global_subscribe
option subscribe_proxy '0'
option auto_update_subscribe '0'
list filter_keyword '过期时间'
list filter_keyword '剩余流量'
list filter_keyword 'QQ群'
list filter_keyword '官网'
config auto_switch
option testing_time '1'

View File

@ -336,7 +336,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 "-U -l $port -b 0.0.0.0 -s $node_address -p $node_port -R"
ln_start_bin $(find_bin ipt2socks) ipt2socks_udp_$5 "-4 -U -l $port -b 0.0.0.0 -s $node_address -p $node_port -R"
elif [ "$type" == "v2ray" ]; then
lua $API_GEN_V2RAY $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"
@ -358,7 +358,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 "-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 $socks5_port -R"
elif [ "$type" == "brook" ]; then
local protocol=$(config_n_get $node brook_protocol client)
if [ "$protocol" == "wsclient" ]; then
@ -392,7 +392,7 @@ gen_start_config() {
local server_username=$(config_n_get $node username)
local server_password=$(config_n_get $node password)
eval port=\$TCP_REDIR_PORT$5
ln_start_bin $(find_bin ipt2socks) ipt2socks_tcp_$5 "-T -l $port -b 0.0.0.0 -s $node_address -p $node_port -R"
ln_start_bin $(find_bin ipt2socks) ipt2socks_tcp_$5 "-4 -T -l $port -b 0.0.0.0 -s $node_address -p $node_port -R"
elif [ "$type" == "v2ray" ]; then
lua $API_GEN_V2RAY $node tcp $local_port nil >$config_file
ln_start_bin $(config_t_get global_app v2ray_file $(find_bin v2ray))/v2ray v2ray_tcp_$5 "-config=$config_file"
@ -451,7 +451,7 @@ gen_start_config() {
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)"
eval port=\$TCP_REDIR_PORT$5
ln_start_bin $(find_bin ipt2socks) ipt2socks_tcp_$5 "-T -l $port -b 0.0.0.0 -s 127.0.0.1 -p $socks5_port -R"
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转换透明代理"
else
[ "$kcptun_use" == "1" ] && {
@ -647,10 +647,10 @@ add_dnsmasq() {
[ "$DNS_MODE" != "nonuse" ] && {
if [ -n "$UP_CHINA_DNS2" ]; then
[ -f "$RULES_PATH/whitelist_host" -a -s "$RULES_PATH/whitelist_host" ] && cat $RULES_PATH/whitelist_host | sed -e "/^$/d" | sort | awk '{print "server=/."$1"/'$UP_CHINA_DNS1'\nserver=/."$1"/'$UP_CHINA_DNS2'\nipset=/."$1"/whitelist"}' > $TMP_DNSMASQ_PATH/whitelist_host.conf
uci show $CONFIG | grep "@nodes" | grep "address" | cut -d "'" -f 2 | sed 's/^\(https:\/\/\|http:\/\/\)//g' | awk -F '/' '{print $1}' | grep -E '.*\..*$' | grep '[a-zA-Z]$' | sort | uniq | awk '{print "server=/."$1"/'$UP_CHINA_DNS1'\nserver=/."$1"/'$UP_CHINA_DNS2'\nipset=/."$1"/vpsiplist"}' > $TMP_DNSMASQ_PATH/vpsiplist_host.conf
uci show $CONFIG | grep "@nodes" | grep "address" | cut -d "'" -f 2 | sed 's/^\(https:\/\/\|http:\/\/\)//g' | awk -F '/' '{print $1}' | grep -v "google.c" | grep -E '.*\..*$' | grep '[a-zA-Z]$' | sort | uniq | awk '{print "server=/."$1"/'$UP_CHINA_DNS1'\nserver=/."$1"/'$UP_CHINA_DNS2'\nipset=/."$1"/vpsiplist"}' > $TMP_DNSMASQ_PATH/vpsiplist_host.conf
else
[ -f "$RULES_PATH/whitelist_host" -a -s "$RULES_PATH/whitelist_host" ] && cat $RULES_PATH/whitelist_host | sed -e "/^$/d" | sort | awk '{print "server=/."$1"/'$UP_CHINA_DNS1'\nipset=/."$1"/whitelist"}' > $TMP_DNSMASQ_PATH/whitelist_host.conf
uci show $CONFIG | grep "@nodes" | grep "address" | cut -d "'" -f 2 | sed 's/^\(https:\/\/\|http:\/\/\)//g' | awk -F '/' '{print $1}' | grep -E '.*\..*$' | grep '[a-zA-Z]$' | sort | uniq | awk '{print "server=/."$1"/'$UP_CHINA_DNS1'\nipset=/."$1"/vpsiplist"}' > $TMP_DNSMASQ_PATH/vpsiplist_host.conf
uci show $CONFIG | grep "@nodes" | grep "address" | cut -d "'" -f 2 | sed 's/^\(https:\/\/\|http:\/\/\)//g' | awk -F '/' '{print $1}' | grep -v "google.c" | grep -E '.*\..*$' | grep '[a-zA-Z]$' | sort | uniq | awk '{print "server=/."$1"/'$UP_CHINA_DNS1'\nipset=/."$1"/vpsiplist"}' > $TMP_DNSMASQ_PATH/vpsiplist_host.conf
fi
[ -f "$RULES_PATH/blacklist_host" -a -s "$RULES_PATH/blacklist_host" ] && cat $RULES_PATH/blacklist_host | sed -e "/^$/d" | sort | awk '{print "server=/."$1"/127.0.0.1#'$DNS_PORT'\nipset=/."$1"/blacklist"}' > $TMP_DNSMASQ_PATH/blacklist_host.conf
[ -f "$RULES_PATH/gfwlist.conf" -a -s "$RULES_PATH/gfwlist.conf" ] && ln -s $RULES_PATH/gfwlist.conf $TMP_DNSMASQ_PATH/gfwlist.conf

View File

@ -60,6 +60,10 @@ config global_app
config global_subscribe
option subscribe_proxy '0'
option auto_update_subscribe '0'
list filter_keyword '过期时间'
list filter_keyword '剩余流量'
list filter_keyword 'QQ群'
list filter_keyword '官网'
config auto_switch
option testing_time '1'

View File

@ -82,6 +82,17 @@ do
end
end
-- 判断是否过滤节点关键字
local filter_keyword_table = ucic2:get(application, "@global_subscribe[0]", "filter_keyword")
local function is_filter_keyword(value)
for k,v in ipairs(filter_keyword_table) do
if value:find(v) then
return true
end
end
return false
end
-- 分割字符串
local function split(full, sep)
if full then
@ -188,6 +199,9 @@ local function processData(szType, content, add_mode)
result.v2ray_h2_path = info.path
end
if info.net == 'tcp' then
if info.type and info.type ~= "http" then
info.type = "none"
end
result.v2ray_tcp_guise = info.type
result.v2ray_tcp_guise_http_host = info.host
result.v2ray_tcp_guise_http_path = info.path
@ -249,6 +263,9 @@ local function processData(szType, content, add_mode)
result.ss_plugin = plugin_info
end
end
if result.ss_plugin and result.ss_plugin == "simple-obfs" then
result.ss_plugin = "obfs-local"
end
else
result.port = host[2]
end
@ -523,10 +540,7 @@ local function parse_link(raw, remark, manual)
end
-- log(result)
if result then
if result.remarks:find("过期时间") or
result.remarks:find("剩余流量") or
result.remarks:find("QQ群") or
result.remarks:find("官网") or
if is_filter_keyword(result.remarks) or
not result.address or
result.address:match("[^0-9a-zA-Z%-%_%.%s]") or -- 中文做地址的 也没有人拿中文域名搞就算中文域也有Puny Code SB 机场
not result.address:find("%.") or -- 虽然没有.也算域,不过应该没有人会这样干吧