luci-app-passwall: bump to 3.9-70

This commit is contained in:
CN_SZTL 2020-10-11 16:46:11 +08:00
parent 7f2a48dcfa
commit a6f339e48b
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
10 changed files with 209 additions and 316 deletions

View File

@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=3.9
PKG_RELEASE:=68
PKG_DATE:=20201006
PKG_RELEASE:=70
PKG_DATE:=20201009
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)

View File

@ -3,6 +3,7 @@ local fs = require "nixio.fs"
local sys = require "luci.sys"
local uci = require"luci.model.uci".cursor()
local util = require "luci.util"
local datatypes = require "luci.cbi.datatypes"
local i18n = require "luci.i18n"
appname = "passwall"
@ -14,6 +15,33 @@ command_timeout = 300
LEDE_BOARD = nil
DISTRIB_TARGET = nil
function get_valid_nodes()
local nodes = {}
uci:foreach(appname, "nodes", function(e)
if e.type and e.remarks then
if e.type == "V2ray" and (e.protocol == "_balancing" or e.protocol == "_shunt") then
e.remarks_name = "%s[%s] " % {i18n.translatef(e.type .. e.protocol), e.remarks}
e.node_type = "special"
nodes[#nodes + 1] = e
end
if e.port and e.address then
local address = e.address
if datatypes.ipaddr(address) or datatypes.hostname(address) then
local address2 = address
if datatypes.ip6addr(address) then address2 = "[" .. address .. "]" end
e.remarks_name = "%s[%s] %s:%s" % {e.type, e.remarks, address2, e.port}
if e.use_kcp and e.use_kcp == "1" then
e.remarks_name = "%s+%s[%s] %s" % {e.type, "Kcptun", e.remarks, address2}
end
e.node_type = "normal"
nodes[#nodes + 1] = e
end
end
end
end)
return nodes
end
function gen_uuid(format)
local uuid = sys.exec("echo -n $(cat /proc/sys/kernel/random/uuid)")
if format == nil then

View File

@ -1,16 +1,18 @@
module("luci.model.cbi.passwall.api.gen_v2ray", package.seeall)
local ucursor = require"luci.model.uci".cursor()
local sys = require "luci.sys"
local json = require "luci.jsonc"
local appname = "passwall"
local node_section = arg[1]
local inbounds = {}
local outbounds = {}
local routing = nil
local node_section = arg[1] or "nil"
local proto = arg[2]
local redir_port = arg[3]
local socks_proxy_port = arg[4]
local node = ucursor:get_all(appname, node_section)
local inbounds = {}
local outbounds = {}
local network = proto
local routing = nil
local new_port
local function get_new_port()
@ -22,7 +24,7 @@ local function get_new_port()
return new_port
end
local function gen_outbound(node, tag, relay_port)
function gen_outbound(node, tag, relay_port)
local result = nil
if node then
local node_id = node[".name"]
@ -145,159 +147,160 @@ local function gen_outbound(node, tag, relay_port)
}
}
end
return result
end
if socks_proxy_port ~= "nil" then
table.insert(inbounds, {
listen = "0.0.0.0",
port = tonumber(socks_proxy_port),
protocol = "socks",
settings = {auth = "noauth", udp = true, ip = "127.0.0.1"}
})
network = "tcp,udp"
end
if redir_port ~= "nil" then
table.insert(inbounds, {
port = tonumber(redir_port),
protocol = "dokodemo-door",
settings = {network = proto, followRedirect = true},
sniffing = {enabled = true, destOverride = {"http", "tls"}}
})
if proto == "tcp" and node.tcp_socks == "1" then
if node then
if socks_proxy_port ~= "nil" then
table.insert(inbounds, {
listen = "0.0.0.0",
port = tonumber(node.tcp_socks_port),
port = tonumber(socks_proxy_port),
protocol = "socks",
settings = {
auth = node.tcp_socks_auth,
accounts = (node.tcp_socks_auth == "password") and {
{
user = node.tcp_socks_auth_username,
pass = node.tcp_socks_auth_password
}
} or nil,
udp = true
}
settings = {auth = "noauth", udp = true, ip = "127.0.0.1"}
})
network = "tcp,udp"
end
end
if node.protocol == "_shunt" then
local rules = {}
ucursor:foreach(appname, "shunt_rules", function(e)
local name = e[".name"]
local _node_id = node[name] or nil
if _node_id and _node_id ~= "nil" then
local _node = ucursor:get_all(appname, _node_id)
local is_proxy = node[name .. "_proxy"]
local relay_port
if is_proxy and is_proxy == "1" then
new_port = get_new_port()
relay_port = new_port
table.insert(inbounds, {
tag = "proxy_" .. name,
listen = "127.0.0.1",
port = new_port,
protocol = "dokodemo-door",
settings = {network = "tcp,udp", address = _node.address, port = tonumber(_node.port)}
})
if _node.tls_serverName == nil then
_node.tls_serverName = _node.address
end
_node.address = "127.0.0.1"
_node.port = new_port
end
local _outbound = gen_outbound(_node, name, relay_port)
if _outbound then
table.insert(outbounds, _outbound)
if redir_port ~= "nil" then
table.insert(inbounds, {
port = tonumber(redir_port),
protocol = "dokodemo-door",
settings = {network = proto, followRedirect = true},
sniffing = {enabled = true, destOverride = {"http", "tls"}}
})
if proto == "tcp" and node.tcp_socks == "1" then
table.insert(inbounds, {
listen = "0.0.0.0",
port = tonumber(node.tcp_socks_port),
protocol = "socks",
settings = {
auth = node.tcp_socks_auth,
accounts = (node.tcp_socks_auth == "password") and {
{
user = node.tcp_socks_auth_username,
pass = node.tcp_socks_auth_password
}
} or nil,
udp = true
}
})
end
end
if node.protocol == "_shunt" then
local rules = {}
ucursor:foreach(appname, "shunt_rules", function(e)
local name = e[".name"]
local _node_id = node[name] or nil
if _node_id and _node_id ~= "nil" then
local _node = ucursor:get_all(appname, _node_id)
local is_proxy = node[name .. "_proxy"]
local relay_port
if is_proxy and is_proxy == "1" then
table.insert(rules, {
type = "field",
inboundTag = {"proxy_" .. name},
outboundTag = "default"
new_port = get_new_port()
relay_port = new_port
table.insert(inbounds, {
tag = "proxy_" .. name,
listen = "127.0.0.1",
port = new_port,
protocol = "dokodemo-door",
settings = {network = "tcp,udp", address = _node.address, port = tonumber(_node.port)}
})
if _node.tls_serverName == nil then
_node.tls_serverName = _node.address
end
_node.address = "127.0.0.1"
_node.port = new_port
end
if e.domain_list then
local _domain = {}
string.gsub(e.domain_list, '[^' .. "\r\n" .. ']+', function(w)
table.insert(_domain, w)
end)
table.insert(rules, {
type = "field",
outboundTag = name,
domain = _domain
})
end
if e.ip_list then
local _ip = {}
string.gsub(e.ip_list, '[^' .. "\r\n" .. ']+', function(w)
table.insert(_ip, w)
end)
table.insert(rules, {
type = "field",
outboundTag = name,
ip = _ip
})
local _outbound = gen_outbound(_node, name, relay_port)
if _outbound then
table.insert(outbounds, _outbound)
if is_proxy and is_proxy == "1" then
table.insert(rules, {
type = "field",
inboundTag = {"proxy_" .. name},
outboundTag = "default"
})
end
if e.domain_list then
local _domain = {}
string.gsub(e.domain_list, '[^' .. "\r\n" .. ']+', function(w)
table.insert(_domain, w)
end)
table.insert(rules, {
type = "field",
outboundTag = name,
domain = _domain
})
end
if e.ip_list then
local _ip = {}
string.gsub(e.ip_list, '[^' .. "\r\n" .. ']+', function(w)
table.insert(_ip, w)
end)
table.insert(rules, {
type = "field",
outboundTag = name,
ip = _ip
})
end
end
end
end)
local default_node_id = node.default_node or nil
if default_node_id and default_node_id ~= "nil" then
local default_node = ucursor:get_all(appname, default_node_id)
local default_outbound = gen_outbound(default_node, "default")
if default_outbound then
table.insert(outbounds, default_outbound)
local rule = {
type = "field",
outboundTag = "default",
network = network
}
table.insert(rules, rule)
end
end
end)
local default_node_id = node.default_node or nil
if default_node_id and default_node_id ~= "nil" then
local default_node = ucursor:get_all(appname, default_node_id)
local default_outbound = gen_outbound(default_node, "default")
if default_outbound then
table.insert(outbounds, default_outbound)
local rule = {
type = "field",
outboundTag = "default",
network = network
routing = {domainStrategy = "IPOnDemand", rules = rules}
elseif node.protocol == "_balancing" then
if node.balancing_node then
local nodes = node.balancing_node
local length = #nodes
for i = 1, length do
local node = ucursor:get_all(appname, 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"}
}
}
table.insert(rules, rule)
end
else
local outbound = gen_outbound(node)
if outbound then table.insert(outbounds, outbound) end
end
routing = {domainStrategy = "IPOnDemand", rules = rules}
-- 额外传出连接
table.insert(outbounds, {protocol = "freedom", tag = "direct", settings = {keep = ""}})
elseif node.protocol == "_balancing" then
if node.balancing_node then
local nodes = node.balancing_node
local length = #nodes
for i = 1, length do
local node = ucursor:get_all(appname, 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"}
}
}
end
else
local outbound = gen_outbound(node)
if outbound then table.insert(outbounds, outbound) end
local v2ray = {
log = {
-- error = string.format("/var/etc/passwall/%s.log", node[".name"]),
loglevel = "warning"
},
-- 传入连接
inbounds = inbounds,
-- 传出连接
outbounds = outbounds,
-- 路由
routing = routing
}
print(json.stringify(v2ray, 1))
end
-- 额外传出连接
table.insert(outbounds, {protocol = "freedom", tag = "direct", settings = {keep = ""}})
local v2ray = {
log = {
-- error = string.format("/var/etc/passwall/%s.log", node[".name"]),
loglevel = "warning"
},
-- 传入连接
inbounds = inbounds,
-- 传出连接
outbounds = outbounds,
-- 路由
routing = routing
}
print(json.stringify(v2ray, 1))

View File

@ -1,21 +1,14 @@
local uci = require"luci.model.uci".cursor()
local api = require "luci.model.cbi.passwall.api.api"
local appname = "passwall"
local nodes_table = {}
uci:foreach(appname, "nodes", function(e)
if e.type and e.remarks then
local remarks = ""
if e.type == "V2ray" and (e.protocol == "_balancing" or e.protocol == "_shunt") then
remarks = "%s[%s] " % {translatef(e.type .. e.protocol), e.remarks}
else
remarks = "%s[%s] %s:%s" % {e.type, e.remarks, e.address, e.port}
end
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = remarks
}
end
end)
for k, e in ipairs(api.get_valid_nodes()) do
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = e.remarks_name
}
end
m = Map(appname)

