luci-app-passwall: update

This commit is contained in:
CN_SZTL 2019-11-30 19:16:05 +08:00
parent 06cf189875
commit 37e16fde63
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
39 changed files with 2969 additions and 2494 deletions

View File

@ -6,8 +6,8 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-passwall
PKG_VERSION:=2.0
PKG_RELEASE:=103-20191120
PKG_VERSION:=3.0
PKG_RELEASE:=113-20191129
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PO2LMO:=./po2lmo
@ -77,7 +77,7 @@ endmenu
endef
define Package/$(PKG_NAME)
CATEGORY:=LuCI
CATEGORY:=LuCI for Lienol
SUBMENU:=3. Applications
TITLE:=LuCI support for PassWall By Lienol
PKGARCH:=all

View File

@ -19,8 +19,8 @@ function index()
end
entry({"admin", "vpn", "passwall", "settings"}, cbi("passwall/global"),
_("Basic Settings"), 1).dependent = true
entry({"admin", "vpn", "passwall", "server_list"},
cbi("passwall/server_list"), _("Server List"), 2).dependent = true
entry({"admin", "vpn", "passwall", "node_list"}, cbi("passwall/node_list"),
_("Node List"), 2).dependent = true
-- entry({"admin", "vpn", "passwall", "auto_switch"},
-- cbi("passwall/auto_switch"), _("Auto Switch"), 3).leaf = true
entry({"admin", "vpn", "passwall", "other"}, cbi("passwall/other"),
@ -33,31 +33,30 @@ function index()
_("Rule Update"), 96).leaf = true
entry({"admin", "vpn", "passwall", "acl"}, cbi("passwall/acl"),
_("Access control"), 97).leaf = true
entry({"admin", "vpn", "passwall", "rulelist"}, cbi("passwall/rulelist"),
entry({"admin", "vpn", "passwall", "rule_list"}, cbi("passwall/rule_list"),
_("Set Blacklist And Whitelist"), 98).leaf = true
entry({"admin", "vpn", "passwall", "log"}, cbi("passwall/log"),
_("Watch Logs"), 99).leaf = true
entry({"admin", "vpn", "passwall", "serverconfig"},
cbi("passwall/serverconfig")).leaf = true
entry({"admin", "vpn", "passwall", "node_config"},
cbi("passwall/node_config")).leaf = true
entry({"admin", "vpn", "passwall", "link_add_server"},
call("link_add_server")).leaf = true
entry({"admin", "vpn", "passwall", "link_add_node"}, call("link_add_node")).leaf =
true
entry({"admin", "vpn", "passwall", "get_log"}, call("get_log")).leaf = true
entry({"admin", "vpn", "passwall", "clear_log"}, call("clear_log")).leaf =
true
entry({"admin", "vpn", "passwall", "server_status"}, call("server_status")).leaf =
true
entry({"admin", "vpn", "passwall", "status"}, call("status")).leaf = true
entry({"admin", "vpn", "passwall", "connect_status"}, call("connect_status")).leaf =
true
entry({"admin", "vpn", "passwall", "check_port"}, call("check_port")).leaf =
true
entry({"admin", "vpn", "passwall", "auto_ping_server"},
call("auto_ping_server")).leaf = true
entry({"admin", "vpn", "passwall", "ping_server"}, call("ping_server")).leaf =
entry({"admin", "vpn", "passwall", "auto_ping_node"}, call("auto_ping_node")).leaf =
true
entry({"admin", "vpn", "passwall", "set_server"}, call("set_server")).leaf =
entry({"admin", "vpn", "passwall", "ping_node"}, call("ping_node")).leaf =
true
entry({"admin", "vpn", "passwall", "copy_server"}, call("copy_server")).leaf =
entry({"admin", "vpn", "passwall", "set_node"}, call("set_node")).leaf =
true
entry({"admin", "vpn", "passwall", "copy_node"}, call("copy_node")).leaf =
true
entry({"admin", "vpn", "passwall", "update_rules"}, call("update_rules")).leaf =
true
@ -90,7 +89,7 @@ function hide_menu()
luci.http.redirect(luci.dispatcher.build_url("admin", "status", "overview"))
end
function link_add_server()
function link_add_node()
local link = luci.http.formvalue("link")
luci.sys.call('rm -f /tmp/links.conf && echo "' .. link ..
'" >> /tmp/links.conf')
@ -105,8 +104,8 @@ end
function clear_log() luci.sys.call("echo '' > /var/log/passwall.log") end
function server_status()
-- local dns_mode = luci.sys.exec("echo -n `uci get " .. appname .. ".@global[0].dns_mode`")
function status()
-- local dns_mode = luci.sys.exec("echo -n `uci -q get " .. appname .. ".@global[0].dns_mode`")
local e = {}
e.dns_mode_status = luci.sys.call("netstat -apn | grep 7913 >/dev/null") ==
0
@ -117,46 +116,48 @@ function server_status()
"ps -w | grep -v grep | grep -i 'log /var/etc/" ..
appname .. "/kcptun' >/dev/null") == 0
local tcp_redir_server_num = luci.sys.exec(
"echo -n `uci get %s.@global_other[0].tcp_redir_server_num`" %
appname)
for i = 1, tcp_redir_server_num, 1 do
local tcp_node_num = luci.sys.exec(
"echo -n `uci -q get %s.@global_other[0].tcp_node_num`" %
appname)
for i = 1, tcp_node_num, 1 do
local listen_port = luci.sys.exec(
string.format(
"[ -f '/var/etc/passwall/port/TCP_%s' ] && echo -n `cat /var/etc/passwall/port/TCP_%s`",
i, i))
e["tcp_redir_server%s_status" % i] =
luci.sys.call(string.format(
"ps -w | grep -v grep | grep -i -E '%s/TCP_%s|brook tproxy -l 0.0.0.0:%s|ipt2socks -T -l %s' >/dev/null",
appname, i, listen_port, listen_port)) == 0
e["tcp_node%s_status" % i] = luci.sys.call(
string.format(
"ps -w | grep -v grep | grep -i -E '%s/TCP_%s|brook tproxy -l 0.0.0.0:%s|ipt2socks -T -l %s' >/dev/null",
appname, i, listen_port,
listen_port)) == 0
end
local udp_redir_server_num = luci.sys.exec(
"echo -n `uci get %s.@global_other[0].udp_redir_server_num`" %
appname)
for i = 1, udp_redir_server_num, 1 do
local udp_node_num = luci.sys.exec(
"echo -n `uci -q get %s.@global_other[0].udp_node_num`" %
appname)
for i = 1, udp_node_num, 1 do
local listen_port = luci.sys.exec(
string.format(
"[ -f '/var/etc/passwall/port/UDP_%s' ] && echo -n `cat /var/etc/passwall/port/UDP_%s`",
i, i))
e["udp_redir_server%s_status" % i] =
luci.sys.call(string.format(
"ps -w | grep -v grep | grep -i -E '%s/UDP_%s|brook tproxy -l 0.0.0.0:%s|ipt2socks -U -l %s' >/dev/null",
appname, i, listen_port, listen_port)) == 0
e["udp_node%s_status" % i] = luci.sys.call(
string.format(
"ps -w | grep -v grep | grep -i -E '%s/UDP_%s|brook tproxy -l 0.0.0.0:%s|ipt2socks -U -l %s' >/dev/null",
appname, i, listen_port,
listen_port)) == 0
end
local socks5_proxy_server_num = luci.sys.exec(
"echo -n `uci get %s.@global_other[0].socks5_proxy_server_num`" %
appname)
for i = 1, socks5_proxy_server_num, 1 do
local socks5_node_num = luci.sys.exec(
"echo -n `uci -q get %s.@global_other[0].socks5_node_num`" %
appname)
for i = 1, socks5_node_num, 1 do
local listen_port = luci.sys.exec(
string.format(
"[ -f '/var/etc/passwall/port/Socks5_%s' ] && echo -n `cat /var/etc/passwall/port/Socks5_%s`",
i, i))
e["socks5_proxy_server%s_status" % i] =
luci.sys.call(string.format(
"ps -w | grep -v grep | grep -i -E '%s/Socks5_%s|brook client -l 0.0.0.0:%s' >/dev/null",
appname, i, listen_port)) == 0
e["socks5_node%s_status" % i] = luci.sys.call(
string.format(
"ps -w | grep -v grep | grep -i -E '%s/Socks5_%s|brook client -l 0.0.0.0:%s' >/dev/null",
appname, i, listen_port)) == 0
end
luci.http.prepare_content("application/json")
luci.http.write_json(e)
@ -177,7 +178,7 @@ function connect_status()
luci.http.write_json(e)
end
function auto_ping_server()
function auto_ping_node()
local e = {}
e.index = luci.http.formvalue("index")
e.ping = luci.sys.exec(
@ -187,41 +188,40 @@ function auto_ping_server()
luci.http.write_json(e)
end
function ping_server()
function ping_node()
local e = {}
local server = luci.http.formvalue("server")
local node = luci.http.formvalue("node")
e.ping = luci.sys.exec(
"echo -n `ping -c 1 -W 1 %q 2>&1 | grep -o 'time=[0-9]*' | awk -F '=' '{print$2}'`" %
server)
node)
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function set_server()
function set_node()
local e = {}
local protocol = luci.http.formvalue("protocol")
local number = luci.http.formvalue("number")
local section = luci.http.formvalue("section")
if protocol == "tcp" then
luci.sys.call(
"uci set passwall.@global[0].tcp_redir_server" .. number .. "=" ..
section ..
" && uci commit passwall && /etc/init.d/passwall restart")
elseif protocol == "udp" then
luci.sys.call(
"uci set passwall.@global[0].udp_redir_server" .. number .. "=" ..
section ..
" && uci commit passwall && /etc/init.d/passwall restart")
elseif protocol == "socks5" then
luci.sys.call("uci set passwall.@global[0].socks5_proxy_server" ..
number .. "=" .. section ..
luci.sys.call("uci set passwall.@global[0].tcp_node" .. number .. "=" ..
section ..
" && uci commit passwall && /etc/init.d/passwall restart")
elseif protocol == "udp" then
luci.sys.call("uci set passwall.@global[0].udp_node" .. number .. "=" ..
section ..
" && uci commit passwall && /etc/init.d/passwall restart")
elseif protocol == "socks5" then
luci.sys.call(
"uci set passwall.@global[0].socks5_node" .. number .. "=" ..
section ..
" && uci commit passwall && /etc/init.d/passwall restart")
end
luci.http.prepare_content("application/json")
luci.http.write_json(e)
end
function copy_server()
function copy_node()
local e = {}
local section = luci.http.formvalue("section")
luci.http.prepare_content("application/json")
@ -233,41 +233,38 @@ function check_port()
retstring = retstring ..
"<font color='red'>暂时不支持UDP检测</font><br />"
local s
local server_name = ""
local node_name = ""
local uci = luci.model.uci.cursor()
uci:foreach("passwall", "servers", function(s)
uci:foreach("passwall", "nodes", function(s)
local ret = ""
local tcp_socket
local udp_socket
if (s.use_kcp and s.use_kcp == "1" and s.kcp_port) or
(s.v2ray_transport and s.v2ray_transport == "mkcp" and s.server_port) then
--[[local port = (s.use_kcp == "1" and s.kcp_port) and s.kcp_port or (s.v2ray_transport == "mkcp" and s.server_port) and s.server_port or nil
(s.v2ray_transport and s.v2ray_transport == "mkcp" and s.port) then
--[[local port = (s.use_kcp == "1" and s.kcp_port) and s.kcp_port or (s.v2ray_transport == "mkcp" and s.port) and s.port or nil
if port then
udp_socket = nixio.socket("inet", "dgram")
udp_socket:setopt("socket", "rcvtimeo", 3)
udp_socket:setopt("socket", "sndtimeo", 3)
udp_socket:sendto("test", s.server, port)
udp_socket:sendto("test", s.address, port)
r,c,d=udp_socket:recvfrom(10)
ret=""
end--]]
else
if s.server_type and s.server and s.server_port and s.remarks then
server_name = "%s[%s] %s:%s" %
{
s.server_type, s.remarks, s.server, s.server_port
}
if s.type and s.address and s.port and s.remarks then
node_name = "%s[%s] %s:%s" %
{s.type, s.remarks, s.address, s.port}
end
tcp_socket = nixio.socket("inet", "stream")
tcp_socket:setopt("socket", "rcvtimeo", 3)
tcp_socket:setopt("socket", "sndtimeo", 3)
ret = tcp_socket:connect(s.server, s.server_port)
ret = tcp_socket:connect(s.address, s.port)
if tostring(ret) == "true" then
retstring =
retstring .. "<font color='green'>" .. server_name ..
" OK.</font><br />"
retstring = retstring .. "<font color='green'>" .. node_name ..
" OK.</font><br />"
else
retstring = retstring .. "<font color='red'>" .. server_name ..
retstring = retstring .. "<font color='red'>" .. node_name ..
" Error.</font><br />"
end
ret = ""

View File

@ -1,16 +1,16 @@
local sys = require "luci.sys"
local webadmin = require "luci.tools.webadmin"
local uci = require"luci.model.uci".cursor()
local api = require "luci.model.cbi.passwall.api.api"
local appname = "passwall"
local n = {}
uci:foreach(appname, "servers", function(e)
if e.server_type and e.server and e.remarks then
uci:foreach(appname, "nodes", function(e)
if e.type and e.address and e.remarks then
if e.use_kcp and e.use_kcp == "1" then
n[e[".name"]] = "%s+%s[%s]" %
{e.server_type, "Kcptun", e.remarks}
n[e[".name"]] = "%s+%s[%s]" % {e.type, "Kcptun", e.remarks}
else
n[e[".name"]] = "%s[%s]" % {e.server_type, e.remarks}
n[e[".name"]] = "%s[%s]" % {e.type, e.remarks}
end
end
end)
@ -23,7 +23,7 @@ m = Map("passwall")
-- [[ ACLs Settings ]]--
s = m:section(TypedSection, "acl_rule", translate("ACLs"), translate(
"ACLs is a tools which used to designate specific IP proxy mode"))
"ACLs is a tools which used to designate specific IP proxy mode, IP or MAC address can be entered."))
s.template = "cbi/tblsection"
s.sortable = true
s.anonymous = true
@ -33,12 +33,12 @@ s.addremove = true
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
---- ACL Remarks
o = s:option(Value, "aclremarks", translate("ACL Remarks"))
---- Remarks
o = s:option(Value, "remarks", translate("Remarks"))
o.rmempty = true
---- IP Address
o = s:option(Value, "ipaddr", translate("IP Address"))
o = s:option(Value, "ip", translate("IP"))
o.datatype = "ip4addr"
o.rmempty = true
@ -54,27 +54,19 @@ for index, key in pairs(ips) do o:value(key, temp[key]) end
-- webadmin.cbi_add_knownips(o)
---- MAC Address
o = s:option(Value, "macaddr", translate("MAC Address"))
o = s:option(Value, "mac", translate("MAC"))
o.rmempty = true
sys.net.mac_hints(function(e, t) o:value(e, "%s " % {e}) end)
---- TCP Redir Server
local tcp_redir_server_num = uci:get(appname, "@global_other[0]",
"tcp_redir_server_num")
o = s:option(ListValue, "tcp_redir_server", translate("TCP Server"))
o:value("1",translate("TCP Redir Server").." 1")
if tcp_redir_server_num and tonumber(tcp_redir_server_num) >= 2 then
for i = 2, tcp_redir_server_num, 1 do o:value(i,translate("TCP Redir Server").." "..i) end
end
---- TCP Node
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
o = s:option(ListValue, "tcp_node", translate("TCP Node"))
for i = 1, tcp_node_num, 1 do o:value(i, "TCP_" .. i) end
---- UDP Redir Server
local udp_redir_server_num = uci:get(appname, "@global_other[0]",
"udp_redir_server_num")
o = s:option(ListValue, "udp_redir_server", translate("UDP Server"))
o:value("1",translate("UDP Redir Server").." 1")
if udp_redir_server_num and tonumber(udp_redir_server_num) >= 2 then
for i = 2, udp_redir_server_num, 1 do o:value(i,translate("UDP Redir Server").." "..i) end
end
---- UDP Node
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
o = s:option(ListValue, "udp_node", translate("UDP Node"))
for i = 1, udp_node_num, 1 do o:value(i, "UDP_" .. i) end
---- Proxy Mode
o = s:option(ListValue, "proxy_mode", translate("Proxy Mode"))

View File

@ -5,6 +5,8 @@ local uci = require"luci.model.uci".cursor()
local util = require "luci.util"
local i18n = require "luci.i18n"
local appname = "passwall"
local wget = "/usr/bin/wget"
local wget_args = {
"--no-check-certificate", "--quiet", "--timeout=100", "--tries=3"
@ -15,6 +17,19 @@ local command_timeout = 300
local LEDE_BOARD = nil
local DISTRIB_TARGET = nil
function uci_get_type(type, config)
return uci:get(appname, "@" .. type .. "[0]", config) or
sys.exec(
"echo -n `uci -q get " .. appname .. ".@" .. type .. "[0]." ..
config .. "`")
end
function uci_get_type_id(id, config)
return uci:get(appname, id, config) or
sys.exec("echo -n `uci -q get " .. appname .. "." .. id .. "." ..
config .. "`")
end
function _unpack(t, i)
i = i or 1
if t[i] ~= nil then return t[i], _unpack(t, i + 1) end

View File

@ -1,7 +1,6 @@
module("luci.model.cbi.passwall.api.brook", package.seeall)
local fs = require "nixio.fs"
local sys = require "luci.sys"
local uci = require"luci.model.uci".cursor()
local util = require "luci.util"
local i18n = require "luci.i18n"
local api = require "luci.model.cbi.passwall.api.api"
@ -19,9 +18,7 @@ local LEDE_BOARD = nil
local DISTRIB_TARGET = nil
function get_brook_file_path()
return uci:get("passwall", "global_app", "brook_client_file") or
luci.sys.exec(
"echo -n `uci get passwall.@global_app[0].brook_client_file`")
return api.uci_get_type("global_app", "brook_file")
end
function get_brook_version(file)

View File

@ -1,22 +1,22 @@
local ucursor = require"luci.model.uci".cursor()
local json = require "luci.jsonc"
local server_section = arg[1]
local node_section = arg[1]
local run_type = arg[2]
local proxy_port = arg[3]
local server = ucursor:get_all("passwall", server_section)
local node = ucursor:get_all("passwall", node_section)
local trojan = {
run_type = run_type,
local_addr = "0.0.0.0",
local_port = proxy_port,
remote_addr = server.server,
remote_port = tonumber(server.server_port),
password = {server.password},
remote_addr = node.address,
remote_port = tonumber(node.port),
password = {node.password},
log_level = 1,
ssl = {
verify = true,
verify = (node.trojan_verify_cert == "1") and true or false,
verify_hostname = true,
cert = "",
cert = node.trojan_cert_path,
cipher = "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RSA-AES128-GCM-SHA256:RSA-AES256-GCM-SHA384:RSA-AES128-SHA:RSA-AES256-SHA:RSA-3DES-EDE-SHA",
sni = "",
alpn = {"h2", "http/1.1"},
@ -27,7 +27,7 @@ local trojan = {
tcp = {
no_delay = true,
keep_alive = true,
fast_open = (server.fast_open == "true") and true or false,
fast_open = (node.tcp_fast_open == "true") and true or false,
fast_open_qlen = 20
}
}

View File

@ -1,11 +1,12 @@
local ucursor = require"luci.model.uci".cursor()
local json = require "luci.jsonc"
local server_section = arg[1]
local node_section = arg[1]
local proto = arg[2]
local redir_port = arg[3]
local socks5_proxy_port = arg[4]
local server = ucursor:get_all("passwall", server_section)
local node = ucursor:get_all("passwall", node_section)
local inbound_json = {}
local inboundDetour_json = nil
if socks5_proxy_port ~= "nil" then
inbound_json = {
@ -23,6 +24,25 @@ if redir_port ~= "nil" then
settings = {network = proto, followRedirect = true},
sniffing = {enabled = true, destOverride = {"http", "tls"}}
}
if proto == "tcp" and node.v2ray_tcp_socks == "1" then
inboundDetour_json = {
{
listen = "0.0.0.0",
port = tonumber(node.v2ray_tcp_socks_port),
protocol = "socks",
settings = {
auth = node.v2ray_tcp_socks_auth,
accounts = (node.v2ray_tcp_socks_auth == "password") and {
{
user = node.v2ray_tcp_socks_auth_username,
pass = node.v2ray_tcp_socks_auth_password
}
} or nil,
udp = true
}
}
}
end
end
local v2ray = {
@ -32,64 +52,64 @@ local v2ray = {
},
-- 传入连接
inbound = inbound_json,
inboundDetour = inboundDetour_json,
-- 传出连接
outbound = {
protocol = server.v2ray_protocol,
protocol = node.v2ray_protocol,
settings = {
vnext = {
{
address = server.server,
port = tonumber(server.server_port),
address = node.address,
port = tonumber(node.port),
users = {
{
id = server.v2ray_VMess_id,
alterId = tonumber(server.v2ray_VMess_alterId),
level = tonumber(server.v2ray_VMess_level),
security = server.v2ray_security
id = node.v2ray_VMess_id,
alterId = tonumber(node.v2ray_VMess_alterId),
level = tonumber(node.v2ray_VMess_level),
security = node.v2ray_security
}
}
}
}
},
mux = {
enabled = (server.v2ray_mux == "1") and true or false,
concurrency = (server.v2ray_mux_concurrency) and
tonumber(server.v2ray_mux_concurrency) or 8
enabled = (node.v2ray_mux == "1") and true or false,
concurrency = (node.v2ray_mux_concurrency) and
tonumber(node.v2ray_mux_concurrency) or 8
},
-- 底层传输配置
streamSettings = {
network = server.v2ray_transport,
security = server.v2ray_stream_security,
tlsSettings = (server.v2ray_stream_security == "tls") and {
serverName = server.tls_serverName,
allowInsecure = (server.tls_allowInsecure == "1") and true or
network = node.v2ray_transport,
security = node.v2ray_stream_security,
tlsSettings = (node.v2ray_stream_security == "tls") and {
serverName = node.tls_serverName,
allowInsecure = (node.tls_allowInsecure == "1") and true or
false
} or nil,
kcpSettings = (server.v2ray_transport == "mkcp") and {
mtu = tonumber(server.v2ray_mkcp_mtu),
tti = tonumber(server.v2ray_mkcp_tti),
uplinkCapacity = tonumber(server.v2ray_mkcp_uplinkCapacity),
downlinkCapacity = tonumber(server.v2ray_mkcp_downlinkCapacity),
congestion = (server.v2ray_mkcp_congestion == "1") and true or
kcpSettings = (node.v2ray_transport == "mkcp") and {
mtu = tonumber(node.v2ray_mkcp_mtu),
tti = tonumber(node.v2ray_mkcp_tti),
uplinkCapacity = tonumber(node.v2ray_mkcp_uplinkCapacity),
downlinkCapacity = tonumber(node.v2ray_mkcp_downlinkCapacity),
congestion = (node.v2ray_mkcp_congestion == "1") and true or
false,
readBufferSize = tonumber(server.v2ray_mkcp_readBufferSize),
writeBufferSize = tonumber(server.v2ray_mkcp_writeBufferSize),
header = {type = server.v2ray_mkcp_guise}
readBufferSize = tonumber(node.v2ray_mkcp_readBufferSize),
writeBufferSize = tonumber(node.v2ray_mkcp_writeBufferSize),
header = {type = node.v2ray_mkcp_guise}
} or nil,
wsSettings = (server.v2ray_transport == "ws") and {
path = server.v2ray_ws_path,
headers = (server.v2ray_ws_host ~= nil) and
{Host = server.v2ray_ws_host} or nil
wsSettings = (node.v2ray_transport == "ws") and {
path = node.v2ray_ws_path,
headers = (node.v2ray_ws_host ~= nil) and
{Host = node.v2ray_ws_host} or nil
} or nil,
httpSettings = (server.v2ray_transport == "h2") and
{path = server.v2ray_h2_path, host = server.v2ray_h2_host} or
nil,
dsSettings = (server.v2ray_transport == "ds") and
{path = server.v2ray_ds_path} or nil,
quicSettings = (server.v2ray_transport == "quic") and {
security = server.v2ray_quic_security,
key = server.v2ray_quic_key,
header = {type = server.v2ray_quic_guise}
httpSettings = (node.v2ray_transport == "h2") and
{path = node.v2ray_h2_path, host = node.v2ray_h2_host} or nil,
dsSettings = (node.v2ray_transport == "ds") and
{path = node.v2ray_ds_path} or nil,
quicSettings = (node.v2ray_transport == "quic") and {
security = node.v2ray_quic_security,
key = node.v2ray_quic_key,
header = {type = node.v2ray_quic_guise}
} or nil
}
},

View File

@ -1,7 +1,6 @@
module("luci.model.cbi.passwall.api.kcptun", package.seeall)
local fs = require "nixio.fs"
local sys = require "luci.sys"
local uci = require"luci.model.uci".cursor()
local util = require "luci.util"
local i18n = require "luci.i18n"
local api = require "luci.model.cbi.passwall.api.api"
@ -18,9 +17,7 @@ local LEDE_BOARD = nil
local DISTRIB_TARGET = nil
function get_kcptun_file_path()
return uci:get("passwall", "global_app", "kcptun_client_file") or
luci.sys.exec(
"echo -n `uci get passwall.@global_app[0].kcptun_client_file`")
return api.uci_get_type("global_app", "kcptun_client_file")
end
function get_kcptun_version(file)

View File

@ -1,7 +1,6 @@
module("luci.model.cbi.passwall.api.v2ray", package.seeall)
local fs = require "nixio.fs"
local sys = require "luci.sys"
local uci = require"luci.model.uci".cursor()
local util = require "luci.util"
local i18n = require "luci.i18n"
local ipkg = require("luci.model.ipkg")
@ -20,9 +19,7 @@ local DISTRIB_TARGET = nil
local is_armv7 = false
function get_v2ray_file_path()
return uci:get("passwall", "global_app", "v2ray_client_file") or
sys.exec(
"echo -n `uci get passwall.@global_app[0].v2ray_client_file`")
return api.uci_get_type("global_app", "v2ray_file")
end
function get_v2ray_version()

View File

@ -1,10 +1,10 @@
local uci = require "luci.model.uci".cursor()
local uci = require"luci.model.uci".cursor()
local appname = "passwall"
local n = {}
uci:foreach(appname, "servers", function(e)
if e.server_type and e.server and e.remarks then
n[e[".name"]] = "%s[%s] %s" % {e.server_type, e.remarks, e.server}
uci:foreach(appname, "nodes", function(e)
if e.type and e.address and e.remarks then
n[e[".name"]] = "%s[%s] %s" % {e.type, e.remarks, e.address}
end
end)
@ -30,7 +30,7 @@ o.default = "10"
---- Tcp Redir Server
o = s:option(DynamicList, "tcp_redir_server",
translate("List of alternate TCP forwarding servers"), translate(
translate("List of alternate TCP forwarding nodes"), translate(
"When there is no server, an automatic reconnect scheme is used"))
for _, key in pairs(key_table) do o:value(key, n[key]) end

View File

@ -1,83 +1,76 @@
local e = require "nixio.fs"
local e = require "luci.sys"
local net = require "luci.model.network".init()
local uci = require "luci.model.uci".cursor()
local net = require"luci.model.network".init()
local uci = require"luci.model.uci".cursor()
local ifaces = e.net:devices()
local appname = "passwall"
local servers_name = {}
local servers_port = {}
local nodes_name = {}
local nodes_port = {}
uci:foreach(appname, "servers", function(e)
if e.server and e.server_port and e.server ~= "127.0.0.1" then
servers_name[e[".name"]] = "%s" % {e.server}
servers_port[e[".name"]] = "%s" % {e.server_port}
uci:foreach(appname, "nodes", function(e)
if e.address and e.port and e.address ~= "127.0.0.1" then
nodes_name[e[".name"]] = "%s" % {e.address}
nodes_port[e[".name"]] = "%s" % {e.port}
end
end)
m = Map("passwall")
-- [[ Haproxy Settings ]]--
s = m:section(TypedSection, "global_haproxy", translate("Admin Status"),
translate(
"In the browser input routing IP plus port access, such as:192.168.1.1:1188") ..
"<br><input type='button' class='cbi-button cbi-input-reload' value='" ..
s = m:section(TypedSection, "global_haproxy", translate("Load Balancing"),
"<input type='button' class='cbi-button cbi-input-reload' value='" ..
translate("Click here to setting your Load Balancing") ..
"' onclick=javascript:window.open('http://koolshare.cn/thread-65561-1-1.html','target'); />")
s.anonymous = true
---- Admin Enable
o = s:option(Flag, "admin_enable", translate("Enable Admin Status"))
---- Balancing Enable
o = s:option(Flag, "balancing_enable", translate("Enable Load Balancing"))
o.rmempty = false
o.default = false
---- Admin Port
o = s:option(Value, "admin_port", translate("Admin Status port setting"))
o.default = "1188"
o:depends("admin_enable", 1)
---- Admin User
o = s:option(Value, "admin_user", translate("Admin Status User"))
---- Console Username
o = s:option(Value, "console_user", translate("Console Username"))
o.default = "admin"
o:depends("admin_enable", 1)
o:depends("balancing_enable", 1)
---- Admin Password
o = s:option(Value, "admin_password", translate("Admin Status Password"))
---- Console Password
o = s:option(Value, "console_password", translate("Console Password"))
o.password = true
o.default = "admin"
o:depends("admin_enable", 1)
o:depends("balancing_enable", 1)
---- Balancing Enable
o = s:option(Flag, "balancing_enable",
translate("Enable or Disable Load Balancing"))
o.rmempty = false
o.default = false
---- Console Port
o = s:option(Value, "console_port", translate("Console Port"), translate(
"In the browser input routing IP plus port access, such as:192.168.1.1:1188"))
o.default = "1188"
o:depends("balancing_enable", 1)
---- Haproxy Port
o = s:option(Value, "haproxy_port", translate("Haproxy port setting"))
o = s:option(Value, "haproxy_port", translate("Haproxy Port"))
o.default = "1181"
o:depends("balancing_enable", 1)
-- [[ Balancing Settings ]]--
s = m:section(TypedSection, "balancing",
translate("Load Balancing Server Setting"), translate(
"Add a load balancing server, note reading above requirements."))
s = m:section(TypedSection, "balancing", translate("Load Balancing Setting"),
translate(
"Add a node, Export Of Multi WAN Only support Multi Wan. If no effect, please go to mwan3 to set. Load specific gravity range 1-256. Multiple primary servers can be load balanced, standby will only be enabled when the primary server is offline!"))
s.template = "cbi/tblsection"
s.sortable = true
s.anonymous = true
s.addremove = true
---- Server Address
o = s:option(Value, "lbss", translate("Server Address"))
for m, s in pairs(servers_name) do o:value(s) end
---- Node Address
o = s:option(Value, "lbss", translate("Node Address"))
for m, s in pairs(nodes_name) do o:value(s) end
o.rmempty = false
---- Server Port
o = s:option(Value, "lbort", translate("Server Port"))
for m, s in pairs(servers_port) do o:value(s) end
---- Node Port
o = s:option(Value, "lbort", translate("Node Port"))
for m, s in pairs(nodes_port) do o:value(s) end
o.rmempty = false
---- Server weight
o = s:option(Value, "lbweight", translate("Server weight"))
---- Node Weight
o = s:option(Value, "lbweight", translate("Node Weight"))
o.default = "5"
o.rmempty = false
@ -96,10 +89,10 @@ end
o.default = 0
o.rmempty = false
---- Backup
o = s:option(ListValue, "backup", translate("Server Mode"))
o:value(0, translate("Primary Server"))
o:value(1, translate("Standby Server"))
---- Mode
o = s:option(ListValue, "backup", translate("Mode"))
o:value(0, translate("Primary"))
o:value(1, translate("Standby"))
o.rmempty = false
return m

View File

@ -3,6 +3,7 @@ local fs = require "nixio.fs"
local sys = require "luci.sys"
local ipkg = require("luci.model.ipkg")
local uci = require"luci.model.uci".cursor()
local api = require "luci.model.cbi.passwall.api.api"
local appname = "passwall"
local function is_installed(e) return ipkg.installed(e) end
@ -13,19 +14,14 @@ local function is_finded(e)
false
end
local function has_udp_relay()
return sys.call("lsmod | grep TPROXY >/dev/null") == 0
end
local n = {}
uci:foreach(appname, "servers", function(e)
if e.server_type and e.server and e.remarks then
uci:foreach(appname, "nodes", function(e)
if e.type and e.address and e.remarks then
if e.use_kcp and e.use_kcp == "1" then
n[e[".name"]] = "%s+%s[%s] %s" %
{e.server_type, "Kcptun", e.remarks, e.server}
{e.type, "Kcptun", e.remarks, e.address}
else
n[e[".name"]] = "%s[%s] %s" %
{e.server_type, e.remarks, e.server}
n[e[".name"]] = "%s[%s] %s" % {e.type, e.remarks, e.address}
end
end
end)
@ -35,67 +31,62 @@ for key, _ in pairs(n) do table.insert(key_table, key) end
table.sort(key_table)
m = Map(appname)
m:append(Template("passwall/global/status"))
local status_use_big_icon = api.uci_get_type("global_other",
"status_use_big_icon")
if status_use_big_icon and status_use_big_icon == "1" then
m:append(Template("passwall/global/status"))
else
m:append(Template("passwall/global/status2"))
end
-- [[ Global Settings ]]--
s = m:section(TypedSection, "global", translate("Global Settings"))
s.anonymous = true
s.addremove = false
---- TCP Redir Server
o = s:option(ListValue, "tcp_redir_server1", translate("TCP Redir Server"),
translate("For used to surf the Internet."))
o:value("nil", translate("Close"))
for _, key in pairs(key_table) do o:value(key, n[key]) end
local tcp_redir_server_num = uci:get(appname, "@global_other[0]",
"tcp_redir_server_num")
if tcp_redir_server_num and tonumber(tcp_redir_server_num) >= 2 then
for i = 2, tcp_redir_server_num, 1 do
o = s:option(ListValue, "tcp_redir_server" .. i,
translate("TCP Redir Server") .. " " .. i)
o:value("nil", translate("Close"))
for _, key in pairs(key_table) do o:value(key, n[key]) end
---- TCP Node
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
for i = 1, tcp_node_num, 1 do
if i == 1 then
o = s:option(ListValue, "tcp_node" .. i, translate("TCP Node"),
translate("For used to surf the Internet."))
else
o = s:option(ListValue, "tcp_node" .. i,
translate("TCP Node") .. " " .. i)
end
end
---- UDP Redir Server
if has_udp_relay() then
o = s:option(ListValue, "udp_redir_server1", translate("UDP Redir Server"),
translate("For Game Mode or DNS resolution and more.") ..
translate("The selected server will not use Kcptun."))
o:value("nil", translate("Close"))
o:value("default", translate("Same as the tcp redir server"))
for _, key in pairs(key_table) do o:value(key, n[key]) end
local udp_redir_server_num = uci:get(appname, "@global_other[0]",
"udp_redir_server_num")
if udp_redir_server_num and tonumber(udp_redir_server_num) >= 2 then
for i = 2, udp_redir_server_num, 1 do
o = s:option(ListValue, "udp_redir_server" .. i,
translate("UDP Redir Server") .. " " .. i)
o:value("nil", translate("Close"))
for _, key in pairs(key_table) do o:value(key, n[key]) end
end
end
end
---- Socks5 Proxy Server
o = s:option(ListValue, "socks5_proxy_server1",
translate("Socks5 Proxy Server"),
translate("The client can use the router's Socks5 proxy"))
o:value("nil", translate("Close"))
for _, key in pairs(key_table) do o:value(key, n[key]) end
local socks5_proxy_server_num = uci:get(appname, "@global_other[0]",
"socks5_proxy_server_num")
if socks5_proxy_server_num and tonumber(socks5_proxy_server_num) >= 2 then
for i = 2, socks5_proxy_server_num, 1 do
o = s:option(ListValue, "socks5_proxy_server" .. i,
translate("Socks5 Proxy Server") .. " " .. i)
---- UDP Node
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
for i = 1, udp_node_num, 1 do
if i == 1 then
o = s:option(ListValue, "udp_node" .. i, translate("UDP Node"),
translate("For Game Mode or DNS resolution and more.") ..
translate("The selected server will not use Kcptun."))
o:value("nil", translate("Close"))
o:value("default", translate("Same as the tcp node"))
else
o = s:option(ListValue, "udp_node" .. i,
translate("UDP Node") .. " " .. i)
o:value("nil", translate("Close"))
for _, key in pairs(key_table) do o:value(key, n[key]) end
end
for _, key in pairs(key_table) do o:value(key, n[key]) end
end
---- Socks5 Node
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
for i = 1, socks5_node_num, 1 do
if i == 1 then
o = s:option(ListValue, "socks5_node" .. i, translate("Socks5 Node"),
translate("The client can use the router's Socks5 proxy"))
else
o = s:option(ListValue, "socks5_node" .. i,
translate("Socks5 Node") .. " " .. i)
end
o:value("nil", translate("Close"))
for _, key in pairs(key_table) do o:value(key, n[key]) end
end
---- DNS Forward Mode

View File

@ -44,117 +44,109 @@ local v2ray_header_type_list = {
"none", "srtp", "utp", "wechat-video", "dtls", "wireguard"
}
m = Map(appname, translate("ShadowSocks Server Config"),
translate("TCP quick open server does not support do not open.") ..
translate("HAProxy cannot be used with KCP."))
m = Map(appname, translate("Node Config"))
m.redirect = d.build_url("admin", "vpn", "passwall")
s = m:section(NamedSection, arg[1], "servers", "")
s = m:section(NamedSection, arg[1], "nodes", "")
s.addremove = false
s.dynamic = false
remarks = s:option(Value, "remarks", translate("Node Remarks"))
remarks.default = translate("Node Remarks")
remarks.default = translate("Remarks")
remarks.rmempty = false
server_type = s:option(ListValue, "server_type", translate("Server Type"))
type = s:option(ListValue, "type", translate("Type"))
if ((is_installed("redsocks2") or is_finded("redsocks2")) or
(is_installed("ipt2socks") or is_finded("ipt2socks"))) then
server_type:value("Socks5", translate("Socks5 Server"))
end
if is_finded("ss-redir") then
server_type:value("SS", translate("Shadowsocks Server"))
end
if is_finded("ssr-redir") then
server_type:value("SSR", translate("ShadowsocksR Server"))
end
if is_installed("v2ray") then
server_type:value("V2ray", translate("V2ray Server"))
type:value("Socks5", translate("Socks5"))
end
if is_finded("ss-redir") then type:value("SS", translate("Shadowsocks")) end
if is_finded("ssr-redir") then type:value("SSR", translate("ShadowsocksR")) end
if is_installed("v2ray") then type:value("V2ray", translate("V2ray")) end
if is_installed("brook") or is_finded("brook") then
server_type:value("Brook", translate("Brook Server"))
type:value("Brook", translate("Brook"))
end
if is_installed("trojan") or is_finded("trojan") then
server_type:value("Trojan", translate("Trojan Server"))
type:value("Trojan", translate("Trojan"))
end
v2ray_protocol = s:option(ListValue, "v2ray_protocol",
translate("V2ray Protocol"))
v2ray_protocol:value("vmess", translate("Vmess"))
v2ray_protocol:depends("server_type", "V2ray")
v2ray_protocol:depends("type", "V2ray")
server = s:option(Value, "server",
translate("Server Address (Support Domain Name)"))
server.rmempty = false
address = s:option(Value, "address", translate("Address (Support Domain Name)"))
address.rmempty = false
use_ipv6 = s:option(Flag, "use_ipv6", translate("Use IPv6"))
use_ipv6.default = 0
server_port = s:option(Value, "server_port", translate("Server Port"))
server_port.datatype = "port"
server_port.rmempty = false
port = s:option(Value, "port", translate("Port"))
port.datatype = "port"
port.rmempty = false
username = s:option(Value, "username", translate("Username"))
username:depends("server_type", "Socks5")
username:depends("type", "Socks5")
password = s:option(Value, "password", translate("Password"))
password.password = true
password:depends("server_type", "Socks5")
password:depends("server_type", "SS")
password:depends("server_type", "SSR")
password:depends("server_type", "Brook")
password:depends("server_type", "Trojan")
password:depends("type", "Socks5")
password:depends("type", "SS")
password:depends("type", "SSR")
password:depends("type", "Brook")
password:depends("type", "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
ss_encrypt_method:depends("server_type", "SS")
ss_encrypt_method:depends("type", "SS")
ssr_encrypt_method = s:option(ListValue, "ssr_encrypt_method",
translate("Encrypt Method"))
for a, t in ipairs(ssr_encrypt_method_list) do ssr_encrypt_method:value(t) end
ssr_encrypt_method:depends("server_type", "SSR")
ssr_encrypt_method:depends("type", "SSR")
v2ray_security = s:option(ListValue, "v2ray_security",
translate("Encrypt Method"))
for a, t in ipairs(v2ray_security_list) do v2ray_security:value(t) end
v2ray_security:depends("server_type", "V2ray")
v2ray_security:depends("type", "V2ray")
protocol = s:option(ListValue, "protocol", translate("Protocol"))
for a, t in ipairs(ssr_protocol_list) do protocol:value(t) end
protocol:depends("server_type", "SSR")
protocol:depends("type", "SSR")
protocol_param = s:option(Value, "protocol_param", translate("Protocol_param"))
protocol_param:depends("server_type", "SSR")
protocol_param:depends("type", "SSR")
obfs = s:option(ListValue, "obfs", translate("Obfs"))
for a, t in ipairs(ssr_obfs_list) do obfs:value(t) end
obfs:depends("server_type", "SSR")
obfs:depends("type", "SSR")
obfs_param = s:option(Value, "obfs_param", translate("Obfs_param"))
obfs_param:depends("server_type", "SSR")
obfs_param:depends("type", "SSR")
timeout = s:option(Value, "timeout", translate("Connection Timeout"))
timeout.datatype = "uinteger"
timeout.default = 300
timeout:depends("server_type", "SS")
timeout:depends("server_type", "SSR")
timeout:depends("type", "SS")
timeout:depends("type", "SSR")
fast_open = s:option(ListValue, "fast_open", translate("Fast_open"))
fast_open:value("false")
fast_open:value("true")
fast_open:depends("server_type", "SS")
fast_open:depends("server_type", "SSR")
fast_open:depends("server_type", "Trojan")
tcp_fast_open = s:option(ListValue, "tcp_fast_open", translate("TCP Fast Open"),
translate("Need node support required"))
tcp_fast_open:value("false")
tcp_fast_open:value("true")
tcp_fast_open:depends("type", "SS")
tcp_fast_open:depends("type", "SSR")
tcp_fast_open:depends("type", "Trojan")
use_kcp = s:option(Flag, "use_kcp", translate("Use Kcptun"),
"<span style='color:red'>" .. translate(
"Please confirm whether the Kcptun is installed. If not, please go to Rule Update download installation.") ..
"</span>")
use_kcp.default = 0
use_kcp:depends("server_type", "SS")
use_kcp:depends("server_type", "SSR")
use_kcp:depends("server_type", "Brook")
use_kcp:depends("type", "SS")
use_kcp:depends("type", "SSR")
use_kcp:depends("type", "Brook")
kcp_server = s:option(Value, "kcp_server", translate("Kcptun Server"))
kcp_server.placeholder = translate("Default:Current Server")
@ -186,7 +178,7 @@ v2ray_VMess_alterId:depends("v2ray_protocol", "vmess")
v2ray_VMess_level =
s:option(Value, "v2ray_VMess_level", translate("User Level"))
v2ray_VMess_level.default = 1
v2ray_VMess_level:depends("server_type", "V2ray")
v2ray_VMess_level:depends("type", "V2ray")
v2ray_stream_security = s:option(ListValue, "v2ray_stream_security",
translate("Transport Layer Encryption"),
@ -194,7 +186,7 @@ v2ray_stream_security = s:option(ListValue, "v2ray_stream_security",
'Whether or not transport layer encryption is enabled, the supported options are "none" for unencrypted (default) and "TLS" for using TLS.'))
v2ray_stream_security:value("none", "none")
v2ray_stream_security:value("tls", "tls")
v2ray_stream_security:depends("server_type", "V2ray")
v2ray_stream_security:depends("type", "V2ray")
-- [[ TLS部分 ]] --
tls_serverName = s:option(Value, "tls_serverName", translate("Domain"))
@ -214,7 +206,7 @@ v2ray_transport:value("ws", "WebSocket")
v2ray_transport:value("h2", "HTTP/2")
v2ray_transport:value("ds", "DomainSocket")
v2ray_transport:value("quic", "QUIC")
v2ray_transport:depends("server_type", "V2ray")
v2ray_transport:depends("type", "V2ray")
-- [[ TCP部分 ]]--
@ -311,35 +303,75 @@ v2ray_quic_guise:depends("v2ray_transport", "quic")
-- [[ 其它 ]]--
v2ray_mux = s:option(Flag, "v2ray_mux", translate("Mux"))
v2ray_mux:depends("server_type", "V2ray")
v2ray_mux:depends("type", "V2ray")
v2ray_mux_concurrency = s:option(Value, "v2ray_mux_concurrency",
translate("Mux Concurrency"))
v2ray_mux_concurrency.default = 8
v2ray_mux_concurrency:depends("v2ray_mux", "1")
-- [[ 当作为TCP节点时是否同时开启socks代理 ]]
v2ray_tcp_socks = s:option(Flag, "v2ray_tcp_socks", translate("TCP Open Socks"),
translate(
"When using this TCP node, whether to open the socks proxy at the same time"))
v2ray_tcp_socks.default = 0
v2ray_tcp_socks:depends("type", "V2ray")
v2ray_tcp_socks_port = s:option(Value, "v2ray_tcp_socks_port",
"Socks5 " .. translate("Port"),
translate("Do not conflict with other ports"))
v2ray_tcp_socks_port.datatype = "port"
v2ray_tcp_socks_port.default = 1080
v2ray_tcp_socks_port:depends("v2ray_tcp_socks", "1")
v2ray_tcp_socks_auth = s:option(ListValue, "v2ray_tcp_socks_auth",
translate("Socks for authentication"),
translate(
'Socks protocol authentication, support anonymous and password.'))
v2ray_tcp_socks_auth:value("noauth", translate("anonymous"))
v2ray_tcp_socks_auth:value("password", translate("User Password"))
v2ray_tcp_socks_auth:depends("v2ray_tcp_socks", "1")
v2ray_tcp_socks_auth_username = s:option(Value, "v2ray_tcp_socks_auth_username",
"Socks5 " .. translate("Username"))
v2ray_tcp_socks_auth_username:depends("v2ray_tcp_socks_auth", "password")
v2ray_tcp_socks_auth_password = s:option(Value, "v2ray_tcp_socks_auth_password",
"Socks5 " .. translate("Password"))
v2ray_tcp_socks_auth_password:depends("v2ray_tcp_socks_auth", "password")
-- [[ Trojan Cert ]]--
trojan_verify_cert = s:option(Flag, "trojan_verify_cert",
translate("Trojan Verify Cert"))
trojan_verify_cert:depends("type", "Trojan")
trojan_cert_path = s:option(Value, "trojan_cert_path",
translate("Trojan Cert Path"))
trojan_cert_path.default = ""
trojan_cert_path:depends("trojan_verify_cert", "1")
-- v2ray_insecure = s:option(Flag, "v2ray_insecure", translate("allowInsecure"))
-- v2ray_insecure:depends("server_type", "V2ray")
-- v2ray_insecure:depends("type", "V2ray")
function rmempty_restore()
password.rmempty = true
timeout.rmempty = true
fast_open.rmempty = true
tcp_fast_open.rmempty = true
v2ray_protocol.rmempty = true
v2ray_VMess_id.rmempty = true
v2ray_VMess_alterId.rmempty = true
end
server_type.validate = function(self, value)
type.validate = function(self, value)
rmempty_restore()
if value == "SS" then
password.rmempty = false
timeout.rmempty = false
fast_open.rmempty = false
tcp_fast_open.rmempty = false
elseif value == "SSR" then
password.rmempty = false
timeout.rmempty = false
fast_open.rmempty = false
tcp_fast_open.rmempty = false
elseif value == "V2ray" then
v2ray_protocol.rmempty = false
v2ray_VMess_id.rmempty = false
@ -348,7 +380,7 @@ server_type.validate = function(self, value)
password.rmempty = false
elseif value == "Trojan" then
password.rmempty = false
fast_open.rmempty = false
tcp_fast_open.rmempty = false
end
return value
end

View File

@ -0,0 +1,99 @@
local d = require "luci.dispatcher"
local fs = require "nixio.fs"
local sys = require "luci.sys"
local uci = require"luci.model.uci".cursor()
local api = require "luci.model.cbi.passwall.api.api"
local appname = "passwall"
m = Map(appname)
-- [[ Other Settings ]]--
s = m:section(TypedSection, "global_other")
s.anonymous = true
---- Auto Ping
o = s:option(Flag, "auto_ping", translate("Auto Ping"),
translate("This will automatically ping the node for latency"))
o.default = 0
-- [[ Add the node via the link ]]--
s:append(Template("passwall/node_list/link_add_node"))
-- [[ Node List ]]--
s = m:section(TypedSection, "nodes")
s.anonymous = true
s.sortable = true
s.addremove = true
s.template = "cbi/tblsection"
s.extedit = d.build_url("admin", "vpn", "passwall", "node_config", "%s")
function s.create(e, t)
local e = TypedSection.create(e, t)
luci.http
.redirect(d.build_url("admin", "vpn", "passwall", "node_config", e))
end
function s.remove(t, a)
s.map.proceed = true
s.map:del(a)
luci.http.redirect(d.build_url("admin", "vpn", "passwall", "node_list"))
end
---- Remarks
o = s:option(DummyValue, "remarks", translate("Remarks"))
---- Add Mode
o = s:option(DummyValue, "add_mode", translate("Add Mode"))
o.cfgvalue = function(t, n)
local v = Value.cfgvalue(t, n)
if v and v ~= '' then
return v
else
return '手动'
end
return str
end
---- Type
o = s:option(DummyValue, "type", translate("Type"))
---- Address
o = s:option(DummyValue, "address", translate("Address"))
---- Port
o = s:option(DummyValue, "port", translate("Port"))
---- Encrypt Method
--[[ o = s:option(DummyValue, "encrypt_method", translate("Encrypt Method"))
o.width = "15%"
o.cfgvalue = function(t, n)
local str = ""
local type = api.uci_get_type_id(n, "type") or ""
if type == "SSR" then
return api.uci_get_type_id(n, "ssr_encrypt_method")
elseif type == "SS" then
return api.uci_get_type_id(n, "ss_encrypt_method")
elseif type == "V2ray" then
return api.uci_get_type_id(n, "v2ray_security")
end
return str
end--]]
---- Ping
o = s:option(DummyValue, "address", translate("Ping"))
if api.uci_get_type("global_other", "auto_ping") == "0" then
o.template = "passwall/node_list/ping"
else
o.template = "passwall/node_list/auto_ping"
end
---- Apply
o = s:option(DummyValue, "apply", translate("Apply"))
o.template = "passwall/node_list/apply"
m:append(Template("passwall/node_list/node_list"))
if luci.http.formvalue("cbi.apply") then
luci.http.redirect(d.build_url("admin", "vpn", "passwall", "node_list"))
end
return m

View File

@ -95,7 +95,9 @@ o:value("210.2.4.8", "210.2.4.8(CNNIC DNS2)")
o:value("180.76.76.76", "180.76.76.76(" .. translate("Baidu") .. "DNS)")
---- DNS Export Of Multi WAN
o = s:option(ListValue, "dns_port", translate("DNS Export Of Multi WAN"))
o = s:option(ListValue, "dns_port", translate("DNS Export Of Multi WAN"),
translate(
"Only support Multi Wan. If no effect, please go to mwan3 to set."))
o.rmempty = false
o.default = 0
o:value(0, translate("Auto"))
@ -109,8 +111,10 @@ for _, iface in ipairs(ifaces) do
end
end
---- Designated Export for Client
o = s:option(ListValue, "wan_port", translate("Designated Export for Client"))
---- Node Export Of Multi WAN
o = s:option(ListValue, "wan_port", translate("Node Export Of Multi WAN"),
translate(
"Only support Multi Wan. If no effect, please go to mwan3 to set."))
o.default = 0
o.rmempty = false
o:value(0, translate("Auto"))
@ -200,11 +204,10 @@ s = m:section(TypedSection, "global_other", translate("Other Settings"))
s.anonymous = true
s.addremove = false
---- TCP Servers Number Option
o = s:option(ListValue, "tcp_redir_server_num",
translate("TCP Redir Server Number"),
---- TCP Node Number Option
o = s:option(ListValue, "tcp_node_num", "TCP" .. translate("Node Number"),
translatef(
"You can only set up a maximum of %s servers for the time being",
"You can only set up a maximum of %s nodes for the time being",
"3"))
o.default = "1"
o.rmempty = false
@ -212,11 +215,10 @@ o:value("1")
o:value("2")
o:value("3")
---- UDP Servers Number Option
o = s:option(ListValue, "udp_redir_server_num",
translate("UDP Redir Server Number"),
---- UDP Node Number Option
o = s:option(ListValue, "udp_node_num", "UDP" .. translate("Node Number"),
translatef(
"You can only set up a maximum of %s servers for the time being",
"You can only set up a maximum of %s nodes for the time being",
"3"))
o.default = "1"
o.rmempty = false
@ -224,11 +226,10 @@ o:value("1")
o:value("2")
o:value("3")
---- Socks5 Servers Number Option
o = s:option(ListValue, "socks5_proxy_server_num",
translate("Socks5 Proxy Server Number"),
---- Socks5 Node Number Option
o = s:option(ListValue, "socks5_node_num", "Socks5" .. translate("Node Number"),
translatef(
"You can only set up a maximum of %s servers for the time being",
"You can only set up a maximum of %s nodes for the time being",
"5"))
o.default = "1"
o.rmempty = false
@ -238,6 +239,11 @@ o:value("3")
o:value("4")
o:value("5")
---- 状态使用大图标
o = s:option(Flag, "status_use_big_icon", translate("Status Use Big Icon"))
o.default = "0"
o.rmempty = false
---- Hide Menu
o = s:option(Button, "hide", translate("Hide Menu"), translate(
"After the hidden to the display, type in the address bar enter the admin/vpn/passwall/show, such as: http://192.168.1.1/cgi-bin/luci/admin/vpn/passwall/show"))

View File

@ -27,50 +27,14 @@ for e = 0, 23 do o:value(e, e .. translate("oclock")) end
o.default = 0
o:depends("auto_update", 1)
-- [[ V2ray Settings ]]--
s = m:section(TypedSection, "global_app", translate("App Update"),
translate("Please confirm that your firmware supports FPU."))
s.anonymous = true
s:append(Template("passwall/rule/v2ray_version"))
s:append(Template("passwall/rule/kcptun_version"))
s:append(Template("passwall/rule/brook_version"))
---- V2ray client path
o = s:option(Value, "v2ray_client_file", translate("V2ray client path"),
translate(
"if you want to run from memory, change the path, such as /tmp/v2ray/, Then save the application and update it manually."))
o.default = "/usr/bin/v2ray/"
o.rmempty = false
---- Kcptun client path
o = s:option(Value, "kcptun_client_file", translate("Kcptun client path"),
translate(
"if you want to run from memory, change the path, such as /tmp/kcptun-client, Then save the application and update it manually."))
o.default = "/usr/bin/kcptun-client"
o.rmempty = false
--[[
o = s:option(Button, "_check_kcptun", translate("Manually update"), translate("Make sure there is enough space to install Kcptun"))
o.template = "passwall/kcptun"
o.inputstyle = "apply"
o.btnclick = "onBtnClick_kcptun(this);"
o.id = "_kcptun-check_btn"]] --
---- Brook client path
o = s:option(Value, "brook_client_file", translate("Brook client path"),
translate(
"if you want to run from memory, change the path, such as /tmp/brook, Then save the application and update it manually."))
o.default = "/usr/bin/brook"
o.rmempty = false
-- [[ Subscribe Settings ]]--
s = m:section(TypedSection, "global_subscribe", translate("Server Subscribe"))
s = m:section(TypedSection, "global_subscribe", translate("Node Subscribe"))
s.anonymous = true
---- Subscribe URL
o = s:option(DynamicList, "subscribe_url", translate("Subscribe URL"),
translate(
"Servers unsubscribed will be deleted in next update; Please summit the Subscribe URL first before manually update."))
"Please input the subscription url first, save and submit before updating. If you subscribe to update, it is recommended to delete all subscriptions and then re-subscribe."))
---- Subscribe Manually update
o = s:option(Button, "_update", translate("Manually update"))
@ -83,7 +47,7 @@ function o.write(e, e)
end
---- Subscribe Delete All
o = s:option(Button, "_stop", translate("Delete All Subscribe"))
o = s:option(Button, "_stop", translate("Delete All Subscribe Node"))
o.inputstyle = "remove"
function o.write(e, e)
luci.sys.call(
@ -117,4 +81,38 @@ for e = 0, 23 do o:value(e, e .. translate("oclock")) end
o.default = 0
o:depends("auto_update_subscribe", 1)
-- [[ App Settings ]]--
s = m:section(TypedSection, "global_app", translate("App Update"),
translate("Please confirm that your firmware supports FPU."))
s.anonymous = true
s:append(Template("passwall/rule/v2ray_version"))
s:append(Template("passwall/rule/kcptun_version"))
s:append(Template("passwall/rule/brook_version"))
---- V2ray Path
o = s:option(Value, "v2ray_file", translate("V2ray Path"), translate(
"if you want to run from memory, change the path, such as /tmp/v2ray/, Then save the application and update it manually."))
o.default = "/usr/bin/v2ray/"
o.rmempty = false
---- Kcptun client Path
o = s:option(Value, "kcptun_client_file", translate("Kcptun Client Path"),
translate(
"if you want to run from memory, change the path, such as /tmp/kcptun-client, Then save the application and update it manually."))
o.default = "/usr/bin/kcptun-client"
o.rmempty = false
--[[
o = s:option(Button, "_check_kcptun", translate("Manually update"), translate("Make sure there is enough space to install Kcptun"))
o.template = "passwall/kcptun"
o.inputstyle = "apply"
o.btnclick = "onBtnClick_kcptun(this);"
o.id = "_kcptun-check_btn"]] --
---- Brook Path
o = s:option(Value, "brook_file", translate("Brook Path"), translate(
"if you want to run from memory, change the path, such as /tmp/brook, Then save the application and update it manually."))
o.default = "/usr/bin/brook"
o.rmempty = false
return m

View File

@ -1,92 +0,0 @@
local d = require "luci.dispatcher"
local fs = require "nixio.fs"
local sys = require "luci.sys"
local uci = require "luci.model.uci".cursor()
local appname = "passwall"
m = Map(appname)
-- [[ Other Settings ]]--
s = m:section(TypedSection, "global_other")
s.anonymous = true
---- Auto Ping
o = s:option(Flag, "auto_ping", translate("Auto Ping"),
translate("This will automatically ping the server for latency"))
o.default = 0
-- [[ Add the server via the link ]]--
s:append(Template("passwall/server_list/link_add_server"))
-- [[ Servers List ]]--
s = m:section(TypedSection, "servers")
s.anonymous = true
s.sortable = true
s.addremove = true
s.template = "cbi/tblsection"
s.extedit = d.build_url("admin", "vpn", "passwall", "serverconfig", "%s")
function s.create(e, t)
local e = TypedSection.create(e, t)
luci.http.redirect(
d.build_url("admin", "vpn", "passwall", "serverconfig", e))
end
function s.remove(t, a)
s.map.proceed = true
s.map:del(a)
luci.http.redirect(d.build_url("admin", "vpn", "passwall", "server_list"))
end
---- Node Remarks
o = s:option(DummyValue, "remarks", translate("Node Remarks"))
o.width = "20%"
---- Server Type
o = s:option(DummyValue, "server_type", translate("Server Type"))
o.width = "10%"
---- Server Address
o = s:option(DummyValue, "server", translate("Server Address"))
o.width = "15%"
---- Server Port
o = s:option(DummyValue, "server_port", translate("Server Port"))
o.width = "10%"
---- Encrypt Method
--[[o = s:option(DummyValue, "encrypt_method", translate("Encrypt Method"))
o.width="15%"
o.cfgvalue=function(t, n)
local str=""
local type = m.uci:get(appname, n, "server_type") or ""
if type == "SSR" then
return m.uci:get(appname, n, "ssr_encrypt_method")
elseif type == "SS" then
return m.uci:get(appname, n, "ss_encrypt_method")
elseif type == "V2ray" then
return m.uci:get(appname, n, "v2ray_security")
end
return str
end--]]
---- Ping
o = s:option(DummyValue, "server", translate("Ping"))
if uci:get(appname, "@global_other[0]", "auto_ping") == "0" then
o.template = "passwall/server_list/ping"
else
o.template = "passwall/server_list/auto_ping"
end
o.width = "10%"
---- Apply
o = s:option(DummyValue, "apply", translate("Apply"))
o.width = "15%"
o.template = "passwall/server_list/apply"
m:append(Template("passwall/server_list/server_list"))
if luci.http.formvalue("cbi.apply") then
luci.http.redirect(d.build_url("admin", "vpn", "passwall", "server_list"))
end
return m

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,260 @@
<%
local api = require "luci.model.cbi.passwall.api.api"
local dsp = require "luci.dispatcher"
local ipkg = require "luci.model.ipkg"
local function is_finded(e)
local result=luci.sys.exec("find /usr/*bin -iname "..e.." -type f")
if result~="" then
return true
end
return false
end
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
-%>
<style>
/* @media screen and (min-width: 1600px) {
#_passwall_status_fieldset > fieldset {
padding: 0px;
}
#_passwall_status_fieldset > fieldset > div {
width: 200px;
height: 60px;
background: #f7fafd;
float: left;
margin: 5px;
padding: 0.3rem 1rem;
border-radius: 10px;
display: flex;
align-items: center;
clear: unset;
}
#_passwall_status_fieldset > fieldset > div > .cbi-value-title {
text-align: left;
width: unset;
padding-top: unset;
}
#_passwall_status_fieldset > fieldset > div > .cbi-value-field {
padding-top: unset;
}
#_passwall_status_fieldset > fieldset > div > .cbi-value-field > font {
padding-top: unset;
}
#_server_status > font {
display: block;
}
}
*/
</style>
<fieldset id="_passwall_status_fieldset" class="cbi-section">
<legend>
<%:Running Status%>
</legend>
<fieldset class="cbi-section">
<% if tcp_node_num and tonumber(tcp_node_num) >= 1 then %>
<% for i = 1, tcp_node_num, 1 do %>
<div class="cbi-value">
<label class="cbi-value-title">TCP_<%=i%>
<%:Status%>
</label>
<div class="cbi-value-field" id="_tcp_node<%=i%>_status">
<%:Collecting data...%>
</div>
</div>
<% end %>
<% end %>
<% if udp_node_num and tonumber(udp_node_num) >= 1 then %>
<% for i = 1, udp_node_num, 1 do %>
<div class="cbi-value">
<label class="cbi-value-title">UDP_<%=i%>
<%:Status%>
</label>
<div class="cbi-value-field" id="_udp_node<%=i%>_status">
<%:Collecting data...%>
</div>
</div>
<% end %>
<% end %>
<% if socks5_node_num and tonumber(socks5_node_num) >= 1 then %>
<% for i = 1, socks5_node_num, 1 do %>
<div class="cbi-value">
<label class="cbi-value-title">Socks5_<%=i%>
<%:Status%>
</label>
<div class="cbi-value-field" id="_socks5_node<%=i%>_status">
<%:Collecting data...%>
</div>
</div>
<% end %>
<% end %>
<div class="cbi-value">
<label class="cbi-value-title">DNS
<%:Status%>
</label>
<div class="cbi-value-field" id="_dns_mode_status">
<%:Collecting data...%>
</div>
</div>
<% if ipkg.installed("haproxy") or is_finded("haproxy*") then %>
<div class="cbi-value">
<label class="cbi-value-title">
<%:Load Balancing%>
</label>
<div class="cbi-value-field" id="_haproxy_status">
<%:Collecting data...%>
</div>
</div>
<% end %>
<% if ipkg.installed("kcptun") or is_finded("kcptun*") then %>
<div class="cbi-value">
<label class="cbi-value-title">
<%:Kcptun%>
</label>
<div class="cbi-value-field" id="_kcptun_status">
<%:Collecting data...%>
</div>
</div>
<% end %>
<div class="cbi-value">
<label class="cbi-value-title">
<%:Baidu Connection%>
</label>
<div class="cbi-value-field">
<input type="button" class="cbi-button cbi-input-apply" value="<%:Check%>" onclick="return check_connect(this,'baidu')" />
<font id="_baidu_status"></font>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title">
<%:Google Connection%>
</label>
<div class="cbi-value-field">
<input type="button" class="cbi-button cbi-input-apply" value="<%:Check%>" onclick="return check_connect(this,'google')" />
<font id="_google_status"></font>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title">
<%:Server Check%>
</label>
<div class="cbi-value-field">
<input type="button" class="cbi-button cbi-input-apply" value="<%:Check%>" onclick="return check_port(this)" />
<font id="_server_status"></font>
<input id="clear_check_port_btn" type="button" class="cbi-button cbi-button-remove" style="display:none" value="<%:Clear%>" onclick="return clear_check_port(this)" />
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"></label>
<div class="cbi-value-field">
<input type="button" class="cbi-button cbi-input-reload" value="IP111.cn" onclick="javascript:window.open('http://www.ip111.cn/','target');" />
</div>
</div>
</fieldset>
</fieldset>
<script type="text/javascript">
//<![CDATA[
var dns_mode_status = document.getElementById('_dns_mode_status');
var haproxy_status = document.getElementById('_haproxy_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/vpn/passwall/status")%>', null,
function(x, json) {
if(x && x.status == 200) {
<% if tcp_node_num and tonumber(tcp_node_num) >= 1 then %>
<% for i = 1, tcp_node_num, 1 do %>
var tcp_node<%=i%>_status = document.getElementById('_tcp_node<%=i%>_status');
if(tcp_node<%=i%>_status)
tcp_node<%=i%>_status.innerHTML = json.tcp_node<%=i%>_status ? '<font color=green><%:RUNNING%> ✓</font>' : '<font color=red><%:NOT RUNNING%> X</font>';
<% end %>
<% end %>
<% if udp_node_num and tonumber(udp_node_num) >= 1 then %>
<% for i = 1, udp_node_num, 1 do %>
var udp_node<%=i%>_status = document.getElementById('_udp_node<%=i%>_status');
if(udp_node<%=i%>_status)
udp_node<%=i%>_status.innerHTML = json.udp_node<%=i%>_status ? '<font color=green><%:RUNNING%> ✓</font>' : '<font color=red><%:NOT RUNNING%> X</font>';
<% end %>
<% end %>
<% if socks5_node_num and tonumber(socks5_node_num) >= 1 then %>
<% for i = 1, socks5_node_num, 1 do %>
var socks5_node<%=i%>_status = document.getElementById('_socks5_node<%=i%>_status');
if(socks5_node<%=i%>_status)
socks5_node<%=i%>_status.innerHTML = json.socks5_node<%=i%>_status ? '<font color=green><%:RUNNING%> ✓</font>' : '<font color=red><%:NOT RUNNING%> X</font>';
<% end %>
<% end %>
if(dns_mode_status)
dns_mode_status.innerHTML = json.dns_mode_status ? '<font color=green><%:RUNNING%> ✓</font>' : '<font color=red><%:NOT RUNNING%> X</font>';
if(haproxy_status)
haproxy_status.innerHTML = json.haproxy_status ? '<font color=green><%:RUNNING%> ✓</font>' : '<font color=red><%:NOT RUNNING%> X</font>';
if(kcptun_status)
kcptun_status.innerHTML = json.kcptun_status ? '<font color=green><%:RUNNING%> ✓</font>' : '<font color=red><%:NOT RUNNING%> X</font>';
}
});
function check_connect(btn, type) {
btn.disabled = true;
btn.value = '<%:Check...%>';
XHR.get('<%=dsp.build_url("admin/vpn/passwall/connect_status")%>', {
type: type
},
function(x, rv) {
var s = document.getElementById('_' + type + '_status');
if(s) {
if(rv.status) {
//s.setAttribute("color","green");
btn.setAttribute("style","background-color: green !important; border-color: green !important;");
btn.value = '<%:Working...%> ✓';
}
else {
//s.setAttribute("color","red");
btn.setAttribute("style","background-color:red !important; border-color: red !important;");
btn.value = '<%:Problem detected!%> X';
}
}
btn.disabled = false;
//btn.value = '<%:Check%>';
}
);
return false;
}
function check_port(btn) {
btn.disabled = true;
btn.value = '<%:Check...%>';
XHR.get('<%=dsp.build_url("admin/vpn/passwall/check_port")%>', null,
function(x, rv) {
var s = document.getElementById('_server_status');
if(s) {
s.innerHTML = rv.ret;
var clear_btn = document.getElementById('clear_check_port_btn');
clear_btn.style.display = "inline-block";
}
btn.disabled = false;
btn.value = '<%:Check%>';
}
);
return false;
}
function clear_check_port(btn) {
btn.style.display = 'none';
var s = document.getElementById('_server_status');
s.innerHTML = "";
return false;
}
//]]>
</script>

View File

@ -0,0 +1,3 @@
<%+cbi/valueheader%>
<input class="cbi-button cbi-button-add" type="button" onclick="open_set_node_div('<%=section%>')" value="<%:Use%>">
<%+cbi/valuefooter%>

View File

@ -6,7 +6,7 @@ local dsp = require "luci.dispatcher"
-%>
<style>
#div1{
#add_link_div{
display: none;
width: 30rem;
position: absolute;
@ -23,14 +23,14 @@ local dsp = require "luci.dispatcher"
<script type="text/javascript">
//<![CDATA[
function ajax_add_server(link) {
function ajax_add_node(link) {
if (link) {
XHR.get('<%=dsp.build_url("admin/vpn/passwall/link_add_server")%>', {
XHR.get('<%=dsp.build_url("admin/vpn/passwall/link_add_node")%>', {
'link': link
},
function(x, data) {
if(x && x.status == 200) {
window.location.href = '<%=dsp.build_url("admin/vpn/passwall/server_list")%>';
window.location.href = '<%=dsp.build_url("admin/vpn/passwall/node_list")%>';
}
else {
alert("<%:Error%>");
@ -39,20 +39,20 @@ local dsp = require "luci.dispatcher"
}
}
function open_show_div() {
document.getElementById("div1").style.display="block";
document.getElementById("servers_link").focus();
function open_add_link_div() {
document.getElementById("add_link_div").style.display = "block";
document.getElementById("nodes_link").focus();
}
function close_show_div() {
document.getElementById("div1").style.display="none";
function close_add_link_div() {
document.getElementById("add_link_div").style.display = "none";
}
function add_server() {
var servers_link = document.getElementById("servers_link").value;
if (servers_link.trim() != "") {
if (servers_link.indexOf("ss://") == 0 || servers_link.indexOf("ssr://") == 0 || servers_link.indexOf("vmess://") == 0) {
ajax_add_server(servers_link);
function add_node() {
var nodes_link = document.getElementById("nodes_link").value;
if (nodes_link.trim() != "") {
if (nodes_link.indexOf("ss://") == 0 || nodes_link.indexOf("ssr://") == 0 || nodes_link.indexOf("vmess://") == 0) {
ajax_add_node(nodes_link);
}
else {
alert("<%:Please enter the correct link, ss:// ssr:// vmess://%>");
@ -60,31 +60,31 @@ local dsp = require "luci.dispatcher"
}
else {
alert("<%:Please Enter The Link%>");
document.getElementById("servers_link").focus();
document.getElementById("nodes_link").focus();
}
}
//]]>
</script>
<div class="cbi-value">
<label class="cbi-value-title"><%:Add Server%></label>
<label class="cbi-value-title"><%:Add Node%></label>
<div class="cbi-value-field">
<input class="cbi-button cbi-button-add" type="button" onclick="open_show_div()" value="<%:Add the server via the link%>">
<input class="cbi-button cbi-button-add" type="button" onclick="open_add_link_div()" value="<%:Add the node via the link%>">
</div>
</div>
<div id="div1">
<div id="add_link_div">
<div class="cbi-value">
<label class="cbi-value-title"><%:Please Enter The SS/SSR/V2ray Link%></label>
<div class="cbi-value-field">
<textarea id="servers_link" rows="5" cols="50"></textarea>
<textarea id="nodes_link" rows="5" cols="50"></textarea>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title"></label>
<div class="cbi-value-field">
<input class="cbi-button cbi-button-add" type="button" onclick="add_server()" value="<%:Add%>">
<input class="cbi-button cbi-button-remove" type="button" onclick="close_show_div()" value="<%:Close%>">
<input class="cbi-button cbi-button-add" type="button" onclick="add_node()" value="<%:Add%>">
<input class="cbi-button cbi-button-remove" type="button" onclick="close_add_link_div()" value="<%:Close%>">
</div>
</div>
</div>

View File

@ -0,0 +1,104 @@
<%
local api = require "luci.model.cbi.passwall.api.api"
local dsp = require "luci.dispatcher"
local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num")
local udp_node_num = api.uci_get_type("global_other", "udp_node_num")
local socks5_node_num = api.uci_get_type("global_other", "socks5_node_num")
-%>
<style>
table th, .table .th {
text-align: center;
}
table td, .table .td {
text-align: center;
}
#set_node_div{
display: none;
width: 30rem;
position: absolute;
left:50%;
top:50%;
transform: translate(-50%, -50%);
padding-top: 30px;
z-index: 99;
text-align: center;
background: white;
box-shadow: darkgrey 10px 10px 30px 5px;
}
</style>
<script type="text/javascript">
//<![CDATA[
var section = "";
function open_set_node_div(cbi_id) {
section = cbi_id;
document.getElementById("set_node_div").style.display="block";
}
function close_set_node_div() {
document.getElementById("set_node_div").style.display="none";
}
var auto_ping_value = document.getElementsByClassName('auto_ping_value');
for(var i = 0; i < auto_ping_value.length; i++) {
XHR.get('<%=dsp.build_url("admin/vpn/passwall/auto_ping_node")%>', {
index: i,
domain: auto_ping_value[i].getAttribute("server")
},
function(x, result) {
auto_ping_value[result.index].innerHTML = (result.ping ? result.ping : "--") + " ms";
}
);
}
function set_node(protocol,number) {
if (confirm('<%:Are you sure set to%> ' + protocol.toUpperCase() + "_" + number + '<%:the server?%>')==true){
XHR.get('<%=dsp.build_url("admin/vpn/passwall/set_node")%>', { "protocol" : protocol , "number" : number , "section" : section },
function(x, result) {
if(x && x.status == 200) {
window.location.href = '<%=dsp.build_url("admin/vpn/passwall/log")%>'
}
}
);
}
}
function ping_node(node,dom) {
XHR.get('<%=dsp.build_url("admin/vpn/passwall/ping_node")%>', { "node" : node },
function(x, result) {
if(x && x.status == 200) {
dom.outerHTML = result.ping + " ms";
}
}
);
}
//]]>
</script>
<div id="set_node_div">
<div class="cbi-value">
<% if tcp_node_num and tonumber(tcp_node_num) >= 1 then %>
<% for i = 1, tcp_node_num, 1 do %>
<input class="cbi-button cbi-button-edit" type="button" onclick="set_node('tcp',<%=i%>)" value="TCP_<%=i%>">
<% end %>
<% end %>
<% if udp_node_num and tonumber(udp_node_num) >= 1 then %>
<% for i = 1, udp_node_num, 1 do %>
<input class="cbi-button cbi-button-edit" type="button" onclick="set_node('udp',<%=i%>)" value="UDP_<%=i%>">
<% end %>
<% end %>
<% if socks5_node_num and tonumber(socks5_node_num) >= 1 then %>
<% for i = 1, socks5_node_num, 1 do %>
<input class="cbi-button cbi-button-edit" type="button" onclick="set_node('socks5',<%=i%>)" value="Socks5_<%=i%>">
<% end %>
<% end %>
<input class="cbi-button cbi-button-remove" type="button" onclick="close_set_node_div()" value="<%:Close%>">
</div>
</div>

View File

@ -6,6 +6,6 @@
<%+cbi/valueheader%>
<span class="ping">
<a href="javascript:void(0)" onclick="javascript:ping_server('<%=self:cfgvalue(section)%>',this)">Ping</a>
<a href="javascript:void(0)" onclick="javascript:ping_node('<%=self:cfgvalue(section)%>',this)">Ping</a>
</span>
<%+cbi/valuefooter%>

View File

@ -1,7 +1,9 @@
<%
local brook_path = luci.sys.exec("echo -n `uci get passwall.@global_app[0].brook_client_file`")
local brook_version = luci.sys.exec("[ -f '" .. brook_path .. "' ] && " .. brook_path .. " -v | awk '{print $3}'")
local api = require "luci.model.cbi.passwall.api.api"
local dsp = require "luci.dispatcher"
local brook_path = api.uci_get_type("global_app", "brook_file")
local brook_version = luci.sys.exec("[ -f '" .. brook_path .. "' ] && " .. brook_path .. " -v | awk '{print $3}'")
-%>
<script type="text/javascript">

View File

@ -1,7 +1,9 @@
<%
local kcptun_path = luci.sys.exec("echo -n `uci get passwall.@global_app[0].kcptun_client_file`")
local kcptun_version = luci.sys.exec("[ -f '" .. kcptun_path .. "' ] && " .. kcptun_path .. " -v | awk '{print $3}'")
local api = require "luci.model.cbi.passwall.api.api"
local dsp = require "luci.dispatcher"
local kcptun_path = api.uci_get_type("global_app", "kcptun_client_file")
local kcptun_version = luci.sys.exec("[ -f '" .. kcptun_path .. "' ] && " .. kcptun_path .. " -v | awk '{print $3}'")
-%>
<script type="text/javascript">

View File

@ -1,17 +1,12 @@
<%
local appname = "passwall"
local ipkg = require "luci.model.ipkg"
local api = require "luci.model.cbi.passwall.api.api"
local dsp = require "luci.dispatcher"
local uci = require "luci.model.uci".cursor()
local gfwlist_version = uci:get(appname,"@global_rules[0]","gfwlist_version")
local chnroute_version = uci:get(appname,"@global_rules[0]","chnroute_version")
local Pcap_Routing_version = uci:get(appname,"@global_rules[0]","pcap_Routing_version")
local Pcap_WhiteList_version = uci:get(appname,"@global_rules[0]","pcap_WhiteList_version")
local gfwlist_update = uci:get(appname,"@global_rules[0]","gfwlist_update")=="1" and "checked='checked'" or ""
local chnroute_update = uci:get(appname,"@global_rules[0]","chnroute_update")=="1" and "checked='checked'" or ""
local Pcap_Routing_update = uci:get(appname,"@global_rules[0]","pcap_Routing_update")=="1" and "checked='checked'" or ""
local Pcap_WhiteList_update = uci:get(appname,"@global_rules[0]","pcap_WhiteList_update")=="1" and "checked='checked'" or ""
local gfwlist_version = api.uci_get_type("global_rules", "gfwlist_version")
local chnroute_version = api.uci_get_type("global_rules", "chnroute_version")
local gfwlist_update = api.uci_get_type("global_rules", "gfwlist_update") == "1" and "checked='checked'" or ""
local chnroute_update = api.uci_get_type("global_rules", "chnroute_update") == "1" and "checked='checked'" or ""
-%>
<script type="text/javascript">
@ -74,34 +69,6 @@ local Pcap_WhiteList_update = uci:get(appname,"@global_rules[0]","pcap_WhiteList
</div>
</div>
<% if ipkg.installed("pcap-dnsproxy") then %>
<div class="cbi-value">
<label class="cbi-value-title">Pcap_Routing
<%:Version%>
</label>
<div class="cbi-value-field">
<div class="cbi-value-description">
<img src="/luci-static/resources/cbi/help.gif">
<span><%=Pcap_Routing_version%> 】</span>
<input type="checkbox" name="Pcap_Routing_update" value="1" <%=Pcap_Routing_update%> />
</div>
</div>
</div>
<div class="cbi-value">
<label class="cbi-value-title">Pcap_WhiteList
<%:Version%>
</label>
<div class="cbi-value-field">
<div class="cbi-value-description">
<img src="/luci-static/resources/cbi/help.gif">
<span><%=Pcap_WhiteList_version%> 】</span>
<input type="checkbox" name="Pcap_WhiteList_update" value="1" <%=Pcap_WhiteList_update%> />
</div>
</div>
</div>
<% end %>
<div class="cbi-value">
<label class="cbi-value-title">
<%:Manually update%>

View File

@ -1,7 +1,9 @@
<%
local V2ray_path = luci.sys.exec("echo -n `uci get passwall.@global_app[0].v2ray_client_file`")
local V2ray_version = luci.sys.exec("[ -f '" .. V2ray_path .. "/v2ray' ] && " .. V2ray_path .. "/v2ray -version | awk '{print $2}' | sed -n 1P")
local api = require "luci.model.cbi.passwall.api.api"
local dsp = require "luci.dispatcher"
local V2ray_path = api.uci_get_type("global_app", "v2ray_file")
local V2ray_version = luci.sys.exec("[ -f '" .. V2ray_path .. "/v2ray' ] && " .. V2ray_path .. "/v2ray -version | awk '{print $2}' | sed -n 1P")
-%>
<script type="text/javascript">

View File

@ -1,33 +0,0 @@
<%
local tcp_redir_server_num = luci.sys.exec("echo -n `uci get passwall.@global_other[0].tcp_redir_server_num`")
local udp_redir_server_num = luci.sys.exec("echo -n `uci get passwall.@global_other[0].udp_redir_server_num`")
local socks5_proxy_num = luci.sys.exec("echo -n `uci get passwall.@global_other[0].socks5_proxy_server_num`")
-%>
<style>
.apply a:hover{
text-decoration : underline;
}
</style>
<%+cbi/valueheader%>
<span class="apply" hint="<%=self:cfgvalue(section)%>">
<% if tcp_redir_server_num and tonumber(tcp_redir_server_num) >= 1 then %>
<% for i = 1, tcp_redir_server_num, 1 do %>
<a href="javascript:set_server('tcp',<%=i%>,'<%=section%>')">TCP<%=i%></a>
<% end %>
<% end %>
<% if udp_redir_server_num and tonumber(udp_redir_server_num) >= 1 then %>
<% for i = 1, udp_redir_server_num, 1 do %>
<a href="javascript:set_server('udp',<%=i%>,'<%=section%>')">UDP<%=i%></a>
<% end %>
<% end %>
<% if socks5_proxy_num and tonumber(socks5_proxy_num) >= 1 then %>
<% for i = 1, socks5_proxy_num, 1 do %>
<a href="javascript:set_server('socks5',<%=i%>,'<%=section%>')">Socks5_<%=i%></a>
<% end %>
<% end %>
<!-- <a href="javascript:copy_server('<%=section%>')">Copy</a> -->
</span>
<%+cbi/valuefooter%>

View File

@ -1,41 +0,0 @@
<%
local dsp = require "luci.dispatcher"
-%>
<script type="text/javascript">
//<![CDATA[
var auto_ping_value = document.getElementsByClassName('auto_ping_value');
for(var i = 0; i < auto_ping_value.length; i++) {
XHR.get('<%=dsp.build_url("admin/vpn/passwall/auto_ping_server")%>', {
index: i,
domain: auto_ping_value[i].getAttribute("server")
},
function(x, result) {
auto_ping_value[result.index].innerHTML = (result.ping ? result.ping : "--") + " ms";
}
);
}
function set_server(protocol,number,section) {
if (confirm('<%:Are you sure set to%> ' + protocol.toUpperCase() + "_" + number + '<%:the server?%>')==true){
XHR.get('<%=dsp.build_url("admin/vpn/passwall/set_server")%>', { "protocol" : protocol , "number" : number , "section" : section },
function(x, result) {
if(x && x.status == 200) {
window.location.href = '<%=dsp.build_url("admin/vpn/passwall/log")%>'
}
}
);
}
}
function ping_server(server,dom) {
XHR.get('<%=dsp.build_url("admin/vpn/passwall/ping_server")%>', { "server" : server },
function(x, result) {
if(x && x.status == 200) {
dom.outerHTML = result.ping + " ms";
}
}
);
}
//]]>
</script>

View File

@ -34,6 +34,12 @@ msgstr "连接正常"
msgid "Problem detected!"
msgstr "连接失败"
msgid "Touch Check"
msgstr "点我检测"
msgid "Kernel Unsupported"
msgstr "内核不支持"
msgid "Use IPv6"
msgstr "使用IPv6"
@ -46,11 +52,14 @@ msgstr "TCP服务器"
msgid "UDP Server"
msgstr "UDP服务器"
msgid "Global Settings"
msgstr "全局设置"
msgid "Basic Settings"
msgstr "基本设置"
msgid "Server List"
msgstr "服务端列表"
msgid "Node List"
msgstr "节点列表"
msgid "Other Settings"
msgstr "高级设置"
@ -73,15 +82,12 @@ msgstr "白名单设置"
msgid "Watch Logs"
msgstr "查看日志"
msgid "ShadowSocks Server Config"
msgstr "服务器配置"
msgid "Node Config"
msgstr "节点配置"
msgid "Running Status"
msgstr "运行状态"
msgid "Kcptun Client"
msgstr "Kcptun客户端"
msgid "Baidu Connection"
msgstr "百度连接"
@ -100,29 +106,17 @@ msgstr "清除"
msgid "Global Setting"
msgstr "全局配置"
msgid "TCP Redir Server"
msgstr "TCP转发服务器"
msgid "TCP Node"
msgstr "TCP节点"
msgid "UDP Redir Server"
msgstr "UDP转发服务器"
msgid "UDP Node"
msgstr "UDP节点"
msgid "Same as the tcp redir server"
msgstr "与TCP转发服务器相同"
msgid "Socks5 Node"
msgstr "Socks5节点"
msgid "Start the TCP redir"
msgstr "TCP转发"
msgid "Start the UDP redir"
msgstr "UDP转发"
msgid "Start the Socks5 Proxy"
msgstr "Socks5代理"
msgid "The client can use the router's Socks5 proxy"
msgstr "客户端可以使用路由器的Socks5代理"
msgid "Socks5 Proxy Server"
msgstr "Socks5代理服务器"
msgid "Same as the tcp node"
msgstr "与TCP节点相同"
msgid "For used to surf the Internet."
msgstr "用于科学上网。"
@ -133,6 +127,9 @@ msgstr "用于游戏模式或DNS解析等。"
msgid "The selected server will not use Kcptun."
msgstr "选中的服务器不会使用Kcptun。"
msgid "The client can use the router's Socks5 proxy"
msgstr "客户端可以使用路由器的Socks5代理"
msgid "Use Local 7913 Port"
msgstr "使用本机7913端口"
@ -199,11 +196,11 @@ msgstr "本机"
msgid "Danger"
msgstr "危险"
msgid "Add Server"
msgstr "添加服务器"
msgid "Add Node"
msgstr "添加节点"
msgid "Add the server via the link"
msgstr "通过链接添加服务器"
msgid "Add the node via the link"
msgstr "通过链接添加节点"
msgid "Please Enter The SS/SSR/V2ray Link"
msgstr "请输入SS/SSR/V2ray链接"
@ -220,23 +217,26 @@ msgstr "服务器吗?"
msgid "The server client can also use this rule to scientifically surf the Internet"
msgstr "本机服务器的客户端也可以使用这个代理模式上网"
msgid "Servers List"
msgstr "服务器列表"
msgid "Node Remarks"
msgstr "节点备注"
msgid "Server Type"
msgid "Add Mode"
msgstr "添加方式"
msgid "Type"
msgstr "类型"
msgid "Server Address"
msgid "Address"
msgstr "地址"
msgid "Server Address (Support Domain Name)"
msgid "Address (Support Domain Name)"
msgstr "地址(支持域名)"
msgid "Server Port"
msgstr "端口"
msgid "Trojan Verify Cert"
msgstr "验证证书"
msgid "Trojan Cert Path"
msgstr "证书路径"
msgid "Encrypt Method"
msgstr "加密"
@ -253,12 +253,15 @@ msgstr "Ping值"
msgid "Auto Ping"
msgstr "自动Ping"
msgid "This will automatically ping the server for latency"
msgstr "选中后保存应用后刷新即可自动Ping服务器"
msgid "This will automatically ping the node for latency"
msgstr "选中后保存应用后刷新即可自动Ping节点"
msgid "Apply"
msgstr "应用"
msgid "Use"
msgstr "使用"
msgid "DNS Settings"
msgstr "DNS配置"
@ -283,18 +286,21 @@ msgstr "百度"
msgid "DNS Export Of Multi WAN"
msgstr "国内DNS指定解析出口"
msgid "Node Export Of Multi WAN"
msgstr "节点指定出口"
msgid "Only support Multi Wan. If no effect, please go to mwan3 to set."
msgstr "只有多线接入才有效如果设置后还是无效请到mwan3设置。"
msgid "Not Specify"
msgstr "不指定"
msgid "DNS Hijack"
msgstr "接管局域网DNS解析"
msgstr "DNS劫持"
msgid "If the GFW mode cannot be used normally, please enable it"
msgstr "如果GFW模式不能正常使用请启用"
msgid "Designated Export for Client"
msgstr "客户端指定出口"
msgid "Delay Settings"
msgstr "定时配置"
@ -326,10 +332,10 @@ msgid "Forwarding Settings"
msgstr "转发配置"
msgid "TCP Redir Ports"
msgstr "TCP代理转发端口"
msgstr "TCP转发端口"
msgid "UDP Redir Ports"
msgstr "UDP代理转发端口"
msgstr "UDP转发端口"
msgid "All"
msgstr "所有"
@ -367,9 +373,6 @@ msgstr "自定义Dnsmasq设置"
msgid "Setting a parameter error will cause dnsmasq fail to start."
msgstr "参数设置错误将会导致Dnsmasq无法启动。"
msgid "Click here to setting your Load Balancing"
msgstr "点击这里查看负载均衡设置教程。"
msgid "Auto Switch"
msgstr "自动切换"
@ -388,50 +391,53 @@ msgstr "备用TCP转发服务器的列表"
msgid "Load Balancing Setting"
msgstr "负载均衡设置"
msgid "Enable or Disable Load Balancing"
msgstr "开启或关闭负载均衡"
msgid "Click here to setting your Load Balancing"
msgstr "点击这里查看负载均衡设置教程。"
msgid "Haproxy port setting"
msgstr "负载均衡服务器端口"
msgid "Enable Load Balancing"
msgstr "开启负载均衡"
msgid "Admin Status"
msgstr "负载均衡控制台"
msgid "Console Username"
msgstr "控制台账号"
msgid "Console Password"
msgstr "控制台密码"
msgid "Console Port"
msgstr "控制台端口"
msgid "In the browser input routing IP plus port access, such as:192.168.1.1:1188"
msgstr "在浏览器输入路由IP加端口访问192.168.1.1:1188"
msgid "Enable Admin Status"
msgstr "开启控制台"
msgid "Haproxy Port"
msgstr "负载均衡端口"
msgid "Admin Status port setting"
msgstr "控制台端口"
msgid "Load Balancing Setting"
msgstr "负载均衡设置"
msgid "Admin Status User"
msgstr "登陆用户名"
msgid "Add a node, Export Of Multi WAN Only support Multi Wan. If no effect, please go to mwan3 to set. Load specific gravity range 1-256. Multiple primary servers can be load balanced, standby will only be enabled when the primary server is offline!"
msgstr "添加节点指定出口功能是为多WAN用户准备的如果设置后还是无效请到mwan3设置。负载比重范围1-256。多个主服务器可以负载均衡备用只有在主服务器离线时才会启用"
msgid "Admin Status Password"
msgstr "登陆密码"
msgid "Node Address"
msgstr "节点地址"
msgid "Load Balancing Server Setting"
msgstr "负载均衡服务器设置"
msgid "Node Port"
msgstr "节点端口"
msgid "Add a load balancing server, note reading above requirements."
msgstr "添加负载均衡服务器指定出口功能是为多WAN用户准备的。负载比重范围1-256。多个主服务器可以负载均衡备服务器只有在主服务器离线时才会启用"
msgid "Server weight"
msgid "Node Weight"
msgstr "负载比重"
msgid "Export Of Multi WAN"
msgstr "多WAN指定出口"
msgid "Server Mode"
msgstr "服务器模式"
msgid "Mode"
msgstr "模式"
msgid "Primary Server"
msgstr "主服务器"
msgid "Primary"
msgstr "主"
msgid "Standby Server"
msgstr "备服务器"
msgid "Standby"
msgstr "备"
msgid "Manually update"
msgstr "手动更新"
@ -496,13 +502,13 @@ msgstr "更新主程序"
msgid "Please confirm that your firmware supports FPU."
msgstr "请确认你的固件支持FPU。"
msgid "V2ray client path"
msgstr "V2ray客户端路径"
msgid "V2ray Path"
msgstr "V2ray路径"
msgid "if you want to run from memory, change the path, such as /tmp/v2ray/, Then save the application and update it manually."
msgstr "如果你希望从内存中运行,请更改路径,例如/tmp/v2ray/,然后保存应用后,再手动更新。"
msgid "Kcptun client path"
msgid "Kcptun Client Path"
msgstr "Kcptun客户端路径"
msgid "if you want to run from memory, change the path, such as /tmp/kcptun-client, Then save the application and update it manually."
@ -511,23 +517,23 @@ msgstr "如果你希望从内存中运行,请更改路径,例如/tmp/kcptun-
msgid "Make sure there is enough space to install Kcptun"
msgstr "确保有足够的空间安装Kcptun"
msgid "Brook client path"
msgstr "Brook客户端路径"
msgid "Brook Path"
msgstr "Brook路径"
msgid "if you want to run from memory, change the path, such as /tmp/brook, Then save the application and update it manually."
msgstr "如果你希望从内存中运行,请更改路径,例如/tmp/brook然后保存应用后再手动更新。"
msgid "Server Subscribe"
msgstr "服务器订阅"
msgid "Node Subscribe"
msgstr "节点订阅"
msgid "Subscribe URL"
msgstr "订阅网址"
msgid "Servers unsubscribed will be deleted in next update; Please summit the Subscribe URL first before manually update."
msgstr "取消订阅的服务器将在下次更新时删除,请先输入订阅网址保存提交之后再更新。"
msgid "Please input the subscription url first, save and submit before updating. If you subscribe to update, it is recommended to delete all subscriptions and then re-subscribe."
msgstr "请输入订阅网址保存应用后再更新,如果订阅节点更新了,建议删除所有订阅,然后重新订阅。"
msgid "Delete All Subscribe"
msgstr "删除所有订阅"
msgid "Delete All Subscribe Node"
msgstr "删除所有订阅节点"
msgid "Subscribe via proxy"
msgstr "通过代理订阅"
@ -541,17 +547,11 @@ msgstr "添加"
msgid "ACLs"
msgstr "访问控制"
msgid "ACLs is a tools which used to designate specific IP proxy mode"
msgid "ACLs is a tools which used to designate specific IP proxy mode, IP or MAC address can be entered."
msgstr "访问控制列表是用于指定特殊IP代理模式的工具。IP、MAC地址可只填写一项。"
msgid "ACL Remarks"
msgstr "主机备注"
msgid "IP Address"
msgstr "内部IP地址"
msgid "MAC Address"
msgstr "MAC地址"
msgid "Remarks"
msgstr "备注"
msgid "Set Blacklist And Whitelist"
msgstr "黑白名单"
@ -592,8 +592,8 @@ msgstr "这里显示的是最近的日志。"
msgid "Clear logs"
msgstr "清空日志"
msgid "TCP quick open server does not support do not open."
msgstr "TCP快速打开服务器不支持不要打开。"
msgid "Need node support required"
msgstr "需要节点支持"
msgid "HAProxy cannot be used with KCP."
msgstr "HAProxy不能和KCP一起使用"
@ -607,9 +607,12 @@ msgstr "连接超时时间"
msgid "Local Port"
msgstr "本地端口"
msgid "Fast_open"
msgid "TCP Fast Open"
msgstr "TCP快速打开"
msgid "Need node support required"
msgstr "需要节点支持"
msgid "Protocol"
msgstr "协议名称"
@ -673,6 +676,9 @@ msgstr "传输层加密"
msgid "Whether or not transport layer encryption is enabled, the supported options are \"none\" for unencrypted (default) and \"TLS\" for using TLS."
msgstr "是否启入传输层加密,支持的选项有 \"none\" 表示不加密(默认值),\"tls\" 表示使用 TLS。"
msgid "Domain"
msgstr "域名"
msgid "Whether unsafe connections are allowed. When checked, V2Ray does not check the validity of the TLS certificate provided by the remote host."
msgstr "是否允许不安全连接。当勾选时V2Ray 不会检查远端主机所提供的 TLS 证书的有效性。"
@ -682,17 +688,35 @@ msgstr "<br>none默认值不进行伪装发送的数据是没有特征
msgid "A legal file path. This file must not exist before running V2Ray."
msgstr "一个合法的文件路径。在运行 V2Ray 之前,这个文件必须不存在。"
msgid "TCP Redir Server Number"
msgstr "TCP转发服务器数量"
msgid "TCP Open Socks"
msgstr "开启Socks"
msgid "UDP Redir Server Number"
msgstr "UDP转发服务器数量"
msgid "When using this TCP node, whether to open the socks proxy at the same time"
msgstr "使用此TCP节点时是否同时打开socks代理"
msgid "Socks5 Proxy Server Number"
msgstr "Socks5代理服务器数量"
msgid "Do not conflict with other ports"
msgstr "端口不能冲突"
msgid "You can only set up a maximum of %s servers for the time being"
msgstr "目前最多只能设置%s个服务器"
msgid "Socks for authentication"
msgstr "Socks认证方式"
msgid "Socks protocol authentication, support anonymous and password."
msgstr "Socks 协议的认证方式,支持匿名方式和账号密码方式。"
msgid "anonymous"
msgstr "匿名"
msgid "User Password"
msgstr "账号密码"
msgid "Node Number"
msgstr "节点数量"
msgid "You can only set up a maximum of %s nodes for the time being"
msgstr "目前最多只能设置%s个节点"
msgid "Status Use Big Icon"
msgstr "状态信息使用大图标"
msgid "Hide Menu"
msgstr "隐藏菜单"
@ -729,9 +753,3 @@ msgstr "客户端文件不适合当前设备。"
msgid "Can't move new file to path: %s"
msgstr "无法移动新文件到:%s"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "RUNNING"
msgstr "运行中"

View File

@ -1,15 +1,14 @@
config global
option proxy_mode 'chnroute'
option tcp_node1 'nil'
option udp_node1 'nil'
option socks5_node1 'nil'
option dns_mode 'chinadns'
option up_chinadns_mode 'OpenDNS_1'
option socks5_proxy_server1 'nil'
option udp_redir_server1 'nil'
option tcp_redir_server1 'nil'
option proxy_mode 'chnroute'
option localhost_proxy_mode 'default'
config global_haproxy
option admin_enable '0'
option balancing_enable '0'
config global_delay
@ -27,7 +26,7 @@ config global_dns
config global_forwarding
option udp_redir_ports '1:65535'
option tcp_redir_ports '1:65535'
option tcp_redir_ports '80,443'
option process '1'
config global_proxy
@ -39,23 +38,22 @@ config global_proxy
config global_other
option auto_ping '1'
option tcp_redir_server_num '1'
option udp_redir_server_num '1'
option socks5_proxy_server_num '1'
option tcp_node_num '1'
option udp_node_num '1'
option socks5_node_num '1'
option status_use_big_icon '1'
config global_rules
option auto_update '0'
option gfwlist_update '1'
option chnroute_update '1'
option Pcap_Routing_update '0'
option Pcap_WhiteList_update '0'
option auto_update '0'
option chnroute_version '2019-10-18'
option gfwlist_version '2019-11-16'
option gfwlist_version '2019-11-27'
config global_app
option v2ray_client_file '/usr/bin/v2ray/'
option v2ray_file '/usr/bin/v2ray/'
option kcptun_client_file '/usr/bin/kcptun-client'
option brook_client_file '/usr/bin/brook'
option brook_file '/usr/bin/brook'
config global_subscribe
option subscribe_by_ss '0'

View File

@ -117,35 +117,35 @@ get_not_exists_port_after() {
fi
}
TCP_REDIR_SERVER_NUM=$(config_t_get global_other tcp_redir_server_num 1)
for i in $(seq 1 $TCP_REDIR_SERVER_NUM); do
eval TCP_REDIR_SERVER$i=$(config_t_get global tcp_redir_server$i nil)
TCP_NODE_NUM=$(config_t_get global_other tcp_node_num 1)
for i in $(seq 1 $TCP_NODE_NUM); do
eval TCP_NODE$i=$(config_t_get global tcp_node$i nil)
done
UDP_REDIR_SERVER_NUM=$(config_t_get global_other udp_redir_server_num 1)
for i in $(seq 1 $UDP_REDIR_SERVER_NUM); do
eval UDP_REDIR_SERVER$i=$(config_t_get global udp_redir_server$i nil)
UDP_NODE_NUM=$(config_t_get global_other udp_node_num 1)
for i in $(seq 1 $UDP_NODE_NUM); do
eval UDP_NODE$i=$(config_t_get global udp_node$i nil)
done
SOCKS5_PROXY_SERVER_NUM=$(config_t_get global_other socks5_proxy_server_num 1)
for i in $(seq 1 $SOCKS5_PROXY_SERVER_NUM); do
eval SOCKS5_PROXY_SERVER$i=$(config_t_get global socks5_proxy_server$i nil)
SOCKS5_NODE_NUM=$(config_t_get global_other socks5_node_num 1)
for i in $(seq 1 $SOCKS5_NODE_NUM); do
eval SOCKS5_NODE$i=$(config_t_get global socks5_node$i nil)
done
[ "$UDP_REDIR_SERVER1" == "default" ] && UDP_REDIR_SERVER1=$TCP_REDIR_SERVER1
[ "$UDP_NODE1" == "default" ] && UDP_NODE1=$TCP_NODE1
TCP_REDIR_SERVER1_IP=""
UDP_REDIR_SERVER1_IP=""
SOCKS5_PROXY_SERVER1_IP=""
TCP_REDIR_SERVER1_IPV6=""
UDP_REDIR_SERVER1_IPV6=""
SOCKS5_PROXY_SERVER1_IPV6=""
TCP_REDIR_SERVER1_PORT=""
UDP_REDIR_SERVER1_PORT=""
SOCKS5_PROXY_SERVER1_PORT=""
TCP_REDIR_SERVER1_TYPE=""
UDP_REDIR_SERVER1_TYPE=""
SOCKS5_PROXY_SERVER1_TYPE=""
TCP_NODE1_IP=""
UDP_NODE1_IP=""
SOCKS5_NODE1_IP=""
TCP_NODE1_IPV6=""
UDP_NODE1_IPV6=""
SOCKS5_NODE1_IPV6=""
TCP_NODE1_PORT=""
UDP_NODE1_PORT=""
SOCKS5_NODE1_PORT=""
TCP_NODE1_TYPE=""
UDP_NODE1_TYPE=""
SOCKS5_NODE1_TYPE=""
BROOK_SOCKS5_CMD=""
BROOK_TCP_CMD=""
@ -157,7 +157,7 @@ KCPTUN_REDIR_PORT=$(config_t_get global_proxy kcptun_port 11183)
PROXY_MODE=$(config_t_get global proxy_mode gfwlist)
load_config() {
[ "$TCP_REDIR_SERVER1" == "nil" -a "$UDP_REDIR_SERVER1" == "nil" -a "$SOCKS5_PROXY_SERVER1" == "nil" ] && {
[ "$TCP_NODE1" == "nil" -a "$UDP_NODE1" == "nil" -a "$SOCKS5_NODE1" == "nil" ] && {
echolog "没有选择服务器!"
return 1
}
@ -191,115 +191,115 @@ load_config() {
}
gen_ss_ssr_config_file() {
local server_type local_port kcptun server configfile
server_type=$1
local type local_port kcptun node configfile
type=$1
local_port=$2
kcptun=$3
server=$4
node=$4
configfile=$5
local server_port encrypt_method
server_port=$(config_get $server server_port)
encrypt_method=$(config_get $server ss_encrypt_method)
[ "$server_type" == "ssr" ] && encrypt_method=$(config_get $server ssr_encrypt_method)
local port encrypt_method
port=$(config_n_get $node port)
encrypt_method=$(config_n_get $node ss_encrypt_method)
[ "$type" == "ssr" ] && encrypt_method=$(config_n_get $node ssr_encrypt_method)
[ "$kcptun" == "1" ] && {
server_ip=127.0.0.1
server_host=127.0.0.1
server_port=$KCPTUN_REDIR_PORT
port=$KCPTUN_REDIR_PORT
}
cat <<-EOF >$configfile
{
"server": "$server_host",
"_comment": "$server_ip",
"server_port": $server_port,
"server_port": $port,
"local_address": "0.0.0.0",
"local_port": $local_port,
"password": "$(config_get $server password)",
"timeout": $(config_get $server timeout),
"password": "$(config_n_get $node password)",
"timeout": $(config_n_get $node timeout),
"method": "$encrypt_method",
"fast_open": $(config_get $server fast_open),
"fast_open": $(config_n_get $node tcp_fast_open false),
"reuse_port": true,
EOF
[ "$1" == "ssr" ] && {
cat <<-EOF >>$configfile
"protocol": "$(config_get $server protocol)",
"protocol_param": "$(config_get $server protocol_param)",
"obfs": "$(config_get $server obfs)",
"obfs_param": "$(config_get $server obfs_param)"
"protocol": "$(config_n_get $node protocol)",
"protocol_param": "$(config_n_get $node protocol_param)",
"obfs": "$(config_n_get $node obfs)",
"obfs_param": "$(config_n_get $node obfs_param)"
EOF
}
echo -e "}" >>$configfile
}
gen_config_file() {
local server local_port redir_type config_file_path server_host server_ip server_port server_type use_ipv6 network_type
server=$1
local node local_port redir_type config_file_path server_host server_ip port type use_ipv6 network_type
node=$1
local_port=$2
redir_type=$3
config_file_path=$4
server_host=$(config_get $server server)
use_ipv6=$(config_get $server use_ipv6)
server_host=$(config_n_get $node address)
use_ipv6=$(config_n_get $node use_ipv6)
network_type="ipv4"
[ "$use_ipv6" == "1" ] && network_type="ipv6"
server_ip=$(get_host_ip $network_type $server_host)
server_port=$(config_get $server server_port)
server_type=$(echo $(config_get $server server_type) | tr 'A-Z' 'a-z')
port=$(config_n_get $node port)
type=$(echo $(config_n_get $node type) | tr 'A-Z' 'a-z')
echolog "$redir_type服务器IP地址:$server_ip"
if [ "$redir_type" == "Socks5" ]; then
if [ "$network_type" == "ipv6" ]; then
SOCKS5_PROXY_SERVER1_IPV6=$server_ip
SOCKS5_NODE1_IPV6=$server_ip
else
SOCKS5_PROXY_SERVER1_IP=$server_ip
SOCKS5_NODE1_IP=$server_ip
fi
SOCKS5_PROXY_SERVER1_PORT=$server_port
if [ "$server_type" == "ss" -o "$server_type" == "ssr" ]; then
gen_ss_ssr_config_file $server_type $local_port 0 $server $config_file_path
elif [ "$server_type" == "v2ray" ]; then
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_v2ray_client_config_file.lua $server nil nil $local_port >$config_file_path
elif [ "$server_type" == "brook" ]; then
BROOK_SOCKS5_CMD="client -l 0.0.0.0:$local_port -i 0.0.0.0 -s $server_ip:$server_port -p $(config_get $server password)"
elif [ "$server_type" == "trojan" ]; then
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_trojan_client_config_file.lua $server client $local_port >$config_file_path
SOCKS5_NODE1_PORT=$port
if [ "$type" == "ss" -o "$type" == "ssr" ]; then
gen_ss_ssr_config_file $type $local_port 0 $node $config_file_path
elif [ "$type" == "v2ray" ]; then
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_v2ray_client_config_file.lua $node nil nil $local_port >$config_file_path
elif [ "$type" == "brook" ]; then
BROOK_SOCKS5_CMD="client -l 0.0.0.0:$local_port -i 0.0.0.0 -s $server_ip:$port -p $(config_n_get $node password)"
elif [ "$type" == "trojan" ]; then
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_trojan_client_config_file.lua $node client $local_port >$config_file_path
fi
fi
if [ "$redir_type" == "UDP" ]; then
if [ "$network_type" == "ipv6" ]; then
UDP_REDIR_SERVER1_IPV6=$server_ip
UDP_NODE1_IPV6=$server_ip
else
UDP_REDIR_SERVER1_IP=$server_ip
UDP_NODE1_IP=$server_ip
fi
UDP_REDIR_SERVER1_PORT=$server_port
if [ "$server_type" == "ss" -o "$server_type" == "ssr" ]; then
gen_ss_ssr_config_file $server_type $local_port 0 $server $config_file_path
elif [ "$server_type" == "v2ray" ]; then
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_v2ray_client_config_file.lua $server udp $local_port nil >$config_file_path
elif [ "$server_type" == "brook" ]; then
BROOK_UDP_CMD="tproxy -l 0.0.0.0:$local_port -s $server_ip:$server_port -p $(config_get $server password)"
elif [ "$server_type" == "trojan" ]; then
UDP_NODE1_PORT=$port
if [ "$type" == "ss" -o "$type" == "ssr" ]; then
gen_ss_ssr_config_file $type $local_port 0 $node $config_file_path
elif [ "$type" == "v2ray" ]; then
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_v2ray_client_config_file.lua $node udp $local_port nil >$config_file_path
elif [ "$type" == "brook" ]; then
BROOK_UDP_CMD="tproxy -l 0.0.0.0:$local_port -s $server_ip:$port -p $(config_n_get $node password)"
elif [ "$type" == "trojan" ]; then
local_port=$(get_not_exists_port_after $SOCKS5_PROXY_PORT1 tcp)
socks5_port=$local_port
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_trojan_client_config_file.lua $server client $socks5_port >$config_file_path
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_trojan_client_config_file.lua $node client $socks5_port >$config_file_path
fi
fi
if [ "$redir_type" == "TCP" ]; then
if [ "$network_type" == "ipv6" ]; then
TCP_REDIR_SERVER1_IPV6=$server_ip
TCP_NODE1_IPV6=$server_ip
else
TCP_REDIR_SERVER1_IP=$server_ip
TCP_NODE1_IP=$server_ip
fi
TCP_REDIR_SERVER1_PORT=$server_port
if [ "$server_type" == "v2ray" ]; then
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_v2ray_client_config_file.lua $server tcp $local_port nil >$config_file_path
elif [ "$server_type" == "trojan" ]; then
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_trojan_client_config_file.lua $server nat $local_port >$config_file_path
TCP_NODE1_PORT=$port
if [ "$type" == "v2ray" ]; then
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_v2ray_client_config_file.lua $node tcp $local_port nil >$config_file_path
elif [ "$type" == "trojan" ]; then
lua /usr/lib/lua/luci/model/cbi/passwall/api/gen_trojan_client_config_file.lua $node nat $local_port >$config_file_path
else
local kcptun_use kcptun_server_host kcptun_port kcptun_config
kcptun_use=$(config_get $server use_kcp)
kcptun_server_host=$(config_get $server kcp_server)
kcptun_port=$(config_get $server kcp_port)
kcptun_config=$(config_get $server kcp_opts)
kcptun_use=$(config_n_get $node use_kcp)
kcptun_server_host=$(config_n_get $node kcp_server)
kcptun_port=$(config_n_get $node kcp_port)
kcptun_config=$(config_n_get $node kcp_opts)
kcptun_path=""
lbenabled=$(config_t_get global_haproxy balancing_enable 0)
if [ "$kcptun_use" == "1" ] && ([ -z "$kcptun_port" ] || [ -z "$kcptun_config" ]); then
@ -326,26 +326,26 @@ gen_config_file() {
if [ -z "$kcptun_server_host" ]; then
start_kcptun "$kcptun_path" $server_ip $kcptun_port "$kcptun_config"
else
kcptun_use_ipv6=$(config_get $server kcp_use_ipv6)
kcptun_use_ipv6=$(config_n_get $node kcp_use_ipv6)
network_type="ipv4"
[ "$kcptun_use_ipv6" == "1" ] && network_type="ipv6"
kcptun_server_ip=$(get_host_ip $network_type $kcptun_server_host)
echolog "KCP服务器IP地址:$kcptun_server_ip"
TCP_REDIR_SERVER1_IP=$kcptun_server_ip
TCP_NODE1_IP=$kcptun_server_ip
start_kcptun "$kcptun_path" $kcptun_server_ip $kcptun_port "$kcptun_config"
fi
echolog "运行Kcptun..."
if [ "$server_type" == "ss" -o "$server_type" == "ssr" ]; then
gen_ss_ssr_config_file $server_type $local_port 1 $server $config_file_path
if [ "$type" == "ss" -o "$type" == "ssr" ]; then
gen_ss_ssr_config_file $type $local_port 1 $node $config_file_path
fi
if [ "$server_type" == "brook" ]; then
BROOK_TCP_CMD="tproxy -l 0.0.0.0:$local_port -s 127.0.0.1:$KCPTUN_REDIR_PORT -p $(config_get $server password)"
if [ "$type" == "brook" ]; then
BROOK_TCP_CMD="tproxy -l 0.0.0.0:$local_port -s 127.0.0.1:$KCPTUN_REDIR_PORT -p $(config_n_get $node password)"
fi
else
if [ "$server_type" == "ss" -o "$server_type" == "ssr" ]; then
gen_ss_ssr_config_file $server_type $local_port 0 $server $config_file_path
elif [ "$server_type" == "brook" ]; then
BROOK_TCP_CMD="tproxy -l 0.0.0.0:$local_port -s $server_ip:$server_port -p $(config_get $server password)"
if [ "$type" == "ss" -o "$type" == "ssr" ]; then
gen_ss_ssr_config_file $type $local_port 0 $node $config_file_path
elif [ "$type" == "brook" ]; then
BROOK_TCP_CMD="tproxy -l 0.0.0.0:$local_port -s $server_ip:$port -p $(config_n_get $node password)"
fi
fi
fi
@ -363,17 +363,17 @@ start_kcptun() {
}
start_tcp_redir() {
for i in $(seq 1 $TCP_REDIR_SERVER_NUM); do
eval temp_server=\$TCP_REDIR_SERVER$i
for i in $(seq 1 $TCP_NODE_NUM); do
eval temp_server=\$TCP_NODE$i
[ "$temp_server" != "nil" ] && {
TYPE=$(echo $(config_get $temp_server server_type) | tr 'A-Z' 'a-z')
TYPE=$(echo $(config_n_get $temp_server type) | tr 'A-Z' 'a-z')
local config_file=$CONFIG_PATH/TCP_$i.json
eval current_port=\$TCP_REDIR_PORT$i
local port=$(echo $(get_not_exists_port_after $current_port tcp))
eval TCP_REDIR_PORT$i=$port
gen_config_file $temp_server $port TCP $config_file
if [ "$TYPE" == "v2ray" ]; then
v2ray_path=$(config_t_get global_v2ray v2ray_client_file)
v2ray_path=$(config_t_get global_app v2ray_file)
if [ -f "${v2ray_path}/v2ray" ]; then
${v2ray_path}/v2ray -config=$config_file >/dev/null &
else
@ -381,24 +381,29 @@ start_tcp_redir() {
[ -n "$v2ray_bin" ] && $v2ray_bin -config=$config_file >/dev/null &
fi
elif [ "$TYPE" == "brook" ]; then
brook_bin=$(find_bin Brook)
[ -n "$brook_bin" ] && $brook_bin $BROOK_TCP_CMD &>/dev/null &
brook_bin=$(config_t_get global_app brook_file)
if [ -f "$brook_bin" ]; then
$brook_bin $BROOK_TCP_CMD &>/dev/null &
else
brook_bin=$(find_bin Brook)
[ -n "$brook_bin" ] && $brook_bin $BROOK_TCP_CMD &>/dev/null &
fi
elif [ "$TYPE" == "trojan" ]; then
trojan_bin=$(find_bin trojan)
[ -n "$trojan_bin" ] && $trojan_bin -c $config_file >/dev/null 2>&1 &
elif [ "$TYPE" == "socks5" ]; then
local server=$(config_get $temp_server server)
local server_port=$(config_get $temp_server server_port)
local server_username=$(config_get $temp_server username)
local server_password=$(config_get $temp_server password)
local address=$(config_n_get $temp_server address)
local port=$(config_n_get $temp_server port)
local server_username=$(config_n_get $temp_server username)
local server_password=$(config_n_get $temp_server password)
#ipt2socks_bin=$(find_bin ipt2socks)
#[ -n "$ipt2socks_bin" ] && {
# $ipt2socks_bin -T -l $port -b 0.0.0.0 -s $server -p $server_port -R >/dev/null &
# $ipt2socks_bin -T -l $port -b 0.0.0.0 -s $address -p $port -R >/dev/null &
#}
redsocks_bin=$(find_bin redsocks2)
[ -n "$redsocks_bin" ] && {
local redsocks_config_file=$CONFIG_PATH/TCP_$i.conf
gen_redsocks_config $redsocks_config_file tcp $port $server $server_port $server_username $server_password
gen_redsocks_config $redsocks_config_file tcp $port $address $port $server_username $server_password
$redsocks_bin -c $redsocks_config_file >/dev/null &
}
elif [ "$TYPE" == "ss" -o "$TYPE" == "ssr" ]; then
@ -415,17 +420,17 @@ start_tcp_redir() {
}
start_udp_redir() {
for i in $(seq 1 $UDP_REDIR_SERVER_NUM); do
eval temp_server=\$UDP_REDIR_SERVER$i
for i in $(seq 1 $UDP_NODE_NUM); do
eval temp_server=\$UDP_NODE$i
[ "$temp_server" != "nil" ] && {
TYPE=$(echo $(config_get $temp_server server_type) | tr 'A-Z' 'a-z')
TYPE=$(echo $(config_n_get $temp_server type) | tr 'A-Z' 'a-z')
local config_file=$CONFIG_PATH/UDP_$i.json
eval current_port=\$UDP_REDIR_PORT$i
local port=$(echo $(get_not_exists_port_after $current_port udp))
eval UDP_REDIR_PORT$i=$port
gen_config_file $temp_server $port UDP $config_file
if [ "$TYPE" == "v2ray" ]; then
v2ray_path=$(config_t_get global_v2ray v2ray_client_file)
v2ray_path=$(config_t_get global_app v2ray_file)
if [ -f "${v2ray_path}/v2ray" ]; then
${v2ray_path}/v2ray -config=$config_file >/dev/null &
else
@ -433,15 +438,20 @@ start_udp_redir() {
[ -n "$v2ray_bin" ] && $v2ray_bin -config=$config_file >/dev/null &
fi
elif [ "$TYPE" == "brook" ]; then
brook_bin=$(find_bin brook)
[ -n "$brook_bin" ] && $brook_bin $BROOK_UDP_CMD >/dev/null &
brook_bin=$(config_t_get global_app brook_file)
if [ -f "$brook_bin" ]; then
$brook_bin $BROOK_UDP_CMD >/dev/null &
else
brook_bin=$(find_bin Brook)
[ -n "$brook_bin" ] && $brook_bin $BROOK_UDP_CMD >/dev/null &
fi
elif [ "$TYPE" == "trojan" ]; then
trojan_bin=$(find_bin trojan)
[ -n "$trojan_bin" ] && $trojan_bin -c $config_file >/dev/null 2>&1 &
local server=$(config_get $temp_server server)
local server_port=$(config_get $temp_server server_port)
local server_username=$(config_get $temp_server username)
local server_password=$(config_get $temp_server password)
local address=$(config_n_get $temp_server address)
local port=$(config_n_get $temp_server port)
local server_username=$(config_n_get $temp_server username)
local server_password=$(config_n_get $temp_server password)
#ipt2socks_bin=$(find_bin ipt2socks)
#[ -n "$ipt2socks_bin" ] && {
# $ipt2socks_bin -U -l $port -b 0.0.0.0 -s 127.0.0.1 -p $socks5_port -R >/dev/null &
@ -454,19 +464,19 @@ start_udp_redir() {
$redsocks_bin -c $redsocks_config_file >/dev/null &
}
elif [ "$TYPE" == "socks5" ]; then
local server=$(config_get $temp_server server)
local server_port=$(config_get $temp_server server_port)
local server_username=$(config_get $temp_server username)
local server_password=$(config_get $temp_server password)
local address=$(config_n_get $temp_server address)
local port=$(config_n_get $temp_server port)
local server_username=$(config_n_get $temp_server username)
local server_password=$(config_n_get $temp_server password)
#ipt2socks_bin=$(find_bin ipt2socks)
#[ -n "$ipt2socks_bin" ] && {
# $ipt2socks_bin -U -l $port -b 0.0.0.0 -s $server -p $server_port -R >/dev/null &
# $ipt2socks_bin -U -l $port -b 0.0.0.0 -s $address -p $port -R >/dev/null &
#}
redsocks_bin=$(find_bin redsocks2)
[ -n "$redsocks_bin" ] && {
local redsocks_config_file=$CONFIG_PATH/UDP_$i.conf
gen_redsocks_config $redsocks_config_file udp $port $server $server_port $server_username $server_password
gen_redsocks_config $redsocks_config_file udp $port $address $port $server_username $server_password
$redsocks_bin -c $redsocks_config_file >/dev/null &
}
elif [ "$TYPE" == "ss" -o "$TYPE" == "ssr" ]; then
@ -481,17 +491,17 @@ start_udp_redir() {
}
start_socks5_proxy() {
for i in $(seq 1 $SOCKS5_PROXY_SERVER_NUM); do
eval temp_server=\$SOCKS5_PROXY_SERVER$i
for i in $(seq 1 $SOCKS5_NODE_NUM); do
eval temp_server=\$SOCKS5_NODE$i
if [ "$temp_server" != "nil" ]; then
TYPE=$(echo $(config_get $temp_server server_type) | tr 'A-Z' 'a-z')
TYPE=$(echo $(config_n_get $temp_server type) | tr 'A-Z' 'a-z')
local config_file=$CONFIG_PATH/Socks5_$i.json
eval current_port=\$SOCKS5_PROXY_PORT$i
local port=$(get_not_exists_port_after $current_port tcp)
eval SOCKS5_PROXY_PORT$i=$port
gen_config_file $temp_server $port Socks5 $config_file
if [ "$TYPE" == "v2ray" ]; then
v2ray_path=$(config_t_get global_v2ray v2ray_client_file)
v2ray_path=$(config_t_get global_app v2ray_file)
if [ -f "${v2ray_path}/v2ray" ]; then
${v2ray_path}/v2ray -config=$config_file >/dev/null &
else
@ -499,8 +509,13 @@ start_socks5_proxy() {
[ -n "$v2ray_bin" ] && $v2ray_bin -config=$config_file >/dev/null &
fi
elif [ "$TYPE" == "brook" ]; then
brook_bin=$(find_bin brook)
[ -n "$brook_bin" ] && $brook_bin $BROOK_SOCKS5_CMD >/dev/null &
brook_bin=$(config_t_get global_app brook_file)
if [ -f "$brook_bin" ]; then
$brook_bin $BROOK_SOCKS5_CMD >/dev/null &
else
brook_bin=$(find_bin Brook)
[ -n "$brook_bin" ] && $brook_bin $BROOK_SOCKS5_CMD >/dev/null &
fi
elif [ "$TYPE" == "trojan" ]; then
trojan_bin=$(find_bin trojan)
[ -n "$trojan_bin" ] && $trojan_bin -c $config_file >/dev/null 2>&1 &
@ -603,7 +618,7 @@ stop_crontab() {
start_dns() {
case "$DNS_MODE" in
dns2socks)
if [ -n "$SOCKS5_PROXY_SERVER1" -a "$SOCKS5_PROXY_SERVER1" != "nil" ]; then
if [ -n "$SOCKS5_NODE1" -a "$SOCKS5_NODE1" != "nil" ]; then
dns2socks_bin=$(find_bin dns2socks)
[ -n "$dns2socks_bin" ] && {
nohup $dns2socks_bin 127.0.0.1:$SOCKS5_PROXY_PORT1 $DNS_FORWARD 127.0.0.1:7913 >/dev/null 2>&1 &
@ -957,7 +972,7 @@ gen_pdnsd_config() {
}
stop_dnsmasq() {
if [ "$TCP_REDIR_SERVER1" == "nil" ]; then
if [ "$TCP_NODE1" == "nil" ]; then
rm -rf /var/dnsmasq.d/dnsmasq-$CONFIG.conf
rm -rf $DNSMASQ_PATH/dnsmasq-$CONFIG.conf
rm -rf $TMP_DNSMASQ_PATH
@ -1048,23 +1063,20 @@ start_haproxy() {
fi
done
#生成负载均衡控制台
adminstatus=$(config_t_get global_haproxy admin_enable)
if [ "$adminstatus" = "1" ]; then
adminport=$(config_t_get global_haproxy admin_port)
adminuser=$(config_t_get global_haproxy admin_user)
adminpassword=$(config_t_get global_haproxy admin_password)
cat <<-EOF >>$HAPROXY_FILE
listen status
bind 0.0.0.0:$adminport
mode http
stats refresh 30s
stats uri /
stats auth $adminuser:$adminpassword
#stats hide-version
stats admin if TRUE
EOF
fi
console_port=$(config_t_get global_haproxy console_port)
console_user=$(config_t_get global_haproxy console_user)
console_password=$(config_t_get global_haproxy console_password)
cat <<-EOF >>$HAPROXY_FILE
listen status
bind 0.0.0.0:$console_port
mode http
stats refresh 30s
stats uri /
stats auth $console_user:$console_password
#stats hide-version
stats admin if TRUE
EOF
nohup $haproxy_bin -f $HAPROXY_FILE 2>&1
echolog "负载均衡服务运行成功!"
}
@ -1083,11 +1095,11 @@ add_vps_port() {
[ "$failcount" -ge 10 ] && exit 0
sleep 1m
else
route add -host ${TCP_REDIR_SERVER1_IP} dev ${multiwan}
route add -host ${UDP_REDIR_SERVER1_IP} dev ${multiwan}
route add -host ${TCP_NODE1_IP} dev ${multiwan}
route add -host ${UDP_NODE1_IP} dev ${multiwan}
echolog "添加SS出口路由表$multiwan"
echo "$TCP_REDIR_SERVER1_IP" >$CONFIG_PATH/tcp_ip
echo "$UDP_REDIR_SERVER1_IP" >$CONFIG_PATH/udp_ip
echo "$TCP_NODE1_IP" >$CONFIG_PATH/tcp_ip
echo "$UDP_NODE1_IP" >$CONFIG_PATH/udp_ip
break
fi
done
@ -1108,7 +1120,7 @@ kill_all() {
boot() {
local delay=$(config_t_get global_delay start_delay 0)
if [ "$delay" -gt 0 ]; then
[ "$TCP_REDIR_SERVER1" != "nil" -o "$UDP_REDIR_SERVER1" != "nil" ] && {
[ "$TCP_NODE1" != "nil" -o "$UDP_NODE1" != "nil" ] && {
echolog "执行启动延时 $delay 秒后再启动!"
sleep $delay && start >/dev/null 2>&1 &
}

View File

@ -101,70 +101,70 @@ gen_laniplist() {
load_acl() {
local enabled
local aclremarks
local ipaddr
local macaddr
local remarks
local ip
local mac
local proxy_mode
local tcp_redir_server
local udp_redir_server
local tcp_node
local udp_node
local tcp_redir_ports
local udp_redir_ports
config_get enabled $1 enabled
config_get aclremarks $1 aclremarks
config_get ipaddr $1 ipaddr
config_get macaddr $1 macaddr
config_get remarks $1 remarks
config_get ip $1 ip
config_get mac $1 mac
config_get proxy_mode $1 proxy_mode
config_get tcp_redir_server $1 tcp_redir_server
config_get udp_redir_server $1 udp_redir_server
config_get tcp_node $1 tcp_node
config_get udp_node $1 udp_node
config_get tcp_redir_ports $1 tcp_redir_ports
config_get udp_redir_ports $1 udp_redir_ports
[ -z "$proxy_mode" -o "$proxy_mode" = "default" ] && proxy_mode=$PROXY_MODE
[ -z "$tcp_redir_ports" -o "$tcp_redir_ports" = "default" ] && tcp_redir_ports=$TCP_REDIR_PORTS
[ -z "$udp_redir_ports" -o "$udp_redir_ports" = "default" ] && udp_redir_ports=$UDP_REDIR_PORTS
eval TCP_REDIR_SERVER=\$TCP_REDIR_SERVER$tcp_redir_server
eval UDP_REDIR_SERVER=\$UDP_REDIR_SERVER$tcp_redir_server
local ip_mark=$(get_ip_mark $ipaddr)
eval TCP_NODE=\$TCP_NODE$tcp_node
eval UDP_NODE=\$UDP_NODE$udp_node
local ip_mark=$(get_ip_mark $ip)
[ "$enabled" == "1" -a -n "$proxy_mode" ] && {
if [ -n "$ipaddr" ] || [ -n "$macaddr" ]; then
if [ -n "$ipaddr" -a -n "$macaddr" ]; then
echolog "访问控制IP$ipaddrMAC$macaddr,代理模式:$(get_action_chain_name $proxy_mode)"
if [ -n "$ip" ] || [ -n "$mac" ]; then
if [ -n "$ip" -a -n "$mac" ]; then
echolog "访问控制IP$ipMAC$mac,代理模式:$(get_action_chain_name $proxy_mode)"
else
[ -n "$ipaddr" ] && echolog "访问控制IP$ipaddr,代理模式:$(get_action_chain_name $proxy_mode)"
[ -n "$macaddr" ] && echolog "访问控制MAC$macaddr,代理模式:$(get_action_chain_name $proxy_mode)"
[ -n "$ip" ] && echolog "访问控制IP$ip,代理模式:$(get_action_chain_name $proxy_mode)"
[ -n "$mac" ] && echolog "访问控制MAC$mac,代理模式:$(get_action_chain_name $proxy_mode)"
fi
[ "$TCP_REDIR_SERVER" != "nil" ] && {
#local TCP_REDIR_SERVER_TYPE=$(echo $(config_get $TCP_REDIR_SERVER server_type) | tr 'A-Z' 'a-z')
$iptables_mangle -A SS_ACL $(factor $ipaddr "-s") -p tcp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "$aclremarks" -j TTL --ttl-set 14$tcp_redir_server
$iptables_mangle -A SS_ACL $(factor $ipaddr "-s") -p tcp $(factor $macaddr "-m mac --mac-source") $(factor $tcp_redir_ports "-m multiport --dport") -m comment --comment "$aclremarks" -$(get_jump_mode $proxy_mode) $(get_action_chain $proxy_mode)$tcp_redir_server
[ "$TCP_NODE" != "nil" ] && {
#local TCP_NODE_TYPE=$(echo $(config_get $TCP_NODE type) | tr 'A-Z' 'a-z')
$iptables_mangle -A SS_ACL $(factor $ip "-s") -p tcp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "$remarks" -j TTL --ttl-set 14$tcp_node
$iptables_mangle -A SS_ACL $(factor $ip "-s") -p tcp $(factor $mac "-m mac --mac-source") $(factor $tcp_redir_ports "-m multiport --dport") -m comment --comment "$remarks" -$(get_jump_mode $proxy_mode) $(get_action_chain $proxy_mode)$tcp_node
}
[ "$UDP_REDIR_SERVER" != "nil" ] && {
#local UDP_REDIR_SERVER_TYPE=$(echo $(config_get $UDP_REDIR_SERVER server_type) | tr 'A-Z' 'a-z')
eval udp_redir_port=\$UDP_REDIR_PORT$udp_redir_server
$iptables_mangle -A SS_ACL $(factor $ipaddr "-s") -p udp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "$aclremarks" -j TPROXY --on-port $udp_redir_port --tproxy-mark 0x1/0x1
$iptables_mangle -A SS_ACL $(factor $ipaddr "-s") -p udp $(factor $macaddr "-m mac --mac-source") $(factor $udp_redir_ports "-m multiport --dport") -m comment --comment "$aclremarks" -$(get_jump_mode $proxy_mode) $(get_action_chain $proxy_mode)$udp_redir_server
[ "$UDP_NODE" != "nil" ] && {
#local UDP_NODE_TYPE=$(echo $(config_get $UDP_NODE type) | tr 'A-Z' 'a-z')
eval udp_redir_port=\$UDP_REDIR_PORT$udp_node
$iptables_mangle -A SS_ACL $(factor $ip "-s") -p udp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "$remarks" -j TPROXY --on-port $udp_redir_port --tproxy-mark 0x1/0x1
$iptables_mangle -A SS_ACL $(factor $ip "-s") -p udp $(factor $mac "-m mac --mac-source") $(factor $udp_redir_ports "-m multiport --dport") -m comment --comment "$remarks" -$(get_jump_mode $proxy_mode) $(get_action_chain $proxy_mode)$udp_node
}
[ -z "$ipaddr" ] && {
lower_macaddr=$(echo $macaddr | tr '[A-Z]' '[a-z]')
ipaddr=$(ip neigh show | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | grep $lower_macaddr | awk '{print $1}')
[ -z "$ipaddr" ] && {
dhcp_index=$(uci show dhcp | grep $lower_macaddr | awk -F'.' '{print $2}')
ipaddr=$(uci -q get dhcp.$dhcp_index.ip)
[ -z "$ip" ] && {
lower_mac=$(echo $mac | tr '[A-Z]' '[a-z]')
ip=$(ip neigh show | grep -E "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | grep $lower_mac | awk '{print $1}')
[ -z "$ip" ] && {
dhcp_index=$(uci show dhcp | grep $lower_mac | awk -F'.' '{print $2}')
ip=$(uci -q get dhcp.$dhcp_index.ip)
}
[ -z "$ipaddr" ] && ipaddr=$(cat /tmp/dhcp.leases | grep -E "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | grep $lower_macaddr | awk '{print $3}')
[ -z "$ip" ] && ip=$(cat /tmp/dhcp.leases | grep -E "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | grep $lower_mac | awk '{print $3}')
}
fi
}
}
filter_vpsip() {
local server_host server_ip use_ipv6 network_type
server_host=$(config_get $1 server)
local address server_ip use_ipv6 network_type
address=$(config_get $1 address)
use_ipv6=$(config_get $1 use_ipv6)
network_type="ipv4"
[ "$use_ipv6" == "1" ] && network_type="ipv6"
server_ip=$(get_host_ip $network_type $server_host)
server_ip=$(get_host_ip $network_type $address)
[ -n "$server_ip" -a "$server_ip" != "$TCP_REDIR_SERVER_IP" ] && {
[ -n "$server_ip" -a "$server_ip" != "$TCP_NODE_IP" ] && {
[ "$network_type" == "ipv4" ] && ipset add $IPSET_VPSIPLIST $server_ip >/dev/null 2>&1 &
}
}
@ -221,7 +221,7 @@ add_firewall_rule() {
[ -n "$lan_ipv4" ] && ipset add $IPSET_LANIPLIST $lan_ipv4 >/dev/null 2>&1 &
# 过滤所有节点IP
config_foreach filter_vpsip "servers"
config_foreach filter_vpsip "nodes"
$iptables_mangle -N SS
$iptables_mangle -A SS -m set --match-set $IPSET_LANIPLIST dst -j RETURN
@ -229,9 +229,9 @@ add_firewall_rule() {
$iptables_mangle -A SS -m set --match-set $IPSET_WHITELIST dst -j RETURN
$iptables_mangle -N SS_ACL
if [[ "$TCP_REDIR_SERVER_NUM" -ge 1 ]] || [[ "$UDP_REDIR_SERVER_NUM" -ge 1 ]]; then
if [[ "$TCP_NODE_NUM" -ge 1 ]] || [[ "$UDP_NODE_NUM" -ge 1 ]]; then
local max_num=1
[ "$TCP_REDIR_SERVER_NUM" -ge "$UDP_REDIR_SERVER_NUM" ] && max_num=$TCP_REDIR_SERVER_NUM
[ "$TCP_NODE_NUM" -ge "$UDP_NODE_NUM" ] && max_num=$TCP_NODE_NUM
if [ "$max_num" -ge 1 ]; then
for i in $(seq 1 $max_num); do
$iptables_mangle -N SS_GLO$i
@ -246,34 +246,34 @@ add_firewall_rule() {
fi
fi
if [ "$SOCKS5_PROXY_SERVER_NUM" -ge 1 ]; then
for i in $(seq 1 $SOCKS5_PROXY_SERVER_NUM); do
if [ "$SOCKS5_NODE_NUM" -ge 1 ]; then
for i in $(seq 1 $SOCKS5_NODE_NUM); do
local k=$i
eval temp_server=\$SOCKS5_PROXY_SERVER$k
eval temp_server=\$SOCKS5_NODE$k
if [ "$temp_server" != "nil" ]; then
local server_host=$(config_get $temp_server server)
local SOCKS5_PROXY_SERVER_PORT=$(config_get $temp_server server_port)
local SOCKS5_PROXY_SERVER_IP=$(get_host_ip "ipv4" $server_host)
[ -n "$SOCKS5_PROXY_SERVER_IP" -a -n "$SOCKS5_PROXY_SERVER_PORT" ] && $iptables_mangle -A SS -p tcp -d $SOCKS5_PROXY_SERVER_IP -m multiport --dports $SOCKS5_PROXY_SERVER_PORT -j RETURN
local address=$(config_get $temp_server address)
local SOCKS5_NODE_PORT=$(config_get $temp_server port)
local SOCKS5_NODE_IP=$(get_host_ip "ipv4" $address)
[ -n "$SOCKS5_NODE_IP" -a -n "$SOCKS5_NODE_PORT" ] && $iptables_mangle -A SS -p tcp -d $SOCKS5_NODE_IP -m multiport --dports $SOCKS5_NODE_PORT -j RETURN
fi
done
fi
if [ "$TCP_REDIR_SERVER_NUM" -ge 1 ]; then
for i in $(seq 1 $TCP_REDIR_SERVER_NUM); do
if [ "$TCP_NODE_NUM" -ge 1 ]; then
for i in $(seq 1 $TCP_NODE_NUM); do
local k=$i
local local_port=104$k
local ttl=14$k
eval temp_server=\$TCP_REDIR_SERVER$k
eval temp_server=\$TCP_NODE$k
eval local_port=\$TCP_REDIR_PORT$k
# 生成TCP转发规则
if [ "$temp_server" != "nil" ]; then
local server_host=$(config_get $temp_server server)
local TCP_REDIR_SERVER_PORT=$(config_get $temp_server server_port)
local TCP_REDIR_SERVER_IP=$(get_host_ip "ipv4" $server_host)
local TCP_REDIR_SERVER_TYPE=$(echo $(config_get $temp_server server_type) | tr 'A-Z' 'a-z')
[ -n "$TCP_REDIR_SERVER_IP" -a -n "$TCP_REDIR_SERVER_PORT" ] && $iptables_mangle -A SS -p tcp -d $TCP_REDIR_SERVER_IP -m multiport --dports $TCP_REDIR_SERVER_PORT -j RETURN
if [ "$TCP_REDIR_SERVER_TYPE" == "brook" ]; then
local address=$(config_get $temp_server address)
local TCP_NODE_PORT=$(config_get $temp_server port)
local TCP_NODE_IP=$(get_host_ip "ipv4" $address)
local TCP_NODE_TYPE=$(echo $(config_get $temp_server type) | tr 'A-Z' 'a-z')
[ -n "$TCP_NODE_IP" -a -n "$TCP_NODE_PORT" ] && $iptables_mangle -A SS -p tcp -d $TCP_NODE_IP -m multiport --dports $TCP_NODE_PORT -j RETURN
if [ "$TCP_NODE_TYPE" == "brook" ]; then
$iptables_mangle -A SS_ACL -p tcp -m socket -j MARK --set-mark 1
# $iptables_mangle -A SS$k -p tcp -m set --match-set $IPSET_BLACKLIST dst -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
@ -366,26 +366,46 @@ add_firewall_rule() {
$iptables_nat -A SS -p tcp -m ttl --ttl-eq $ttl -j REDIRECT --to $local_port
echolog "IPv4 防火墙TCP转发规则加载完成"
fi
if [ "$PROXY_IPV6" == "1" ]; then
lan_ipv6=$(ip address show br-lan | grep -w "inet6" | awk '{print $2}') #当前LAN IPv6段
$ip6tables_nat -N SS
$ip6tables_nat -N SS_ACL
$ip6tables_nat -A PREROUTING -j SS
[ -n "$lan_ipv6" ] && {
for ip in $lan_ipv6; do
$ip6tables_nat -A SS -d $ip -j RETURN
done
}
[ "$use_ipv6" == "1" -a -n "$server_ip" ] && $ip6tables_nat -A SS -d $server_ip -j RETURN
$ip6tables_nat -N SS_GLO$k
$ip6tables_nat -N SS_GFW$k
$ip6tables_nat -N SS_CHN$k
$ip6tables_nat -N SS_HOME$k
$ip6tables_nat -A SS_GLO$k -p tcp -j REDIRECT --to $TCP_REDIR_PORT
$ip6tables_nat -A SS -j SS_GLO$k
#$ip6tables_nat -I OUTPUT -p tcp -j SS
echolog "IPv6防火墙规则加载完成"
fi
fi
done
else
echolog "主服务器未选择无法转发TCP"
fi
if [ "$UDP_REDIR_SERVER_NUM" -ge 1 ]; then
for i in $(seq 1 $UDP_REDIR_SERVER_NUM); do
if [ "$UDP_NODE_NUM" -ge 1 ]; then
for i in $(seq 1 $UDP_NODE_NUM); do
local k=$i
local local_port=104$k
eval temp_server=\$UDP_REDIR_SERVER$k
eval temp_server=\$UDP_NODE$k
eval local_port=\$UDP_REDIR_PORT$k
# 生成UDP转发规则
if [ "$temp_server" != "nil" ]; then
local server_host=$(config_get $temp_server server)
local UDP_REDIR_SERVER_PORT=$(config_get $temp_server server_port)
local UDP_REDIR_SERVER_IP=$(get_host_ip "ipv4" $server_host)
local UDP_REDIR_SERVER_TYPE=$(echo $(config_get $temp_server server_type) | tr 'A-Z' 'a-z')
[ -n "$UDP_REDIR_SERVER_IP" -a -n "$UDP_REDIR_SERVER_PORT" ] && $iptables_mangle -A SS -p udp -d $UDP_REDIR_SERVER_IP -m multiport --dports $UDP_REDIR_SERVER_PORT -j RETURN
[ "$UDP_REDIR_SERVER_TYPE" == "brook" ] && $iptables_mangle -A SS_ACL -p udp -m socket -j MARK --set-mark 1
local address=$(config_get $temp_server address)
local UDP_NODE_PORT=$(config_get $temp_server port)
local UDP_NODE_IP=$(get_host_ip "ipv4" $address)
local UDP_NODE_TYPE=$(echo $(config_get $temp_server type) | tr 'A-Z' 'a-z')
[ -n "$UDP_NODE_IP" -a -n "$UDP_NODE_PORT" ] && $iptables_mangle -A SS -p udp -d $UDP_NODE_IP -m multiport --dports $UDP_NODE_PORT -j RETURN
[ "$UDP_NODE_TYPE" == "brook" ] && $iptables_mangle -A SS_ACL -p udp -m socket -j MARK --set-mark 1
# 全局模式
$iptables_mangle -A SS_GLO$k -p udp -j TPROXY --on-port $local_port --tproxy-mark 0x1/0x1
@ -413,47 +433,23 @@ add_firewall_rule() {
$iptables_mangle -A PREROUTING -j SS
$iptables_mangle -A SS -j SS_ACL
# 加载ACLS
config_foreach load_acl "acl_rule"
local max_num=1
[ "$TCP_REDIR_SERVER_NUM" -ge "$UDP_REDIR_SERVER_NUM" ] && max_num=$TCP_REDIR_SERVER_NUM
if [ "$max_num" -ge 1 ]; then
for i in $(seq 1 $max_num); do
local k=$i
# 加载ACLS
[ "$k" == 1 ] && config_foreach load_acl "acl_rule"
# 加载默认代理模式
if [ "$PROXY_MODE" == "disable" ]; then
[ "$TCP_REDIR_SERVER" != "nil" ] && $iptables_mangle -A SS_ACL -p tcp -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)
[ "$UDP_REDIR_SERVER" != "nil" ] && $iptables_mangle -A SS_ACL -p udp -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)
else
$iptables_mangle -A SS_ACL -p tcp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "$Default" -j TTL --ttl-set 14$k
[ "$PROXY_MODE" == "gfwlist" ] && dns_hijack "force"
[ "$TCP_REDIR_SERVER" != "nil" ] && $iptables_mangle -A SS_ACL -p tcp -m multiport --dport $TCP_REDIR_PORTS -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)$k
[ "$UDP_REDIR_SERVER" != "nil" ] && $iptables_mangle -A SS_ACL -p udp -m multiport --dport $UDP_REDIR_PORTS -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)$k
fi
if [ "$PROXY_IPV6" == "1" ]; then
lan_ipv6=$(ip address show br-lan | grep -w "inet6" | awk '{print $2}') #当前LAN IPv6段
$ip6tables_nat -N SS
$ip6tables_nat -N SS_ACL
$ip6tables_nat -A PREROUTING -j SS
[ -n "$lan_ipv6" ] && {
for ip in $lan_ipv6; do
$ip6tables_nat -A SS -d $ip -j RETURN
done
}
[ "$use_ipv6" == "1" -a -n "$server_ip" ] && $ip6tables_nat -A SS -d $server_ip -j RETURN
$ip6tables_nat -N SS_GLO$k
$ip6tables_nat -N SS_GFW$k
$ip6tables_nat -N SS_CHN$k
$ip6tables_nat -N SS_HOME$k
$ip6tables_nat -A SS_GLO$k -p tcp -j REDIRECT --to $TCP_REDIR_PORT
$ip6tables_nat -A SS -j SS_GLO$k
#$ip6tables_nat -I OUTPUT -p tcp -j SS
echolog "IPv6防火墙规则加载完成"
fi
done
# 加载默认代理模式
if [ "$PROXY_MODE" == "disable" ]; then
[ "$TCP_NODE1" != "nil" ] && $iptables_mangle -A SS_ACL -p tcp -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)
[ "$UDP_NODE1" != "nil" ] && $iptables_mangle -A SS_ACL -p udp -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)
else
[ "$TCP_NODE1" != "nil" ] && {
$iptables_mangle -A SS_ACL -p tcp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "Default" -j TTL --ttl-set 141
$iptables_mangle -A SS_ACL -p tcp -m multiport --dport $TCP_REDIR_PORTS -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)1
}
[ "$UDP_NODE1" != "nil" ] && {
$iptables_mangle -A SS_ACL -p udp -m set --match-set $IPSET_BLACKLIST dst -m comment --comment "Default" -j TPROXY --on-port $UDP_REDIR_PORT1 --tproxy-mark 0x1/0x1
$iptables_mangle -A SS_ACL -p udp -m multiport --dport $UDP_REDIR_PORTS -m comment --comment "Default" -j $(get_action_chain $PROXY_MODE)1
}
fi
}
@ -499,7 +495,7 @@ del_firewall_rule() {
$ip6tables_nat -F SS 2>/dev/null && $ip6tables_nat -X SS 2>/dev/null
$ip6tables_nat -F SS_ACL 2>/dev/null && $ip6tables_nat -X SS_ACL 2>/dev/null
local max_num=10
local max_num=5
if [ "$max_num" -ge 1 ]; then
for i in $(seq 1 $max_num); do
local k=$i

View File

@ -15,27 +15,27 @@ config_t_get() {
echo ${ret:=$3}
}
TCP_REDIR_SERVER_NUM=$(config_t_get global_other tcp_redir_server_num 1)
for i in $(seq 1 $TCP_REDIR_SERVER_NUM); do
eval TCP_REDIR_SERVER$i=$(config_t_get global tcp_redir_server$i nil)
TCP_NODE_NUM=$(config_t_get global_other tcp_node_num 1)
for i in $(seq 1 $TCP_NODE_NUM); do
eval TCP_NODE$i=$(config_t_get global tcp_node$i nil)
done
UDP_REDIR_SERVER_NUM=$(config_t_get global_other udp_redir_server_num 1)
for i in $(seq 1 $UDP_REDIR_SERVER_NUM); do
eval UDP_REDIR_SERVER$i=$(config_t_get global udp_redir_server$i nil)
UDP_NODE_NUM=$(config_t_get global_other udp_node_num 1)
for i in $(seq 1 $UDP_NODE_NUM); do
eval UDP_NODE$i=$(config_t_get global udp_node$i nil)
done
SOCKS5_PROXY_SERVER_NUM=$(config_t_get global_other socks5_proxy_server_num 1)
for i in $(seq 1 $SOCKS5_PROXY_SERVER_NUM); do
eval SOCKS5_PROXY_SERVER$i=$(config_t_get global socks5_proxy_server$i nil)
SOCKS5_NODE_NUM=$(config_t_get global_other socks5_node_num 1)
for i in $(seq 1 $SOCKS5_NODE_NUM); do
eval SOCKS5_NODE$i=$(config_t_get global socks5_node$i nil)
done
dns_mode=$(config_t_get global dns_mode)
use_haproxy=$(config_t_get global_haproxy balancing_enable 0)
#tcp
for i in $(seq 1 $TCP_REDIR_SERVER_NUM); do
eval temp_server=\$TCP_REDIR_SERVER$i
for i in $(seq 1 $TCP_NODE_NUM); do
eval temp_server=\$TCP_NODE$i
if [ "$temp_server" != "nil" ]; then
#kcptun
use_kcp=$(config_n_get $temp_server use_kcp 0)
@ -58,10 +58,10 @@ done
#udp
for i in $(seq 1 $UDP_REDIR_SERVER_NUM); do
eval temp_server=\$UDP_REDIR_SERVER$i
for i in $(seq 1 $UDP_NODE_NUM); do
eval temp_server=\$UDP_NODE$i
if [ "$temp_server" != "nil" ]; then
[ "$temp_server" == "default" ] && temp_server=$TCP_REDIR_SERVER1
[ "$temp_server" == "default" ] && temp_server=$TCP_NODE1
[ -f "/var/etc/passwall/port/UDP_$i" ] && listen_port=$(echo -n `cat /var/etc/passwall/port/UDP_$i`)
icount=$(ps -w | grep -v grep | grep -i -E "${CONFIG}/UDP_${i}|brook tproxy -l 0.0.0.0:${listen_port}|ipt2socks -U -l ${listen_port}" | wc -l)
if [ $icount = 0 ]; then
@ -72,8 +72,8 @@ for i in $(seq 1 $UDP_REDIR_SERVER_NUM); do
done
#socks5
for i in $(seq 1 $SOCKS5_PROXY_SERVER_NUM); do
eval temp_server=\$SOCKS5_PROXY_SERVER$i
for i in $(seq 1 $SOCKS5_NODE_NUM); do
eval temp_server=\$SOCKS5_NODE$i
if [ "$temp_server" != "nil" ]; then
[ -f "/var/etc/passwall/port/Socks5_$i" ] && listen_port=$(echo -n `cat /var/etc/passwall/port/Socks5_$i`)
icount=$(ps -w | grep -v grep | grep -i -E "${CONFIG}/Socks5_${i}|brook client -l 0.0.0.0:${listen_port}" | wc -l)

View File

@ -29,22 +29,22 @@ decode_url_link() {
fi
}
get_server_index(){
get_node_index(){
[ -f "/etc/config/$CONFIG" ] && {
servers_index=$(uci show $CONFIG | grep -c "=servers")
nodes_index=$(uci show $CONFIG | grep -c "=nodes")
}
}
get_local_servers(){
[ -f "/etc/config/$CONFIG" ] && [ "`uci show $CONFIG | grep -c 'sub_server'`" -gt 0 ] && {
get_server_index
for i in `seq $servers_index -1 1`
get_local_nodes(){
[ -f "/etc/config/$CONFIG" ] && [ "`uci show $CONFIG | grep -c 'sub_node'`" -gt 0 ] && {
get_node_index
for i in `seq $nodes_index -1 1`
do
[ "$(uci show $CONFIG.@servers[$(($i-1))]|grep -c "sub_server")" -eq 1 ] && {
if [ ! -f "/usr/share/${CONFIG}/sub/all_localservers" ]; then
echo $(config_t_get servers server $(($i-1))) > /usr/share/${CONFIG}/sub/all_localservers
[ "$(uci show $CONFIG.@nodes[$(($i-1))]|grep -c "sub_node")" -eq 1 ] && {
if [ ! -f "/usr/share/${CONFIG}/sub/all_localnodes" ]; then
echo $(config_t_get nodes address $(($i-1))) > /usr/share/${CONFIG}/sub/all_localnodes
else
echo $(config_t_get servers server $(($i-1))) >> /usr/share/${CONFIG}/sub/all_localservers
echo $(config_t_get nodes address $(($i-1))) >> /usr/share/${CONFIG}/sub/all_localnodes
fi
}
done
@ -52,20 +52,19 @@ get_local_servers(){
}
get_remote_config(){
remarks="(订阅)"
[ -n "$3" ] && remarks="(导入)"
group="sub_server"
add_mode="订阅"
[ -n "$3" ] && add_mode="导入"
group="sub_node"
if [ "$1" == "ss" ]; then
decode_link="$2"
server=$(echo "$decode_link" | awk -F ':' '{print $2}' | awk -F '@' '{print $2}')
server_port=$(echo "$decode_link" | awk -F ':' '{print $3}')
node_address=$(echo "$decode_link" | awk -F ':' '{print $2}' | awk -F '@' '{print $2}')
node_port=$(echo "$decode_link" | awk -F ':' '{print $3}')
ssr_encrypt_method=$(echo "$decode_link" | awk -F ':' '{print $1}')
password=$(echo "$decode_link" | awk -F ':' '{print $2}' | awk -F '@' '{print $1}')
server_host=$server
elif [ "$1" == "ssr" ]; then
decode_link="$2"
server=$(echo "$decode_link" | awk -F ':' '{print $1}')
server_port=$(echo "$decode_link" | awk -F ':' '{print $2}')
node_address=$(echo "$decode_link" | awk -F ':' '{print $1}')
node_port=$(echo "$decode_link" | awk -F ':' '{print $2}')
protocol=$(echo "$decode_link" | awk -F ':' '{print $3}')
ssr_encrypt_method=$(echo "$decode_link" | awk -F ':' '{print $4}')
obfs=$(echo "$decode_link" | awk -F ':' '{print $5}')
@ -78,13 +77,12 @@ get_remote_config(){
remarks_temp=$(echo "$decode_link" |grep -Eo "remarks.+" |sed 's/remarks=//g'|awk -F'&' '{print $1}')
[ -n "$remarks_temp" ] && remarks="${remarks}$(decode_url_link $remarks_temp 0)"
group_temp=$(echo "$decode_link" |grep -Eo "group.+" |sed 's/group=//g'|awk -F'&' '{print $1}')
server_host=$server
elif [ "$1" == "v2ray" ]; then
json_load "$2"
json_get_var json_v v
json_get_var json_ps ps
json_get_var json_server add
json_get_var json_server_port port
json_get_var json_node_address add
json_get_var json_node_port port
json_get_var json_id id
json_get_var json_aid aid
json_get_var json_security security
@ -101,34 +99,35 @@ get_remote_config(){
json_tls="none"
fi
remarks="${remarks}${json_ps}"
server_host=$json_server
remarks="${json_ps}"
node_address=$json_node_address
fi
# 把全部服务器节点写入文件 /usr/share/${CONFIG}/sub/all_onlineservers
if [ ! -f "/usr/share/${CONFIG}/sub/all_onlineservers" ]; then
echo $server_host > /usr/share/${CONFIG}/sub/all_onlineservers
# 把全部服务器节点写入文件 /usr/share/${CONFIG}/sub/all_onlinenodes
if [ ! -f "/usr/share/${CONFIG}/sub/all_onlinenodes" ]; then
echo $node_address > /usr/share/${CONFIG}/sub/all_onlinenodes
else
echo $server_host >> /usr/share/${CONFIG}/sub/all_onlineservers
echo $node_address >> /usr/share/${CONFIG}/sub/all_onlinenodes
fi
}
add_servers(){
get_server_index
uci_set="uci set $CONFIG.@servers[$servers_index]."
uci add $CONFIG servers > /dev/null
add_nodes(){
get_node_index
uci_set="uci set $CONFIG.@nodes[$nodes_index]."
uci add $CONFIG nodes > /dev/null
[ -z "$3" ] && ${uci_set}group="$group"
if [ "$2" == "ss" ]; then
${uci_set}add_mode="$add_mode"
${uci_set}remarks="$remarks"
${uci_set}server_type="SSR"
${uci_set}server="$server_host"
${uci_set}type="SSR"
${uci_set}address="$node_address"
${uci_set}use_ipv6=0
${uci_set}server_port="$server_port"
${uci_set}port="$node_port"
${uci_set}password="$password"
${uci_set}ssr_encrypt_method="$ssr_encrypt_method"
${uci_set}timeout=300
${uci_set}fast_open=false
${uci_set}tcp_fast_open=false
if [ "$1" == "add" ]; then
let addnum_ss+=1
@ -137,11 +136,12 @@ add_servers(){
fi
elif [ "$2" == "ssr" ]; then
${uci_set}add_mode="$add_mode"
${uci_set}remarks="$remarks"
${uci_set}server_type="SSR"
${uci_set}server="$server_host"
${uci_set}type="SSR"
${uci_set}address="$node_address"
${uci_set}use_ipv6=0
${uci_set}server_port="$server_port"
${uci_set}port="$node_port"
${uci_set}password="$password"
${uci_set}ssr_encrypt_method="$ssr_encrypt_method"
${uci_set}protocol="$protocol"
@ -149,7 +149,7 @@ add_servers(){
${uci_set}obfs="$obfs"
${uci_set}obfs_param="$obfsparam"
${uci_set}timeout=300
${uci_set}fast_open=false
${uci_set}tcp_fast_open=false
if [ "$1" == "add" ]; then
let addnum_ssr+=1
@ -158,12 +158,13 @@ add_servers(){
fi
elif [ "$2" == "v2ray" ]; then
${uci_set}add_mode="$add_mode"
${uci_set}remarks="$remarks"
${uci_set}server_type="V2ray"
${uci_set}type="V2ray"
${uci_set}v2ray_protocol="vmess"
${uci_set}server="$json_server"
${uci_set}address="$node_address"
${uci_set}use_ipv6=0
${uci_set}server_port="$json_server_port"
${uci_set}port="$json_node_port"
${uci_set}v2ray_security="auto"
${uci_set}v2ray_VMess_id="$json_id"
${uci_set}v2ray_VMess_alterId="$json_aid"
@ -187,34 +188,34 @@ add_servers(){
}
update_config(){
isadded_server=$(uci show $CONFIG | grep -c "remarks='$remarks'")
if [ "$isadded_server" -eq 0 ]; then
add_servers add "$link_type"
isadded_address=$(uci show $CONFIG | grep -c "remarks='$remarks'")
if [ "$isadded_address" -eq 0 ]; then
add_nodes add "$link_type"
else
index=$(uci show $CONFIG | grep -w "remarks='$remarks'" | cut -d '[' -f2|cut -d ']' -f1)
local_server_port=$(config_t_get servers server_port $index)
local_vmess_id=$(config_t_get servers v2ray_VMess_id $index)
local_port=$(config_t_get nodes port $index)
local_vmess_id=$(config_t_get nodes v2ray_VMess_id $index)
uci delete $CONFIG.@servers[$index]
add_servers update "$link_type"
uci delete $CONFIG.@nodes[$index]
add_nodes update "$link_type"
fi
}
del_config(){
# 删除订阅服务器已经不存在的节点
for localserver in $(cat /usr/share/${CONFIG}/sub/all_localservers)
for localaddress in $(cat /usr/share/${CONFIG}/sub/all_localnodes)
do
[ "`cat /usr/share/${CONFIG}/sub/all_onlineservers |grep -c "$localserver"`" -eq 0 ] && {
for localindex in $(uci show $CONFIG|grep -w "$localserver" |grep -w "server=" |cut -d '[' -f2|cut -d ']' -f1)
[ "`cat /usr/share/${CONFIG}/sub/all_onlinenodes |grep -c "$localaddress"`" -eq 0 ] && {
for localindex in $(uci show $CONFIG|grep -w "$localaddress" |grep -w "address=" |cut -d '[' -f2|cut -d ']' -f1)
do
del_server_type=$(uci get $CONFIG.@servers[$localindex].server_type)
uci delete $CONFIG.@servers[$localindex]
del_type=$(uci get $CONFIG.@nodes[$localindex].type)
uci delete $CONFIG.@nodes[$localindex]
uci commit $CONFIG
if [ "$del_server_type" == "SS" ]; then
if [ "$del_type" == "SS" ]; then
let delnum_ss+=1 #删除该节点
elif [ "$del_server_type" == "SSR" ]; then
elif [ "$del_type" == "SSR" ]; then
let delnum_ssr+=1 #删除该节点
elif [ "$del_server_type" == "V2ray" ]; then
elif [ "$del_type" == "V2ray" ]; then
let delnum_v2ray+=1 #删除该节点
fi
@ -224,16 +225,16 @@ del_config(){
}
del_all_config(){
get_server_index
[ "`uci show $CONFIG | grep -c 'sub_server'`" -eq 0 ] && exit 0
current_tcp_redir_server1=$(config_t_get global tcp_redir_server1)
is_sub_server=`uci -q get $CONFIG.$current_tcp_redir_server1.group`
for i in `seq $servers_index -1 1`
get_node_index
[ "`uci show $CONFIG | grep -c 'sub_node'`" -eq 0 ] && exit 0
current_tcp_node1=$(config_t_get global tcp_node1)
is_sub_node=`uci -q get $CONFIG.$current_tcp_node1.group`
for i in `seq $nodes_index -1 1`
do
[ "$(uci show $CONFIG.@servers[$(($i-1))] | grep -c 'sub_server')" -eq 1 ] && uci delete $CONFIG.@servers[$(($i-1))] && uci commit $CONFIG
[ "$(uci show $CONFIG.@nodes[$(($i-1))] | grep -c 'sub_node')" -eq 1 ] && uci delete $CONFIG.@nodes[$(($i-1))] && uci commit $CONFIG
done
[ -n "$is_sub_server" ] && {
uci set $CONFIG.global[0].tcp_redir_server1="nil"
[ -n "$is_sub_node" ] && {
uci set $CONFIG.global[0].tcp_node1="nil"
uci commit $CONFIG && /etc/init.d/$CONFIG stop
}
}
@ -261,7 +262,7 @@ add() {
get_remote_config "$link_type" "$decode_link" 1
update_config
done
[ -f "/usr/share/${CONFIG}/sub/all_onlineservers" ] && rm -f /usr/share/${CONFIG}/sub/all_onlineservers
[ -f "/usr/share/${CONFIG}/sub/all_onlinenodes" ] && rm -f /usr/share/${CONFIG}/sub/all_onlinenodes
}
rm -f /tmp/links.conf
rm -f "$LOCK_FILE"
@ -290,7 +291,7 @@ start() {
[ ! -d "/var/${CONFIG}_sub" ] || [ "$(ls /var/${CONFIG}_sub | wc -l)" -eq 0 ] && echo "$Date: 订阅链接下载失败,请重试!" >> $LOG_FILE && rm -f "$LOCK_FILE" && exit 0
mkdir -p /usr/share/${CONFIG}/sub && rm -f /usr/share/${CONFIG}/sub/*
get_local_servers
get_local_nodes
for file in /var/${CONFIG}_sub/*
do
[ -z "$(du -sh $file 2> /dev/null)" ] && echo "$Date: 订阅链接下载 $file 失败,请重试!" >> $LOG_FILE && continue
@ -321,7 +322,7 @@ start() {
update_config
done
done
[ -f "/usr/share/${CONFIG}/sub/all_localservers" ] && del_config
[ -f "/usr/share/${CONFIG}/sub/all_localnodes" ] && del_config
echo "$Date: 本次更新SS新增服务器节点 $addnum_ss 个,修改 $updatenum_ss 个,删除 $delnum_ss 个。" >> $LOG_FILE
echo "$Date: 本次更新SSR新增服务器节点 $addnum_ssr 个,修改 $updatenum_ssr 个,删除 $delnum_ssr 个。" >> $LOG_FILE
echo "$Date: 本次更新V2ray新增服务器节点 $addnum_v2ray 个,修改 $updatenum_v2ray 个,删除 $delnum_v2ray 个。" >> $LOG_FILE
@ -331,7 +332,7 @@ start() {
}
stop() {
[ "`uci show $CONFIG | grep -c 'sub_server'`" -gt 0 ] && {
[ "`uci show $CONFIG | grep -c 'sub_node'`" -gt 0 ] && {
echo "$Date: 在线订阅节点已全部删除" >> $LOG_FILE
del_all_config
}

View File

@ -30,7 +30,7 @@ test_proxy() {
test_auto_switch() {
if [ -f "/var/etc/passwall/tcp_server_id" ]; then
TCP_REDIR_SERVER1=$(cat /var/etc/passwall/tcp_server_id)
TCP_NODES1=$(cat /var/etc/passwall/tcp_server_id)
else
rm -f $LOCK_FILE
exit 1
@ -47,17 +47,17 @@ test_auto_switch() {
let "failcount++"
[ "$failcount" -ge 6 ] && {
echo "$(get_date): 自动切换检测:检测异常,切换节点" >>/var/log/passwall.log
TCP_REDIR_SERVERS=$(uci get passwall.@auto_switch[0].tcp_redir_server)
has_backup_server=$(echo $TCP_REDIR_SERVERS | grep $TCP_REDIR_SERVER1)
TCP_NODES=$(uci get passwall.@auto_switch[0].tcp_node)
has_backup_server=$(echo $TCP_NODES | grep $TCP_NODES1)
setserver=
if [ -z "$has_backup_server" ]; then
setserver=$(echo $TCP_REDIR_SERVERS | awk -F ' ' '{print $1}')
setserver=$(echo $TCP_NODES | awk -F ' ' '{print $1}')
else
setserver=$TCP_REDIR_SERVER1
setserver=$TCP_NODES1
flag=0
for server in $has_backup_server; do
if [ "$flag" == 0 ]; then
if [ "$TCP_REDIR_SERVER1" == "$server" ]; then
if [ "$TCP_NODES1" == "$server" ]; then
flag=1
continue
fi
@ -73,7 +73,7 @@ test_auto_switch() {
done
fi
rm -f $LOCK_FILE
uci set passwall.@global[0].tcp_redir_server=$setserver
uci set passwall.@global[0].tcp_node=$setserver
uci commit passwall
/etc/init.d/passwall restart
exit 1
@ -117,7 +117,7 @@ else
touch $LOCK_FILE
fi
is_auto_switch=$(uci show $CONFIG.@auto_switch[0] | grep "tcp_redir_server")
is_auto_switch=$(uci show $CONFIG.@auto_switch[0] | grep "tcp_node")
if [ -z "$is_auto_switch" ]; then
test_reconnection
else