luci-app-passwall: bump to 4-10

Signed-off-by: CN_SZTL <cnsztl@project-openwrt.eu.org>
This commit is contained in:
xiaorouji 2021-01-22 18:17:24 +08:00 committed by CN_SZTL
parent e988e529b8
commit d7dd4bfecb
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
26 changed files with 235 additions and 909 deletions

View File

@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=4
PKG_RELEASE:=9
PKG_DATE:=20210119
PKG_RELEASE:=10
PKG_DATE:=20210122
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
@ -92,7 +92,6 @@ define Package/$(PKG_NAME)
DEPENDS:=+libmbedtls +iptables-mod-tproxy +ip +ipset +coreutils +coreutils-base64 +coreutils-nohup +luci-lib-jsonc \
+curl +ca-certificates +resolveip +unzip +dnsmasq-full +tcping +libuci-lua \
+ipt2socks \
+ssocks \
+microsocks \
+pdnsd-alt \
+PACKAGE_$(PKG_NAME)_INCLUDE_Shadowsocks:shadowsocks-libev-ss-redir \
@ -102,7 +101,6 @@ define Package/$(PKG_NAME)
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR:shadowsocksr-libev-ssr-local \
+PACKAGE_$(PKG_NAME)_INCLUDE_ShadowsocksR_Server:shadowsocksr-libev-server \
+PACKAGE_$(PKG_NAME)_INCLUDE_Xray:xray \
+PACKAGE_$(PKG_NAME)_INCLUDE_V2ray:v2ray \
+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan_Plus:trojan-plus \
+PACKAGE_$(PKG_NAME)_INCLUDE_Trojan_GO:trojan-go \
+PACKAGE_$(PKG_NAME)_INCLUDE_NaiveProxy:naiveproxy \

View File

@ -9,7 +9,6 @@ local api = require "luci.model.cbi.passwall.api.api"
local kcptun = require "luci.model.cbi.passwall.api.kcptun"
local brook = require "luci.model.cbi.passwall.api.brook"
local xray = require "luci.model.cbi.passwall.api.xray"
local v2ray = require "luci.model.cbi.passwall.api.v2ray"
local trojan_go = require "luci.model.cbi.passwall.api.trojan_go"
function index()
@ -72,8 +71,6 @@ function index()
entry({"admin", "services", appname, "brook_update"}, call("brook_update")).leaf = true
entry({"admin", "services", appname, "xray_check"}, call("xray_check")).leaf = true
entry({"admin", "services", appname, "xray_update"}, call("xray_update")).leaf = true
entry({"admin", "services", appname, "v2ray_check"}, call("v2ray_check")).leaf = true
entry({"admin", "services", appname, "v2ray_update"}, call("v2ray_update")).leaf = true
entry({"admin", "services", appname, "trojan_go_check"}, call("trojan_go_check")).leaf = true
entry({"admin", "services", appname, "trojan_go_update"}, call("trojan_go_update")).leaf = true
end
@ -413,25 +410,6 @@ function xray_update()
http_write_json(json)
end
function v2ray_check()
local json = v2ray.to_check("")
http_write_json(json)
end
function v2ray_update()
local json = nil
local task = http.formvalue("task")
if task == "extract" then
json = v2ray.to_extract(http.formvalue("file"), http.formvalue("subfix"))
elseif task == "move" then
json = v2ray.to_move(http.formvalue("file"))
else
json = v2ray.to_download(http.formvalue("url"))
end
http_write_json(json)
end
function trojan_go_check()
local json = trojan_go.to_check("")
http_write_json(json)

View File

@ -149,31 +149,6 @@ function get_xray_version(file)
return ""
end
function get_v2ray_path()
local path = uci_get_type("global_app", "v2ray_file")
return path
end
function get_v2ray_version(file)
if file == nil then file = get_v2ray_path() end
chmod_755(file)
if fs.access(file) then
if file == get_v2ray_path() then
local md5 = sys.exec("echo -n $(md5sum " .. file .. " | awk '{print $1}')")
if fs.access("/tmp/psw_" .. md5) then
return sys.exec("cat /tmp/psw_" .. md5)
else
local version = sys.exec("echo -n $(%s -version | awk '{print $2}' | sed -n 1P)" % file)
sys.call("echo '" .. version .. "' > " .. "/tmp/psw_" .. md5)
return version
end
else
return sys.exec("echo -n $(%s -version | awk '{print $2}' | sed -n 1P)" % file)
end
end
return ""
end
function get_trojan_go_path()
local path = uci_get_type("global_app", "trojan_go_file")
return path

View File

@ -57,13 +57,13 @@ function gen_outbound(node, tag, relay_port)
node.port = new_port
sys.call(string.format('/usr/share/%s/app.sh run_socks "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"> /dev/null',
appname,
new_port,
node_id,
"127.0.0.1",
new_port,
string.format("/var/etc/%s/v2_%s_%s.json", appname, node_type, node_id),
"0",
"nil",
"4",
relay_port and tostring(relay_port) or ""
)
)
@ -286,6 +286,38 @@ if node_section then
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)
if "1" == node.default_proxy then
local node_id = node.main_node or nil
if node_id and node_id ~= "nil" then
if node_id == default_node_id then
else
new_port = get_new_port()
table.insert(inbounds, {
tag = "proxy_default",
listen = "127.0.0.1",
port = new_port,
protocol = "dokodemo-door",
settings = {network = "tcp,udp", address = default_node.address, port = tonumber(default_node.port)}
})
if default_node.tls_serverName == nil then
default_node.tls_serverName = default_node.address
end
default_node.address = "127.0.0.1"
default_node.port = new_port
local node = ucursor:get_all(appname, node_id)
local outbound = gen_outbound(node, "main")
if outbound then
table.insert(outbounds, outbound)
local rule = {
type = "field",
inboundTag = {"proxy_default"},
outboundTag = "main"
}
table.insert(rules, rule)
end
end
end
end
local default_outbound = gen_outbound(default_node, "default")
if default_outbound then
table.insert(outbounds, default_outbound)

View File