View File

@ -4,24 +4,12 @@ local api = require "luci.model.cbi.passwall.api.api"
local appname = "passwall"
local nodes_table = {}
uci:foreach(appname, "nodes", function(e)
if e.type and e.remarks then
local remarks = ""
if e.type == "V2ray" and (e.protocol == "_balancing" or e.protocol == "_shunt") then
remarks = "%s[%s] " % {translatef(e.type .. e.protocol), e.remarks}
else
if e.use_kcp and e.use_kcp == "1" then
remarks = "%s+%s[%s] %s" % {e.type, "Kcptun", e.remarks, e.address}
else
remarks = "%s[%s] %s:%s" % {e.type, e.remarks, e.address, e.port}
end
end
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = remarks
}
end
end)
for k, e in ipairs(api.get_valid_nodes()) do
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = e.remarks_name
}
end
local socks_table = {}
uci:foreach(appname, "socks", function(s)

View File

@ -1,20 +1,19 @@
local e = require "luci.sys"
local net = require "luci.model.network".init()
local uci = require "luci.model.uci".cursor()
local api = require "luci.model.cbi.passwall.api.api"
local appname = "passwall"
local nodes_table = {}
uci:foreach(appname, "nodes", function(e)
if e.type and e.remarks and e.port and e.address and e.address ~= "127.0.0.1" then
if e.address:match("[\u4e00-\u9fa5]") and e.address:find("%.") and e.address:sub(#e.address) ~= "." then
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = "%s[%s] %s:%s" % {translate(e.type), e.remarks, e.address, e.port},
obj = e
}
end
for k, e in ipairs(api.get_valid_nodes()) do
if e.node_type == "normal" then
nodes_table[#nodes_table + 1] = {
id = e[".name"],
obj = e,
remarks = e.remarks_name
}
end
end)
end
m = Map(appname)

View File

@ -112,16 +112,14 @@ protocol:value("_shunt", translate("Shunt"))
protocol:depends("type", "V2ray")
local nodes_table = {}
uci:foreach(appname, "nodes", function(e)
if e.type and e.remarks and e.port then
if e.address:match("[\u4e00-\u9fa5]") and e.address:find("%.") and e.address:sub(#e.address) ~= "." then
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = "%s[%s] %s:%s" % {e.type, e.remarks, e.address, e.port}
}
end
for k, e in ipairs(api.get_valid_nodes()) do
if e.node_type == "normal" then
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = e.remarks_name
}
end
end)
end
-- 负载均衡列表
balancing_node = s:option(DynamicList, "balancing_node", translate("Load balancing node list"), translate("Load balancing node list, <a target='_blank' href='https://toutyrater.github.io/routing/balance2.html'>document</a>"))

