luci-app-passwall: bump to 4-12
Signed-off-by: CN_SZTL <cnsztl@project-openwrt.eu.org>
This commit is contained in:
parent
e3f93a0b59
commit
eed5cdeb90
@ -1,5 +1,5 @@
|
||||
# Copyright (C) 2018-2020 L-WRT Team
|
||||
#
|
||||
# Copyright (C) 2021 xiaorouji
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
#
|
||||
|
||||
@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=4
|
||||
PKG_RELEASE:=10
|
||||
PKG_DATE:=20210122
|
||||
PKG_RELEASE:=12
|
||||
PKG_DATE:=20210127
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
-- Copyright (C) 2018-2020 L-WRT Team
|
||||
-- Copyright (C) 2021 xiaorouji
|
||||
|
||||
module("luci.controller.passwall", package.seeall)
|
||||
local appname = "passwall"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = api.appname
|
||||
local ucic = luci.model.uci.cursor()
|
||||
local http = require "luci.http"
|
||||
local util = require "luci.util"
|
||||
local i18n = require "luci.i18n"
|
||||
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 trojan_go = require "luci.model.cbi.passwall.api.trojan_go"
|
||||
local kcptun = require("luci.model.cbi." .. appname ..".api.kcptun")
|
||||
local brook = require("luci.model.cbi." .. appname ..".api.brook")
|
||||
local xray = require("luci.model.cbi." .. appname ..".api.xray")
|
||||
local trojan_go = require("luci.model.cbi." .. appname ..".api.trojan_go")
|
||||
|
||||
function index()
|
||||
appname = "passwall"
|
||||
appname = require "luci.model.cbi.passwall.api.api".appname
|
||||
entry({"admin", "services", appname}).dependent = true
|
||||
entry({"admin", "services", appname, "reset_config"}, call("reset_config")).leaf = true
|
||||
entry({"admin", "services", appname, "show"}, call("show_menu")).leaf = true
|
||||
@ -82,12 +84,12 @@ end
|
||||
|
||||
function reset_config()
|
||||
luci.sys.call('[ -f "/usr/share/passwall/config.default" ] && cp -f /usr/share/passwall/config.default /etc/config/passwall && /etc/init.d/passwall reload')
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname))
|
||||
luci.http.redirect(api.url())
|
||||
end
|
||||
|
||||
function show_menu()
|
||||
luci.sys.call("touch /etc/config/passwall_show")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname))
|
||||
luci.http.redirect(api.url())
|
||||
end
|
||||
|
||||
function hide_menu()
|
||||
@ -170,14 +172,14 @@ function status()
|
||||
-- local dns_mode = ucic:get(appname, "@global[0]", "dns_mode")
|
||||
local e = {}
|
||||
e.dns_mode_status = luci.sys.call("netstat -apn | grep ':7913 ' >/dev/null") == 0
|
||||
e.haproxy_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
|
||||
e["kcptun_tcp_node_status"] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/kcptun' | grep -i 'tcp' >/dev/null", appname)) == 0
|
||||
e["tcp_node_status"] = luci.sys.call(string.format("ps -w | grep -v -E 'grep|kcptun' | grep '%s/bin/' | grep -i 'TCP' >/dev/null", appname)) == 0
|
||||
e.haproxy_status = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0
|
||||
e["kcptun_tcp_node_status"] = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/kcptun' | grep -i 'tcp' >/dev/null", appname)) == 0
|
||||
e["tcp_node_status"] = luci.sys.call(string.format("top -bn1 | grep -v -E 'grep|kcptun' | grep '%s/bin/' | grep -i 'TCP' >/dev/null", appname)) == 0
|
||||
|
||||
if (ucic:get(appname, "@global[0]", "udp_node") or "nil") == "tcp" then
|
||||
e["udp_node_status"] = e["tcp_node_status"]
|
||||
else
|
||||
e["udp_node_status"] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep -i 'UDP' >/dev/null", appname)) == 0
|
||||
e["udp_node_status"] = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/' | grep -i 'UDP' >/dev/null", appname)) == 0
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
@ -188,12 +190,12 @@ function socks_status()
|
||||
local index = luci.http.formvalue("index")
|
||||
local id = luci.http.formvalue("id")
|
||||
e.index = index
|
||||
e.socks_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep '%s' | grep 'SOCKS_' > /dev/null", appname, id)) == 0
|
||||
e.socks_status = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/' | grep '%s' | grep 'SOCKS_' > /dev/null", appname, id)) == 0
|
||||
local use_http = ucic:get(appname, id, "http_port") or 0
|
||||
e.use_http = 0
|
||||
if tonumber(use_http) > 0 then
|
||||
e.use_http = 1
|
||||
e.http_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep '%s' | grep -E 'HTTP_|HTTP2SOCKS' > /dev/null", appname, id)) == 0
|
||||
e.http_status = luci.sys.call(string.format("top -bn1 | grep -v grep | grep '%s/bin/' | grep '%s' | grep -E 'HTTP_|HTTP2SOCKS' > /dev/null", appname, id)) == 0
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
@ -241,7 +243,7 @@ function set_node()
|
||||
ucic:set(appname, "@global[0]", protocol .. "_node", section)
|
||||
ucic:commit(appname)
|
||||
luci.sys.call("/etc/init.d/passwall restart > /dev/null 2>&1 &")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname, "log"))
|
||||
luci.http.redirect(api.url("log"))
|
||||
end
|
||||
|
||||
function copy_node()
|
||||
@ -260,7 +262,7 @@ function copy_node()
|
||||
end
|
||||
end
|
||||
ucic:commit(appname)
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname, "node_config", uuid))
|
||||
luci.http.redirect(api.url("node_config", uuid))
|
||||
end
|
||||
|
||||
function clear_all_nodes()
|
||||
@ -332,7 +334,7 @@ end
|
||||
function server_user_status()
|
||||
local e = {}
|
||||
e.index = luci.http.formvalue("index")
|
||||
e.status = luci.sys.call(string.format("ps -w | grep -v 'grep' | grep '%s/bin/' | grep -i '%s' >/dev/null", appname .. "_server", luci.http.formvalue("id"))) == 0
|
||||
e.status = luci.sys.call(string.format("top -bn1 | grep -v 'grep' | grep '%s/bin/' | grep -i '%s' >/dev/null", appname .. "_server", luci.http.formvalue("id"))) == 0
|
||||
http_write_json(e)
|
||||
end
|
||||
|
||||
|
||||
@ -9,12 +9,25 @@ local i18n = require "luci.i18n"
|
||||
appname = "passwall"
|
||||
curl = "/usr/bin/curl"
|
||||
curl_args = {"-skL", "--connect-timeout 3", "--retry 3", "-m 60"}
|
||||
wget = "/usr/bin/wget"
|
||||
wget_args = {"--no-check-certificate", "--quiet", "--timeout=100", "--tries=3"}
|
||||
command_timeout = 300
|
||||
LEDE_BOARD = nil
|
||||
DISTRIB_TARGET = nil
|
||||
|
||||
function url(...)
|
||||
local url = string.format("admin/services/%s", appname)
|
||||
local args = { ... }
|
||||
for i, v in pairs(args) do
|
||||
if v ~= "" then
|
||||
url = url .. "/" .. v
|
||||
end
|
||||
end
|
||||
return require "luci.dispatcher".build_url(url)
|
||||
end
|
||||
|
||||
function trim(s)
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
function is_exist(table, value)
|
||||
for index, k in ipairs(table) do
|
||||
if k == value then
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
local d = require "luci.dispatcher"
|
||||
local appname = "passwall"
|
||||
|
||||
m = Map(appname)
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
local uci = require"luci.model.uci".cursor()
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = "passwall"
|
||||
local appname = api.appname
|
||||
|
||||
local nodes_table = {}
|
||||
for k, e in ipairs(api.get_valid_nodes()) do
|
||||
@ -23,12 +22,7 @@ o.rmempty = false
|
||||
|
||||
---- Testing Time
|
||||
o = s:option(Value, "testing_time", translate("How often is a diagnosis made"), translate("Units:minutes"))
|
||||
o.default = "3"
|
||||
|
||||
o = s:option(ListValue, "tcp_main", "TCP " .. translate("Main node"))
|
||||
for k, v in pairs(nodes_table) do
|
||||
o:value(v.id, v.remarks)
|
||||
end
|
||||
o.default = "1"
|
||||
|
||||
o = s:option(DynamicList, "tcp_node", "TCP " .. translate("List of backup nodes"))
|
||||
for k, v in pairs(nodes_table) do
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
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 appname = api.appname
|
||||
local has_xray = api.is_finded("xray")
|
||||
|
||||
m = Map(appname)
|
||||
@ -95,7 +94,7 @@ if current_node and current_node ~= "" and current_node ~= "nil" then
|
||||
if n then
|
||||
if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then
|
||||
local remarks = api.get_full_node_remarks(n)
|
||||
local url = d.build_url("admin", "services", appname, "node_config", current_node)
|
||||
local url = api.url("node_config", current_node)
|
||||
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
|
||||
@ -103,7 +102,7 @@ if current_node and current_node ~= "" and current_node ~= "nil" then
|
||||
local id = e[".name"]
|
||||
local remarks = translate(e.remarks)
|
||||
if n[id] and n[id] ~= "nil" then
|
||||
local url = d.build_url("admin", "services", appname, "node_config", n[id])
|
||||
local url = api.url("node_config", n[id])
|
||||
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
|
||||
tcp_node.description = tcp_node.description .. remarks .. ":" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
|
||||
end
|
||||
@ -111,7 +110,7 @@ if current_node and current_node ~= "" and current_node ~= "nil" then
|
||||
local id = "default_node"
|
||||
local remarks = translate("Default")
|
||||
if n[id] and n[id] ~= "nil" then
|
||||
local url = d.build_url("admin", "services", appname, "node_config", n[id])
|
||||
local url = api.url("node_config", n[id])
|
||||
local r = api.get_full_node_remarks(uci:get_all(appname, n[id]))
|
||||
tcp_node.description = tcp_node.description .. remarks .. ":" .. string.format('<a href="%s">%s</a>', url, r) .. "<br />"
|
||||
end
|
||||
@ -371,8 +370,12 @@ 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)
|
||||
if v.type == "Xray" then
|
||||
if has_xray then
|
||||
tcp_node_http:depends("tcp_node", v.id)
|
||||
end
|
||||
else
|
||||
tcp_node_http:depends("tcp_node_socks", true)
|
||||
end
|
||||
udp_node:value(v.id, v.remarks)
|
||||
if v.type == "Socks" then
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
local e = require "luci.sys"
|
||||
local net = require "luci.model.network".init()
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = "passwall"
|
||||
local appname = api.appname
|
||||
|
||||
local nodes_table = {}
|
||||
for k, e in ipairs(api.get_valid_nodes()) do
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
f = SimpleForm("passwall")
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = api.appname
|
||||
|
||||
f = SimpleForm(appname)
|
||||
f.reset = false
|
||||
f.submit = false
|
||||
f:append(Template("passwall/log/log"))
|
||||
f:append(Template(appname .. "/log/log"))
|
||||
return f
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
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 appname = api.appname
|
||||
|
||||
local ss_encrypt_method_list = {
|
||||
"rc4-md5", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-ctr",
|
||||
@ -54,7 +53,7 @@ local encrypt_methods_ss_aead = {
|
||||
}
|
||||
|
||||
m = Map(appname, translate("Node Config"))
|
||||
m.redirect = d.build_url("admin", "services", appname)
|
||||
m.redirect = api.url()
|
||||
|
||||
s = m:section(NamedSection, arg[1], "nodes", "")
|
||||
s.addremove = false
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
local d = require "luci.dispatcher"
|
||||
local _api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = "passwall"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = api.appname
|
||||
|
||||
m = Map(appname)
|
||||
|
||||
@ -28,9 +27,9 @@ s = m:section(TypedSection, "nodes")
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.template = "cbi/tblsection"
|
||||
s.extedit = d.build_url("admin", "services", appname, "node_config", "%s")
|
||||
s.extedit = api.url("node_config", "%s")
|
||||
function s.create(e, t)
|
||||
local uuid = _api.gen_uuid()
|
||||
local uuid = api.gen_uuid()
|
||||
t = uuid
|
||||
TypedSection.create(e, t)
|
||||
luci.http.redirect(e.extedit:format(t))
|
||||
@ -39,7 +38,7 @@ end
|
||||
function s.remove(e, t)
|
||||
s.map.proceed = true
|
||||
s.map:del(t)
|
||||
luci.http.redirect(d.build_url("admin", "services", appname, "node_list"))
|
||||
luci.http.redirect(api.url("node_list"))
|
||||
end
|
||||
|
||||
if nodes_display:find("show_group") then
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
local appname = "passwall"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = api.appname
|
||||
|
||||
m = Map(appname)
|
||||
|
||||
@ -36,7 +37,7 @@ o = s:option(Button, "_update", translate("Manual subscription"))
|
||||
o.inputstyle = "apply"
|
||||
function o.write(e, e)
|
||||
luci.sys.call("lua /usr/share/" .. appname .. "/subscribe.lua start log > /dev/null 2>&1 &")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname, "log"))
|
||||
luci.http.redirect(api.url("log"))
|
||||
end
|
||||
|
||||
---- Subscribe Delete All
|
||||
@ -44,7 +45,7 @@ o = s:option(Button, "_stop", translate("Delete All Subscribe Node"))
|
||||
o.inputstyle = "remove"
|
||||
function o.write(e, e)
|
||||
luci.sys.call("lua /usr/share/" .. appname .. "/subscribe.lua truncate log > /dev/null 2>&1 &")
|
||||
luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname, "log"))
|
||||
luci.http.redirect(api.url("log"))
|
||||
end
|
||||
|
||||
filter_enabled = s:option(Flag, "filter_enabled", translate("Filter keyword switch"), translate("When checked, below options can only be take effect."))
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
local uci = require"luci.model.uci".cursor()
|
||||
local appname = "passwall"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = api.appname
|
||||
|
||||
m = Map(appname)
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
local d = require "luci.dispatcher"
|
||||
local appname = "passwall"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = api.appname
|
||||
|
||||
m = Map(appname)
|
||||
-- [[ Rule Settings ]]--
|
||||
@ -53,7 +53,7 @@ s = m:section(TypedSection, "shunt_rules", "Xray" .. translate("Shunt") .. trans
|
||||
s.template = "cbi/tblsection"
|
||||
s.anonymous = false
|
||||
s.addremove = true
|
||||
s.extedit = d.build_url("admin", "services", appname, "shunt_rules", "%s")
|
||||
s.extedit = api.url("shunt_rules", "%s")
|
||||
function s.create(e, t)
|
||||
TypedSection.create(e, t)
|
||||
luci.http.redirect(e.extedit:format(t))
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
local fs = require "nixio.fs"
|
||||
local appname = "passwall"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = api.appname
|
||||
|
||||
m = Map(appname)
|
||||
m.apply_on_parse=true
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
local d = require "luci.dispatcher"
|
||||
local appname = "passwall"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = api.appname
|
||||
|
||||
m = Map(appname, "Xray" .. translate("Shunt") .. translate("Rule"))
|
||||
m.redirect = d.build_url("admin", "services", appname)
|
||||
m.redirect = api.url()
|
||||
|
||||
s = m:section(NamedSection, arg[1], "shunt_rules", "")
|
||||
s.addremove = false
|
||||
|
||||
@ -4,7 +4,7 @@ local action = arg[1]
|
||||
local sys = require 'luci.sys'
|
||||
local jsonc = require "luci.jsonc"
|
||||
local ucic = require"luci.model.uci".cursor()
|
||||
local _api = require "luci.model.cbi.passwall.api.api"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
|
||||
local CONFIG = "passwall_server"
|
||||
local CONFIG_PATH = "/var/etc/" .. CONFIG
|
||||
@ -111,7 +111,7 @@ local function start()
|
||||
bin = ln_start("/usr/bin/" .. type .. "-server", type .. "-server", "-c " .. config_file .. " " .. udp_param, log_path)
|
||||
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)
|
||||
bin = ln_start(api.get_xray_path(), "xray", "-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)
|
||||
@ -120,11 +120,11 @@ local function start()
|
||||
bin = ln_start("/usr/sbin/trojan-plus", "trojan-plus", "-c " .. config_file, log_path)
|
||||
elseif type == "Trojan-Go" then
|
||||
config = require("luci.model.cbi.passwall.server.api.trojan").gen_config(user)
|
||||
bin = ln_start(_api.get_trojan_go_path(), "trojan-go", "-config " .. config_file, log_path)
|
||||
bin = ln_start(api.get_trojan_go_path(), "trojan-go", "-config " .. config_file, log_path)
|
||||
elseif type == "Brook" then
|
||||
local brook_protocol = user.protocol
|
||||
local brook_password = user.password
|
||||
bin = ln_start(_api.get_brook_path(), "brook_" .. id, string.format("%s -l :%s -p %s", brook_protocol, port, brook_password), log_path)
|
||||
bin = ln_start(api.get_brook_path(), "brook_" .. id, string.format("%s -l :%s -p %s", brook_protocol, port, brook_password), log_path)
|
||||
end
|
||||
|
||||
if next(config) then
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
local d = require "luci.dispatcher"
|
||||
local _api = require "luci.model.cbi.passwall.api.api"
|
||||
local e = luci.model.uci.cursor()
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = api.appname
|
||||
|
||||
m = Map("passwall_server", translate("Server-Side"))
|
||||
|
||||
@ -16,9 +15,9 @@ t.anonymous = true
|
||||
t.addremove = true
|
||||
t.sortable = true
|
||||
t.template = "cbi/tblsection"
|
||||
t.extedit = d.build_url("admin", "services", "passwall", "server_user", "%s")
|
||||
t.extedit = api.url("server_user", "%s")
|
||||
function t.create(e, t)
|
||||
local uuid = _api.gen_uuid()
|
||||
local uuid = api.gen_uuid()
|
||||
t = uuid
|
||||
TypedSection.create(e, t)
|
||||
luci.http.redirect(e.extedit:format(t))
|
||||
@ -26,7 +25,7 @@ end
|
||||
function t.remove(e, t)
|
||||
e.map.proceed = true
|
||||
e.map:del(t)
|
||||
luci.http.redirect(d.build_url("admin", "services", "passwall", "server"))
|
||||
luci.http.redirect(api.url("server"))
|
||||
end
|
||||
|
||||
e = t:option(Flag, "enable", translate("Enable"))
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
local d = require "luci.dispatcher"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local appname = api.appname
|
||||
|
||||
local ss_encrypt_method_list = {
|
||||
"rc4-md5", "aes-128-cfb", "aes-192-cfb", "aes-256-cfb", "aes-128-ctr",
|
||||
@ -48,7 +48,7 @@ local encrypt_methods_ss_aead = {
|
||||
}
|
||||
|
||||
m = Map("passwall_server", translate("Server Config"))
|
||||
m.redirect = d.build_url("admin", "services", "passwall", "server")
|
||||
m.redirect = api.url("server")
|
||||
|
||||
s = m:section(NamedSection, arg[1], "user", "")
|
||||
s.addremove = false
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<%
|
||||
local brook_version = require "luci.model.cbi.passwall.api.api".get_brook_version()
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local brook_version = api.get_brook_version()
|
||||
-%>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -72,7 +73,7 @@ local brook_version = require "luci.model.cbi.passwall.api.api".get_brook_versio
|
||||
|
||||
var ckeckDetailElm = document.getElementById(btn.id + '-detail');
|
||||
|
||||
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[brook_check]])%>', {
|
||||
XHR.get('<%=api.url("brook_check")%>', {
|
||||
token: tokenStr,
|
||||
arch: ''
|
||||
}, function(x,json) {
|
||||
@ -112,7 +113,7 @@ local brook_version = require "luci.model.cbi.passwall.api.api".get_brook_versio
|
||||
|
||||
addPageNotice_brook();
|
||||
|
||||
var brookUpdateUrl = '<%=url([[admin]], [[services]], [[passwall]], [[brook_update]])%>';
|
||||
var brookUpdateUrl = '<%=api.url("brook_update")%>';
|
||||
// Download file
|
||||
XHR.get(brookUpdateUrl, {
|
||||
token: tokenStr,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<%
|
||||
local kcptun_version = require "luci.model.cbi.passwall.api.api".get_kcptun_version()
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local kcptun_version = api.get_kcptun_version()
|
||||
-%>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -72,7 +73,7 @@ local kcptun_version = require "luci.model.cbi.passwall.api.api".get_kcptun_vers
|
||||
|
||||
var ckeckDetailElm = document.getElementById(btn.id + '-detail');
|
||||
|
||||
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[kcptun_check]])%>', {
|
||||
XHR.get('<%=api.url("kcptun_check")%>', {
|
||||
token: tokenStr,
|
||||
arch: ''
|
||||
}, function(x,json) {
|
||||
@ -112,7 +113,7 @@ local kcptun_version = require "luci.model.cbi.passwall.api.api".get_kcptun_vers
|
||||
|
||||
addPageNotice_kcptun();
|
||||
|
||||
var kcptunUpdateUrl = '<%=url([[admin]], [[services]], [[passwall]], [[kcptun_update]])%>';
|
||||
var kcptunUpdateUrl = '<%=api.url("kcptun_update")%>';
|
||||
// Download file
|
||||
XHR.get(kcptunUpdateUrl, {
|
||||
token: tokenStr,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<%
|
||||
local trojan_go_version = require "luci.model.cbi.passwall.api.api".get_trojan_go_version()
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local trojan_go_version = api.get_trojan_go_version()
|
||||
-%>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -72,7 +73,7 @@ local trojan_go_version = require "luci.model.cbi.passwall.api.api".get_trojan_g
|
||||
|
||||
var ckeckDetailElm = document.getElementById(btn.id + '-detail');
|
||||
|
||||
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[trojan_go_check]])%>', {
|
||||
XHR.get('<%=api.url("trojan_go_check")%>', {
|
||||
token: tokenStr,
|
||||
arch: ''
|
||||
}, function(x,json) {
|
||||
@ -112,7 +113,7 @@ local trojan_go_version = require "luci.model.cbi.passwall.api.api".get_trojan_g
|
||||
|
||||
addPageNotice_trojan();
|
||||
|
||||
var trojanUpdateUrl = '<%=url([[admin]], [[services]], [[passwall]], [[trojan_go_update]])%>';
|
||||
var trojanUpdateUrl = '<%=api.url("trojan_go_update")%>';
|
||||
// Download file
|
||||
XHR.get(trojanUpdateUrl, {
|
||||
token: tokenStr,
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<%
|
||||
local xray_version = require "luci.model.cbi.passwall.api.api".get_xray_version()
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local xray_version = api.get_xray_version()
|
||||
-%>
|
||||
|
||||
<script type="text/javascript">
|
||||
@ -72,7 +73,7 @@ local xray_version = require "luci.model.cbi.passwall.api.api".get_xray_version(
|
||||
|
||||
var ckeckDetailElm = document.getElementById(btn.id + '-detail');
|
||||
|
||||
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[xray_check]])%>', {
|
||||
XHR.get('<%=api.url("xray_check")%>', {
|
||||
token: tokenStr,
|
||||
arch: ''
|
||||
}, function(x,json) {
|
||||
@ -112,7 +113,7 @@ local xray_version = require "luci.model.cbi.passwall.api.api".get_xray_version(
|
||||
|
||||
addPageNotice_xray();
|
||||
|
||||
var xrayUpdateUrl = '<%=url([[admin]], [[services]], [[passwall]], [[xray_update]])%>';
|
||||
var xrayUpdateUrl = '<%=api.url("xray_update")%>';
|
||||
// Download file
|
||||
XHR.get(xrayUpdateUrl, {
|
||||
token: tokenStr,
|
||||
|
||||
@ -7,7 +7,7 @@ local auto_switch = api.uci_get_type("auto_switch", "enable", 0)
|
||||
var _status = document.getElementsByClassName('_status');
|
||||
for (var i = 0; i < _status.length; i++) {
|
||||
var id = _status[i].getAttribute("socks_id");
|
||||
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[socks_status]])%>', {
|
||||
XHR.get('<%=api.url("socks_status")%>', {
|
||||
index: i,
|
||||
id: id
|
||||
},
|
||||
@ -57,12 +57,12 @@ local auto_switch = api.uci_get_type("auto_switch", "enable", 0)
|
||||
var new_a = document.createElement("a");
|
||||
new_a.innerHTML = "<%:Edit%>";
|
||||
new_a.href = "#";
|
||||
new_a.setAttribute("onclick", "location.href='" + '<%=url([[admin]], [[services]], [[passwall]], [[node_config]])%>' + "/" + node_select_value + "'");
|
||||
new_a.setAttribute("onclick", "location.href='" + '<%=api.url("node_config")%>' + "/" + node_select_value + "'");
|
||||
|
||||
var log_a = document.createElement("a");
|
||||
log_a.innerHTML = "<%:Log%>";
|
||||
log_a.href = "#";
|
||||
log_a.setAttribute("onclick", "window.open('" + '<%=url([[admin]], [[services]], [[passwall]], [[get_redir_log]])%>' + "?proto=" + proto + "', '_blank')");
|
||||
log_a.setAttribute("onclick", "window.open('" + '<%=api.url("get_redir_log")%>' + "?proto=" + proto + "', '_blank')");
|
||||
|
||||
node_select.outerHTML = node_select.outerHTML + "  " + new_a.outerHTML + "  " + log_a.outerHTML;
|
||||
//node_select.parentNode.insertBefore(new_a, node_select.nextSibling);
|
||||
@ -102,7 +102,7 @@ local auto_switch = api.uci_get_type("auto_switch", "enable", 0)
|
||||
var new_a = document.createElement("a");
|
||||
new_a.innerHTML = "<%:Edit%>";
|
||||
new_a.href = "#";
|
||||
new_a.setAttribute("onclick","location.href='" + '<%=url([[admin]], [[services]], [[passwall]], [[node_config]])%>' + "/" + node_select_value + "'");
|
||||
new_a.setAttribute("onclick","location.href='" + '<%=api.url("node_config")%>' + "/" + node_select_value + "'");
|
||||
|
||||
node_select.outerHTML = node_select.outerHTML + "  " + new_a.outerHTML;
|
||||
//node_select.parentNode.insertBefore(new_a, node_select.nextSibling);
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
<%
|
||||
local dsp = require "luci.dispatcher"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
|
||||
local status = api.uci_get_type("global_other", "status", "")
|
||||
-%>
|
||||
|
||||
@ -231,7 +229,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
document.getElementsByTagName('img')[i].setAttribute("oncontextmenu","return false;");
|
||||
document.getElementsByTagName('img')[i].setAttribute("ondragstart","return false;");
|
||||
}
|
||||
XHR.poll(5, '<%=dsp.build_url("admin/services/passwall/status")%>', null,
|
||||
XHR.poll(5, '<%=api.url("status")%>', null,
|
||||
function (x, data) {
|
||||
var status_dns = document.getElementById('status_dns');
|
||||
var status_haproxy = document.getElementById('status_haproxy');
|
||||
@ -292,7 +290,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
div.removeAttribute('onclick');
|
||||
s.innerHTML = '<%:Check...%>';
|
||||
var sendDate = (new Date()).getTime();
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/connect_status")%>', {
|
||||
XHR.get('<%=api.url("connect_status")%>', {
|
||||
type: type,
|
||||
url : url
|
||||
},
|
||||
@ -327,7 +325,7 @@ https://github.com/pure-css/pure/blob/master/LICENSE.md
|
||||
if (s) {
|
||||
dom.removeAttribute('onclick');
|
||||
s.innerHTML = '<%:Check...%>';
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/check_port")%>', null,
|
||||
XHR.get('<%=api.url("check_port")%>', null,
|
||||
function(x, rv) {
|
||||
if (rv.ret) {
|
||||
s.innerHTML = rv.ret;
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
<%
|
||||
local dsp = require "luci.dispatcher"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
|
||||
local status = api.uci_get_type("global_other", "status", "")
|
||||
-%>
|
||||
|
||||
@ -156,7 +154,7 @@ local status = api.uci_get_type("global_other", "status", "")
|
||||
var kcptun_status = document.getElementById('_kcptun_status');
|
||||
var baidu_status = document.getElementById('_baidu_status');
|
||||
var google_status = document.getElementById('_google_status');
|
||||
XHR.poll(3, '<%=dsp.build_url("admin/services/passwall/status")%>', null,
|
||||
XHR.poll(3, '<%=api.url("status")%>', null,
|
||||
function(x, json) {
|
||||
if (x && x.status == 200) {
|
||||
var tcp_node_status = document.getElementById('_tcp_node_status');
|
||||
@ -202,7 +200,7 @@ local status = api.uci_get_type("global_other", "status", "")
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Check...%>';
|
||||
var sendDate = (new Date()).getTime();
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/connect_status")%>', {
|
||||
XHR.get('<%=api.url("connect_status")%>', {
|
||||
type: type,
|
||||
url: url
|
||||
},
|
||||
@ -239,7 +237,7 @@ local status = api.uci_get_type("global_other", "status", "")
|
||||
function check_port(btn) {
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:Check...%>';
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/check_port")%>', null,
|
||||
XHR.get('<%=api.url("check_port")%>', null,
|
||||
function(x, rv) {
|
||||
var s = document.getElementById('_node_status');
|
||||
if (s) {
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
<%
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
-%>
|
||||
<div class="cbi-section cbi-tblsection">
|
||||
<!-- <h3><%:Tips%></h3> -->
|
||||
<div>
|
||||
<%:You can use load balancing for failover.%>
|
||||
<br />
|
||||
<%:Restore the default configuration method. Input example in the address bar:%> http://192.168.1.1/cgi-bin/luci/admin/services/passwall/reset_config
|
||||
<%:Restore the default configuration method. Input example in the address bar:%> http://192.168.1.1<%=api.url("reset_config")%>
|
||||
<br />
|
||||
<%:Hide menu method, input example in the address bar:%> http://192.168.1.1/cgi-bin/luci/admin/services/passwall/hide
|
||||
<%:Hide menu method, input example in the address bar:%> http://192.168.1.1<%=api.url("hide")%>
|
||||
<br />
|
||||
<%:After the hidden to the display, input example in the address bar:%> http://192.168.1.1/cgi-bin/luci/admin/services/passwall/show
|
||||
<%:After the hidden to the display, input example in the address bar:%> http://192.168.1.1<%=api.url("show")%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
<%
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local console_port = api.uci_get_type("global_haproxy", "console_port", "")
|
||||
-%>
|
||||
<p id="_status"></p>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[passwall]], [[status]])%>', null,
|
||||
XHR.poll(3, '<%=api.url("status")%>', null,
|
||||
function(x, json) {
|
||||
if (x && x.status == 200) {
|
||||
var _status = document.getElementById('_status');
|
||||
@ -14,7 +18,7 @@
|
||||
});
|
||||
|
||||
function openwebui(){
|
||||
var url = window.location.host+":<%=luci.sys.exec("uci -q get passwall.@global_haproxy[0].console_port"):gsub("^%s*(.-)%s*$", "%1")%>";
|
||||
window.open('http://'+url,'target','');
|
||||
var url = window.location.host + ":<%=console_port%>";
|
||||
window.open('http://' + url, 'target', '');
|
||||
}
|
||||
//]]></script>
|
||||
@ -1,7 +1,10 @@
|
||||
<%
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
-%>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function clearlog(btn) {
|
||||
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[clear_log]])%>', null,
|
||||
XHR.get('<%=api.url("clear_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
@ -11,7 +14,7 @@
|
||||
}
|
||||
);
|
||||
}
|
||||
XHR.poll(5, '<%=url([[admin]], [[services]], [[passwall]], [[get_log]])%>', null,
|
||||
XHR.poll(5, '<%=api.url("get_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
<%
|
||||
function trim(s)
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
local dsp = require "luci.dispatcher"
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
-%>
|
||||
|
||||
<style>
|
||||
@ -25,10 +22,10 @@ local dsp = require "luci.dispatcher"
|
||||
//<![CDATA[
|
||||
function link_clear_temp() {
|
||||
if (confirm('<%:Are you sure to clear all cached links?%>') == true){
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/link_clear_temp")%>', null,
|
||||
XHR.get('<%=api.url("link_clear_temp")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
window.location.href = '<%=dsp.build_url("admin/services/passwall/node_list")%>';
|
||||
window.location.href = '<%=api.url("node_list")%>';
|
||||
}
|
||||
else {
|
||||
alert("<%:Error%>");
|
||||
@ -39,7 +36,7 @@ local dsp = require "luci.dispatcher"
|
||||
|
||||
function link_load_temp() {
|
||||
var inputer = document.getElementById("nodes_link");
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/link_load_temp")%>', null,
|
||||
XHR.get('<%=api.url("link_load_temp")%>', null,
|
||||
function(x, data) {
|
||||
if(x.readyState === 4 && x.status === 200) {
|
||||
try {
|
||||
@ -60,12 +57,12 @@ local dsp = require "luci.dispatcher"
|
||||
|
||||
function ajax_add_node(link) {
|
||||
if (link) {
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/link_add_node")%>', {
|
||||
XHR.get('<%=api.url("link_add_node")%>', {
|
||||
'link': link
|
||||
},
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
window.location.href = '<%=dsp.build_url("admin/services/passwall/node_list")%>';
|
||||
window.location.href = '<%=api.url("node_list")%>';
|
||||
}
|
||||
else {
|
||||
alert("<%:Error%>");
|
||||
@ -100,10 +97,10 @@ local dsp = require "luci.dispatcher"
|
||||
|
||||
function clear_all_nodes() {
|
||||
if (confirm('<%:Are you sure to clear all nodes?%>') == true){
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/clear_all_nodes")%>', null,
|
||||
XHR.get('<%=api.url("clear_all_nodes")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
window.location.href = '<%=dsp.build_url("admin/services/passwall/node_list")%>';
|
||||
window.location.href = '<%=api.url("node_list")%>';
|
||||
}
|
||||
else {
|
||||
alert("<%:Error%>");
|
||||
@ -117,7 +114,7 @@ local dsp = require "luci.dispatcher"
|
||||
|
||||
<div id="add_link_div">
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"><%:SS/SSR/V2ray/Trojan Link%></label>
|
||||
<label class="cbi-value-title"><%:SS/SSR/Vmess/Trojan Link%></label>
|
||||
<div class="cbi-value-field">
|
||||
<textarea id="nodes_link" rows="5" cols="50"></textarea>
|
||||
</div>
|
||||
@ -135,6 +132,7 @@ local dsp = require "luci.dispatcher"
|
||||
<div class="cbi-value">
|
||||
<label class="cbi-value-title"></label>
|
||||
<div class="cbi-value-field">
|
||||
<input class="cbi-button cbi-button-add" type="submit" name="cbi.cts.<%=api.appname%>.nodes." value="<%:Add%>" />
|
||||
<input class="cbi-button cbi-button-add" type="button" onclick="open_add_link_div()" value="<%:Add the node via the link%>" />
|
||||
<input class="cbi-button cbi-button-remove" type="button" onclick="clear_all_nodes()" value="<%:Clear all nodes%>" />
|
||||
<input class="cbi-button cbi-button-remove" type="button" onclick="delete_select_nodes()" value="<%:Delete select nodes%>" />
|
||||
|
||||
@ -1,6 +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) {
|
||||
@ -77,7 +77,7 @@ local dsp = require "luci.dispatcher"
|
||||
}
|
||||
|
||||
function link_append_temp(link) {
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/link_append_temp")%>', {
|
||||
XHR.get('<%=api.url("link_append_temp")%>', {
|
||||
'link': link
|
||||
},
|
||||
function(x, data) {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<%
|
||||
-- Copyright (C) 2018-2020 L-WRT Team
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
local dsp = require "luci.dispatcher"
|
||||
-- Copyright (C) 2018-2020 L-WRT Team
|
||||
-- Copyright (C) 2021 xiaorouji
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
-%>
|
||||
|
||||
<style>
|
||||
@ -94,7 +94,7 @@ table td, .table .td {
|
||||
}
|
||||
|
||||
function copy_node(cbi_id) {
|
||||
window.location.href = '<%=dsp.build_url("admin/services/passwall/copy_node")%>' + "?section=" + cbi_id;
|
||||
window.location.href = '<%=api.url("copy_node")%>' + "?section=" + cbi_id;
|
||||
}
|
||||
|
||||
var section = "";
|
||||
@ -181,12 +181,12 @@ table td, .table .td {
|
||||
}
|
||||
}
|
||||
if (confirm('<%:Are you sure to delete select nodes?%>') == true){
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/delete_select_nodes")%>', {
|
||||
XHR.get('<%=api.url("delete_select_nodes")%>', {
|
||||
ids: ids.join()
|
||||
},
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
window.location.href = '<%=dsp.build_url("admin/services/passwall/node_list")%>';
|
||||
window.location.href = '<%=api.url("node_list")%>';
|
||||
}
|
||||
else {
|
||||
alert("<%:Error%>");
|
||||
@ -200,7 +200,7 @@ table td, .table .td {
|
||||
|
||||
function set_node(protocol) {
|
||||
if (confirm('<%:Are you sure set to%> ' + protocol.toUpperCase() + '<%:the server?%>')==true){
|
||||
window.location.href = '<%=dsp.build_url("admin/services/passwall/set_node")%>?protocol=' + protocol + '§ion=' + section;
|
||||
window.location.href = '<%=api.url("set_node")%>?protocol=' + protocol + '§ion=' + section;
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ table td, .table .td {
|
||||
|
||||
//获取当前使用的节点
|
||||
function get_now_use_node() {
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/get_now_use_node")%>', null,
|
||||
XHR.get('<%=api.url("get_now_use_node")%>', null,
|
||||
function(x, result) {
|
||||
var id = result["TCP"];
|
||||
if (id) {
|
||||
@ -248,7 +248,7 @@ table td, .table .td {
|
||||
function ping_node(cbi_id, dom) {
|
||||
var full = get_address_full(cbi_id);
|
||||
if (full != null) {
|
||||
XHR.get('<%=dsp.build_url("admin/services/passwall/ping_node")%>', {
|
||||
XHR.get('<%=api.url("ping_node")%>', {
|
||||
address: full.address,
|
||||
port: full.port
|
||||
},
|
||||
@ -303,7 +303,7 @@ table td, .table .td {
|
||||
return new Promise((res) => {
|
||||
const dom = nodes[index];
|
||||
if (!dom) res()
|
||||
ajax.post('<%=dsp.build_url("admin/services/passwall/ping_node")%>', {
|
||||
ajax.post('<%=api.url("ping_node")%>', {
|
||||
index: dom.indexs,
|
||||
address: dom.address,
|
||||
port: dom.port
|
||||
@ -359,7 +359,7 @@ table td, .table .td {
|
||||
var indexs = nodes[index].indexs;
|
||||
var address = nodes[index].address;
|
||||
var port = nodes[index].port;
|
||||
ajax.post('<%=dsp.build_url("admin/services/passwall/ping_node")%>', {
|
||||
ajax.post('<%=api.url("ping_node")%>', {
|
||||
index: indexs,
|
||||
address: address,
|
||||
port: port
|
||||
|
||||
@ -22,12 +22,12 @@ local chnlist_update = api.uci_get_type("global_rules", "chnlist_update", "1") =
|
||||
checkBoxList.push(dom.name);
|
||||
}
|
||||
}
|
||||
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[update_rules]])%>', {
|
||||
XHR.get('<%=api.url("update_rules")%>', {
|
||||
update: checkBoxList
|
||||
},
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
window.location.href = '<%=url([[admin]], [[services]], [[passwall]], [[log]])%>';
|
||||
window.location.href = '<%=api.url("log")%>';
|
||||
} else {
|
||||
alert("<%:Error%>");
|
||||
btn.disabled = false;
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
<%
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
-%>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
function clear_log(btn) {
|
||||
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[server_clear_log]])%>', null,
|
||||
XHR.get('<%=api.url("server_clear_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
@ -11,7 +14,7 @@
|
||||
}
|
||||
);
|
||||
}
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[passwall]], [[server_get_log]])%>', null,
|
||||
XHR.poll(3, '<%=api.url("server_get_log")%>', null,
|
||||
function(x, data) {
|
||||
if(x && x.status == 200) {
|
||||
var log_textarea = document.getElementById('log_textarea');
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
<%
|
||||
local api = require "luci.model.cbi.passwall.api.api"
|
||||
-%>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
var _users_status = document.getElementsByClassName('_users_status');
|
||||
for(var i = 0; i < _users_status.length; i++) {
|
||||
var id = _users_status[i].parentElement.parentElement.parentElement.id;
|
||||
id = id.substr(id.lastIndexOf("-") + 1);
|
||||
XHR.get('<%=url([[admin]], [[services]], [[passwall]], [[server_user_status]])%>', {
|
||||
XHR.get('<%=api.url("server_user_status")%>', {
|
||||
index: i,
|
||||
id: id
|
||||
},
|
||||
@ -24,7 +27,7 @@
|
||||
var td = edit_btn[i].parentNode;
|
||||
var new_div = "";
|
||||
//添加"日志"按钮
|
||||
new_div += '<input class="cbi-button cbi-button-add" type="button" value="<%:Log%>" onclick="window.open(\'' + '<%=url([[admin]], [[services]], [[passwall]], [[server_user_log]])%>' + '?id=' + id + '\', \'_blank\')"/> ';
|
||||
new_div += '<input class="cbi-button cbi-button-add" type="button" value="<%:Log%>" onclick="window.open(\'' + '<%=api.url("server_user_log")%>' + '?id=' + id + '\', \'_blank\')"/> ';
|
||||
td.innerHTML = new_div + td.innerHTML;
|
||||
}
|
||||
catch(err) {
|
||||
|
||||
@ -328,8 +328,8 @@ msgstr "添加节点"
|
||||
msgid "Add the node via the link"
|
||||
msgstr "通过链接添加节点"
|
||||
|
||||
msgid "SS/SSR/V2ray/Trojan Link"
|
||||
msgstr "SS/SSR/V2ray/Trojan链接"
|
||||
msgid "SS/SSR/Vmess/Trojan Link"
|
||||
msgstr "SS/SSR/Vmess/Trojan链接"
|
||||
|
||||
msgid "Please enter the correct link, ss:// ssr:// vmess:// trojan://"
|
||||
msgstr "请输入正确的链接,ss:// ssr:// vmess:// trojan://"
|
||||
|
||||
@ -27,8 +27,6 @@ EOF
|
||||
|
||||
tmp=$(uci -q get passwall.@global_app[0].xray_file)
|
||||
[ -z "$tmp" ] && uci set passwall.@global_app[0].xray_file="/usr/bin/xray"
|
||||
tmp=$(uci -q get passwall.@global_app[0].v2ray_file)
|
||||
[ -z "$tmp" ] && uci set passwall.@global_app[0].v2ray_file="/usr/bin/v2ray"
|
||||
uci commit passwall
|
||||
|
||||
rm -rf /tmp/luci-*cache
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) 2018-2020 L-WRT Team
|
||||
# Copyright (C) 2021 xiaorouji
|
||||
|
||||
. $IPKG_INSTROOT/lib/functions.sh
|
||||
. $IPKG_INSTROOT/lib/functions/service.sh
|
||||
@ -571,15 +572,29 @@ run_redir() {
|
||||
ln_start_bin "$(first_type ipt2socks)" "ipt2socks_tcp" $log_file -l "$local_port" -b 0.0.0.0 -s "$_socks_address" -p "$_socks_port" -R -v $extra_param
|
||||
fi
|
||||
unset _socks_flag _socks_address _socks_port _socks_username _socks_password
|
||||
|
||||
[ "$type" != "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
|
||||
}
|
||||
}
|
||||
;;
|
||||
esac
|
||||
return 0
|
||||
}
|
||||
|
||||
node_switch() {
|
||||
local node=$3
|
||||
[ -n "$1" -a -n "$2" -a -n "$3" ] && {
|
||||
ps -w | grep -E "$TMP_PATH" | grep -i "${1}" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
local node=$3
|
||||
top -bn1 | grep -E "$TMP_PATH" | grep -i "${1}" | grep -v "grep" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
local config_file=$TMP_PATH/${1}.json
|
||||
local log_file=$TMP_PATH/${1}.log
|
||||
eval current_port=\$${1}_REDIR_PORT
|
||||
@ -610,19 +625,6 @@ 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
|
||||
@ -1099,10 +1101,9 @@ start_haproxy() {
|
||||
cat <<-EOF > "${haproxy_file}"
|
||||
global
|
||||
log 127.0.0.1 local2
|
||||
chroot /usr/bin
|
||||
chroot ${haproxy_path}
|
||||
maxconn 60000
|
||||
stats socket ${haproxy_path}/haproxy.sock
|
||||
user root
|
||||
daemon
|
||||
|
||||
defaults
|
||||
@ -1193,6 +1194,7 @@ start_haproxy() {
|
||||
local auth=""
|
||||
[ -n "$console_user" ] && [ -n "$console_password" ] && auth="stats auth $console_user:$console_password"
|
||||
cat <<-EOF >> "${haproxy_file}"
|
||||
|
||||
listen console
|
||||
bind 0.0.0.0:$console_port
|
||||
mode http
|
||||
@ -1202,7 +1204,7 @@ start_haproxy() {
|
||||
$auth
|
||||
EOF
|
||||
|
||||
[ "${hasvalid}" != "1" ] && echolog " - 没有发现任何有效节点信息..." && return 0
|
||||
[ "${hasvalid}" != "1" ] && echolog " - 没有发现任何有效节点信息,不启动。" && return 0
|
||||
ln_start_bin "$(first_type haproxy)" haproxy "/dev/null" -f "${haproxy_file}"
|
||||
echolog " * 控制台端口:${console_port}/,${auth:-公开}"
|
||||
}
|
||||
@ -1257,10 +1259,10 @@ stop() {
|
||||
clean_log
|
||||
source $APP_PATH/iptables.sh stop
|
||||
kill_all v2ray-plugin obfs-local
|
||||
ps -w | grep -v "grep" | grep $CONFIG/test.sh | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
ps -w | grep -v "grep" | grep $CONFIG/monitor.sh | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
ps -w | grep -v -E "grep|${TMP_PATH}_server" | grep -E "$TMP_PATH" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
ps -w | grep -v "grep" | grep "sleep 1m" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
top -bn1 | grep -v "grep" | grep $CONFIG/test.sh | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
top -bn1 | grep -v "grep" | grep $CONFIG/monitor.sh | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
top -bn1 | grep -v -E "grep|${TMP_PATH}_server" | grep -E "$TMP_PATH" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
top -bn1 | grep -v "grep" | grep "sleep 1m" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
|
||||
rm -rf $TMP_DNSMASQ_PATH $TMP_PATH
|
||||
stop_crontab
|
||||
del_dnsmasq
|
||||
|
||||
@ -234,10 +234,18 @@ load_acl() {
|
||||
$ipt_m -A PSW $(comment "默认") -p udp -j RETURN
|
||||
}
|
||||
|
||||
filter_haproxy() {
|
||||
uci show $CONFIG | grep "@haproxy_config" | grep "lbss=" | cut -d "'" -f 2 | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | awk -F ":" '{print $1}' | sed -e "/^$/d" | sed -e "s/^/add $IPSET_VPSIPLIST &/g" | awk '{print $0} END{print "COMMIT"}' | ipset -! -R
|
||||
for host in $(uci show $CONFIG | grep "@haproxy_config" | grep "lbss=" | cut -d "'" -f 2 | grep -v -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | awk -F ":" '{print $1}'); do
|
||||
ipset -q add $IPSET_VPSIPLIST $(get_host_ip ipv4 $host 1)
|
||||
done
|
||||
echolog "加入负载均衡的节点到ipset[$IPSET_VPSIPLIST]直连完成"
|
||||
}
|
||||
|
||||
filter_vpsip() {
|
||||
uci show $CONFIG | grep ".address=" | cut -d "'" -f 2 | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | sed -e "/^$/d" | sed -e "s/^/add $IPSET_VPSIPLIST &/g" | awk '{print $0} END{print "COMMIT"}' | ipset -! -R
|
||||
#uci show $CONFIG | grep ".address=" | cut -d "'" -f 2 | grep -E "([[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){0,7}::[a-f0-9]{0,4}(:[a-f0-9]{1,4}){0,7}])" | sed -e "/^$/d" | sed -e "s/^/add $IPSET_VPSIP6LIST &/g" | awk '{print $0} END{print "COMMIT"}' | ipset -! -R
|
||||
echolog "过滤所有节点直接 IP 地址完成[$?]"
|
||||
echolog "加入所有节点到ipset[$IPSET_VPSIPLIST]直连完成"
|
||||
}
|
||||
|
||||
filter_node() {
|
||||
@ -403,7 +411,8 @@ add_firewall_rule() {
|
||||
}
|
||||
|
||||
# 过滤所有节点IP
|
||||
filter_vpsip
|
||||
filter_vpsip > /dev/null 2>&1 &
|
||||
filter_haproxy > /dev/null 2>&1 &
|
||||
|
||||
$ipt_n -N PSW
|
||||
$ipt_n -A PSW $(dst $IPSET_LANIPLIST) -j RETURN
|
||||
@ -447,7 +456,7 @@ add_firewall_rule() {
|
||||
fi
|
||||
_proxy_tcp_access() {
|
||||
[ -n "${2}" ] || return 0
|
||||
ipset test $IPSET_LANIPLIST ${2} 2>/dev/null
|
||||
ipset -q test $IPSET_LANIPLIST ${2}
|
||||
[ $? -eq 0 ] && {
|
||||
echolog " - 上游 DNS 服务器 ${2} 已在直接访问的列表中,不强制向 TCP 代理转发对该服务器 TCP/${3} 端口的访问"
|
||||
return 0
|
||||
@ -522,8 +531,8 @@ add_firewall_rule() {
|
||||
eval "node=\${TCP_NODE}"
|
||||
msg="${msg} 使用与 TCP 代理自动切换${num} 相同的节点,延后处理"
|
||||
else
|
||||
filter_node $node TCP
|
||||
filter_node $node UDP
|
||||
filter_node $node TCP > /dev/null 2>&1 &
|
||||
filter_node $node UDP > /dev/null 2>&1 &
|
||||
fi
|
||||
echolog " - ${msg}"
|
||||
done
|
||||
@ -541,7 +550,7 @@ add_firewall_rule() {
|
||||
echolog " - 采用 TCP 代理的配置"
|
||||
}
|
||||
if [ "$node" != "nil" ]; then
|
||||
filter_node $node $stream $port
|
||||
filter_node $node $stream $port > /dev/null 2>&1 &
|
||||
else
|
||||
echolog " - 忽略无效的 $stream 代理自动切换"
|
||||
fi
|
||||
@ -554,7 +563,7 @@ add_firewall_rule() {
|
||||
local ADD_INDEX=$FORCE_INDEX
|
||||
_proxy_udp_access() {
|
||||
[ -n "${2}" ] || return 0
|
||||
ipset test $IPSET_LANIPLIST ${2} 2>/dev/null
|
||||
ipset -q test $IPSET_LANIPLIST ${2}
|
||||
[ $? == 0 ] && {
|
||||
echolog " - 上游 DNS 服务器 ${2} 已在直接访问的列表中,不强制向 UDP 代理转发对该服务器 UDP/${3} 端口的访问"
|
||||
return 0
|
||||
|
||||
@ -15,7 +15,7 @@ config_t_get() {
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
if [ "$(ps -w | grep -v grep | grep $CONFIG/monitor.sh | wc -l)" -gt 2 ]; then
|
||||
if [ "$(top -bn1 | grep -v grep | grep $CONFIG/monitor.sh | wc -l)" -gt 2 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -32,13 +32,13 @@ do
|
||||
#kcptun
|
||||
use_kcp=$(config_n_get $TCP_NODE use_kcp 0)
|
||||
if [ $use_kcp -gt 0 ]; then
|
||||
icount=$(ps -w | grep -v grep | grep "$RUN_BIN_PATH/kcptun" | grep -i "tcp" | wc -l)
|
||||
icount=$(top -bn1 | grep -v grep | grep "$RUN_BIN_PATH/kcptun" | grep -i "tcp" | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
icount=$(ps -w | grep -v -E 'grep|kcptun' | grep "$RUN_BIN_PATH" | grep -i "TCP" | wc -l)
|
||||
icount=$(top -bn1 | grep -v -E 'grep|kcptun' | grep "$RUN_BIN_PATH" | grep -i "TCP" | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
@ -50,7 +50,7 @@ do
|
||||
if [ "$UDP_NODE" != "nil" ]; then
|
||||
[ "$UDP_NODE" == "tcp" ] && continue
|
||||
[ "$UDP_NODE" == "tcp_" ] && UDP_NODE=$TCP_NODE1
|
||||
icount=$(ps -w | grep -v grep | grep "$RUN_BIN_PATH" | grep -i "UDP" | wc -l)
|
||||
icount=$(top -bn1 | grep -v grep | grep "$RUN_BIN_PATH" | grep -i "UDP" | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
@ -70,7 +70,7 @@ do
|
||||
#haproxy
|
||||
use_haproxy=$(config_t_get global_haproxy balancing_enable 0)
|
||||
if [ $use_haproxy -gt 0 ]; then
|
||||
icount=$(ps -w | grep -v grep | grep "$RUN_BIN_PATH/haproxy" | wc -l)
|
||||
icount=$(top -bn1 | grep -v grep | grep "$RUN_BIN_PATH/haproxy" | wc -l)
|
||||
if [ $icount = 0 ]; then
|
||||
/etc/init.d/passwall restart
|
||||
exit 0
|
||||
|
||||
@ -82,16 +82,6 @@ do
|
||||
}
|
||||
end)
|
||||
|
||||
local tcp_main = ucic2:get(application, "@auto_switch[0]", "tcp_main") or "nil"
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
log = false,
|
||||
remarks = "自动切换TCP主节点",
|
||||
currentNode = ucic2:get_all(application, tcp_main),
|
||||
set = function(server)
|
||||
ucic2:set(application, "@auto_switch[0]", "tcp_main1", server)
|
||||
end
|
||||
}
|
||||
|
||||
local tcp_node_table = ucic2:get(application, "@auto_switch[0]", "tcp_node")
|
||||
if tcp_node_table then
|
||||
local nodes = {}
|
||||
|
||||
@ -74,32 +74,37 @@ test_auto_switch() {
|
||||
local restore_switch=$(config_t_get auto_switch restore_switch 0)
|
||||
if [ "$restore_switch" == "1" ]; then
|
||||
#检测主节点是否能使用
|
||||
local main_node=$(config_t_get auto_switch tcp_main)
|
||||
if [ "$now_node" != "$main_node" ]; then
|
||||
local main_node=$(config_t_get global tcp_node nil)
|
||||
if [ "$main_node" != "nil" ] && [ "$now_node" != "$main_node" ]; then
|
||||
local node_type=$(echo $(config_n_get $main_node type) | tr 'A-Z' 'a-z')
|
||||
if [ "$node_type" == "socks" ]; then
|
||||
local node_address=$(config_n_get $main_node address)
|
||||
local node_port=$(config_n_get $main_node port)
|
||||
[ -n "$node_address" ] && [ -n "$node_port" ] && local curlx="socks5h://$node_address:$node_port"
|
||||
[ -n "$node_address" ] && [ -n "$node_port" ] && {
|
||||
local curlx="socks5h://$node_address:$node_port"
|
||||
local node_username=$(config_n_get $main_node username)
|
||||
local node_password=$(config_n_get $main_node password)
|
||||
[ -n "$node_username" ] && [ -n "$node_password" ] && curlx="socks5h://$node_username:$node_password@$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 "auto_switch" "$main_node" "127.0.0.1" "$tmp_port" "/var/etc/passwall/auto_switch.json"
|
||||
local tmp_port=$(/usr/share/${CONFIG}/app.sh get_new_port 61080 tcp)
|
||||
/usr/share/${CONFIG}/app.sh run_socks "auto_switch" "$main_node" "127.0.0.1" "$tmp_port" "/var/etc/${CONFIG}/auto_switch.json"
|
||||
local curlx="socks5h://127.0.0.1:$tmp_port"
|
||||
fi
|
||||
sleep 10s
|
||||
proxy_status=$(test_url "https://www.google.com/generate_204" 3 3 "-x $curlx")
|
||||
ps -w | grep -v "grep" | grep "/var/etc/passwall/auto_switch.json" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1
|
||||
top -bn1 | grep -v "grep" | grep "/var/etc/${CONFIG}/auto_switch.json" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1
|
||||
if [ "$proxy_status" -eq 200 ]; then
|
||||
#主节点正常,切换到主节点
|
||||
echolog "自动切换检测:${type}主节点正常,切换到主节点!"
|
||||
/usr/share/passwall/app.sh node_switch $type $2 $main_node
|
||||
/usr/share/${CONFIG}/app.sh node_switch $type $2 $main_node
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$status" == 0 ]; then
|
||||
echolog "自动切换检测:${type}节点$(config_n_get $now_node type) $(config_n_get $now_node address) $(config_n_get $now_node port)正常。"
|
||||
#echolog "自动切换检测:${type}节点【$(config_n_get $now_node type) $(config_n_get $now_node remarks)】正常。"
|
||||
return 0
|
||||
elif [ "$status" == 1 ]; then
|
||||
echolog "自动切换检测:${type}节点异常,开始切换节点!"
|
||||
@ -119,7 +124,7 @@ test_auto_switch() {
|
||||
new_node=$next_node
|
||||
fi
|
||||
fi
|
||||
/usr/share/passwall/app.sh node_switch $type $2 $new_node
|
||||
/usr/share/${CONFIG}/app.sh node_switch $type $2 $new_node
|
||||
sleep 10s
|
||||
# 切换节点后等待10秒后再检测一次,如果还是不通继续切,直到可用为止
|
||||
status2=$(test_proxy)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user