From 6bb37834f02cd3bd578d14d9cdfad94f78bf425f Mon Sep 17 00:00:00 2001 From: xiaorouji <60100640+xiaorouji@users.noreply.github.com> Date: Mon, 4 Jan 2021 19:35:26 +0800 Subject: [PATCH] luci-app-passwall: bump to 4-6 --- package/lienol/luci-app-passwall/Makefile | 8 +- .../luasrc/controller/passwall.lua | 44 ++--- .../model/cbi/passwall/api/gen_xray.lua | 1 + .../luasrc/model/cbi/passwall/client/acl.lua | 14 -- .../model/cbi/passwall/client/auto_switch.lua | 24 +-- .../model/cbi/passwall/client/global.lua | 108 ++++++------ .../model/cbi/passwall/client/node_config.lua | 2 + .../model/cbi/passwall/client/other.lua | 21 +-- .../model/cbi/passwall/client/rule_list.lua | 78 +-------- .../model/cbi/passwall/server/api/xray.lua | 31 +++- .../luasrc/model/cbi/passwall/server/user.lua | 25 ++- .../luasrc/view/passwall/global/footer.htm | 51 +++--- .../luasrc/view/passwall/global/status.htm | 13 +- .../luasrc/view/passwall/global/status2.htm | 13 +- .../passwall/node_list/link_share_man.htm | 5 + .../view/passwall/node_list/node_list.htm | 21 +-- .../luci-app-passwall/po/zh-cn/passwall.po | 3 - .../root/etc/config/passwall | 10 +- .../root/usr/share/passwall/app.sh | 122 ++++++-------- .../root/usr/share/passwall/iptables.sh | 154 ++++++------------ .../root/usr/share/passwall/monitor.sh | 61 +++---- .../root/usr/share/passwall/subscribe.lua | 53 +++--- .../root/usr/share/passwall/test.sh | 43 ++--- 23 files changed, 327 insertions(+), 578 deletions(-) diff --git a/package/lienol/luci-app-passwall/Makefile b/package/lienol/luci-app-passwall/Makefile index c57ca08c26..81094c77f3 100644 --- a/package/lienol/luci-app-passwall/Makefile +++ b/package/lienol/luci-app-passwall/Makefile @@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-passwall PKG_VERSION:=4 -PKG_RELEASE:=4 -PKG_DATE:=20201221 +PKG_RELEASE:=6 +PKG_DATE:=20210104 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) @@ -136,10 +136,6 @@ define Package/$(PKG_NAME)/conffiles /usr/share/passwall/rules/direct_ip /usr/share/passwall/rules/proxy_host /usr/share/passwall/rules/proxy_ip -/usr/share/passwall/rules/proxy_host2 -/usr/share/passwall/rules/proxy_ip2 -/usr/share/passwall/rules/proxy_host3 -/usr/share/passwall/rules/proxy_ip3 endef define Package/$(PKG_NAME)/install diff --git a/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua b/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua index 75b10d9424..e1375137f0 100644 --- a/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua +++ b/package/lienol/luci-app-passwall/luasrc/controller/passwall.lua @@ -135,21 +135,13 @@ end function get_now_use_node() local e = {} - local tcp_node_num = ucic:get(appname, "@global_other[0]", "tcp_node_num") or 1 - e.tcp = tonumber(tcp_node_num) - for i = 1, tcp_node_num, 1 do - local data, code, msg = nixio.fs.readfile("/var/etc/passwall/id/TCP_" .. i) - if data then - e["TCP" .. i] = util.trim(data) - end + local data, code, msg = nixio.fs.readfile("/var/etc/passwall/id/TCP") + if data then + e["TCP"] = util.trim(data) end - local udp_node_num = ucic:get(appname, "@global_other[0]", "udp_node_num") or 1 - e.udp = tonumber(udp_node_num) - for i = 1, udp_node_num, 1 do - local data, code, msg = nixio.fs.readfile("/var/etc/passwall/id/UDP_" .. i) - if data then - e["UDP" .. i] = util.trim(data) - end + local data, code, msg = nixio.fs.readfile("/var/etc/passwall/id/UDP") + if data then + e["UDP"] = util.trim(data) end luci.http.prepare_content("application/json") luci.http.write_json(e) @@ -158,8 +150,7 @@ end function get_redir_log() local proto = luci.http.formvalue("proto") proto = proto:upper() - local index = luci.http.formvalue("index") - local filename = proto .. "_" .. index + local filename = proto if nixio.fs.access("/var/etc/passwall/" .. filename .. ".log") then local content = luci.sys.exec("cat /var/etc/passwall/" .. filename .. ".log") content = content:gsub("\n", "
") @@ -183,19 +174,13 @@ function status() local e = {} e.dns_mode_status = luci.sys.call("netstat -apn | grep ':7913 ' >/dev/null") == 0 e.haproxy_status = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep haproxy >/dev/null", appname)) == 0 - local tcp_node_num = ucic:get(appname, "@global_other[0]", "tcp_node_num") or 1 - for i = 1, tcp_node_num, 1 do - e["kcptun_tcp_node%s_status" % i] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/kcptun' | grep -i 'tcp_%s' >/dev/null", appname, i)) == 0 - e["tcp_node%s_status" % i] = luci.sys.call(string.format("ps -w | grep -v -E 'grep|kcptun' | grep '%s/bin/' | grep -i 'TCP_%s' >/dev/null", appname, i)) == 0 - end + e["kcptun_tcp_node_status"] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/kcptun' | grep -i 'tcp' >/dev/null", appname)) == 0 + e["tcp_node_status"] = luci.sys.call(string.format("ps -w | grep -v -E 'grep|kcptun' | grep '%s/bin/' | grep -i 'TCP' >/dev/null", appname)) == 0 - local udp_node_num = ucic:get(appname, "@global_other[0]", "udp_node_num") or 1 - for i = 1, udp_node_num, 1 do - if (ucic:get(appname, "@global[0]", "udp_node" .. i) or "nil") == "tcp" then - e["udp_node%s_status" % i] = e["tcp_node%s_status" % i] - else - e["udp_node%s_status" % i] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep -i 'UDP_%s' >/dev/null", appname, i)) == 0 - end + if (ucic:get(appname, "@global[0]", "udp_node") or "nil") == "tcp" then + e["udp_node_status"] = e["tcp_node_status"] + else + e["udp_node_status"] = luci.sys.call(string.format("ps -w | grep -v grep | grep '%s/bin/' | grep -i 'UDP' >/dev/null", appname)) == 0 end luci.http.prepare_content("application/json") luci.http.write_json(e) @@ -255,9 +240,8 @@ end function set_node() local protocol = luci.http.formvalue("protocol") - local number = luci.http.formvalue("number") local section = luci.http.formvalue("section") - ucic:set(appname, "@global[0]", protocol .. "_node" .. number, section) + ucic:set(appname, "@global[0]", protocol .. "_node", section) ucic:commit(appname) luci.sys.call("/etc/init.d/passwall restart > /dev/null 2>&1 &") luci.http.redirect(luci.dispatcher.build_url("admin", "services", appname, "log")) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_xray.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_xray.lua index 7759a0a7c0..63d823a3ab 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_xray.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/api/gen_xray.lua @@ -155,6 +155,7 @@ function gen_outbound(node, tag, relay_port) address = node.address, port = tonumber(node.port), method = node.method or nil, + flow = node.flow or nil, password = node.password or "", users = (node.username and node.password) and {{user = node.username, pass = node.password}} or nil diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/acl.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/acl.lua index 78fc29f06c..d700d457d2 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/acl.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/acl.lua @@ -40,20 +40,6 @@ o = s:option(Value, "mac", translate("MAC")) o.rmempty = true sys.net.mac_hints(function(e, t) o:value(e, "%s (%s)" % {e, t}) end) ----- TCP Node -local tcp_node_num = m:get("@global_other[0]", "tcp_node_num") or 1 -if tonumber(tcp_node_num) > 1 then - o = s:option(ListValue, "tcp_node", translate("TCP Node")) - for i = 1, tcp_node_num, 1 do o:value(i, "TCP_" .. i) end -end - ----- UDP Node -local udp_node_num = m:get("@global_other[0]", "udp_node_num") or 1 -if tonumber(udp_node_num) > 1 then - o = s:option(ListValue, "udp_node", translate("UDP Node")) - for i = 1, udp_node_num, 1 do o:value(i, "UDP_" .. i) end -end - ---- TCP Proxy Mode o = s:option(ListValue, "tcp_proxy_mode", "TCP" .. translate("Proxy Mode")) o.default = "default" diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua index e9baecd5ec..e17aa025d8 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/auto_switch.lua @@ -25,22 +25,16 @@ o.rmempty = false o = s:option(Value, "testing_time", translate("How often is a diagnosis made"), translate("Units:minutes")) o.default = "3" ----- TCP Node --- local tcp_node_num = tonumber(m:get("@global_other[0]", "tcp_node_num") or 1) --- 暂时只支持TCP1 -local tcp_node_num = 1 -for i = 1, tcp_node_num, 1 do - o = s:option(ListValue, "tcp_main" .. i, "TCP " .. i .. " " .. translate("Main node")) - for k, v in pairs(nodes_table) do - o:value(v.id, v.remarks) - end +o = s:option(ListValue, "tcp_main", "TCP " .. translate("Main node")) +for k, v in pairs(nodes_table) do + o:value(v.id, v.remarks) +end - o = s:option(DynamicList, "tcp_node" .. i, "TCP " .. i .. " " .. translate("List of backup nodes")) - for k, v in pairs(nodes_table) do - o:value(v.id, v.remarks) - end - - o = s:option(Flag, "restore_switch" .. i, "TCP " .. i .. " " .. translate("Restore Switch"), translate("When detects main node is available, switch back to the main node.")) +o = s:option(DynamicList, "tcp_node", "TCP " .. translate("List of backup nodes")) +for k, v in pairs(nodes_table) do + o:value(v.id, v.remarks) end +o = s:option(Flag, "restore_switch", "TCP " .. translate("Restore Switch"), translate("When detects main node is available, switch back to the main node.")) + return m diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua index 27990677d6..24236c0d61 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/global.lua @@ -74,62 +74,51 @@ o = s:taboption("Main", Flag, "enabled", translate("Main switch")) o.rmempty = false ---- TCP Node -local tcp_node_num = tonumber(m:get("@global_other[0]", "tcp_node_num") or 1) -for i = 1, tcp_node_num, 1 do - o = s:taboption("Main", ListValue, "tcp_node" .. i, translate("TCP Node") .. " " .. i) - if i == 1 then - o.title = translate("TCP Node") - o.description = "" - --o.description = translate("For proxy specific list.") - --o.description = o.description .. "
" - local current_node = luci.sys.exec(string.format("[ -f '/var/etc/%s/id/TCP_%s' ] && echo -n $(cat /var/etc/%s/id/TCP_%s)", appname, i, appname, i)) - if current_node and current_node ~= "" and current_node ~= "nil" then - local n = uci:get_all(appname, current_node) - if n then - if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then - local remarks = api.get_full_node_remarks(n) - local url = d.build_url("admin", "services", appname, "node_config", current_node) - o.description = o.description .. translatef("Current node: %s", string.format('%s', url, remarks)) .. "
" - end - if n.protocol and n.protocol == "_shunt" then - uci:foreach(appname, "shunt_rules", function(e) - local id = e[".name"] - local remarks = translate(e.remarks) - if n[id] and n[id] ~= "nil" then - local url = d.build_url("admin", "services", appname, "node_config", n[id]) - local r = api.get_full_node_remarks(uci:get_all(appname, n[id])) - o.description = o.description .. remarks .. ":" .. string.format('%s', url, r) .. "
" - end - end) - local id = "default_node" - local remarks = translate("Default") - if n[id] and n[id] ~= "nil" then - local url = d.build_url("admin", "services", appname, "node_config", n[id]) - local r = api.get_full_node_remarks(uci:get_all(appname, n[id])) - o.description = o.description .. remarks .. ":" .. string.format('%s', url, r) .. "
" - end +o = s:taboption("Main", ListValue, "tcp_node", translate("TCP Node")) +o.title = translate("TCP Node") +o.description = "" +--o.description = translate("For proxy specific list.") +--o.description = o.description .. "
" +local current_node = luci.sys.exec(string.format("[ -f '/var/etc/%s/id/TCP' ] && echo -n $(cat /var/etc/%s/id/TCP)", appname, appname)) +if current_node and current_node ~= "" and current_node ~= "nil" then + local n = uci:get_all(appname, current_node) + if n then + if tonumber(m:get("@auto_switch[0]", "enable") or 0) == 1 then + local remarks = api.get_full_node_remarks(n) + local url = d.build_url("admin", "services", appname, "node_config", current_node) + o.description = o.description .. translatef("Current node: %s", string.format('%s', url, remarks)) .. "
" + end + if n.protocol and n.protocol == "_shunt" then + uci:foreach(appname, "shunt_rules", function(e) + local id = e[".name"] + local remarks = translate(e.remarks) + if n[id] and n[id] ~= "nil" then + local url = d.build_url("admin", "services", appname, "node_config", n[id]) + local r = api.get_full_node_remarks(uci:get_all(appname, n[id])) + o.description = o.description .. remarks .. ":" .. string.format('%s', url, r) .. "
" end + end) + local id = "default_node" + local remarks = translate("Default") + if n[id] and n[id] ~= "nil" then + local url = d.build_url("admin", "services", appname, "node_config", n[id]) + local r = api.get_full_node_remarks(uci:get_all(appname, n[id])) + o.description = o.description .. remarks .. ":" .. string.format('%s', url, r) .. "
" end end end - o:value("nil", translate("Close")) - for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end end +o:value("nil", translate("Close")) +for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end ----- UDP Node -local udp_node_num = tonumber(m:get("@global_other[0]", "udp_node_num") or 1) -for i = 1, udp_node_num, 1 do - o = s:taboption("Main", ListValue, "udp_node" .. i, translate("UDP Node") .. " " .. i) - o:value("nil", translate("Close")) - if i == 1 then - o.title = translate("UDP Node") - --o.description = translate("For proxy game network, DNS hijack etc.") .. "
" .. translate("The selected server will not use Kcptun.") - o:value("tcp_", translate("Same as the tcp node")) - --o:value("tcp", translate("Same as the tcp node")) - --o:value("tcp_", translate("Same as the tcp node") .. "(" .. translate("New process") .. ")") - end - for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end -end +o = s:taboption("Main", ListValue, "udp_node", translate("UDP Node")) +o:value("nil", translate("Close")) +o.title = translate("UDP Node") +--o.description = translate("For proxy game network, DNS hijack etc.") .. "
" .. translate("The selected server will not use Kcptun.") +o:value("tcp_", translate("Same as the tcp node")) +--o:value("tcp", translate("Same as the tcp node")) +--o:value("tcp_", translate("Same as the tcp node") .. "(" .. translate("New process") .. ")") +for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end s:tab("DNS", translate("DNS")) @@ -306,14 +295,12 @@ o.default = "default" o.rmempty = false s:tab("log", translate("Log")) -for i = 1, tcp_node_num, 1 do - o = s:taboption("log", Flag, "close_log_tcp_" .. i , translate("Close") .. translate("Log") .. " " .. translate("TCP Node") .. " " .. i) - o.rmempty = false -end -for i = 1, udp_node_num, 1 do - o = s:taboption("log", Flag, "close_log_udp_" .. i, translate("Close") .. translate("Log") .. " " .. translate("UDP Node") .. " " .. i) - o.rmempty = false -end +o = s:taboption("log", Flag, "close_log_tcp", translate("Close") .. translate("Log") .. " " .. translate("TCP Node")) +o.rmempty = false + +o = s:taboption("log", Flag, "close_log_udp", translate("Close") .. translate("Log") .. " " .. translate("UDP Node")) +o.rmempty = false + loglevel = s:taboption("log", ListValue, "loglevel", "X/V2ray" .. translate("Log Level")) loglevel.default = "warning" loglevel:value("debug") @@ -355,10 +342,7 @@ o.default = 1 o.rmempty = false o = s:option(ListValue, "node", translate("Socks Node")) -local tcp_node_num = tonumber(m:get("@global_other[0]", "tcp_node_num") or 1) -for i = 1, tcp_node_num, 1 do - o:value("tcp" .. i, translatef("Same as the tcp %s node", i)) -end +o:value("tcp", translate("Same as the tcp node")) for k, v in pairs(nodes_table) do o:value(v.id, v.remarks) end o = s:option(Value, "port", "Socks" .. translate("Listen Port")) diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua index 02c785f935..f11d3f3cf1 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/node_config.lua @@ -454,8 +454,10 @@ tls:depends("type", "Trojan-Go") xtls = s:option(Flag, "xtls", translate("XTLS")) xtls.default = 0 xtls:depends({ type = "Xray", protocol = "vless", tls = "1" }) +xtls:depends({ type = "Xray", protocol = "trojan", tls = "1" }) flow = s:option(Value, "flow", translate("flow")) +flow.default = "xtls-rprx-direct" flow:value("xtls-rprx-origin") flow:value("xtls-rprx-origin-udp443") flow:value("xtls-rprx-direct") diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua index e9eddc103b..d7efef2c21 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/other.lua @@ -121,29 +121,10 @@ o.rmempty = true --]] -- [[ Other Settings ]]-- -s = m:section(TypedSection, "global_other", translate("Other Settings"), - "" .. translatef( - "You can only set up a maximum of %s nodes for the time being, Used for access control.", - "3") .. "") +s = m:section(TypedSection, "global_other", translate("Other Settings")) s.anonymous = true s.addremove = false ----- TCP Node Number Option -o = s:option(ListValue, "tcp_node_num", "TCP" .. translate("Node Number")) -o.default = "1" -o.rmempty = false -o:value("1") -o:value("2") -o:value("3") - ----- UDP Node Number Option -o = s:option(ListValue, "udp_node_num", "UDP" .. translate("Node Number")) -o.default = "1" -o.rmempty = false -o:value("1") -o:value("2") -o:value("3") - o = s:option(MultiValue, "status", translate("Status info")) o:value("big_icon", translate("Big icon")) -- 大图标 o:value("show_check_port", translate("Show node check")) -- 显示节点检测 diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua index bf95912e54..d6bb806ea9 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/client/rule_list.lua @@ -17,7 +17,7 @@ s:tab("proxy_list3", translate("Proxy List") .. " 3") ---- Direct Hosts local direct_host = string.format("/usr/share/%s/rules/direct_host", appname) -o = s:taboption("direct_list", TextValue, "direct_hosts", "", "" .. translate("Join the direct hosts list of domain names will not proxy.") .. "") +o = s:taboption("direct_list", TextValue, "direct_host", "", "" .. translate("Join the direct hosts list of domain names will not proxy.") .. "") o.rows = 15 o.wrap = "off" o.cfgvalue = function(self, section) return fs.readfile(direct_host) or "" end @@ -91,80 +91,4 @@ o.validate = function(self, value) return value end ----- Proxy Hosts 2 -local proxy_host2 = string.format("/usr/share/%s/rules/proxy_host2", appname) -o = s:taboption("proxy_list2", TextValue, "proxy_host2", "", "" .. translate("These had been joined websites will use proxy. Please input the domain names of websites,every line can input only one website domain. For example: google.com.") .. "") -o.rows = 15 -o.wrap = "off" -o.cfgvalue = function(self, section) return fs.readfile(proxy_host2) or "" end -o.write = function(self, section, value) fs.writefile(proxy_host2, value:gsub("\r\n", "\n")) end -o.remove = function(self, section, value) fs.writefile(proxy_host2, "") end -o.validate = function(self, value) - local hosts= {} - string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(hosts, w) end) - for index, host in ipairs(hosts) do - if not datatypes.hostname(host) then - return nil, host .. " " .. translate("Not valid domain name, please re-enter!") - end - end - return value -end - ----- Proxy IP 2 -local proxy_ip2 = string.format("/usr/share/%s/rules/proxy_ip2", appname) -o = s:taboption("proxy_list2", TextValue, "blacklist_ip2", "", "" .. translate("These had been joined ip addresses will use proxy.Please input the ip address or ip address segment,every line can input only one ip address.For example: 35.24.0.0/24 or 8.8.4.4.") .. "") -o.rows = 15 -o.wrap = "off" -o.cfgvalue = function(self, section) return fs.readfile(proxy_ip2) or "" end -o.write = function(self, section, value) fs.writefile(proxy_ip2, value:gsub("\r\n", "\n")) end -o.remove = function(self, section, value) fs.writefile(proxy_ip2, "") end -o.validate = function(self, value) - local ipmasks= {} - string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(ipmasks, w) end) - for index, ipmask in ipairs(ipmasks) do - if not datatypes.ipmask4(ipmask) then - return nil, ipmask .. " " .. translate("Not valid IP format, please re-enter!") - end - end - return value -end - ----- Proxy Hosts 3 -local proxy_host3 = string.format("/usr/share/%s/rules/proxy_host3", appname) -o = s:taboption("proxy_list3", TextValue, "proxy_host3", "", "" .. translate("These had been joined websites will use proxy. Please input the domain names of websites,every line can input only one website domain. For example: google.com.") .. "") -o.rows = 15 -o.wrap = "off" -o.cfgvalue = function(self, section) return fs.readfile(proxy_host3) or "" end -o.write = function(self, section, value) fs.writefile(proxy_host3, value:gsub("\r\n", "\n")) end -o.remove = function(self, section, value) fs.writefile(proxy_host3, "") end -o.validate = function(self, value) - local hosts= {} - string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(hosts, w) end) - for index, host in ipairs(hosts) do - if not datatypes.hostname(host) then - return nil, host .. " " .. translate("Not valid domain name, please re-enter!") - end - end - return value -end - ----- Proxy IP 3 -local proxy_ip3 = string.format("/usr/share/%s/rules/proxy_ip3", appname) -o = s:taboption("proxy_list3", TextValue, "blacklist_ip3", "", "" .. translate("These had been joined ip addresses will use proxy.Please input the ip address or ip address segment,every line can input only one ip address.For example: 35.24.0.0/24 or 8.8.4.4.") .. "") -o.rows = 15 -o.wrap = "off" -o.cfgvalue = function(self, section) return fs.readfile(proxy_ip3) or "" end -o.write = function(self, section, value) fs.writefile(proxy_ip3, value:gsub("\r\n", "\n")) end -o.remove = function(self, section, value) fs.writefile(proxy_ip3, "") end -o.validate = function(self, value) - local ipmasks= {} - string.gsub(value, '[^' .. "\r\n" .. ']+', function(w) table.insert(ipmasks, w) end) - for index, ipmask in ipairs(ipmasks) do - if not datatypes.ipmask4(ipmask) then - return nil, ipmask .. " " .. translate("Not valid IP format, please re-enter!") - end - end - return value -end - return m diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/xray.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/xray.lua index 4d38285ebf..9c155db14f 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/xray.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/api/xray.lua @@ -58,6 +58,7 @@ function gen_config(user) local clients = {} for i = 1, #user.uuid do clients[i] = { + flow = (user.xtls and user.xtls == "1") and user.flow or nil, password = user.uuid[i], level = tonumber(user.level) } @@ -77,6 +78,31 @@ function gen_config(user) } end + if user.fallback and user.fallback == "1" then + local fallbacks = {} + for i = 1, #user.fallback_list do + local fallbackStr = user.fallback_list[i] + if fallbackStr then + local tmp = {} + string.gsub(fallbackStr, '[^' .. "," .. ']+', function(w) + table.insert(tmp, w) + end) + local dest = tmp[1] or "" + local path = tmp[2] + if dest:find("%.") then + else + dest = tonumber(dest) + end + fallbacks[i] = { + path = path, + dest = dest, + xver = 1 + } + end + end + settings.fallbacks = fallbacks + end + routing = { domainStrategy = "IPOnDemand", rules = { @@ -110,7 +136,7 @@ function gen_config(user) network = user.transport, security = "none", xtlsSettings = (user.tls and user.tls == "1" and user.xtls and user.xtls == "1") and { - --alpn = {"http/1.1"}, + alpn = {"http/1.1"}, disableSystemRoot = false, certificates = { { @@ -120,6 +146,7 @@ function gen_config(user) } } or nil, tlsSettings = (user.tls and user.tls == "1") and { + alpn = {"http/1.1"}, disableSystemRoot = false, certificates = { { @@ -151,7 +178,7 @@ function gen_config(user) header = {type = user.mkcp_guise} } or nil, wsSettings = (user.transport == "ws") and { - acceptProxyProtocol = false, + acceptProxyProtocol = true, headers = (user.ws_host) and {Host = user.ws_host} or nil, path = user.ws_path } or nil, diff --git a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua index 8d9c6212e8..2efd15eb86 100644 --- a/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua +++ b/package/lienol/luci-app-passwall/luasrc/model/cbi/passwall/server/user.lua @@ -297,6 +297,7 @@ tls:depends({ type = "Xray", protocol = "vmess" }) tls:depends({ type = "Xray", protocol = "vless" }) tls:depends({ type = "Xray", protocol = "socks" }) tls:depends({ type = "Xray", protocol = "shadowsocks" }) +tls:depends({ type = "Xray", protocol = "trojan" }) tls:depends({ type = "V2ray", protocol = "vmess" }) tls:depends({ type = "V2ray", protocol = "vless" }) tls:depends({ type = "V2ray", protocol = "socks" }) @@ -308,15 +309,14 @@ tls:depends("type", "Trojan-Go") xtls = s:option(Flag, "xtls", translate("XTLS")) xtls.default = 0 xtls:depends({ type = "Xray", protocol = "vless", tls = "1" }) +xtls:depends({ type = "Xray", protocol = "trojan", tls = "1" }) flow = s:option(Value, "flow", translate("flow")) -flow.default = "xtls-rprx-origin" +flow.default = "xtls-rprx-direct" flow:value("xtls-rprx-origin") flow:value("xtls-rprx-origin-udp443") flow:value("xtls-rprx-direct") flow:value("xtls-rprx-direct-udp443") -flow:value("xtls-rprx-splice") -flow:value("xtls-rprx-splice-udp443") flow:depends("xtls", "1") -- [[ TLS部分 ]] -- @@ -330,7 +330,7 @@ tls_allowInsecure:depends({ type = "Trojan-Go", tls = "1" }) tls_serverName = s:option(Value, "tls_serverName", translate("Domain")) tls_serverName:depends("tls", "1") -tls_certificateFile = s:option(Value, "tls_certificateFile", translate("Public key absolute path"), translate("as:") .. "/etc/ssl/fullchain.pem") +tls_certificateFile = s:option(FileUpload, "tls_certificateFile", translate("Public key absolute path"), translate("as:") .. "/etc/ssl/fullchain.pem") tls_certificateFile.validate = function(self, value, t) if value and value ~= "" then if not nixio.fs.access(value) then @@ -341,9 +341,10 @@ tls_certificateFile.validate = function(self, value, t) end return nil end +tls_certificateFile.default = "/etc/config/ssl/" .. arg[1] .. ".pem" tls_certificateFile:depends("tls", "1") -tls_keyFile = s:option(Value, "tls_keyFile", translate("Private key absolute path"), translate("as:") .. "/etc/ssl/private.key") +tls_keyFile = s:option(FileUpload, "tls_keyFile", translate("Private key absolute path"), translate("as:") .. "/etc/ssl/private.key") tls_keyFile.validate = function(self, value, t) if value and value ~= "" then if not nixio.fs.access(value) then @@ -354,6 +355,7 @@ tls_keyFile.validate = function(self, value, t) end return nil end +tls_keyFile.default = "/etc/config/ssl/" .. arg[1] .. ".key" tls_keyFile:depends("tls", "1") tls_sessionTicket = s:option(Flag, "tls_sessionTicket", translate("Session Ticket")) @@ -509,12 +511,14 @@ quic_guise = s:option(ListValue, "quic_guise", translate("Camouflage Type")) for a, t in ipairs(header_type_list) do quic_guise:value(t) end quic_guise:depends("transport", "quic") --- [[ VLESS Fallback部分 ]]-- ---[[ +-- [[ Fallback部分 ]]-- fallback = s:option(Flag, "fallback", translate("Fallback")) -fallback:depends({ type = "Xray", protocol = "vless", transport = "tcp", tls = "1" }) -fallback:depends({ type = "V2ray", protocol = "vless", transport = "tcp", tls = "1" }) +fallback:depends({ type = "Xray", protocol = "vless", transport = "tcp" }) +fallback:depends({ type = "Xray", protocol = "trojan", transport = "tcp" }) +fallback:depends({ type = "V2ray", protocol = "vless", transport = "tcp" }) +fallback:depends({ type = "V2ray", protocol = "trojan", transport = "tcp" }) +--[[ fallback_alpn = s:option(Value, "fallback_alpn", "Fallback alpn") fallback_alpn:depends("fallback", "1") @@ -529,6 +533,9 @@ fallback_xver.default = 0 fallback_xver:depends("fallback", "1") ]]-- +fallback_list = s:option(DynamicList, "fallback_list", "Fallback", translate("dest,path")) +fallback_list:depends("fallback", "1") + ss_aead = s:option(Flag, "ss_aead", translate("Shadowsocks2")) ss_aead:depends("type", "Trojan-Go") ss_aead.default = "0" diff --git a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/footer.htm b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/footer.htm index dacce36afa..8e033c92aa 100644 --- a/package/lienol/luci-app-passwall/luasrc/view/passwall/global/footer.htm +++ b/package/lienol/luci-app-passwall/luasrc/view/passwall/global/footer.htm @@ -1,7 +1,5 @@ <% local api = require "luci.model.cbi.passwall.api.api" -local tcp_node_num = api.uci_get_type("global_other", "tcp_node_num", 1) -local udp_node_num = api.uci_get_type("global_other", "udp_node_num", 1) local auto_switch = api.uci_get_type("auto_switch", "enable", 0) -%>