View File

@ -149,24 +149,4 @@ o:value("big_icon", translate("Big icon")) -- 大图标
o:value("show_check_port", translate("Show node check")) -- 显示节点检测
o:value("show_ip111", translate("Show Show IP111")) -- 显示IP111
local nodes_table = {}
uci:foreach(appname, "nodes", function(e)
if e.type and e.remarks then
local remarks = ""
if e.type == "V2ray" and (e.protocol == "_balancing" or e.protocol == "_shunt") then
remarks = "%s[%s] " % {translatef(e.type .. e.protocol), e.remarks}
else
if e.use_kcp and e.use_kcp == "1" then
remarks = "%s+%s[%s] %s" % {e.type, "Kcptun", e.remarks, e.address}
else
remarks = "%s[%s] %s:%s" % {e.type, e.remarks, e.address, e.port}
end
end
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = remarks
}
end
end)
return m

View File

@ -87,105 +87,9 @@ function gen_config(user)
}
if user.transit_node and user.transit_node ~= "nil" then
local node = ucic:get_all("passwall", user.transit_node)
if node and node ~= "nil" and node.type and node.type == "V2ray" then
if node.transport == "mkcp" or node.transport == "quic" then
node.stream_security = "none"
end
local transit_node = {
tag = "transit",
protocol = node.protocol,
mux = {
enabled = (node.mux == "1") and true or false,
concurrency = (node.mux_concurrency) and tonumber(node.mux_concurrency) or 8
},
-- 底层传输配置
streamSettings = {
network = node.transport,
security = node.stream_security,
xtlsSettings = (node.stream_security == "xtls") and {
serverName = node.tls_serverName,
allowInsecure = (node.tls_allowInsecure == "1") and true or false
} or nil,
tlsSettings = (node.stream_security == "tls") and {
disableSessionResumption = node.sessionTicket ~= "1" and true or false,
serverName = node.tls_serverName,
allowInsecure = (node.tls_allowInsecure == "1") and true or false
} or nil,
tcpSettings = (node.transport == "tcp") and {
header = {
type = node.tcp_guise,
request = (node.tcp_guise == "http") and {
path = node.tcp_guise_http_path or {"/"},
headers = {
Host = node.tcp_guise_http_host or {}
}
} or nil
}
} or nil,
kcpSettings = (node.transport == "mkcp") and {
mtu = tonumber(node.mkcp_mtu),
tti = tonumber(node.mkcp_tti),
uplinkCapacity = tonumber(node.mkcp_uplinkCapacity),
downlinkCapacity = tonumber(node.mkcp_downlinkCapacity),
congestion = (node.mkcp_congestion == "1") and true or false,
readBufferSize = tonumber(node.mkcp_readBufferSize),
writeBufferSize = tonumber(node.mkcp_writeBufferSize),
seed = (node.mkcp_seed and node.mkcp_seed ~= "") and node.mkcp_seed or nil,
header = {type = node.mkcp_guise}
} or nil,
wsSettings = (node.transport == "ws") and {
path = node.ws_path or "",
headers = (node.ws_host ~= nil) and {Host = node.ws_host} or nil
} or nil,
httpSettings = (node.transport == "h2") and {
path = node.h2_path, host = node.h2_host
} or nil,
dsSettings = (node.transport == "ds") and {
path = node.ds_path
} or nil,
quicSettings = (node.transport == "quic") and {
security = node.quic_security,
key = node.quic_key,
header = {type = node.quic_guise}
} or nil
},
settings = {
vnext = (node.protocol == "vmess" or node.protocol == "vless") and {
{
address = node.address,
port = tonumber(node.port),
users = {
{
id = node.uuid,
alterId = tonumber(node.alter_id),
level = node.level and tonumber(node.level) or 0,
security = (node.protocol == "vmess") and node.security or nil,
encryption = node.encryption or "none",
flow = (node.stream_security == "xtls") and node.flow or nil
}
}
}
} or nil,
servers = (node.protocol == "http" or node.protocol == "socks" or node.protocol == "shadowsocks" or node.protocol == "trojan") and {
{
address = node.address,
port = tonumber(node.port),
method = node.v_ss_encrypt_method,
password = node.password or "",
users = (node.username and node.password) and
{
{
user = node.username or "",
pass = node.password or ""
}
} or nil
}
} or nil
}
}
table.insert(outbounds, 1, transit_node)
end
local gen_v2ray = require("luci.model.cbi.passwall.api.gen_v2ray")
local client = gen_v2ray.gen_outbound(ucic:get_all("passwall", user.transit_node), "transit")
table.insert(outbounds, 1, client)
end
local config = {

View File

@ -514,14 +514,14 @@ ss_aead_pwd.rmempty = false
ss_aead_pwd:depends("ss_aead", "1")
local nodes_table = {}
uci:foreach("passwall", "nodes", function(e)
if e.type and e.type == "V2ray" and e.remarks and e.address and e.port then
for k, e in ipairs(api.get_valid_nodes()) do
if e.node_type == "normal" and e.type == "V2ray" then
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = "%s[%s] %s:%s" % {e.type, e.remarks, e.address, e.port}
remarks = e.remarks_name
}
end
end)
end
transit_node = s:option(ListValue, "transit_node", translate("transit node"))
transit_node:value("nil", translate("Close"))