@ -1,173 +0,0 @@
module("luci.model.cbi.passwall.api.v2ray", package.seeall)
local fs = require "nixio.fs"
local sys = require "luci.sys"
local util = require "luci.util"
local i18n = require "luci.i18n"
local api = require "luci.model.cbi.passwall.api.api"
local v2ray_api = "https://api.github.com/repos/v2fly/v2ray-core/releases/latest"
local is_armv7 = false
function to_check(arch)
local app_path = api.get_v2ray_path() or ""
if app_path == "" then
return {
code = 1,
error = i18n.translatef("You did not fill in the %s path. Please save and apply then update manually.", "V2ray")
}
end
if not arch or arch == "" then arch = api.auto_get_arch() end
local file_tree, sub_version = api.get_file_info(arch)
if sub_version == "7" then is_armv7 = true end
if file_tree == "" then
return {
code = 1,
error = i18n.translate("Can't determine ARCH, or ARCH not supported.")
}
end
if file_tree == "amd64" then file_tree = "64" end
if file_tree == "386" then file_tree = "32" end
local json = api.get_api_json(v2ray_api)
if json.tag_name == nil then
return {
code = 1,
error = i18n.translate("Get remote version info failed.")
}
end
local now_version = api.get_v2ray_version()
local remote_version = json.tag_name:match("[^v]+")
local needs_update = api.compare_versions(now_version, "<", remote_version)
local html_url, download_url
if needs_update then
html_url = json.html_url
for _, v in ipairs(json.assets) do
if v.name and v.name:match("linux%-" .. file_tree) then
download_url = v.browser_download_url
break
end
end
end
if needs_update and not download_url then
return {
code = 1,
now_version = now_version,
version = remote_version,
html_url = html_url,
error = i18n.translate("New version found, but failed to get new version download url.")
}
end
return {
code = 0,
update = needs_update,
now_version = now_version,
version = remote_version,
url = {html = html_url, download = download_url}
}
end
function to_download(url)
local app_path = api.get_v2ray_path() or ""
if app_path == "" then
return {
code = 1,
error = i18n.translatef("You did not fill in the %s path. Please save and apply then update manually.", "V2ray")
}
end
if not url or url == "" then
return {code = 1, error = i18n.translate("Download url is required.")}
end
sys.call("/bin/rm -f /tmp/v2ray_download.*")
local tmp_file = util.trim(util.exec("mktemp -u -t v2ray_download.XXXXXX"))
local result = api.exec(api.curl, {api._unpack(api.curl_args), "-o", tmp_file, url}, nil, api.command_timeout) == 0
if not result then
api.exec("/bin/rm", {"-f", tmp_file})
return {
code = 1,
error = i18n.translatef("File download failed or timed out: %s", url)
}
end
return {code = 0, file = tmp_file}
end
function to_extract(file, subfix)
local app_path = api.get_v2ray_path() or ""
if app_path == "" then
return {
code = 1,
error = i18n.translatef("You did not fill in the %s path. Please save and apply then update manually.", "V2ray")
}
end
if not file or file == "" or not fs.access(file) then
return {code = 1, error = i18n.translate("File path required.")}
end
if sys.exec("echo -n $(opkg list-installed | grep -c unzip)") ~= "1" then
api.exec("/bin/rm", {"-f", file})
return {
code = 1,
error = i18n.translate("Not installed unzip, Can't unzip!")
}
end
sys.call("/bin/rm -rf /tmp/v2ray_extract.*")
local tmp_dir = util.trim(util.exec("mktemp -d -t v2ray_extract.XXXXXX"))
local output = {}
api.exec("/usr/bin/unzip", {"-o", file, "-d", tmp_dir},
function(chunk) output[#output + 1] = chunk end)
local files = util.split(table.concat(output))
api.exec("/bin/rm", {"-f", file})
return {code = 0, file = tmp_dir}
end
function to_move(file)
local app_path = api.get_v2ray_path() or ""
if app_path == "" then
return {
code = 1,
error = i18n.translatef("You did not fill in the %s path. Please save and apply then update manually.", "V2ray")
}
end
if not file or file == "" then
sys.call("/bin/rm -rf /tmp/v2ray_extract.*")
return {code = 1, error = i18n.translate("Client file is required.")}
end
if not arch or arch == "" then arch = api.auto_get_arch() end
local file_tree, sub_version = api.get_file_info(arch)
local t = ""
sys.call("/etc/init.d/passwall stop")
local result = nil
if sub_version and sub_version == "7" then t = "_armv7" end
result = api.exec("/bin/mv", { "-f", file .. "/v2ray" .. t, app_path }, nil, api.command_timeout) == 0
sys.call("/bin/rm -rf /tmp/v2ray_extract.*")
if not result or not fs.access(app_path) then
return {
code = 1,
error = i18n.translatef("Can't move new file to path: %s", app_path)
}
end
api.chmod_755(app_path)
sys.call("/etc/init.d/passwall restart >/dev/null 2>&1 &")
return {code = 0}
end

View File

@ -10,7 +10,6 @@ s = m:section(TypedSection, "global_app", translate("App Update"),
"</font>")
s.anonymous = true
s:append(Template(appname .. "/app_update/xray_version"))
s:append(Template(appname .. "/app_update/v2ray_version"))
s:append(Template(appname .. "/app_update/trojan_go_version"))
s:append(Template(appname .. "/app_update/kcptun_version"))
s:append(Template(appname .. "/app_update/brook_version"))
@ -19,10 +18,6 @@ o = s:option(Value, "xray_file", translatef("%s App Path", "Xray"))
o.default = "/usr/bin/xray"
o.rmempty = false
o = s:option(Value, "v2ray_file", translatef("%s App Path", "V2ray"))
o.default = "/usr/bin/v2ray"
o.rmempty = false
o = s:option(Value, "trojan_go_file", translatef("%s App Path", "Trojan-Go"))
o.default = "/usr/bin/trojan-go"
o.rmempty = false

View File

@ -2,16 +2,27 @@ local d = require "luci.dispatcher"
local uci = require"luci.model.uci".cursor()
local api = require "luci.model.cbi.passwall.api.api"
local appname = "passwall"
local has_xray = api.is_finded("xray")
m = Map(appname)
local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = e.remarks_name
remarks = e.remarks_name,
type = e["type"]
}
end
local socks_table = {}
if tonumber(m:get("@global[0]", "tcp_node_socks") or 0) == 1 then
local id = "127.0.0.1" .. ":" .. m:get("@global[0]", "tcp_node_socks_port")
socks_table[#socks_table + 1] = {
id = id,
remarks = id .. " - " .. translate("TCP Node")
}
end
uci:foreach(appname, "socks", function(s)
if s.enabled == "1" and s.node then
local id, remarks
@ -25,7 +36,7 @@ uci:foreach(appname, "socks", function(s)
end
end
end
id = "0.0.0.0" .. ":" .. s.port
id = "127.0.0.1" .. ":" .. s.port
socks_table[#socks_table + 1] = {
id = id,
remarks = id .. " - " .. (remarks or translate("Misconfigured"))
@ -55,7 +66,6 @@ local doh_validate = function(self, value, t)
return nil, translate("DoH request address") .. " " .. translate("Format must be:") .. " URL,IP"
end
m = Map(appname)
local status = m:get("@global_other[0]", "status") or ""
if status:find("big_icon") then
m:append(Template(appname .. "/global/status"))
@ -74,11 +84,11 @@ o = s:taboption("Main", Flag, "enabled", translate("Main switch"))
o.rmempty = false
---- TCP Node
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 />"
tcp_node = s:taboption("Main", ListValue, "tcp_node", translate("TCP Node"))
tcp_node.title = translate("TCP Node")
tcp_node.description = ""
--tcp_node.description = translate("For proxy specific list.")
--tcp_node.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)
@ -86,7 +96,7 @@ if current_node and current_node ~= "" and current_node ~= "nil" 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 />"
tcp_node.description = tcp_node.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)
@ -95,7 +105,7 @@ if current_node and current_node ~= "" and current_node ~= "nil" then
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 />"
tcp_node.description = tcp_node.description .. remarks .. "" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
end
end)
local id = "default_node"
@ -103,22 +113,32 @@ if current_node and current_node ~= "" and current_node ~= "nil" then
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 />"
tcp_node.description = tcp_node.description .. remarks .. "" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
end
end
end
end
o:value("nil", translate("Close"))
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end
tcp_node:value("nil", translate("Close"))
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
udp_node = s:taboption("Main", ListValue, "udp_node", translate("UDP Node"))
udp_node:value("nil", translate("Close"))
udp_node.title = translate("UDP Node")
--udp_node.description = translate("For proxy game network, DNS hijack etc.") .. "<br />" .. translate("The selected server will not use Kcptun.")
udp_node:value("tcp_", translate("Same as the tcp node"))
--udp_node:value("tcp", translate("Same as the tcp node"))
--udp_node:value("tcp_", translate("Same as the tcp node") .. "" .. translate("New process") .. "")
tcp_node_socks = s:taboption("Main", Flag, "tcp_node_socks", translate("Enable") .. translate("TCP Node") .. "Socks")
o = s:taboption("Main", Value, "tcp_node_socks_port", "Socks" .. translate("Listen Port"))
o.default = 1080
o.datatype = "port"
o:depends("tcp_node_socks", true)
tcp_node_http = s:taboption("Main", Flag, "tcp_node_http", translate("Enable") .. translate("TCP Node") .. "Http")
o = s:taboption("Main", Value, "tcp_node_http_port", "HTTP" .. translate("Listen Port"))
o.default = 1180
o.datatype = "port"
o:depends("tcp_node_http", true)
s:tab("DNS", translate("DNS"))
@ -135,7 +155,7 @@ o = s:taboption("DNS", Value, "up_china_dns", translate("Local DNS") .. "(UDP)")
o.description = translate("IP:Port mode acceptable, multi value split with english comma.") .. "<br />" .. translate("When the selection is not the default, this DNS is forced to be set to dnsmasq upstream DNS.")
o.default = "default"
o:value("default", translate("Default"))
if api.is_finded("xray") then
if has_xray then
o:value("xray_doh", "Xray DNS(DoH)")
end
o:value("223.5.5.5", "223.5.5.5 (" .. translate("Ali") .. "DNS)")
@ -166,7 +186,7 @@ end
if api.is_finded("dns2socks") then
o:value("dns2socks", "dns2socks")
end
if api.is_finded("xray") then
if has_xray then
o:value("xray_doh", "Xray DNS(DoH)")
end
o:value("udp", translatef("Requery DNS By %s", translate("UDP Node")))
@ -335,21 +355,35 @@ o = s:option(Flag, "enabled", translate("Enable"))
o.default = 1
o.rmempty = false
o = s:option(ListValue, "node", translate("Socks Node"))
o:value("tcp", translate("Same as the tcp node"))
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end
socks_node = s:option(ListValue, "node", translate("Socks Node"))
o = s:option(Value, "port", "Socks" .. translate("Listen Port"))
o.default = 9050
o.datatype = "port"
o.rmempty = false
if api.is_finded("xray") or api.is_finded("v2ray") then
if has_xray then
o = s:option(Value, "http_port", "HTTP" .. translate("Listen Port") .. " " .. translate("0 is not use"))
o.default = 0
o.datatype = "port"
end
for k, v in pairs(nodes_table) do
tcp_node:value(v.id, v.remarks)
tcp_node_socks:depends("tcp_node", v.id)
if has_xray then
tcp_node_http:depends("tcp_node", v.id)
end
udp_node:value(v.id, v.remarks)
if v.type == "Socks" then
if has_xray then
socks_node:value(v.id, v.remarks)
end
else
socks_node:value(v.id, v.remarks)
end
end
m:append(Template(appname .. "/global/footer"))
--[[

View File

@ -83,9 +83,6 @@ if api.is_finded("xray") then
type:value("Xray", translate("Xray"))
type.description = translate("Xray is currently directly compatible with V2ray and used.")
end
if api.is_finded("v2ray") then
type:value("V2ray", translate("V2ray"))
end
if api.is_finded("brook") then
type:value("Brook", translate("Brook"))
end
@ -113,7 +110,6 @@ protocol:value("shadowsocks", translate("Shadowsocks"))
protocol:value("trojan", translate("Trojan"))
protocol:value("_balancing", translate("Balancing"))
protocol:value("_shunt", translate("Shunt"))
protocol:depends("type", "V2ray")
protocol:depends("type", "Xray")
local nodes_table = {}
@ -155,6 +151,14 @@ default_node:value("nil", translate("Close"))
for k, v in pairs(nodes_table) do default_node:value(v.id, v.remarks) end
default_node:depends("protocol", "_shunt")
default_proxy = s:option(Flag, "default_proxy", translate("Default") .. translate("Node") .. translate("Preproxy"), translate("Use the under node for the transit."))
default_proxy.default = 0
default_proxy:depends("protocol", "_shunt")
o = s:option(ListValue, "main_node", " ")
for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end
o:depends("default_proxy", "1")
domainStrategy = s:option(ListValue, "domainStrategy", translate("Domain Strategy"))
domainStrategy:value("AsIs")
domainStrategy:value("IPIfNonMatch")
@ -209,12 +213,6 @@ address:depends({ type = "Xray", protocol = "http" })
address:depends({ type = "Xray", protocol = "socks" })
address:depends({ type = "Xray", protocol = "shadowsocks" })
address:depends({ type = "Xray", protocol = "trojan" })
address:depends({ type = "V2ray", protocol = "vmess" })
address:depends({ type = "V2ray", protocol = "vless" })
address:depends({ type = "V2ray", protocol = "http" })
address:depends({ type = "V2ray", protocol = "socks" })
address:depends({ type = "V2ray", protocol = "shadowsocks" })
address:depends({ type = "V2ray", protocol = "trojan" })
--[[
use_ipv6 = s:option(Flag, "use_ipv6", translate("Use IPv6"))
@ -232,12 +230,6 @@ use_ipv6:depends({ type = "Xray", protocol = "http" })
use_ipv6:depends({ type = "Xray", protocol = "socks" })
use_ipv6:depends({ type = "Xray", protocol = "shadowsocks" })
use_ipv6:depends({ type = "Xray", protocol = "trojan" })
use_ipv6:depends({ type = "V2ray", protocol = "vmess" })
use_ipv6:depends({ type = "V2ray", protocol = "vless" })
use_ipv6:depends({ type = "V2ray", protocol = "http" })
use_ipv6:depends({ type = "V2ray", protocol = "socks" })
use_ipv6:depends({ type = "V2ray", protocol = "shadowsocks" })
use_ipv6:depends({ type = "V2ray", protocol = "trojan" })
--]]
port = s:option(Value, "port", translate("Port"))
@ -257,20 +249,12 @@ port:depends({ type = "Xray", protocol = "http" })
port:depends({ type = "Xray", protocol = "socks" })
port:depends({ type = "Xray", protocol = "shadowsocks" })
port:depends({ type = "Xray", protocol = "trojan" })
port:depends({ type = "V2ray", protocol = "vmess" })
port:depends({ type = "V2ray", protocol = "vless" })
port:depends({ type = "V2ray", protocol = "http" })
port:depends({ type = "V2ray", protocol = "socks" })
port:depends({ type = "V2ray", protocol = "shadowsocks" })
port:depends({ type = "V2ray", protocol = "trojan" })
username = s:option(Value, "username", translate("Username"))
username:depends("type", "Socks")
username:depends("type", "Naiveproxy")
username:depends({ type = "Xray", protocol = "http" })
username:depends({ type = "Xray", protocol = "socks" })
username:depends({ type = "V2ray", protocol = "http" })
username:depends({ type = "V2ray", protocol = "socks" })
password = s:option(Value, "password", translate("Password"))
password.password = true
@ -286,10 +270,6 @@ password:depends({ type = "Xray", protocol = "http" })
password:depends({ type = "Xray", protocol = "socks" })
password:depends({ type = "Xray", protocol = "shadowsocks" })
password:depends({ type = "Xray", protocol = "trojan" })
password:depends({ type = "V2ray", protocol = "http" })
password:depends({ type = "V2ray", protocol = "socks" })
password:depends({ type = "V2ray", protocol = "shadowsocks" })
password:depends({ type = "V2ray", protocol = "trojan" })
ss_encrypt_method = s:option(ListValue, "ss_encrypt_method", translate("Encrypt Method"))
for a, t in ipairs(ss_encrypt_method_list) do ss_encrypt_method:value(t) end
@ -314,12 +294,10 @@ end
security = s:option(ListValue, "security", translate("Encrypt Method"))
for a, t in ipairs(security_list) do security:value(t) end
security:depends({ type = "Xray", protocol = "vmess" })
security:depends({ type = "V2ray", protocol = "vmess" })
encryption = s:option(Value, "encryption", translate("Encrypt Method"))
encryption.default = "none"
encryption:depends({ type = "Xray", protocol = "vless" })
encryption:depends({ type = "V2ray", protocol = "vless" })
v_ss_encrypt_method = s:option(ListValue, "v_ss_encrypt_method", translate("Encrypt Method"))
for a, t in ipairs(v_ss_encrypt_method_list) do v_ss_encrypt_method:value(t) end
@ -411,8 +389,6 @@ uuid = s:option(Value, "uuid", translate("ID"))
uuid.password = true
uuid:depends({ type = "Xray", protocol = "vmess" })
uuid:depends({ type = "Xray", protocol = "vless" })
uuid:depends({ type = "V2ray", protocol = "vmess" })
uuid:depends({ type = "V2ray", protocol = "vless" })
alter_id = s:option(Value, "alter_id", translate("Alter ID"))
alter_id:depends("protocol", "vmess")
@ -433,11 +409,6 @@ tls:depends({ type = "Xray", protocol = "vless" })
tls:depends({ type = "Xray", protocol = "socks" })
tls:depends({ type = "Xray", protocol = "trojan" })
tls:depends({ type = "Xray", protocol = "shadowsocks" })
tls:depends({ type = "V2ray", protocol = "vmess" })
tls:depends({ type = "V2ray", protocol = "vless" })
tls:depends({ type = "V2ray", protocol = "socks" })
tls:depends({ type = "V2ray", protocol = "shadowsocks" })
tls:depends({ type = "Xray", protocol = "trojan" })
tls:depends("type", "Trojan")
tls:depends("type", "Trojan-Plus")
tls:depends("type", "Trojan-Go")
@ -526,11 +497,6 @@ transport:depends({ type = "Xray", protocol = "vless" })
transport:depends({ type = "Xray", protocol = "socks" })
transport:depends({ type = "Xray", protocol = "shadowsocks" })
transport:depends({ type = "Xray", protocol = "trojan" })
transport:depends({ type = "V2ray", protocol = "vmess" })
transport:depends({ type = "V2ray", protocol = "vless" })
transport:depends({ type = "V2ray", protocol = "socks" })
transport:depends({ type = "V2ray", protocol = "shadowsocks" })
transport:depends({ type = "V2ray", protocol = "trojan" })
--[[
ss_transport = s:option(ListValue, "ss_transport", translate("Transport"))
@ -538,7 +504,6 @@ ss_transport:value("ws", "WebSocket")
ss_transport:value("h2", "HTTP/2")
ss_transport:value("h2+ws", "HTTP/2 & WebSocket")
ss_transport:depends({ type = "Xray", protocol = "shadowsocks" })
ss_transport:depends({ type = "V2ray", protocol = "shadowsocks" })
]]--
-- [[ TCP部分 ]]--
@ -658,11 +623,6 @@ mux:depends({ type = "Xray", protocol = "vless", xtls = false })
mux:depends({ type = "Xray", protocol = "http" })
mux:depends({ type = "Xray", protocol = "socks" })
mux:depends({ type = "Xray", protocol = "shadowsocks" })
mux:depends({ type = "V2ray", protocol = "vmess" })
mux:depends({ type = "V2ray", protocol = "vless" })
mux:depends({ type = "V2ray", protocol = "http" })
mux:depends({ type = "V2ray", protocol = "socks" })
mux:depends({ type = "V2ray", protocol = "shadowsocks" })
mux:depends("type", "Trojan-Go")
mux_concurrency = s:option(Value, "mux_concurrency", translate("Mux Concurrency"))
@ -674,7 +634,6 @@ mux_concurrency:depends("mux", "1")
tcp_socks = s:option(Flag, "tcp_socks", translate("TCP Open Socks"), translate("When using this TCP node, whether to open the socks proxy at the same time"))
tcp_socks.default = 0
tcp_socks:depends("type", "Xray")
tcp_socks:depends("type", "V2ray")
tcp_socks_port = s:option(Value, "tcp_socks_port", "Socks " .. translate("Port"), translate("Do not conflict with other ports"))
tcp_socks_port.datatype = "port"

View File

@ -63,7 +63,7 @@ if nodes_display:find("compact_display_nodes") then
local remarks = m:get(n, "remarks") or ""
local type = m:get(n, "type") or ""
str = str .. string.format("<input type='hidden' id='cbid.%s.%s.type' value='%s'/>", appname, n, type)
if type == "Xray" or type == "V2ray" then
if type == "Xray" then
local protocol = m:get(n, "protocol")
if protocol == "_balancing" then
type = type .. " 负载均衡"
@ -106,7 +106,7 @@ else
local v = Value.cfgvalue(t, n)
if v then
result = translate(v)
if v == "Xray" or v == "V2ray" then
if v == "Xray" then
local protocol = m:get(n, "protocol")
if protocol == "_balancing" then
result = result .. " 负载均衡"

View File

@ -49,7 +49,7 @@ for e = 0, 23 do o:value(e, e .. translate("oclock")) end
o.default = 0
o:depends("auto_update", 1)
s = m:section(TypedSection, "shunt_rules", "Xray/V2ray" .. translate("Shunt") .. translate("Rule"))
s = m:section(TypedSection, "shunt_rules", "Xray" .. translate("Shunt") .. translate("Rule"))
s.template = "cbi/tblsection"
s.anonymous = false
s.addremove = true

View File

@ -1,7 +1,7 @@
local d = require "luci.dispatcher"
local appname = "passwall"
m = Map(appname, "Xray/V2ray" .. translate("Shunt") .. translate("Rule"))
m = Map(appname, "Xray" .. translate("Shunt") .. translate("Rule"))
m.redirect = d.build_url("admin", "services", appname)
s = m:section(NamedSection, arg[1], "shunt_rules", "")

View File

@ -112,9 +112,6 @@ local function start()
elseif type == "Xray" then
config = require("luci.model.cbi.passwall.server.api.xray").gen_config(user)
bin = ln_start(_api.get_xray_path(), "xray", "-config=" .. config_file, log_path)
elseif type == "V2ray" then
config = require("luci.model.cbi.passwall.server.api.v2ray").gen_config(user)
bin = ln_start(_api.get_v2ray_path(), "v2ray", "-config=" .. config_file, log_path)
elseif type == "Trojan" then
config = require("luci.model.cbi.passwall.server.api.trojan").gen_config(user)
bin = ln_start("/usr/sbin/trojan", "trojan", "-c " .. config_file, log_path)

View File

@ -1,177 +0,0 @@
module("luci.model.cbi.passwall.server.api.v2ray", package.seeall)
local ucic = require"luci.model.uci".cursor()
function gen_config(user)
local settings = nil
local routing = nil
local outbounds = {
{protocol = "freedom", tag = "direct"}, {protocol = "blackhole", tag = "blocked"}
}
if user.protocol == "vmess" or user.protocol == "vless" then
if user.uuid then
local clients = {}
for i = 1, #user.uuid do
clients[i] = {
id = user.uuid[i],
flow = user.flow or nil,
level = tonumber(user.level),
alterId = tonumber(user.alter_id)
}
end
settings = {
clients = clients,
decryption = user.decryption or "none"
}
end
elseif user.protocol == "socks" then
settings = {
auth = (user.auth and user.auth == "1") and "password" or "noauth",
accounts = (user.auth and user.auth == "1") and {
{
user = user.username,
pass = user.password
}
}
}
elseif user.protocol == "http" then
settings = {
allowTransparent = false,
accounts = (user.auth and user.auth == "1") and {
{
user = user.username,
pass = user.password
}
}
}
user.transport = "tcp"
user.tcp_guise = "none"
elseif user.protocol == "shadowsocks" then
settings = {
method = user.method,
password = user.password,
level = tonumber(user.level) or 1,
network = user.ss_network or "TCP,UDP"
}
elseif user.protocol == "trojan" then
if user.uuid then
local clients = {}
for i = 1, #user.uuid do
clients[i] = {
password = user.uuid[i],
level = tonumber(user.level)
}
end
settings = {
clients = clients
}
end
elseif user.protocol == "mtproto" then
settings = {
users = {
{
level = tonumber(user.level) or 1,
secret = (user.password == nil) and "" or user.password
}
}
}
end
routing = {
domainStrategy = "IPOnDemand",
rules = {
{
type = "field",
ip = {"10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"},
outboundTag = (user.accept_lan == nil or user.accept_lan == "0") and "blocked" or "direct"
}
}
}
if user.transit_node and user.transit_node ~= "nil" then
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 = {
log = {
-- error = "/var/etc/passwall_server/log/" .. user[".name"] .. ".log",
loglevel = (user.log and user.log == "1") and user.loglevel or "none"
},
-- 传入连接
inbounds = {
{
listen = (user.bind_local == "1") and "127.0.0.1" or nil,
port = tonumber(user.port),
protocol = user.protocol,
settings = settings,
streamSettings = {
network = user.transport,
security = "none",
tlsSettings = (user.tls and user.tls == "1") and {
disableSystemRoot = false,
certificates = {
{
certificateFile = user.tls_certificateFile,
keyFile = user.tls_keyFile
}
}
} or nil,
tcpSettings = (user.transport == "tcp") and {
header = {
type = user.tcp_guise,
request = (user.tcp_guise == "http") and {
path = user.tcp_guise_http_path or {"/"},
headers = {
Host = user.tcp_guise_http_host or {}
}
} or nil
}
} or nil,
kcpSettings = (user.transport == "mkcp") and {
mtu = tonumber(user.mkcp_mtu),
tti = tonumber(user.mkcp_tti),
uplinkCapacity = tonumber(user.mkcp_uplinkCapacity),
downlinkCapacity = tonumber(user.mkcp_downlinkCapacity),
congestion = (user.mkcp_congestion == "1") and true or false,
readBufferSize = tonumber(user.mkcp_readBufferSize),
writeBufferSize = tonumber(user.mkcp_writeBufferSize),
seed = (user.mkcp_seed and user.mkcp_seed ~= "") and user.mkcp_seed or nil,
header = {type = user.mkcp_guise}
} or nil,
wsSettings = (user.transport == "ws") and {
acceptProxyProtocol = false,
headers = (user.ws_host) and {Host = user.ws_host} or nil,
path = user.ws_path
} or nil,
httpSettings = (user.transport == "h2") and {
path = user.h2_path, host = user.h2_host
} or nil,
dsSettings = (user.transport == "ds") and {
path = user.ds_path
} or nil,
quicSettings = (user.transport == "quic") and {
security = user.quic_security,
key = user.quic_key,
header = {type = user.quic_guise}
} or nil
}
}
},
-- 传出连接
outbounds = outbounds,
routing = routing
}
if user.tls and user.tls == "1" then
config.inbounds[1].streamSettings.security = "tls"
end
if user.transport == "mkcp" or user.transport == "quic" then
config.inbounds[1].streamSettings.security = "none"
config.inbounds[1].streamSettings.tlsSettings = nil
end
return config
end

View File

@ -47,7 +47,7 @@ e = t:option(DummyValue, "type", translate("Type"))
e.cfgvalue = function(t, n)
local v = Value.cfgvalue(t, n)
if v then
if v == "Xray" or v == "V2ray" then
if v == "Xray" then
local protocol = m:get(n, "protocol")
return v .. " -> " .. protocol
end

View File

@ -80,9 +80,6 @@ end
if api.is_finded("xray") then
type:value("Xray", translate("Xray"))
end
if api.is_finded("v2ray") then
type:value("V2ray", translate("V2ray"))
end
if api.is_finded("brook") then
type:value("Brook", translate("Brook"))
end
@ -107,7 +104,6 @@ protocol:value("shadowsocks", "Shadowsocks")
protocol:value("trojan", "Trojan")
protocol:value("mtproto", "MTProto")
protocol:depends("type", "Xray")
protocol:depends("type", "V2ray")
-- Brook协议
brook_protocol = s:option(ListValue, "brook_protocol", translate("Protocol"))
@ -142,8 +138,6 @@ end
auth:depends("type", "Socks")
auth:depends({ type = "Xray", protocol = "socks" })
auth:depends({ type = "Xray", protocol = "http" })
auth:depends({ type = "V2ray", protocol = "socks" })
auth:depends({ type = "V2ray", protocol = "http" })
username = s:option(Value, "username", translate("Username"))
username:depends("auth", "1")
@ -155,11 +149,9 @@ password:depends("type", "SS")
password:depends("type", "SSR")
password:depends("type", "Brook")
password:depends({ type = "Xray", protocol = "shadowsocks" })
password:depends({ type = "V2ray", protocol = "shadowsocks" })
mtproto_password = s:option(Value, "mtproto_password", translate("Password"), translate("The MTProto protocol must be 32 characters and can only contain characters from 0 to 9 and a to f."))
mtproto_password:depends({ type = "Xray", protocol = "mtproto" })
mtproto_password:depends({ type = "V2ray", protocol = "mtproto" })
mtproto_password.default = arg[1]
function mtproto_password.cfgvalue(self, section)
return m:get(section, "password")
@ -171,7 +163,6 @@ end
decryption = s:option(Value, "decryption", translate("Encrypt Method"))
decryption.default = "none"
decryption:depends({ type = "Xray", protocol = "vless" })
decryption:depends({ type = "V2ray", protocol = "vless" })
ss_encrypt_method = s:option(ListValue, "ss_encrypt_method", translate("Encrypt Method"))
for a, t in ipairs(ss_encrypt_method_list) do ss_encrypt_method:value(t) end
@ -196,7 +187,6 @@ end
v_ss_encrypt_method = s:option(ListValue, "v_ss_encrypt_method", translate("Encrypt Method"))
for a, t in ipairs(v_ss_encrypt_method_list) do v_ss_encrypt_method:value(t) end
v_ss_encrypt_method:depends({ type = "Xray", protocol = "shadowsocks" })
v_ss_encrypt_method:depends({ type = "V2ray", protocol = "shadowsocks" })
function v_ss_encrypt_method.cfgvalue(self, section)
return m:get(section, "method")
end
@ -210,7 +200,6 @@ ss_network:value("tcp", "TCP")
ss_network:value("udp", "UDP")
ss_network:value("tcp,udp", "TCP,UDP")
ss_network:depends({ type = "Xray", protocol = "shadowsocks" })
ss_network:depends({ type = "V2ray", protocol = "shadowsocks" })
ssr_protocol = s:option(ListValue, "ssr_protocol", translate("Protocol"))
for a, t in ipairs(ssr_protocol_list) do ssr_protocol:value(t) end
@ -250,16 +239,12 @@ end
uuid:depends({ type = "Xray", protocol = "vmess" })
uuid:depends({ type = "Xray", protocol = "vless" })
uuid:depends({ type = "Xray", protocol = "trojan" })
uuid:depends({ type = "V2ray", protocol = "vmess" })
uuid:depends({ type = "V2ray", protocol = "vless" })
uuid:depends({ type = "V2ray", protocol = "trojan" })
uuid:depends("type", "Trojan")
uuid:depends("type", "Trojan-Go")
uuid:depends("type", "Trojan-Plus")
alter_id = s:option(Value, "alter_id", translate("Alter ID"))
alter_id:depends({ type = "Xray", protocol = "vmess" })
alter_id:depends({ type = "V2ray", protocol = "vmess" })
level = s:option(Value, "level", translate("User Level"))
level:depends({ type = "Xray", protocol = "vmess" })
@ -267,11 +252,6 @@ level:depends({ type = "Xray", protocol = "vless" })
level:depends({ type = "Xray", protocol = "shadowsocks" })
level:depends({ type = "Xray", protocol = "trojan" })
level:depends({ type = "Xray", protocol = "mtproto" })
level:depends({ type = "V2ray", protocol = "vmess" })
level:depends({ type = "V2ray", protocol = "vless" })
level:depends({ type = "V2ray", protocol = "shadowsocks" })
level:depends({ type = "V2ray", protocol = "trojan" })
level:depends({ type = "V2ray", protocol = "mtproto" })
tls = s:option(Flag, "tls", translate("TLS"))
tls.default = 0
@ -296,10 +276,6 @@ 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" })
tls:depends({ type = "V2ray", protocol = "shadowsocks" })
tls:depends("type", "Trojan")
tls:depends("type", "Trojan-Plus")
tls:depends("type", "Trojan-Go")
@ -374,11 +350,6 @@ transport:depends({ type = "Xray", protocol = "vless" })
transport:depends({ type = "Xray", protocol = "socks" })
transport:depends({ type = "Xray", protocol = "shadowsocks" })
transport:depends({ type = "Xray", protocol = "trojan" })
transport:depends({ type = "V2ray", protocol = "vmess" })
transport:depends({ type = "V2ray", protocol = "vless" })
transport:depends({ type = "V2ray", protocol = "socks" })
transport:depends({ type = "V2ray", protocol = "shadowsocks" })
transport:depends({ type = "V2ray", protocol = "trojan" })
trojan_transport = s:option(ListValue, "trojan_transport", translate("Transport"))
trojan_transport:value("original", "Original")
@ -512,15 +483,11 @@ quic_guise:depends("transport", "quic")
acceptProxyProtocol = s:option(Flag, "acceptProxyProtocol", translate("acceptProxyProtocol"), translate("Whether to receive PROXY protocol, when this node want to be fallback or forwarded by proxy, it must be enable, otherwise it cannot be used."))
acceptProxyProtocol:depends({ type = "Xray", transport = "tcp" })
acceptProxyProtocol:depends({ type = "Xray", transport = "ws" })
acceptProxyProtocol:depends({ type = "V2ray", transport = "tcp" })
acceptProxyProtocol:depends({ type = "V2ray", transport = "ws" })
-- [[ Fallback部分 ]]--
fallback = s:option(Flag, "fallback", translate("Fallback"))
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")
@ -580,17 +547,15 @@ remote_port:depends("remote_enable", 1)
bind_local = s:option(Flag, "bind_local", translate("Bind Local"), translate("When selected, it can only be accessed locally, It is recommended to turn on when using reverse proxies or be fallback."))
bind_local.default = "0"
bind_local:depends("type", "Xray")
bind_local:depends("type", "V2ray")
accept_lan = s:option(Flag, "accept_lan", translate("Accept LAN Access"), translate("When selected, it can accessed lan , this will not be safe!"))
accept_lan.default = "0"
accept_lan.rmempty = false
accept_lan:depends("type", "Xray")
accept_lan:depends("type", "V2ray")
local nodes_table = {}
for k, e in ipairs(api.get_valid_nodes()) do
if e.node_type == "normal" and e.type == "Xray" or e.type == "V2ray" then
if e.node_type == "normal" and e.type == "Xray" then
nodes_table[#nodes_table + 1] = {
id = e[".name"],
remarks = e.remarks_name
@ -603,7 +568,6 @@ transit_node:value("nil", translate("Close"))
for k, v in pairs(nodes_table) do transit_node:value(v.id, v.remarks) end
transit_node.default = "nil"
transit_node:depends("type", "Xray")
transit_node:depends("type", "V2ray")
log = s:option(Flag, "log", translate("Enable") .. translate("Log"))
log.default = "1"
@ -616,7 +580,6 @@ loglevel:value("info")
loglevel:value("warning")
loglevel:value("error")
loglevel:depends({ type = "Xray", log = true })
loglevel:depends({ type = "V2ray", log = true })
trojan_loglevel = s:option(ListValue, "trojan_loglevel", translate("Log Level"))
trojan_loglevel.default = "2"

View File

@ -1,172 +0,0 @@
<%
local v2ray_version = require "luci.model.cbi.passwall.api.api".get_v2ray_version()
-%>
<script type="text/javascript">
//<![CDATA[
var v2rayInfo;
var tokenStr = '<%=token%>';
var manuallyUpdateText = '<%:Manually update%>';
var noUpdateText = '<%:It is the latest version%>';
var updateSuccessText = '<%:Update successful%>';
var clickToUpdateText = '<%:Click to update%>';
var inProgressText = '<%:Updating...%>';
var unexpectedErrorText = '<%:Unexpected error%>';
var updateInProgressNotice = '<%:Updating, are you sure to close?%>';
var downloadingText = '<%:Downloading...%>';
var decompressioningText = '<%:Unpacking...%>';
var movingText = '<%:Moving...%>';
window.onload = function() {
var v2rayCheckBtn = document.getElementById('_v2ray-check_btn');
var v2rayDetailElm = document.getElementById('_v2ray-check_btn-detail');
};
function addPageNotice_v2ray() {
window.onbeforeunload = function(e) {
e.returnValue = updateInProgressNotice;
return updateInProgressNotice;
};
}
function removePageNotice_v2ray() {
window.onbeforeunload = undefined;
}
function onUpdateSuccess_v2ray(btn) {
alert(updateSuccessText);
if(btn) {
btn.value = updateSuccessText;
btn.placeholder = updateSuccessText;
btn.disabled = true;
}
window.setTimeout(function() {
window.location.reload();
}, 1000);
}
function onRequestError_v2ray(btn, errorMessage) {
btn.disabled = false;
btn.value = manuallyUpdateText;
if(errorMessage) {
alert(errorMessage);
}
}
function onBtnClick_v2ray(btn) {
if(v2rayInfo === undefined) {
checkUpdate_v2ray(btn);
} else {
doUpdate_v2ray(btn);
}
}
function checkUpdate_v2ray(btn) {
btn.disabled = true;
btn.value = inProgressText;
addPageNotice_v2ray();
var ckeckDetailElm = document.getElementById(btn.id + '-detail');
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[v2ray_check]])%>', {
token: tokenStr,
arch: ''
}, function(x,json) {
removePageNotice_v2ray();
if(json.code) {
v2rayInfo = undefined;
onRequestError_v2ray(btn, json.error);
} else {
if(json.update) {
v2rayInfo = json;
btn.disabled = false;
btn.value = clickToUpdateText;
btn.placeholder = clickToUpdateText;
if(ckeckDetailElm) {
var urlNode = '';
if(json.version) {
urlNode = '<em style="color:red;">最新版本号:' + json.version + '</em>';
if(json.url && json.url.html) {
urlNode = '<a href="' + json.url.html + '" target="_blank">' + urlNode + '</a>';
}
}
ckeckDetailElm.innerHTML = urlNode;
}
} else {
btn.disabled = true;
btn.value = noUpdateText;
}
}
},300);
}
function doUpdate_v2ray(btn) {
btn.disabled = true;
btn.value = downloadingText;
addPageNotice_v2ray();
var v2rayUpdateUrl = '<%=url([[admin]], [[services]], [[passwall]], [[v2ray_update]])%>';
// Download file
XHR.get(v2rayUpdateUrl, {
token: tokenStr,
url: v2rayInfo ? v2rayInfo.url.download : ''
}, function(x,json) {
if(json.code) {
removePageNotice_v2ray();
onRequestError_v2ray(btn, json.error);
} else {
btn.value = decompressioningText;
// Extract file
XHR.get(v2rayUpdateUrl, {
token: tokenStr,
task: 'extract',
file: json.file,
subfix: v2rayInfo ? v2rayInfo.type : ''
}, function(x,json) {
if(json.code) {
removePageNotice_v2ray();
onRequestError_v2ray(btn, json.error);
} else {
btn.value = movingText;
// Move file to target dir
XHR.get(v2rayUpdateUrl, {
token: tokenStr,
task: 'move',
file: json.file
}, function(x,json) {
removePageNotice_v2ray();
if(json.code) {
onRequestError_v2ray(btn, json.error);
} else {
onUpdateSuccess_v2ray(btn);
}
},300)
}
},300)
}
},300)
}
//]]>
</script>
<div class="cbi-value">
<label class="cbi-value-title">V2ray
<%:Version%>
</label>
<div class="cbi-value-field">
<div class="cbi-value-description">
<span><%=v2ray_version%> 】</span>
<input class="cbi-button cbi-input-apply" type="button" id="_v2ray-check_btn" onclick="onBtnClick_v2ray(this);" value="<%:Manually update%>" />
<span id="_v2ray-check_btn-detail"></span>
</div>
</div>
</div>

View File

@ -1,8 +1,6 @@
<%+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) {
@ -314,6 +312,8 @@ local api = require "luci.model.cbi.passwall.api.api"
if (ploc > 0) {
url0 = sstr.substr(0, ploc);
param = sstr.substr(ploc + 2);
} else {
var url0 = sstr;
}
console.log(param);
var ssm = url0.match(/^(.+):([^:]+):([^:]*):([^:]+):([^:]*):([^:]+)/);
@ -556,10 +556,7 @@ local api = require "luci.model.cbi.passwall.api.api"
} else if (ssu[0] === "vmess") {
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.set('type', "Xray");
opt.get('type').dispatchEvent(event);
var url0, param = "";
if (ploc > 0) {

View File

@ -412,6 +412,9 @@ msgstr "前置代理"
msgid "Use the default node for the transit."
msgstr "使用默认节点代理转发。"
msgid "Use the under node for the transit."
msgstr "使用下面的节点代理转发。"
msgid "No shunt rules? Click me to go to add."
msgstr "没有分流规则?点我前往去添加。"

View File

@ -50,7 +50,6 @@ config global_rules
config global_app
option xray_file '/usr/bin/xray'
option v2ray_file '/usr/bin/v2ray'
option trojan_go_file '/usr/bin/trojan-go'
option kcptun_client_file '/usr/bin/kcptun-client'
option brook_file '/usr/bin/brook'

View File

@ -317,13 +317,13 @@ load_config() {
}
run_socks() {
local node=$1
local bind=$2
local socks_port=$3
local config_file=$4
local http_port=$5
local http_config_file=$6
local id=$7
local flag=$1
local node=$2
local bind=$3
local socks_port=$4
local config_file=$5
local http_port=$6
local http_config_file=$7
local relay_port=$8
local log_file="/dev/null"
local type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
@ -344,7 +344,7 @@ run_socks() {
msg="某种原因,此 Socks 服务的相关配置已失联,启动中止!"
fi
if [ "$type" == "xray" -o "$type" == "v2ray" ] && ([ -n "$(config_n_get $node balancing_node)" ] || [ "$(config_n_get $node default_node)" != "nil" ]); then
if [ "$type" == "xray" ] && ([ -n "$(config_n_get $node balancing_node)" ] || [ "$(config_n_get $node default_node)" != "nil" ]); then
unset msg
fi
@ -355,13 +355,8 @@ run_socks() {
[ "$bind" != "127.0.0.1" ] && echolog " - 启动 ${bind}:${socks_port} - 节点:$remarks${tmp}"
case "$type" in
socks)
_username=$(config_n_get $node username)
_password=$(config_n_get $node password)
[ -n "$_username" ] && [ -n "$_password" ] && local _auth="--uname $_username --passwd $_password"
ln_start_bin "$(first_type ssocks)" ssocks_SOCKS_$id $log_file --listen $socks_port --socks $server_host:$port $_auth
;;
xray|v2ray)
socks|\
xray)
[ "$http_port" != "0" ] && {
local extra_param="-http_proxy_port $http_port"
config_file=$(echo $config_file | sed "s/SOCKS/HTTP_SOCKS/g")
@ -387,7 +382,7 @@ run_socks() {
[ "$protocol" == "wsclient" ] && {
[ "$brook_tls" == "1" ] && server_host="wss://${server_host}" || server_host="ws://${server_host}"
}
ln_start_bin "$(first_type $(config_t_get global_app brook_file) brook)" "brook_SOCKS_$id" $log_file "$protocol" --socks5 "$bind:$socks_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_SOCKS_${flag}" $log_file "$protocol" --socks5 "$bind:$socks_port" -s "$server_host:$port" -p "$(config_n_get $node password)"
;;
ss|ssr)
lua $API_GEN_SS -node $node -local_addr "0.0.0.0" -local_port $socks_port -server_host $server_host -server_port $port > $config_file
@ -396,12 +391,11 @@ run_socks() {
esac
# socks to http
[ "$type" != "xray" -a "$type" != "v2ray" ] && [ "$http_port" != "0" ] && [ "$http_config_file" != "nil" ] && {
[ "$type" != "xray" ] && [ "$type" != "socks" ] && [ "$http_port" != "0" ] && [ "$http_config_file" != "nil" ] && {
lua $API_GEN_XRAY_PROTO -local_proto http -local_address "0.0.0.0" -local_port $http_port -server_proto socks -server_address "127.0.0.1" -server_port $socks_port -server_username $_username -server_password $_password > $http_config_file
echo lua $API_GEN_XRAY_PROTO -local_proto http -local_address "0.0.0.0" -local_port $http_port -server_proto socks -server_address "127.0.0.1" -server_port $socks_port -server_username $_username -server_password $_password
ln_start_bin "$(first_type $(config_t_get global_app xray_file) xray)" xray $log_file -config="$http_config_file"
}
unset _username _password _auth
}
run_redir() {
@ -444,7 +438,7 @@ run_redir() {
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 -v
;;
xray|v2ray)
xray)
local loglevel=$(config_t_get global loglevel "warning")
lua $API_GEN_XRAY -node $node -proto udp -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"
@ -506,18 +500,20 @@ run_redir() {
;;
xray)
local loglevel=$(config_t_get global loglevel "warning")
local extra_param="tcp"
[ "$UDP_NODE" == "tcp" ] && extra_param="tcp,udp"
lua $API_GEN_XRAY -node $node -proto $extra_param -redir_port $local_port -loglevel $loglevel > $config_file
local proto="-proto tcp"
[ "$UDP_NODE" == "tcp" ] && proto="-proto tcp,udp"
local extra_param="${proto}"
[ "$(config_t_get global tcp_node_socks 0)" = "1" ] && {
local socks_param="-socks_proxy_port $(config_t_get global tcp_node_socks_port 1080)"
extra_param="${extra_param} ${socks_param}"
}
[ "$(config_t_get global tcp_node_http 0)" = "1" ] && {
local http_param="-http_proxy_port $(config_t_get global tcp_node_http_port 1180)"
extra_param="${extra_param} ${http_param}"
}
lua $API_GEN_XRAY -node $node -redir_port $local_port -loglevel $loglevel $extra_param > $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"
[ "$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"
;;
trojan-go)
local loglevel=$(config_t_get global trojan_loglevel "2")
lua $API_GEN_TROJAN -node $node -run_type nat -local_addr "0.0.0.0" -local_port $local_port -loglevel $loglevel > $config_file
@ -614,22 +610,32 @@ start_redir() {
}
start_socks() {
[ "$(config_n_get $TCP_NODE type nil)" != "xray" ] && {
[ "$(config_t_get global tcp_node_socks 0)" = "1" ] && {
local port=$(config_t_get global tcp_node_socks_port 1080)
local config_file=$TMP_PATH/SOCKS_TCP.json
local log_file=$TMP_PATH/SOCKS_TCP.log
}
local http_port=0
local http_config_file=$TMP_PATH/HTTP2SOCKS_TCP.json
[ "$(config_t_get global tcp_node_http 0)" = "1" ] && {
http_port=$(config_t_get global tcp_node_http_port 1180)
}
run_socks TCP $TCP_NODE "0.0.0.0" $port $config_file $http_port $http_config_file
}
local ids=$(uci show $CONFIG | grep "=socks" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
echolog "分析 Socks 服务的节点配置..."
for id in $ids; do
local enabled=$(config_n_get $id enabled 0)
[ "$enabled" == "0" ] && continue
local node=$(config_n_get $id node nil)
if [ "$(echo $node | grep ^tcp)" ]; then
eval node=\$TCP_NODE
fi
[ "$node" == "nil" ] && continue
local port=$(config_n_get $id port)
local config_file=$TMP_PATH/SOCKS_${id}.json
local log_file=$TMP_PATH/SOCKS_${id}.log
local http_port=$(config_n_get $id http_port 0)
local http_config_file=$TMP_PATH/HTTP2SOCKS_${id}.json
run_socks $node "0.0.0.0" $port $config_file $http_port $http_config_file $id
run_socks $id $node "0.0.0.0" $port $config_file $http_port $http_config_file
done
}
@ -805,6 +811,11 @@ start_dns() {
TUN_DNS=""
;;
dns2socks)
local dns2socks_socks_server=$(echo $(config_t_get global socks_server 127.0.0.1:9050) | sed "s/#/:/g")
local dns2socks_forward=$(get_first_dns DNS_FORWARD 53 | sed 's/#/:/g')
[ "$DNS_CACHE" == "0" ] && local dns2sock_cache="/d"
ln_start_bin "$(first_type dns2socks)" dns2socks "/dev/null" "$dns2socks_socks_server" "$dns2socks_forward" "127.0.0.1:$dns_listen_port" $dns2sock_cache
echolog " - dns2sock(127.0.0.1:${dns_listen_port}${dns2sock_cache})${dns2socks_socks_server:-127.0.0.1:9050} -> ${dns2socks_forward-D8.8.8.8:53}"
echolog " - 域名解析dns2socks..."
;;
xray_doh)
@ -816,29 +827,6 @@ start_dns() {
use_tcp_node_resolve_dns=1
msg="TCP节点"
fi
echolog " - 域名解析 Xray DNS(DOH)..."
;;
pdnsd)
echolog " - 域名解析pdnsd + 使用(TCP节点)解析域名..."
;;
udp)
use_udp_node_resolve_dns=1
TUN_DNS=${DNS_FORWARD}
echolog " - 域名解析直接使用UDP节点请求DNS$TUN_DNS"
;;
custom)
[ "$CHINADNS_NG" != "1" ] && {
custom_dns=$(config_t_get global custom_dns)
TUN_DNS="$(echo ${custom_dns} | sed 's/:/#/g')"
echolog " - 域名解析直接使用UDP协议自定义DNS$TUN_DNS)解析..."
}
;;
esac
if [ -n "$(echo ${DNS_MODE} | grep pdnsd)" ]; then
gen_pdnsd_config "${dns_listen_port}" "${pdnsd_forward}"
ln_start_bin "$(first_type pdnsd)" pdnsd "/dev/null" --daemon -c "${TMP_PATH}/pdnsd/pdnsd.conf" -d
fi
if [ -n "$(echo ${DNS_MODE} | grep 'xray_doh')" ]; then
up_trust_doh=$(config_t_get global up_trust_doh "https://dns.google/dns-query,8.8.4.4")
_doh_url=$(echo $up_trust_doh | awk -F ',' '{print $1}')
_doh_host_port=$(echo $_doh_url | sed "s/https:\/\///g" | awk -F '/' '{print $1}')
@ -865,7 +853,27 @@ start_dns() {
unset _dns _doh_bootstrap_dns
fi
unset _doh_url _doh_port _doh_bootstrap
fi
echolog " - 域名解析 Xray DNS(DOH)..."
;;
pdnsd)
gen_pdnsd_config "${dns_listen_port}" "${pdnsd_forward}"
ln_start_bin "$(first_type pdnsd)" pdnsd "/dev/null" --daemon -c "${TMP_PATH}/pdnsd/pdnsd.conf" -d
echolog " - 域名解析pdnsd + 使用(TCP节点)解析域名..."
;;
udp)
use_udp_node_resolve_dns=1
TUN_DNS=${DNS_FORWARD}
echolog " - 域名解析直接使用UDP节点请求DNS$TUN_DNS"
;;
custom)
[ "$CHINADNS_NG" != "1" ] && {
custom_dns=$(config_t_get global custom_dns)
TUN_DNS="$(echo ${custom_dns} | sed 's/:/#/g')"
echolog " - 域名解析直接使用UDP协议自定义DNS$TUN_DNS)解析..."
}
;;
esac
[ "${use_udp_node_resolve_dns}" = "1" ] && echolog " * 要求代理 DNS 请求,如上游 DNS 非直连地址,确保 UDP 代理打开,并且已经正确转发!"
[ "${use_tcp_node_resolve_dns}" = "1" ] && echolog " * 请确认上游 DNS 支持 TCP 查询,如非直连地址,确保 TCP 代理打开,并且已经正确转发!"
}

View File

@ -35,7 +35,8 @@ dst() {
}
comment() {
echo "-m comment --comment '$1'"
local name=$(echo $1 | sed 's/ /_/g')
echo "-m comment --comment '$name'"
}
RULE_LAST_INDEX() {
@ -222,7 +223,7 @@ load_acl() {
[ "$UDP_NO_REDIR_PORTS" != "disable" ] && $ipt_m -A PSW $(comment "默认") -p udp -m multiport --dport $UDP_NO_REDIR_PORTS -j RETURN
[ "$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}外的"
[ "$UDP_NO_REDIR_PORTS" != "disable" ] && msg="${msg}${UDP_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_PORT TPROXY)
$ipt_m -A PSW $(comment "默认") -p udp $(factor $UDP_REDIR_PORTS "-m multiport --dport") $(dst $IPSET_BLACKLIST) $(REDIRECT $UDP_REDIR_PORT TPROXY)
@ -311,14 +312,21 @@ filter_node() {
elif [ "$proxy_protocol" == "_shunt" ]; then
#echolog " - 按请求目的地址分流(${proxy_type}..."
local default_node=$(config_n_get $proxy_node default_node nil)
filter_rules $default_node $stream
local default_proxy=$(config_n_get $proxy_node default_proxy 0)
if [ "$default_proxy" == 1 ]; then
local main_node=$(config_n_get $proxy_node main_node nil)
filter_rules $main_node $stream
else
filter_rules $default_node $stream
fi
:<<!
local default_node_address=$(get_host_ip ipv4 $(config_n_get $default_node address) 1)
local default_node_port=$(config_n_get $default_node port)
local shunt_ids=$(uci show $CONFIG | grep "=shunt_rules" | awk -F '.' '{print $2}' | awk -F '=' '{print $1}')
for shunt_id in $shunt_ids; do
local shunt_proxy=$(config_n_get $proxy_node "${shunt_id}_proxy" 0)
#local shunt_proxy=$(config_n_get $proxy_node "${shunt_id}_proxy" 0)
local shunt_proxy=0
local shunt_node=$(config_n_get $proxy_node "${shunt_id}" nil)
[ "$shunt_node" != "nil" ] && {
[ "$shunt_proxy" == 1 ] && {

View File

@ -3921,7 +3921,6 @@
103.142.96.0/23
103.142.102.0/23
103.142.122.0/23
103.142.126.0/24
103.142.128.0/23
103.142.140.0/23
103.142.154.0/23
@ -4123,6 +4122,7 @@
103.161.138.0/23
103.161.208.0/23
103.161.220.0/23
103.161.254.0/23
103.192.0.0/22
103.192.4.0/22
103.192.8.0/22

View File

@ -34,7 +34,6 @@
2001:df0:d180::/48
2001:df0:d880::/48
2001:df1:c80::/48
2001:df1:4180::/48
2001:df1:4580::/48
2001:df1:5280::/48
2001:df1:5b80::/48

View File

@ -163,6 +163,20 @@ do
ucic2:set(application, node_id, "default_node", server)
end
}
local main_node_id = node.main_node
local main_node
if main_node_id then
main_node = ucic2:get_all(application, main_node_id)
end
CONFIG[#CONFIG + 1] = {
log = false,
currentNode = main_node,
remarks = "分流默认前置代理节点",
set = function(server)
ucic2:set(application, node_id, "main_node", server)
end
}
elseif node.protocol and node.protocol == '_balancing' then
local node_id = node[".name"]
local nodes = {}
@ -340,10 +354,7 @@ local function processData(szType, content, add_mode)
result.remarks = base64Decode(params.remarks)
elseif szType == 'vmess' then
local info = jsonParse(content)
result.type = 'V2ray'
if api.is_finded("xray") then
result.type = 'Xray'
end
result.type = 'Xray'
result.address = info.add
result.port = info.port
result.protocol = 'vmess'

View File

@ -83,7 +83,7 @@ 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.json" "10"
/usr/share/passwall/app.sh run_socks "auto_switch" "$main_node" "127.0.0.1" "$tmp_port" "/var/etc/passwall/auto_switch.json"
local curlx="socks5h://127.0.0.1:$tmp_port"
fi
sleep 10s